@@ -91,8 +91,9 @@ discard block |
||
| 91 | 91 | */ |
| 92 | 92 | function getChildren() { |
| 93 | 93 | |
| 94 | - if ($this->disableListing) |
|
| 95 | - throw new DAV\Exception\MethodNotAllowed('Listing members of this collection is disabled'); |
|
| 94 | + if ($this->disableListing) { |
|
| 95 | + throw new DAV\Exception\MethodNotAllowed('Listing members of this collection is disabled'); |
|
| 96 | + } |
|
| 96 | 97 | |
| 97 | 98 | $children = []; |
| 98 | 99 | foreach ($this->principalBackend->getPrincipalsByPrefix($this->principalPrefix) as $principalInfo) { |
@@ -115,7 +116,9 @@ discard block |
||
| 115 | 116 | function getChild($name) { |
| 116 | 117 | |
| 117 | 118 | $principalInfo = $this->principalBackend->getPrincipalByPath($this->principalPrefix . '/' . $name); |
| 118 | - if (!$principalInfo) throw new DAV\Exception\NotFound('Principal with name ' . $name . ' not found'); |
|
| 119 | + if (!$principalInfo) { |
|
| 120 | + throw new DAV\Exception\NotFound('Principal with name ' . $name . ' not found'); |
|
| 121 | + } |
|
| 119 | 122 | return $this->getChildForPrincipal($principalInfo); |
| 120 | 123 | |
| 121 | 124 | } |
@@ -19,163 +19,163 @@ |
||
| 19 | 19 | */ |
| 20 | 20 | abstract class AbstractPrincipalCollection extends DAV\Collection implements IPrincipalCollection { |
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * Principal backend |
|
| 24 | - * |
|
| 25 | - * @var PrincipalBackend\BackendInterface |
|
| 26 | - */ |
|
| 27 | - protected $principalBackend; |
|
| 28 | - |
|
| 29 | - /** |
|
| 30 | - * The path to the principals we're listing from. |
|
| 31 | - * |
|
| 32 | - * @var string |
|
| 33 | - */ |
|
| 34 | - protected $principalPrefix; |
|
| 35 | - |
|
| 36 | - /** |
|
| 37 | - * If this value is set to true, it effectively disables listing of users |
|
| 38 | - * it still allows user to find other users if they have an exact url. |
|
| 39 | - * |
|
| 40 | - * @var bool |
|
| 41 | - */ |
|
| 42 | - public $disableListing = false; |
|
| 43 | - |
|
| 44 | - /** |
|
| 45 | - * Creates the object |
|
| 46 | - * |
|
| 47 | - * This object must be passed the principal backend. This object will |
|
| 48 | - * filter all principals from a specified prefix ($principalPrefix). The |
|
| 49 | - * default is 'principals', if your principals are stored in a different |
|
| 50 | - * collection, override $principalPrefix |
|
| 51 | - * |
|
| 52 | - * |
|
| 53 | - * @param PrincipalBackend\BackendInterface $principalBackend |
|
| 54 | - * @param string $principalPrefix |
|
| 55 | - */ |
|
| 56 | - public function __construct(PrincipalBackend\BackendInterface $principalBackend, $principalPrefix = 'principals') { |
|
| 57 | - |
|
| 58 | - $this->principalPrefix = $principalPrefix; |
|
| 59 | - $this->principalBackend = $principalBackend; |
|
| 60 | - |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - /** |
|
| 64 | - * This method returns a node for a principal. |
|
| 65 | - * |
|
| 66 | - * The passed array contains principal information, and is guaranteed to |
|
| 67 | - * at least contain a uri item. Other properties may or may not be |
|
| 68 | - * supplied by the authentication backend. |
|
| 69 | - * |
|
| 70 | - * @param array $principalInfo |
|
| 71 | - * @return IPrincipal |
|
| 72 | - */ |
|
| 73 | - abstract function getChildForPrincipal(array $principalInfo); |
|
| 74 | - |
|
| 75 | - /** |
|
| 76 | - * Returns the name of this collection. |
|
| 77 | - * |
|
| 78 | - * @return string |
|
| 79 | - */ |
|
| 80 | - public function getName() { |
|
| 81 | - |
|
| 82 | - list(, $name) = URLUtil::splitPath($this->principalPrefix); |
|
| 83 | - return $name; |
|
| 84 | - |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - /** |
|
| 88 | - * Return the list of users |
|
| 89 | - * |
|
| 90 | - * @return array |
|
| 91 | - */ |
|
| 92 | - public function getChildren() { |
|
| 93 | - |
|
| 94 | - if ($this->disableListing) |
|
| 95 | - throw new DAV\Exception\MethodNotAllowed('Listing members of this collection is disabled'); |
|
| 96 | - |
|
| 97 | - $children = []; |
|
| 98 | - foreach ($this->principalBackend->getPrincipalsByPrefix($this->principalPrefix) as $principalInfo) { |
|
| 99 | - |
|
| 100 | - $children[] = $this->getChildForPrincipal($principalInfo); |
|
| 101 | - |
|
| 102 | - |
|
| 103 | - } |
|
| 104 | - return $children; |
|
| 105 | - |
|
| 106 | - } |
|
| 107 | - |
|
| 108 | - /** |
|
| 109 | - * Returns a child object, by its name. |
|
| 110 | - * |
|
| 111 | - * @param string $name |
|
| 112 | - * @throws DAV\Exception\NotFound |
|
| 113 | - * @return IPrincipal |
|
| 114 | - */ |
|
| 115 | - public function getChild($name) { |
|
| 116 | - |
|
| 117 | - $principalInfo = $this->principalBackend->getPrincipalByPath($this->principalPrefix . '/' . $name); |
|
| 118 | - if (!$principalInfo) throw new DAV\Exception\NotFound('Principal with name ' . $name . ' not found'); |
|
| 119 | - return $this->getChildForPrincipal($principalInfo); |
|
| 120 | - |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - /** |
|
| 124 | - * This method is used to search for principals matching a set of |
|
| 125 | - * properties. |
|
| 126 | - * |
|
| 127 | - * This search is specifically used by RFC3744's principal-property-search |
|
| 128 | - * REPORT. You should at least allow searching on |
|
| 129 | - * http://sabredav.org/ns}email-address. |
|
| 130 | - * |
|
| 131 | - * The actual search should be a unicode-non-case-sensitive search. The |
|
| 132 | - * keys in searchProperties are the WebDAV property names, while the values |
|
| 133 | - * are the property values to search on. |
|
| 134 | - * |
|
| 135 | - * By default, if multiple properties are submitted to this method, the |
|
| 136 | - * various properties should be combined with 'AND'. If $test is set to |
|
| 137 | - * 'anyof', it should be combined using 'OR'. |
|
| 138 | - * |
|
| 139 | - * This method should simply return a list of 'child names', which may be |
|
| 140 | - * used to call $this->getChild in the future. |
|
| 141 | - * |
|
| 142 | - * @param array $searchProperties |
|
| 143 | - * @param string $test |
|
| 144 | - * @return array |
|
| 145 | - */ |
|
| 146 | - public function searchPrincipals(array $searchProperties, $test = 'allof') { |
|
| 147 | - |
|
| 148 | - $result = $this->principalBackend->searchPrincipals($this->principalPrefix, $searchProperties, $test); |
|
| 149 | - $r = []; |
|
| 150 | - |
|
| 151 | - foreach ($result as $row) { |
|
| 152 | - list(, $r[]) = URLUtil::splitPath($row); |
|
| 153 | - } |
|
| 154 | - |
|
| 155 | - return $r; |
|
| 156 | - |
|
| 157 | - } |
|
| 158 | - |
|
| 159 | - /** |
|
| 160 | - * Finds a principal by its URI. |
|
| 161 | - * |
|
| 162 | - * This method may receive any type of uri, but mailto: addresses will be |
|
| 163 | - * the most common. |
|
| 164 | - * |
|
| 165 | - * Implementation of this API is optional. It is currently used by the |
|
| 166 | - * CalDAV system to find principals based on their email addresses. If this |
|
| 167 | - * API is not implemented, some features may not work correctly. |
|
| 168 | - * |
|
| 169 | - * This method must return a relative principal path, or null, if the |
|
| 170 | - * principal was not found or you refuse to find it. |
|
| 171 | - * |
|
| 172 | - * @param string $uri |
|
| 173 | - * @return string |
|
| 174 | - */ |
|
| 175 | - public function findByUri($uri) { |
|
| 176 | - |
|
| 177 | - return $this->principalBackend->findByUri($uri, $this->principalPrefix); |
|
| 178 | - |
|
| 179 | - } |
|
| 22 | + /** |
|
| 23 | + * Principal backend |
|
| 24 | + * |
|
| 25 | + * @var PrincipalBackend\BackendInterface |
|
| 26 | + */ |
|
| 27 | + protected $principalBackend; |
|
| 28 | + |
|
| 29 | + /** |
|
| 30 | + * The path to the principals we're listing from. |
|
| 31 | + * |
|
| 32 | + * @var string |
|
| 33 | + */ |
|
| 34 | + protected $principalPrefix; |
|
| 35 | + |
|
| 36 | + /** |
|
| 37 | + * If this value is set to true, it effectively disables listing of users |
|
| 38 | + * it still allows user to find other users if they have an exact url. |
|
| 39 | + * |
|
| 40 | + * @var bool |
|
| 41 | + */ |
|
| 42 | + public $disableListing = false; |
|
| 43 | + |
|
| 44 | + /** |
|
| 45 | + * Creates the object |
|
| 46 | + * |
|
| 47 | + * This object must be passed the principal backend. This object will |
|
| 48 | + * filter all principals from a specified prefix ($principalPrefix). The |
|
| 49 | + * default is 'principals', if your principals are stored in a different |
|
| 50 | + * collection, override $principalPrefix |
|
| 51 | + * |
|
| 52 | + * |
|
| 53 | + * @param PrincipalBackend\BackendInterface $principalBackend |
|
| 54 | + * @param string $principalPrefix |
|
| 55 | + */ |
|
| 56 | + public function __construct(PrincipalBackend\BackendInterface $principalBackend, $principalPrefix = 'principals') { |
|
| 57 | + |
|
| 58 | + $this->principalPrefix = $principalPrefix; |
|
| 59 | + $this->principalBackend = $principalBackend; |
|
| 60 | + |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + /** |
|
| 64 | + * This method returns a node for a principal. |
|
| 65 | + * |
|
| 66 | + * The passed array contains principal information, and is guaranteed to |
|
| 67 | + * at least contain a uri item. Other properties may or may not be |
|
| 68 | + * supplied by the authentication backend. |
|
| 69 | + * |
|
| 70 | + * @param array $principalInfo |
|
| 71 | + * @return IPrincipal |
|
| 72 | + */ |
|
| 73 | + abstract function getChildForPrincipal(array $principalInfo); |
|
| 74 | + |
|
| 75 | + /** |
|
| 76 | + * Returns the name of this collection. |
|
| 77 | + * |
|
| 78 | + * @return string |
|
| 79 | + */ |
|
| 80 | + public function getName() { |
|
| 81 | + |
|
| 82 | + list(, $name) = URLUtil::splitPath($this->principalPrefix); |
|
| 83 | + return $name; |
|
| 84 | + |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + /** |
|
| 88 | + * Return the list of users |
|
| 89 | + * |
|
| 90 | + * @return array |
|
| 91 | + */ |
|
| 92 | + public function getChildren() { |
|
| 93 | + |
|
| 94 | + if ($this->disableListing) |
|
| 95 | + throw new DAV\Exception\MethodNotAllowed('Listing members of this collection is disabled'); |
|
| 96 | + |
|
| 97 | + $children = []; |
|
| 98 | + foreach ($this->principalBackend->getPrincipalsByPrefix($this->principalPrefix) as $principalInfo) { |
|
| 99 | + |
|
| 100 | + $children[] = $this->getChildForPrincipal($principalInfo); |
|
| 101 | + |
|
| 102 | + |
|
| 103 | + } |
|
| 104 | + return $children; |
|
| 105 | + |
|
| 106 | + } |
|
| 107 | + |
|
| 108 | + /** |
|
| 109 | + * Returns a child object, by its name. |
|
| 110 | + * |
|
| 111 | + * @param string $name |
|
| 112 | + * @throws DAV\Exception\NotFound |
|
| 113 | + * @return IPrincipal |
|
| 114 | + */ |
|
| 115 | + public function getChild($name) { |
|
| 116 | + |
|
| 117 | + $principalInfo = $this->principalBackend->getPrincipalByPath($this->principalPrefix . '/' . $name); |
|
| 118 | + if (!$principalInfo) throw new DAV\Exception\NotFound('Principal with name ' . $name . ' not found'); |
|
| 119 | + return $this->getChildForPrincipal($principalInfo); |
|
| 120 | + |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + /** |
|
| 124 | + * This method is used to search for principals matching a set of |
|
| 125 | + * properties. |
|
| 126 | + * |
|
| 127 | + * This search is specifically used by RFC3744's principal-property-search |
|
| 128 | + * REPORT. You should at least allow searching on |
|
| 129 | + * http://sabredav.org/ns}email-address. |
|
| 130 | + * |
|
| 131 | + * The actual search should be a unicode-non-case-sensitive search. The |
|
| 132 | + * keys in searchProperties are the WebDAV property names, while the values |
|
| 133 | + * are the property values to search on. |
|
| 134 | + * |
|
| 135 | + * By default, if multiple properties are submitted to this method, the |
|
| 136 | + * various properties should be combined with 'AND'. If $test is set to |
|
| 137 | + * 'anyof', it should be combined using 'OR'. |
|
| 138 | + * |
|
| 139 | + * This method should simply return a list of 'child names', which may be |
|
| 140 | + * used to call $this->getChild in the future. |
|
| 141 | + * |
|
| 142 | + * @param array $searchProperties |
|
| 143 | + * @param string $test |
|
| 144 | + * @return array |
|
| 145 | + */ |
|
| 146 | + public function searchPrincipals(array $searchProperties, $test = 'allof') { |
|
| 147 | + |
|
| 148 | + $result = $this->principalBackend->searchPrincipals($this->principalPrefix, $searchProperties, $test); |
|
| 149 | + $r = []; |
|
| 150 | + |
|
| 151 | + foreach ($result as $row) { |
|
| 152 | + list(, $r[]) = URLUtil::splitPath($row); |
|
| 153 | + } |
|
| 154 | + |
|
| 155 | + return $r; |
|
| 156 | + |
|
| 157 | + } |
|
| 158 | + |
|
| 159 | + /** |
|
| 160 | + * Finds a principal by its URI. |
|
| 161 | + * |
|
| 162 | + * This method may receive any type of uri, but mailto: addresses will be |
|
| 163 | + * the most common. |
|
| 164 | + * |
|
| 165 | + * Implementation of this API is optional. It is currently used by the |
|
| 166 | + * CalDAV system to find principals based on their email addresses. If this |
|
| 167 | + * API is not implemented, some features may not work correctly. |
|
| 168 | + * |
|
| 169 | + * This method must return a relative principal path, or null, if the |
|
| 170 | + * principal was not found or you refuse to find it. |
|
| 171 | + * |
|
| 172 | + * @param string $uri |
|
| 173 | + * @return string |
|
| 174 | + */ |
|
| 175 | + public function findByUri($uri) { |
|
| 176 | + |
|
| 177 | + return $this->principalBackend->findByUri($uri, $this->principalPrefix); |
|
| 178 | + |
|
| 179 | + } |
|
| 180 | 180 | |
| 181 | 181 | } |
@@ -59,8 +59,12 @@ |
||
| 59 | 59 | |
| 60 | 60 | $path = $this->path . '/' . $name; |
| 61 | 61 | |
| 62 | - if (!file_exists($path)) throw new NotFound('File could not be located'); |
|
| 63 | - if ($name == '.' || $name == '..') throw new Forbidden('Permission denied to . and ..'); |
|
| 62 | + if (!file_exists($path)) { |
|
| 63 | + throw new NotFound('File could not be located'); |
|
| 64 | + } |
|
| 65 | + if ($name == '.' || $name == '..') { |
|
| 66 | + throw new Forbidden('Permission denied to . and ..'); |
|
| 67 | + } |
|
| 64 | 68 | |
| 65 | 69 | if (is_dir($path)) { |
| 66 | 70 | |
@@ -2,10 +2,10 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace Sabre\DAVACL\FS; |
| 4 | 4 | |
| 5 | -use Sabre\DAV\FSExt\Directory as BaseCollection; |
|
| 6 | 5 | use Sabre\DAVACL\IACL; |
| 7 | 6 | use Sabre\DAV\Exception\Forbidden; |
| 8 | 7 | use Sabre\DAV\Exception\NotFound; |
| 8 | +use Sabre\DAV\FSExt\Directory as BaseCollection; |
|
| 9 | 9 | |
| 10 | 10 | /** |
| 11 | 11 | * This is an ACL-enabled collection. |
@@ -16,138 +16,138 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | class Collection extends BaseCollection implements IACL { |
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * A list of ACL rules. |
|
| 21 | - * |
|
| 22 | - * @var array |
|
| 23 | - */ |
|
| 24 | - protected $acl; |
|
| 25 | - |
|
| 26 | - /** |
|
| 27 | - * Owner uri, or null for no owner. |
|
| 28 | - * |
|
| 29 | - * @var string|null |
|
| 30 | - */ |
|
| 31 | - protected $owner; |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * Constructor |
|
| 35 | - * |
|
| 36 | - * @param string $path on-disk path. |
|
| 37 | - * @param array $acl ACL rules. |
|
| 38 | - * @param string|null $owner principal owner string. |
|
| 39 | - */ |
|
| 40 | - public function __construct($path, array $acl, $owner = null) { |
|
| 41 | - |
|
| 42 | - parent::__construct($path); |
|
| 43 | - $this->acl = $acl; |
|
| 44 | - $this->owner = $owner; |
|
| 45 | - |
|
| 46 | - } |
|
| 47 | - |
|
| 48 | - /** |
|
| 49 | - * Returns a specific child node, referenced by its name |
|
| 50 | - * |
|
| 51 | - * This method must throw Sabre\DAV\Exception\NotFound if the node does not |
|
| 52 | - * exist. |
|
| 53 | - * |
|
| 54 | - * @param string $name |
|
| 55 | - * @throws DAV\Exception\NotFound |
|
| 56 | - * @return DAV\INode |
|
| 57 | - */ |
|
| 58 | - public function getChild($name) { |
|
| 59 | - |
|
| 60 | - $path = $this->path . '/' . $name; |
|
| 61 | - |
|
| 62 | - if (!file_exists($path)) throw new NotFound('File could not be located'); |
|
| 63 | - if ($name == '.' || $name == '..') throw new Forbidden('Permission denied to . and ..'); |
|
| 64 | - |
|
| 65 | - if (is_dir($path)) { |
|
| 66 | - |
|
| 67 | - return new self($path, $this->acl, $this->owner); |
|
| 68 | - |
|
| 69 | - } else { |
|
| 70 | - |
|
| 71 | - return new File($path, $this->acl, $this->owner); |
|
| 72 | - |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - /** |
|
| 78 | - * Returns the owner principal |
|
| 79 | - * |
|
| 80 | - * This must be a url to a principal, or null if there's no owner |
|
| 81 | - * |
|
| 82 | - * @return string|null |
|
| 83 | - */ |
|
| 84 | - public function getOwner() { |
|
| 85 | - |
|
| 86 | - return $this->owner; |
|
| 87 | - |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - /** |
|
| 91 | - * Returns a group principal |
|
| 92 | - * |
|
| 93 | - * This must be a url to a principal, or null if there's no owner |
|
| 94 | - * |
|
| 95 | - * @return string|null |
|
| 96 | - */ |
|
| 97 | - public function getGroup() { |
|
| 98 | - |
|
| 99 | - return null; |
|
| 100 | - |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - /** |
|
| 104 | - * Returns a list of ACE's for this node. |
|
| 105 | - * |
|
| 106 | - * Each ACE has the following properties: |
|
| 107 | - * * 'privilege', a string such as {DAV:}read or {DAV:}write. These are |
|
| 108 | - * currently the only supported privileges |
|
| 109 | - * * 'principal', a url to the principal who owns the node |
|
| 110 | - * * 'protected' (optional), indicating that this ACE is not allowed to |
|
| 111 | - * be updated. |
|
| 112 | - * |
|
| 113 | - * @return array |
|
| 114 | - */ |
|
| 115 | - public function getACL() { |
|
| 116 | - |
|
| 117 | - return $this->acl; |
|
| 118 | - |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - /** |
|
| 122 | - * Updates the ACL |
|
| 123 | - * |
|
| 124 | - * This method will receive a list of new ACE's as an array argument. |
|
| 125 | - * |
|
| 126 | - * @param array $acl |
|
| 127 | - * @return void |
|
| 128 | - */ |
|
| 129 | - public function setACL(array $acl) { |
|
| 130 | - |
|
| 131 | - throw new Forbidden('Setting ACL is not allowed here'); |
|
| 132 | - |
|
| 133 | - } |
|
| 134 | - |
|
| 135 | - /** |
|
| 136 | - * Returns the list of supported privileges for this node. |
|
| 137 | - * |
|
| 138 | - * The returned data structure is a list of nested privileges. |
|
| 139 | - * See Sabre\DAVACL\Plugin::getDefaultSupportedPrivilegeSet for a simple |
|
| 140 | - * standard structure. |
|
| 141 | - * |
|
| 142 | - * If null is returned from this method, the default privilege set is used, |
|
| 143 | - * which is fine for most common usecases. |
|
| 144 | - * |
|
| 145 | - * @return array|null |
|
| 146 | - */ |
|
| 147 | - public function getSupportedPrivilegeSet() { |
|
| 148 | - |
|
| 149 | - return null; |
|
| 150 | - |
|
| 151 | - } |
|
| 19 | + /** |
|
| 20 | + * A list of ACL rules. |
|
| 21 | + * |
|
| 22 | + * @var array |
|
| 23 | + */ |
|
| 24 | + protected $acl; |
|
| 25 | + |
|
| 26 | + /** |
|
| 27 | + * Owner uri, or null for no owner. |
|
| 28 | + * |
|
| 29 | + * @var string|null |
|
| 30 | + */ |
|
| 31 | + protected $owner; |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * Constructor |
|
| 35 | + * |
|
| 36 | + * @param string $path on-disk path. |
|
| 37 | + * @param array $acl ACL rules. |
|
| 38 | + * @param string|null $owner principal owner string. |
|
| 39 | + */ |
|
| 40 | + public function __construct($path, array $acl, $owner = null) { |
|
| 41 | + |
|
| 42 | + parent::__construct($path); |
|
| 43 | + $this->acl = $acl; |
|
| 44 | + $this->owner = $owner; |
|
| 45 | + |
|
| 46 | + } |
|
| 47 | + |
|
| 48 | + /** |
|
| 49 | + * Returns a specific child node, referenced by its name |
|
| 50 | + * |
|
| 51 | + * This method must throw Sabre\DAV\Exception\NotFound if the node does not |
|
| 52 | + * exist. |
|
| 53 | + * |
|
| 54 | + * @param string $name |
|
| 55 | + * @throws DAV\Exception\NotFound |
|
| 56 | + * @return DAV\INode |
|
| 57 | + */ |
|
| 58 | + public function getChild($name) { |
|
| 59 | + |
|
| 60 | + $path = $this->path . '/' . $name; |
|
| 61 | + |
|
| 62 | + if (!file_exists($path)) throw new NotFound('File could not be located'); |
|
| 63 | + if ($name == '.' || $name == '..') throw new Forbidden('Permission denied to . and ..'); |
|
| 64 | + |
|
| 65 | + if (is_dir($path)) { |
|
| 66 | + |
|
| 67 | + return new self($path, $this->acl, $this->owner); |
|
| 68 | + |
|
| 69 | + } else { |
|
| 70 | + |
|
| 71 | + return new File($path, $this->acl, $this->owner); |
|
| 72 | + |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + /** |
|
| 78 | + * Returns the owner principal |
|
| 79 | + * |
|
| 80 | + * This must be a url to a principal, or null if there's no owner |
|
| 81 | + * |
|
| 82 | + * @return string|null |
|
| 83 | + */ |
|
| 84 | + public function getOwner() { |
|
| 85 | + |
|
| 86 | + return $this->owner; |
|
| 87 | + |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + /** |
|
| 91 | + * Returns a group principal |
|
| 92 | + * |
|
| 93 | + * This must be a url to a principal, or null if there's no owner |
|
| 94 | + * |
|
| 95 | + * @return string|null |
|
| 96 | + */ |
|
| 97 | + public function getGroup() { |
|
| 98 | + |
|
| 99 | + return null; |
|
| 100 | + |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + /** |
|
| 104 | + * Returns a list of ACE's for this node. |
|
| 105 | + * |
|
| 106 | + * Each ACE has the following properties: |
|
| 107 | + * * 'privilege', a string such as {DAV:}read or {DAV:}write. These are |
|
| 108 | + * currently the only supported privileges |
|
| 109 | + * * 'principal', a url to the principal who owns the node |
|
| 110 | + * * 'protected' (optional), indicating that this ACE is not allowed to |
|
| 111 | + * be updated. |
|
| 112 | + * |
|
| 113 | + * @return array |
|
| 114 | + */ |
|
| 115 | + public function getACL() { |
|
| 116 | + |
|
| 117 | + return $this->acl; |
|
| 118 | + |
|
| 119 | + } |
|
| 120 | + |
|
| 121 | + /** |
|
| 122 | + * Updates the ACL |
|
| 123 | + * |
|
| 124 | + * This method will receive a list of new ACE's as an array argument. |
|
| 125 | + * |
|
| 126 | + * @param array $acl |
|
| 127 | + * @return void |
|
| 128 | + */ |
|
| 129 | + public function setACL(array $acl) { |
|
| 130 | + |
|
| 131 | + throw new Forbidden('Setting ACL is not allowed here'); |
|
| 132 | + |
|
| 133 | + } |
|
| 134 | + |
|
| 135 | + /** |
|
| 136 | + * Returns the list of supported privileges for this node. |
|
| 137 | + * |
|
| 138 | + * The returned data structure is a list of nested privileges. |
|
| 139 | + * See Sabre\DAVACL\Plugin::getDefaultSupportedPrivilegeSet for a simple |
|
| 140 | + * standard structure. |
|
| 141 | + * |
|
| 142 | + * If null is returned from this method, the default privilege set is used, |
|
| 143 | + * which is fine for most common usecases. |
|
| 144 | + * |
|
| 145 | + * @return array|null |
|
| 146 | + */ |
|
| 147 | + public function getSupportedPrivilegeSet() { |
|
| 148 | + |
|
| 149 | + return null; |
|
| 150 | + |
|
| 151 | + } |
|
| 152 | 152 | |
| 153 | 153 | } |
@@ -22,80 +22,80 @@ discard block |
||
| 22 | 22 | */ |
| 23 | 23 | function resolve($basePath, $newPath) { |
| 24 | 24 | |
| 25 | - $base = parse($basePath); |
|
| 26 | - $delta = parse($newPath); |
|
| 27 | - |
|
| 28 | - $pick = function($part) use ($base, $delta) { |
|
| 29 | - |
|
| 30 | - if ($delta[$part]) { |
|
| 31 | - return $delta[$part]; |
|
| 32 | - } elseif ($base[$part]) { |
|
| 33 | - return $base[$part]; |
|
| 34 | - } |
|
| 35 | - return null; |
|
| 36 | - |
|
| 37 | - }; |
|
| 38 | - |
|
| 39 | - // If the new path defines a scheme, it's absolute and we can just return |
|
| 40 | - // that. |
|
| 41 | - if ($delta['scheme']) { |
|
| 42 | - return build($delta); |
|
| 43 | - } |
|
| 44 | - |
|
| 45 | - $newParts = []; |
|
| 46 | - |
|
| 47 | - $newParts['scheme'] = $pick('scheme'); |
|
| 48 | - $newParts['host'] = $pick('host'); |
|
| 49 | - $newParts['port'] = $pick('port'); |
|
| 50 | - |
|
| 51 | - $path = ''; |
|
| 52 | - if ($delta['path']) { |
|
| 53 | - // If the path starts with a slash |
|
| 54 | - if ($delta['path'][0] === '/') { |
|
| 55 | - $path = $delta['path']; |
|
| 56 | - } else { |
|
| 57 | - // Removing last component from base path. |
|
| 58 | - $path = $base['path']; |
|
| 59 | - if (strpos($path, '/') !== false) { |
|
| 60 | - $path = substr($path, 0, strrpos($path, '/')); |
|
| 61 | - } |
|
| 62 | - $path .= '/' . $delta['path']; |
|
| 63 | - } |
|
| 64 | - } else { |
|
| 65 | - $path = $base['path'] ?: '/'; |
|
| 66 | - } |
|
| 67 | - // Removing .. and . |
|
| 68 | - $pathParts = explode('/', $path); |
|
| 69 | - $newPathParts = []; |
|
| 70 | - foreach ($pathParts as $pathPart) { |
|
| 71 | - |
|
| 72 | - switch ($pathPart) { |
|
| 73 | - //case '' : |
|
| 74 | - case '.' : |
|
| 75 | - break; |
|
| 76 | - case '..' : |
|
| 77 | - array_pop($newPathParts); |
|
| 78 | - break; |
|
| 79 | - default : |
|
| 80 | - $newPathParts[] = $pathPart; |
|
| 81 | - break; |
|
| 82 | - } |
|
| 83 | - } |
|
| 84 | - |
|
| 85 | - $path = implode('/', $newPathParts); |
|
| 86 | - |
|
| 87 | - // If the source url ended with a /, we want to preserve that. |
|
| 88 | - $newParts['path'] = $path; |
|
| 89 | - if ($delta['query']) { |
|
| 90 | - $newParts['query'] = $delta['query']; |
|
| 91 | - } elseif (!empty($base['query']) && empty($delta['host']) && empty($delta['path'])) { |
|
| 92 | - // Keep the old query if host and path didn't change |
|
| 93 | - $newParts['query'] = $base['query']; |
|
| 94 | - } |
|
| 95 | - if ($delta['fragment']) { |
|
| 96 | - $newParts['fragment'] = $delta['fragment']; |
|
| 97 | - } |
|
| 98 | - return build($newParts); |
|
| 25 | + $base = parse($basePath); |
|
| 26 | + $delta = parse($newPath); |
|
| 27 | + |
|
| 28 | + $pick = function($part) use ($base, $delta) { |
|
| 29 | + |
|
| 30 | + if ($delta[$part]) { |
|
| 31 | + return $delta[$part]; |
|
| 32 | + } elseif ($base[$part]) { |
|
| 33 | + return $base[$part]; |
|
| 34 | + } |
|
| 35 | + return null; |
|
| 36 | + |
|
| 37 | + }; |
|
| 38 | + |
|
| 39 | + // If the new path defines a scheme, it's absolute and we can just return |
|
| 40 | + // that. |
|
| 41 | + if ($delta['scheme']) { |
|
| 42 | + return build($delta); |
|
| 43 | + } |
|
| 44 | + |
|
| 45 | + $newParts = []; |
|
| 46 | + |
|
| 47 | + $newParts['scheme'] = $pick('scheme'); |
|
| 48 | + $newParts['host'] = $pick('host'); |
|
| 49 | + $newParts['port'] = $pick('port'); |
|
| 50 | + |
|
| 51 | + $path = ''; |
|
| 52 | + if ($delta['path']) { |
|
| 53 | + // If the path starts with a slash |
|
| 54 | + if ($delta['path'][0] === '/') { |
|
| 55 | + $path = $delta['path']; |
|
| 56 | + } else { |
|
| 57 | + // Removing last component from base path. |
|
| 58 | + $path = $base['path']; |
|
| 59 | + if (strpos($path, '/') !== false) { |
|
| 60 | + $path = substr($path, 0, strrpos($path, '/')); |
|
| 61 | + } |
|
| 62 | + $path .= '/' . $delta['path']; |
|
| 63 | + } |
|
| 64 | + } else { |
|
| 65 | + $path = $base['path'] ?: '/'; |
|
| 66 | + } |
|
| 67 | + // Removing .. and . |
|
| 68 | + $pathParts = explode('/', $path); |
|
| 69 | + $newPathParts = []; |
|
| 70 | + foreach ($pathParts as $pathPart) { |
|
| 71 | + |
|
| 72 | + switch ($pathPart) { |
|
| 73 | + //case '' : |
|
| 74 | + case '.' : |
|
| 75 | + break; |
|
| 76 | + case '..' : |
|
| 77 | + array_pop($newPathParts); |
|
| 78 | + break; |
|
| 79 | + default : |
|
| 80 | + $newPathParts[] = $pathPart; |
|
| 81 | + break; |
|
| 82 | + } |
|
| 83 | + } |
|
| 84 | + |
|
| 85 | + $path = implode('/', $newPathParts); |
|
| 86 | + |
|
| 87 | + // If the source url ended with a /, we want to preserve that. |
|
| 88 | + $newParts['path'] = $path; |
|
| 89 | + if ($delta['query']) { |
|
| 90 | + $newParts['query'] = $delta['query']; |
|
| 91 | + } elseif (!empty($base['query']) && empty($delta['host']) && empty($delta['path'])) { |
|
| 92 | + // Keep the old query if host and path didn't change |
|
| 93 | + $newParts['query'] = $base['query']; |
|
| 94 | + } |
|
| 95 | + if ($delta['fragment']) { |
|
| 96 | + $newParts['fragment'] = $delta['fragment']; |
|
| 97 | + } |
|
| 98 | + return build($newParts); |
|
| 99 | 99 | |
| 100 | 100 | } |
| 101 | 101 | |
@@ -113,55 +113,55 @@ discard block |
||
| 113 | 113 | */ |
| 114 | 114 | function normalize($uri) { |
| 115 | 115 | |
| 116 | - $parts = parse($uri); |
|
| 117 | - |
|
| 118 | - if (!empty($parts['path'])) { |
|
| 119 | - $pathParts = explode('/', ltrim($parts['path'], '/')); |
|
| 120 | - $newPathParts = []; |
|
| 121 | - foreach ($pathParts as $pathPart) { |
|
| 122 | - switch ($pathPart) { |
|
| 123 | - case '.': |
|
| 124 | - // skip |
|
| 125 | - break; |
|
| 126 | - case '..' : |
|
| 127 | - // One level up in the hierarchy |
|
| 128 | - array_pop($newPathParts); |
|
| 129 | - break; |
|
| 130 | - default : |
|
| 131 | - // Ensuring that everything is correctly percent-encoded. |
|
| 132 | - $newPathParts[] = rawurlencode(rawurldecode($pathPart)); |
|
| 133 | - break; |
|
| 134 | - } |
|
| 135 | - } |
|
| 136 | - $parts['path'] = '/' . implode('/', $newPathParts); |
|
| 137 | - } |
|
| 138 | - |
|
| 139 | - if ($parts['scheme']) { |
|
| 140 | - $parts['scheme'] = strtolower($parts['scheme']); |
|
| 141 | - $defaultPorts = [ |
|
| 142 | - 'http' => '80', |
|
| 143 | - 'https' => '443', |
|
| 144 | - ]; |
|
| 145 | - |
|
| 146 | - if (!empty($parts['port']) && isset($defaultPorts[$parts['scheme']]) && $defaultPorts[$parts['scheme']] == $parts['port']) { |
|
| 147 | - // Removing default ports. |
|
| 148 | - unset($parts['port']); |
|
| 149 | - } |
|
| 150 | - // A few HTTP specific rules. |
|
| 151 | - switch ($parts['scheme']) { |
|
| 152 | - case 'http' : |
|
| 153 | - case 'https' : |
|
| 154 | - if (empty($parts['path'])) { |
|
| 155 | - // An empty path is equivalent to / in http. |
|
| 156 | - $parts['path'] = '/'; |
|
| 157 | - } |
|
| 158 | - break; |
|
| 159 | - } |
|
| 160 | - } |
|
| 161 | - |
|
| 162 | - if ($parts['host']) $parts['host'] = strtolower($parts['host']); |
|
| 163 | - |
|
| 164 | - return build($parts); |
|
| 116 | + $parts = parse($uri); |
|
| 117 | + |
|
| 118 | + if (!empty($parts['path'])) { |
|
| 119 | + $pathParts = explode('/', ltrim($parts['path'], '/')); |
|
| 120 | + $newPathParts = []; |
|
| 121 | + foreach ($pathParts as $pathPart) { |
|
| 122 | + switch ($pathPart) { |
|
| 123 | + case '.': |
|
| 124 | + // skip |
|
| 125 | + break; |
|
| 126 | + case '..' : |
|
| 127 | + // One level up in the hierarchy |
|
| 128 | + array_pop($newPathParts); |
|
| 129 | + break; |
|
| 130 | + default : |
|
| 131 | + // Ensuring that everything is correctly percent-encoded. |
|
| 132 | + $newPathParts[] = rawurlencode(rawurldecode($pathPart)); |
|
| 133 | + break; |
|
| 134 | + } |
|
| 135 | + } |
|
| 136 | + $parts['path'] = '/' . implode('/', $newPathParts); |
|
| 137 | + } |
|
| 138 | + |
|
| 139 | + if ($parts['scheme']) { |
|
| 140 | + $parts['scheme'] = strtolower($parts['scheme']); |
|
| 141 | + $defaultPorts = [ |
|
| 142 | + 'http' => '80', |
|
| 143 | + 'https' => '443', |
|
| 144 | + ]; |
|
| 145 | + |
|
| 146 | + if (!empty($parts['port']) && isset($defaultPorts[$parts['scheme']]) && $defaultPorts[$parts['scheme']] == $parts['port']) { |
|
| 147 | + // Removing default ports. |
|
| 148 | + unset($parts['port']); |
|
| 149 | + } |
|
| 150 | + // A few HTTP specific rules. |
|
| 151 | + switch ($parts['scheme']) { |
|
| 152 | + case 'http' : |
|
| 153 | + case 'https' : |
|
| 154 | + if (empty($parts['path'])) { |
|
| 155 | + // An empty path is equivalent to / in http. |
|
| 156 | + $parts['path'] = '/'; |
|
| 157 | + } |
|
| 158 | + break; |
|
| 159 | + } |
|
| 160 | + } |
|
| 161 | + |
|
| 162 | + if ($parts['host']) $parts['host'] = strtolower($parts['host']); |
|
| 163 | + |
|
| 164 | + return build($parts); |
|
| 165 | 165 | |
| 166 | 166 | } |
| 167 | 167 | |
@@ -180,29 +180,29 @@ discard block |
||
| 180 | 180 | */ |
| 181 | 181 | function parse($uri) { |
| 182 | 182 | |
| 183 | - // Normally a URI must be ASCII, however. However, often it's not and |
|
| 184 | - // parse_url might corrupt these strings. |
|
| 185 | - // |
|
| 186 | - // For that reason we take any non-ascii characters from the uri and |
|
| 187 | - // uriencode them first. |
|
| 188 | - $uri = preg_replace_callback( |
|
| 189 | - '/[^[:ascii:]]/u', |
|
| 190 | - function($matches) { |
|
| 191 | - return rawurlencode($matches[0]); |
|
| 192 | - }, |
|
| 193 | - $uri |
|
| 194 | - ); |
|
| 195 | - |
|
| 196 | - return |
|
| 197 | - parse_url($uri) + [ |
|
| 198 | - 'scheme' => null, |
|
| 199 | - 'host' => null, |
|
| 200 | - 'path' => null, |
|
| 201 | - 'port' => null, |
|
| 202 | - 'user' => null, |
|
| 203 | - 'query' => null, |
|
| 204 | - 'fragment' => null, |
|
| 205 | - ]; |
|
| 183 | + // Normally a URI must be ASCII, however. However, often it's not and |
|
| 184 | + // parse_url might corrupt these strings. |
|
| 185 | + // |
|
| 186 | + // For that reason we take any non-ascii characters from the uri and |
|
| 187 | + // uriencode them first. |
|
| 188 | + $uri = preg_replace_callback( |
|
| 189 | + '/[^[:ascii:]]/u', |
|
| 190 | + function($matches) { |
|
| 191 | + return rawurlencode($matches[0]); |
|
| 192 | + }, |
|
| 193 | + $uri |
|
| 194 | + ); |
|
| 195 | + |
|
| 196 | + return |
|
| 197 | + parse_url($uri) + [ |
|
| 198 | + 'scheme' => null, |
|
| 199 | + 'host' => null, |
|
| 200 | + 'path' => null, |
|
| 201 | + 'port' => null, |
|
| 202 | + 'user' => null, |
|
| 203 | + 'query' => null, |
|
| 204 | + 'fragment' => null, |
|
| 205 | + ]; |
|
| 206 | 206 | |
| 207 | 207 | } |
| 208 | 208 | |
@@ -215,41 +215,41 @@ discard block |
||
| 215 | 215 | */ |
| 216 | 216 | function build(array $parts) { |
| 217 | 217 | |
| 218 | - $uri = ''; |
|
| 219 | - |
|
| 220 | - $authority = ''; |
|
| 221 | - if (!empty($parts['host'])) { |
|
| 222 | - $authority = $parts['host']; |
|
| 223 | - if (!empty($parts['user'])) { |
|
| 224 | - $authority = $parts['user'] . '@' . $authority; |
|
| 225 | - } |
|
| 226 | - if (!empty($parts['port'])) { |
|
| 227 | - $authority = $authority . ':' . $parts['port']; |
|
| 228 | - } |
|
| 229 | - } |
|
| 230 | - |
|
| 231 | - if (!empty($parts['scheme'])) { |
|
| 232 | - // If there's a scheme, there's also a host. |
|
| 233 | - $uri = $parts['scheme'] . ':'; |
|
| 234 | - |
|
| 235 | - } |
|
| 236 | - if ($authority) { |
|
| 237 | - // No scheme, but there is a host. |
|
| 238 | - $uri .= '//' . $authority; |
|
| 239 | - |
|
| 240 | - } |
|
| 241 | - |
|
| 242 | - if (!empty($parts['path'])) { |
|
| 243 | - $uri .= $parts['path']; |
|
| 244 | - } |
|
| 245 | - if (!empty($parts['query'])) { |
|
| 246 | - $uri .= '?' . $parts['query']; |
|
| 247 | - } |
|
| 248 | - if (!empty($parts['fragment'])) { |
|
| 249 | - $uri .= '#' . $parts['fragment']; |
|
| 250 | - } |
|
| 251 | - |
|
| 252 | - return $uri; |
|
| 218 | + $uri = ''; |
|
| 219 | + |
|
| 220 | + $authority = ''; |
|
| 221 | + if (!empty($parts['host'])) { |
|
| 222 | + $authority = $parts['host']; |
|
| 223 | + if (!empty($parts['user'])) { |
|
| 224 | + $authority = $parts['user'] . '@' . $authority; |
|
| 225 | + } |
|
| 226 | + if (!empty($parts['port'])) { |
|
| 227 | + $authority = $authority . ':' . $parts['port']; |
|
| 228 | + } |
|
| 229 | + } |
|
| 230 | + |
|
| 231 | + if (!empty($parts['scheme'])) { |
|
| 232 | + // If there's a scheme, there's also a host. |
|
| 233 | + $uri = $parts['scheme'] . ':'; |
|
| 234 | + |
|
| 235 | + } |
|
| 236 | + if ($authority) { |
|
| 237 | + // No scheme, but there is a host. |
|
| 238 | + $uri .= '//' . $authority; |
|
| 239 | + |
|
| 240 | + } |
|
| 241 | + |
|
| 242 | + if (!empty($parts['path'])) { |
|
| 243 | + $uri .= $parts['path']; |
|
| 244 | + } |
|
| 245 | + if (!empty($parts['query'])) { |
|
| 246 | + $uri .= '?' . $parts['query']; |
|
| 247 | + } |
|
| 248 | + if (!empty($parts['fragment'])) { |
|
| 249 | + $uri .= '#' . $parts['fragment']; |
|
| 250 | + } |
|
| 251 | + |
|
| 252 | + return $uri; |
|
| 253 | 253 | |
| 254 | 254 | } |
| 255 | 255 | |
@@ -273,10 +273,10 @@ discard block |
||
| 273 | 273 | */ |
| 274 | 274 | function split($path) { |
| 275 | 275 | |
| 276 | - $matches = []; |
|
| 277 | - if (preg_match('/^(?:(?:(.*)(?:\/+))?([^\/]+))(?:\/?)$/u', $path, $matches)) { |
|
| 278 | - return [$matches[1], $matches[2]]; |
|
| 279 | - } |
|
| 280 | - return [null,null]; |
|
| 276 | + $matches = []; |
|
| 277 | + if (preg_match('/^(?:(?:(.*)(?:\/+))?([^\/]+))(?:\/?)$/u', $path, $matches)) { |
|
| 278 | + return [$matches[1], $matches[2]]; |
|
| 279 | + } |
|
| 280 | + return [null,null]; |
|
| 281 | 281 | |
| 282 | 282 | } |
@@ -277,6 +277,6 @@ |
||
| 277 | 277 | if (preg_match('/^(?:(?:(.*)(?:\/+))?([^\/]+))(?:\/?)$/u', $path, $matches)) { |
| 278 | 278 | return [$matches[1], $matches[2]]; |
| 279 | 279 | } |
| 280 | - return [null,null]; |
|
| 280 | + return [null, null]; |
|
| 281 | 281 | |
| 282 | 282 | } |
@@ -159,7 +159,9 @@ |
||
| 159 | 159 | } |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - if ($parts['host']) $parts['host'] = strtolower($parts['host']); |
|
| 162 | + if ($parts['host']) { |
|
| 163 | + $parts['host'] = strtolower($parts['host']); |
|
| 164 | + } |
|
| 163 | 165 | |
| 164 | 166 | return build($parts); |
| 165 | 167 | |
@@ -11,9 +11,9 @@ |
||
| 11 | 11 | */ |
| 12 | 12 | class Version { |
| 13 | 13 | |
| 14 | - /** |
|
| 15 | - * Full version number |
|
| 16 | - */ |
|
| 17 | - const VERSION = '1.1.0'; |
|
| 14 | + /** |
|
| 15 | + * Full version number |
|
| 16 | + */ |
|
| 17 | + const VERSION = '1.1.0'; |
|
| 18 | 18 | |
| 19 | 19 | } |
@@ -214,7 +214,7 @@ |
||
| 214 | 214 | if ($dir = @opendir($languageFolder)) { // open languages folder |
| 215 | 215 | while (($langName = readdir($dir)) !== false) { |
| 216 | 216 | if ($langName != '..' && $langName != '.' && is_dir($languageFolder . "/" . $langName)) { |
| 217 | - $langDir = @opendir($languageFolder . '/' . $langName); //open languages/en_us folder |
|
| 217 | + $langDir = @opendir($languageFolder . '/' . $langName); //open languages/en_us folder |
|
| 218 | 218 | while (($moduleLangFile = readdir($langDir)) !== false) { |
| 219 | 219 | $langFilePath = $languageFolder . '/' . $langName . '/' . $moduleLangFile; |
| 220 | 220 | if (is_file($langFilePath) && $moduleLangFile === $module . '.php') { //check if languages/en_us/module.php file exists |
@@ -48,11 +48,13 @@ discard block |
||
| 48 | 48 | /** @access private */ |
| 49 | 49 | public function outputNode($value, $node = '') |
| 50 | 50 | { |
| 51 | - if ($node != '') |
|
| 52 | - $this->openNode($node, ''); |
|
| 51 | + if ($node != '') { |
|
| 52 | + $this->openNode($node, ''); |
|
| 53 | + } |
|
| 53 | 54 | $this->__write($value); |
| 54 | - if ($node != '') |
|
| 55 | - $this->closeNode($node); |
|
| 55 | + if ($node != '') { |
|
| 56 | + $this->closeNode($node); |
|
| 57 | + } |
|
| 56 | 58 | } |
| 57 | 59 | |
| 58 | 60 | /** @access private */ |
@@ -145,20 +147,24 @@ discard block |
||
| 145 | 147 | $zip->copyDirectoryFromDisk("modules/$module"); |
| 146 | 148 | |
| 147 | 149 | // Copy Settings/module directory |
| 148 | - if (is_dir("modules/Settings/$module")) |
|
| 149 | - $zip->copyDirectoryFromDisk("modules/Settings/$module", 'settings/'); |
|
| 150 | + if (is_dir("modules/Settings/$module")) { |
|
| 151 | + $zip->copyDirectoryFromDisk("modules/Settings/$module", 'settings/'); |
|
| 152 | + } |
|
| 150 | 153 | |
| 151 | 154 | // Copy cron files of the module (if any) |
| 152 | - if (is_dir("cron/modules/$module")) |
|
| 153 | - $zip->copyDirectoryFromDisk("cron/modules/$module", "cron"); |
|
| 155 | + if (is_dir("cron/modules/$module")) { |
|
| 156 | + $zip->copyDirectoryFromDisk("cron/modules/$module", "cron"); |
|
| 157 | + } |
|
| 154 | 158 | |
| 155 | 159 | //Copy module templates files |
| 156 | - if (is_dir('layouts/' . \Vtiger_Viewer::getDefaultLayoutName() . '/modules/' . $module)) |
|
| 157 | - $zip->copyDirectoryFromDisk('layouts/' . \Vtiger_Viewer::getDefaultLayoutName() . '/modules/' . $module, 'templates'); |
|
| 160 | + if (is_dir('layouts/' . \Vtiger_Viewer::getDefaultLayoutName() . '/modules/' . $module)) { |
|
| 161 | + $zip->copyDirectoryFromDisk('layouts/' . \Vtiger_Viewer::getDefaultLayoutName() . '/modules/' . $module, 'templates'); |
|
| 162 | + } |
|
| 158 | 163 | |
| 159 | 164 | //Copy Settings module templates files, if any |
| 160 | - if (is_dir('layouts/' . \Vtiger_Viewer::getDefaultLayoutName() . "/modules/Settings/$module")) |
|
| 161 | - $zip->copyDirectoryFromDisk('layouts/' . \Vtiger_Viewer::getDefaultLayoutName() . "/modules/Settings/$module", "settings/templates"); |
|
| 165 | + if (is_dir('layouts/' . \Vtiger_Viewer::getDefaultLayoutName() . "/modules/Settings/$module")) { |
|
| 166 | + $zip->copyDirectoryFromDisk('layouts/' . \Vtiger_Viewer::getDefaultLayoutName() . "/modules/Settings/$module", "settings/templates"); |
|
| 167 | + } |
|
| 162 | 168 | |
| 163 | 169 | //Support to multiple layouts of module |
| 164 | 170 | $layoutDirectories = glob('layouts' . '/*', GLOB_ONLYDIR); |
@@ -262,8 +268,9 @@ discard block |
||
| 262 | 268 | } |
| 263 | 269 | $this->openNode('dependencies'); |
| 264 | 270 | $this->outputNode($minVersion, 'vtiger_version'); |
| 265 | - if ($maxVersion !== false) |
|
| 266 | - $this->outputNode($maxVersion, 'vtiger_max_version'); |
|
| 271 | + if ($maxVersion !== false) { |
|
| 272 | + $this->outputNode($maxVersion, 'vtiger_max_version'); |
|
| 273 | + } |
|
| 267 | 274 | $this->closeNode('dependencies'); |
| 268 | 275 | } |
| 269 | 276 | |
@@ -382,8 +389,9 @@ discard block |
||
| 382 | 389 | $sqlresult = $adb->pquery("SELECT * FROM vtiger_blocks WHERE tabid = ?", Array($moduleInstance->id)); |
| 383 | 390 | $resultrows = $adb->num_rows($sqlresult); |
| 384 | 391 | |
| 385 | - if (empty($resultrows)) |
|
| 386 | - return; |
|
| 392 | + if (empty($resultrows)) { |
|
| 393 | + return; |
|
| 394 | + } |
|
| 387 | 395 | |
| 388 | 396 | $this->openNode('blocks'); |
| 389 | 397 | for ($index = 0; $index < $resultrows; ++$index) { |
@@ -429,8 +437,9 @@ discard block |
||
| 429 | 437 | $fieldresult = $adb->pquery("SELECT * FROM vtiger_field WHERE tabid=? && block=?", Array($moduleInstance->id, $blockid)); |
| 430 | 438 | $fieldcount = $adb->num_rows($fieldresult); |
| 431 | 439 | |
| 432 | - if (empty($fieldcount)) |
|
| 433 | - return; |
|
| 440 | + if (empty($fieldcount)) { |
|
| 441 | + return; |
|
| 442 | + } |
|
| 434 | 443 | |
| 435 | 444 | $entityresult = $adb->pquery("SELECT * FROM vtiger_entityname WHERE tabid=?", Array($moduleInstance->id)); |
| 436 | 445 | $entity_fieldname = $adb->query_result($entityresult, 0, 'fieldname'); |
@@ -545,8 +554,9 @@ discard block |
||
| 545 | 554 | $db = \PearDatabase::getInstance(); |
| 546 | 555 | |
| 547 | 556 | $customviewres = $db->pquery("SELECT * FROM vtiger_customview WHERE entitytype = ?", [$moduleInstance->name]); |
| 548 | - if (!$customviewres->rowCount()) |
|
| 549 | - return; |
|
| 557 | + if (!$customviewres->rowCount()) { |
|
| 558 | + return; |
|
| 559 | + } |
|
| 550 | 560 | |
| 551 | 561 | $this->openNode('customviews'); |
| 552 | 562 | while ($row = $db->getRow($customviewres)) { |
@@ -606,22 +616,27 @@ discard block |
||
| 606 | 616 | $deforgshare = $adb->pquery("SELECT * FROM vtiger_def_org_share WHERE tabid=?", Array($moduleInstance->id)); |
| 607 | 617 | $deforgshareCount = $adb->num_rows($deforgshare); |
| 608 | 618 | |
| 609 | - if (empty($deforgshareCount)) |
|
| 610 | - return; |
|
| 619 | + if (empty($deforgshareCount)) { |
|
| 620 | + return; |
|
| 621 | + } |
|
| 611 | 622 | |
| 612 | 623 | $this->openNode('sharingaccess'); |
| 613 | 624 | if ($deforgshareCount) { |
| 614 | 625 | for ($index = 0; $index < $deforgshareCount; ++$index) { |
| 615 | 626 | $permission = $adb->query_result($deforgshare, $index, 'permission'); |
| 616 | 627 | $permissiontext = ''; |
| 617 | - if ($permission == '0') |
|
| 618 | - $permissiontext = 'public_readonly'; |
|
| 619 | - if ($permission == '1') |
|
| 620 | - $permissiontext = 'public_readwrite'; |
|
| 621 | - if ($permission == '2') |
|
| 622 | - $permissiontext = 'public_readwritedelete'; |
|
| 623 | - if ($permission == '3') |
|
| 624 | - $permissiontext = 'private'; |
|
| 628 | + if ($permission == '0') { |
|
| 629 | + $permissiontext = 'public_readonly'; |
|
| 630 | + } |
|
| 631 | + if ($permission == '1') { |
|
| 632 | + $permissiontext = 'public_readwrite'; |
|
| 633 | + } |
|
| 634 | + if ($permission == '2') { |
|
| 635 | + $permissiontext = 'public_readwritedelete'; |
|
| 636 | + } |
|
| 637 | + if ($permission == '3') { |
|
| 638 | + $permissiontext = 'private'; |
|
| 639 | + } |
|
| 625 | 640 | |
| 626 | 641 | $this->outputNode($permissiontext, 'default'); |
| 627 | 642 | } |
@@ -636,8 +651,9 @@ discard block |
||
| 636 | 651 | public function export_Events($moduleInstance) |
| 637 | 652 | { |
| 638 | 653 | $events = Event::getAll($moduleInstance); |
| 639 | - if (!$events) |
|
| 640 | - return; |
|
| 654 | + if (!$events) { |
|
| 655 | + return; |
|
| 656 | + } |
|
| 641 | 657 | |
| 642 | 658 | $this->openNode('events'); |
| 643 | 659 | foreach ($events as $event) { |
@@ -654,8 +670,9 @@ discard block |
||
| 654 | 670 | public function export_Actions($moduleInstance) |
| 655 | 671 | { |
| 656 | 672 | |
| 657 | - if (!$moduleInstance->isentitytype) |
|
| 658 | - return; |
|
| 673 | + if (!$moduleInstance->isentitytype) { |
|
| 674 | + return; |
|
| 675 | + } |
|
| 659 | 676 | |
| 660 | 677 | $adb = \PearDatabase::getInstance(); |
| 661 | 678 | $result = $adb->pquery('SELECT distinct(actionname) FROM vtiger_profile2utility, vtiger_actionmapping |
@@ -680,8 +697,9 @@ discard block |
||
| 680 | 697 | public function export_RelatedLists($moduleInstance) |
| 681 | 698 | { |
| 682 | 699 | |
| 683 | - if (!$moduleInstance->isentitytype) |
|
| 684 | - return; |
|
| 700 | + if (!$moduleInstance->isentitytype) { |
|
| 701 | + return; |
|
| 702 | + } |
|
| 685 | 703 | |
| 686 | 704 | $adb = \PearDatabase::getInstance(); |
| 687 | 705 | $result = $adb->pquery("SELECT * FROM vtiger_relatedlists WHERE tabid = ?", Array($moduleInstance->id)); |
@@ -815,8 +833,9 @@ discard block |
||
| 815 | 833 | $tableName = $inventoryFieldModel->getTableName('fields'); |
| 816 | 834 | |
| 817 | 835 | $result = $db->query(sprintf('SELECT * FROM %s', $tableName)); |
| 818 | - if ($db->getRowCount($result) == 0) |
|
| 819 | - return false; |
|
| 836 | + if ($db->getRowCount($result) == 0) { |
|
| 837 | + return false; |
|
| 838 | + } |
|
| 820 | 839 | |
| 821 | 840 | $this->openNode('inventory'); |
| 822 | 841 | $this->openNode('fields'); |
@@ -118,6 +118,7 @@ discard block |
||
| 118 | 118 | * @param Path Output directory path |
| 119 | 119 | * @param String Zipfilename to use |
| 120 | 120 | * @param Boolean True for sending the output as download |
| 121 | + * @param \Vtiger_Module_Model $moduleInstance |
|
| 121 | 122 | */ |
| 122 | 123 | public function export($moduleInstance, $todir = '', $zipfilename = '', $directDownload = false) |
| 123 | 124 | { |
@@ -205,7 +206,7 @@ discard block |
||
| 205 | 206 | |
| 206 | 207 | /** |
| 207 | 208 | * Function copies language files to zip |
| 208 | - * @param <vtlib\Zip> $zip |
|
| 209 | + * @param Zip $zip |
|
| 209 | 210 | * @param <String> $module |
| 210 | 211 | */ |
| 211 | 212 | public function __copyLanguageFiles($zip, $module) |
@@ -240,6 +241,7 @@ discard block |
||
| 240 | 241 | /** |
| 241 | 242 | * Export vtiger dependencies |
| 242 | 243 | * @access private |
| 244 | + * @param boolean $moduleInstance |
|
| 243 | 245 | */ |
| 244 | 246 | public function export_Dependencies($moduleInstance) |
| 245 | 247 | { |
@@ -375,6 +377,7 @@ discard block |
||
| 375 | 377 | /** |
| 376 | 378 | * Export module blocks with its related fields |
| 377 | 379 | * @access private |
| 380 | + * @param boolean $moduleInstance |
|
| 378 | 381 | */ |
| 379 | 382 | public function export_Blocks($moduleInstance) |
| 380 | 383 | { |
@@ -539,6 +542,7 @@ discard block |
||
| 539 | 542 | /** |
| 540 | 543 | * Export Custom views of the module |
| 541 | 544 | * @access private |
| 545 | + * @param boolean $moduleInstance |
|
| 542 | 546 | */ |
| 543 | 547 | public function export_CustomViews($moduleInstance) |
| 544 | 548 | { |
@@ -598,6 +602,7 @@ discard block |
||
| 598 | 602 | /** |
| 599 | 603 | * Export Sharing Access of the module |
| 600 | 604 | * @access private |
| 605 | + * @param boolean $moduleInstance |
|
| 601 | 606 | */ |
| 602 | 607 | public function export_SharingAccess($moduleInstance) |
| 603 | 608 | { |
@@ -632,6 +637,7 @@ discard block |
||
| 632 | 637 | /** |
| 633 | 638 | * Export Events of the module |
| 634 | 639 | * @access private |
| 640 | + * @param boolean $moduleInstance |
|
| 635 | 641 | */ |
| 636 | 642 | public function export_Events($moduleInstance) |
| 637 | 643 | { |
@@ -651,6 +657,9 @@ discard block |
||
| 651 | 657 | $this->closeNode('events'); |
| 652 | 658 | } |
| 653 | 659 | |
| 660 | + /** |
|
| 661 | + * @param boolean $moduleInstance |
|
| 662 | + */ |
|
| 654 | 663 | public function export_Actions($moduleInstance) |
| 655 | 664 | { |
| 656 | 665 | |
@@ -676,6 +685,7 @@ discard block |
||
| 676 | 685 | /** |
| 677 | 686 | * Export related lists associated with module. |
| 678 | 687 | * @access private |
| 688 | + * @param boolean $moduleInstance |
|
| 679 | 689 | */ |
| 680 | 690 | public function export_RelatedLists($moduleInstance) |
| 681 | 691 | { |
@@ -750,6 +760,7 @@ discard block |
||
| 750 | 760 | /** |
| 751 | 761 | * Export custom links of the module. |
| 752 | 762 | * @access private |
| 763 | + * @param boolean $moduleInstance |
|
| 753 | 764 | */ |
| 754 | 765 | public function export_CustomLinks($moduleInstance) |
| 755 | 766 | { |
@@ -775,6 +786,7 @@ discard block |
||
| 775 | 786 | /** |
| 776 | 787 | * Export cron tasks for the module. |
| 777 | 788 | * @access private |
| 789 | + * @param boolean $moduleInstance |
|
| 778 | 790 | */ |
| 779 | 791 | public function export_CronTasks($moduleInstance) |
| 780 | 792 | { |
@@ -25,8 +25,9 @@ discard block |
||
| 25 | 25 | public function __checkPathInArray($path, $pathArray) |
| 26 | 26 | { |
| 27 | 27 | foreach ($pathArray as $checkPath) { |
| 28 | - if (strpos($path, $checkPath) === 0) |
|
| 29 | - return true; |
|
| 28 | + if (strpos($path, $checkPath) === 0) { |
|
| 29 | + return true; |
|
| 30 | + } |
|
| 30 | 31 | } |
| 31 | 32 | return false; |
| 32 | 33 | } |
@@ -37,8 +38,9 @@ discard block |
||
| 37 | 38 | */ |
| 38 | 39 | public function isdir($filepath) |
| 39 | 40 | { |
| 40 | - if (substr($filepath, -1, 1) == "/") |
|
| 41 | - return true; |
|
| 41 | + if (substr($filepath, -1, 1) == "/") { |
|
| 42 | + return true; |
|
| 43 | + } |
|
| 42 | 44 | return false; |
| 43 | 45 | } |
| 44 | 46 | |
@@ -53,11 +55,13 @@ discard block |
||
| 53 | 55 | // We want to always maintain the structure |
| 54 | 56 | $maintainStructure = true; |
| 55 | 57 | |
| 56 | - if ($targetDir === false) |
|
| 57 | - $targetDir = dirname(__FILE__) . "/"; |
|
| 58 | + if ($targetDir === false) { |
|
| 59 | + $targetDir = dirname(__FILE__) . "/"; |
|
| 60 | + } |
|
| 58 | 61 | |
| 59 | - if ($renamePaths === false) |
|
| 60 | - $renamePaths = []; |
|
| 62 | + if ($renamePaths === false) { |
|
| 63 | + $renamePaths = []; |
|
| 64 | + } |
|
| 61 | 65 | |
| 62 | 66 | /* |
| 63 | 67 | * Setup includeExclude parameter |
@@ -70,17 +74,19 @@ discard block |
||
| 70 | 74 | * DEFAULT: If include is specified only files under the specified path will be included. |
| 71 | 75 | * If exclude is specified folders or files will be excluded. |
| 72 | 76 | */ |
| 73 | - if ($includeExclude === false) |
|
| 74 | - $includeExclude = []; |
|
| 77 | + if ($includeExclude === false) { |
|
| 78 | + $includeExclude = []; |
|
| 79 | + } |
|
| 75 | 80 | |
| 76 | 81 | $lista = $this->getList(); |
| 77 | - if (sizeof($lista)) |
|
| 78 | - foreach ($lista as $fileName => $trash) { |
|
| 82 | + if (sizeof($lista)) { |
|
| 83 | + foreach ($lista as $fileName => $trash) { |
|
| 79 | 84 | // Should the file be ignored? |
| 80 | 85 | if ($includeExclude['include'] && |
| 81 | 86 | !$this->__checkPathInArray($fileName, $includeExclude['include'])) { |
| 82 | 87 | // Do not include something not specified in include |
| 83 | 88 | continue; |
| 89 | + } |
|
| 84 | 90 | } |
| 85 | 91 | if ($includeExclude['exclude'] && |
| 86 | 92 | $this->__checkPathInArray($fileName, $includeExclude['exclude'])) { |
@@ -104,8 +110,9 @@ discard block |
||
| 104 | 110 | |
| 105 | 111 | $outDN = "$targetDir/$dirname"; |
| 106 | 112 | |
| 107 | - if (substr($dirname, 0, strlen($baseDir)) != $baseDir) |
|
| 108 | - continue; |
|
| 113 | + if (substr($dirname, 0, strlen($baseDir)) != $baseDir) { |
|
| 114 | + continue; |
|
| 115 | + } |
|
| 109 | 116 | |
| 110 | 117 | if (!is_dir($outDN) && $maintainStructure) { |
| 111 | 118 | $str = ''; |
@@ -115,16 +122,20 @@ discard block |
||
| 115 | 122 | if (!is_dir("$targetDir/$str")) { |
| 116 | 123 | $this->debugMsg(1, "Creating folder: $targetDir/$str"); |
| 117 | 124 | mkdir("$targetDir/$str"); |
| 118 | - if ($applyChmod) |
|
| 119 | - @chmod("$targetDir/$str", $applyChmod); |
|
| 125 | + if ($applyChmod) { |
|
| 126 | + @chmod("$targetDir/$str", $applyChmod); |
|
| 127 | + } |
|
| 120 | 128 | } |
| 121 | 129 | } |
| 122 | 130 | } |
| 123 | - if (substr($fileName, -1, 1) == '/') |
|
| 124 | - continue; |
|
| 131 | + if (substr($fileName, -1, 1) == '/') { |
|
| 132 | + continue; |
|
| 133 | + } |
|
| 125 | 134 | |
| 126 | - if (substr($fileName, -3) == '.sh') |
|
| 127 | - $applyChmod = 0775; // Script executable. |
|
| 135 | + if (substr($fileName, -3) == '.sh') { |
|
| 136 | + $applyChmod = 0775; |
|
| 137 | + } |
|
| 138 | + // Script executable. |
|
| 128 | 139 | $this->unzip($fileName, "$targetDir/$dirname/" . basename($fileName), $applyChmod); |
| 129 | 140 | } |
| 130 | 141 | } |
@@ -138,8 +149,9 @@ discard block |
||
| 138 | 149 | { |
| 139 | 150 | $fileList = $this->getList(); |
| 140 | 151 | foreach ($fileList as $file => $details) { |
| 141 | - if ($fileName === $file) |
|
| 142 | - return true; |
|
| 152 | + if ($fileName === $file) { |
|
| 153 | + return true; |
|
| 154 | + } |
|
| 143 | 155 | } |
| 144 | 156 | return false; |
| 145 | 157 | } |
@@ -84,8 +84,9 @@ discard block |
||
| 84 | 84 | foreach ($filelist as $filename => $fileinfo) { |
| 85 | 85 | if (!$unzip->isdir($filename)) { |
| 86 | 86 | |
| 87 | - if (strpos($filename, '/') === false) |
|
| 88 | - continue; |
|
| 87 | + if (strpos($filename, '/') === false) { |
|
| 88 | + continue; |
|
| 89 | + } |
|
| 89 | 90 | |
| 90 | 91 | $targetdir = substr($filename, 0, strripos($filename, '/')); |
| 91 | 92 | $targetfile = basename($filename); |
@@ -146,8 +147,9 @@ discard block |
||
| 146 | 147 | } |
| 147 | 148 | } |
| 148 | 149 | } |
| 149 | - if ($unzip) |
|
| 150 | - $unzip->close(); |
|
| 150 | + if ($unzip) { |
|
| 151 | + $unzip->close(); |
|
| 152 | + } |
|
| 151 | 153 | |
| 152 | 154 | self::register($prefix, $label, $name); |
| 153 | 155 | |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | //END |
| 36 | 36 | |
| 37 | 37 | $recordId = $entityData->getId(); |
| 38 | - $vtEntityDelta = new VTEntityDelta (); |
|
| 38 | + $vtEntityDelta = new VTEntityDelta(); |
|
| 39 | 39 | $newEntityData = $vtEntityDelta->getNewEntity($moduleName, $recordId); |
| 40 | 40 | $recordValues = $newEntityData->getData(); |
| 41 | 41 | $isAssignToModified = $this->isAssignToChanged($moduleName, $recordId, $current_user); |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | $meta = $handler->getMeta(); |
| 61 | 61 | $moduleOwnerFields = $meta->getOwnerFields(); |
| 62 | 62 | $assignToChanged = false; |
| 63 | - $vtEntityDelta = new VTEntityDelta (); |
|
| 63 | + $vtEntityDelta = new VTEntityDelta(); |
|
| 64 | 64 | foreach ($moduleOwnerFields as $ownerField) { |
| 65 | 65 | $assignToChanged = $vtEntityDelta->hasChanged($moduleName, $recordId, $ownerField); |
| 66 | 66 | if ($assignToChanged) |
@@ -63,8 +63,9 @@ discard block |
||
| 63 | 63 | $vtEntityDelta = new VTEntityDelta (); |
| 64 | 64 | foreach ($moduleOwnerFields as $ownerField) { |
| 65 | 65 | $assignToChanged = $vtEntityDelta->hasChanged($moduleName, $recordId, $ownerField); |
| 66 | - if ($assignToChanged) |
|
| 67 | - break; |
|
| 66 | + if ($assignToChanged) { |
|
| 67 | + break; |
|
| 68 | + } |
|
| 68 | 69 | } |
| 69 | 70 | return $assignToChanged; |
| 70 | 71 | } |
@@ -73,8 +74,9 @@ discard block |
||
| 73 | 74 | { |
| 74 | 75 | //TODO: Handle getting the webservice modulename in a better way |
| 75 | 76 | $wsModuleName = $workFlowModuleName; |
| 76 | - if ($workFlowModuleName == "Activity") |
|
| 77 | - $wsModuleName = "Calendar"; |
|
| 77 | + if ($workFlowModuleName == "Activity") { |
|
| 78 | + $wsModuleName = "Calendar"; |
|
| 79 | + } |
|
| 78 | 80 | return $wsModuleName; |
| 79 | 81 | } |
| 80 | 82 | } |
@@ -42,15 +42,19 @@ discard block |
||
| 42 | 42 | $entityMetaList = array(); |
| 43 | 43 | $db = PearDatabase::getInstance(); |
| 44 | 44 | |
| 45 | - if (empty($entityNames)) |
|
| 46 | - return; |
|
| 47 | - |
|
| 48 | - if (!is_array($entityNames)) |
|
| 49 | - $entityNames = array($entityNames); |
|
| 50 | - if (empty($modules)) |
|
| 51 | - return array(); |
|
| 52 | - if (!is_array($modules)) |
|
| 53 | - $modules = array($modules); |
|
| 45 | + if (empty($entityNames)) { |
|
| 46 | + return; |
|
| 47 | + } |
|
| 48 | + |
|
| 49 | + if (!is_array($entityNames)) { |
|
| 50 | + $entityNames = array($entityNames); |
|
| 51 | + } |
|
| 52 | + if (empty($modules)) { |
|
| 53 | + return array(); |
|
| 54 | + } |
|
| 55 | + if (!is_array($modules)) { |
|
| 56 | + $modules = array($modules); |
|
| 57 | + } |
|
| 54 | 58 | $entityNameIds = array(); |
| 55 | 59 | foreach ($modules as $moduleName) { |
| 56 | 60 | if (empty($entityMetaList[$moduleName])) { |
@@ -62,8 +66,9 @@ discard block |
||
| 62 | 66 | $nameFieldsArray = explode(",", $meta->getNameFields()); |
| 63 | 67 | if (count($nameFieldsArray) > 1) { |
| 64 | 68 | $nameFields = "concat(" . implode(",' ',", $nameFieldsArray) . ")"; |
| 65 | - } else |
|
| 66 | - $nameFields = $nameFieldsArray[0]; |
|
| 69 | + } else { |
|
| 70 | + $nameFields = $nameFieldsArray[0]; |
|
| 71 | + } |
|
| 67 | 72 | |
| 68 | 73 | $query = sprintf("SELECT %s as id,%s as entityname |
| 69 | 74 | FROM %s as moduleentity |
@@ -102,12 +107,15 @@ discard block |
||
| 102 | 107 | function wsapp_checkIfRecordsAssignToUser($recordsIds, $userIds) |
| 103 | 108 | { |
| 104 | 109 | $assignedRecordIds = []; |
| 105 | - if (!is_array($recordsIds)) |
|
| 106 | - $recordsIds = [$recordsIds]; |
|
| 107 | - if (count($recordsIds) <= 0) |
|
| 108 | - return $assignedRecordIds; |
|
| 109 | - if (!is_array($userIds)) |
|
| 110 | - $userIds = [$userIds]; |
|
| 110 | + if (!is_array($recordsIds)) { |
|
| 111 | + $recordsIds = [$recordsIds]; |
|
| 112 | + } |
|
| 113 | + if (count($recordsIds) <= 0) { |
|
| 114 | + return $assignedRecordIds; |
|
| 115 | + } |
|
| 116 | + if (!is_array($userIds)) { |
|
| 117 | + $userIds = [$userIds]; |
|
| 118 | + } |
|
| 111 | 119 | $db = PearDatabase::getInstance(); |
| 112 | 120 | $query = sprintf("SELECT * FROM vtiger_crmentity where crmid IN (%s) and smownerid in (%s)", generateQuestionMarks($recordsIds), generateQuestionMarks($userIds)); |
| 113 | 121 | $params = []; |
@@ -126,6 +126,9 @@ discard block |
||
| 126 | 126 | return $assignedRecordIds; |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | +/** |
|
| 130 | + * @param string $appName |
|
| 131 | + */ |
|
| 129 | 132 | function wsapp_getAppKey($appName) |
| 130 | 133 | { |
| 131 | 134 | $db = PearDatabase::getInstance(); |
@@ -152,6 +155,11 @@ discard block |
||
| 152 | 155 | return $syncType; |
| 153 | 156 | } |
| 154 | 157 | |
| 158 | +/** |
|
| 159 | + * @param string $type |
|
| 160 | + * @param string $handlerClass |
|
| 161 | + * @param string $handlerPath |
|
| 162 | + */ |
|
| 155 | 163 | function wsapp_RegisterHandler($type, $handlerClass, $handlerPath) |
| 156 | 164 | { |
| 157 | 165 | $db = PearDatabase::getInstance(); |