/** * Function to remove a user from Joomla */ function removeUsers($cid) { global $database, $acl, $my, $vmLogger, $VM_LANG; if (!is_array($cid)) { $cid = array($cid); } if (count($cid)) { $obj = new mosUser($database); foreach ($cid as $id) { // check for a super admin ... can't delete them //TODO: Find out the group name of the User to be deleted // $groups = $acl->get_object_groups( 'users', $id, 'ARO' ); // $this_group = strtolower( $acl->get_group_name( $groups[0], 'ARO' ) ); $obj->load($id); $this_group = strtolower($obj->get('usertype')); if ($this_group == 'super administrator') { $vmLogger->err($VM_LANG->_('VM_USER_DELETE_ERR_SUPERADMIN')); return false; } else { if ($id == $my->id) { $vmLogger->err($VM_LANG->_('VM_USER_DELETE_ERR_YOURSELF')); return false; } else { if ($this_group == 'administrator' && $my->gid == 24) { $vmLogger->err($VM_LANG->_('VM_USER_DELETE_ERR_ADMIN')); return false; } else { $obj->delete($id); $err = $obj->getError(); if ($err) { $vmLogger->err($err); return false; } return true; } } } } } }
function removeUsers($cid, $option) { global $database, $acl, $my; if (!is_array($cid) || count($cid) < 1) { $msg = T_("Select an item to delete"); mosRedirect('index2.php?option=' . $option, $msg); } if (in_array($my->id, $cid)) { $msg = T_("You cannot delete yourself!"); mosRedirect('index2.php?option=' . $option, $msg); } // count super/admin gids within $cid $super_gid = $acl->get_group_id('super administrator'); $admin_gid = $acl->get_group_id('administrator'); $cids = implode(',', $cid); $database->setQuery("SELECT COUNT(id) FROM #__users WHERE id IN ({$cids}) AND gid IN ({$super_gid},{$admin_gid})"); if ($database->getErrorMsg()) { echo $database->stderr(); return; } $admin_count = (int) $database->loadResult(); // disallow deleting administrators / super administrators if not super administrator if ($admin_count && $my->gid !== $super_gid) { $msg = T_("You cannot delete another `Administrator` only `Super Administrators` have this power"); mosRedirect('index2.php?option=' . $option, $msg); } if (count($cid)) { $obj = new mosUser($database); $deleted = array(); foreach ($cid as $id) { $obj->delete($id); $deleted[] = $id; $msg = $obj->getError(); } if (count($deleted)) { $mambothandler =& mosMambotHandler::getInstance(); $mambothandler->loadBotGroup('authenticator'); $cids = implode(',', $deleted); $query = "SELECT username FROM #__users WHERE id IN ({$cids})"; $database->setQuery($query); $results = $database->loadResultArray(); if ($results) { foreach ($results as $result) { $loginfo = new mosLoginDetails($result->username); $mambothandler->trigger('userDelete', array($loginfo)); } } } } mosRedirect('index2.php?option=' . $option, $msg); }
function removeUsers($cid, $option) { global $database, $acl, $adminLanguage; if (!is_array($cid) || count($cid) < 1) { echo "<script> alert(\"" . $adminLanguage->A_COMP_CONTENT_SEL_DEL . "\"); window.history.go(-1);</script>\n"; exit; } $msg = ''; if (count($cid)) { $obj = new mosUser($database); foreach ($cid as $id) { // check for a super admin ... can't delete them $groups = $acl->get_object_groups('users', $id, 'ARO'); $this_group = strtolower($acl->get_group_name($groups[0], 'ARO')); if ($this_group == 'super administrator') { $msg .= $adminLanguage->A_COMP_USERS_CANNOT; } else { $obj->delete($id); $msg .= $obj->getError(); } } } $limit = intval(mosGetParam($_REQUEST, 'limit', 10)); $limitstart = intval(mosGetParam($_REQUEST, 'limitstart', 0)); mosRedirect('index2.php?option=' . $option, $msg); }
function removeUsers($cid, $option) { global $database, $acl, $my; josSpoofCheck(); if (!is_array($cid) || count($cid) < 1) { echo "<script> alert('Select an item to delete'); window.history.go(-1);</script>\n"; exit; } $msg = checkUserPermissions($cid, 'delete'); if (!$msg && count($cid)) { $obj = new mosUser($database); foreach ($cid as $id) { $obj->load($id); $count = 2; if ($obj->gid == 25) { // count number of active super admins $query = "SELECT COUNT( id )" . "\n FROM #__users" . "\n WHERE gid = 25" . "\n AND block = 0"; $database->setQuery($query); $count = $database->loadResult(); } if ($count <= 1 && $obj->gid == 25) { // cannot delete Super Admin where it is the only one that exists $msg = "You cannot delete this Super Administrator as it is the only active Super Administrator for your site"; } else { // delete user $obj->delete($id); $msg = $obj->getError(); // delete user acounts active sessions logoutUser($id, 'com_users', 'remove'); } } } mosRedirect('index2.php?option=' . $option, $msg); }
function removeUsers($cid, $option) { global $database, $acl; if (!is_array($cid) || count($cid) < 1) { echo "<script> alert('Select an item to delete'); window.history.go(-1);</script>\n"; exit; } $msg = ''; if (count($cid)) { $obj = new mosUser($database); foreach ($cid as $id) { // check for a super admin ... can't delete them $groups = $acl->get_object_groups('users', $id, 'ARO'); $this_group = strtolower($acl->get_group_name($groups[0], 'ARO')); if ($this_group == 'super administrator') { $msg .= "You cannot delete a Super Administrator"; } else { $obj->delete($id); $msg .= $obj->getError(); $obj2 = new mosUser_extended($database); $obj2->delete($id); $msg .= $obj2->getError(); } } } $limit = intval(mosGetParam($_REQUEST, 'limit', 10)); $limitstart = intval(mosGetParam($_REQUEST, 'limitstart', 0)); mosRedirect("index2.php?option={$option}", $msg); }