Commit 8ff4bddf by pupi1985

Add permission to define what users can see the special users page

parent f22e8abb
......@@ -1299,26 +1299,37 @@
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(
if (QA_FINAL_EXTERNAL_USERS) {
return null;
}
$menuItems = array();
$moderatorPlus = qa_get_logged_in_level() >= QA_USER_LEVEL_MODERATOR;
$showSpecialUsersPage = !qa_user_permit_error('permit_view_special_users_page');
if ($moderatorPlus || $showSpecialUsersPage) { // We want to show this item when more than one item should be displayed
$menuItems['users$'] = array(
'url' => qa_path_html('users'),
'label' => qa_lang_html('main/highest_users'),
),
);
}
'users/special' => array(
if ($showSpecialUsersPage) {
$menuItems['users/special'] = array(
'label' => qa_lang('users/special_users'),
'url' => qa_path_html('users/special'),
),
);
}
'users/blocked' => array(
if ($moderatorPlus) {
$menuItems['users/blocked'] = array(
'label' => qa_lang('users/blocked_users'),
'url' => qa_path_html('users/blocked'),
),
);
}
} else
return null;
return $menuItems;
}
......
......@@ -320,6 +320,7 @@
'permit_post_wall' => QA_PERMIT_CONFIRMED,
'permit_select_a' => QA_PERMIT_EXPERTS,
'permit_view_q_page' => QA_PERMIT_ALL,
'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 +789,8 @@
if (qa_opt('allow_user_walls'))
$permits[]='permit_post_wall';
$permits[]='permit_view_special_users_page';
return $permits;
}
......
......@@ -56,6 +56,7 @@
'permit_retag' => 'Retagging any question',
'permit_select_a' => 'Selecting answer for any question',
'permit_view_q_page' => 'Viewing question pages',
'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,7 @@ foreach ($showoptions as $optionname) {
break;
case 'permit_view_q_page':
case 'permit_view_special_users_page':
case 'permit_post_q':
case 'permit_post_a':
case 'permit_post_c':
......@@ -1370,7 +1371,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 ($optionname == 'permit_view_q_page' || $optionname == 'permit_view_special_users_page' || $optionname == 'permit_post_q' || $optionname == 'permit_post_a' || $optionname == 'permit_post_c' || $optionname == '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 +1385,9 @@ foreach ($showoptions as $optionname) {
if ($optionname == 'permit_view_q_page') {
$narrowest = QA_PERMIT_APPROVED;
$dopoints = false;
} elseif ($optionname == 'permit_view_special_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')
......
......@@ -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;
......@@ -77,5 +77,4 @@ foreach ($users as $user) {
$qa_content['navigation']['sub'] = qa_users_sub_navigation();
return $qa_content;
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