From 6053160b382f28986d7147102b951c965043b3cb Mon Sep 17 00:00:00 2001 From: Jan Schneider Date: Fri, 28 Jan 2011 15:39:54 +0100 Subject: [PATCH] Add shortcut methods for adding and removing default, guest, and creator permissions. --- framework/Share/lib/Horde/Share/Object.php | 72 ++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/framework/Share/lib/Horde/Share/Object.php b/framework/Share/lib/Horde/Share/Object.php index 9c100cff8..08452bb01 100644 --- a/framework/Share/lib/Horde/Share/Object.php +++ b/framework/Share/lib/Horde/Share/Object.php @@ -229,6 +229,78 @@ abstract class Horde_Share_Object implements Serializable } /** + * Gives guests a certain privilege for this share. + * + * @param integer $permission A Horde_Perms::* constant. + */ + public function addGuestPermission($permission) + { + $perm = $this->getPermission(); + $perm->addGuestPermission($permission, false); + $this->setPermission($perm); + } + + /** + * Removes a certain privilege for guests from this share. + * + * @param integer $permission A Horde_Perms::* constant. + */ + public function removeGuestPermission($permission) + { + $perm = $this->getPermission(); + $perm->removeGuestPermission($permission, false); + $this->setPermission($perm); + } + + /** + * Gives creators a certain privilege for this share. + * + * @param integer $permission A Horde_Perms::* constant. + */ + public function addCreatorPermission($permission) + { + $perm = $this->getPermission(); + $perm->addCreatorPermission($permission, false); + $this->setPermission($perm); + } + + /** + * Removes a certain privilege for creators from this share. + * + * @param integer $permission A Horde_Perms::* constant. + */ + public function removeCreatorPermission($permission) + { + $perm = $this->getPermission(); + $perm->removeCreatorPermission($permission, false); + $this->setPermission($perm); + } + + /** + * Gives all authenticated users a certain privilege for this share. + * + * @param integer $permission A Horde_Perms::* constant. + */ + public function addDefaultPermission($permission) + { + $perm = $this->getPermission(); + $perm->addDefaultPermission($permission, false); + $this->setPermission($perm); + } + + /** + * Removes a certain privilege for all authenticated users from this share. + * + * @param integer $permission A Horde_Perms::* constant. + */ + public function removeDefaultPermission($permission) + { + $perm = $this->getPermission(); + $perm->removeDefaultPermission($permission, false); + $this->setPermission($perm); + } + + /** * Checks to see if a user has a given permission. * * @param string $userid The userid of the user. -- 2.11.0