Commit 22e5fb6e by Scott

Merge branch 'pr/467' into 1.8

parents 7858823c d90bb416
......@@ -1294,31 +1294,49 @@
}
/**
* Return the sub navigation structure for user listing pages
*/
function qa_users_sub_navigation()
/*
Return the sub navigation structure for user listing pages
*/
{
if ((!QA_FINAL_EXTERNAL_USERS) && (qa_get_logged_in_level()>=QA_USER_LEVEL_MODERATOR)) {
return array(
'users$' => array(
'url' => qa_path_html('users'),
'label' => qa_lang_html('main/highest_users'),
),
'users/special' => array(
'label' => qa_lang('users/special_users'),
'url' => qa_path_html('users/special'),
),
'users/blocked' => array(
'label' => qa_lang('users/blocked_users'),
'url' => qa_path_html('users/blocked'),
),
if (QA_FINAL_EXTERNAL_USERS) {
return null;
}
$menuItems = array();
$moderatorPlus = qa_get_logged_in_level() >= QA_USER_LEVEL_MODERATOR;
$showNewUsersPage = !qa_user_permit_error('permit_view_new_users_page');
$showSpecialUsersPage = !qa_user_permit_error('permit_view_special_users_page');
if ($moderatorPlus || $showNewUsersPage || $showSpecialUsersPage) {
// We want to show this item when more than one item should be displayed
$menuItems['users$'] = array(
'label' => qa_lang_html('main/highest_users'),
'url' => qa_path_html('users'),
);
}
} else
return null;
$menuItems['users/new'] = array(
'label' => qa_lang_html('main/newest_users'),
'url' => qa_path_html('users/new'),
);
if ($showSpecialUsersPage) {
$menuItems['users/special'] = array(
'label' => qa_lang('users/special_users'),
'url' => qa_path_html('users/special'),
);
}
if ($moderatorPlus) {
$menuItems['users/blocked'] = array(
'label' => qa_lang('users/blocked_users'),
'url' => qa_path_html('users/blocked'),
);
}
return $menuItems;
}
......
......@@ -320,6 +320,8 @@
'permit_post_wall' => QA_PERMIT_CONFIRMED,
'permit_select_a' => QA_PERMIT_EXPERTS,
'permit_view_q_page' => QA_PERMIT_ALL,
'permit_view_new_users_page' => QA_PERMIT_EDITORS,
'permit_view_special_users_page' => QA_PERMIT_MODERATORS,
'permit_view_voters_flaggers' => QA_PERMIT_ADMINS,
'permit_vote_a' => QA_PERMIT_USERS,
'permit_vote_down' => QA_PERMIT_USERS,
......@@ -788,6 +790,8 @@
if (qa_opt('allow_user_walls'))
$permits[]='permit_post_wall';
array_push($permits, 'permit_view_new_users_page', 'permit_view_special_users_page');
return $permits;
}
......
......@@ -1307,6 +1307,24 @@
}
function qa_db_newest_users_selectspec($start, $count = null)
/*
Return the selectspec to get the newest users. Return $count (if null, a default is used) users starting from the
offset $start. This query must not be run when using external users
*/
{
$count = isset($count) ? min($count, QA_DB_RETRIEVE_USERS) : QA_DB_RETRIEVE_USERS;
return array(
'columns' => array('userid', 'handle', 'flags', 'email', 'created' => 'UNIX_TIMESTAMP(created)', 'avatarblobid' => 'BINARY avatarblobid', 'avatarwidth', 'avatarheight'),
'source' => '^users ORDER BY created DESC, userid DESC LIMIT #,#',
'arguments' => array($start, $count),
'sortdesc' => 'created',
'sortdesc_2' => 'userid',
);
}
function qa_db_users_from_level_selectspec($level)
/*
Return the selectspec to get information about users at a certain privilege level or higher
......
......@@ -122,6 +122,7 @@
'nav_unanswered' => 'Unanswered',
'nav_updates' => 'My Updates',
'nav_users' => 'Users',
'newest_users' => 'Newest users',
'no_active_users' => 'No active users found',
'no_answers_found' => 'No answers found',
'no_answers_in_x' => 'No answers in ^',
......
......@@ -56,6 +56,8 @@
'permit_retag' => 'Retagging any question',
'permit_select_a' => 'Selecting answer for any question',
'permit_view_q_page' => 'Viewing question pages',
'permit_view_new_users_page' => 'Viewing the newest users page',
'permit_view_special_users_page' => 'Viewing the special users page',
'permit_view_voters_flaggers' => 'Viewing who voted or flagged posts',
'permit_vote_a' => 'Voting on answers',
'permit_vote_down' => 'Voting posts down',
......
......@@ -1343,6 +1343,8 @@ foreach ($showoptions as $optionname) {
break;
case 'permit_view_q_page':
case 'permit_view_new_users_page':
case 'permit_view_special_users_page':
case 'permit_post_q':
case 'permit_post_a':
case 'permit_post_c':
......@@ -1370,7 +1372,7 @@ foreach ($showoptions as $optionname) {
else
$optionfield['label'] = qa_lang_html('profile/' . $optionname) . ':';
if ($optionname == 'permit_view_q_page' || $optionname == 'permit_post_q' || $optionname == 'permit_post_a' || $optionname == 'permit_post_c' || $optionname == 'permit_anon_view_ips')
if (in_array($optionname, array('permit_view_q_page', 'permit_view_new_users_page', 'permit_view_special_users_page', 'permit_post_q', 'permit_post_a', 'permit_post_c', 'permit_anon_view_ips')))
$widest = QA_PERMIT_ALL;
elseif ($optionname == 'permit_close_q' || $optionname == 'permit_select_a' || $optionname == 'permit_moderate' || $optionname == 'permit_hide_show')
$widest = QA_PERMIT_POINTS;
......@@ -1384,6 +1386,9 @@ foreach ($showoptions as $optionname) {
if ($optionname == 'permit_view_q_page') {
$narrowest = QA_PERMIT_APPROVED;
$dopoints = false;
} elseif ($optionname == 'permit_view_special_users_page' || $optionname == 'permit_view_new_users_page') {
$narrowest = QA_PERMIT_SUPERS;
$dopoints = false;
} elseif ($optionname == 'permit_edit_c' || $optionname == 'permit_close_q' || $optionname == 'permit_select_a' || $optionname == 'permit_moderate' || $optionname == 'permit_hide_show' || $optionname == 'permit_anon_view_ips')
$narrowest = QA_PERMIT_MODERATORS;
elseif ($optionname == 'permit_post_c' || $optionname == 'permit_edit_q' || $optionname == 'permit_retag_cat' || $optionname == 'permit_edit_a' || $optionname == 'permit_flag')
......
......@@ -71,7 +71,7 @@ $qa_content['title'] = $count > 0 ? qa_lang_html('users/blocked_users') : qa_lan
$qa_content['ranking'] = array(
'items' => array(),
'rows' => ceil(count($users) / qa_opt('columns_users')),
'type' => 'users'
'type' => 'blocked-users'
);
foreach ($users as $user) {
......
<?php
/*
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
File: qa-include/pages/users-newest.php
Description: Controller for newest users page
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
More about this license: http://www.question2answer.org/license.php
*/
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../');
exit;
}
require_once QA_INCLUDE_DIR . 'db/selects.php';
require_once QA_INCLUDE_DIR . 'app/format.php';
// Check we're not using single-sign on integration
if (QA_FINAL_EXTERNAL_USERS)
qa_fatal_error('User accounts are handled by external code');
// Check we have permission to view this page (moderator or above)
if (qa_user_permit_error('permit_view_new_users_page')) {
$qa_content = qa_content_prepare();
$qa_content['error'] = qa_lang_html('users/no_permission');
return $qa_content;
}
// Get list of all users
$start = qa_get_start();
$users = qa_db_select_with_pending(qa_db_newest_users_selectspec($start, qa_opt_if_loaded('page_size_users')));
$userCount = qa_opt('cache_userpointscount');
$pageSize = qa_opt('page_size_users');
$users = array_slice($users, 0, $pageSize);
$usersHtml = qa_userids_handles_html($users);
// Prepare content for theme
$qa_content = qa_content_prepare();
$qa_content['title'] = qa_lang_html('main/newest_users');
$qa_content['ranking'] = array(
'items' => array(),
'rows' => ceil($pageSize / qa_opt('columns_users')),
'type' => 'newest-users',
);
if (!empty($users)) {
foreach ($users as $user) {
$avatarHtml = qa_get_user_avatar_html($user['flags'], $user['email'], $user['handle'],
$user['avatarblobid'], $user['avatarwidth'], $user['avatarheight'], qa_opt('avatar_users_size'), true);
$when = qa_when_to_html($user['created'], 7);
$qa_content['ranking']['items'][] = array(
'avatar' => $avatarHtml,
'label' => $usersHtml[$user['userid']],
'score' => $when['data'],
'raw' => $user,
);
}
} else {
$qa_content['title'] = qa_lang_html('main/no_active_users');
}
// set the canonical url based on possible pagination
$qa_content['canonical'] = qa_path_html(qa_request(), ($start > 0 ? array('start' => $start) : null), qa_opt('site_url'));
$qa_content['page_links'] = qa_html_page_links(qa_request(), $start, $pageSize, $userCount, qa_opt('pages_prev_next'));
$qa_content['navigation']['sub'] = qa_users_sub_navigation();
return $qa_content;
......@@ -43,7 +43,7 @@ $users = qa_db_select_with_pending(qa_db_users_from_level_selectspec(QA_USER_LEV
// Check we have permission to view this page (moderator or above)
if (qa_get_logged_in_level() < QA_USER_LEVEL_MODERATOR) {
if (qa_user_permit_error('permit_view_special_users_page')) {
$qa_content = qa_content_prepare();
$qa_content['error'] = qa_lang_html('users/no_permission');
return $qa_content;
......@@ -64,7 +64,7 @@ $qa_content['title'] = qa_lang_html('users/special_users');
$qa_content['ranking'] = array(
'items' => array(),
'rows' => ceil(qa_opt('page_size_users') / qa_opt('columns_users')),
'type' => 'users'
'type' => 'special-users'
);
foreach ($users as $user) {
......@@ -77,5 +77,4 @@ foreach ($users as $user) {
$qa_content['navigation']['sub'] = qa_users_sub_navigation();
return $qa_content;
......@@ -444,6 +444,7 @@
'user/' => 'pages/user.php',
'users' => 'pages/users.php',
'users/blocked' => 'pages/users-blocked.php',
'users/new' => 'pages/users-newest.php',
'users/special' => 'pages/users-special.php',
);
}
......
......@@ -65,7 +65,8 @@ $(document).ready(function () {
/*
* Add wrapper to users point on users list
*/
$('.qa-top-users-score').wrapInner('<div class="qam-user-score-icon"></div>');
$('.qa-top-users-score, .qa-top-newest-users-score, .qa-top-special-users-score, .qa-top-blocked-users-score')
.wrapInner('<div class="qam-user-score-icon"></div>');
/*
* add wrapper to the message sent note 'td'
......
......@@ -1454,35 +1454,54 @@ blockquote p {
padding: 5px;
}
.qa-top-users-item {
.qa-top-users-item,
.qa-top-special-users-item,
.qa-top-blocked-users-item,
.qa-top-newest-users-item {
width: 100%;
max-width: 320px;
}
.qa-top-tags-item {
width: 100%;
max-width: 150px;
}
@media only screen and (min-width: 992px) {
/* two column layout for Desktops and above*/
.qa-top-users-item {
.qa-top-users-item,
.qa-top-special-users-item,
.qa-top-blocked-users-item,
.qa-top-newest-users-item {
width: 48%;
max-width: none;
}
.qa-top-tags-item {
width: 23%;
max-width: none;
}
}
.qa-top-users-avatar .qa-avatar-link {
.qa-top-users-avatar .qa-avatar-link,
.qa-top-special-users-avatar .qa-avatar-link,
.qa-top-newest-users-avatar .qa-avatar-link {
display: block;
float: left;
margin-right: 1em;
}
.qa-top-users-avatar .qa-avatar-link img {
.qa-top-users-avatar .qa-avatar-link img,
.qa-top-special-users-avatar .qa-avatar-link img,
.qa-top-blocked-users-avatar .qa-avatar-link img,
.qa-top-newest-users-avatar .qa-avatar-link img {
border: 1px solid #cbd7e3;
}
.qa-top-users-label .qa-user-link {
.qa-top-users-label .qa-user-link,
.qa-top-special-users-label .qa-user-link,
.qa-top-blocked-users-label .qa-user-link,
.qa-top-newest-users-label .qa-user-link {
background-color: #e74c3c;
display: block;
float: left;
......@@ -1490,12 +1509,23 @@ blockquote p {
padding: 2px 1em;
position: relative;
}
.qa-top-users-label .qa-user-link:hover, .qa-top-users-label .qa-user-link:focus {
.qa-top-users-label .qa-user-link:hover,
.qa-top-users-label .qa-user-link:focus,
.qa-top-special-users-label .qa-user-link:hover,
.qa-top-special-users-label .qa-user-link:focus,
.qa-top-blocked-users-label .qa-user-link:hover,
.qa-top-blocked-users-label .qa-user-link:focus,
.qa-top-newest-users-label .qa-user-link:hover,
.qa-top-newest-users-label .qa-user-link:focus {
background-color: #eb695c;
text-decoration: none;
}
.qa-top-users-label .qa-user-link:before {
.qa-top-users-label .qa-user-link:before,
.qa-top-special-users-label .qa-user-link:before,
.qa-top-blocked-users-label .qa-user-link:before,
.qa-top-newest-users-label .qa-user-link:before {
content: "";
position: absolute;
left: -5px;
......@@ -1509,13 +1539,19 @@ blockquote p {
}
@media (min-width: 980px) {
.qa-top-users-label .qa-user-link:hover:after, .qa-top-users-label .qa-user-link:focus:after {
.qa-top-users-label .qa-user-link:hover:after, .qa-top-users-label .qa-user-link:focus:after,
.qa-top-special-users-label .qa-user-link:hover:after, .qa-top-special-users-label .qa-user-link:focus:after,
.qa-top-blocked-users-label .qa-user-link:hover:after, .qa-top-blocked-users-label .qa-user-link:focus:after,
.qa-top-newest-users-label .qa-user-link:hover:after, .qa-top-newest-users-label .qa-user-link:focus:after {
-ms-transform: translate(80px, 0);
-webkit-transform: translate(80px, 0);
transform: translate(80px, 0);
}
.qa-top-users-label .qa-user-link:after {
.qa-top-users-label .qa-user-link:after,
.qa-top-special-users-label .qa-user-link:after,
.qa-top-blocked-users-label .qa-user-link:after,
.qa-top-newest-users-label .qa-user-link:after {
content: "";
display: block;
width: 0;
......@@ -1534,7 +1570,11 @@ blockquote p {
transition: all 0.5s ease;
}
}
.qa-top-users-label .qa-user-link.qa-user-favorited {
.qa-top-users-label .qa-user-link.qa-user-favorited,
.qa-top-special-users-label .qa-user-link.qa-user-favorited,
.qa-top-blocked-users-label .qa-user-link.qa-user-favorited,
.qa-top-newest-users-label .qa-user-link.qa-user-favorited {
background-image: url('images/icons/fev-star.png');
background-repeat: no-repeat;
background-position: 2px center;
......@@ -1543,13 +1583,13 @@ blockquote p {
.qam-user-score-icon {
display: inline-block;
padding: 2px 6px 2px 1.8em;
background-color: #2ecc71;
color: #fff;
position: relative;
float: right;
}
.qam-user-score-icon:before {
.qa-top-users-score .qam-user-score-icon:before {
background-color: #27ae60;
content: '\e810';
font-family: "fontello";
......@@ -1563,6 +1603,16 @@ blockquote p {
left: 0;
}
.qa-top-users-score .qam-user-score-icon {
padding: 2px 6px 2px 1.8em;
}
.qa-top-special-users-score .qam-user-score-icon,
.qa-top-blocked-users-score .qam-user-score-icon,
.qa-top-newest-users-score .qam-user-score-icon {
padding: 2px 6px 2px 6px;
}
.qa-top-tags-count {
width: 8%;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment