diff --git a/_sakura/changelog.json b/_sakura/changelog.json index 1f094ab..2c67551 100644 --- a/_sakura/changelog.json +++ b/_sakura/changelog.json @@ -2764,6 +2764,62 @@ "user": "Flashwave" } + ], + + "20150916": [ + + "eminence", + { + "type": "ADD", + "change": "Begin implementation of new comment system.", + "user": "Flashwave" + }, + { + "type": "UPD", + "change": "Made ajaxPost async.", + "user": "Flashwave" + }, + { + "type": "FIX", + "change": "Fix AJAX submitted forms using a strange behaviour.", + "user": "Flashwave" + }, + { + "type": "REM", + "change": "Removed CORS from the notification system since we're not using subdomains anymore.", + "user": "Flashwave" + }, + { + "type": "FIX", + "change": "Fixed usertitle page having Username as the title.", + "user": "Flashwave" + }, + { + "type": "ADD", + "change": "Added usertitle changing.", + "user": "Flashwave" + }, + { + "type": "ADD", + "change": "Added site closing.", + "user": "Flashwave" + }, + { + "type": "FIX", + "change": "Fixed user class related issues in the forum.", + "user": "Flashwave" + }, + { + "type": "FIX", + "change": "Fixed reference to users class in permissions class.", + "user": "Flashwave" + }, + { + "type": "ADD", + "change": "Added more templates for the settings page.", + "user": "Flashwave" + } + ] } diff --git a/_sakura/components/Forum.php b/_sakura/components/Forum.php index d4a1a9b..c88f7db 100644 --- a/_sakura/components/Forum.php +++ b/_sakura/components/Forum.php @@ -61,12 +61,13 @@ class Forum ], ['post_id', true]); // Add last poster data and the details about the post as well - $return[$forum['forum_category']]['forums'][$forum['forum_id']]['last_poster'] = [ - 'post' => $lastPost, - 'user' => ($_LAST_POSTER = Users::getUser($lastPost['poster_id'])), - 'rank' => Users::getRank($_LAST_POSTER['rank_main']), - 'elap' => Main::timeElapsed($lastPost['post_time']), - ]; + $return[$forum['forum_category']]['forums'][$forum['forum_id']]['last_poster'] = new User($lastPost['poster_id']); + + // Add last poster data and the details about the post as well + $return[$forum['forum_category']]['forums'][$forum['forum_id']]['last_post'] = array_merge( + empty($lastPost) ? [] : $lastPost, + ['elapsed' => Main::timeElapsed($lastPost['post_time'])] + ); } } @@ -120,11 +121,11 @@ class Forum 'forum_id' => [$sub['forum_id'], '='], ], ['post_id', true]); - $forum['forums'][$key]['last_poster'] = [ - 'post' => $lastPost, - 'user' => ($lastPoster = Users::getUser($lastPost['poster_id'])), - 'rank' => Users::getRank($lastPoster['rank_main']), - ]; + $forum['forums'][$key]['last_poster'] = new User($lastPost['poster_id']); + $forum['forums'][$key]['last_post'] = array_merge( + empty($lastPost) ? [] : $lastPost, + ['elapsed' => Main::timeElapsed($lastPost['post_time'])] + ); } // Lastly grab the topics for this forum @@ -156,24 +157,24 @@ class Forum 'topic_id' => [$topic['topic_id'], '='], ]); - $topics[$key]['first_poster'] = [ - 'post' => $firstPost, - 'user' => ($_FIRST_POSTER = Users::getUser($firstPost['poster_id'])), - 'rank' => Users::getRank($_FIRST_POSTER['rank_main']), - 'elap' => Main::timeElapsed($firstPost['post_time']), - ]; + $topics[$key]['first_poster'] = new User($firstPost['poster_id']); + + $topics[$key]['first_post'] = array_merge( + empty($firstPost) ? [] : $firstPost, + ['elapsed' => Main::timeElapsed($firstPost['post_time'])] + ); // Get last post in topics $lastPost = Database::fetch('posts', false, [ 'topic_id' => [$topic['topic_id'], '='], ], ['post_id', true]); - $topics[$key]['last_poster'] = [ - 'post' => $lastPost, - 'user' => ($_LAST_POSTER = Users::getUser($lastPost['poster_id'])), - 'rank' => Users::getRank($_LAST_POSTER['rank_main']), - 'elap' => Main::timeElapsed($lastPost['post_time']), - ]; + $topics[$key]['last_poster'] = new User($lastPost['poster_id']); + + $topics[$key]['last_post'] = array_merge( + empty($lastPost) ? [] : $lastPost, + ['elapsed' => Main::timeElapsed($lastPost['post_time'])] + ); } return $topics; @@ -229,26 +230,24 @@ class Forum 'topic_id' => [$topic['topic']['topic_id'], '='], ]); - // Get the data of the first poster - $topic['topic']['first_poster'] = [ - 'post' => $firstPost, - 'user' => ($_FIRST_POSTER = Users::getUser($firstPost['poster_id'])), - 'rank' => Users::getRank($_FIRST_POSTER['rank_main']), - 'elap' => Main::timeElapsed($firstPost['post_time']), - ]; + $topic['topic']['first_poster'] = new User($firstPost['poster_id']); + + $topic['topic']['first_post'] = array_merge( + empty($firstPost) ? [] : $firstPost, + ['elapsed' => Main::timeElapsed($firstPost['post_time'])] + ); // Get last post in topics $lastPost = Database::fetch('posts', false, [ 'topic_id' => [$topic['topic']['topic_id'], '='], ], ['post_id', true]); - // Get the data of the last poster - $topic['topic']['last_poster'] = [ - 'post' => $lastPost, - 'user' => ($_LAST_POSTER = Users::getUser($lastPost['poster_id'])), - 'rank' => Users::getRank($_LAST_POSTER['rank_main']), - 'elap' => Main::timeElapsed($lastPost['post_time']), - ]; + $topic['topic']['last_poster'] = new User($lastPost['poster_id']); + + $topic['topic']['last_post'] = array_merge( + empty($lastPost) ? [] : $lastPost, + ['elapsed' => Main::timeElapsed($lastPost['post_time'])] + ); // Create space for posts $topic['posts'] = []; @@ -257,14 +256,9 @@ class Forum foreach ($rawPosts as $post) { // Add post and metadata to the global storage array $topic['posts'][$post['post_id']] = array_merge($post, [ + 'user' => (new User($post['poster_id'])), + 'elapsed' => Main::timeElapsed($post['post_time']), 'is_op' => ($post['poster_id'] == $firstPost['poster_id'] ? '1' : '0'), - 'user' => ($_POSTER = Users::getUser($post['poster_id'])), - 'rank' => Users::getRank($_POSTER['rank_main']), - 'time_elapsed' => Main::timeElapsed($post['post_time']), - 'country' => Main::getCountryName($_POSTER['country']), - 'is_premium' => Users::checkUserPremium($_POSTER['id'])[0], - 'is_online' => Users::checkUserOnline($_POSTER['id']), - 'is_friend' => Users::checkFriend($_POSTER['id']), 'parsed_post' => self::parseMarkUp($post['post_text'], $post['parse_mode'], $post['enable_emotes']), 'signature' => empty($_POSTER['userData']['signature']) ? '' : diff --git a/_sakura/components/Permissions.php b/_sakura/components/Permissions.php index d6703c9..98fd2ad 100644 --- a/_sakura/components/Permissions.php +++ b/_sakura/components/Permissions.php @@ -150,13 +150,13 @@ class Permissions { // Get user data - $user = Users::getUser($uid); + $user = new User($uid); // Attempt to get the permission row of a user - $userPerms = Database::fetch('permissions', false, ['rid' => [0, '='], 'uid' => [$user['id'], '=']]); + $userPerms = Database::fetch('permissions', false, ['rid' => [0, '='], 'uid' => [$user->data['id'], '=']]); // Get their rank permissions - $rankPerms = self::getRankPermissions(json_decode($user['ranks'], true)); + $rankPerms = self::getRankPermissions(json_decode($user->data['ranks'], true)); // Just return the rank permissions if no special ones are set if (empty($userPerms)) { diff --git a/_sakura/components/Users.php b/_sakura/components/Users.php index 794cf92..3329524 100644 --- a/_sakura/components/Users.php +++ b/_sakura/components/Users.php @@ -1508,7 +1508,7 @@ class Users ]); // Return true because yay - return [1, Users::checkFriend($uid) == 2 ? 'FRIENDS' : 'NOT_MUTUAL']; + return [1, self::checkFriend($uid) == 2 ? 'FRIENDS' : 'NOT_MUTUAL']; } diff --git a/_sakura/sakura.php b/_sakura/sakura.php index 9265645..f090d2d 100644 --- a/_sakura/sakura.php +++ b/_sakura/sakura.php @@ -8,7 +8,7 @@ namespace Sakura; // Define Sakura version -define('SAKURA_VERSION', '20150915'); +define('SAKURA_VERSION', '20150916'); define('SAKURA_VLABEL', 'Eminence'); define('SAKURA_COLOUR', '#6C3082'); define('SAKURA_STABLE', false); @@ -157,8 +157,6 @@ if (!defined('SAKURA_NO_TPL')) { 'recaptchaEnabled' => Configuration::getConfig('recaptcha'), 'disableRegistration' => Configuration::getConfig('disable_registration'), - 'lockSite' => Configuration::getConfig('lock_site'), - 'lockSiteReason' => Configuration::getConfig('lock_site_reason'), 'lockAuth' => Configuration::getConfig('lock_authentication'), 'requireRegCodes' => Configuration::getConfig('require_registration_code'), 'requireActivation' => Configuration::getConfig('require_activation'), @@ -189,6 +187,21 @@ if (!defined('SAKURA_NO_TPL')) { ]; + // Site closing + if (Configuration::getConfig('site_closed')) { + // Additional render data + $renderData = array_merge($renderData, [ + + 'page' => [ + 'message' => Configuration::getConfig('site_closed_reason'), + ], + + ]); + + print Templates::render('global/information.tpl', $renderData); + exit; + } + // Ban checking if (Users::checkLogin() && $ban = Bans::checkBan(Session::$userId)) { // Additional render data diff --git a/_sakura/templates/yuuno/elements/comments.tpl b/_sakura/templates/yuuno/elements/comments.tpl index 2d93474..da0c10d 100644 --- a/_sakura/templates/yuuno/elements/comments.tpl +++ b/_sakura/templates/yuuno/elements/comments.tpl @@ -1,19 +1,19 @@
Log in to comment!
+Log in to comment!
{% endif %}+- Report
+ - Delete
+ - Reply
+ - 1
+ - 1
+
+ +@@ -31,8 +43,19 @@
-
- aaaaaaaaaa
+
+
+
+
+ aaaaaaaaaa
+
+- Report
+ - Delete
+ - Reply
+ - 1
+ - 1
+
+@@ -40,8 +63,19 @@
-
- aaaaaaaaaa
+
+
+
+
+ aaaaaaaaaa
+
+- Report
+ - Delete
+ - Reply
+ - 1
+ - 1
+
+@@ -49,8 +83,19 @@
-
- aaaaaaaaaa
+
+
+
+
+ aaaaaaaaaa
+
@@ -60,8 +105,19 @@
-
- aaaaaaaaaa
+
+
+
+
+ aaaaaaaaaa
+
@@ -71,8 +127,19 @@
-
- aaaaaaaaaa
+
+
+
+
+ aaaaaaaaaa
+
@@ -81,3 +148,10 @@
+
diff --git a/_sakura/templates/yuuno/forum/forumEntry.tpl b/_sakura/templates/yuuno/forum/forumEntry.tpl
index 021417e..0af6da8 100644
--- a/_sakura/templates/yuuno/forum/forumEntry.tpl
+++ b/_sakura/templates/yuuno/forum/forumEntry.tpl
@@ -28,8 +28,8 @@
- {% if forum.last_poster.user.id %}
- {{ forum.last_poster.post.post_subject }}
- {% if topic.first_poster.user.id %}
- {{ topic.first_poster.user.username }}
+ {% if topic.first_poster.data.id %}
+ {{ topic.first_poster.data.username }}
{% else %}
[deleted user]
{% endif %}
@@ -17,11 +17,11 @@
{{ topic.topic_views }}
- {% if topic.last_poster.user.id %}
- {{ topic.last_poster.user.username }}
+ {% if topic.last_poster.data.id %}
+ {{ topic.last_poster.data.username }}
{% else %}
[deleted user]
- {% endif %}
diff --git a/_sakura/templates/yuuno/forum/viewtopic.tpl b/_sakura/templates/yuuno/forum/viewtopic.tpl
index e4cecdd..6a449a7 100644
--- a/_sakura/templates/yuuno/forum/viewtopic.tpl
+++ b/_sakura/templates/yuuno/forum/viewtopic.tpl
@@ -11,23 +11,25 @@
{% for post in posts %}
- {% if post.user.rank_main > 1 %}{{ post.user.username }}
-
+ {% if not post.user.checkPermission('SITE', 'DEACTIVATED') or post.user.checkPermission('SITE', 'RESTRICTED') %}{{ post.user.data.username }}
+
{% else %}
[deleted user]
{% endif %}
{% if not post.user.usertitle %}{{ post.rank.title }}{% else %}{{ post.user.usertitle }}{% endif %}
-
+
{% if session.checkLogin %}
- {% if user.data.id == post.user.id %}
-
-
- {% elseif post.user.rank_main > 1 %}
- {% if post.is_friend != 0 %}{% endif %}
-
-
+ {% if user.data.id == post.user.data.id %}
+
+
+ {% elseif not post.user.checkPermission('SITE', 'DEACTIVATED') or post.user.checkPermission('SITE', 'RESTRICTED') %}
+ {% if post.user.checkFriends(user.data.id) != 0 %}
+
+ {% endif %}
+
+
{% endif %}
@@ -40,7 +42,7 @@
{{ post.post_subject }}
- {{ post.time_elapsed }}
+ {{ post.elapsed }}
diff --git a/_sakura/templates/yuuno/global/master.tpl b/_sakura/templates/yuuno/global/master.tpl
index 63bd109..916fa92 100644
--- a/_sakura/templates/yuuno/global/master.tpl
+++ b/_sakura/templates/yuuno/global/master.tpl
@@ -72,17 +72,7 @@
prepareAjaxLink('headerLogoutLink', 'submitPost', ', true, "Logging out..."');
{% elseif not sakura.lockAuth and php.self != '/authenticate.php' %}
// Make the header login form dynamic
- var headerLoginForm = document.getElementById('headerLoginForm');
- var createInput = document.createElement('input');
- var submit = headerLoginForm.querySelector('[type="submit"]');
-
- createInput.setAttribute('name', 'ajax');
- createInput.setAttribute('value', 'true');
- createInput.setAttribute('type', 'hidden');
- headerLoginForm.appendChild(createInput);
-
- submit.setAttribute('type', 'button');
- submit.setAttribute('onclick', 'submitPost(\''+ headerLoginForm.action +'\', formToObject(\'headerLoginForm\'), true, \'Logging in...\');');
+ prepareAjaxForm('headerLoginForm', 'Logging in...');
{% endif %}
{% if session.checkLogin %}
@@ -127,20 +117,7 @@
};
for(var i in forms) {
- var form = document.getElementById(i);
- var submit = form.querySelector('[type="submit"]');
-
- form.setAttribute('onkeydown', 'formEnterCatch(event, \''+ submit.id +'\');');
-
- submit.setAttribute('href', 'javascript:void(0);');
- submit.setAttribute('onclick', 'submitPost(\''+ form.action +'\', formToObject(\''+ i+ '\'), true, \''+ forms[i] +'\', '+ (i == 'registerForm' ? 'true' : 'false') +');');
- submit.setAttribute('type', 'button');
-
- var createInput = document.createElement('input');
- createInput.setAttribute('name', 'ajax');
- createInput.setAttribute('value', 'true');
- createInput.setAttribute('type', 'hidden');
- form.appendChild(createInput);
+ prepareAjaxForm(i, forms[i], (i == 'registerForm'));
}
{% endif %}
@@ -210,7 +187,7 @@
{% endif %}
{% if not session.checkLogin and php.self != '/authenticate.php' %}
-
+- Report
+ - Delete
+ - Reply
+ - 1
+ - 1
+
++- Report
+ - Delete
+ - Reply
+ - 1
+ - 1
+
++- Report
+ - Delete
+ - Reply
+ - 1
+ - 1
+
+{{ forum.last_poster.elap }} by {% if forum.last_poster.user.id %}{{ forum.last_poster.user.username }}{% else %}[deleted user]{% endif %} + {% if forum.last_post.post_id %} + {{ forum.last_post.post_subject }}
{{ forum.last_post.elapsed }} by {% if forum.last_poster.data.id %}{{ forum.last_poster.data.username }}{% else %}[deleted user]{% endif %} {% else %} There are no posts in this forum.
{% endif %} diff --git a/_sakura/templates/yuuno/forum/topicEntry.tpl b/_sakura/templates/yuuno/forum/topicEntry.tpl index 8c1ea59..7b51cb0 100644 --- a/_sakura/templates/yuuno/forum/topicEntry.tpl +++ b/_sakura/templates/yuuno/forum/topicEntry.tpl @@ -6,8 +6,8 @@ {{ topic.topic_title }}
- {{ topic.last_poster.elap }} + {% endif %}
+ {{ topic.last_post.elapsed }}