Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest sNews - sNews 1.7 - with its own forums - for discussion and user mods.

Author Topic: [PATCH] Admin access to User Privilege Options Panel  (Read 845 times)

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6019
  • Semantically Challenged
    • snews.ca
[PATCH] Admin access to User Privilege Options Panel
« on: August 11, 2010, 08:24:03 PM »

An issue with Admin access to the User Privilege Options cam up in this post while working out another issue, and I provided what appears to be a good Patch (solution) in my reponse post.

To be brief, we wanted the Admin to have access to all available User Privilege options in the expandable User Privilege panel in any User's Profile page. As it was, the Admin could set these options when creating a new account, but was not able to change and update them later on because they were not visible... later on. So this patch makes them visible.

NOTE: This patch pertains to the sNewsMU 1.6.3 [zip] - Multiple Users Version of sNews 1.6, that was updated as at Jan 11, 2008.
           If you have a newer updated version of the package, this patch is most likely already in it (in the snews.php file).
           Although... you should check the news.php file to be sure.


Identify this section of code and remove it and put it in a safe file for the time being:
Code: [Select]
<?php

// ----------------------- START OF REMOVED SECTION -------------------------------------------------------

if (get_identity($_SESSION['id'], 'level') == '1') {
echo html_input('fieldset''''''''''''''''''''''''''','<a title="'.l('mu_userlevel').'" onclick="toggle(\'sub2\')" style="cursor: pointer;">'.l('mu_userlevel').'</a>');
echo '<div id="sub2" style="display: none;">';
echo '<select id="level" name="user_level">';
echo '<option value="1"'.($level == '1' ' selected="selected"' '').'>'.l('mu_level_admin').'</option>';
echo '<option value="2"'.($level == '2' ' selected="selected"' '').'>'.l('mu_level_supereditor').'</option>';
echo '<option value="3"'.($level == '3' ' selected="selected"' '').'>'.l('mu_level_editor').'</option>';
echo '<option value="4"'.($level == '4' ' selected="selected"' '').'>'.l('mu_level_user').'</option></select>';
/************************************************************************
2008-1-11
FIX: by bakercad
Problem: Admin wasn't able to set this information, Super Editor and Editor shoudn't have this option. Only Admin with Site Owner privileges should have this acces
Offening code: if ($level == '2' || $level == '3'){
************************************************************************/
if ($level == '1' && get_identity($_SESSION['id'], 'site_owner') == 'YES'){
// END FIX
echo html_input('checkbox''edit_comments''edcom''YES'l('mu_edit_comments'), ''''''''$edit_comments'''''''''''');
echo html_input('checkbox''permit_upload''pfiles''YES'l('mu_permit_upload'), ''''''''$permit_upload'''''''''');
/************************************************************************
2008-1-11
FIX: by bakercad
Problem: $_GET['id'] is incorrect code
Offening code: if (get_identity($_GET['id'], 'site_owner') == 'YES'){
************************************************************************/
if (get_identity($_SESSION['id'], 'site_owner') == 'YES'){
// END FIX
echo html_input('checkbox''site_owner''sowner''YES'l('mu_site_owner'), ''''''''$site_owner'''''''''');
}
/************************************************************************
2008-1-11
FIX: by bakercad
Problem: no code to set in site_owner field in db table
Offening code: N/A
************************************************************************/
else {
echo html_input('hidden''site_owner''siteown''NO''''''''''''''''''''''');
}
// END FIX
}
echo '</div></fieldset>';
}

// ----------------------- END OF REMOVED SECTION -------------------------------------------------------

?>


and, above (or below) it, paste in this revised section:
Code: [Select]
<?php

// START: User Privilege Level Panel
#--------------------------------------------------------------------------------------------------------
#  PATCH: (keyrocks, Nov.04.09 - refined Aug.11.10)
#  Problem: Admin wasn't able to see 3 check-box options.
#  Super Editor and Editor shoudn't have this option but Admin should.
#  This fix shows the full User Privilege Panel only to the Admin(1)
#--------------------------------------------------------------------------------------------------------

# If logged-in user is Admin (level 1)
if (get_identity($_SESSION['id'], 'level') == '1') {
    # Show User Privilege Level Panel -------------------
    echo html_input('fieldset''''''''''''''''''''''''''','<a title="'.l('mu_userlevel').'" onclick="toggle(\'sub2\')" style="cursor: pointer;">'.l('mu_userlevel').'</a>');
    echo '<div id="sub2" style="display: none;">';
    # User level drop-down, 5 strings
    echo '<select id="level" name="user_level">';
    echo '<option value="1"'.($level == '1' ' selected="selected"' '').'>'.l('mu_level_admin').'</option>';
    echo '<option value="2"'.($level == '2' ' selected="selected"' '').'>'.l('mu_level_supereditor').'</option>';
    echo '<option value="3"'.($level == '3' ' selected="selected"' '').'>'.l('mu_level_editor').'</option>';
    echo '<option value="4"'.($level == '4' ' selected="selected"' '').'>'.l('mu_level_user').'</option></select>';
    # check-box: edit comments option
    echo html_input('checkbox''edit_comments''edcom''YES'l('mu_edit_comments'), ''''''''$edit_comments'''''''''''');
    # check-box: files manager access option
    echo html_input('checkbox''permit_upload''pfiles''YES'l('mu_permit_upload'), ''''''''$permit_upload'''''''''');
    # If logged-in user's site owner status is YES
    if (get_identity($_SESSION['id'], 'site_owner') == 'YES'){
# show site owner status as checked
echo html_input('checkbox''site_owner''sowner''YES'l('mu_site_owner'), ''''''''$site_owner'''''''''');
    } else { # show site owner status as un-checked
echo html_input('hidden''site_owner''siteown''NO''''''''''''''''''''''');
    }
    echo '</div></fieldset>';
}
# END: User Privilege Level Panel ----------

?>

« Last Edit: August 11, 2010, 08:28:04 PM by Keyrocks »
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU