From 430e8ffa8234f2925e02638563abf80a86ff9621 Mon Sep 17 00:00:00 2001 From: flashwave Date: Wed, 16 Sep 2015 22:34:36 +0200 Subject: [PATCH] r20150916 --- _sakura/changelog.json | 56 +++++++++ _sakura/components/Forum.php | 82 ++++++------ _sakura/components/Permissions.php | 6 +- _sakura/components/Users.php | 2 +- _sakura/sakura.php | 19 ++- _sakura/templates/yuuno/elements/comments.tpl | 104 ++++++++++++--- _sakura/templates/yuuno/forum/forumEntry.tpl | 4 +- _sakura/templates/yuuno/forum/topicEntry.tpl | 12 +- _sakura/templates/yuuno/forum/viewtopic.tpl | 24 ++-- _sakura/templates/yuuno/global/master.tpl | 29 +---- _sakura/templates/yuuno/main/news.tpl | 4 +- .../yuuno/settings/account.email.tpl | 25 ++++ .../yuuno/settings/account.password.tpl | 28 +++++ .../yuuno/settings/account.username.tpl | 30 +++++ .../yuuno/settings/account.usertitle.tpl | 21 ++++ .../yuuno/settings/general.groups.tpl | 0 .../yuuno/settings/general.options.tpl | 10 +- .../yuuno/settings/general.profile.tpl | 10 +- public/content/data/yuuno/css/yuuno.css | 56 ++++++--- public/content/data/yuuno/js/yuuno.js | 119 ++++++++++++------ public/settings.php | 68 ++++++++-- 21 files changed, 519 insertions(+), 190 deletions(-) delete mode 100644 _sakura/templates/yuuno/settings/general.groups.tpl 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 @@
{% if session.checkLogin %} -
+
- +
{% else %} -

Log in to comment!

+

Log in to comment!

{% endif %}
@@ -22,8 +22,20 @@
-
- aaaaaaaaaa +
+
+
    +
  • Report
  • +
  • Delete
  • +
  • Reply
  • +
  • 1
  • +
  • 1
  • +
+
+
+
+ aaaaaaaaaa +
    @@ -31,8 +43,19 @@
    -
    - aaaaaaaaaa +
    +
    +
      +
    • Report
    • +
    • Delete
    • +
    • Reply
    • +
    • 1
    • +
    • 1
    • +
    +
    +
    + aaaaaaaaaa +
      @@ -40,8 +63,19 @@
      -
      - aaaaaaaaaa +
      +
      +
        +
      • Report
      • +
      • Delete
      • +
      • Reply
      • +
      • 1
      • +
      • 1
      • +
      +
      +
      + aaaaaaaaaa +
        @@ -49,8 +83,19 @@
        -
        - aaaaaaaaaa +
        +
        +
          +
        • Report
        • +
        • Delete
        • +
        • Reply
        • +
        • 1
        • +
        • 1
        • +
        +
        +
        + aaaaaaaaaa +
        @@ -60,8 +105,19 @@
        -
        - aaaaaaaaaa +
        +
        +
          +
        • Report
        • +
        • Delete
        • +
        • Reply
        • +
        • 1
        • +
        • 1
        • +
        +
        +
        + aaaaaaaaaa +
        @@ -71,8 +127,19 @@
        -
        - aaaaaaaaaa +
        +
        +
          +
        • Report
        • +
        • Delete
        • +
        • Reply
        • +
        • 1
        • +
        • 1
        • +
        +
        +
        + 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 }}
    {{ 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 }} - {% 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 %}
    - {{ topic.last_poster.elap }} + {% endif %}
    + {{ topic.last_post.elapsed }} 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 }} - {{ post.user.username }} + {% if not post.user.checkPermission('SITE', 'DEACTIVATED') or post.user.checkPermission('SITE', 'RESTRICTED') %}{{ post.user.data.username }} + {{ post.user.data.username }} {% else %} [deleted user] {% endif %}
    {% if not post.user.usertitle %}{{ post.rank.title }}{% else %}{{ post.user.usertitle }}{% endif %}
    - Tenshi {{ post.country }} + Tenshi {{ post.user.country.long }} {% 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 }}
    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' %} -
    + diff --git a/_sakura/templates/yuuno/main/news.tpl b/_sakura/templates/yuuno/main/news.tpl index acf25a5..b65587c 100644 --- a/_sakura/templates/yuuno/main/news.tpl +++ b/_sakura/templates/yuuno/main/news.tpl @@ -32,7 +32,9 @@
{% endif %} - {% include 'elements/comments.tpl' %} + {% if viewPost and postExists %} + {% include 'elements/comments.tpl' %} + {% endif %} {% else %}

The requested news post does not exist!

diff --git a/_sakura/templates/yuuno/settings/account.email.tpl b/_sakura/templates/yuuno/settings/account.email.tpl index e69de29..e313706 100644 --- a/_sakura/templates/yuuno/settings/account.email.tpl +++ b/_sakura/templates/yuuno/settings/account.email.tpl @@ -0,0 +1,25 @@ + + + + +

Your e-mail address is currently set to {{ user.data.email }}.

+
+

E-mail address

+
+
+
+

Confirmation

+
+
+
+ + +
+ + diff --git a/_sakura/templates/yuuno/settings/account.password.tpl b/_sakura/templates/yuuno/settings/account.password.tpl index e69de29..f02f7a5 100644 --- a/_sakura/templates/yuuno/settings/account.password.tpl +++ b/_sakura/templates/yuuno/settings/account.password.tpl @@ -0,0 +1,28 @@ +
+ + + +
+

Current Password

+
+
+
+

New Password

+
+
+
+

Confirmation

+
+
+
+ + +
+
+ diff --git a/_sakura/templates/yuuno/settings/account.username.tpl b/_sakura/templates/yuuno/settings/account.username.tpl index e69de29..aebaa3c 100644 --- a/_sakura/templates/yuuno/settings/account.username.tpl +++ b/_sakura/templates/yuuno/settings/account.username.tpl @@ -0,0 +1,30 @@ +{% set eligible = (php.time - user.data.lastunamechange) > 2592000 %} + +
+ + + +

You are {% if not eligible %}not {% endif %}eligible for a name change.

+

Your last name change was {{ difference }}.

+ {% if eligible %} +
+

Username

+
+
+
+

Confirmation

+
+
+
+ + +
+ {% endif %} +
+ diff --git a/_sakura/templates/yuuno/settings/account.usertitle.tpl b/_sakura/templates/yuuno/settings/account.usertitle.tpl index e69de29..2a80c86 100644 --- a/_sakura/templates/yuuno/settings/account.usertitle.tpl +++ b/_sakura/templates/yuuno/settings/account.usertitle.tpl @@ -0,0 +1,21 @@ +
+ + + +

Your current user title is:
{{ user.userTitle }}

+
+

Usertitle

+
+
+
+ + +
+
+ diff --git a/_sakura/templates/yuuno/settings/general.groups.tpl b/_sakura/templates/yuuno/settings/general.groups.tpl deleted file mode 100644 index e69de29..0000000 diff --git a/_sakura/templates/yuuno/settings/general.options.tpl b/_sakura/templates/yuuno/settings/general.options.tpl index be0cab8..29ee35c 100644 --- a/_sakura/templates/yuuno/settings/general.options.tpl +++ b/_sakura/templates/yuuno/settings/general.options.tpl @@ -23,17 +23,9 @@ {% else %} diff --git a/_sakura/templates/yuuno/settings/general.profile.tpl b/_sakura/templates/yuuno/settings/general.profile.tpl index 215ce8b..54888d3 100644 --- a/_sakura/templates/yuuno/settings/general.profile.tpl +++ b/_sakura/templates/yuuno/settings/general.profile.tpl @@ -54,16 +54,8 @@ diff --git a/public/content/data/yuuno/css/yuuno.css b/public/content/data/yuuno/css/yuuno.css index 183f24c..c72ac07 100644 --- a/public/content/data/yuuno/css/yuuno.css +++ b/public/content/data/yuuno/css/yuuno.css @@ -2109,17 +2109,17 @@ textarea.inputStyling { .comments .comment { display: flex; align-items: stretch; - margin: 2px 0; + margin: 3px 0; } .comments .comment > .comment-avatar { - height: 58px; - width: 58px; - background: url("/content/pixel.png") no-repeat scroll left center / contain; + height: 60px; + width: 60px; + background: rgba(0, 0, 0, .2) url("/content/pixel.png") no-repeat scroll left center / contain; flex-shrink: 0; margin-right: 2px; border-radius: 4px; - border: 1px solid #9475B2; + border: 0; } .comments .comment > .comment-pointer { @@ -2127,18 +2127,35 @@ textarea.inputStyling { height: 0px; border-style: solid; border-width: 0px 15px 15px 0px; - border-color: transparent #FFF transparent transparent; + border-color: transparent #F6F6F6 transparent transparent; + margin-top: 10px; } -.comments .comment > .comment-text { - border-radius: 0 5px 5px 5px; +.comments .comment > .comment-content { + border-radius: 5px; border: 0; min-height: 50px; height: 50px; flex-grow: 2; padding: 5px; font: 12px/20px "SegoeUI", "Segoe UI", sans-serif; - background: #FFF; + background: #F6F6F6; +} + +.comments .comment > .comment-content > .comment-controls { + float: right; +} + +.comments .comment > .comment-content > .comment-controls > ul > li { + float: left; + margin: 0 5px; + opacity: 0; + transition: .5s; +} + +.comments .comment > .comment-content:hover > .comment-controls > ul > li, +.comments .comment > .comment-content > .comment-controls > ul > li.shown { + opacity: 1; } .comments .comment > .comment-submit { @@ -2148,10 +2165,19 @@ textarea.inputStyling { width: 60px; border-radius: 4px; margin-left: 2px; - border: 0; - background: #9475B2; - color: #FFF; font-size: 2em; + background: linear-gradient(0deg, #9475B2 10%, #C2AFFE 90%); + color: #306; + border: 1px solid #9475B2; + cursor: pointer; +} + +.comments .comment > .comment-submit:hover { + background: linear-gradient(0deg, #9475B2 30%, #C2AFFE 70%); +} + +.comments .comment > .comment-submit:active { + background: linear-gradient(180deg, #9475B2 30%, #C2AFFE 70%); } .comments ul { @@ -2163,11 +2189,11 @@ textarea.inputStyling { } .comments ul > li > ul .comment > .comment-avatar { - height: 48px; - width: 48px; + height: 50px; + width: 50px; } -.comments ul > li > ul .comment > .comment-text { +.comments ul > li > ul .comment > .comment-content { min-height: 40px; height: 40px; } diff --git a/public/content/data/yuuno/js/yuuno.js b/public/content/data/yuuno/js/yuuno.js index 7412ad8..d3c5b49 100644 --- a/public/content/data/yuuno/js/yuuno.js +++ b/public/content/data/yuuno/js/yuuno.js @@ -375,16 +375,7 @@ function ajaxBusyView(show, message, type) { } // Making a post request using AJAX -function ajaxPost(url, data) { - - // Create a new XMLHttpRequest - var req = new XMLHttpRequest(); - - // Open a post request - req.open("POST", url, false); - - // Set the request header to a form - req.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); +function ajaxPost(url, data, callback) { // Combine name and value with an = inbetween var query = []; @@ -394,11 +385,50 @@ function ajaxPost(url, data) { } - // Join the array and submit the request - req.send(query.join("&")); + // Join the array + query = query.join("&"); - // If the HTTP resonse was 200 return the page - return (req.status === 200 ? req.responseText : null); + // Create XMLHttpRequest + var request = new XMLHttpRequest(); + + // Open a post request + request.open('POST', url, true); + + // Wait for the readiness to change + request.onreadystatechange = function() { + + // Wait for completion + if(request.readyState === 4) { + + if(request.status === 200) { + + callback.call(request.responseText); + + } else { + + ajaxBusyView(false); + + notifyUI({ + "title": "An internal server error occurred!", + "text": "If this problem persists please report this to the administrator.", + "img": "FONT:fa-chain-broken", + "timeout": 60000, + "sound": false + }); + + return null; + + } + + } + + } + + // Set headers + request.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); + + // Submit the request + request.send(query); } @@ -447,6 +477,26 @@ function prepareAjaxLink(linkId, callback, attrs) { } +function prepareAjaxForm(formId, message, resetCaptchaOnFailure) { + + // Get the form + var form = document.getElementById(formId); + + // Create the AJAX form input + var createHidden = document.createElement('input'); + + // Set the attributes + createHidden.setAttribute('name', 'ajax'); + createHidden.setAttribute('value', 'true'); + createHidden.setAttribute('type', 'hidden'); + form.appendChild(createHidden); + + // Update form + form.setAttribute('onsubmit', 'submitPost(\''+ form.action +'\', formToObject(\''+ formId +'\'), true, \''+ (message ? message : 'Please wait...') +'\', '+ (resetCaptchaOnFailure ? 'true' : 'false') +');'); + form.setAttribute('action', 'javascript:void(0);'); + +} + // Convert form to an object function formToObject(formId) { @@ -517,25 +567,6 @@ function generateForm(formId, formAttr, formData, appendTo) { } -// Enter substitute -function formEnterCatch(key, id) { - - // 13 == Enter - if(key.which == 13) { - - // Submit the form - document.getElementById(id).click(); - - // Return true if yeah - return true; - - } - - // Return false if not - return false; - -} - // Submitting a form using an AJAX POST request function submitPost(action, requestParts, busyView, msg, resetCaptchaOnFailure) { @@ -547,17 +578,29 @@ function submitPost(action, requestParts, busyView, msg, resetCaptchaOnFailure) } // Submit the AJAX request - var request = ajaxPost(action, requestParts).split('|'); + var request = ajaxPost(action, requestParts, function() { + + submitPostHandler(this, busyView, resetCaptchaOnFailure); + + }); + +} + +// Submitting a form using an AJAX POST request +function submitPostHandler(result, busyView, resetCaptchaOnFailure) { + + // Split result + result = result.split('|'); // If using the busy view thing update the text displayed to the return of the request if(busyView) { - ajaxBusyView(true, request[0], (request[1] == '1' ? 'ok' : 'fail')); + ajaxBusyView(true, result[0], (result[1] == '1' ? 'ok' : 'fail')); } // If request reset the recaptcha on failure - if(resetCaptchaOnFailure && request[1] != '1' && sakuraVars.recpatchaEnabled) { + if(resetCaptchaOnFailure && result[1] != '1' && sakuraVars.recaptchaEnabled) { grecaptcha.reset(); @@ -571,9 +614,9 @@ function submitPost(action, requestParts, busyView, msg, resetCaptchaOnFailure) } - if(request[1] == '1') { + if(result[1] == '1') { - window.location = request[2]; + window.location = result[2]; } diff --git a/public/settings.php b/public/settings.php index 932f618..9b4cb72 100644 --- a/public/settings.php +++ b/public/settings.php @@ -16,9 +16,6 @@ require_once str_replace(basename(__DIR__), '', dirname(__FILE__)) . '_sakura/sa // Notifications if (isset($_REQUEST['request-notifications']) && $_REQUEST['request-notifications']) { - // Set CORS header - header('Access-Control-Allow-Origin: *'); - // Create the notification container array $notifications = array(); @@ -198,7 +195,7 @@ if (isset($_REQUEST['request-notifications']) && $_REQUEST['request-notification ]; - break; + $continue = false; } // Check session variables @@ -215,7 +212,7 @@ if (isset($_REQUEST['request-notifications']) && $_REQUEST['request-notification ]; - break; + $continue = false; } // Change settings @@ -541,7 +538,7 @@ if (isset($_REQUEST['request-notifications']) && $_REQUEST['request-notification break; - // Profile + // Site Options case 'options': // Get profile fields and create storage var $fields = Users::getOptionFields(); @@ -575,6 +572,58 @@ if (isset($_REQUEST['request-notifications']) && $_REQUEST['request-notification break; + // Usertitle + case 'usertitle': + // Check permissions + if (!$currentUser->checkPermission('SITE', 'CHANGE_USERTITLE')) { + $renderData['page'] = [ + + 'redirect' => $redirect, + 'message' => 'You aren\'t allowed to change your usertitle.', + 'success' => 0, + + ]; + + break; + } + + // Check length + if (isset($_POST['usertitle']) ? (strlen($_POST['usertitle']) > 64) : false) { + $renderData['page'] = [ + + 'redirect' => $redirect, + 'message' => 'Your usertitle is too long.', + 'success' => 0, + + ]; + + break; + } + + // Update database + Database::update( + 'users', + [ + [ + 'usertitle' => (isset($_POST['usertitle']) ? $_POST['usertitle'] : null), + ], + [ + 'id' => [Session::$userId, '='], + ], + ] + ); + + // Set render data + $renderData['page'] = [ + + 'redirect' => $redirect, + 'message' => 'Updated your usertitle!', + 'success' => 1, + + ]; + + break; + // Userpage /*case 'userpage': @@ -892,7 +941,7 @@ if (Users::checkLogin()) { ], 'usertitle' => [ - 'title' => 'Username', + 'title' => 'Usertitle', 'description' => [ 'That little piece of text displayed under your username on your profile.', @@ -1103,6 +1152,11 @@ if (Users::checkLogin()) { // Profile case 'appearance.userpage': break; + + // Username changing + case 'account.username': + $renderData['difference'] = Main::timeElapsed($currentUser->data['lastunamechange']); + break; } // Print page contents