diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/l10n/cs_CZ.php | 1 | ||||
-rw-r--r-- | lib/private/appframework/routing/routeconfig.php | 14 | ||||
-rw-r--r-- | lib/private/files/view.php | 3 | ||||
-rw-r--r-- | lib/private/group/metadata.php | 86 | ||||
-rw-r--r-- | lib/private/installer.php | 13 | ||||
-rw-r--r-- | lib/private/log.php | 2 | ||||
-rw-r--r-- | lib/private/share/share.php | 2 | ||||
-rw-r--r-- | lib/private/user/manager.php | 3 | ||||
-rw-r--r-- | lib/private/user/session.php | 3 | ||||
-rw-r--r-- | lib/private/user/user.php | 3 | ||||
-rw-r--r-- | lib/public/iservercontainer.php | 7 | ||||
-rw-r--r-- | lib/public/iuser.php | 105 | ||||
-rw-r--r-- | lib/public/iusermanager.php | 105 | ||||
-rw-r--r-- | lib/public/iusersession.php | 13 |
14 files changed, 283 insertions, 77 deletions
diff --git a/lib/l10n/cs_CZ.php b/lib/l10n/cs_CZ.php index 48340a2f4a7..42b4ebba233 100644 --- a/lib/l10n/cs_CZ.php +++ b/lib/l10n/cs_CZ.php @@ -67,6 +67,7 @@ $TRANSLATIONS = array( "Share type %s is not valid for %s" => "Sdílení typu %s není korektní pro %s", "Setting permissions for %s failed, because the permissions exceed permissions granted to %s" => "Nastavení oprávnění pro %s selhalo, protože jsou k tomu nutná vyšší oprávnění, než jaká byla povolena pro %s", "Setting permissions for %s failed, because the item was not found" => "Nastavení práv pro %s selhalo, protože položka nebyla nalezena", +"Sharing backend %s must implement the interface OCP\\Share_Backend" => "Podpůrná vrstva pro sdílení %s musí obsahovat rozhraní OCP\\Share_Backend", "Sharing backend %s not found" => "Podpůrná vrstva sdílení %s nenalezena", "Sharing backend for %s not found" => "Podpůrná vrstva sdílení pro %s nenalezena", "Sharing %s failed, because the user %s is the original sharer" => "Sdílení položky %s selhalo, protože byla sdílena uživatelem %s jako první.", diff --git a/lib/private/appframework/routing/routeconfig.php b/lib/private/appframework/routing/routeconfig.php index 91ea7778d08..5b4d411a355 100644 --- a/lib/private/appframework/routing/routeconfig.php +++ b/lib/private/appframework/routing/routeconfig.php @@ -88,7 +88,7 @@ class RouteConfig { ->method($verb) ->action($handler); - // optionally register requirements for route. This is used to + // optionally register requirements for route. This is used to // tell the route parser how url parameters should be matched if(array_key_exists('requirements', $simpleRoute)) { $router->requirements($simpleRoute['requirements']); @@ -122,14 +122,13 @@ class RouteConfig { foreach ($resources as $resource => $config) { // the url parameter used as id to the resource - $resourceId = $this->buildResourceId($resource); foreach($actions as $action) { $url = $config['url']; $method = $action['name']; $verb = isset($action['verb']) ? strtoupper($action['verb']) : 'GET'; $collectionAction = isset($action['on-collection']) ? $action['on-collection'] : false; if (!$collectionAction) { - $url = $url . '/' . $resourceId; + $url = $url . '/{id}'; } if (isset($action['url-postfix'])) { $url = $url . '/' . $action['url-postfix']; @@ -169,15 +168,6 @@ class RouteConfig { } /** - * Generates the id used in the url part o the route url - * @param string $resource - * @return string - */ - private function buildResourceId($resource) { - return '{'.$this->underScoreToCamelCase(rtrim($resource, 's')).'Id}'; - } - - /** * Underscored strings are converted to camel case strings * @param string $str * @return string diff --git a/lib/private/files/view.php b/lib/private/files/view.php index 2af693d5a64..e08cb20f73d 100644 --- a/lib/private/files/view.php +++ b/lib/private/files/view.php @@ -1103,8 +1103,9 @@ class View { foreach ($results as $result) { if (substr($mountPoint . $result['path'], 0, $rootLength + 1) === $this->fakeRoot . '/') { $internalPath = $result['path']; + $path = $mountPoint . $result['path']; $result['path'] = substr($mountPoint . $result['path'], $rootLength); - $files[] = new FileInfo($mountPoint . $result['path'], $storage, $internalPath, $result); + $files[] = new FileInfo($path, $storage, $internalPath, $result); } } diff --git a/lib/private/group/metadata.php b/lib/private/group/metadata.php index 1883ba727e0..57abbe20c64 100644 --- a/lib/private/group/metadata.php +++ b/lib/private/group/metadata.php @@ -24,9 +24,9 @@ class MetaData { protected $isAdmin; /** - * @var string[] $groups + * @var array $metaData */ - protected $groups = array(); + protected $metaData = array(); /** * @var \OC\Group\Manager $groupManager @@ -39,14 +39,9 @@ class MetaData { protected $sorting = false; /** - * @var string $lastSearch - */ - protected $lastSearch; - - /** - * @param string the uid of the current user - * @param bool whether the current users is an admin - * @param \OC\Group\Manager + * @param string $user the uid of the current user + * @param bool $isAdmin whether the current users is an admin + * @param \OC\Group\Manager $groupManager */ public function __construct( $user, @@ -63,14 +58,15 @@ class MetaData { * the array is structured as follows: * [0] array containing meta data about admin groups * [1] array containing meta data about unprivileged groups - * @param string only effective when instance was created with isAdmin being - * true + * @param string $groupSearch only effective when instance was created with + * isAdmin being true + * @param string $userSearch the pattern users are search for * @return array */ - public function get($search = '') { - if($this->lastSearch !== $search) { - $this->lastSearch = $search; - $this->groups = array(); + public function get($groupSearch = '', $userSearch = '') { + $key = $groupSearch . '::' . $userSearch; + if(isset($this->metaData[$key])) { + return $this->metaData[$key]; } $adminGroups = array(); @@ -80,8 +76,8 @@ class MetaData { $sortAdminGroupsIndex = 0; $sortAdminGroupsKeys = array(); - foreach($this->getGroups($search) as $group) { - $groupMetaData = $this->generateGroupMetaData($group); + foreach($this->getGroups($groupSearch) as $group) { + $groupMetaData = $this->generateGroupMetaData($group, $userSearch); if (strtolower($group->getGID()) !== 'admin') { $this->addEntry( $groups, @@ -104,13 +100,14 @@ class MetaData { $this->sort($groups, $sortGroupsKeys); $this->sort($adminGroups, $sortAdminGroupsKeys); - return array($adminGroups, $groups); + $this->metaData[$key] = array($adminGroups, $groups); + return $this->metaData[$key]; } /** - * @brief sets the sort mode, currently 0 (none) and 1 (user entries, + * sets the sort mode, currently 0 (none) and 1 (user entries, * descending) are supported - * @param int the sortMode (SORT_NONE, SORT_USERCOUNT) + * @param int $sortMode (SORT_NONE, SORT_USERCOUNT) */ public function setSorting($sortMode) { if($sortMode >= 0 && $sortMode <= 1) { @@ -121,11 +118,11 @@ class MetaData { } /** - * @brief adds an group entry to the resulting array - * @param array the resulting array, by reference - * @param array the sort key array, by reference - * @param array the sort key index, by reference - * @param array the group's meta data as returned by generateGroupMetaData() + * adds an group entry to the resulting array + * @param array $entries the resulting array, by reference + * @param array $sortKeys the sort key array, by reference + * @param int $sortIndex the sort key index, by reference + * @param array $data the group's meta data as returned by generateGroupMetaData() * @return null */ private function addEntry(&$entries, &$sortKeys, &$sortIndex, $data) { @@ -137,22 +134,23 @@ class MetaData { } /** - * @brief creates an array containing the group meta data - * @param \OC\Group\Group + * creates an array containing the group meta data + * @param \OC\Group\Group $group + * @param string $userSearch * @return array with the keys 'id', 'name' and 'usercount' */ - private function generateGroupMetaData(\OC\Group\Group $group) { + private function generateGroupMetaData(\OC\Group\Group $group, $userSearch) { return array( - 'id' => str_replace(' ','', $group->getGID()), + 'id' => $group->getGID(), 'name' => $group->getGID(), - 'usercount' => $group->count() + 'usercount' => $group->count($userSearch) ); } /** - * @brief sorts the result array, if applicable - * @param array the result array, by reference - * @param array the array containing the sort keys + * sorts the result array, if applicable + * @param array $entries the result array, by reference + * @param array $sortKeys the array containing the sort keys * @param return null */ private function sort(&$entries, $sortKeys) { @@ -162,27 +160,15 @@ class MetaData { } /** - * @brief returns the available groups - * @param string a search string + * returns the available groups + * @param string $search a search string * @return \OC\Group\Group[] */ private function getGroups($search = '') { - if(count($this->groups) === 0) { - $this->fetchGroups($search); - } - return $this->groups; - } - - /** - * @brief fetches the group using the group manager or the subAdmin API - * @param string a search string - * @return null - */ - private function fetchGroups($search = '') { if($this->isAdmin) { - $this->groups = $this->groupManager->search($search); + return $this->groupManager->search($search); } else { - $this->groups = \OC_SubAdmin::getSubAdminsGroups($this->user); + return \OC_SubAdmin::getSubAdminsGroups($this->user); } } } diff --git a/lib/private/installer.php b/lib/private/installer.php index f9d0b36afb4..c5a09349629 100644 --- a/lib/private/installer.php +++ b/lib/private/installer.php @@ -235,9 +235,10 @@ class OC_Installer{ throw new \Exception($l->t("No source specified when installing app")); } - //download the file if necesary + //download the file if necessary if($data['source']=='http') { - $path=OC_Helper::tmpFile(); + $pathInfo = pathinfo($data['href']); + $path=OC_Helper::tmpFile('.' . $pathInfo['extension']); if(!isset($data['href'])) { throw new \Exception($l->t("No href specified when installing app from http")); } @@ -251,13 +252,7 @@ class OC_Installer{ //detect the archive type $mime=OC_Helper::getMimeType($path); - if($mime=='application/zip') { - rename($path, $path.'.zip'); - $path.='.zip'; - }elseif($mime=='application/x-gzip') { - rename($path, $path.'.tgz'); - $path.='.tgz'; - }else{ + if ($mime !=='application/zip' && $mime !== 'application/x-gzip') { throw new \Exception($l->t("Archives of type %s are not supported", array($mime))); } diff --git a/lib/private/log.php b/lib/private/log.php index 98465ec40ea..021cc1578a7 100644 --- a/lib/private/log.php +++ b/lib/private/log.php @@ -154,6 +154,6 @@ class Log implements ILogger { $message = strtr($message, $replace); $logger = $this->logger; - $logger::write($app, $message, $level); + call_user_func(array($logger, 'write'), $app, $message, $level); } } diff --git a/lib/private/share/share.php b/lib/private/share/share.php index 691a2053a82..673c0dc383a 100644 --- a/lib/private/share/share.php +++ b/lib/private/share/share.php @@ -1905,7 +1905,7 @@ class Share extends \OC\Share\Constants { } else if (!isset($statuses[$item[$column]])) { $statuses[$item[$column]]['link'] = false; } - if ($item['file_target']) { + if (!empty($item['file_target'])) { $statuses[$item[$column]]['path'] = $item['path']; } } diff --git a/lib/private/user/manager.php b/lib/private/user/manager.php index f2964fecca3..d4d91163003 100644 --- a/lib/private/user/manager.php +++ b/lib/private/user/manager.php @@ -10,6 +10,7 @@ namespace OC\User; use OC\Hooks\PublicEmitter; +use OCP\IUserManager; /** * Class Manager @@ -24,7 +25,7 @@ use OC\Hooks\PublicEmitter; * * @package OC\User */ -class Manager extends PublicEmitter { +class Manager extends PublicEmitter implements IUserManager { /** * @var \OC_User_Interface[] $backends */ diff --git a/lib/private/user/session.php b/lib/private/user/session.php index 5f0dee607ae..8c9b3e264e3 100644 --- a/lib/private/user/session.php +++ b/lib/private/user/session.php @@ -10,6 +10,7 @@ namespace OC\User; use OC\Hooks\Emitter; +use OCP\IUserSession; /** * Class Session @@ -29,7 +30,7 @@ use OC\Hooks\Emitter; * * @package OC\User */ -class Session implements Emitter, \OCP\IUserSession { +class Session implements IUserSession, Emitter { /** * @var \OC\User\Manager $manager */ diff --git a/lib/private/user/user.php b/lib/private/user/user.php index 8aba7188e24..f9c2cb4d130 100644 --- a/lib/private/user/user.php +++ b/lib/private/user/user.php @@ -10,8 +10,9 @@ namespace OC\User; use OC\Hooks\Emitter; +use OCP\IUser; -class User { +class User implements IUser { /** * @var string $uid */ diff --git a/lib/public/iservercontainer.php b/lib/public/iservercontainer.php index 8bf97828581..f3dbc18322e 100644 --- a/lib/public/iservercontainer.php +++ b/lib/public/iservercontainer.php @@ -93,6 +93,13 @@ interface IServerContainer { function getAppFolder(); /** + * Returns a user manager + * + * @return \OCP\IUserManager + */ + function getUserManager(); + + /** * Returns the user session * * @return \OCP\IUserSession diff --git a/lib/public/iuser.php b/lib/public/iuser.php new file mode 100644 index 00000000000..dc4acc7658f --- /dev/null +++ b/lib/public/iuser.php @@ -0,0 +1,105 @@ +<?php + +/** + * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +namespace OCP; + +interface IUser { + /** + * get the user id + * + * @return string + */ + public function getUID(); + + /** + * get the displayname for the user, if no specific displayname is set it will fallback to the user id + * + * @return string + */ + public function getDisplayName(); + + /** + * set the displayname for the user + * + * @param string $displayName + * @return bool + */ + public function setDisplayName($displayName); + + /** + * returns the timestamp of the user's last login or 0 if the user did never + * login + * + * @return int + */ + public function getLastLogin(); + + /** + * updates the timestamp of the most recent login of this user + */ + public function updateLastLoginTimestamp(); + + /** + * Delete the user + * + * @return bool + */ + public function delete(); + + /** + * Set the password of the user + * + * @param string $password + * @param string $recoveryPassword for the encryption app to reset encryption keys + * @return bool + */ + public function setPassword($password, $recoveryPassword); + + /** + * get the users home folder to mount + * + * @return string + */ + public function getHome(); + + /** + * check if the backend allows the user to change his avatar on Personal page + * + * @return bool + */ + public function canChangeAvatar(); + + /** + * check if the backend supports changing passwords + * + * @return bool + */ + public function canChangePassword(); + + /** + * check if the backend supports changing display names + * + * @return bool + */ + public function canChangeDisplayName(); + + /** + * check if the user is enabled + * + * @return bool + */ + public function isEnabled(); + + /** + * set the enabled status for the user + * + * @param bool $enabled + */ + public function setEnabled($enabled); +} diff --git a/lib/public/iusermanager.php b/lib/public/iusermanager.php new file mode 100644 index 00000000000..fc0729b860b --- /dev/null +++ b/lib/public/iusermanager.php @@ -0,0 +1,105 @@ +<?php + +/** + * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +namespace OCP; + + +/** + * Class Manager + * + * Hooks available in scope \OC\User: + * - preSetPassword(\OC\User\User $user, string $password, string $recoverPassword) + * - postSetPassword(\OC\User\User $user, string $password, string $recoverPassword) + * - preDelete(\OC\User\User $user) + * - postDelete(\OC\User\User $user) + * - preCreateUser(string $uid, string $password) + * - postCreateUser(\OC\User\User $user, string $password) + * + * @package OC\User + */ +interface IUserManager { + /** + * register a user backend + * + * @param \OCP\UserInterface $backend + */ + public function registerBackend($backend); + + /** + * remove a user backend + * + * @param \OCP\UserInterface $backend + */ + public function removeBackend($backend); + + /** + * remove all user backends + */ + public function clearBackends() ; + + /** + * get a user by user id + * + * @param string $uid + * @return \OCP\IUser + */ + public function get($uid); + + /** + * check if a user exists + * + * @param string $uid + * @return bool + */ + public function userExists($uid); + + /** + * Check if the password is valid for the user + * + * @param string $loginname + * @param string $password + * @return mixed the User object on success, false otherwise + */ + public function checkPassword($loginname, $password); + + /** + * search by user id + * + * @param string $pattern + * @param int $limit + * @param int $offset + * @return \OCP\IUser[] + */ + public function search($pattern, $limit = null, $offset = null); + + /** + * search by displayName + * + * @param string $pattern + * @param int $limit + * @param int $offset + * @return \OCP\IUser[] + */ + public function searchDisplayName($pattern, $limit = null, $offset = null); + + /** + * @param string $uid + * @param string $password + * @throws \Exception + * @return bool|\OCP\IUser the created user of false + */ + public function createUser($uid, $password); + + /** + * returns how many users per backend exist (if supported by backend) + * + * @return array an array of backend class as key and count number as value + */ + public function countUsers(); +} diff --git a/lib/public/iusersession.php b/lib/public/iusersession.php index adc706cc7c3..e9d417c1ace 100644 --- a/lib/public/iusersession.php +++ b/lib/public/iusersession.php @@ -49,4 +49,17 @@ interface IUserSession { */ public function logout(); + /** + * set the currently active user + * + * @param \OCP\User|null $user + */ + public function setUser($user); + + /** + * get the current active user + * + * @return \OCP\User + */ + public function getUser(); } |