/usr/share/php/Horde/Share/Object.php is in php-horde-share 2.0.4-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 | <?php
/**
* Abstract class for storing Share information.
*
* This class should be extended for the more specific drivers.
*
* @author Mike Cochrane <mike@graftonhall.co.nz>
* @author Jan Schneider <jan@horde.org>
* @author Gunnar Wrobel <wrobel@pardus.de>
* @package Share
*/
abstract class Horde_Share_Object implements Serializable
{
/**
* A function to be called when a Horde_Share object is needed and not
* available.
*
* @var callback
*/
protected $_shareCallback;
/**
* The Horde_Share object which this share is associated with.
* If this is empty, the $_shareCallback is called to obtain it.
*
* @var Horde_Share
*/
protected $_shareOb;
/**
* Associates a Share object with this share, or provides a callback that
* knows how to provide it.
*
* @param mixed Horde_Share | Callback $shareOb The Share object.
*/
public function setShareOb($shareOb)
{
if ($shareOb instanceof Horde_Share_Base) {
$this->_shareOb = $shareOb;
} else {
$this->_shareCallback = $shareOb;
}
}
/**
* Obtain this object's share driver.
*
* @return Horde_Share The share driver.
*/
public function getShareOb()
{
if (empty($this->_shareOb)) {
$this->_shareOb = call_user_func($this->_shareCallback);
}
if (empty($this->_shareOb)) {
throw new Horde_Share_Exception('Unable to obtain a Horde_Share object');
}
return $this->_shareOb;
}
/**
* Sets an attribute value in this object.
*
* @param string $attribute The attribute to set.
* @param mixed $value The value for $attribute.
* @param boolean $update Immediately update only this change.
*
* @return boolean
*/
abstract public function set($attribute, $value, $update = false);
/**
* Returns an attribute value from this object.
*
* @param string $attribute The attribute to return.
*
* @return mixed The value for $attribute.
*/
abstract public function get($attribute);
/**
* Returns the ID of this share.
*
* @return string The share's ID.
*/
abstract public function getId();
/**
* Returns the name of this share.
*
* @return string The share's name.
*/
abstract public function getName();
/**
* Saves the current attribute values.
*
* @return boolean
* @throws Horde_Exception
*/
public function save()
{
$this->getShareOb()->runCallback('modify', array($this));
$this->getShareOb()->expireListCache();
return $this->_save();
}
/**
* Saves the current attribute values.
*/
abstract protected function _save();
/**
* Gives a user a certain privilege for this share.
*
* @param string $userid The userid of the user.
* @param integer $permission A Horde_Perms::* constant.
*/
public function addUserPermission($userid, $permission)
{
$perm = $this->getPermission();
$perm->addUserPermission($userid, $permission, false);
$this->setPermission($perm);
}
/**
* Removes a certain privilege for a user from this share.
*
* @param string $userid The userid of the user.
* @param integer $permission A Horde_Perms::* constant.
*/
public function removeUserPermission($userid, $permission)
{
$perm = $this->getPermission();
$perm->removeUserPermission($userid, $permission, false);
$this->setPermission($perm);
}
/**
* Gives a group certain privileges for this share.
*
* @param string $group The group to add permissions for.
* @param integer $permission A Horde_Perms::* constant.
*/
public function addGroupPermission($group, $permission)
{
$perm = $this->getPermission();
$perm->addGroupPermission($group, $permission, false);
$this->setPermission($perm);
}
/**
* Removes a certain privilege from a group.
*
* @param string $group The group to remove permissions from.
* @param constant $permission A Horde_Perms::* constant.
*/
public function removeGroupPermission($group, $permission)
{
$perm = $this->getPermission();
$perm->removeGroupPermission($group, $permission, false);
$this->setPermission($perm);
}
/**
* Removes a user from this share.
*
* @param string $userid The userid of the user to remove.
*/
public function removeUser($userid)
{
/* Remove all $userid's permissions. */
$perm = $this->getPermission();
$perm->removeUserPermission($userid, Horde_Perms::SHOW, false);
$perm->removeUserPermission($userid, Horde_Perms::READ, false);
$perm->removeUserPermission($userid, Horde_Perms::EDIT, false);
$perm->removeUserPermission($userid, Horde_Perms::DELETE, false);
return $this->setPermission($perm);
}
/**
* Removes a group from this share.
*
* @param integer $groupId The group to remove.
*/
public function removeGroup($groupId)
{
/* Remove all $groupId's permissions. */
$perm = $this->getPermission();
$perm->removeGroupPermission($groupId, Horde_Perms::SHOW, false);
$perm->removeGroupPermission($groupId, Horde_Perms::READ, false);
$perm->removeGroupPermission($groupId, Horde_Perms::EDIT, false);
$perm->removeGroupPermission($groupId, Horde_Perms::DELETE, false);
return $this->setPermission($perm);
}
/**
* Returns an array containing all the userids of the users with access to
* this share.
*
* @param integer $perm_level List only users with this permission level.
* Defaults to all users.
*
* @return array The users with access to this share.
*/
public function listUsers($perm_level = null)
{
$perm = $this->getPermission();
$results = array_keys($perm->getUserPermissions($perm_level));
// Always return the share's owner.
$owner = $this->get('owner');
if ($owner && !in_array($owner, $results)) {
$results[] = $owner;
}
return $results;
}
/**
* Returns an array containing all the groupids of the groups with access
* to this share.
*
* @param integer $perm_level List only users with this permission level.
* Defaults to all users.
*
* @return array The IDs of the groups with access to this share.
*/
public function listGroups($perm_level = null)
{
$perm = $this->getPermission();
return array_keys($perm->getGroupPermissions($perm_level));
}
/**
* 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.
* @param integer $permission A Horde_Perms::* constant to test for.
* @param string $creator The creator of the event.
*
* @return boolean Whether or not $userid has $permission.
*/
abstract public function hasPermission($userid, $permission,
$creator = null);
/**
* Sets the permission of this share.
*
* @param Horde_Perms_Permission $perm Permission object.
* @param boolean $update Should the share be saved
* after this operation?
*/
abstract public function setPermission($perm, $update = true);
/**
* Returns the permission of this share.
*
* @return Horde_Perms_Permission Permission object that represents the
* permissions on this share.
*/
abstract public function getPermission();
}
|