@@ -33,128 +33,128 @@ |
||
| 33 | 33 | * @since 11.0.0 |
| 34 | 34 | */ |
| 35 | 35 | interface ILDAPProvider { |
| 36 | - /** |
|
| 37 | - * Translate a user id to LDAP DN. |
|
| 38 | - * @param string $uid user id |
|
| 39 | - * @return string |
|
| 40 | - * @since 11.0.0 |
|
| 41 | - */ |
|
| 42 | - public function getUserDN($uid); |
|
| 36 | + /** |
|
| 37 | + * Translate a user id to LDAP DN. |
|
| 38 | + * @param string $uid user id |
|
| 39 | + * @return string |
|
| 40 | + * @since 11.0.0 |
|
| 41 | + */ |
|
| 42 | + public function getUserDN($uid); |
|
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * Translate a group id to LDAP DN. |
|
| 46 | - * @param string $gid group id |
|
| 47 | - * @return string |
|
| 48 | - * @since 13.0.0 |
|
| 49 | - */ |
|
| 50 | - public function getGroupDN($gid); |
|
| 44 | + /** |
|
| 45 | + * Translate a group id to LDAP DN. |
|
| 46 | + * @param string $gid group id |
|
| 47 | + * @return string |
|
| 48 | + * @since 13.0.0 |
|
| 49 | + */ |
|
| 50 | + public function getGroupDN($gid); |
|
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * Translate a LDAP DN to an internal user name. |
|
| 54 | - * @param string $dn LDAP DN |
|
| 55 | - * @return string with the internal user name |
|
| 56 | - * @throws \Exception if translation was unsuccessful |
|
| 57 | - * @since 11.0.0 |
|
| 58 | - */ |
|
| 59 | - public function getUserName($dn); |
|
| 52 | + /** |
|
| 53 | + * Translate a LDAP DN to an internal user name. |
|
| 54 | + * @param string $dn LDAP DN |
|
| 55 | + * @return string with the internal user name |
|
| 56 | + * @throws \Exception if translation was unsuccessful |
|
| 57 | + * @since 11.0.0 |
|
| 58 | + */ |
|
| 59 | + public function getUserName($dn); |
|
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * Convert a stored DN so it can be used as base parameter for LDAP queries. |
|
| 63 | - * @param string $dn the DN |
|
| 64 | - * @return string |
|
| 65 | - * @since 11.0.0 |
|
| 66 | - */ |
|
| 67 | - public function DNasBaseParameter($dn); |
|
| 61 | + /** |
|
| 62 | + * Convert a stored DN so it can be used as base parameter for LDAP queries. |
|
| 63 | + * @param string $dn the DN |
|
| 64 | + * @return string |
|
| 65 | + * @since 11.0.0 |
|
| 66 | + */ |
|
| 67 | + public function DNasBaseParameter($dn); |
|
| 68 | 68 | |
| 69 | - /** |
|
| 70 | - * Sanitize a DN received from the LDAP server. |
|
| 71 | - * @param array $dn the DN in question |
|
| 72 | - * @return array the sanitized DN |
|
| 73 | - * @since 11.0.0 |
|
| 74 | - */ |
|
| 75 | - public function sanitizeDN($dn); |
|
| 69 | + /** |
|
| 70 | + * Sanitize a DN received from the LDAP server. |
|
| 71 | + * @param array $dn the DN in question |
|
| 72 | + * @return array the sanitized DN |
|
| 73 | + * @since 11.0.0 |
|
| 74 | + */ |
|
| 75 | + public function sanitizeDN($dn); |
|
| 76 | 76 | |
| 77 | - /** |
|
| 78 | - * Return a new LDAP connection resource for the specified user. |
|
| 79 | - * @param string $uid user id |
|
| 80 | - * @return resource of the LDAP connection |
|
| 81 | - * @since 11.0.0 |
|
| 82 | - */ |
|
| 83 | - public function getLDAPConnection($uid); |
|
| 77 | + /** |
|
| 78 | + * Return a new LDAP connection resource for the specified user. |
|
| 79 | + * @param string $uid user id |
|
| 80 | + * @return resource of the LDAP connection |
|
| 81 | + * @since 11.0.0 |
|
| 82 | + */ |
|
| 83 | + public function getLDAPConnection($uid); |
|
| 84 | 84 | |
| 85 | - /** |
|
| 86 | - * Return a new LDAP connection resource for the specified group. |
|
| 87 | - * @param string $gid group id |
|
| 88 | - * @return resource of the LDAP connection |
|
| 89 | - * @since 13.0.0 |
|
| 90 | - */ |
|
| 91 | - public function getGroupLDAPConnection($gid); |
|
| 85 | + /** |
|
| 86 | + * Return a new LDAP connection resource for the specified group. |
|
| 87 | + * @param string $gid group id |
|
| 88 | + * @return resource of the LDAP connection |
|
| 89 | + * @since 13.0.0 |
|
| 90 | + */ |
|
| 91 | + public function getGroupLDAPConnection($gid); |
|
| 92 | 92 | |
| 93 | - /** |
|
| 94 | - * Get the LDAP base for users. |
|
| 95 | - * @param string $uid user id |
|
| 96 | - * @return string the base for users |
|
| 97 | - * @throws \Exception if user id was not found in LDAP |
|
| 98 | - * @since 11.0.0 |
|
| 99 | - */ |
|
| 100 | - public function getLDAPBaseUsers($uid); |
|
| 93 | + /** |
|
| 94 | + * Get the LDAP base for users. |
|
| 95 | + * @param string $uid user id |
|
| 96 | + * @return string the base for users |
|
| 97 | + * @throws \Exception if user id was not found in LDAP |
|
| 98 | + * @since 11.0.0 |
|
| 99 | + */ |
|
| 100 | + public function getLDAPBaseUsers($uid); |
|
| 101 | 101 | |
| 102 | - /** |
|
| 103 | - * Get the LDAP base for groups. |
|
| 104 | - * @param string $uid user id |
|
| 105 | - * @return string the base for groups |
|
| 106 | - * @throws \Exception if user id was not found in LDAP |
|
| 107 | - * @since 11.0.0 |
|
| 108 | - */ |
|
| 109 | - public function getLDAPBaseGroups($uid); |
|
| 102 | + /** |
|
| 103 | + * Get the LDAP base for groups. |
|
| 104 | + * @param string $uid user id |
|
| 105 | + * @return string the base for groups |
|
| 106 | + * @throws \Exception if user id was not found in LDAP |
|
| 107 | + * @since 11.0.0 |
|
| 108 | + */ |
|
| 109 | + public function getLDAPBaseGroups($uid); |
|
| 110 | 110 | |
| 111 | - /** |
|
| 112 | - * Check whether a LDAP DN exists |
|
| 113 | - * @param string $dn LDAP DN |
|
| 114 | - * @return bool whether the DN exists |
|
| 115 | - * @since 11.0.0 |
|
| 116 | - */ |
|
| 117 | - public function dnExists($dn); |
|
| 111 | + /** |
|
| 112 | + * Check whether a LDAP DN exists |
|
| 113 | + * @param string $dn LDAP DN |
|
| 114 | + * @return bool whether the DN exists |
|
| 115 | + * @since 11.0.0 |
|
| 116 | + */ |
|
| 117 | + public function dnExists($dn); |
|
| 118 | 118 | |
| 119 | - /** |
|
| 120 | - * Clear the cache if a cache is used, otherwise do nothing. |
|
| 121 | - * @param string $uid user id |
|
| 122 | - * @since 11.0.0 |
|
| 123 | - */ |
|
| 124 | - public function clearCache($uid); |
|
| 119 | + /** |
|
| 120 | + * Clear the cache if a cache is used, otherwise do nothing. |
|
| 121 | + * @param string $uid user id |
|
| 122 | + * @since 11.0.0 |
|
| 123 | + */ |
|
| 124 | + public function clearCache($uid); |
|
| 125 | 125 | |
| 126 | - /** |
|
| 127 | - * Clear the cache if a cache is used, otherwise do nothing. |
|
| 128 | - * @param string $gid group id |
|
| 129 | - * @since 13.0.0 |
|
| 130 | - */ |
|
| 131 | - public function clearGroupCache($gid); |
|
| 126 | + /** |
|
| 127 | + * Clear the cache if a cache is used, otherwise do nothing. |
|
| 128 | + * @param string $gid group id |
|
| 129 | + * @since 13.0.0 |
|
| 130 | + */ |
|
| 131 | + public function clearGroupCache($gid); |
|
| 132 | 132 | |
| 133 | - /** |
|
| 134 | - * Get the LDAP attribute name for the user's display name |
|
| 135 | - * @param string $uid user id |
|
| 136 | - * @return string the display name field |
|
| 137 | - * @throws \Exception if user id was not found in LDAP |
|
| 138 | - * @since 12.0.0 |
|
| 139 | - */ |
|
| 140 | - public function getLDAPDisplayNameField($uid); |
|
| 133 | + /** |
|
| 134 | + * Get the LDAP attribute name for the user's display name |
|
| 135 | + * @param string $uid user id |
|
| 136 | + * @return string the display name field |
|
| 137 | + * @throws \Exception if user id was not found in LDAP |
|
| 138 | + * @since 12.0.0 |
|
| 139 | + */ |
|
| 140 | + public function getLDAPDisplayNameField($uid); |
|
| 141 | 141 | |
| 142 | - /** |
|
| 143 | - * Get the LDAP attribute name for the email |
|
| 144 | - * @param string $uid user id |
|
| 145 | - * @return string the email field |
|
| 146 | - * @throws \Exception if user id was not found in LDAP |
|
| 147 | - * @since 12.0.0 |
|
| 148 | - */ |
|
| 149 | - public function getLDAPEmailField($uid); |
|
| 142 | + /** |
|
| 143 | + * Get the LDAP attribute name for the email |
|
| 144 | + * @param string $uid user id |
|
| 145 | + * @return string the email field |
|
| 146 | + * @throws \Exception if user id was not found in LDAP |
|
| 147 | + * @since 12.0.0 |
|
| 148 | + */ |
|
| 149 | + public function getLDAPEmailField($uid); |
|
| 150 | 150 | |
| 151 | - /** |
|
| 152 | - * Get the LDAP attribute name for the type of association betweeen users and groups |
|
| 153 | - * @param string $gid group id |
|
| 154 | - * @return string the configuration, one of: 'memberUid', 'uniqueMember', 'member', 'gidNumber' |
|
| 155 | - * @throws \Exception if group id was not found in LDAP |
|
| 156 | - * @since 13.0.0 |
|
| 157 | - */ |
|
| 158 | - public function getLDAPGroupMemberAssoc($gid); |
|
| 151 | + /** |
|
| 152 | + * Get the LDAP attribute name for the type of association betweeen users and groups |
|
| 153 | + * @param string $gid group id |
|
| 154 | + * @return string the configuration, one of: 'memberUid', 'uniqueMember', 'member', 'gidNumber' |
|
| 155 | + * @throws \Exception if group id was not found in LDAP |
|
| 156 | + * @since 13.0.0 |
|
| 157 | + */ |
|
| 158 | + public function getLDAPGroupMemberAssoc($gid); |
|
| 159 | 159 | |
| 160 | 160 | } |
@@ -27,143 +27,143 @@ |
||
| 27 | 27 | |
| 28 | 28 | class GroupPluginManager { |
| 29 | 29 | |
| 30 | - private $respondToActions = 0; |
|
| 31 | - |
|
| 32 | - private $which = array( |
|
| 33 | - GroupInterface::CREATE_GROUP => null, |
|
| 34 | - GroupInterface::DELETE_GROUP => null, |
|
| 35 | - GroupInterface::ADD_TO_GROUP => null, |
|
| 36 | - GroupInterface::REMOVE_FROM_GROUP => null, |
|
| 37 | - GroupInterface::COUNT_USERS => null, |
|
| 38 | - GroupInterface::GROUP_DETAILS => null |
|
| 39 | - ); |
|
| 40 | - |
|
| 41 | - /** |
|
| 42 | - * @return int All implemented actions |
|
| 43 | - */ |
|
| 44 | - public function getImplementedActions() { |
|
| 45 | - return $this->respondToActions; |
|
| 46 | - } |
|
| 47 | - |
|
| 48 | - /** |
|
| 49 | - * Registers a group plugin that may implement some actions, overriding User_LDAP's group actions. |
|
| 50 | - * @param ILDAPGroupPlugin $plugin |
|
| 51 | - */ |
|
| 52 | - public function register(ILDAPGroupPlugin $plugin) { |
|
| 53 | - $respondToActions = $plugin->respondToActions(); |
|
| 54 | - $this->respondToActions |= $respondToActions; |
|
| 55 | - |
|
| 56 | - foreach($this->which as $action => $v) { |
|
| 57 | - if ((bool)($respondToActions & $action)) { |
|
| 58 | - $this->which[$action] = $plugin; |
|
| 59 | - \OC::$server->getLogger()->debug("Registered action ".$action." to plugin ".get_class($plugin), ['app' => 'user_ldap']); |
|
| 60 | - } |
|
| 61 | - } |
|
| 62 | - } |
|
| 63 | - |
|
| 64 | - /** |
|
| 65 | - * Signal if there is a registered plugin that implements some given actions |
|
| 66 | - * @param int $actions Actions defined in \OCP\GroupInterface, like GroupInterface::REMOVE_FROM_GROUP |
|
| 67 | - * @return bool |
|
| 68 | - */ |
|
| 69 | - public function implementsActions($actions) { |
|
| 70 | - return ($actions & $this->respondToActions) == $actions; |
|
| 71 | - } |
|
| 72 | - |
|
| 73 | - /** |
|
| 74 | - * Create a group |
|
| 75 | - * @param string $gid Group Id |
|
| 76 | - * @return string | null The group DN if group creation was successful. |
|
| 77 | - * @throws \Exception |
|
| 78 | - */ |
|
| 79 | - public function createGroup($gid) { |
|
| 80 | - $plugin = $this->which[GroupInterface::CREATE_GROUP]; |
|
| 81 | - |
|
| 82 | - if ($plugin) { |
|
| 83 | - return $plugin->createGroup($gid); |
|
| 84 | - } |
|
| 85 | - throw new \Exception('No plugin implements createGroup in this LDAP Backend.'); |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - /** |
|
| 89 | - * Delete a group |
|
| 90 | - * @param string $gid Group Id of the group to delete |
|
| 91 | - * @return bool |
|
| 92 | - * @throws \Exception |
|
| 93 | - */ |
|
| 94 | - public function deleteGroup($gid) { |
|
| 95 | - $plugin = $this->which[GroupInterface::DELETE_GROUP]; |
|
| 96 | - |
|
| 97 | - if ($plugin) { |
|
| 98 | - return $plugin->deleteGroup($gid); |
|
| 99 | - } |
|
| 100 | - throw new \Exception('No plugin implements deleteGroup in this LDAP Backend.'); |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - /** |
|
| 104 | - * Add a user to a group |
|
| 105 | - * @param string $uid ID of the user to add to group |
|
| 106 | - * @param string $gid ID of the group in which add the user |
|
| 107 | - * @return bool |
|
| 108 | - * @throws \Exception |
|
| 109 | - * |
|
| 110 | - * Adds a user to a group. |
|
| 111 | - */ |
|
| 112 | - public function addToGroup($uid, $gid) { |
|
| 113 | - $plugin = $this->which[GroupInterface::ADD_TO_GROUP]; |
|
| 114 | - |
|
| 115 | - if ($plugin) { |
|
| 116 | - return $plugin->addToGroup($uid, $gid); |
|
| 117 | - } |
|
| 118 | - throw new \Exception('No plugin implements addToGroup in this LDAP Backend.'); |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - /** |
|
| 122 | - * Removes a user from a group |
|
| 123 | - * @param string $uid ID of the user to remove from group |
|
| 124 | - * @param string $gid ID of the group from which remove the user |
|
| 125 | - * @return bool |
|
| 126 | - * @throws \Exception |
|
| 127 | - * |
|
| 128 | - * removes the user from a group. |
|
| 129 | - */ |
|
| 130 | - public function removeFromGroup($uid, $gid) { |
|
| 131 | - $plugin = $this->which[GroupInterface::REMOVE_FROM_GROUP]; |
|
| 132 | - |
|
| 133 | - if ($plugin) { |
|
| 134 | - return $plugin->removeFromGroup($uid, $gid); |
|
| 135 | - } |
|
| 136 | - throw new \Exception('No plugin implements removeFromGroup in this LDAP Backend.'); |
|
| 137 | - } |
|
| 138 | - |
|
| 139 | - /** |
|
| 140 | - * get the number of all users matching the search string in a group |
|
| 141 | - * @param string $gid ID of the group |
|
| 142 | - * @param string $search query string |
|
| 143 | - * @return int|false |
|
| 144 | - * @throws \Exception |
|
| 145 | - */ |
|
| 146 | - public function countUsersInGroup($gid, $search = '') { |
|
| 147 | - $plugin = $this->which[GroupInterface::COUNT_USERS]; |
|
| 148 | - |
|
| 149 | - if ($plugin) { |
|
| 150 | - return $plugin->countUsersInGroup($gid,$search); |
|
| 151 | - } |
|
| 152 | - throw new \Exception('No plugin implements countUsersInGroup in this LDAP Backend.'); |
|
| 153 | - } |
|
| 154 | - |
|
| 155 | - /** |
|
| 156 | - * get an array with group details |
|
| 157 | - * @param string $gid |
|
| 158 | - * @return array|false |
|
| 159 | - * @throws \Exception |
|
| 160 | - */ |
|
| 161 | - public function getGroupDetails($gid) { |
|
| 162 | - $plugin = $this->which[GroupInterface::GROUP_DETAILS]; |
|
| 163 | - |
|
| 164 | - if ($plugin) { |
|
| 165 | - return $plugin->getGroupDetails($gid); |
|
| 166 | - } |
|
| 167 | - throw new \Exception('No plugin implements getGroupDetails in this LDAP Backend.'); |
|
| 168 | - } |
|
| 30 | + private $respondToActions = 0; |
|
| 31 | + |
|
| 32 | + private $which = array( |
|
| 33 | + GroupInterface::CREATE_GROUP => null, |
|
| 34 | + GroupInterface::DELETE_GROUP => null, |
|
| 35 | + GroupInterface::ADD_TO_GROUP => null, |
|
| 36 | + GroupInterface::REMOVE_FROM_GROUP => null, |
|
| 37 | + GroupInterface::COUNT_USERS => null, |
|
| 38 | + GroupInterface::GROUP_DETAILS => null |
|
| 39 | + ); |
|
| 40 | + |
|
| 41 | + /** |
|
| 42 | + * @return int All implemented actions |
|
| 43 | + */ |
|
| 44 | + public function getImplementedActions() { |
|
| 45 | + return $this->respondToActions; |
|
| 46 | + } |
|
| 47 | + |
|
| 48 | + /** |
|
| 49 | + * Registers a group plugin that may implement some actions, overriding User_LDAP's group actions. |
|
| 50 | + * @param ILDAPGroupPlugin $plugin |
|
| 51 | + */ |
|
| 52 | + public function register(ILDAPGroupPlugin $plugin) { |
|
| 53 | + $respondToActions = $plugin->respondToActions(); |
|
| 54 | + $this->respondToActions |= $respondToActions; |
|
| 55 | + |
|
| 56 | + foreach($this->which as $action => $v) { |
|
| 57 | + if ((bool)($respondToActions & $action)) { |
|
| 58 | + $this->which[$action] = $plugin; |
|
| 59 | + \OC::$server->getLogger()->debug("Registered action ".$action." to plugin ".get_class($plugin), ['app' => 'user_ldap']); |
|
| 60 | + } |
|
| 61 | + } |
|
| 62 | + } |
|
| 63 | + |
|
| 64 | + /** |
|
| 65 | + * Signal if there is a registered plugin that implements some given actions |
|
| 66 | + * @param int $actions Actions defined in \OCP\GroupInterface, like GroupInterface::REMOVE_FROM_GROUP |
|
| 67 | + * @return bool |
|
| 68 | + */ |
|
| 69 | + public function implementsActions($actions) { |
|
| 70 | + return ($actions & $this->respondToActions) == $actions; |
|
| 71 | + } |
|
| 72 | + |
|
| 73 | + /** |
|
| 74 | + * Create a group |
|
| 75 | + * @param string $gid Group Id |
|
| 76 | + * @return string | null The group DN if group creation was successful. |
|
| 77 | + * @throws \Exception |
|
| 78 | + */ |
|
| 79 | + public function createGroup($gid) { |
|
| 80 | + $plugin = $this->which[GroupInterface::CREATE_GROUP]; |
|
| 81 | + |
|
| 82 | + if ($plugin) { |
|
| 83 | + return $plugin->createGroup($gid); |
|
| 84 | + } |
|
| 85 | + throw new \Exception('No plugin implements createGroup in this LDAP Backend.'); |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + /** |
|
| 89 | + * Delete a group |
|
| 90 | + * @param string $gid Group Id of the group to delete |
|
| 91 | + * @return bool |
|
| 92 | + * @throws \Exception |
|
| 93 | + */ |
|
| 94 | + public function deleteGroup($gid) { |
|
| 95 | + $plugin = $this->which[GroupInterface::DELETE_GROUP]; |
|
| 96 | + |
|
| 97 | + if ($plugin) { |
|
| 98 | + return $plugin->deleteGroup($gid); |
|
| 99 | + } |
|
| 100 | + throw new \Exception('No plugin implements deleteGroup in this LDAP Backend.'); |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + /** |
|
| 104 | + * Add a user to a group |
|
| 105 | + * @param string $uid ID of the user to add to group |
|
| 106 | + * @param string $gid ID of the group in which add the user |
|
| 107 | + * @return bool |
|
| 108 | + * @throws \Exception |
|
| 109 | + * |
|
| 110 | + * Adds a user to a group. |
|
| 111 | + */ |
|
| 112 | + public function addToGroup($uid, $gid) { |
|
| 113 | + $plugin = $this->which[GroupInterface::ADD_TO_GROUP]; |
|
| 114 | + |
|
| 115 | + if ($plugin) { |
|
| 116 | + return $plugin->addToGroup($uid, $gid); |
|
| 117 | + } |
|
| 118 | + throw new \Exception('No plugin implements addToGroup in this LDAP Backend.'); |
|
| 119 | + } |
|
| 120 | + |
|
| 121 | + /** |
|
| 122 | + * Removes a user from a group |
|
| 123 | + * @param string $uid ID of the user to remove from group |
|
| 124 | + * @param string $gid ID of the group from which remove the user |
|
| 125 | + * @return bool |
|
| 126 | + * @throws \Exception |
|
| 127 | + * |
|
| 128 | + * removes the user from a group. |
|
| 129 | + */ |
|
| 130 | + public function removeFromGroup($uid, $gid) { |
|
| 131 | + $plugin = $this->which[GroupInterface::REMOVE_FROM_GROUP]; |
|
| 132 | + |
|
| 133 | + if ($plugin) { |
|
| 134 | + return $plugin->removeFromGroup($uid, $gid); |
|
| 135 | + } |
|
| 136 | + throw new \Exception('No plugin implements removeFromGroup in this LDAP Backend.'); |
|
| 137 | + } |
|
| 138 | + |
|
| 139 | + /** |
|
| 140 | + * get the number of all users matching the search string in a group |
|
| 141 | + * @param string $gid ID of the group |
|
| 142 | + * @param string $search query string |
|
| 143 | + * @return int|false |
|
| 144 | + * @throws \Exception |
|
| 145 | + */ |
|
| 146 | + public function countUsersInGroup($gid, $search = '') { |
|
| 147 | + $plugin = $this->which[GroupInterface::COUNT_USERS]; |
|
| 148 | + |
|
| 149 | + if ($plugin) { |
|
| 150 | + return $plugin->countUsersInGroup($gid,$search); |
|
| 151 | + } |
|
| 152 | + throw new \Exception('No plugin implements countUsersInGroup in this LDAP Backend.'); |
|
| 153 | + } |
|
| 154 | + |
|
| 155 | + /** |
|
| 156 | + * get an array with group details |
|
| 157 | + * @param string $gid |
|
| 158 | + * @return array|false |
|
| 159 | + * @throws \Exception |
|
| 160 | + */ |
|
| 161 | + public function getGroupDetails($gid) { |
|
| 162 | + $plugin = $this->which[GroupInterface::GROUP_DETAILS]; |
|
| 163 | + |
|
| 164 | + if ($plugin) { |
|
| 165 | + return $plugin->getGroupDetails($gid); |
|
| 166 | + } |
|
| 167 | + throw new \Exception('No plugin implements getGroupDetails in this LDAP Backend.'); |
|
| 168 | + } |
|
| 169 | 169 | } |
@@ -53,8 +53,8 @@ discard block |
||
| 53 | 53 | $respondToActions = $plugin->respondToActions(); |
| 54 | 54 | $this->respondToActions |= $respondToActions; |
| 55 | 55 | |
| 56 | - foreach($this->which as $action => $v) { |
|
| 57 | - if ((bool)($respondToActions & $action)) { |
|
| 56 | + foreach ($this->which as $action => $v) { |
|
| 57 | + if ((bool) ($respondToActions & $action)) { |
|
| 58 | 58 | $this->which[$action] = $plugin; |
| 59 | 59 | \OC::$server->getLogger()->debug("Registered action ".$action." to plugin ".get_class($plugin), ['app' => 'user_ldap']); |
| 60 | 60 | } |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | $plugin = $this->which[GroupInterface::COUNT_USERS]; |
| 148 | 148 | |
| 149 | 149 | if ($plugin) { |
| 150 | - return $plugin->countUsersInGroup($gid,$search); |
|
| 150 | + return $plugin->countUsersInGroup($gid, $search); |
|
| 151 | 151 | } |
| 152 | 152 | throw new \Exception('No plugin implements countUsersInGroup in this LDAP Backend.'); |
| 153 | 153 | } |
@@ -30,35 +30,35 @@ |
||
| 30 | 30 | use OCP\Command\ICommand; |
| 31 | 31 | |
| 32 | 32 | class Expire implements ICommand { |
| 33 | - use FileAccess; |
|
| 33 | + use FileAccess; |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * @var string |
|
| 37 | - */ |
|
| 38 | - private $fileName; |
|
| 35 | + /** |
|
| 36 | + * @var string |
|
| 37 | + */ |
|
| 38 | + private $fileName; |
|
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * @var string |
|
| 42 | - */ |
|
| 43 | - private $user; |
|
| 40 | + /** |
|
| 41 | + * @var string |
|
| 42 | + */ |
|
| 43 | + private $user; |
|
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * @param string $user |
|
| 47 | - * @param string $fileName |
|
| 48 | - */ |
|
| 49 | - function __construct($user, $fileName) { |
|
| 50 | - $this->user = $user; |
|
| 51 | - $this->fileName = $fileName; |
|
| 52 | - } |
|
| 45 | + /** |
|
| 46 | + * @param string $user |
|
| 47 | + * @param string $fileName |
|
| 48 | + */ |
|
| 49 | + function __construct($user, $fileName) { |
|
| 50 | + $this->user = $user; |
|
| 51 | + $this->fileName = $fileName; |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | 54 | |
| 55 | - public function handle() { |
|
| 56 | - $userManager = \OC::$server->getUserManager(); |
|
| 57 | - if (!$userManager->userExists($this->user)) { |
|
| 58 | - // User has been deleted already |
|
| 59 | - return; |
|
| 60 | - } |
|
| 55 | + public function handle() { |
|
| 56 | + $userManager = \OC::$server->getUserManager(); |
|
| 57 | + if (!$userManager->userExists($this->user)) { |
|
| 58 | + // User has been deleted already |
|
| 59 | + return; |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - Storage::expire($this->fileName, $this->user); |
|
| 63 | - } |
|
| 62 | + Storage::expire($this->fileName, $this->user); |
|
| 63 | + } |
|
| 64 | 64 | } |
@@ -30,82 +30,82 @@ |
||
| 30 | 30 | |
| 31 | 31 | class Manager { |
| 32 | 32 | |
| 33 | - /** @var ContactsStore */ |
|
| 34 | - private $store; |
|
| 33 | + /** @var ContactsStore */ |
|
| 34 | + private $store; |
|
| 35 | 35 | |
| 36 | - /** @var ActionProviderStore */ |
|
| 37 | - private $actionProviderStore; |
|
| 36 | + /** @var ActionProviderStore */ |
|
| 37 | + private $actionProviderStore; |
|
| 38 | 38 | |
| 39 | - /** @var IAppManager */ |
|
| 40 | - private $appManager; |
|
| 39 | + /** @var IAppManager */ |
|
| 40 | + private $appManager; |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * @param ContactsStore $store |
|
| 44 | - * @param ActionProviderStore $actionProviderStore |
|
| 45 | - * @param IAppManager $appManager |
|
| 46 | - */ |
|
| 47 | - public function __construct(ContactsStore $store, ActionProviderStore $actionProviderStore, IAppManager $appManager) { |
|
| 48 | - $this->store = $store; |
|
| 49 | - $this->actionProviderStore = $actionProviderStore; |
|
| 50 | - $this->appManager = $appManager; |
|
| 51 | - } |
|
| 42 | + /** |
|
| 43 | + * @param ContactsStore $store |
|
| 44 | + * @param ActionProviderStore $actionProviderStore |
|
| 45 | + * @param IAppManager $appManager |
|
| 46 | + */ |
|
| 47 | + public function __construct(ContactsStore $store, ActionProviderStore $actionProviderStore, IAppManager $appManager) { |
|
| 48 | + $this->store = $store; |
|
| 49 | + $this->actionProviderStore = $actionProviderStore; |
|
| 50 | + $this->appManager = $appManager; |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * @param IUser $user |
|
| 55 | - * @param string $filter |
|
| 56 | - * @return array |
|
| 57 | - */ |
|
| 58 | - public function getEntries(IUser $user, $filter) { |
|
| 59 | - $entries = $this->store->getContacts($user, $filter); |
|
| 53 | + /** |
|
| 54 | + * @param IUser $user |
|
| 55 | + * @param string $filter |
|
| 56 | + * @return array |
|
| 57 | + */ |
|
| 58 | + public function getEntries(IUser $user, $filter) { |
|
| 59 | + $entries = $this->store->getContacts($user, $filter); |
|
| 60 | 60 | |
| 61 | - $sortedEntries = $this->sortEntries($entries); |
|
| 62 | - $topEntries = array_slice($sortedEntries, 0, 25); |
|
| 63 | - $this->processEntries($topEntries, $user); |
|
| 61 | + $sortedEntries = $this->sortEntries($entries); |
|
| 62 | + $topEntries = array_slice($sortedEntries, 0, 25); |
|
| 63 | + $this->processEntries($topEntries, $user); |
|
| 64 | 64 | |
| 65 | - $contactsEnabled = $this->appManager->isEnabledForUser('contacts', $user); |
|
| 66 | - return [ |
|
| 67 | - 'contacts' => $topEntries, |
|
| 68 | - 'contactsAppEnabled' => $contactsEnabled, |
|
| 69 | - ]; |
|
| 70 | - } |
|
| 65 | + $contactsEnabled = $this->appManager->isEnabledForUser('contacts', $user); |
|
| 66 | + return [ |
|
| 67 | + 'contacts' => $topEntries, |
|
| 68 | + 'contactsAppEnabled' => $contactsEnabled, |
|
| 69 | + ]; |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | - /** |
|
| 73 | - * @param IUser $user |
|
| 74 | - * @param integer $shareType |
|
| 75 | - * @param string $shareWith |
|
| 76 | - * @return IEntry |
|
| 77 | - */ |
|
| 78 | - public function findOne(IUser $user, $shareType, $shareWith) { |
|
| 79 | - $entry = $this->store->findOne($user, $shareType, $shareWith); |
|
| 80 | - if ($entry) { |
|
| 81 | - $this->processEntries([$entry], $user); |
|
| 82 | - } |
|
| 72 | + /** |
|
| 73 | + * @param IUser $user |
|
| 74 | + * @param integer $shareType |
|
| 75 | + * @param string $shareWith |
|
| 76 | + * @return IEntry |
|
| 77 | + */ |
|
| 78 | + public function findOne(IUser $user, $shareType, $shareWith) { |
|
| 79 | + $entry = $this->store->findOne($user, $shareType, $shareWith); |
|
| 80 | + if ($entry) { |
|
| 81 | + $this->processEntries([$entry], $user); |
|
| 82 | + } |
|
| 83 | 83 | |
| 84 | - return $entry; |
|
| 85 | - } |
|
| 84 | + return $entry; |
|
| 85 | + } |
|
| 86 | 86 | |
| 87 | - /** |
|
| 88 | - * @param IEntry[] $entries |
|
| 89 | - * @return IEntry[] |
|
| 90 | - */ |
|
| 91 | - private function sortEntries(array $entries) { |
|
| 92 | - usort($entries, function(IEntry $entryA, IEntry $entryB) { |
|
| 93 | - return strcasecmp($entryA->getFullName(), $entryB->getFullName()); |
|
| 94 | - }); |
|
| 95 | - return $entries; |
|
| 96 | - } |
|
| 87 | + /** |
|
| 88 | + * @param IEntry[] $entries |
|
| 89 | + * @return IEntry[] |
|
| 90 | + */ |
|
| 91 | + private function sortEntries(array $entries) { |
|
| 92 | + usort($entries, function(IEntry $entryA, IEntry $entryB) { |
|
| 93 | + return strcasecmp($entryA->getFullName(), $entryB->getFullName()); |
|
| 94 | + }); |
|
| 95 | + return $entries; |
|
| 96 | + } |
|
| 97 | 97 | |
| 98 | - /** |
|
| 99 | - * @param IEntry[] $entries |
|
| 100 | - * @param IUser $user |
|
| 101 | - */ |
|
| 102 | - private function processEntries(array $entries, IUser $user) { |
|
| 103 | - $providers = $this->actionProviderStore->getProviders($user); |
|
| 104 | - foreach ($entries as $entry) { |
|
| 105 | - foreach ($providers as $provider) { |
|
| 106 | - $provider->process($entry); |
|
| 107 | - } |
|
| 108 | - } |
|
| 109 | - } |
|
| 98 | + /** |
|
| 99 | + * @param IEntry[] $entries |
|
| 100 | + * @param IUser $user |
|
| 101 | + */ |
|
| 102 | + private function processEntries(array $entries, IUser $user) { |
|
| 103 | + $providers = $this->actionProviderStore->getProviders($user); |
|
| 104 | + foreach ($entries as $entry) { |
|
| 105 | + foreach ($providers as $provider) { |
|
| 106 | + $provider->process($entry); |
|
| 107 | + } |
|
| 108 | + } |
|
| 109 | + } |
|
| 110 | 110 | |
| 111 | 111 | } |
@@ -27,114 +27,114 @@ |
||
| 27 | 27 | |
| 28 | 28 | class Manager implements \OCP\Calendar\IManager { |
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * @var ICalendar[] holds all registered calendars |
|
| 32 | - */ |
|
| 33 | - private $calendars=[]; |
|
| 30 | + /** |
|
| 31 | + * @var ICalendar[] holds all registered calendars |
|
| 32 | + */ |
|
| 33 | + private $calendars=[]; |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * @var \Closure[] to call to load/register calendar providers |
|
| 37 | - */ |
|
| 38 | - private $calendarLoaders=[]; |
|
| 35 | + /** |
|
| 36 | + * @var \Closure[] to call to load/register calendar providers |
|
| 37 | + */ |
|
| 38 | + private $calendarLoaders=[]; |
|
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * This function is used to search and find objects within the user's calendars. |
|
| 42 | - * In case $pattern is empty all events/journals/todos will be returned. |
|
| 43 | - * |
|
| 44 | - * @param string $pattern which should match within the $searchProperties |
|
| 45 | - * @param array $searchProperties defines the properties within the query pattern should match |
|
| 46 | - * @param array $options - optional parameters: |
|
| 47 | - * ['timerange' => ['start' => new DateTime(...), 'end' => new DateTime(...)]] |
|
| 48 | - * @param integer|null $limit - limit number of search results |
|
| 49 | - * @param integer|null $offset - offset for paging of search results |
|
| 50 | - * @return array an array of events/journals/todos which are arrays of arrays of key-value-pairs |
|
| 51 | - * @since 13.0.0 |
|
| 52 | - */ |
|
| 53 | - public function search($pattern, array $searchProperties=[], array $options=[], $limit=null, $offset=null) { |
|
| 54 | - $this->loadCalendars(); |
|
| 55 | - $result = []; |
|
| 56 | - foreach($this->calendars as $calendar) { |
|
| 57 | - $r = $calendar->search($pattern, $searchProperties, $options, $limit, $offset); |
|
| 58 | - foreach($r as $o) { |
|
| 59 | - $o['calendar-key'] = $calendar->getKey(); |
|
| 60 | - $result[] = $o; |
|
| 61 | - } |
|
| 62 | - } |
|
| 40 | + /** |
|
| 41 | + * This function is used to search and find objects within the user's calendars. |
|
| 42 | + * In case $pattern is empty all events/journals/todos will be returned. |
|
| 43 | + * |
|
| 44 | + * @param string $pattern which should match within the $searchProperties |
|
| 45 | + * @param array $searchProperties defines the properties within the query pattern should match |
|
| 46 | + * @param array $options - optional parameters: |
|
| 47 | + * ['timerange' => ['start' => new DateTime(...), 'end' => new DateTime(...)]] |
|
| 48 | + * @param integer|null $limit - limit number of search results |
|
| 49 | + * @param integer|null $offset - offset for paging of search results |
|
| 50 | + * @return array an array of events/journals/todos which are arrays of arrays of key-value-pairs |
|
| 51 | + * @since 13.0.0 |
|
| 52 | + */ |
|
| 53 | + public function search($pattern, array $searchProperties=[], array $options=[], $limit=null, $offset=null) { |
|
| 54 | + $this->loadCalendars(); |
|
| 55 | + $result = []; |
|
| 56 | + foreach($this->calendars as $calendar) { |
|
| 57 | + $r = $calendar->search($pattern, $searchProperties, $options, $limit, $offset); |
|
| 58 | + foreach($r as $o) { |
|
| 59 | + $o['calendar-key'] = $calendar->getKey(); |
|
| 60 | + $result[] = $o; |
|
| 61 | + } |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - return $result; |
|
| 65 | - } |
|
| 64 | + return $result; |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - /** |
|
| 68 | - * Check if calendars are available |
|
| 69 | - * |
|
| 70 | - * @return bool true if enabled, false if not |
|
| 71 | - * @since 13.0.0 |
|
| 72 | - */ |
|
| 73 | - public function isEnabled() { |
|
| 74 | - return !empty($this->calendars) || !empty($this->calendarLoaders); |
|
| 75 | - } |
|
| 67 | + /** |
|
| 68 | + * Check if calendars are available |
|
| 69 | + * |
|
| 70 | + * @return bool true if enabled, false if not |
|
| 71 | + * @since 13.0.0 |
|
| 72 | + */ |
|
| 73 | + public function isEnabled() { |
|
| 74 | + return !empty($this->calendars) || !empty($this->calendarLoaders); |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - /** |
|
| 78 | - * Registers a calendar |
|
| 79 | - * |
|
| 80 | - * @param ICalendar $calendar |
|
| 81 | - * @return void |
|
| 82 | - * @since 13.0.0 |
|
| 83 | - */ |
|
| 84 | - public function registerCalendar(ICalendar $calendar) { |
|
| 85 | - $this->calendars[$calendar->getKey()] = $calendar; |
|
| 86 | - } |
|
| 77 | + /** |
|
| 78 | + * Registers a calendar |
|
| 79 | + * |
|
| 80 | + * @param ICalendar $calendar |
|
| 81 | + * @return void |
|
| 82 | + * @since 13.0.0 |
|
| 83 | + */ |
|
| 84 | + public function registerCalendar(ICalendar $calendar) { |
|
| 85 | + $this->calendars[$calendar->getKey()] = $calendar; |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | - /** |
|
| 89 | - * Unregisters a calendar |
|
| 90 | - * |
|
| 91 | - * @param ICalendar $calendar |
|
| 92 | - * @return void |
|
| 93 | - * @since 13.0.0 |
|
| 94 | - */ |
|
| 95 | - public function unregisterCalendar(ICalendar $calendar) { |
|
| 96 | - unset($this->calendars[$calendar->getKey()]); |
|
| 97 | - } |
|
| 88 | + /** |
|
| 89 | + * Unregisters a calendar |
|
| 90 | + * |
|
| 91 | + * @param ICalendar $calendar |
|
| 92 | + * @return void |
|
| 93 | + * @since 13.0.0 |
|
| 94 | + */ |
|
| 95 | + public function unregisterCalendar(ICalendar $calendar) { |
|
| 96 | + unset($this->calendars[$calendar->getKey()]); |
|
| 97 | + } |
|
| 98 | 98 | |
| 99 | - /** |
|
| 100 | - * In order to improve lazy loading a closure can be registered which will be called in case |
|
| 101 | - * calendars are actually requested |
|
| 102 | - * |
|
| 103 | - * @param \Closure $callable |
|
| 104 | - * @return void |
|
| 105 | - * @since 13.0.0 |
|
| 106 | - */ |
|
| 107 | - public function register(\Closure $callable) { |
|
| 108 | - $this->calendarLoaders[] = $callable; |
|
| 109 | - } |
|
| 99 | + /** |
|
| 100 | + * In order to improve lazy loading a closure can be registered which will be called in case |
|
| 101 | + * calendars are actually requested |
|
| 102 | + * |
|
| 103 | + * @param \Closure $callable |
|
| 104 | + * @return void |
|
| 105 | + * @since 13.0.0 |
|
| 106 | + */ |
|
| 107 | + public function register(\Closure $callable) { |
|
| 108 | + $this->calendarLoaders[] = $callable; |
|
| 109 | + } |
|
| 110 | 110 | |
| 111 | - /** |
|
| 112 | - * @return ICalendar[] |
|
| 113 | - * @since 13.0.0 |
|
| 114 | - */ |
|
| 115 | - public function getCalendars() { |
|
| 116 | - $this->loadCalendars(); |
|
| 111 | + /** |
|
| 112 | + * @return ICalendar[] |
|
| 113 | + * @since 13.0.0 |
|
| 114 | + */ |
|
| 115 | + public function getCalendars() { |
|
| 116 | + $this->loadCalendars(); |
|
| 117 | 117 | |
| 118 | - return array_values($this->calendars); |
|
| 119 | - } |
|
| 118 | + return array_values($this->calendars); |
|
| 119 | + } |
|
| 120 | 120 | |
| 121 | - /** |
|
| 122 | - * removes all registered calendar instances |
|
| 123 | - * @return void |
|
| 124 | - * @since 13.0.0 |
|
| 125 | - */ |
|
| 126 | - public function clear() { |
|
| 127 | - $this->calendars = []; |
|
| 128 | - $this->calendarLoaders = []; |
|
| 129 | - } |
|
| 121 | + /** |
|
| 122 | + * removes all registered calendar instances |
|
| 123 | + * @return void |
|
| 124 | + * @since 13.0.0 |
|
| 125 | + */ |
|
| 126 | + public function clear() { |
|
| 127 | + $this->calendars = []; |
|
| 128 | + $this->calendarLoaders = []; |
|
| 129 | + } |
|
| 130 | 130 | |
| 131 | - /** |
|
| 132 | - * loads all calendars |
|
| 133 | - */ |
|
| 134 | - private function loadCalendars() { |
|
| 135 | - foreach($this->calendarLoaders as $callable) { |
|
| 136 | - $callable($this); |
|
| 137 | - } |
|
| 138 | - $this->calendarLoaders = []; |
|
| 139 | - } |
|
| 131 | + /** |
|
| 132 | + * loads all calendars |
|
| 133 | + */ |
|
| 134 | + private function loadCalendars() { |
|
| 135 | + foreach($this->calendarLoaders as $callable) { |
|
| 136 | + $callable($this); |
|
| 137 | + } |
|
| 138 | + $this->calendarLoaders = []; |
|
| 139 | + } |
|
| 140 | 140 | } |
@@ -30,12 +30,12 @@ discard block |
||
| 30 | 30 | /** |
| 31 | 31 | * @var ICalendar[] holds all registered calendars |
| 32 | 32 | */ |
| 33 | - private $calendars=[]; |
|
| 33 | + private $calendars = []; |
|
| 34 | 34 | |
| 35 | 35 | /** |
| 36 | 36 | * @var \Closure[] to call to load/register calendar providers |
| 37 | 37 | */ |
| 38 | - private $calendarLoaders=[]; |
|
| 38 | + private $calendarLoaders = []; |
|
| 39 | 39 | |
| 40 | 40 | /** |
| 41 | 41 | * This function is used to search and find objects within the user's calendars. |
@@ -50,12 +50,12 @@ discard block |
||
| 50 | 50 | * @return array an array of events/journals/todos which are arrays of arrays of key-value-pairs |
| 51 | 51 | * @since 13.0.0 |
| 52 | 52 | */ |
| 53 | - public function search($pattern, array $searchProperties=[], array $options=[], $limit=null, $offset=null) { |
|
| 53 | + public function search($pattern, array $searchProperties = [], array $options = [], $limit = null, $offset = null) { |
|
| 54 | 54 | $this->loadCalendars(); |
| 55 | 55 | $result = []; |
| 56 | - foreach($this->calendars as $calendar) { |
|
| 56 | + foreach ($this->calendars as $calendar) { |
|
| 57 | 57 | $r = $calendar->search($pattern, $searchProperties, $options, $limit, $offset); |
| 58 | - foreach($r as $o) { |
|
| 58 | + foreach ($r as $o) { |
|
| 59 | 59 | $o['calendar-key'] = $calendar->getKey(); |
| 60 | 60 | $result[] = $o; |
| 61 | 61 | } |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | * loads all calendars |
| 133 | 133 | */ |
| 134 | 134 | private function loadCalendars() { |
| 135 | - foreach($this->calendarLoaders as $callable) { |
|
| 135 | + foreach ($this->calendarLoaders as $callable) { |
|
| 136 | 136 | $callable($this); |
| 137 | 137 | } |
| 138 | 138 | $this->calendarLoaders = []; |
@@ -36,135 +36,135 @@ |
||
| 36 | 36 | */ |
| 37 | 37 | class SystemConfig { |
| 38 | 38 | |
| 39 | - /** @var array */ |
|
| 40 | - protected $sensitiveValues = [ |
|
| 41 | - 'instanceid' => true, |
|
| 42 | - 'datadirectory' => true, |
|
| 43 | - 'dbname' => true, |
|
| 44 | - 'dbhost' => true, |
|
| 45 | - 'dbpassword' => true, |
|
| 46 | - 'dbuser' => true, |
|
| 47 | - 'mail_from_address' => true, |
|
| 48 | - 'mail_domain' => true, |
|
| 49 | - 'mail_smtphost' => true, |
|
| 50 | - 'mail_smtpname' => true, |
|
| 51 | - 'mail_smtppassword' => true, |
|
| 52 | - 'passwordsalt' => true, |
|
| 53 | - 'secret' => true, |
|
| 54 | - 'updater.secret' => true, |
|
| 55 | - 'trusted_proxies' => true, |
|
| 56 | - 'proxyuserpwd' => true, |
|
| 57 | - 'log.condition' => [ |
|
| 58 | - 'shared_secret' => true, |
|
| 59 | - ], |
|
| 60 | - 'license-key' => true, |
|
| 61 | - 'redis' => [ |
|
| 62 | - 'host' => true, |
|
| 63 | - 'password' => true, |
|
| 64 | - ], |
|
| 65 | - 'objectstore' => [ |
|
| 66 | - 'arguments' => [ |
|
| 67 | - 'password' => true, |
|
| 68 | - 'options' => [ |
|
| 69 | - 'credentials' => [ |
|
| 70 | - 'key' => true, |
|
| 71 | - 'secret' => true, |
|
| 72 | - ] |
|
| 73 | - ] |
|
| 74 | - ], |
|
| 75 | - ], |
|
| 76 | - ]; |
|
| 77 | - |
|
| 78 | - /** @var Config */ |
|
| 79 | - private $config; |
|
| 80 | - |
|
| 81 | - public function __construct(Config $config) { |
|
| 82 | - $this->config = $config; |
|
| 83 | - } |
|
| 84 | - |
|
| 85 | - /** |
|
| 86 | - * Lists all available config keys |
|
| 87 | - * @return array an array of key names |
|
| 88 | - */ |
|
| 89 | - public function getKeys() { |
|
| 90 | - return $this->config->getKeys(); |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - /** |
|
| 94 | - * Sets a new system wide value |
|
| 95 | - * |
|
| 96 | - * @param string $key the key of the value, under which will be saved |
|
| 97 | - * @param mixed $value the value that should be stored |
|
| 98 | - */ |
|
| 99 | - public function setValue($key, $value) { |
|
| 100 | - $this->config->setValue($key, $value); |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - /** |
|
| 104 | - * Sets and deletes values and writes the config.php |
|
| 105 | - * |
|
| 106 | - * @param array $configs Associative array with `key => value` pairs |
|
| 107 | - * If value is null, the config key will be deleted |
|
| 108 | - */ |
|
| 109 | - public function setValues(array $configs) { |
|
| 110 | - $this->config->setValues($configs); |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - /** |
|
| 114 | - * Looks up a system wide defined value |
|
| 115 | - * |
|
| 116 | - * @param string $key the key of the value, under which it was saved |
|
| 117 | - * @param mixed $default the default value to be returned if the value isn't set |
|
| 118 | - * @return mixed the value or $default |
|
| 119 | - */ |
|
| 120 | - public function getValue($key, $default = '') { |
|
| 121 | - return $this->config->getValue($key, $default); |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - /** |
|
| 125 | - * Looks up a system wide defined value and filters out sensitive data |
|
| 126 | - * |
|
| 127 | - * @param string $key the key of the value, under which it was saved |
|
| 128 | - * @param mixed $default the default value to be returned if the value isn't set |
|
| 129 | - * @return mixed the value or $default |
|
| 130 | - */ |
|
| 131 | - public function getFilteredValue($key, $default = '') { |
|
| 132 | - $value = $this->getValue($key, $default); |
|
| 133 | - |
|
| 134 | - if (isset($this->sensitiveValues[$key])) { |
|
| 135 | - $value = $this->removeSensitiveValue($this->sensitiveValues[$key], $value); |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - return $value; |
|
| 139 | - } |
|
| 140 | - |
|
| 141 | - /** |
|
| 142 | - * Delete a system wide defined value |
|
| 143 | - * |
|
| 144 | - * @param string $key the key of the value, under which it was saved |
|
| 145 | - */ |
|
| 146 | - public function deleteValue($key) { |
|
| 147 | - $this->config->deleteKey($key); |
|
| 148 | - } |
|
| 149 | - |
|
| 150 | - /** |
|
| 151 | - * @param bool|array $keysToRemove |
|
| 152 | - * @param mixed $value |
|
| 153 | - * @return mixed |
|
| 154 | - */ |
|
| 155 | - protected function removeSensitiveValue($keysToRemove, $value) { |
|
| 156 | - if ($keysToRemove === true) { |
|
| 157 | - return IConfig::SENSITIVE_VALUE; |
|
| 158 | - } |
|
| 159 | - |
|
| 160 | - if (is_array($value)) { |
|
| 161 | - foreach ($keysToRemove as $keyToRemove => $valueToRemove) { |
|
| 162 | - if (isset($value[$keyToRemove])) { |
|
| 163 | - $value[$keyToRemove] = $this->removeSensitiveValue($valueToRemove, $value[$keyToRemove]); |
|
| 164 | - } |
|
| 165 | - } |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - return $value; |
|
| 169 | - } |
|
| 39 | + /** @var array */ |
|
| 40 | + protected $sensitiveValues = [ |
|
| 41 | + 'instanceid' => true, |
|
| 42 | + 'datadirectory' => true, |
|
| 43 | + 'dbname' => true, |
|
| 44 | + 'dbhost' => true, |
|
| 45 | + 'dbpassword' => true, |
|
| 46 | + 'dbuser' => true, |
|
| 47 | + 'mail_from_address' => true, |
|
| 48 | + 'mail_domain' => true, |
|
| 49 | + 'mail_smtphost' => true, |
|
| 50 | + 'mail_smtpname' => true, |
|
| 51 | + 'mail_smtppassword' => true, |
|
| 52 | + 'passwordsalt' => true, |
|
| 53 | + 'secret' => true, |
|
| 54 | + 'updater.secret' => true, |
|
| 55 | + 'trusted_proxies' => true, |
|
| 56 | + 'proxyuserpwd' => true, |
|
| 57 | + 'log.condition' => [ |
|
| 58 | + 'shared_secret' => true, |
|
| 59 | + ], |
|
| 60 | + 'license-key' => true, |
|
| 61 | + 'redis' => [ |
|
| 62 | + 'host' => true, |
|
| 63 | + 'password' => true, |
|
| 64 | + ], |
|
| 65 | + 'objectstore' => [ |
|
| 66 | + 'arguments' => [ |
|
| 67 | + 'password' => true, |
|
| 68 | + 'options' => [ |
|
| 69 | + 'credentials' => [ |
|
| 70 | + 'key' => true, |
|
| 71 | + 'secret' => true, |
|
| 72 | + ] |
|
| 73 | + ] |
|
| 74 | + ], |
|
| 75 | + ], |
|
| 76 | + ]; |
|
| 77 | + |
|
| 78 | + /** @var Config */ |
|
| 79 | + private $config; |
|
| 80 | + |
|
| 81 | + public function __construct(Config $config) { |
|
| 82 | + $this->config = $config; |
|
| 83 | + } |
|
| 84 | + |
|
| 85 | + /** |
|
| 86 | + * Lists all available config keys |
|
| 87 | + * @return array an array of key names |
|
| 88 | + */ |
|
| 89 | + public function getKeys() { |
|
| 90 | + return $this->config->getKeys(); |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + /** |
|
| 94 | + * Sets a new system wide value |
|
| 95 | + * |
|
| 96 | + * @param string $key the key of the value, under which will be saved |
|
| 97 | + * @param mixed $value the value that should be stored |
|
| 98 | + */ |
|
| 99 | + public function setValue($key, $value) { |
|
| 100 | + $this->config->setValue($key, $value); |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + /** |
|
| 104 | + * Sets and deletes values and writes the config.php |
|
| 105 | + * |
|
| 106 | + * @param array $configs Associative array with `key => value` pairs |
|
| 107 | + * If value is null, the config key will be deleted |
|
| 108 | + */ |
|
| 109 | + public function setValues(array $configs) { |
|
| 110 | + $this->config->setValues($configs); |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + /** |
|
| 114 | + * Looks up a system wide defined value |
|
| 115 | + * |
|
| 116 | + * @param string $key the key of the value, under which it was saved |
|
| 117 | + * @param mixed $default the default value to be returned if the value isn't set |
|
| 118 | + * @return mixed the value or $default |
|
| 119 | + */ |
|
| 120 | + public function getValue($key, $default = '') { |
|
| 121 | + return $this->config->getValue($key, $default); |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + /** |
|
| 125 | + * Looks up a system wide defined value and filters out sensitive data |
|
| 126 | + * |
|
| 127 | + * @param string $key the key of the value, under which it was saved |
|
| 128 | + * @param mixed $default the default value to be returned if the value isn't set |
|
| 129 | + * @return mixed the value or $default |
|
| 130 | + */ |
|
| 131 | + public function getFilteredValue($key, $default = '') { |
|
| 132 | + $value = $this->getValue($key, $default); |
|
| 133 | + |
|
| 134 | + if (isset($this->sensitiveValues[$key])) { |
|
| 135 | + $value = $this->removeSensitiveValue($this->sensitiveValues[$key], $value); |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + return $value; |
|
| 139 | + } |
|
| 140 | + |
|
| 141 | + /** |
|
| 142 | + * Delete a system wide defined value |
|
| 143 | + * |
|
| 144 | + * @param string $key the key of the value, under which it was saved |
|
| 145 | + */ |
|
| 146 | + public function deleteValue($key) { |
|
| 147 | + $this->config->deleteKey($key); |
|
| 148 | + } |
|
| 149 | + |
|
| 150 | + /** |
|
| 151 | + * @param bool|array $keysToRemove |
|
| 152 | + * @param mixed $value |
|
| 153 | + * @return mixed |
|
| 154 | + */ |
|
| 155 | + protected function removeSensitiveValue($keysToRemove, $value) { |
|
| 156 | + if ($keysToRemove === true) { |
|
| 157 | + return IConfig::SENSITIVE_VALUE; |
|
| 158 | + } |
|
| 159 | + |
|
| 160 | + if (is_array($value)) { |
|
| 161 | + foreach ($keysToRemove as $keyToRemove => $valueToRemove) { |
|
| 162 | + if (isset($value[$keyToRemove])) { |
|
| 163 | + $value[$keyToRemove] = $this->removeSensitiveValue($valueToRemove, $value[$keyToRemove]); |
|
| 164 | + } |
|
| 165 | + } |
|
| 166 | + } |
|
| 167 | + |
|
| 168 | + return $value; |
|
| 169 | + } |
|
| 170 | 170 | } |
@@ -28,92 +28,92 @@ |
||
| 28 | 28 | |
| 29 | 29 | class CalendarImpl implements ICalendar { |
| 30 | 30 | |
| 31 | - /** @var CalDavBackend */ |
|
| 32 | - private $backend; |
|
| 31 | + /** @var CalDavBackend */ |
|
| 32 | + private $backend; |
|
| 33 | 33 | |
| 34 | - /** @var Calendar */ |
|
| 35 | - private $calendar; |
|
| 34 | + /** @var Calendar */ |
|
| 35 | + private $calendar; |
|
| 36 | 36 | |
| 37 | - /** @var array */ |
|
| 38 | - private $calendarInfo; |
|
| 37 | + /** @var array */ |
|
| 38 | + private $calendarInfo; |
|
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * CalendarImpl constructor. |
|
| 42 | - * |
|
| 43 | - * @param Calendar $calendar |
|
| 44 | - * @param array $calendarInfo |
|
| 45 | - * @param CalDavBackend $backend |
|
| 46 | - */ |
|
| 47 | - public function __construct(Calendar $calendar, array $calendarInfo, |
|
| 48 | - CalDavBackend $backend) { |
|
| 49 | - $this->calendar = $calendar; |
|
| 50 | - $this->calendarInfo = $calendarInfo; |
|
| 51 | - $this->backend = $backend; |
|
| 52 | - } |
|
| 40 | + /** |
|
| 41 | + * CalendarImpl constructor. |
|
| 42 | + * |
|
| 43 | + * @param Calendar $calendar |
|
| 44 | + * @param array $calendarInfo |
|
| 45 | + * @param CalDavBackend $backend |
|
| 46 | + */ |
|
| 47 | + public function __construct(Calendar $calendar, array $calendarInfo, |
|
| 48 | + CalDavBackend $backend) { |
|
| 49 | + $this->calendar = $calendar; |
|
| 50 | + $this->calendarInfo = $calendarInfo; |
|
| 51 | + $this->backend = $backend; |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * @return string defining the technical unique key |
|
| 56 | - * @since 13.0.0 |
|
| 57 | - */ |
|
| 58 | - public function getKey() { |
|
| 59 | - return $this->calendarInfo['id']; |
|
| 60 | - } |
|
| 54 | + /** |
|
| 55 | + * @return string defining the technical unique key |
|
| 56 | + * @since 13.0.0 |
|
| 57 | + */ |
|
| 58 | + public function getKey() { |
|
| 59 | + return $this->calendarInfo['id']; |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - /** |
|
| 63 | - * In comparison to getKey() this function returns a human readable (maybe translated) name |
|
| 64 | - * @return null|string |
|
| 65 | - * @since 13.0.0 |
|
| 66 | - */ |
|
| 67 | - public function getDisplayName() { |
|
| 68 | - return $this->calendarInfo['{DAV:}displayname']; |
|
| 69 | - } |
|
| 62 | + /** |
|
| 63 | + * In comparison to getKey() this function returns a human readable (maybe translated) name |
|
| 64 | + * @return null|string |
|
| 65 | + * @since 13.0.0 |
|
| 66 | + */ |
|
| 67 | + public function getDisplayName() { |
|
| 68 | + return $this->calendarInfo['{DAV:}displayname']; |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | - /** |
|
| 72 | - * Calendar color |
|
| 73 | - * @return null|string |
|
| 74 | - * @since 13.0.0 |
|
| 75 | - */ |
|
| 76 | - public function getDisplayColor() { |
|
| 77 | - return $this->calendarInfo['{http://apple.com/ns/ical/}calendar-color']; |
|
| 78 | - } |
|
| 71 | + /** |
|
| 72 | + * Calendar color |
|
| 73 | + * @return null|string |
|
| 74 | + * @since 13.0.0 |
|
| 75 | + */ |
|
| 76 | + public function getDisplayColor() { |
|
| 77 | + return $this->calendarInfo['{http://apple.com/ns/ical/}calendar-color']; |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | - /** |
|
| 81 | - * @param string $pattern which should match within the $searchProperties |
|
| 82 | - * @param array $searchProperties defines the properties within the query pattern should match |
|
| 83 | - * @param array $options - optional parameters: |
|
| 84 | - * ['timerange' => ['start' => new DateTime(...), 'end' => new DateTime(...)]] |
|
| 85 | - * @param integer|null $limit - limit number of search results |
|
| 86 | - * @param integer|null $offset - offset for paging of search results |
|
| 87 | - * @return array an array of events/journals/todos which are arrays of key-value-pairs |
|
| 88 | - * @since 13.0.0 |
|
| 89 | - */ |
|
| 90 | - public function search($pattern, array $searchProperties=[], array $options=[], $limit=null, $offset=null) { |
|
| 91 | - return $this->backend->search($this->calendarInfo, $pattern, |
|
| 92 | - $searchProperties, $options, $limit, $offset); |
|
| 93 | - } |
|
| 80 | + /** |
|
| 81 | + * @param string $pattern which should match within the $searchProperties |
|
| 82 | + * @param array $searchProperties defines the properties within the query pattern should match |
|
| 83 | + * @param array $options - optional parameters: |
|
| 84 | + * ['timerange' => ['start' => new DateTime(...), 'end' => new DateTime(...)]] |
|
| 85 | + * @param integer|null $limit - limit number of search results |
|
| 86 | + * @param integer|null $offset - offset for paging of search results |
|
| 87 | + * @return array an array of events/journals/todos which are arrays of key-value-pairs |
|
| 88 | + * @since 13.0.0 |
|
| 89 | + */ |
|
| 90 | + public function search($pattern, array $searchProperties=[], array $options=[], $limit=null, $offset=null) { |
|
| 91 | + return $this->backend->search($this->calendarInfo, $pattern, |
|
| 92 | + $searchProperties, $options, $limit, $offset); |
|
| 93 | + } |
|
| 94 | 94 | |
| 95 | - /** |
|
| 96 | - * @return integer build up using \OCP\Constants |
|
| 97 | - * @since 13.0.0 |
|
| 98 | - */ |
|
| 99 | - public function getPermissions() { |
|
| 100 | - $permissions = $this->calendar->getACL(); |
|
| 101 | - $result = 0; |
|
| 102 | - foreach ($permissions as $permission) { |
|
| 103 | - switch($permission['privilege']) { |
|
| 104 | - case '{DAV:}read': |
|
| 105 | - $result |= Constants::PERMISSION_READ; |
|
| 106 | - break; |
|
| 107 | - case '{DAV:}write': |
|
| 108 | - $result |= Constants::PERMISSION_CREATE; |
|
| 109 | - $result |= Constants::PERMISSION_UPDATE; |
|
| 110 | - break; |
|
| 111 | - case '{DAV:}all': |
|
| 112 | - $result |= Constants::PERMISSION_ALL; |
|
| 113 | - break; |
|
| 114 | - } |
|
| 115 | - } |
|
| 95 | + /** |
|
| 96 | + * @return integer build up using \OCP\Constants |
|
| 97 | + * @since 13.0.0 |
|
| 98 | + */ |
|
| 99 | + public function getPermissions() { |
|
| 100 | + $permissions = $this->calendar->getACL(); |
|
| 101 | + $result = 0; |
|
| 102 | + foreach ($permissions as $permission) { |
|
| 103 | + switch($permission['privilege']) { |
|
| 104 | + case '{DAV:}read': |
|
| 105 | + $result |= Constants::PERMISSION_READ; |
|
| 106 | + break; |
|
| 107 | + case '{DAV:}write': |
|
| 108 | + $result |= Constants::PERMISSION_CREATE; |
|
| 109 | + $result |= Constants::PERMISSION_UPDATE; |
|
| 110 | + break; |
|
| 111 | + case '{DAV:}all': |
|
| 112 | + $result |= Constants::PERMISSION_ALL; |
|
| 113 | + break; |
|
| 114 | + } |
|
| 115 | + } |
|
| 116 | 116 | |
| 117 | - return $result; |
|
| 118 | - } |
|
| 117 | + return $result; |
|
| 118 | + } |
|
| 119 | 119 | } |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | * @return array an array of events/journals/todos which are arrays of key-value-pairs |
| 88 | 88 | * @since 13.0.0 |
| 89 | 89 | */ |
| 90 | - public function search($pattern, array $searchProperties=[], array $options=[], $limit=null, $offset=null) { |
|
| 90 | + public function search($pattern, array $searchProperties = [], array $options = [], $limit = null, $offset = null) { |
|
| 91 | 91 | return $this->backend->search($this->calendarInfo, $pattern, |
| 92 | 92 | $searchProperties, $options, $limit, $offset); |
| 93 | 93 | } |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | $permissions = $this->calendar->getACL(); |
| 101 | 101 | $result = 0; |
| 102 | 102 | foreach ($permissions as $permission) { |
| 103 | - switch($permission['privilege']) { |
|
| 103 | + switch ($permission['privilege']) { |
|
| 104 | 104 | case '{DAV:}read': |
| 105 | 105 | $result |= Constants::PERMISSION_READ; |
| 106 | 106 | break; |
@@ -36,482 +36,482 @@ |
||
| 36 | 36 | * This restricts access to a subfolder of the wrapped storage with the subfolder becoming the root folder new storage |
| 37 | 37 | */ |
| 38 | 38 | class Jail extends Wrapper { |
| 39 | - /** |
|
| 40 | - * @var string |
|
| 41 | - */ |
|
| 42 | - protected $rootPath; |
|
| 43 | - |
|
| 44 | - /** |
|
| 45 | - * @param array $arguments ['storage' => $storage, 'mask' => $root] |
|
| 46 | - * |
|
| 47 | - * $storage: The storage that will be wrapper |
|
| 48 | - * $root: The folder in the wrapped storage that will become the root folder of the wrapped storage |
|
| 49 | - */ |
|
| 50 | - public function __construct($arguments) { |
|
| 51 | - parent::__construct($arguments); |
|
| 52 | - $this->rootPath = $arguments['root']; |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - public function getUnjailedPath($path) { |
|
| 56 | - if ($path === '') { |
|
| 57 | - return $this->rootPath; |
|
| 58 | - } else { |
|
| 59 | - return $this->rootPath . '/' . $path; |
|
| 60 | - } |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - public function getJailedPath($path) { |
|
| 64 | - $root = rtrim($this->rootPath, '/') . '/'; |
|
| 65 | - |
|
| 66 | - if (strpos($path, $root) !== 0) { |
|
| 67 | - return null; |
|
| 68 | - } else { |
|
| 69 | - $path = substr($path, strlen($this->rootPath)); |
|
| 70 | - return trim($path, '/'); |
|
| 71 | - } |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - public function getId() { |
|
| 75 | - return parent::getId(); |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - /** |
|
| 79 | - * see http://php.net/manual/en/function.mkdir.php |
|
| 80 | - * |
|
| 81 | - * @param string $path |
|
| 82 | - * @return bool |
|
| 83 | - */ |
|
| 84 | - public function mkdir($path) { |
|
| 85 | - return $this->getWrapperStorage()->mkdir($this->getUnjailedPath($path)); |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - /** |
|
| 89 | - * see http://php.net/manual/en/function.rmdir.php |
|
| 90 | - * |
|
| 91 | - * @param string $path |
|
| 92 | - * @return bool |
|
| 93 | - */ |
|
| 94 | - public function rmdir($path) { |
|
| 95 | - return $this->getWrapperStorage()->rmdir($this->getUnjailedPath($path)); |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - /** |
|
| 99 | - * see http://php.net/manual/en/function.opendir.php |
|
| 100 | - * |
|
| 101 | - * @param string $path |
|
| 102 | - * @return resource |
|
| 103 | - */ |
|
| 104 | - public function opendir($path) { |
|
| 105 | - return $this->getWrapperStorage()->opendir($this->getUnjailedPath($path)); |
|
| 106 | - } |
|
| 107 | - |
|
| 108 | - /** |
|
| 109 | - * see http://php.net/manual/en/function.is_dir.php |
|
| 110 | - * |
|
| 111 | - * @param string $path |
|
| 112 | - * @return bool |
|
| 113 | - */ |
|
| 114 | - public function is_dir($path) { |
|
| 115 | - return $this->getWrapperStorage()->is_dir($this->getUnjailedPath($path)); |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - /** |
|
| 119 | - * see http://php.net/manual/en/function.is_file.php |
|
| 120 | - * |
|
| 121 | - * @param string $path |
|
| 122 | - * @return bool |
|
| 123 | - */ |
|
| 124 | - public function is_file($path) { |
|
| 125 | - return $this->getWrapperStorage()->is_file($this->getUnjailedPath($path)); |
|
| 126 | - } |
|
| 127 | - |
|
| 128 | - /** |
|
| 129 | - * see http://php.net/manual/en/function.stat.php |
|
| 130 | - * only the following keys are required in the result: size and mtime |
|
| 131 | - * |
|
| 132 | - * @param string $path |
|
| 133 | - * @return array |
|
| 134 | - */ |
|
| 135 | - public function stat($path) { |
|
| 136 | - return $this->getWrapperStorage()->stat($this->getUnjailedPath($path)); |
|
| 137 | - } |
|
| 138 | - |
|
| 139 | - /** |
|
| 140 | - * see http://php.net/manual/en/function.filetype.php |
|
| 141 | - * |
|
| 142 | - * @param string $path |
|
| 143 | - * @return bool |
|
| 144 | - */ |
|
| 145 | - public function filetype($path) { |
|
| 146 | - return $this->getWrapperStorage()->filetype($this->getUnjailedPath($path)); |
|
| 147 | - } |
|
| 148 | - |
|
| 149 | - /** |
|
| 150 | - * see http://php.net/manual/en/function.filesize.php |
|
| 151 | - * The result for filesize when called on a folder is required to be 0 |
|
| 152 | - * |
|
| 153 | - * @param string $path |
|
| 154 | - * @return int |
|
| 155 | - */ |
|
| 156 | - public function filesize($path) { |
|
| 157 | - return $this->getWrapperStorage()->filesize($this->getUnjailedPath($path)); |
|
| 158 | - } |
|
| 159 | - |
|
| 160 | - /** |
|
| 161 | - * check if a file can be created in $path |
|
| 162 | - * |
|
| 163 | - * @param string $path |
|
| 164 | - * @return bool |
|
| 165 | - */ |
|
| 166 | - public function isCreatable($path) { |
|
| 167 | - return $this->getWrapperStorage()->isCreatable($this->getUnjailedPath($path)); |
|
| 168 | - } |
|
| 169 | - |
|
| 170 | - /** |
|
| 171 | - * check if a file can be read |
|
| 172 | - * |
|
| 173 | - * @param string $path |
|
| 174 | - * @return bool |
|
| 175 | - */ |
|
| 176 | - public function isReadable($path) { |
|
| 177 | - return $this->getWrapperStorage()->isReadable($this->getUnjailedPath($path)); |
|
| 178 | - } |
|
| 179 | - |
|
| 180 | - /** |
|
| 181 | - * check if a file can be written to |
|
| 182 | - * |
|
| 183 | - * @param string $path |
|
| 184 | - * @return bool |
|
| 185 | - */ |
|
| 186 | - public function isUpdatable($path) { |
|
| 187 | - return $this->getWrapperStorage()->isUpdatable($this->getUnjailedPath($path)); |
|
| 188 | - } |
|
| 189 | - |
|
| 190 | - /** |
|
| 191 | - * check if a file can be deleted |
|
| 192 | - * |
|
| 193 | - * @param string $path |
|
| 194 | - * @return bool |
|
| 195 | - */ |
|
| 196 | - public function isDeletable($path) { |
|
| 197 | - return $this->getWrapperStorage()->isDeletable($this->getUnjailedPath($path)); |
|
| 198 | - } |
|
| 199 | - |
|
| 200 | - /** |
|
| 201 | - * check if a file can be shared |
|
| 202 | - * |
|
| 203 | - * @param string $path |
|
| 204 | - * @return bool |
|
| 205 | - */ |
|
| 206 | - public function isSharable($path) { |
|
| 207 | - return $this->getWrapperStorage()->isSharable($this->getUnjailedPath($path)); |
|
| 208 | - } |
|
| 209 | - |
|
| 210 | - /** |
|
| 211 | - * get the full permissions of a path. |
|
| 212 | - * Should return a combination of the PERMISSION_ constants defined in lib/public/constants.php |
|
| 213 | - * |
|
| 214 | - * @param string $path |
|
| 215 | - * @return int |
|
| 216 | - */ |
|
| 217 | - public function getPermissions($path) { |
|
| 218 | - return $this->getWrapperStorage()->getPermissions($this->getUnjailedPath($path)); |
|
| 219 | - } |
|
| 220 | - |
|
| 221 | - /** |
|
| 222 | - * see http://php.net/manual/en/function.file_exists.php |
|
| 223 | - * |
|
| 224 | - * @param string $path |
|
| 225 | - * @return bool |
|
| 226 | - */ |
|
| 227 | - public function file_exists($path) { |
|
| 228 | - return $this->getWrapperStorage()->file_exists($this->getUnjailedPath($path)); |
|
| 229 | - } |
|
| 230 | - |
|
| 231 | - /** |
|
| 232 | - * see http://php.net/manual/en/function.filemtime.php |
|
| 233 | - * |
|
| 234 | - * @param string $path |
|
| 235 | - * @return int |
|
| 236 | - */ |
|
| 237 | - public function filemtime($path) { |
|
| 238 | - return $this->getWrapperStorage()->filemtime($this->getUnjailedPath($path)); |
|
| 239 | - } |
|
| 240 | - |
|
| 241 | - /** |
|
| 242 | - * see http://php.net/manual/en/function.file_get_contents.php |
|
| 243 | - * |
|
| 244 | - * @param string $path |
|
| 245 | - * @return string |
|
| 246 | - */ |
|
| 247 | - public function file_get_contents($path) { |
|
| 248 | - return $this->getWrapperStorage()->file_get_contents($this->getUnjailedPath($path)); |
|
| 249 | - } |
|
| 250 | - |
|
| 251 | - /** |
|
| 252 | - * see http://php.net/manual/en/function.file_put_contents.php |
|
| 253 | - * |
|
| 254 | - * @param string $path |
|
| 255 | - * @param string $data |
|
| 256 | - * @return bool |
|
| 257 | - */ |
|
| 258 | - public function file_put_contents($path, $data) { |
|
| 259 | - return $this->getWrapperStorage()->file_put_contents($this->getUnjailedPath($path), $data); |
|
| 260 | - } |
|
| 261 | - |
|
| 262 | - /** |
|
| 263 | - * see http://php.net/manual/en/function.unlink.php |
|
| 264 | - * |
|
| 265 | - * @param string $path |
|
| 266 | - * @return bool |
|
| 267 | - */ |
|
| 268 | - public function unlink($path) { |
|
| 269 | - return $this->getWrapperStorage()->unlink($this->getUnjailedPath($path)); |
|
| 270 | - } |
|
| 271 | - |
|
| 272 | - /** |
|
| 273 | - * see http://php.net/manual/en/function.rename.php |
|
| 274 | - * |
|
| 275 | - * @param string $path1 |
|
| 276 | - * @param string $path2 |
|
| 277 | - * @return bool |
|
| 278 | - */ |
|
| 279 | - public function rename($path1, $path2) { |
|
| 280 | - return $this->getWrapperStorage()->rename($this->getUnjailedPath($path1), $this->getUnjailedPath($path2)); |
|
| 281 | - } |
|
| 282 | - |
|
| 283 | - /** |
|
| 284 | - * see http://php.net/manual/en/function.copy.php |
|
| 285 | - * |
|
| 286 | - * @param string $path1 |
|
| 287 | - * @param string $path2 |
|
| 288 | - * @return bool |
|
| 289 | - */ |
|
| 290 | - public function copy($path1, $path2) { |
|
| 291 | - return $this->getWrapperStorage()->copy($this->getUnjailedPath($path1), $this->getUnjailedPath($path2)); |
|
| 292 | - } |
|
| 293 | - |
|
| 294 | - /** |
|
| 295 | - * see http://php.net/manual/en/function.fopen.php |
|
| 296 | - * |
|
| 297 | - * @param string $path |
|
| 298 | - * @param string $mode |
|
| 299 | - * @return resource |
|
| 300 | - */ |
|
| 301 | - public function fopen($path, $mode) { |
|
| 302 | - return $this->getWrapperStorage()->fopen($this->getUnjailedPath($path), $mode); |
|
| 303 | - } |
|
| 304 | - |
|
| 305 | - /** |
|
| 306 | - * get the mimetype for a file or folder |
|
| 307 | - * The mimetype for a folder is required to be "httpd/unix-directory" |
|
| 308 | - * |
|
| 309 | - * @param string $path |
|
| 310 | - * @return string |
|
| 311 | - */ |
|
| 312 | - public function getMimeType($path) { |
|
| 313 | - return $this->getWrapperStorage()->getMimeType($this->getUnjailedPath($path)); |
|
| 314 | - } |
|
| 315 | - |
|
| 316 | - /** |
|
| 317 | - * see http://php.net/manual/en/function.hash.php |
|
| 318 | - * |
|
| 319 | - * @param string $type |
|
| 320 | - * @param string $path |
|
| 321 | - * @param bool $raw |
|
| 322 | - * @return string |
|
| 323 | - */ |
|
| 324 | - public function hash($type, $path, $raw = false) { |
|
| 325 | - return $this->getWrapperStorage()->hash($type, $this->getUnjailedPath($path), $raw); |
|
| 326 | - } |
|
| 327 | - |
|
| 328 | - /** |
|
| 329 | - * see http://php.net/manual/en/function.free_space.php |
|
| 330 | - * |
|
| 331 | - * @param string $path |
|
| 332 | - * @return int |
|
| 333 | - */ |
|
| 334 | - public function free_space($path) { |
|
| 335 | - return $this->getWrapperStorage()->free_space($this->getUnjailedPath($path)); |
|
| 336 | - } |
|
| 337 | - |
|
| 338 | - /** |
|
| 339 | - * search for occurrences of $query in file names |
|
| 340 | - * |
|
| 341 | - * @param string $query |
|
| 342 | - * @return array |
|
| 343 | - */ |
|
| 344 | - public function search($query) { |
|
| 345 | - return $this->getWrapperStorage()->search($query); |
|
| 346 | - } |
|
| 347 | - |
|
| 348 | - /** |
|
| 349 | - * see http://php.net/manual/en/function.touch.php |
|
| 350 | - * If the backend does not support the operation, false should be returned |
|
| 351 | - * |
|
| 352 | - * @param string $path |
|
| 353 | - * @param int $mtime |
|
| 354 | - * @return bool |
|
| 355 | - */ |
|
| 356 | - public function touch($path, $mtime = null) { |
|
| 357 | - return $this->getWrapperStorage()->touch($this->getUnjailedPath($path), $mtime); |
|
| 358 | - } |
|
| 359 | - |
|
| 360 | - /** |
|
| 361 | - * get the path to a local version of the file. |
|
| 362 | - * The local version of the file can be temporary and doesn't have to be persistent across requests |
|
| 363 | - * |
|
| 364 | - * @param string $path |
|
| 365 | - * @return string |
|
| 366 | - */ |
|
| 367 | - public function getLocalFile($path) { |
|
| 368 | - return $this->getWrapperStorage()->getLocalFile($this->getUnjailedPath($path)); |
|
| 369 | - } |
|
| 370 | - |
|
| 371 | - /** |
|
| 372 | - * check if a file or folder has been updated since $time |
|
| 373 | - * |
|
| 374 | - * @param string $path |
|
| 375 | - * @param int $time |
|
| 376 | - * @return bool |
|
| 377 | - * |
|
| 378 | - * hasUpdated for folders should return at least true if a file inside the folder is add, removed or renamed. |
|
| 379 | - * returning true for other changes in the folder is optional |
|
| 380 | - */ |
|
| 381 | - public function hasUpdated($path, $time) { |
|
| 382 | - return $this->getWrapperStorage()->hasUpdated($this->getUnjailedPath($path), $time); |
|
| 383 | - } |
|
| 384 | - |
|
| 385 | - /** |
|
| 386 | - * get a cache instance for the storage |
|
| 387 | - * |
|
| 388 | - * @param string $path |
|
| 389 | - * @param \OC\Files\Storage\Storage (optional) the storage to pass to the cache |
|
| 390 | - * @return \OC\Files\Cache\Cache |
|
| 391 | - */ |
|
| 392 | - public function getCache($path = '', $storage = null) { |
|
| 393 | - if (!$storage) { |
|
| 394 | - $storage = $this->getWrapperStorage(); |
|
| 395 | - } |
|
| 396 | - $sourceCache = $this->getWrapperStorage()->getCache($this->getUnjailedPath($path), $storage); |
|
| 397 | - return new CacheJail($sourceCache, $this->rootPath); |
|
| 398 | - } |
|
| 399 | - |
|
| 400 | - /** |
|
| 401 | - * get the user id of the owner of a file or folder |
|
| 402 | - * |
|
| 403 | - * @param string $path |
|
| 404 | - * @return string |
|
| 405 | - */ |
|
| 406 | - public function getOwner($path) { |
|
| 407 | - return $this->getWrapperStorage()->getOwner($this->getUnjailedPath($path)); |
|
| 408 | - } |
|
| 409 | - |
|
| 410 | - /** |
|
| 411 | - * get a watcher instance for the cache |
|
| 412 | - * |
|
| 413 | - * @param string $path |
|
| 414 | - * @param \OC\Files\Storage\Storage (optional) the storage to pass to the watcher |
|
| 415 | - * @return \OC\Files\Cache\Watcher |
|
| 416 | - */ |
|
| 417 | - public function getWatcher($path = '', $storage = null) { |
|
| 418 | - if (!$storage) { |
|
| 419 | - $storage = $this; |
|
| 420 | - } |
|
| 421 | - return $this->getWrapperStorage()->getWatcher($this->getUnjailedPath($path), $storage); |
|
| 422 | - } |
|
| 423 | - |
|
| 424 | - /** |
|
| 425 | - * get the ETag for a file or folder |
|
| 426 | - * |
|
| 427 | - * @param string $path |
|
| 428 | - * @return string |
|
| 429 | - */ |
|
| 430 | - public function getETag($path) { |
|
| 431 | - return $this->getWrapperStorage()->getETag($this->getUnjailedPath($path)); |
|
| 432 | - } |
|
| 433 | - |
|
| 434 | - /** |
|
| 435 | - * @param string $path |
|
| 436 | - * @return array |
|
| 437 | - */ |
|
| 438 | - public function getMetaData($path) { |
|
| 439 | - return $this->getWrapperStorage()->getMetaData($this->getUnjailedPath($path)); |
|
| 440 | - } |
|
| 441 | - |
|
| 442 | - /** |
|
| 443 | - * @param string $path |
|
| 444 | - * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE |
|
| 445 | - * @param \OCP\Lock\ILockingProvider $provider |
|
| 446 | - * @throws \OCP\Lock\LockedException |
|
| 447 | - */ |
|
| 448 | - public function acquireLock($path, $type, ILockingProvider $provider) { |
|
| 449 | - $this->getWrapperStorage()->acquireLock($this->getUnjailedPath($path), $type, $provider); |
|
| 450 | - } |
|
| 451 | - |
|
| 452 | - /** |
|
| 453 | - * @param string $path |
|
| 454 | - * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE |
|
| 455 | - * @param \OCP\Lock\ILockingProvider $provider |
|
| 456 | - */ |
|
| 457 | - public function releaseLock($path, $type, ILockingProvider $provider) { |
|
| 458 | - $this->getWrapperStorage()->releaseLock($this->getUnjailedPath($path), $type, $provider); |
|
| 459 | - } |
|
| 460 | - |
|
| 461 | - /** |
|
| 462 | - * @param string $path |
|
| 463 | - * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE |
|
| 464 | - * @param \OCP\Lock\ILockingProvider $provider |
|
| 465 | - */ |
|
| 466 | - public function changeLock($path, $type, ILockingProvider $provider) { |
|
| 467 | - $this->getWrapperStorage()->changeLock($this->getUnjailedPath($path), $type, $provider); |
|
| 468 | - } |
|
| 469 | - |
|
| 470 | - /** |
|
| 471 | - * Resolve the path for the source of the share |
|
| 472 | - * |
|
| 473 | - * @param string $path |
|
| 474 | - * @return array |
|
| 475 | - */ |
|
| 476 | - public function resolvePath($path) { |
|
| 477 | - return [$this->getWrapperStorage(), $this->getUnjailedPath($path)]; |
|
| 478 | - } |
|
| 479 | - |
|
| 480 | - /** |
|
| 481 | - * @param IStorage $sourceStorage |
|
| 482 | - * @param string $sourceInternalPath |
|
| 483 | - * @param string $targetInternalPath |
|
| 484 | - * @return bool |
|
| 485 | - */ |
|
| 486 | - public function copyFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath) { |
|
| 487 | - if ($sourceStorage === $this) { |
|
| 488 | - return $this->copy($sourceInternalPath, $targetInternalPath); |
|
| 489 | - } |
|
| 490 | - return $this->getWrapperStorage()->copyFromStorage($sourceStorage, $sourceInternalPath, $this->getUnjailedPath($targetInternalPath)); |
|
| 491 | - } |
|
| 492 | - |
|
| 493 | - /** |
|
| 494 | - * @param IStorage $sourceStorage |
|
| 495 | - * @param string $sourceInternalPath |
|
| 496 | - * @param string $targetInternalPath |
|
| 497 | - * @return bool |
|
| 498 | - */ |
|
| 499 | - public function moveFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath) { |
|
| 500 | - if ($sourceStorage === $this) { |
|
| 501 | - return $this->rename($sourceInternalPath, $targetInternalPath); |
|
| 502 | - } |
|
| 503 | - return $this->getWrapperStorage()->moveFromStorage($sourceStorage, $sourceInternalPath, $this->getUnjailedPath($targetInternalPath)); |
|
| 504 | - } |
|
| 505 | - |
|
| 506 | - public function getPropagator($storage = null) { |
|
| 507 | - if (isset($this->propagator)) { |
|
| 508 | - return $this->propagator; |
|
| 509 | - } |
|
| 510 | - |
|
| 511 | - if (!$storage) { |
|
| 512 | - $storage = $this; |
|
| 513 | - } |
|
| 514 | - $this->propagator = new JailPropagator($storage, \OC::$server->getDatabaseConnection()); |
|
| 515 | - return $this->propagator; |
|
| 516 | - } |
|
| 39 | + /** |
|
| 40 | + * @var string |
|
| 41 | + */ |
|
| 42 | + protected $rootPath; |
|
| 43 | + |
|
| 44 | + /** |
|
| 45 | + * @param array $arguments ['storage' => $storage, 'mask' => $root] |
|
| 46 | + * |
|
| 47 | + * $storage: The storage that will be wrapper |
|
| 48 | + * $root: The folder in the wrapped storage that will become the root folder of the wrapped storage |
|
| 49 | + */ |
|
| 50 | + public function __construct($arguments) { |
|
| 51 | + parent::__construct($arguments); |
|
| 52 | + $this->rootPath = $arguments['root']; |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + public function getUnjailedPath($path) { |
|
| 56 | + if ($path === '') { |
|
| 57 | + return $this->rootPath; |
|
| 58 | + } else { |
|
| 59 | + return $this->rootPath . '/' . $path; |
|
| 60 | + } |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + public function getJailedPath($path) { |
|
| 64 | + $root = rtrim($this->rootPath, '/') . '/'; |
|
| 65 | + |
|
| 66 | + if (strpos($path, $root) !== 0) { |
|
| 67 | + return null; |
|
| 68 | + } else { |
|
| 69 | + $path = substr($path, strlen($this->rootPath)); |
|
| 70 | + return trim($path, '/'); |
|
| 71 | + } |
|
| 72 | + } |
|
| 73 | + |
|
| 74 | + public function getId() { |
|
| 75 | + return parent::getId(); |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + /** |
|
| 79 | + * see http://php.net/manual/en/function.mkdir.php |
|
| 80 | + * |
|
| 81 | + * @param string $path |
|
| 82 | + * @return bool |
|
| 83 | + */ |
|
| 84 | + public function mkdir($path) { |
|
| 85 | + return $this->getWrapperStorage()->mkdir($this->getUnjailedPath($path)); |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + /** |
|
| 89 | + * see http://php.net/manual/en/function.rmdir.php |
|
| 90 | + * |
|
| 91 | + * @param string $path |
|
| 92 | + * @return bool |
|
| 93 | + */ |
|
| 94 | + public function rmdir($path) { |
|
| 95 | + return $this->getWrapperStorage()->rmdir($this->getUnjailedPath($path)); |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + /** |
|
| 99 | + * see http://php.net/manual/en/function.opendir.php |
|
| 100 | + * |
|
| 101 | + * @param string $path |
|
| 102 | + * @return resource |
|
| 103 | + */ |
|
| 104 | + public function opendir($path) { |
|
| 105 | + return $this->getWrapperStorage()->opendir($this->getUnjailedPath($path)); |
|
| 106 | + } |
|
| 107 | + |
|
| 108 | + /** |
|
| 109 | + * see http://php.net/manual/en/function.is_dir.php |
|
| 110 | + * |
|
| 111 | + * @param string $path |
|
| 112 | + * @return bool |
|
| 113 | + */ |
|
| 114 | + public function is_dir($path) { |
|
| 115 | + return $this->getWrapperStorage()->is_dir($this->getUnjailedPath($path)); |
|
| 116 | + } |
|
| 117 | + |
|
| 118 | + /** |
|
| 119 | + * see http://php.net/manual/en/function.is_file.php |
|
| 120 | + * |
|
| 121 | + * @param string $path |
|
| 122 | + * @return bool |
|
| 123 | + */ |
|
| 124 | + public function is_file($path) { |
|
| 125 | + return $this->getWrapperStorage()->is_file($this->getUnjailedPath($path)); |
|
| 126 | + } |
|
| 127 | + |
|
| 128 | + /** |
|
| 129 | + * see http://php.net/manual/en/function.stat.php |
|
| 130 | + * only the following keys are required in the result: size and mtime |
|
| 131 | + * |
|
| 132 | + * @param string $path |
|
| 133 | + * @return array |
|
| 134 | + */ |
|
| 135 | + public function stat($path) { |
|
| 136 | + return $this->getWrapperStorage()->stat($this->getUnjailedPath($path)); |
|
| 137 | + } |
|
| 138 | + |
|
| 139 | + /** |
|
| 140 | + * see http://php.net/manual/en/function.filetype.php |
|
| 141 | + * |
|
| 142 | + * @param string $path |
|
| 143 | + * @return bool |
|
| 144 | + */ |
|
| 145 | + public function filetype($path) { |
|
| 146 | + return $this->getWrapperStorage()->filetype($this->getUnjailedPath($path)); |
|
| 147 | + } |
|
| 148 | + |
|
| 149 | + /** |
|
| 150 | + * see http://php.net/manual/en/function.filesize.php |
|
| 151 | + * The result for filesize when called on a folder is required to be 0 |
|
| 152 | + * |
|
| 153 | + * @param string $path |
|
| 154 | + * @return int |
|
| 155 | + */ |
|
| 156 | + public function filesize($path) { |
|
| 157 | + return $this->getWrapperStorage()->filesize($this->getUnjailedPath($path)); |
|
| 158 | + } |
|
| 159 | + |
|
| 160 | + /** |
|
| 161 | + * check if a file can be created in $path |
|
| 162 | + * |
|
| 163 | + * @param string $path |
|
| 164 | + * @return bool |
|
| 165 | + */ |
|
| 166 | + public function isCreatable($path) { |
|
| 167 | + return $this->getWrapperStorage()->isCreatable($this->getUnjailedPath($path)); |
|
| 168 | + } |
|
| 169 | + |
|
| 170 | + /** |
|
| 171 | + * check if a file can be read |
|
| 172 | + * |
|
| 173 | + * @param string $path |
|
| 174 | + * @return bool |
|
| 175 | + */ |
|
| 176 | + public function isReadable($path) { |
|
| 177 | + return $this->getWrapperStorage()->isReadable($this->getUnjailedPath($path)); |
|
| 178 | + } |
|
| 179 | + |
|
| 180 | + /** |
|
| 181 | + * check if a file can be written to |
|
| 182 | + * |
|
| 183 | + * @param string $path |
|
| 184 | + * @return bool |
|
| 185 | + */ |
|
| 186 | + public function isUpdatable($path) { |
|
| 187 | + return $this->getWrapperStorage()->isUpdatable($this->getUnjailedPath($path)); |
|
| 188 | + } |
|
| 189 | + |
|
| 190 | + /** |
|
| 191 | + * check if a file can be deleted |
|
| 192 | + * |
|
| 193 | + * @param string $path |
|
| 194 | + * @return bool |
|
| 195 | + */ |
|
| 196 | + public function isDeletable($path) { |
|
| 197 | + return $this->getWrapperStorage()->isDeletable($this->getUnjailedPath($path)); |
|
| 198 | + } |
|
| 199 | + |
|
| 200 | + /** |
|
| 201 | + * check if a file can be shared |
|
| 202 | + * |
|
| 203 | + * @param string $path |
|
| 204 | + * @return bool |
|
| 205 | + */ |
|
| 206 | + public function isSharable($path) { |
|
| 207 | + return $this->getWrapperStorage()->isSharable($this->getUnjailedPath($path)); |
|
| 208 | + } |
|
| 209 | + |
|
| 210 | + /** |
|
| 211 | + * get the full permissions of a path. |
|
| 212 | + * Should return a combination of the PERMISSION_ constants defined in lib/public/constants.php |
|
| 213 | + * |
|
| 214 | + * @param string $path |
|
| 215 | + * @return int |
|
| 216 | + */ |
|
| 217 | + public function getPermissions($path) { |
|
| 218 | + return $this->getWrapperStorage()->getPermissions($this->getUnjailedPath($path)); |
|
| 219 | + } |
|
| 220 | + |
|
| 221 | + /** |
|
| 222 | + * see http://php.net/manual/en/function.file_exists.php |
|
| 223 | + * |
|
| 224 | + * @param string $path |
|
| 225 | + * @return bool |
|
| 226 | + */ |
|
| 227 | + public function file_exists($path) { |
|
| 228 | + return $this->getWrapperStorage()->file_exists($this->getUnjailedPath($path)); |
|
| 229 | + } |
|
| 230 | + |
|
| 231 | + /** |
|
| 232 | + * see http://php.net/manual/en/function.filemtime.php |
|
| 233 | + * |
|
| 234 | + * @param string $path |
|
| 235 | + * @return int |
|
| 236 | + */ |
|
| 237 | + public function filemtime($path) { |
|
| 238 | + return $this->getWrapperStorage()->filemtime($this->getUnjailedPath($path)); |
|
| 239 | + } |
|
| 240 | + |
|
| 241 | + /** |
|
| 242 | + * see http://php.net/manual/en/function.file_get_contents.php |
|
| 243 | + * |
|
| 244 | + * @param string $path |
|
| 245 | + * @return string |
|
| 246 | + */ |
|
| 247 | + public function file_get_contents($path) { |
|
| 248 | + return $this->getWrapperStorage()->file_get_contents($this->getUnjailedPath($path)); |
|
| 249 | + } |
|
| 250 | + |
|
| 251 | + /** |
|
| 252 | + * see http://php.net/manual/en/function.file_put_contents.php |
|
| 253 | + * |
|
| 254 | + * @param string $path |
|
| 255 | + * @param string $data |
|
| 256 | + * @return bool |
|
| 257 | + */ |
|
| 258 | + public function file_put_contents($path, $data) { |
|
| 259 | + return $this->getWrapperStorage()->file_put_contents($this->getUnjailedPath($path), $data); |
|
| 260 | + } |
|
| 261 | + |
|
| 262 | + /** |
|
| 263 | + * see http://php.net/manual/en/function.unlink.php |
|
| 264 | + * |
|
| 265 | + * @param string $path |
|
| 266 | + * @return bool |
|
| 267 | + */ |
|
| 268 | + public function unlink($path) { |
|
| 269 | + return $this->getWrapperStorage()->unlink($this->getUnjailedPath($path)); |
|
| 270 | + } |
|
| 271 | + |
|
| 272 | + /** |
|
| 273 | + * see http://php.net/manual/en/function.rename.php |
|
| 274 | + * |
|
| 275 | + * @param string $path1 |
|
| 276 | + * @param string $path2 |
|
| 277 | + * @return bool |
|
| 278 | + */ |
|
| 279 | + public function rename($path1, $path2) { |
|
| 280 | + return $this->getWrapperStorage()->rename($this->getUnjailedPath($path1), $this->getUnjailedPath($path2)); |
|
| 281 | + } |
|
| 282 | + |
|
| 283 | + /** |
|
| 284 | + * see http://php.net/manual/en/function.copy.php |
|
| 285 | + * |
|
| 286 | + * @param string $path1 |
|
| 287 | + * @param string $path2 |
|
| 288 | + * @return bool |
|
| 289 | + */ |
|
| 290 | + public function copy($path1, $path2) { |
|
| 291 | + return $this->getWrapperStorage()->copy($this->getUnjailedPath($path1), $this->getUnjailedPath($path2)); |
|
| 292 | + } |
|
| 293 | + |
|
| 294 | + /** |
|
| 295 | + * see http://php.net/manual/en/function.fopen.php |
|
| 296 | + * |
|
| 297 | + * @param string $path |
|
| 298 | + * @param string $mode |
|
| 299 | + * @return resource |
|
| 300 | + */ |
|
| 301 | + public function fopen($path, $mode) { |
|
| 302 | + return $this->getWrapperStorage()->fopen($this->getUnjailedPath($path), $mode); |
|
| 303 | + } |
|
| 304 | + |
|
| 305 | + /** |
|
| 306 | + * get the mimetype for a file or folder |
|
| 307 | + * The mimetype for a folder is required to be "httpd/unix-directory" |
|
| 308 | + * |
|
| 309 | + * @param string $path |
|
| 310 | + * @return string |
|
| 311 | + */ |
|
| 312 | + public function getMimeType($path) { |
|
| 313 | + return $this->getWrapperStorage()->getMimeType($this->getUnjailedPath($path)); |
|
| 314 | + } |
|
| 315 | + |
|
| 316 | + /** |
|
| 317 | + * see http://php.net/manual/en/function.hash.php |
|
| 318 | + * |
|
| 319 | + * @param string $type |
|
| 320 | + * @param string $path |
|
| 321 | + * @param bool $raw |
|
| 322 | + * @return string |
|
| 323 | + */ |
|
| 324 | + public function hash($type, $path, $raw = false) { |
|
| 325 | + return $this->getWrapperStorage()->hash($type, $this->getUnjailedPath($path), $raw); |
|
| 326 | + } |
|
| 327 | + |
|
| 328 | + /** |
|
| 329 | + * see http://php.net/manual/en/function.free_space.php |
|
| 330 | + * |
|
| 331 | + * @param string $path |
|
| 332 | + * @return int |
|
| 333 | + */ |
|
| 334 | + public function free_space($path) { |
|
| 335 | + return $this->getWrapperStorage()->free_space($this->getUnjailedPath($path)); |
|
| 336 | + } |
|
| 337 | + |
|
| 338 | + /** |
|
| 339 | + * search for occurrences of $query in file names |
|
| 340 | + * |
|
| 341 | + * @param string $query |
|
| 342 | + * @return array |
|
| 343 | + */ |
|
| 344 | + public function search($query) { |
|
| 345 | + return $this->getWrapperStorage()->search($query); |
|
| 346 | + } |
|
| 347 | + |
|
| 348 | + /** |
|
| 349 | + * see http://php.net/manual/en/function.touch.php |
|
| 350 | + * If the backend does not support the operation, false should be returned |
|
| 351 | + * |
|
| 352 | + * @param string $path |
|
| 353 | + * @param int $mtime |
|
| 354 | + * @return bool |
|
| 355 | + */ |
|
| 356 | + public function touch($path, $mtime = null) { |
|
| 357 | + return $this->getWrapperStorage()->touch($this->getUnjailedPath($path), $mtime); |
|
| 358 | + } |
|
| 359 | + |
|
| 360 | + /** |
|
| 361 | + * get the path to a local version of the file. |
|
| 362 | + * The local version of the file can be temporary and doesn't have to be persistent across requests |
|
| 363 | + * |
|
| 364 | + * @param string $path |
|
| 365 | + * @return string |
|
| 366 | + */ |
|
| 367 | + public function getLocalFile($path) { |
|
| 368 | + return $this->getWrapperStorage()->getLocalFile($this->getUnjailedPath($path)); |
|
| 369 | + } |
|
| 370 | + |
|
| 371 | + /** |
|
| 372 | + * check if a file or folder has been updated since $time |
|
| 373 | + * |
|
| 374 | + * @param string $path |
|
| 375 | + * @param int $time |
|
| 376 | + * @return bool |
|
| 377 | + * |
|
| 378 | + * hasUpdated for folders should return at least true if a file inside the folder is add, removed or renamed. |
|
| 379 | + * returning true for other changes in the folder is optional |
|
| 380 | + */ |
|
| 381 | + public function hasUpdated($path, $time) { |
|
| 382 | + return $this->getWrapperStorage()->hasUpdated($this->getUnjailedPath($path), $time); |
|
| 383 | + } |
|
| 384 | + |
|
| 385 | + /** |
|
| 386 | + * get a cache instance for the storage |
|
| 387 | + * |
|
| 388 | + * @param string $path |
|
| 389 | + * @param \OC\Files\Storage\Storage (optional) the storage to pass to the cache |
|
| 390 | + * @return \OC\Files\Cache\Cache |
|
| 391 | + */ |
|
| 392 | + public function getCache($path = '', $storage = null) { |
|
| 393 | + if (!$storage) { |
|
| 394 | + $storage = $this->getWrapperStorage(); |
|
| 395 | + } |
|
| 396 | + $sourceCache = $this->getWrapperStorage()->getCache($this->getUnjailedPath($path), $storage); |
|
| 397 | + return new CacheJail($sourceCache, $this->rootPath); |
|
| 398 | + } |
|
| 399 | + |
|
| 400 | + /** |
|
| 401 | + * get the user id of the owner of a file or folder |
|
| 402 | + * |
|
| 403 | + * @param string $path |
|
| 404 | + * @return string |
|
| 405 | + */ |
|
| 406 | + public function getOwner($path) { |
|
| 407 | + return $this->getWrapperStorage()->getOwner($this->getUnjailedPath($path)); |
|
| 408 | + } |
|
| 409 | + |
|
| 410 | + /** |
|
| 411 | + * get a watcher instance for the cache |
|
| 412 | + * |
|
| 413 | + * @param string $path |
|
| 414 | + * @param \OC\Files\Storage\Storage (optional) the storage to pass to the watcher |
|
| 415 | + * @return \OC\Files\Cache\Watcher |
|
| 416 | + */ |
|
| 417 | + public function getWatcher($path = '', $storage = null) { |
|
| 418 | + if (!$storage) { |
|
| 419 | + $storage = $this; |
|
| 420 | + } |
|
| 421 | + return $this->getWrapperStorage()->getWatcher($this->getUnjailedPath($path), $storage); |
|
| 422 | + } |
|
| 423 | + |
|
| 424 | + /** |
|
| 425 | + * get the ETag for a file or folder |
|
| 426 | + * |
|
| 427 | + * @param string $path |
|
| 428 | + * @return string |
|
| 429 | + */ |
|
| 430 | + public function getETag($path) { |
|
| 431 | + return $this->getWrapperStorage()->getETag($this->getUnjailedPath($path)); |
|
| 432 | + } |
|
| 433 | + |
|
| 434 | + /** |
|
| 435 | + * @param string $path |
|
| 436 | + * @return array |
|
| 437 | + */ |
|
| 438 | + public function getMetaData($path) { |
|
| 439 | + return $this->getWrapperStorage()->getMetaData($this->getUnjailedPath($path)); |
|
| 440 | + } |
|
| 441 | + |
|
| 442 | + /** |
|
| 443 | + * @param string $path |
|
| 444 | + * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE |
|
| 445 | + * @param \OCP\Lock\ILockingProvider $provider |
|
| 446 | + * @throws \OCP\Lock\LockedException |
|
| 447 | + */ |
|
| 448 | + public function acquireLock($path, $type, ILockingProvider $provider) { |
|
| 449 | + $this->getWrapperStorage()->acquireLock($this->getUnjailedPath($path), $type, $provider); |
|
| 450 | + } |
|
| 451 | + |
|
| 452 | + /** |
|
| 453 | + * @param string $path |
|
| 454 | + * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE |
|
| 455 | + * @param \OCP\Lock\ILockingProvider $provider |
|
| 456 | + */ |
|
| 457 | + public function releaseLock($path, $type, ILockingProvider $provider) { |
|
| 458 | + $this->getWrapperStorage()->releaseLock($this->getUnjailedPath($path), $type, $provider); |
|
| 459 | + } |
|
| 460 | + |
|
| 461 | + /** |
|
| 462 | + * @param string $path |
|
| 463 | + * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE |
|
| 464 | + * @param \OCP\Lock\ILockingProvider $provider |
|
| 465 | + */ |
|
| 466 | + public function changeLock($path, $type, ILockingProvider $provider) { |
|
| 467 | + $this->getWrapperStorage()->changeLock($this->getUnjailedPath($path), $type, $provider); |
|
| 468 | + } |
|
| 469 | + |
|
| 470 | + /** |
|
| 471 | + * Resolve the path for the source of the share |
|
| 472 | + * |
|
| 473 | + * @param string $path |
|
| 474 | + * @return array |
|
| 475 | + */ |
|
| 476 | + public function resolvePath($path) { |
|
| 477 | + return [$this->getWrapperStorage(), $this->getUnjailedPath($path)]; |
|
| 478 | + } |
|
| 479 | + |
|
| 480 | + /** |
|
| 481 | + * @param IStorage $sourceStorage |
|
| 482 | + * @param string $sourceInternalPath |
|
| 483 | + * @param string $targetInternalPath |
|
| 484 | + * @return bool |
|
| 485 | + */ |
|
| 486 | + public function copyFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath) { |
|
| 487 | + if ($sourceStorage === $this) { |
|
| 488 | + return $this->copy($sourceInternalPath, $targetInternalPath); |
|
| 489 | + } |
|
| 490 | + return $this->getWrapperStorage()->copyFromStorage($sourceStorage, $sourceInternalPath, $this->getUnjailedPath($targetInternalPath)); |
|
| 491 | + } |
|
| 492 | + |
|
| 493 | + /** |
|
| 494 | + * @param IStorage $sourceStorage |
|
| 495 | + * @param string $sourceInternalPath |
|
| 496 | + * @param string $targetInternalPath |
|
| 497 | + * @return bool |
|
| 498 | + */ |
|
| 499 | + public function moveFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath) { |
|
| 500 | + if ($sourceStorage === $this) { |
|
| 501 | + return $this->rename($sourceInternalPath, $targetInternalPath); |
|
| 502 | + } |
|
| 503 | + return $this->getWrapperStorage()->moveFromStorage($sourceStorage, $sourceInternalPath, $this->getUnjailedPath($targetInternalPath)); |
|
| 504 | + } |
|
| 505 | + |
|
| 506 | + public function getPropagator($storage = null) { |
|
| 507 | + if (isset($this->propagator)) { |
|
| 508 | + return $this->propagator; |
|
| 509 | + } |
|
| 510 | + |
|
| 511 | + if (!$storage) { |
|
| 512 | + $storage = $this; |
|
| 513 | + } |
|
| 514 | + $this->propagator = new JailPropagator($storage, \OC::$server->getDatabaseConnection()); |
|
| 515 | + return $this->propagator; |
|
| 516 | + } |
|
| 517 | 517 | } |
@@ -56,12 +56,12 @@ |
||
| 56 | 56 | if ($path === '') { |
| 57 | 57 | return $this->rootPath; |
| 58 | 58 | } else { |
| 59 | - return $this->rootPath . '/' . $path; |
|
| 59 | + return $this->rootPath.'/'.$path; |
|
| 60 | 60 | } |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | public function getJailedPath($path) { |
| 64 | - $root = rtrim($this->rootPath, '/') . '/'; |
|
| 64 | + $root = rtrim($this->rootPath, '/').'/'; |
|
| 65 | 65 | |
| 66 | 66 | if (strpos($path, $root) !== 0) { |
| 67 | 67 | return null; |
@@ -30,49 +30,49 @@ |
||
| 30 | 30 | |
| 31 | 31 | class PublicCalendarRoot extends Collection { |
| 32 | 32 | |
| 33 | - /** @var CalDavBackend */ |
|
| 34 | - protected $caldavBackend; |
|
| 33 | + /** @var CalDavBackend */ |
|
| 34 | + protected $caldavBackend; |
|
| 35 | 35 | |
| 36 | - /** @var \OCP\IL10N */ |
|
| 37 | - protected $l10n; |
|
| 36 | + /** @var \OCP\IL10N */ |
|
| 37 | + protected $l10n; |
|
| 38 | 38 | |
| 39 | - /** @var \OCP\IConfig */ |
|
| 40 | - protected $config; |
|
| 39 | + /** @var \OCP\IConfig */ |
|
| 40 | + protected $config; |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * PublicCalendarRoot constructor. |
|
| 44 | - * |
|
| 45 | - * @param CalDavBackend $caldavBackend |
|
| 46 | - * @param IL10N $l10n |
|
| 47 | - * @param IConfig $config |
|
| 48 | - */ |
|
| 49 | - function __construct(CalDavBackend $caldavBackend, IL10N $l10n, |
|
| 50 | - IConfig $config) { |
|
| 51 | - $this->caldavBackend = $caldavBackend; |
|
| 52 | - $this->l10n = $l10n; |
|
| 53 | - $this->config = $config; |
|
| 42 | + /** |
|
| 43 | + * PublicCalendarRoot constructor. |
|
| 44 | + * |
|
| 45 | + * @param CalDavBackend $caldavBackend |
|
| 46 | + * @param IL10N $l10n |
|
| 47 | + * @param IConfig $config |
|
| 48 | + */ |
|
| 49 | + function __construct(CalDavBackend $caldavBackend, IL10N $l10n, |
|
| 50 | + IConfig $config) { |
|
| 51 | + $this->caldavBackend = $caldavBackend; |
|
| 52 | + $this->l10n = $l10n; |
|
| 53 | + $this->config = $config; |
|
| 54 | 54 | |
| 55 | - } |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * @inheritdoc |
|
| 59 | - */ |
|
| 60 | - function getName() { |
|
| 61 | - return 'public-calendars'; |
|
| 62 | - } |
|
| 57 | + /** |
|
| 58 | + * @inheritdoc |
|
| 59 | + */ |
|
| 60 | + function getName() { |
|
| 61 | + return 'public-calendars'; |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * @inheritdoc |
|
| 66 | - */ |
|
| 67 | - function getChild($name) { |
|
| 68 | - $calendar = $this->caldavBackend->getPublicCalendar($name); |
|
| 69 | - return new PublicCalendar($this->caldavBackend, $calendar, $this->l10n, $this->config); |
|
| 70 | - } |
|
| 64 | + /** |
|
| 65 | + * @inheritdoc |
|
| 66 | + */ |
|
| 67 | + function getChild($name) { |
|
| 68 | + $calendar = $this->caldavBackend->getPublicCalendar($name); |
|
| 69 | + return new PublicCalendar($this->caldavBackend, $calendar, $this->l10n, $this->config); |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | - /** |
|
| 73 | - * @inheritdoc |
|
| 74 | - */ |
|
| 75 | - function getChildren() { |
|
| 76 | - return []; |
|
| 77 | - } |
|
| 72 | + /** |
|
| 73 | + * @inheritdoc |
|
| 74 | + */ |
|
| 75 | + function getChildren() { |
|
| 76 | + return []; |
|
| 77 | + } |
|
| 78 | 78 | } |