From 9249f892b1e635979db2a830393694fb73531080 Mon Sep 17 00:00:00 2001 From: Cameron Date: Sat, 27 Dec 2014 12:02:12 -0800 Subject: [PATCH] Added additional check prior to administrator status change. --- e107_admin/users.php | 20 ++++++++++++++------ e107_handlers/user_handler.php | 7 +++++++ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/e107_admin/users.php b/e107_admin/users.php index 25413f1e0..2c99909c7 100644 --- a/e107_admin/users.php +++ b/e107_admin/users.php @@ -695,15 +695,23 @@ class users_admin_ui extends e_admin_ui $this->redirect('list', 'main', true); } - if(!$sysuser->isAdmin()) + + if($this->getPosted('update_admin')) { - $sysuser->set('user_admin', 1)->save(); //"user","user_admin='1' WHERE user_id={$userid}" - $lan = str_replace(array('--UID--', '--NAME--', '--EMAIL--'), array($sysuser->getId(), $sysuser->getName(), $sysuser->getValue('email')), USRLAN_164); - e107::getLog()->add('USET_08', $lan, E_LOG_INFORMATIVE); - $mes->addSuccess($lan); + e107::getUserPerms()->updatePerms($userid, $_POST['perms']); + $this->redirect('list', 'main', true); + } + + if(!$sysuser->isAdmin()) // Security Check Only. Admin status check is added during 'updatePerms'. + { + // $sysuser->set('user_admin', 1)->save(); //"user","user_admin='1' WHERE user_id={$userid}" + // $lan = str_replace(array('--UID--', '--NAME--', '--EMAIL--'), array($sysuser->getId(), $sysuser->getName(), $sysuser->getValue('email')), USRLAN_164); + // e107::getLog()->add('USET_08', $lan, E_LOG_INFORMATIVE); + // $mes->addSuccess($lan); + $mes->addWarning("You are about to make User #".$sysuser->getId()." : ".$sysuser->getName()." (".$sysuser->getValue('email').") an administrator."); ///TODO LAN + $mes->addWarning("Set the permissions and click Update to proceed or Back to abort."); } - if($this->getPosted('update_admin')) e107::getUserPerms()->updatePerms($userid, $_POST['perms']); } /** diff --git a/e107_handlers/user_handler.php b/e107_handlers/user_handler.php index 0b2c7eb05..1c156a5f5 100644 --- a/e107_handlers/user_handler.php +++ b/e107_handlers/user_handler.php @@ -1598,6 +1598,13 @@ class e_userperms } //$sql->db_Update("user", "user_perms='{$perm}' WHERE user_id='{$modID}' ") + if(!$sysuser->isAdmin()) + { + $sysuser->set('user_admin', 1)->save(); + $lan = str_replace(array('--UID--', '--NAME--', '--EMAIL--'), array($sysuser->getId(), $sysuser->getName(), $sysuser->getValue('email')), USRLAN_164); + e107::getLog()->add('USET_08', $lan, E_LOG_INFORMATIVE); + } + e107::getMessage()->addAuto($sysuser->set('user_perms', $perm)->save(), 'update', sprintf(LAN_UPDATED, $tp->toDB($_POST['ad_name'])), false, false); $logMsg = str_replace(array('--ID--', '--NAME--'),array($modID, $a_name),ADMSLAN_72).$perm; e107::getLog()->add('ADMIN_01',$logMsg,E_LOG_INFORMATIVE,'');