more things

This commit is contained in:
flash 2015-07-08 15:09:57 +02:00
parent 19ac875ac3
commit 524ff6e14e
13 changed files with 98 additions and 27 deletions

View file

@ -31,7 +31,9 @@
"20150702", "20150702",
"20150703", "20150703",
"20150704", "20150704",
"20150705" "20150705",
"20150706",
"20150707"
] ]
@ -1481,6 +1483,28 @@
{ {
"type": "ADD", "type": "ADD",
"change": "Add code for topic view counter." "change": "Add code for topic view counter."
},
{
"type": "FIX",
"change": "Fixed avatars with shit resolutions jumping to the side of the username."
}
],
"20150706": [
{
"type": "ADD",
"change": "Added pending friend requests counter to the frontpage."
}
],
"20150707": [
{
"type": "ADD",
"change": "Added post and topic count variable to the profile."
} }
] ]

View file

@ -0,0 +1,10 @@
<?php
/*
* Ban management
*/
namespace Sakura;
class Bans {
}

View file

@ -331,6 +331,17 @@ class Forum {
} }
// Get forum statistics of a user
public static function getUserStats($uid) {
// Collect the stats
return [
'posts' => Database::count('posts', ['poster_id' => [$uid, '=']])[0],
'topics' => count(Database::fetch('posts', true, ['poster_id' => [$uid, '=']], ['post_time'], null, ['topic_id']))
];
}
// Creating a new post // Creating a new post
public static function createPost($subject, $text, $enableMD, $enableSig, $forum, $type = 0, $status = 0, $topic = 0) { public static function createPost($subject, $text, $enableMD, $enableSig, $forum, $type = 0, $status = 0, $topic = 0) {

View file

@ -1324,6 +1324,35 @@ class Users {
} }
// Get non-mutual friends
public static function getPendingFriends($uid = null) {
// Assign $of automatically if it's not set
if(!$uid)
$uid = Session::$userId;
// Get all friend entries from other people involved the current user
$friends = Database::fetch('friends', true, [
'fid' => [$uid, '=']
]);
// Create pending array
$pending = [];
// Check if the friends are mutual
foreach($friends as $friend) {
// Check if the friend is mutual
if(!self::checkFriend($friend, $uid))
$pending[] = $friend;
}
// Return the pending friends
return $pending;
}
// Check if a friend is mutual // Check if a friend is mutual
public static function checkFriend($fid, $uid = null) { public static function checkFriend($fid, $uid = null) {
@ -1391,11 +1420,4 @@ class Users {
} }
// Checking bans
public static function checkBan($uid) {
}
} }

View file

@ -103,13 +103,6 @@ class MySQL {
} }
// If $order is set and is an array continue
if(is_array($order)) {
$prepare .= ' ORDER BY `'. $order[0] .'`'. (!empty($order[1]) && $order[1] ? ' DESC' : '');
}
// If $group is set and is an array continue // If $group is set and is an array continue
if(is_array($group)) { if(is_array($group)) {
@ -125,6 +118,13 @@ class MySQL {
} }
// If $order is set and is an array continue
if(is_array($order)) {
$prepare .= ' ORDER BY `'. $order[0] .'`'. (!empty($order[1]) && $order[1] ? ' DESC' : '');
}
// If $limit is set and is an array continue // If $limit is set and is an array continue
if(is_array($limit)) { if(is_array($limit)) {

View file

@ -8,7 +8,7 @@
namespace Sakura; namespace Sakura;
// Define Sakura version // Define Sakura version
define('SAKURA_VERSION', '20150705'); define('SAKURA_VERSION', '20150707');
define('SAKURA_VLABEL', 'Eminence'); define('SAKURA_VLABEL', 'Eminence');
define('SAKURA_STABLE', false); define('SAKURA_STABLE', false);
define('SAKURA_COLOUR', '#6C3082'); define('SAKURA_COLOUR', '#6C3082');

View file

@ -113,8 +113,8 @@ user not found, don't forget to make this sexy
<div class="inner"> <div class="inner">
<div class="forumStatTitle">Forum stats</div> <div class="forumStatTitle">Forum stats</div>
<div class="forumStatCount"> <div class="forumStatCount">
<a class="posts" href="/u/{{ profile.user.id }}/posts">{% if profile.data.forum.posts %}{{ profile.data.forum.posts }}{% else %}0{% endif %} post{% if profile.data.forum.posts != 1 %}s{% endif %}</a> <a class="posts" href="/u/{{ profile.user.id }}/posts">{{ profile.forum_stats.posts }} post{% if profile.forum_stats.posts != 1 %}s{% endif %}</a>
<a class="threads" href="/u/{{ profile.user.id }}/threads">{% if profile.data.forum.threads %}{{ profile.data.forum.threads }}{% else %}0{% endif %} thread{% if profile.data.forum.threads != 1 %}s{% endif %}</a> <a class="threads" href="/u/{{ profile.user.id }}/threads">{% if profile.forum_stats.topics %}{{ profile.forum_stats.topics }}{% else %}0{% endif %} thread{% if profile.forum_stats.topics != 1 %}s{% endif %}</a>
</div> </div>
<div class="clear"></div> <div class="clear"></div>
</div> </div>

View file

@ -2,7 +2,7 @@
<div class="head">Hi, {{ user.data.username }}!</div> <div class="head">Hi, {{ user.data.username }}!</div>
<a href="//{{ sakura.urls.main }}/settings/avatar"><img src="//{{ sakura.urls.main }}/a/{{ user.data.id }}" class="default-avatar-setting homepage-menu-avatar" /></a> <a href="//{{ sakura.urls.main }}/settings/avatar"><img src="//{{ sakura.urls.main }}/a/{{ user.data.id }}" class="default-avatar-setting homepage-menu-avatar" /></a>
<ul class="panelQuickLinks"> <ul class="panelQuickLinks">
<li><a href="//{{ sakura.urls.main }}/friends" title="Pending friend requests"><span class="fa fa-user-plus"></span><span class="count">0</span></a></li> <li><a href="//{{ sakura.urls.main }}/friends" title="Pending friend requests"><span class="fa fa-user-plus"></span><span class="count">{{ page.friend_req|length }}</span></a></li>
<li><a href="//{{ sakura.urls.main }}/messages" title="View private messages"><span class="fa fa-envelope"></span><span class="count">0</span></a></li> <li><a href="//{{ sakura.urls.main }}/messages" title="View private messages"><span class="fa fa-envelope"></span><span class="count">0</span></a></li>
</ul> </ul>
<div class="clear"></div> <div class="clear"></div>

View file

@ -15,9 +15,10 @@
<div class="actions"> <div class="actions">
{% if user.data.id == post.user.id %} {% if user.data.id == post.user.id %}
<a class="fa fa-pencil-square-o" title="Edit this post" href="/forum/post/{{ post.post_id }}/edit"></a> <a class="fa fa-pencil-square-o" title="Edit this post" href="/forum/post/{{ post.post_id }}/edit"></a>
<a class="fa fa-trash" title="Delete this post" href="/forum/post/{{ post.post_id }}/delete"></a>
{% else %} {% else %}
{% if post.is_friend != 0 %}<a class="fa fa-{% if post.is_friend == 2 %}heart{% else %}star{% endif %}" title="You are friends"></a>{% endif %} {% if post.is_friend != 0 %}<a class="fa fa-{% if post.is_friend == 2 %}heart{% else %}star{% endif %}" title="You are friends"></a>{% endif %}
<a class="fa fa-user-{% if post.is_friend == 0 %}plus{% else %}times{% endif %}" title="{% if post.is_friend == 0 %}Add {{ post.user.username }} as a friend{% else %}Remove friend{% endif %}" href="//{{ sakura.urls.main }}/friends?{% if post.is_friend == 0 %}add{% else %}remove{% endif %}={{ post.user.id }}&amp;session={{ php.sessionid }}&amp;time={{ php.time }}&amp;redirect=/forum/post/{{ post.post_id }}#p{{ post.post_id }}"></a> <a class="fa fa-user-{% if post.is_friend == 0 %}plus{% else %}times{% endif %}" title="{% if post.is_friend == 0 %}Add {{ post.user.username }} as a friend{% else %}Remove friend{% endif %}" href="//{{ sakura.urls.main }}/friends?{% if post.is_friend == 0 %}add{% else %}remove{% endif %}={{ post.user.id }}&amp;session={{ php.sessionid }}&amp;time={{ php.time }}&amp;redirect=/forum/post/{{ post.post_id }}%23p{{ post.post_id }}"></a>
<a class="fa fa-flag" title="Report {{ post.user.username }}" href="//{{ sakura.urls.main }}/u/{{ post.user.id }}/report"></a> <a class="fa fa-flag" title="Report {{ post.user.username }}" href="//{{ sakura.urls.main }}/u/{{ post.user.id }}/report"></a>
{% endif %} {% endif %}
{% else %} {% else %}

View file

@ -34,11 +34,11 @@
<hr class="default" /> <hr class="default" />
<b>Joined</b> {{ profile.user.regdate|date("l Y-m-d H:i T") }}<br /> <b>Joined</b> {{ profile.user.regdate|date("l Y-m-d H:i T") }}<br />
{% if profile.user.lastdate == 0 %} {% if profile.user.lastdate == 0 %}
<b>User hasn't logged in yet.</b> <b>{{ profile.user.username }} hasn't logged in yet.</b>
{% else %} {% else %}
<b>Last Seen on</b> {{ profile.user.lastdate|date("l Y-m-d H:i T") }} <b>Last Seen on</b> {{ profile.user.lastdate|date("l Y-m-d H:i T") }}
{% endif %}<br /> {% endif %}<br />
<b>User has {% if not profile.user.posts %}no{% else %}{{ profile.user.posts }}{% endif %} forum post{% if profile.user.posts != 1 %}s{% endif %}.</b> <b>{{ profile.user.username }} has {% if not profile.forum_stats.posts %}no{% else %}{{ profile.forum_stats.posts }}{% endif %} forum post{% if profile.forum_stats.posts != 1 %}s{% endif %}.</b>
{% if profile.fields is not null %} {% if profile.fields is not null %}
<hr class="default" /> <hr class="default" />
{% if user.checklogin %} {% if user.checklogin %}

View file

@ -1709,7 +1709,8 @@ textarea.inputStyling {
background: #EEE; background: #EEE;
box-shadow: 0 3px 7px #888; box-shadow: 0 3px 7px #888;
border-radius: 3px; border-radius: 3px;
margin: 5px; display: block;
margin: 0 auto 10px;
} }
.forum.viewtopic .posts .userpanel .usertitle { .forum.viewtopic .posts .userpanel .usertitle {

View file

@ -16,7 +16,8 @@ $forumMode = isset($_GET['forums']) ? ($_GET['forums'] == true) : false;
$renderData['newsPosts'] = ($forumMode ? null : Main::getNewsPosts(3)); $renderData['newsPosts'] = ($forumMode ? null : Main::getNewsPosts(3));
$renderData['page'] = [ $renderData['page'] = [
'title' => ($forumMode ? 'Forum Listing' : Configuration::getConfig('sitename')) 'title' => ($forumMode ? 'Forum Listing' : Configuration::getConfig('sitename')),
'friend_req' => Users::getPendingFriends()
]; ];
$renderData['board'] = [ $renderData['board'] = [

View file

@ -24,12 +24,13 @@ if(isset($_GET['u'])) {
'profilePage' => Users::getProfilePage($_PROFILE_USER_DATA['userData'], true), 'profilePage' => Users::getProfilePage($_PROFILE_USER_DATA['userData'], true),
'fields' => Users::getUserProfileFields($_PROFILE_USER_DATA['userData'], true), 'fields' => Users::getUserProfileFields($_PROFILE_USER_DATA['userData'], true),
'warnings' => Users::getWarnings($_PROFILE_USER_DATA['id']), 'warnings' => Users::getWarnings($_PROFILE_USER_DATA['id']),
'friend' => Users::checkFriend($_PROFILE_USER_DATA['id']) 'friend' => Users::checkFriend($_PROFILE_USER_DATA['id']),
'forum_stats' => Forum::getUserStats($_PROFILE_USER_DATA['id'])
]; ];
$renderData['page'] = [ $renderData['page'] = [
'title' => ($_PROFILE_USER_DATA['id'] < 1 || $_PROFILE_USER_DATA['password_algo'] == 'nologin' ? 'User not found!' : 'Profile of '. $_PROFILE_USER_DATA['username']), 'title' => ($_PROFILE_USER_DATA['id'] < 1 || $_PROFILE_USER_DATA['password_algo'] == 'nologin' ? 'User not found!' : 'Profile of '. $_PROFILE_USER_DATA['username']),
'style' => (!empty($_PROFILE_USER_DATA['userData']['profileBackground']) ? [ 'style' => (!empty($_PROFILE_USER_DATA['userData']['profileBackground']) ? [
'#userBackground' => [ '#userBackground' => [
'background' => 'url("/bg/'. $_PROFILE_USER_DATA['id'] .'") no-repeat center center / cover transparent !important', 'background' => 'url("/bg/'. $_PROFILE_USER_DATA['id'] .'") no-repeat center center / cover transparent !important',
'position' => 'fixed', 'position' => 'fixed',