Copyright 2009-2016 Horde LLC (http://www.horde.org/)
See the enclosed file COPYING for license information (LGPL). If you
did not receive this file, see http://www.horde.org/licenses/lgpl21.
/** * Create a permission deleting form. * * @param Horde_Perms_Permission $permission A permissions object. */ public function setupDeleteForm($permission) { /* Initialise form if required. */ $this->_formInit(); $this->_form->setTitle(sprintf(Horde_Core_Translation::t("Delete permissions for \"%s\""), $this->_corePerms->getTitle($permission->getName()))); $this->_form->setButtons(array(array('class' => 'horde-delete', 'value' => Horde_Core_Translation::t("Delete")), array('class' => 'horde-cancel', 'value' => Horde_Core_Translation::t("Do not delete")))); $this->_form->addHidden('', 'perm_id', 'text', false); $this->_form->addVariable(sprintf(Horde_Core_Translation::t("Delete permissions for \"%s\" and any sub-permissions?"), $this->_corePerms->getTitle($permission->getName())), 'prompt', 'description', false); }
/** * Returns an array of all user permissions on this object. * * @param integer $perm List only users with this permission level. * Defaults to all users. * * @return array All user permissions for this object, indexed by user. */ public function getUserPermissions($perm = null) { $users = parent::getUserPermissions($perm); unset($users[$this->_storage->getOwner()]); return $users; }
/** * Removes a permission from the permissions system permanently. * * @param Horde_Perms_Permission_Sql $perm The permission to * remove. * @param boolean $force Force to remove every * child. * * @return boolean True if permission was deleted. * @throws Horde_Perms_Exception */ public function removePermission(Horde_Perms_Permission $perm, $force = false) { $name = $perm->getName(); $this->_cache->expire('perm_sql_' . $this->_cacheVersion . $name); $this->_cache->expire('perm_sql_exists_' . $this->_cacheVersion . $name); $query = 'DELETE FROM ' . $this->_params['table'] . ' WHERE perm_name = ?'; try { $result = $this->_db->delete($query, array($name)); } catch (Horde_Db_Exception $e) { throw new Horde_Perms_Exception($e); } if (!$force) { return (bool) $result; } /* Need to expire cache for all sub-permissions. */ try { $sub = $this->_db->selectValues('SELECT perm_name FROM ' . $this->_params['table'] . ' WHERE perm_name LIKE ?', array($name . ':%')); foreach ($sub as $val) { $this->_cache->expire('perm_sql_' . $this->_cacheVersion . $val); $this->_cache->expire('perm_sql_exists_' . $this->_cacheVersion . $val); } } catch (Horde_Db_Exception $e) { } $query = 'DELETE FROM ' . $this->_params['table'] . ' WHERE perm_name LIKE ?'; try { return (bool) $this->_db->delete($query, array($name . ':%')); } catch (Horde_Db_Exception $e) { throw new Horde_Perms_Exception($e); } }
/** * Sets the permission of this share. * * @param Horde_Perms_Permission $perm Permission object. * @param boolean $update Should the share be saved * after this operation? */ public function setPermission($perm, $update = true) { $this->data['perm'] = $perm->getData(); if ($update) { $this->save(); } }