protected function processValid() { //Load class variable realmToEdit if (isset($this->fieldData['realmToEdit'])) { $this->realmToEdit = $this->fieldData['realmToEdit']; //The is_numeric call protects against sql injection on this variable if (!is_numeric($this->fieldData['realmToEdit'])) { $badrid = $this->fieldData['realmToEdit']; throw new LoggedException("An invalid realm id was passed ({$badrid})", 0, self::module, 'error'); } } if ($this->formName == 'addRealmDetailsForm' || $this->formName == 'modifyRealmDetailsForm') { //Save the details if the detailsForm is submitted if (!isset($this->fieldData['realmToEdit']) || $this->fieldData['realmToEdit'] == "") { AuthUtil::addRealm($this->fieldData['parentID'], $this->fieldData['name'], $this->fieldData); $this->fieldData['newRealmID'] = $this->realmToEdit; } else { AuthUtil::modifyRealm($this->realmToEdit, $this->fieldData); } } elseif ($this->formName == 'realmDeleteForm') { AuthUtil::deleteRealm($this->fieldData['realmToEdit']); } }
/** * Delete A realm * * This will return false if the specfied realm has children. Use * recursiveDeleteRealm() in order to remove children recursively * * @param array $realmPath The path to the realm to delete * @return boolean True if the realm was added, false if the add failed */ public static function deleteRealm($realmPath) { return AuthUtil::deleteRealm($realmPath); }
/** * Delete A realm * * This will recursively delete the given realm and all below it * and any permissions asociated with them * * @param mixed $realm The name of id of the realm to delete * * * */ public static function recursiveDeleteRealm($realm) { global $cfg; if (!is_numeric($realm)) { $realm = Auth::getRealmIDFromPath($realm); } if (!AuthUtil::deleteRealm($realm)) { $db = Database::getInstance($cfg['Auth']['dsn']); $sql = "SELECT realmid FROM realms WHERE parentid = ?"; $subRealmIDs = $db->getColumn($sql, 0, array($realm)); /*if(count($subRealmIDs) == 0){ throw new LoggedException('Somthing seems to have gone wrong', 0, self::module, 'error'); }*/ foreach ($subRealmIDs as $rid) { AuthUtil::recursiveDeleteRealm($rid); } } $db->delete('realmgrouplink', "realmid = {$realm}"); $db->delete('realmuserlink', "realmid = {$realm}"); AuthUtil::deleteRealm($realm); }