From ac73ce1b2a9cbcafce29d9f6be768b0629f68ddb Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Fri, 20 Sep 2013 12:45:56 +0200 Subject: Add UserSession to server container --- lib/public/iservercontainer.php | 7 ++++++ lib/public/iusersession.php | 30 ++++++++++++++++++++++ lib/server.php | 55 +++++++++++++++++++++++++++++++++++++++++ lib/user.php | 43 ++------------------------------ 4 files changed, 94 insertions(+), 41 deletions(-) create mode 100644 lib/public/iusersession.php diff --git a/lib/public/iservercontainer.php b/lib/public/iservercontainer.php index 1725b7c74e0..ad714276660 100644 --- a/lib/public/iservercontainer.php +++ b/lib/public/iservercontainer.php @@ -62,6 +62,13 @@ interface IServerContainer { */ function getRootFolder(); + /** + * Returns the user session + * + * @return \OCP\IUserSession + */ + function getUserSession(); + /** * Returns an ICache instance * diff --git a/lib/public/iusersession.php b/lib/public/iusersession.php new file mode 100644 index 00000000000..5dc1ecf71e6 --- /dev/null +++ b/lib/public/iusersession.php @@ -0,0 +1,30 @@ + + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + * + */ + +namespace OCP; + +/** + * User session + */ +interface IUserSession { + /** + * Do a user login + * @param string $user the username + * @param string $password the password + * @return bool true if successful + */ + public function login($user, $password); + + /** + * @brief Logs the user out including all the session data + * Logout, destroys session + */ + public function logout(); + +} diff --git a/lib/server.php b/lib/server.php index f4dc22a2be4..316ed39665b 100644 --- a/lib/server.php +++ b/lib/server.php @@ -56,6 +56,47 @@ class Server extends SimpleContainer implements IServerContainer { $view = new View(); return new Root($manager, $view, $user); }); + $this->registerService('UserManager', function($c) { + return new \OC\User\Manager(); + }); + $this->registerService('UserSession', function($c) { + $manager = $c->query('UserManager'); + $userSession = new \OC\User\Session($manager, \OC::$session); + $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { + \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password)); + }); + $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) { + /** @var $user \OC\User\User */ + \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password)); + }); + $userSession->listen('\OC\User', 'preDelete', function ($user) { + /** @var $user \OC\User\User */ + \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID())); + }); + $userSession->listen('\OC\User', 'postDelete', function ($user) { + /** @var $user \OC\User\User */ + \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID())); + }); + $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) { + /** @var $user \OC\User\User */ + \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); + }); + $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) { + /** @var $user \OC\User\User */ + \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); + }); + $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) { + \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password)); + }); + $userSession->listen('\OC\User', 'postLogin', function ($user, $password) { + /** @var $user \OC\User\User */ + \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); + }); + $userSession->listen('\OC\User', 'logout', function () { + \OC_Hook::emit('OC_User', 'logout', array()); + }); + return $userSession; + }); $this->registerService('UserCache', function($c) { return new UserCache(); }); @@ -97,6 +138,20 @@ class Server extends SimpleContainer implements IServerContainer { return $this->query('RootFolder'); } + /** + * @return \OC\User\Manager + */ + function getUserManager() { + return $this->query('UserManager'); + } + + /** + * @return \OC\User\Session + */ + function getUserSession() { + return $this->query('UserSession'); + } + /** * Returns an ICache instance * diff --git a/lib/user.php b/lib/user.php index 0f6f40aec9a..7f6a296c3ea 100644 --- a/lib/user.php +++ b/lib/user.php @@ -37,54 +37,15 @@ * logout() */ class OC_User { - public static $userSession = null; - public static function getUserSession() { - if (!self::$userSession) { - $manager = new \OC\User\Manager(); - self::$userSession = new \OC\User\Session($manager, \OC::$session); - self::$userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { - \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password)); - }); - self::$userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) { - /** @var $user \OC\User\User */ - \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password)); - }); - self::$userSession->listen('\OC\User', 'preDelete', function ($user) { - /** @var $user \OC\User\User */ - \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID())); - }); - self::$userSession->listen('\OC\User', 'postDelete', function ($user) { - /** @var $user \OC\User\User */ - \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID())); - }); - self::$userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) { - /** @var $user \OC\User\User */ - OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); - }); - self::$userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) { - /** @var $user \OC\User\User */ - OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); - }); - self::$userSession->listen('\OC\User', 'preLogin', function ($uid, $password) { - \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password)); - }); - self::$userSession->listen('\OC\User', 'postLogin', function ($user, $password) { - /** @var $user \OC\User\User */ - \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); - }); - self::$userSession->listen('\OC\User', 'logout', function () { - \OC_Hook::emit('OC_User', 'logout', array()); - }); - } - return self::$userSession; + return OC::$server->getUserSession(); } /** * @return \OC\User\Manager */ public static function getManager() { - return self::getUserSession()->getManager(); + return OC::$server->getUserManager(); } private static $_backends = array(); -- cgit v1.2.3 From aa8a85f77d0c6705ee727d182e95d288ba7b7917 Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Fri, 20 Sep 2013 14:33:45 +0200 Subject: Add DBConnection to server container --- lib/db/connection.php | 2 +- lib/public/idbconnection.php | 71 +++++++++++++++++++++++++++++++++++++++++ lib/public/iservercontainer.php | 7 ++++ lib/server.php | 8 +++++ 4 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 lib/public/idbconnection.php diff --git a/lib/db/connection.php b/lib/db/connection.php index 2581969dbd0..2d3193a148a 100644 --- a/lib/db/connection.php +++ b/lib/db/connection.php @@ -12,7 +12,7 @@ use Doctrine\DBAL\Configuration; use Doctrine\DBAL\Cache\QueryCacheProfile; use Doctrine\Common\EventManager; -class Connection extends \Doctrine\DBAL\Connection { +class Connection extends \Doctrine\DBAL\Connection implements \OCP\IDBConnection { /** * @var string $tablePrefix */ diff --git a/lib/public/idbconnection.php b/lib/public/idbconnection.php new file mode 100644 index 00000000000..67dd7ccfc37 --- /dev/null +++ b/lib/public/idbconnection.php @@ -0,0 +1,71 @@ + + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + * + */ + +namespace OCP; + +/** + * TODO: Description + */ +interface IDBConnection { + /** + * Used to abstract the owncloud database access away + * @param string $sql the sql query with ? placeholder for params + * @param int $limit the maximum number of rows + * @param int $offset from which row we want to start + * @return \Doctrine\DBAL\Driver\Statement The prepared statement. + */ + public function prepare($sql, $limit=null, $offset=null); + + /** + * Used to get the id of the just inserted element + * @param string $tableName the name of the table where we inserted the item + * @return int the id of the inserted element + */ + public function lastInsertId($table = null); + + /** + * @brief Insert a row if a matching row doesn't exists. + * @param $table string The table name (will replace *PREFIX*) to perform the replace on. + * @param $input array + * + * The input array if in the form: + * + * array ( 'id' => array ( 'value' => 6, + * 'key' => true + * ), + * 'name' => array ('value' => 'Stoyan'), + * 'family' => array ('value' => 'Stefanov'), + * 'birth_date' => array ('value' => '1975-06-20') + * ); + * @return bool + * + */ + public function insertIfNotExist($table, $input); + + /** + * @brief Start a transaction + */ + public function beginTransaction(); + + /** + * @brief Commit the database changes done during a transaction that is in progress + */ + public function commit(); + + /** + * @brief Rollback the database changes done during a transaction that is in progress + */ + public function rollBack(); + + /** + * returns the error code and message as a string for logging + * @return string + */ + public function getError(); +} diff --git a/lib/public/iservercontainer.php b/lib/public/iservercontainer.php index ad714276660..5481cd6ce6a 100644 --- a/lib/public/iservercontainer.php +++ b/lib/public/iservercontainer.php @@ -83,4 +83,11 @@ interface IServerContainer { */ function getSession(); + /** + * Returns the current session + * + * @return \OCP\IDBConnection + */ + function getDatabaseConnection(); + } diff --git a/lib/server.php b/lib/server.php index 316ed39665b..a5288fa1482 100644 --- a/lib/server.php +++ b/lib/server.php @@ -170,4 +170,12 @@ class Server extends SimpleContainer implements IServerContainer { return \OC::$session; } + /** + * Returns the current session + * + * @return \OCP\IDBConnection + */ + function getDatabaseConnection() { + return \OC_DB::getConnection(); + } } -- cgit v1.2.3 From e3013c580108e6b0cc332ba14976f3ffb4b7b274 Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Fri, 20 Sep 2013 17:34:33 +0200 Subject: Add Navigation class to server container --- lib/app.php | 31 ++++++++----------- lib/navigationmanager.php | 63 +++++++++++++++++++++++++++++++++++++++ lib/public/inavigationmanager.php | 27 +++++++++++++++++ lib/public/iservercontainer.php | 5 ++++ lib/server.php | 10 +++++++ 5 files changed, 117 insertions(+), 19 deletions(-) create mode 100644 lib/navigationmanager.php create mode 100644 lib/public/inavigationmanager.php diff --git a/lib/app.php b/lib/app.php index d98af2dc296..0ab1ee57f63 100644 --- a/lib/app.php +++ b/lib/app.php @@ -27,8 +27,6 @@ * upgrading and removing apps. */ class OC_App{ - static private $activeapp = ''; - static private $navigation = array(); static private $settingsForms = array(); static private $adminForms = array(); static private $personalForms = array(); @@ -271,7 +269,7 @@ class OC_App{ /** * @brief adds an entry to the navigation - * @param string $data array containing the data + * @param array $data array containing the data * @return bool * * This function adds a new entry to the navigation visible to users. $data @@ -287,11 +285,7 @@ class OC_App{ * the navigation. Lower values come first. */ public static function addNavigationEntry( $data ) { - $data['active']=false; - if(!isset($data['icon'])) { - $data['icon']=''; - } - OC_App::$navigation[] = $data; + OC::$server->getNavigationManager()->add($data); return true; } @@ -305,9 +299,7 @@ class OC_App{ * highlighting the current position of the user. */ public static function setActiveNavigationEntry( $id ) { - // load all the apps, to make sure we have all the navigation entries - self::loadApps(); - self::$activeapp = $id; + OC::$server->getNavigationManager()->setActiveEntry($id); return true; } @@ -315,15 +307,14 @@ class OC_App{ * @brief Get the navigation entries for the $app * @param string $app app * @return array of the $data added with addNavigationEntry + * + * Warning: destroys the existing entries */ public static function getAppNavigationEntries($app) { if(is_file(self::getAppPath($app).'/appinfo/app.php')) { - $save = self::$navigation; - self::$navigation = array(); + OC::$server->getNavigationManager()->clear(); require $app.'/appinfo/app.php'; - $app_entries = self::$navigation; - self::$navigation = $save; - return $app_entries; + return OC::$server->getNavigationManager()->getAll(); } return array(); } @@ -336,7 +327,7 @@ class OC_App{ * setActiveNavigationEntry */ public static function getActiveNavigationEntry() { - return self::$activeapp; + return OC::$server->getNavigationManager()->getActiveEntry(); } /** @@ -419,8 +410,9 @@ class OC_App{ // This is private as well. It simply works, so don't ask for more details private static function proceedNavigation( $list ) { + $activeapp = OC::$server->getNavigationManager()->getActiveEntry(); foreach( $list as &$naventry ) { - if( $naventry['id'] == self::$activeapp ) { + if( $naventry['id'] == $activeapp ) { $naventry['active'] = true; } else{ @@ -572,7 +564,8 @@ class OC_App{ * - active: boolean, signals if the user is on this navigation entry */ public static function getNavigation() { - $navigation = self::proceedNavigation( self::$navigation ); + $entries = OC::$server->getNavigationManager()->getAll(); + $navigation = self::proceedNavigation( $entries ); return $navigation; } diff --git a/lib/navigationmanager.php b/lib/navigationmanager.php new file mode 100644 index 00000000000..f032afd1fc4 --- /dev/null +++ b/lib/navigationmanager.php @@ -0,0 +1,63 @@ + + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + * + */ + +namespace OC; + +/** + * Manages the owncloud navigation + */ +class NavigationManager { + protected $entries = array(); + + /** + * Creates a new navigation entry + * @param array $entry containing: id, name, order, icon and href key + */ + public function add(array $entry) { + $entry['active'] = false; + if(!isset($entry['icon'])) { + $entry['icon'] = ''; + } + $this->entries[] = $entry; + } + + /** + * @brief returns all the added Menu entries + * @return array of the added entries + */ + public function getAll() { + return $this->entries; + } + + /** + * @brief removes all the entries + */ + public function clear() { + $this->entries = array(); + } + + /** + * Sets the current navigation entry of the currently running app + * @param string $id of the app entry to activate (from added $entry) + */ + public function setActiveEntry($id) { + $this->activeEntry = $id; + } + + /** + * @brief gets the active Menu entry + * @return string id or empty string + * + * This function returns the id of the active navigation entry (set by + * setActiveEntry + */ + public function getActiveEntry() { + return $this->activeEntry; + } +} diff --git a/lib/public/inavigationmanager.php b/lib/public/inavigationmanager.php new file mode 100644 index 00000000000..21744dd1c21 --- /dev/null +++ b/lib/public/inavigationmanager.php @@ -0,0 +1,27 @@ + + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + * + */ + +namespace OCP; + +/** + * Manages the owncloud navigation + */ +interface INavigationManager { + /** + * Creates a new navigation entry + * @param array $entry containing: id, name, order, icon and href key + */ + public function add(array $entry); + + /** + * Sets the current navigation entry of the currently running app + * @param string $appId id of the app entry to activate (from added $entry) + */ + public function setActiveEntry($appId); +} \ No newline at end of file diff --git a/lib/public/iservercontainer.php b/lib/public/iservercontainer.php index 5481cd6ce6a..ebcc0fe4cd4 100644 --- a/lib/public/iservercontainer.php +++ b/lib/public/iservercontainer.php @@ -69,6 +69,11 @@ interface IServerContainer { */ function getUserSession(); + /** + * @return \OCP\INavigationManager + */ + function getNavigationManager(); + /** * Returns an ICache instance * diff --git a/lib/server.php b/lib/server.php index a5288fa1482..13bda2dc30d 100644 --- a/lib/server.php +++ b/lib/server.php @@ -97,6 +97,9 @@ class Server extends SimpleContainer implements IServerContainer { }); return $userSession; }); + $this->registerService('NavigationManager', function($c) { + return new \OC\NavigationManager(); + }); $this->registerService('UserCache', function($c) { return new UserCache(); }); @@ -152,6 +155,13 @@ class Server extends SimpleContainer implements IServerContainer { return $this->query('UserSession'); } + /** + * @return \OC\NavigationManager + */ + function getNavigationManager() { + return $this->query('NavigationManager'); + } + /** * Returns an ICache instance * -- cgit v1.2.3 From e92abfd4d8dfb9dbb42ccfc0c23193b1ddde3bbf Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Fri, 20 Sep 2013 20:21:24 +0200 Subject: Add Config container class to server container --- lib/allconfig.php | 78 +++++++++++++++++++++++++++++++++++++++++ lib/public/iconfig.php | 59 +++++++++++++++++++++++++++++++ lib/public/iservercontainer.php | 5 +++ lib/server.php | 9 +++++ 4 files changed, 151 insertions(+) create mode 100644 lib/allconfig.php create mode 100644 lib/public/iconfig.php diff --git a/lib/allconfig.php b/lib/allconfig.php new file mode 100644 index 00000000000..81c8892348b --- /dev/null +++ b/lib/allconfig.php @@ -0,0 +1,78 @@ + + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + * + */ + +namespace OC; + +/** + * Class to combine all the configuration options ownCloud offers + */ +class AllConfig implements \OCP\IConfig { + /** + * Sets a new systemwide value + * @param string $key the key of the value, under which will be saved + * @param string $value the value that should be stored + * @todo need a use case for this + */ +// public function setSystemValue($key, $value) { +// \OCP\Config::setSystemValue($key, $value); +// } + + /** + * Looks up a systemwide defined value + * @param string $key the key of the value, under which it was saved + * @return string the saved value + */ + public function getSystemValue($key) { + return \OCP\Config::getSystemValue($key, ''); + } + + + /** + * Writes a new appwide value + * @param string $appName the appName that we want to store the value under + * @param string $key the key of the value, under which will be saved + * @param string $value the value that should be stored + */ + public function setAppValue($appName, $key, $value) { + \OCP\Config::setAppValue($appName, $key, $value); + } + + /** + * Looks up an appwide defined value + * @param string $appName the appName that we stored the value under + * @param string $key the key of the value, under which it was saved + * @return string the saved value + */ + public function getAppValue($appName, $key) { + return \OCP\Config::getAppValue($appName, $key, ''); + } + + + /** + * Set a user defined value + * @param string $userId the userId of the user that we want to store the value under + * @param string $appName the appName that we want to store the value under + * @param string $key the key under which the value is being stored + * @param string $value the value that you want to store + */ + public function setUserValue($userId, $appName, $key, $value) { + \OCP\Config::setUserValue($userId, $appName, $key, $value); + } + + + /** + * Shortcut for getting a user defined value + * @param string $userId the userId of the user that we want to store the value under + * @param string $appName the appName that we stored the value under + * @param string $key the key under which the value is being stored + */ + public function getUserValue($userId, $appName, $key){ + return \OCP\Config::getUserValue($userId, $appName, $key); + } +} diff --git a/lib/public/iconfig.php b/lib/public/iconfig.php new file mode 100644 index 00000000000..0c150ec351a --- /dev/null +++ b/lib/public/iconfig.php @@ -0,0 +1,59 @@ + + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + * + */ +namespace OCP; + +/** + * Access to all the configuration options ownCloud offers + */ +interface IConfig { + /** + * Sets a new systemwide value + * @param string $key the key of the value, under which will be saved + * @param string $value the value that should be stored + * @todo need a use case for this + */ +// public function setSystemValue($key, $value); + + /** + * Looks up a systemwide defined value + * @param string $key the key of the value, under which it was saved + * @return string the saved value + */ + public function getSystemValue($key); + + + /** + * Writes a new appwide value + * @param string $key the key of the value, under which will be saved + * @param string $value the value that should be stored + */ + public function setAppValue($key, $value, $appName=null); + + /** + * Looks up an appwide defined value + * @param string $key the key of the value, under which it was saved + * @return string the saved value + */ + public function getAppValue($key, $appName=null); + + + /** + * Shortcut for setting a user defined value + * @param string $key the key under which the value is being stored + * @param string $value the value that you want to store + * @param string $userId the userId of the user that we want to store the value under, defaults to the current one + */ + public function setUserValue($key, $value, $userId=null); + + /** + * Shortcut for getting a user defined value + * @param string $key the key under which the value is being stored + * @param string $userId the userId of the user that we want to store the value under, defaults to the current one + */ + public function getUserValue($key, $userId=null); +} diff --git a/lib/public/iservercontainer.php b/lib/public/iservercontainer.php index ebcc0fe4cd4..4478a4e8a6c 100644 --- a/lib/public/iservercontainer.php +++ b/lib/public/iservercontainer.php @@ -74,6 +74,11 @@ interface IServerContainer { */ function getNavigationManager(); + /** + * @return \OCP\IConfig + */ + function getConfig(); + /** * Returns an ICache instance * diff --git a/lib/server.php b/lib/server.php index 13bda2dc30d..57e7f4ab4f1 100644 --- a/lib/server.php +++ b/lib/server.php @@ -100,6 +100,9 @@ class Server extends SimpleContainer implements IServerContainer { $this->registerService('NavigationManager', function($c) { return new \OC\NavigationManager(); }); + $this->registerService('AllConfig', function($c) { + return new \OC\AllConfig(); + }); $this->registerService('UserCache', function($c) { return new UserCache(); }); @@ -162,6 +165,12 @@ class Server extends SimpleContainer implements IServerContainer { return $this->query('NavigationManager'); } + /** + * @return \OC\Config + */ + function getConfig() { + return $this->query('AllConfig'); + } /** * Returns an ICache instance * -- cgit v1.2.3 From 9116303cfc5259f05ec348809bfbc8757d4657cb Mon Sep 17 00:00:00 2001 From: Thomas Müller Date: Fri, 20 Sep 2013 21:40:54 +0200 Subject: fixing typos --- lib/allconfig.php | 8 ++++---- lib/public/iconfig.php | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/allconfig.php b/lib/allconfig.php index 81c8892348b..353608e5d21 100644 --- a/lib/allconfig.php +++ b/lib/allconfig.php @@ -14,7 +14,7 @@ namespace OC; */ class AllConfig implements \OCP\IConfig { /** - * Sets a new systemwide value + * Sets a new system wide value * @param string $key the key of the value, under which will be saved * @param string $value the value that should be stored * @todo need a use case for this @@ -24,7 +24,7 @@ class AllConfig implements \OCP\IConfig { // } /** - * Looks up a systemwide defined value + * Looks up a system wide defined value * @param string $key the key of the value, under which it was saved * @return string the saved value */ @@ -34,7 +34,7 @@ class AllConfig implements \OCP\IConfig { /** - * Writes a new appwide value + * Writes a new app wide value * @param string $appName the appName that we want to store the value under * @param string $key the key of the value, under which will be saved * @param string $value the value that should be stored @@ -44,7 +44,7 @@ class AllConfig implements \OCP\IConfig { } /** - * Looks up an appwide defined value + * Looks up an app wide defined value * @param string $appName the appName that we stored the value under * @param string $key the key of the value, under which it was saved * @return string the saved value diff --git a/lib/public/iconfig.php b/lib/public/iconfig.php index 0c150ec351a..dab4590969b 100644 --- a/lib/public/iconfig.php +++ b/lib/public/iconfig.php @@ -12,7 +12,7 @@ namespace OCP; */ interface IConfig { /** - * Sets a new systemwide value + * Sets a new system wide value * @param string $key the key of the value, under which will be saved * @param string $value the value that should be stored * @todo need a use case for this @@ -20,7 +20,7 @@ interface IConfig { // public function setSystemValue($key, $value); /** - * Looks up a systemwide defined value + * Looks up a system wide defined value * @param string $key the key of the value, under which it was saved * @return string the saved value */ @@ -28,14 +28,14 @@ interface IConfig { /** - * Writes a new appwide value + * Writes a new app wide value * @param string $key the key of the value, under which will be saved * @param string $value the value that should be stored */ public function setAppValue($key, $value, $appName=null); /** - * Looks up an appwide defined value + * Looks up an app wide defined value * @param string $key the key of the value, under which it was saved * @return string the saved value */ -- cgit v1.2.3 From e31f6c01e85bea52e973df65a7610d490bf6336c Mon Sep 17 00:00:00 2001 From: Thomas Müller Date: Fri, 20 Sep 2013 21:43:17 +0200 Subject: fixing PHPDoc --- lib/public/app.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/public/app.php b/lib/public/app.php index a1ecf524cc8..0a5721b334e 100644 --- a/lib/public/app.php +++ b/lib/public/app.php @@ -35,10 +35,10 @@ namespace OCP; */ class App { /** - * @brief Makes owncloud aware of this app + * @brief Makes ownCloud aware of this app * @brief This call is deprecated and not necessary to use. * @param $data array with all information - * @returns true/false + * @returns boolean * * @deprecated this method is deprecated * Do not call it anymore @@ -52,7 +52,7 @@ class App { /** * @brief adds an entry to the navigation * @param $data array containing the data - * @returns true/false + * @returns boolean * * This function adds a new entry to the navigation visible to users. $data * is an associative array. @@ -72,8 +72,8 @@ class App { /** * @brief marks a navigation entry as active - * @param $id id of the entry - * @returns true/false + * @param $id string id of the entry + * @returns boolean * * This function sets a navigation entry as active and removes the 'active' * property from all other entries. The templates can use this for @@ -104,7 +104,7 @@ class App { /** * @brief Read app metadata from the info.xml file * @param string $app id of the app or the path of the info.xml file - * @param boolean path (optional) + * @param boolean $path (optional) * @returns array */ public static function getAppInfo( $app, $path=false ) { @@ -114,7 +114,7 @@ class App { /** * @brief checks whether or not an app is enabled * @param $app app - * @returns true/false + * @returns boolean * * This function checks whether or not an app is enabled. */ @@ -133,7 +133,7 @@ class App { /** * @brief Get the last version of the app, either from appinfo/version or from appinfo/info.xml * @param $app app - * @returns true/false + * @returns boolean */ public static function getAppVersion( $app ) { return \OC_App::getAppVersion( $app ); -- cgit v1.2.3 From f83f32326949d6bc16c2b0d7aefcdbb48f9119d7 Mon Sep 17 00:00:00 2001 From: Thomas Müller Date: Fri, 20 Sep 2013 21:45:27 +0200 Subject: fixing typos + adding missing filed $activeEntry --- lib/navigationmanager.php | 3 ++- lib/public/inavigationmanager.php | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/navigationmanager.php b/lib/navigationmanager.php index f032afd1fc4..cf3bf84d998 100644 --- a/lib/navigationmanager.php +++ b/lib/navigationmanager.php @@ -10,10 +10,11 @@ namespace OC; /** - * Manages the owncloud navigation + * Manages the ownCloud navigation */ class NavigationManager { protected $entries = array(); + protected $activeEntry; /** * Creates a new navigation entry diff --git a/lib/public/inavigationmanager.php b/lib/public/inavigationmanager.php index 21744dd1c21..f89e790c1d0 100644 --- a/lib/public/inavigationmanager.php +++ b/lib/public/inavigationmanager.php @@ -10,7 +10,7 @@ namespace OCP; /** - * Manages the owncloud navigation + * Manages the ownCloud navigation */ interface INavigationManager { /** @@ -24,4 +24,4 @@ interface INavigationManager { * @param string $appId id of the app entry to activate (from added $entry) */ public function setActiveEntry($appId); -} \ No newline at end of file +} -- cgit v1.2.3 From d3d52dd23f3da9a3d9ed2b50b1abd1a229dc4be8 Mon Sep 17 00:00:00 2001 From: Thomas Müller Date: Fri, 20 Sep 2013 21:57:48 +0200 Subject: PHPDoc & get UserManager from container for RooFolder --- lib/server.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/server.php b/lib/server.php index 57e7f4ab4f1..804af6b0eac 100644 --- a/lib/server.php +++ b/lib/server.php @@ -4,6 +4,7 @@ namespace OC; use OC\AppFramework\Http\Request; use OC\AppFramework\Utility\SimpleContainer; +use OC\Cache\UserCache; use OC\Files\Node\Root; use OC\Files\View; use OCP\IServerContainer; @@ -49,9 +50,11 @@ class Server extends SimpleContainer implements IServerContainer { return new PreviewManager(); }); $this->registerService('RootFolder', function($c) { - // TODO: get user and user manager from container as well + // TODO: get user from container as well $user = \OC_User::getUser(); - $user = \OC_User::getManager()->get($user); + /** @var $c SimpleContainer */ + $userManager = $c->query('UserManager'); + $user = $userManager->get($user); $manager = \OC\Files\Filesystem::getMountManager(); $view = new View(); return new Root($manager, $view, $user); @@ -60,6 +63,7 @@ class Server extends SimpleContainer implements IServerContainer { return new \OC\User\Manager(); }); $this->registerService('UserSession', function($c) { + /** @var $c SimpleContainer */ $manager = $c->query('UserManager'); $userSession = new \OC\User\Session($manager, \OC::$session); $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { -- cgit v1.2.3 From 0c6dcdba6b890dc170f59a461ab80961a85a53db Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Fri, 20 Sep 2013 22:45:22 +0200 Subject: Add missing implements and fix parameters in IConfig --- lib/allconfig.php | 1 - lib/navigationmanager.php | 2 +- lib/public/iconfig.php | 22 ++++++++++++++-------- lib/public/idbconnection.php | 3 +++ lib/user/session.php | 2 +- 5 files changed, 19 insertions(+), 11 deletions(-) diff --git a/lib/allconfig.php b/lib/allconfig.php index 353608e5d21..72aabf60793 100644 --- a/lib/allconfig.php +++ b/lib/allconfig.php @@ -65,7 +65,6 @@ class AllConfig implements \OCP\IConfig { \OCP\Config::setUserValue($userId, $appName, $key, $value); } - /** * Shortcut for getting a user defined value * @param string $userId the userId of the user that we want to store the value under diff --git a/lib/navigationmanager.php b/lib/navigationmanager.php index cf3bf84d998..1f657b9ad80 100644 --- a/lib/navigationmanager.php +++ b/lib/navigationmanager.php @@ -12,7 +12,7 @@ namespace OC; /** * Manages the ownCloud navigation */ -class NavigationManager { +class NavigationManager implements \OCP\INavigationManager { protected $entries = array(); protected $activeEntry; diff --git a/lib/public/iconfig.php b/lib/public/iconfig.php index dab4590969b..850bddf6935 100644 --- a/lib/public/iconfig.php +++ b/lib/public/iconfig.php @@ -1,10 +1,12 @@ +/** + * Copyright (c) 2013 Bart Visscher * This file is licensed under the Affero General Public License version 3 or * later. * See the COPYING-README file. * */ + namespace OCP; /** @@ -29,31 +31,35 @@ interface IConfig { /** * Writes a new app wide value + * @param string $appName the appName that we want to store the value under * @param string $key the key of the value, under which will be saved * @param string $value the value that should be stored */ - public function setAppValue($key, $value, $appName=null); + public function setAppValue($appName, $key, $value); /** * Looks up an app wide defined value + * @param string $appName the appName that we stored the value under * @param string $key the key of the value, under which it was saved * @return string the saved value */ - public function getAppValue($key, $appName=null); + public function getAppValue($appName, $key); /** - * Shortcut for setting a user defined value + * Set a user defined value + * @param string $userId the userId of the user that we want to store the value under + * @param string $appName the appName that we want to store the value under * @param string $key the key under which the value is being stored * @param string $value the value that you want to store - * @param string $userId the userId of the user that we want to store the value under, defaults to the current one */ - public function setUserValue($key, $value, $userId=null); + public function setUserValue($userId, $appName, $key, $value); /** * Shortcut for getting a user defined value + * @param string $userId the userId of the user that we want to store the value under + * @param string $appName the appName that we stored the value under * @param string $key the key under which the value is being stored - * @param string $userId the userId of the user that we want to store the value under, defaults to the current one */ - public function getUserValue($key, $userId=null); + public function getUserValue($userId, $appName, $key); } diff --git a/lib/public/idbconnection.php b/lib/public/idbconnection.php index 67dd7ccfc37..c741a0f061a 100644 --- a/lib/public/idbconnection.php +++ b/lib/public/idbconnection.php @@ -50,16 +50,19 @@ interface IDBConnection { /** * @brief Start a transaction + * @return bool TRUE on success or FALSE on failure */ public function beginTransaction(); /** * @brief Commit the database changes done during a transaction that is in progress + * @return bool TRUE on success or FALSE on failure */ public function commit(); /** * @brief Rollback the database changes done during a transaction that is in progress + * @return bool TRUE on success or FALSE on failure */ public function rollBack(); diff --git a/lib/user/session.php b/lib/user/session.php index 9a6c669e935..98a24d5bb00 100644 --- a/lib/user/session.php +++ b/lib/user/session.php @@ -27,7 +27,7 @@ use OC\Hooks\Emitter; * * @package OC\User */ -class Session implements Emitter { +class Session implements Emitter, \OCP\IUserSession { /** * @var \OC\User\Manager $manager */ -- cgit v1.2.3