diff --git a/public/manage/general/index.php b/public/manage/general/index.php index 6f31c7a..ba17ac6 100644 --- a/public/manage/general/index.php +++ b/public/manage/general/index.php @@ -163,12 +163,6 @@ $statistics = DB::query(' ) AS `stat_user_warnings` ')->fetch(); -if(!empty($_GET['poll'])) { - header('Content-Type: application/json; charset=utf-8'); - echo json_encode($statistics); - return; -} - Template::render('manage.general.overview', [ 'statistics' => $statistics, ]); diff --git a/src/Changelog/ChangelogChange.php b/src/Changelog/ChangelogChange.php index 7b96a20..a06e60e 100644 --- a/src/Changelog/ChangelogChange.php +++ b/src/Changelog/ChangelogChange.php @@ -1,7 +1,6 @@ $this->getId(), - 'user' => $this->getUserId(), - 'action' => $this->getAction(), - 'header' => $this->getHeader(), - 'body' => $this->getBody(), - 'comments' => $this->getCommentsCategoryName(), - 'created' => ($time = $this->getCreatedTime()) < 0 ? null : date('c', $time), - ]; - } - public function save(): void { $isInsert = $this->getId() < 1; if($isInsert) { diff --git a/src/Changelog/ChangelogChangeTag.php b/src/Changelog/ChangelogChangeTag.php index 9ddf6e6..f092f4c 100644 --- a/src/Changelog/ChangelogChangeTag.php +++ b/src/Changelog/ChangelogChangeTag.php @@ -1,14 +1,13 @@ tag; } - public function jsonSerialize(): mixed { - return [ - 'change' => $this->getChangeId(), - 'tag' => $this->getTagId(), - ]; - } - public static function create(ChangelogChange $change, ChangelogTag $tag, bool $return = false): ?self { $createRelation = DB::prepare( 'REPLACE INTO `' . DB::PREFIX . self::TABLE . '` (`change_id`, `tag_id`)' diff --git a/src/Changelog/ChangelogTag.php b/src/Changelog/ChangelogTag.php index b62e78e..cdca0d6 100644 --- a/src/Changelog/ChangelogTag.php +++ b/src/Changelog/ChangelogTag.php @@ -1,14 +1,13 @@ changeCount; } - public function jsonSerialize(): mixed { - return [ - 'id' => $this->getId(), - 'name' => $this->getName(), - 'description' => $this->getDescription(), - 'created' => ($time = $this->getCreatedTime()) < 0 ? null : date('c', $time), - 'archived' => ($time = $this->getArchivedTime()) < 0 ? null : date('c', $time), - ]; - } - public function compare(ChangelogTag $other): bool { return $other === $this || $other->getId() === $this->getId(); } diff --git a/src/Comments/CommentsCategory.php b/src/Comments/CommentsCategory.php index d7aad4b..165c01b 100644 --- a/src/Comments/CommentsCategory.php +++ b/src/Comments/CommentsCategory.php @@ -1,7 +1,6 @@ postCount; } - public function jsonSerialize(): mixed { - return [ - 'id' => $this->getId(), - 'name' => $this->getName(), - 'created' => ($created = $this->getCreatedTime()) < 0 ? null : date('c', $created), - 'locked' => ($locked = $this->getLockedTime()) < 0 ? null : date('c', $locked), - ]; - } - public function save(): void { $isInsert = $this->getId() < 1; if($isInsert) { diff --git a/src/Comments/CommentsPost.php b/src/Comments/CommentsPost.php index 65847d8..6b82710 100644 --- a/src/Comments/CommentsPost.php +++ b/src/Comments/CommentsPost.php @@ -1,7 +1,6 @@ user_vote ?? 0; } - public function jsonSerialize(): mixed { - $json = [ - 'id' => $this->getId(), - 'category' => $this->getCategoryId(), - 'user' => $this->getUserId(), - 'parent' => ($parent = $this->getParentId()) < 1 ? null : $parent, - 'text' => $this->getText(), - 'created' => ($created = $this->getCreatedTime()) < 0 ? null : date('c', $created), - 'pinned' => ($pinned = $this->getPinnedTime()) < 0 ? null : date('c', $pinned), - 'edited' => ($edited = $this->getEditedTime()) < 0 ? null : date('c', $edited), - 'deleted' => ($deleted = $this->getDeletedTime()) < 0 ? null : date('c', $deleted), - ]; - - if(($likes = $this->getLikes()) >= 0) - $json['likes'] = $likes; - if(($dislikes = $this->getDislikes()) >= 0) - $json['dislikes'] = $dislikes; - - if($this->hasUserVote()) - $json['user_vote'] = $this->getUserVote(); - - return $json; - } - public function save(): void { $isInsert = $this->getId() < 1; if($isInsert) { diff --git a/src/Comments/CommentsVote.php b/src/Comments/CommentsVote.php index 0ab2bd9..947e03d 100644 --- a/src/Comments/CommentsVote.php +++ b/src/Comments/CommentsVote.php @@ -1,7 +1,6 @@ total; } - - public function jsonSerialize(): mixed { - return [ - 'id' => $this->getPostId(), - 'likes' => $this->getLikes(), - 'dislikes' => $this->getDislikes(), - 'total' => $this->getTotal(), - ]; - } } -class CommentsVote implements JsonSerializable { +class CommentsVote { // Database fields private $comment_id = -1; private $user_id = -1; @@ -83,14 +73,6 @@ class CommentsVote implements JsonSerializable { return $this->comment_vote; } - public function jsonSerialize(): mixed { - return [ - 'post' => $this->getPostId(), - 'user' => $this->getUserId(), - 'vote' => $this->getVote(), - ]; - } - public static function create(CommentsPost $post, User $user, int $vote, bool $return = false): ?self { $createVote = DB::prepare(' REPLACE INTO `msz_comments_votes` diff --git a/src/News/NewsCategory.php b/src/News/NewsCategory.php index e2b2925..6bd4087 100644 --- a/src/News/NewsCategory.php +++ b/src/News/NewsCategory.php @@ -2,14 +2,13 @@ namespace Misuzu\News; use ArrayAccess; -use JsonSerializable; use Misuzu\DB; use Misuzu\Pagination; class NewsCategoryException extends NewsException {}; class NewsCategoryNotFoundException extends NewsCategoryException {}; -class NewsCategory implements ArrayAccess, JsonSerializable { +class NewsCategory implements ArrayAccess { // Database fields private $category_id = -1; private $category_name = ''; @@ -58,16 +57,6 @@ class NewsCategory implements ArrayAccess, JsonSerializable { return $this->category_created === null ? -1 : $this->category_created; } - public function jsonSerialize(): mixed { - return [ - 'id' => $this->getId(), - 'name' => $this->getName(), - 'description' => $this->getDescription(), - 'is_hidden' => $this->isHidden(), - 'created' => ($time = $this->getCreatedTime()) < 0 ? null : date('c', $time), - ]; - } - // Purely cosmetic, use ::countAll for pagination public function getPostCount(): int { if($this->postCount < 0) diff --git a/src/News/NewsPost.php b/src/News/NewsPost.php index 17907bc..684fd20 100644 --- a/src/News/NewsPost.php +++ b/src/News/NewsPost.php @@ -1,7 +1,6 @@ $this->getId(), - 'category' => $this->getCategoryId(), - 'user' => $this->getUserId(), - 'comments' => $this->getCommentsCategoryId(), - 'is_featured' => $this->isFeatured(), - 'title' => $this->getTitle(), - 'text' => $this->getText(), - 'scheduled' => ($time = $this->getScheduledTime()) < 0 ? null : date('c', $time), - 'created' => ($time = $this->getCreatedTime()) < 0 ? null : date('c', $time), - 'updated' => ($time = $this->getUpdatedTime()) < 0 ? null : date('c', $time), - 'deleted' => ($time = $this->getDeletedTime()) < 0 ? null : date('c', $time), - ]; - } - public function ensureCommentsCategory(): void { if($this->hasCommentsCategory()) return; diff --git a/src/Users/Assets/UserBackgroundAsset.php b/src/Users/Assets/UserBackgroundAsset.php index 2f1a15a..0cf3acf 100644 --- a/src/Users/Assets/UserBackgroundAsset.php +++ b/src/Users/Assets/UserBackgroundAsset.php @@ -136,12 +136,4 @@ class UserBackgroundAsset extends UserImageAsset { parent::delete(); $this->getUser()->setBackgroundSettings(0); } - - public function jsonSerialize(): mixed { - return array_merge(parent::jsonSerialize(), [ - 'attachment' => $this->getAttachmentString(), - 'is_blend' => $this->isBlend(), - 'is_slide' => $this->isSlide(), - ]); - } } diff --git a/src/Users/Assets/UserImageAsset.php b/src/Users/Assets/UserImageAsset.php index b8358eb..d3a8911 100644 --- a/src/Users/Assets/UserImageAsset.php +++ b/src/Users/Assets/UserImageAsset.php @@ -1,7 +1,6 @@ $this->isPresent(), - 'width' => $this->getWidth(), - 'height' => $this->getHeight(), - 'mime' => $this->getMimeType(), - ]; - } } diff --git a/src/Users/User.php b/src/Users/User.php index 22cd277..6d66897 100644 --- a/src/Users/User.php +++ b/src/Users/User.php @@ -3,7 +3,6 @@ namespace Misuzu\Users; use DateTime; use DateTimeZone; -use JsonSerializable; use Index\XString; use Index\Colour\Colour; use Misuzu\DB; @@ -29,7 +28,7 @@ class UserCreationFailedException extends UserException {} // - Move background settings and about shit to a separate users_profiles table (should birthdate be profile specific?) // - Create a users_stats table containing static counts for things like followers, followings, topics, posts, etc. -class User implements HasRankInterface, JsonSerializable { +class User implements HasRankInterface { public const NAME_MIN_LENGTH = 3; // Minimum username length public const NAME_MAX_LENGTH = 16; // Maximum username length, unless your name is Flappyzor(WorldwideOnline2018through2019through2020) public const NAME_REGEX = '[A-Za-z0-9-_]+'; // Username character constraint @@ -374,26 +373,6 @@ class User implements HasRankInterface, JsonSerializable { return $this->legacyPerms; } - /******** - * JSON * - ********/ - - public function jsonSerialize(): mixed { - return [ - 'id' => $this->getId(), - 'username' => $this->getUsername(), - 'country' => $this->getCountry(), - 'is_super' => $this->isSuper(), - 'rank' => $this->getRank(), - 'display_role' => $this->getDisplayRoleId(), - 'title' => $this->getTitle(), - 'created' => date('c', $this->getCreatedTime()), - 'last_active' => ($date = $this->getActiveTime()) < 0 ? null : date('c', $date), - 'avatar' => $this->getAvatarInfo(), - 'background' => $this->getBackgroundInfo(), - ]; - } - /************ * PASSWORD * ************/ diff --git a/utility.php b/utility.php index 7138443..ff5ba35 100644 --- a/utility.php +++ b/utility.php @@ -1,8 +1,7 @@ 'Kosovo', 'XM' => 'The Moon', + 'XX' => 'Unknown', 'YE' => 'Yemen', 'YT' => 'Mayotte',