function deleteUsers($cid, $inComprofilerOnly = false)
{
    global $_CB_framework, $_CB_database;
    $msg = checkCBpermissions($cid, "delete", false);
    if (!$msg && is_array($cid) && count($cid)) {
        new cbTabs(0, 2, null, false);
        // loads plugins
        foreach ($cid as $id) {
            $obj =& $_CB_framework->_getCmsUserObject((int) $id);
            if ($obj !== null || $inComprofilerOnly) {
                $count = 2;
                if (checkJversion() == 2) {
                    $cms_super_admin = 8;
                    //TODO in CB 2.0 we will do this better
                } else {
                    $cms_super_admin = 25;
                }
                if ($obj !== null && $obj->gid == $cms_super_admin) {
                    // count number of active super admins
                    if (checkJversion() == 2) {
                        $query = 'SELECT COUNT( a.id )' . "\n FROM #__users AS a" . "\n INNER JOIN #__user_usergroup_map AS b" . ' ON b.user_id = a.id' . "\n WHERE b.group_id = " . (int) $cms_super_admin . "\n AND a.block = 0";
                    } else {
                        $query = 'SELECT COUNT( id )' . "\n FROM #__users" . "\n WHERE gid = " . (int) $cms_super_admin . "\n AND block = 0";
                    }
                    $_CB_database->setQuery($query);
                    $count = $_CB_database->loadResult();
                }
                if ($count <= 1 && $obj->gid == $cms_super_admin) {
                    // cannot delete Super Admin where it is the only one that exists
                    $msg .= CBTxt::T('You cannot delete this Super Administrator as it is the only active Super Administrator for your site');
                } else {
                    // delete user
                    $result = cbDeleteUser($id, null, $inComprofilerOnly);
                    if ($result === null) {
                        $msg .= CBTxt::T('User not found');
                    } elseif (is_string($result) && $result != "") {
                        $msg .= $result;
                    }
                }
            } else {
                $msg .= CBTxt::T('User not found');
            }
        }
    }
    return $msg;
}
Ejemplo n.º 2
0
function deleteUsers($cid, $inComprofilerOnly = false)
{
    global $_CB_framework;
    $msg = null;
    if (!Application::MyUser()->isAuthorizedToPerformActionOnAsset('core.admin', 'com_comprofiler')) {
        $msg = CBTxt::T('You cannot delete a user. Only higher-level users have this power.');
    }
    if (!$msg && is_array($cid) && count($cid)) {
        new cbTabs(0, 2, null, false);
        // loads plugins
        foreach ($cid as $id) {
            $obj = null;
            if (!$inComprofilerOnly) {
                $obj =& $_CB_framework->_getCmsUserObject((int) $id);
            }
            if ($obj !== null || $inComprofilerOnly) {
                // Just a double-check as framework checks that too:
                if ($_CB_framework->myId() != $id && ($obj === null || !(Application::User((int) $id)->isSuperAdmin() && !Application::MyUser()->isSuperAdmin()))) {
                    // delete user
                    $result = cbDeleteUser($id, null, $inComprofilerOnly);
                    if ($result === null) {
                        $msg .= CBTxt::T('User not found');
                    } elseif (is_string($result) && $result != "") {
                        $msg .= $result;
                    }
                } else {
                    // cannot delete Super Admin where it is the only one that exists
                    $msg .= CBTxt::T('You cannot delete yourself nor a Super Administrator without being Super Administrator');
                }
            } else {
                $msg .= CBTxt::T('User not found');
            }
        }
    }
    return $msg;
}
Ejemplo n.º 3
0
 /**
  * Deletes this record (no checks)
  *
  * @param  int      $oid   Key id of row to delete (otherwise it's the one of $this)
  * @return boolean         TRUE if OK, FALSE if error
  */
 function delete($oid = null)
 {
     $k = $this->_tbl_key;
     if ($oid) {
         $this->{$k} = (int) $oid;
     }
     $result = cbDeleteUser($this->{$k});
     if (!is_bool(result)) {
         $this->_error = $result;
         $result = false;
     }
     return $result;
 }