Commit d90bb416 by Scott

Add permission option for new users page

parent 071369a2
...@@ -1294,10 +1294,10 @@ ...@@ -1294,10 +1294,10 @@
} }
/**
* Return the sub navigation structure for user listing pages
*/
function qa_users_sub_navigation() function qa_users_sub_navigation()
/*
Return the sub navigation structure for user listing pages
*/
{ {
if (QA_FINAL_EXTERNAL_USERS) { if (QA_FINAL_EXTERNAL_USERS) {
return null; return null;
...@@ -1306,12 +1306,16 @@ ...@@ -1306,12 +1306,16 @@
$menuItems = array(); $menuItems = array();
$moderatorPlus = qa_get_logged_in_level() >= QA_USER_LEVEL_MODERATOR; $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'); $showSpecialUsersPage = !qa_user_permit_error('permit_view_special_users_page');
$menuItems['users$'] = array( if ($moderatorPlus || $showNewUsersPage || $showSpecialUsersPage) {
'label' => qa_lang_html('main/highest_users'), // We want to show this item when more than one item should be displayed
'url' => qa_path_html('users'), $menuItems['users$'] = array(
); 'label' => qa_lang_html('main/highest_users'),
'url' => qa_path_html('users'),
);
}
$menuItems['users/new'] = array( $menuItems['users/new'] = array(
'label' => qa_lang_html('main/newest_users'), 'label' => qa_lang_html('main/newest_users'),
......
...@@ -320,6 +320,7 @@ ...@@ -320,6 +320,7 @@
'permit_post_wall' => QA_PERMIT_CONFIRMED, 'permit_post_wall' => QA_PERMIT_CONFIRMED,
'permit_select_a' => QA_PERMIT_EXPERTS, 'permit_select_a' => QA_PERMIT_EXPERTS,
'permit_view_q_page' => QA_PERMIT_ALL, '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_special_users_page' => QA_PERMIT_MODERATORS,
'permit_view_voters_flaggers' => QA_PERMIT_ADMINS, 'permit_view_voters_flaggers' => QA_PERMIT_ADMINS,
'permit_vote_a' => QA_PERMIT_USERS, 'permit_vote_a' => QA_PERMIT_USERS,
...@@ -789,7 +790,7 @@ ...@@ -789,7 +790,7 @@
if (qa_opt('allow_user_walls')) if (qa_opt('allow_user_walls'))
$permits[]='permit_post_wall'; $permits[]='permit_post_wall';
$permits[]='permit_view_special_users_page'; array_push($permits, 'permit_view_new_users_page', 'permit_view_special_users_page');
return $permits; return $permits;
} }
......
...@@ -56,6 +56,7 @@ ...@@ -56,6 +56,7 @@
'permit_retag' => 'Retagging any question', 'permit_retag' => 'Retagging any question',
'permit_select_a' => 'Selecting answer for any question', 'permit_select_a' => 'Selecting answer for any question',
'permit_view_q_page' => 'Viewing question pages', '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_special_users_page' => 'Viewing the special users page',
'permit_view_voters_flaggers' => 'Viewing who voted or flagged posts', 'permit_view_voters_flaggers' => 'Viewing who voted or flagged posts',
'permit_vote_a' => 'Voting on answers', 'permit_vote_a' => 'Voting on answers',
......
...@@ -1343,6 +1343,7 @@ foreach ($showoptions as $optionname) { ...@@ -1343,6 +1343,7 @@ foreach ($showoptions as $optionname) {
break; break;
case 'permit_view_q_page': case 'permit_view_q_page':
case 'permit_view_new_users_page':
case 'permit_view_special_users_page': case 'permit_view_special_users_page':
case 'permit_post_q': case 'permit_post_q':
case 'permit_post_a': case 'permit_post_a':
...@@ -1371,7 +1372,7 @@ foreach ($showoptions as $optionname) { ...@@ -1371,7 +1372,7 @@ foreach ($showoptions as $optionname) {
else else
$optionfield['label'] = qa_lang_html('profile/' . $optionname) . ':'; $optionfield['label'] = qa_lang_html('profile/' . $optionname) . ':';
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') 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; $widest = QA_PERMIT_ALL;
elseif ($optionname == 'permit_close_q' || $optionname == 'permit_select_a' || $optionname == 'permit_moderate' || $optionname == 'permit_hide_show') elseif ($optionname == 'permit_close_q' || $optionname == 'permit_select_a' || $optionname == 'permit_moderate' || $optionname == 'permit_hide_show')
$widest = QA_PERMIT_POINTS; $widest = QA_PERMIT_POINTS;
...@@ -1385,7 +1386,7 @@ foreach ($showoptions as $optionname) { ...@@ -1385,7 +1386,7 @@ foreach ($showoptions as $optionname) {
if ($optionname == 'permit_view_q_page') { if ($optionname == 'permit_view_q_page') {
$narrowest = QA_PERMIT_APPROVED; $narrowest = QA_PERMIT_APPROVED;
$dopoints = false; $dopoints = false;
} elseif ($optionname == 'permit_view_special_users_page') { } elseif ($optionname == 'permit_view_special_users_page' || $optionname == 'permit_view_new_users_page') {
$narrowest = QA_PERMIT_SUPERS; $narrowest = QA_PERMIT_SUPERS;
$dopoints = false; $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') } 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')
......
...@@ -33,6 +33,16 @@ require_once QA_INCLUDE_DIR . 'app/format.php'; ...@@ -33,6 +33,16 @@ require_once QA_INCLUDE_DIR . 'app/format.php';
if (QA_FINAL_EXTERNAL_USERS) if (QA_FINAL_EXTERNAL_USERS)
qa_fatal_error('User accounts are handled by external code'); 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 // Get list of all users
$start = qa_get_start(); $start = qa_get_start();
......
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