/usr/share/php/Horde/Kolab/Storage/Folder/Namespace/Element.php is in php-horde-kolab-storage 2.0.5-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 | <?php
/**
* The Horde_Kolab_Storage_Folder_Namespace_Element:: class represents a namespace type.
*
* PHP version 5
*
* @category Kolab
* @package Kolab_Storage
* @author Gunnar Wrobel <wrobel@pardus.de>
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @link http://pear.horde.org/index.php?package=Kolab_Storage
*/
/**
* The Horde_Kolab_Storage_Folder_Namespace_Element:: class represents a namespace type.
*
* Copyright 2010-2013 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.
*
* @category Kolab
* @package Kolab_Storage
* @author Gunnar Wrobel <wrobel@pardus.de>
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @link http://pear.horde.org/index.php?package=Kolab_Storage
*/
abstract class Horde_Kolab_Storage_Folder_Namespace_Element
{
/**
* The prefix identifying this namespace.
*
* @var string
*/
protected $_name;
/**
* The delimiter used for this namespace.
*
* @var string
*/
protected $_delimiter;
/**
* The current user.
*
* @var string
*/
protected $_user;
/**
* Constructor.
*
* @param string $name The prefix identifying this namespace.
* @param string $delimiter The delimiter used for this namespace.
* @param string $user The current user.
*/
public function __construct($name, $delimiter, $user)
{
if (substr($name, -1) == $delimiter) {
$name = substr($name, 0, -1);
}
$this->_name = $name;
$this->_delimiter = $delimiter;
$this->_user = $user;
}
/**
* Return the type of this namespace (personal, other, or shared).
*
* @return string The type.
*/
abstract public function getType();
/**
* Return the name of this namespace.
*
* @return string The name/prefix.
*/
public function getName()
{
return $this->_name;
}
/**
* Return the delimiter for this namespace.
*
* @return string The delimiter.
*/
public function getDelimiter()
{
return $this->_delimiter;
}
/**
* Does the folder name lie in this namespace?
*
* @param string $name The name of the folder.
*
* @return boolean True if the folder is element of this namespace.
*/
public function matches($name)
{
return (strpos($name, $this->_name) === 0);
}
/**
* Return the owner of a folder.
*
* @param string $name The name of the folder.
*
* @return string|boolean The owner of the folder.
*/
abstract public function getOwner($name);
/**
* Return the title of a folder.
*
* @param string $name The name of the folder.
*
* @return string The title of the folder.
*/
public function getTitle($name)
{
$subpath = $this->_subpath($name);
if (!empty($subpath)) {
return array_pop($subpath);
} else {
return '';
}
}
/**
* Get the sub path for the given folder name.
*
* @param string $name The folder name.
*
* @return string The sub path.
*/
public function getSubpath($name)
{
return join($this->_subpath($name), $this->_delimiter);
}
/**
* Get the parent for the given folder name.
*
* @param string $name The parent folder name.
*
* @return string The parent.
*/
public function getParent($name)
{
$path = explode($this->_delimiter, $name);
array_pop($path);
return join($path, $this->_delimiter);
}
/**
* Return an array describing the path elements of the folder.
*
* @param string $name The name of the folder.
*
* @return array The path elements.
*/
protected function _subpath($name)
{
$path = explode($this->_delimiter, $name);
if ($path[0] == $this->_name) {
array_shift($path);
}
//@todo: What about the potential trailing domain?
return $path;
}
/**
* Generate a folder path for the given path in this namespace.
*
* @param array $path The path of the folder.
*
* @return string The name of the folder.
*/
public function generateName($path)
{
if (!empty($this->_name)) {
array_unshift($path, $this->_name);
}
return join($path, $this->_delimiter);
}
/**
* Generate a folder path for the given subpath and owner.
*
* @param string $subpath The subpath of the folder.
* @param string $owner The folder owner.
*
* @return string The name of the folder.
*/
public function generatePath($subpath, $owner)
{
return empty($this->_name) ? $subpath : $this->_name . $this->_delimiter . $subpath;
}
/**
* Convert the namespace description to a string.
*
* @return string The namespace description.
*/
public function __toString()
{
return '"' . $this->_name . '" (' . $this->getType() . ', "' . $this->_delimiter . '")';
}
}
|