From ecdd04374a4cabdf682e427b59619ef2e42d2997 Mon Sep 17 00:00:00 2001 From: Michael Kuhn Date: Sat, 26 Jul 2014 02:00:49 +0200 Subject: Allow specifying the item source in unshareFromSelf(). --- lib/private/share/share.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'lib/private/share') diff --git a/lib/private/share/share.php b/lib/private/share/share.php index 673c0dc383a..80389625c61 100644 --- a/lib/private/share/share.php +++ b/lib/private/share/share.php @@ -718,23 +718,24 @@ class Share extends \OC\Share\Constants { /** * Unshare an item shared with the current user * @param string $itemType - * @param string $itemTarget + * @param string $itemOrigin Item target or source + * @param boolean $originIsSource true if $itemOrigin is the source, false if $itemOrigin is the target (optional) * @return boolean true on success or false on failure * * Unsharing from self is not allowed for items inside collections */ - public static function unshareFromSelf($itemType, $itemTarget) { - + public static function unshareFromSelf($itemType, $itemOrigin, $originIsSource = false) { + $originType = ($originIsSource) ? 'source' : 'target'; $uid = \OCP\User::getUser(); if ($itemType === 'file' || $itemType === 'folder') { - $statement = 'SELECT * FROM `*PREFIX*share` WHERE `item_type` = ? and `file_target` = ?'; + $statement = 'SELECT * FROM `*PREFIX*share` WHERE `item_type` = ? and `file_' . $originType . '` = ?'; } else { - $statement = 'SELECT * FROM `*PREFIX*share` WHERE `item_type` = ? and `item_target` = ?'; + $statement = 'SELECT * FROM `*PREFIX*share` WHERE `item_type` = ? and `item_' . $originType . '` = ?'; } $query = \OCP\DB::prepare($statement); - $result = $query->execute(array($itemType, $itemTarget)); + $result = $query->execute(array($itemType, $itemOrigin)); $shares = $result->fetchAll(); -- cgit v1.2.3 From f551917a3ca2cedf748337646ed4b1d398ac8437 Mon Sep 17 00:00:00 2001 From: Jörn Friedrich Dreyer Date: Wed, 16 Jul 2014 19:40:22 +0200 Subject: kill OC::$session maintain deprecated \OC::$session when getting or setting the session via the server container or UserSession restore order os OC::$session and OC::$CLI remove unneded initialization of dummy session write back session when $useCustomSession is true log warning when deprecated app is used --- apps/files/ajax/delete.php | 2 +- apps/files/ajax/download.php | 2 +- apps/files/ajax/getstoragestats.php | 2 +- apps/files/ajax/list.php | 2 +- apps/files/ajax/mimeicon.php | 2 +- apps/files/ajax/move.php | 2 +- apps/files/ajax/newfile.php | 2 +- apps/files/ajax/newfolder.php | 2 +- apps/files/ajax/rename.php | 2 +- apps/files/ajax/scan.php | 2 +- apps/files/ajax/upload.php | 2 +- apps/files_encryption/lib/session.php | 22 +++++------ apps/files_external/lib/smb_oc.php | 8 ++-- apps/files_sharing/lib/helper.php | 6 +-- apps/files_sharing/public.php | 6 +-- cron.php | 4 +- lib/base.php | 39 ++++++++++--------- .../dependencyinjection/dicontainer.php | 2 +- lib/private/connector/sabre/auth.php | 2 +- lib/private/server.php | 30 +++++++++------ lib/private/share/share.php | 4 +- lib/private/template.php | 12 +++--- lib/private/user.php | 8 ++-- lib/private/user/session.php | 44 ++++++++++++++++++++-- lib/private/util.php | 16 ++++---- tests/lib/ocs/privatedata.php | 2 +- tests/lib/share/share.php | 6 +-- tests/startsessionlistener.php | 4 +- 28 files changed, 142 insertions(+), 95 deletions(-) (limited to 'lib/private/share') diff --git a/apps/files/ajax/delete.php b/apps/files/ajax/delete.php index aed53d5db5a..323b70706ce 100644 --- a/apps/files/ajax/delete.php +++ b/apps/files/ajax/delete.php @@ -2,7 +2,7 @@ OCP\JSON::checkLoggedIn(); OCP\JSON::callCheck(); -\OC::$session->close(); +\OC::$server->getSession()->close(); // Get data diff --git a/apps/files/ajax/download.php b/apps/files/ajax/download.php index 4b4a7f8948d..b2e144c4b8f 100644 --- a/apps/files/ajax/download.php +++ b/apps/files/ajax/download.php @@ -23,7 +23,7 @@ // Check if we are a user OCP\User::checkLoggedIn(); -\OC::$session->close(); +\OC::$server->getSession()->close(); $files = $_GET["files"]; $dir = $_GET["dir"]; diff --git a/apps/files/ajax/getstoragestats.php b/apps/files/ajax/getstoragestats.php index dd8af39bada..4ab5b9a779c 100644 --- a/apps/files/ajax/getstoragestats.php +++ b/apps/files/ajax/getstoragestats.php @@ -7,7 +7,7 @@ if (isset($_GET['dir'])) { } OCP\JSON::checkLoggedIn(); -\OC::$session->close(); +\OC::$server->getSession()->close(); // send back json OCP\JSON::success(array('data' => \OCA\Files\Helper::buildFileStorageStatistics($dir))); diff --git a/apps/files/ajax/list.php b/apps/files/ajax/list.php index b4641343ed4..2f2f7054566 100644 --- a/apps/files/ajax/list.php +++ b/apps/files/ajax/list.php @@ -1,7 +1,7 @@ close(); +\OC::$server->getSession()->close(); $l = OC_L10N::get('files'); // Load the files diff --git a/apps/files/ajax/mimeicon.php b/apps/files/ajax/mimeicon.php index 6557ff941ac..fdbcc441a78 100644 --- a/apps/files/ajax/mimeicon.php +++ b/apps/files/ajax/mimeicon.php @@ -1,4 +1,4 @@ close(); +\OC::$server->getSession()->close(); print OC_Helper::mimetypeIcon($_GET['mime']); diff --git a/apps/files/ajax/move.php b/apps/files/ajax/move.php index 0a8dbc24a65..e9a34a1b2f9 100644 --- a/apps/files/ajax/move.php +++ b/apps/files/ajax/move.php @@ -2,7 +2,7 @@ OCP\JSON::checkLoggedIn(); OCP\JSON::callCheck(); -\OC::$session->close(); +\OC::$server->getSession()->close(); // Get data $dir = stripslashes($_POST["dir"]); diff --git a/apps/files/ajax/newfile.php b/apps/files/ajax/newfile.php index 9cfe51a6218..8173816af3a 100644 --- a/apps/files/ajax/newfile.php +++ b/apps/files/ajax/newfile.php @@ -7,7 +7,7 @@ if(!OC_User::isLoggedIn()) { exit; } -\OC::$session->close(); +\OC::$server->getSession()->close(); // Get the params $dir = isset( $_REQUEST['dir'] ) ? '/'.trim($_REQUEST['dir'], '/\\') : ''; diff --git a/apps/files/ajax/newfolder.php b/apps/files/ajax/newfolder.php index 89c241189d7..4ea2ee71de2 100644 --- a/apps/files/ajax/newfolder.php +++ b/apps/files/ajax/newfolder.php @@ -5,7 +5,7 @@ OCP\JSON::checkLoggedIn(); OCP\JSON::callCheck(); -\OC::$session->close(); +\OC::$server->getSession()->close(); // Get the params $dir = isset( $_POST['dir'] ) ? stripslashes($_POST['dir']) : ''; diff --git a/apps/files/ajax/rename.php b/apps/files/ajax/rename.php index fa3ddace63d..e5fdf8af98c 100644 --- a/apps/files/ajax/rename.php +++ b/apps/files/ajax/rename.php @@ -23,7 +23,7 @@ OCP\JSON::checkLoggedIn(); OCP\JSON::callCheck(); -\OC::$session->close(); +\OC::$server->getSession()->close(); $files = new \OCA\Files\App( \OC\Files\Filesystem::getView(), diff --git a/apps/files/ajax/scan.php b/apps/files/ajax/scan.php index d5d88483801..3ec7f9394b1 100644 --- a/apps/files/ajax/scan.php +++ b/apps/files/ajax/scan.php @@ -1,6 +1,6 @@ close(); +\OC::$server->getSession()->close(); $force = (isset($_GET['force']) and ($_GET['force'] === 'true')); $dir = isset($_GET['dir']) ? $_GET['dir'] : ''; diff --git a/apps/files/ajax/upload.php b/apps/files/ajax/upload.php index b737d5f8710..4eca13f1933 100644 --- a/apps/files/ajax/upload.php +++ b/apps/files/ajax/upload.php @@ -68,7 +68,7 @@ if (empty($_POST['dirToken'])) { OCP\JSON::callCheck(); if (!\OCP\App::isEnabled('files_encryption')) { // encryption app need to create keys later, so can't close too early - \OC::$session->close(); + \OC::$server->getSession()->close(); } diff --git a/apps/files_encryption/lib/session.php b/apps/files_encryption/lib/session.php index ff8fbd24ecb..7bd4fd02421 100644 --- a/apps/files_encryption/lib/session.php +++ b/apps/files_encryption/lib/session.php @@ -117,7 +117,7 @@ class Session { */ public function setPrivateKey($privateKey) { - \OC::$session->set('privateKey', $privateKey); + \OC::$server->getSession()->set('privateKey', $privateKey); return true; @@ -140,7 +140,7 @@ class Session { */ public function setInitialized($init) { - \OC::$session->set('encryptionInitialized', $init); + \OC::$server->getSession()->set('encryptionInitialized', $init); return true; @@ -150,8 +150,8 @@ class Session { * remove encryption keys and init status from session */ public function closeSession() { - \OC::$session->remove('encryptionInitialized'); - \OC::$session->remove('privateKey'); + \OC::$server->getSession()->remove('encryptionInitialized'); + \OC::$server->getSession()->remove('privateKey'); } @@ -162,8 +162,8 @@ class Session { * @note this doesn not indicate of the init was successful, we just remeber the try! */ public function getInitialized() { - if (!is_null(\OC::$session->get('encryptionInitialized'))) { - return \OC::$session->get('encryptionInitialized'); + if (!is_null(\OC::$server->getSession()->get('encryptionInitialized'))) { + return \OC::$server->getSession()->get('encryptionInitialized'); } else { return self::NOT_INITIALIZED; } @@ -179,8 +179,8 @@ class Session { if (\OCA\Encryption\Helper::isPublicAccess()) { return $this->getPublicSharePrivateKey(); } else { - if (!is_null(\OC::$session->get('privateKey'))) { - return \OC::$session->get('privateKey'); + if (!is_null(\OC::$server->getSession()->get('privateKey'))) { + return \OC::$server->getSession()->get('privateKey'); } else { return false; } @@ -194,7 +194,7 @@ class Session { */ public function setPublicSharePrivateKey($privateKey) { - \OC::$session->set('publicSharePrivateKey', $privateKey); + \OC::$server->getSession()->set('publicSharePrivateKey', $privateKey); return true; @@ -207,8 +207,8 @@ class Session { */ public function getPublicSharePrivateKey() { - if (!is_null(\OC::$session->get('publicSharePrivateKey'))) { - return \OC::$session->get('publicSharePrivateKey'); + if (!is_null(\OC::$server->getSession()->get('publicSharePrivateKey'))) { + return \OC::$server->getSession()->get('publicSharePrivateKey'); } else { return false; } diff --git a/apps/files_external/lib/smb_oc.php b/apps/files_external/lib/smb_oc.php index 0c79c06c5df..e6f3aaf4052 100644 --- a/apps/files_external/lib/smb_oc.php +++ b/apps/files_external/lib/smb_oc.php @@ -14,12 +14,12 @@ class SMB_OC extends \OC\Files\Storage\SMB { private $username_as_share; public function __construct($params) { - if (isset($params['host']) && \OC::$session->exists('smb-credentials')) { + if (isset($params['host']) && \OC::$server->getSession()->exists('smb-credentials')) { $host=$params['host']; $this->username_as_share = ($params['username_as_share'] === 'true'); - $params_auth = \OC::$session->get('smb-credentials'); - $user = \OC::$session->get('loginname'); + $params_auth = \OC::$server->getSession()->get('smb-credentials'); + $user = \OC::$server->getSession()->get('loginname'); $password = $params_auth['password']; $root=isset($params['root'])?$params['root']:'/'; @@ -45,7 +45,7 @@ class SMB_OC extends \OC\Files\Storage\SMB { } public static function login( $params ) { - \OC::$session->set('smb-credentials', $params); + \OC::$server->getSession()->set('smb-credentials', $params); } public function isSharable($path) { diff --git a/apps/files_sharing/lib/helper.php b/apps/files_sharing/lib/helper.php index f444404c2b1..e7ca4fcccd4 100644 --- a/apps/files_sharing/lib/helper.php +++ b/apps/files_sharing/lib/helper.php @@ -106,7 +106,7 @@ class Helper { return false; } else { // Save item id in session for future requests - \OC::$session->set('public_link_authenticated', $linkItem['id']); + \OC::$server->getSession()->set('public_link_authenticated', $linkItem['id']); } } else { \OCP\Util::writeLog('share', 'Unknown share type '.$linkItem['share_type'] @@ -117,8 +117,8 @@ class Helper { } else { // not authenticated ? - if ( ! \OC::$session->exists('public_link_authenticated') - || \OC::$session->get('public_link_authenticated') !== $linkItem['id']) { + if ( ! \OC::$server->getSession()->exists('public_link_authenticated') + || \OC::$server->getSession()->get('public_link_authenticated') !== $linkItem['id']) { return false; } } diff --git a/apps/files_sharing/public.php b/apps/files_sharing/public.php index 746bdf87c17..bcf99d01edb 100644 --- a/apps/files_sharing/public.php +++ b/apps/files_sharing/public.php @@ -63,7 +63,7 @@ if (isset($path)) { exit(); } else { // Save item id in session for future requests - \OC::$session->set('public_link_authenticated', $linkItem['id']); + \OC::$server->getSession()->set('public_link_authenticated', $linkItem['id']); } } else { OCP\Util::writeLog('share', 'Unknown share type '.$linkItem['share_type'] @@ -76,8 +76,8 @@ if (isset($path)) { } else { // Check if item id is set in session - if ( ! \OC::$session->exists('public_link_authenticated') - || \OC::$session->get('public_link_authenticated') !== $linkItem['id'] + if ( ! \OC::$server->getSession()->exists('public_link_authenticated') + || \OC::$server->getSession()->get('public_link_authenticated') !== $linkItem['id'] ) { // Prompt for password OCP\Util::addStyle('files_sharing', 'authenticate'); diff --git a/cron.php b/cron.php index f0acd2f0492..c48f17ed095 100644 --- a/cron.php +++ b/cron.php @@ -56,10 +56,10 @@ try { // load all apps to get all api routes properly setup OC_App::loadApps(); - \OC::$session->close(); + \OC::$server->getSession()->close(); // initialize a dummy memory session - \OC::$session = new \OC\Session\Memory(''); + \OC::$server->setSession(new \OC\Session\Memory('')); $logger = \OC_Log::$object; diff --git a/lib/base.php b/lib/base.php index 1c69d6f5671..2dd107411f0 100644 --- a/lib/base.php +++ b/lib/base.php @@ -71,6 +71,7 @@ class OC { public static $CLI = false; /** + * @deprecated use \OC::$session->getSession() instead * @var \OC\Session\Session */ public static $session = null; @@ -375,19 +376,20 @@ class OC { $cookie_path = OC::$WEBROOT ? : '/'; ini_set('session.cookie_path', $cookie_path); - //set the session object to a dummy session so code relying on the session existing still works - self::$session = new \OC\Session\Memory(''); - // Let the session name be changed in the initSession Hook $sessionName = OC_Util::getInstanceId(); try { // Allow session apps to create a custom session object $useCustomSession = false; - OC_Hook::emit('OC', 'initSession', array('session' => &self::$session, 'sessionName' => &$sessionName, 'useCustomSession' => &$useCustomSession)); - if(!$useCustomSession) { + $session = self::$server->getSession(); + OC_Hook::emit('OC', 'initSession', array('session' => &$session, 'sessionName' => &$sessionName, 'useCustomSession' => &$useCustomSession)); + if($useCustomSession) { + // use the session reference as the new Session + self::$server->setSession($session); + } else { // set the session name to the instance id - which is unique - self::$session = new \OC\Session\Internal($sessionName); + self::$server->setSession(new \OC\Session\Internal($sessionName)); } // if session cant be started break with http 500 error } catch (Exception $e) { @@ -398,15 +400,19 @@ class OC { $sessionLifeTime = self::getSessionLifeTime(); // regenerate session id periodically to avoid session fixation - if (!self::$session->exists('SID_CREATED')) { - self::$session->set('SID_CREATED', time()); - } else if (time() - self::$session->get('SID_CREATED') > $sessionLifeTime / 2) { + /** + * @var \OCP\ISession $session + */ + $session = self::$server->getSession(); + if (!$session->exists('SID_CREATED')) { + $session->set('SID_CREATED', time()); + } else if (time() - $session->get('SID_CREATED') > $sessionLifeTime / 2) { session_regenerate_id(true); - self::$session->set('SID_CREATED', time()); + $session->set('SID_CREATED', time()); } // session timeout - if (self::$session->exists('LAST_ACTIVITY') && (time() - self::$session->get('LAST_ACTIVITY') > $sessionLifeTime)) { + if ($session->exists('LAST_ACTIVITY') && (time() - $session->get('LAST_ACTIVITY') > $sessionLifeTime)) { if (isset($_COOKIE[session_name()])) { setcookie(session_name(), '', time() - 42000, $cookie_path); } @@ -415,7 +421,7 @@ class OC { session_start(); } - self::$session->set('LAST_ACTIVITY', time()); + $session->set('LAST_ACTIVITY', time()); } /** @@ -447,9 +453,6 @@ class OC { self::$loader->registerPrefix('Pimple', '3rdparty/Pimple'); spl_autoload_register(array(self::$loader, 'load')); - // make a dummy session available as early as possible since error pages need it - self::$session = new \OC\Session\Memory(''); - // set some stuff //ob_start(); error_reporting(E_ALL | E_STRICT); @@ -544,7 +547,7 @@ class OC { // User and Groups if (!OC_Config::getValue("installed", false)) { - self::$session->set('user_id', ''); + self::$server->getSession()->set('user_id', ''); } OC_User::useBackend(new OC_User_Database()); @@ -783,7 +786,7 @@ class OC { if (isset($_COOKIE['oc_ignore_php_auth_user'])) { // Ignore HTTP Authentication for 5 more mintues. setcookie('oc_ignore_php_auth_user', $_SERVER['PHP_AUTH_USER'], time() + 300, OC::$WEBROOT.(empty(OC::$WEBROOT) ? '/' : '')); - } elseif ($_SERVER['PHP_AUTH_USER'] === self::$session->get('loginname')) { + } elseif ($_SERVER['PHP_AUTH_USER'] === self::$server->getSession()->get('loginname')) { // Ignore HTTP Authentication to allow a different user to log in. setcookie('oc_ignore_php_auth_user', $_SERVER['PHP_AUTH_USER'], 0, OC::$WEBROOT.(empty(OC::$WEBROOT) ? '/' : '')); } @@ -930,7 +933,7 @@ class OC { if (OC_User::login($_POST["user"], $_POST["password"])) { // setting up the time zone if (isset($_POST['timezone-offset'])) { - self::$session->set('timezone', $_POST['timezone-offset']); + self::$server->getSession()->set('timezone', $_POST['timezone-offset']); } $userid = OC_User::getUser(); diff --git a/lib/private/appframework/dependencyinjection/dicontainer.php b/lib/private/appframework/dependencyinjection/dicontainer.php index 61a2333ecee..e7efa3fa219 100644 --- a/lib/private/appframework/dependencyinjection/dicontainer.php +++ b/lib/private/appframework/dependencyinjection/dicontainer.php @@ -191,7 +191,7 @@ class DIContainer extends SimpleContainer implements IAppContainer{ } private function getUserId() { - return \OC::$session->get('user_id'); + return \OC::$server->getSession()->get('user_id'); } /** diff --git a/lib/private/connector/sabre/auth.php b/lib/private/connector/sabre/auth.php index b1ef698583d..6e1baca9332 100644 --- a/lib/private/connector/sabre/auth.php +++ b/lib/private/connector/sabre/auth.php @@ -78,7 +78,7 @@ class OC_Connector_Sabre_Auth extends \Sabre\DAV\Auth\Backend\AbstractBasic { $result = $this->auth($server, $realm); // close the session - right after authentication there is not need to write to the session any more - \OC::$session->close(); + \OC::$server->getSession()->close(); return $result; } diff --git a/lib/private/server.php b/lib/private/server.php index aab3c82bfeb..53aab7a586a 100644 --- a/lib/private/server.php +++ b/lib/private/server.php @@ -10,6 +10,7 @@ use OC\DB\ConnectionWrapper; use OC\Files\Node\Root; use OC\Files\View; use OCP\IServerContainer; +use OCP\ISession; /** * Class Server @@ -31,8 +32,8 @@ class Server extends SimpleContainer implements IServerContainer { $urlParams = array(); } - if (\OC::$session->exists('requesttoken')) { - $requestToken = \OC::$session->get('requesttoken'); + if (\OC::$server->getSession()->exists('requesttoken')) { + $requestToken = \OC::$server->getSession()->get('requesttoken'); } else { $requestToken = false; } @@ -100,7 +101,7 @@ class Server extends SimpleContainer implements IServerContainer { * @var \OC\User\Manager $manager */ $manager = $c->query('UserManager'); - $userSession = new \OC\User\Session($manager, \OC::$session); + $userSession = new \OC\User\Session($manager, new \OC\Session\Memory('')); $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password)); }); @@ -327,6 +328,20 @@ class Server extends SimpleContainer implements IServerContainer { return $this->query('UserSession'); } + /** + * @return \OCP\ISession + */ + function getSession() { + return $this->query('UserSession')->getSession(); + } + + /** + * @param \OCP\ISession $session + */ + function setSession(\OCP\ISession $session) { + return $this->query('UserSession')->setSession($session); + } + /** * @return \OC\NavigationManager */ @@ -392,15 +407,6 @@ class Server extends SimpleContainer implements IServerContainer { return $this->query('MemCacheFactory'); } - /** - * Returns the current session - * - * @return \OCP\ISession - */ - function getSession() { - return \OC::$session; - } - /** * Returns the current session * diff --git a/lib/private/share/share.php b/lib/private/share/share.php index faa6453d640..c3593beac45 100644 --- a/lib/private/share/share.php +++ b/lib/private/share/share.php @@ -1855,8 +1855,8 @@ class Share extends \OC\Share\Constants { return true; } - if ( \OC::$session->exists('public_link_authenticated') - && \OC::$session->get('public_link_authenticated') === $linkItem['id'] ) { + if ( \OC::$server->getSession()->exists('public_link_authenticated') + && \OC::$server->getSession()->get('public_link_authenticated') === $linkItem['id'] ) { return true; } diff --git a/lib/private/template.php b/lib/private/template.php index 173345cc001..d6afe1a3e40 100644 --- a/lib/private/template.php +++ b/lib/private/template.php @@ -52,7 +52,7 @@ class OC_Template extends \OC\Template\Base { // Read the detected formfactor and use the right file name. $fext = self::getFormFactorExtension(); - $requesttoken = OC::$session ? OC_Util::callRegister() : ''; + $requesttoken = OC::$server->getSession() ? OC_Util::callRegister() : ''; $parts = explode('/', $app); // fix translation when app is something like core/lostpassword $l10n = OC_L10N::get($parts[0]); @@ -101,20 +101,20 @@ class OC_Template extends \OC\Template\Base { */ static public function getFormFactorExtension() { - if (!\OC::$session) { + if (!\OC::$server->getSession()) { return ''; } // if the formfactor is not yet autodetected do the // autodetection now. For possible formfactors check the // detectFormfactor documentation - if (!\OC::$session->exists('formfactor')) { - \OC::$session->set('formfactor', self::detectFormfactor()); + if (!\OC::$server->getSession()->exists('formfactor')) { + \OC::$server->getSession()->set('formfactor', self::detectFormfactor()); } // allow manual override via GET parameter if(isset($_GET['formfactor'])) { - \OC::$session->set('formfactor', $_GET['formfactor']); + \OC::$server->getSession()->set('formfactor', $_GET['formfactor']); } - $formfactor = \OC::$session->get('formfactor'); + $formfactor = \OC::$server->getSession()->get('formfactor'); if($formfactor==='default') { $fext=''; }elseif($formfactor==='mobile') { diff --git a/lib/private/user.php b/lib/private/user.php index cdef4d8fe65..c9b1522f85a 100644 --- a/lib/private/user.php +++ b/lib/private/user.php @@ -300,7 +300,7 @@ class OC_User { * Sets user id for session and triggers emit */ public static function setUserId($uid) { - OC::$session->set('user_id', $uid); + \OC::$server->getSession()->set('user_id', $uid); } /** @@ -337,8 +337,8 @@ class OC_User { * Checks if the user is logged in */ public static function isLoggedIn() { - if (\OC::$session->get('user_id') !== null && self::$incognitoMode === false) { - return self::userExists(\OC::$session->get('user_id')); + if (\OC::$server->getSession()->get('user_id') !== null && self::$incognitoMode === false) { + return self::userExists(\OC::$server->getSession()->get('user_id')); } return false; } @@ -386,7 +386,7 @@ class OC_User { * @return string uid or false */ public static function getUser() { - $uid = OC::$session ? OC::$session->get('user_id') : null; + $uid = \OC::$server->getSession() ? \OC::$server->getSession()->get('user_id') : null; if (!is_null($uid) && self::$incognitoMode === false) { return $uid; } else { diff --git a/lib/private/user/session.php b/lib/private/user/session.php index 6abf8fb80d2..11938db5076 100644 --- a/lib/private/user/session.php +++ b/lib/private/user/session.php @@ -47,10 +47,10 @@ class Session implements IUserSession, Emitter { protected $activeUser; /** - * @param \OC\User\Manager $manager - * @param \OC\Session\Session $session + * @param \OCP\IUserManager $manager + * @param \OCP\ISession $session */ - public function __construct($manager, $session) { + public function __construct(\OCP\IUserManager $manager, \OCP\ISession $session) { $this->manager = $manager; $this->session = $session; } @@ -82,6 +82,44 @@ class Session implements IUserSession, Emitter { return $this->manager; } + /** + * get the session object + * + * @return \OCP\ISession + */ + public function getSession() { + // fetch the deprecated \OC::$session if it changed for backwards compatibility + if (isset(\OC::$session) && \OC::$session !== $this->session) { + \OC::$server->getLogger()->warning( + 'One of your installed apps still seems to use the deprecated '. + '\OC::$session and has replaced it with a new instance. Please file a bug against it.'. + 'Closing and replacing session in UserSession instance.' + ); + $this->setSession(\OC::$session); + } + return $this->session; + } + + /** + * set the session object + * + * @param \OCP\ISession $session + */ + public function setSession(\OCP\ISession $session) { + if ($this->session instanceof \OCP\ISession) { + $this->session->close(); + } + $this->session = $session; + + // maintain deprecated \OC::$session + if (\OC::$session !== $this->session) { + if (\OC::$session instanceof \OCP\ISession) { + \OC::$session->close(); + } + \OC::$session = $session; + } + } + /** * set the currently active user * diff --git a/lib/private/util.php b/lib/private/util.php index 4307560a928..c79f374771c 100755 --- a/lib/private/util.php +++ b/lib/private/util.php @@ -384,11 +384,11 @@ class OC_Util { * @return string timestamp * @description adjust to clients timezone if we know it */ - public static function formatDate($timestamp, $dateOnly = false) { - if (\OC::$session->exists('timezone')) { + public static function formatDate( $timestamp, $dateOnly = false) { + if(\OC::$server->getSession()->exists('timezone')) { $systemTimeZone = intval(date('O')); $systemTimeZone = (round($systemTimeZone / 100, 0) * 60) + ($systemTimeZone % 100); - $clientTimeZone = \OC::$session->get('timezone') * 60; + $clientTimeZone = \OC::$server->getSession()->get('timezone') * 60; $offset = $clientTimeZone - $systemTimeZone; $timestamp = $timestamp + $offset * 60; } @@ -412,7 +412,7 @@ class OC_Util { } // Assume that if checkServer() succeeded before in this session, then all is fine. - if (\OC::$session->exists('checkServer_succeeded') && \OC::$session->get('checkServer_succeeded')) { + if (\OC::$server->getSession()->exists('checkServer_succeeded') && \OC::$server->getSession()->get('checkServer_succeeded')) { return $errors; } @@ -615,7 +615,7 @@ class OC_Util { $errors = array_merge($errors, self::checkDatabaseVersion()); // Cache the result of this function - \OC::$session->set('checkServer_succeeded', count($errors) == 0); + \OC::$server->getSession()->set('checkServer_succeeded', count($errors) == 0); return $errors; } @@ -938,13 +938,13 @@ class OC_Util { */ public static function callRegister() { // Check if a token exists - if (!\OC::$session->exists('requesttoken')) { + if (!\OC::$server->getSession()->exists('requesttoken')) { // No valid token found, generate a new one. $requestToken = self::generateRandomBytes(20); - \OC::$session->set('requesttoken', $requestToken); + \OC::$server->getSession()->set('requesttoken', $requestToken); } else { // Valid token already exists, send it - $requestToken = \OC::$session->get('requesttoken'); + $requestToken = \OC::$server->getSession()->get('requesttoken'); } return ($requestToken); } diff --git a/tests/lib/ocs/privatedata.php b/tests/lib/ocs/privatedata.php index 530750fabea..534fc21b07a 100644 --- a/tests/lib/ocs/privatedata.php +++ b/tests/lib/ocs/privatedata.php @@ -26,7 +26,7 @@ class Test_OC_OCS_Privatedata extends PHPUnit_Framework_TestCase private $appKey; public function setUp() { - \OC::$session->set('user_id', 'user1'); + \OC::$server->getSession()->set('user_id', 'user1'); $this->appKey = uniqid('app'); } diff --git a/tests/lib/share/share.php b/tests/lib/share/share.php index 59056003fca..0a8d7856915 100644 --- a/tests/lib/share/share.php +++ b/tests/lib/share/share.php @@ -740,7 +740,7 @@ class Test_Share extends PHPUnit_Framework_TestCase { * @param $item */ public function testCheckPasswordProtectedShare($expected, $item) { - \OC::$session->set('public_link_authenticated', 100); + \OC::$server->getSession()->set('public_link_authenticated', 100); $result = \OCP\Share::checkPasswordProtectedShare($item); $this->assertEquals($expected, $result); } @@ -767,8 +767,8 @@ class Test_Share extends PHPUnit_Framework_TestCase { return true; } - if ( \OC::$session->exists('public_link_authenticated') - && \OC::$session->get('public_link_authenticated') === $linkItem['id'] ) { + if ( \OC::$server->getSession()->exists('public_link_authenticated') + && \OC::$server->getSession()->get('public_link_authenticated') === $linkItem['id'] ) { return true; } * */ diff --git a/tests/startsessionlistener.php b/tests/startsessionlistener.php index ba049559c6e..1f3573555ca 100644 --- a/tests/startsessionlistener.php +++ b/tests/startsessionlistener.php @@ -31,9 +31,9 @@ class StartSessionListener implements PHPUnit_Framework_TestListener { public function endTest(PHPUnit_Framework_Test $test, $time) { // reopen the session - only allowed for memory session - if (\OC::$session instanceof \OC\Session\Memory) { + if (\OC::$server->getSession() instanceof \OC\Session\Memory) { /** @var $session \OC\Session\Memory */ - $session = \OC::$session; + $session = \OC::$server->getSession(); $session->reopen(); } } -- cgit v1.2.3 From d0266c0bf85e431a3b1b39cbfaced4e8df52a264 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Sun, 31 Aug 2014 10:05:59 +0200 Subject: Use public api for getting l10n --- apps/files/ajax/list.php | 2 +- apps/files/ajax/move.php | 2 +- apps/files/ajax/newfile.php | 2 +- apps/files/ajax/newfolder.php | 2 +- apps/files/ajax/rename.php | 2 +- apps/files/ajax/upload.php | 2 +- apps/files/appinfo/app.php | 2 +- apps/files_encryption/ajax/adminrecovery.php | 2 +- apps/files_encryption/ajax/changeRecoveryPassword.php | 2 +- apps/files_encryption/ajax/updatePrivateKeyPassword.php | 2 +- apps/files_encryption/files/error.php | 2 +- apps/files_external/ajax/dropbox.php | 2 +- apps/files_external/ajax/google.php | 2 +- apps/files_external/appinfo/app.php | 2 +- apps/files_sharing/ajax/external.php | 2 +- apps/files_sharing/appinfo/app.php | 2 +- apps/files_trashbin/ajax/delete.php | 2 +- apps/files_trashbin/ajax/undelete.php | 2 +- apps/files_trashbin/appinfo/app.php | 2 +- apps/files_trashbin/lib/trashbin.php | 2 +- apps/files_versions/ajax/rollbackVersion.php | 2 +- apps/user_ldap/ajax/clearMappings.php | 2 +- apps/user_ldap/ajax/deleteConfiguration.php | 2 +- apps/user_ldap/ajax/testConfiguration.php | 2 +- apps/user_ldap/ajax/wizard.php | 2 +- apps/user_ldap/lib/wizard.php | 2 +- apps/user_ldap/settings.php | 2 +- core/ajax/share.php | 6 +++--- core/ajax/translations.php | 2 +- core/js/config.php | 2 +- core/setup/controller.php | 2 +- core/strings.php | 2 +- lib/base.php | 5 ++--- lib/private/app.php | 4 ++-- lib/private/avatar.php | 4 ++-- lib/private/defaults.php | 2 +- lib/private/installer.php | 6 +++--- lib/private/json.php | 12 ++++++------ lib/private/l10n/factory.php | 7 +++++-- lib/private/server.php | 5 +++-- lib/private/setup.php | 2 +- lib/private/share/mailnotifications.php | 2 +- lib/private/share/share.php | 10 +++++----- lib/private/tags.php | 2 +- lib/private/template.php | 2 +- lib/private/template/functions.php | 2 +- lib/private/user/manager.php | 2 +- lib/private/util.php | 10 +++++----- lib/public/files/locknotacquiredexception.php | 4 ++-- lib/public/util.php | 2 +- settings/admin/controller.php | 4 ++-- settings/ajax/apps/ocs.php | 2 +- settings/ajax/changedisplayname.php | 2 +- settings/ajax/creategroup.php | 2 +- settings/ajax/decryptall.php | 2 +- settings/ajax/deletekeys.php | 2 +- settings/ajax/installapp.php | 2 +- settings/ajax/lostpassword.php | 2 +- settings/ajax/removeuser.php | 4 ++-- settings/ajax/restorekeys.php | 2 +- settings/ajax/setlanguage.php | 2 +- settings/ajax/setquota.php | 2 +- settings/ajax/togglegroups.php | 6 +++--- settings/ajax/uninstallapp.php | 2 +- settings/ajax/updateapp.php | 2 +- settings/personal.php | 2 +- 66 files changed, 97 insertions(+), 94 deletions(-) (limited to 'lib/private/share') diff --git a/apps/files/ajax/list.php b/apps/files/ajax/list.php index 2f2f7054566..16e48a2c2af 100644 --- a/apps/files/ajax/list.php +++ b/apps/files/ajax/list.php @@ -2,7 +2,7 @@ OCP\JSON::checkLoggedIn(); \OC::$server->getSession()->close(); -$l = OC_L10N::get('files'); +$l = \OC::$server->getL10N('files'); // Load the files $dir = isset($_GET['dir']) ? $_GET['dir'] : ''; diff --git a/apps/files/ajax/move.php b/apps/files/ajax/move.php index e9a34a1b2f9..3a07554ad00 100644 --- a/apps/files/ajax/move.php +++ b/apps/files/ajax/move.php @@ -9,7 +9,7 @@ $dir = stripslashes($_POST["dir"]); $file = stripslashes($_POST["file"]); $target = stripslashes(rawurldecode($_POST["target"])); -$l = OC_L10N::get('files'); +$l = \OC::$server->getL10N('files'); if(\OC\Files\Filesystem::file_exists($target . '/' . $file)) { OCP\JSON::error(array("data" => array( "message" => $l->t("Could not move %s - File with this name already exists", array($file)) ))); diff --git a/apps/files/ajax/newfile.php b/apps/files/ajax/newfile.php index 8173816af3a..606576760ec 100644 --- a/apps/files/ajax/newfile.php +++ b/apps/files/ajax/newfile.php @@ -46,7 +46,7 @@ function progress($notification_code, $severity, $message, $message_code, $bytes } } -$l10n = \OC_L10n::get('files'); +$l10n = \OC::$server->getL10N('files'); $result = array( 'success' => false, diff --git a/apps/files/ajax/newfolder.php b/apps/files/ajax/newfolder.php index 4ea2ee71de2..ea7a10c2ab9 100644 --- a/apps/files/ajax/newfolder.php +++ b/apps/files/ajax/newfolder.php @@ -11,7 +11,7 @@ OCP\JSON::callCheck(); $dir = isset( $_POST['dir'] ) ? stripslashes($_POST['dir']) : ''; $foldername = isset( $_POST['foldername'] ) ? stripslashes($_POST['foldername']) : ''; -$l10n = \OC_L10n::get('files'); +$l10n = \OC::$server->getL10N('files'); $result = array( 'success' => false, diff --git a/apps/files/ajax/rename.php b/apps/files/ajax/rename.php index e5fdf8af98c..00c8a1e44db 100644 --- a/apps/files/ajax/rename.php +++ b/apps/files/ajax/rename.php @@ -27,7 +27,7 @@ OCP\JSON::callCheck(); $files = new \OCA\Files\App( \OC\Files\Filesystem::getView(), - \OC_L10n::get('files') + \OC::$server->getL10N('files') ); $result = $files->rename( $_GET["dir"], diff --git a/apps/files/ajax/upload.php b/apps/files/ajax/upload.php index 4eca13f1933..b960e02ced7 100644 --- a/apps/files/ajax/upload.php +++ b/apps/files/ajax/upload.php @@ -10,7 +10,7 @@ OCP\JSON::setContentTypeHeader('text/plain'); $allowedPermissions = OCP\PERMISSION_ALL; $errorCode = null; -$l = OC_L10N::get('files'); +$l = \OC::$server->getL10N('files'); if (empty($_POST['dirToken'])) { // The standard case, files are uploaded through logged in users :) OCP\JSON::checkLoggedIn(); diff --git a/apps/files/appinfo/app.php b/apps/files/appinfo/app.php index 9af36c682fd..3567bc26def 100644 --- a/apps/files/appinfo/app.php +++ b/apps/files/appinfo/app.php @@ -1,6 +1,6 @@ getL10N('files'); OCP\App::registerAdmin('files', 'admin'); diff --git a/apps/files_encryption/ajax/adminrecovery.php b/apps/files_encryption/ajax/adminrecovery.php index 303ba0e16e1..070ca6f667e 100644 --- a/apps/files_encryption/ajax/adminrecovery.php +++ b/apps/files_encryption/ajax/adminrecovery.php @@ -13,7 +13,7 @@ use OCA\Encryption; \OCP\JSON::checkAppEnabled('files_encryption'); \OCP\JSON::callCheck(); -$l = OC_L10N::get('files_encryption'); +$l = \OC::$server->getL10N('files_encryption'); $return = false; // Enable recoveryAdmin diff --git a/apps/files_encryption/ajax/changeRecoveryPassword.php b/apps/files_encryption/ajax/changeRecoveryPassword.php index 99cc7b3cdde..71fbe333fe0 100644 --- a/apps/files_encryption/ajax/changeRecoveryPassword.php +++ b/apps/files_encryption/ajax/changeRecoveryPassword.php @@ -15,7 +15,7 @@ use OCA\Encryption; \OCP\JSON::checkAppEnabled('files_encryption'); \OCP\JSON::callCheck(); -$l = OC_L10N::get('core'); +$l = \OC::$server->getL10N('core'); $return = false; diff --git a/apps/files_encryption/ajax/updatePrivateKeyPassword.php b/apps/files_encryption/ajax/updatePrivateKeyPassword.php index a14c9fe5076..f88e9c64dfd 100644 --- a/apps/files_encryption/ajax/updatePrivateKeyPassword.php +++ b/apps/files_encryption/ajax/updatePrivateKeyPassword.php @@ -15,7 +15,7 @@ use OCA\Encryption; \OCP\JSON::checkAppEnabled('files_encryption'); \OCP\JSON::callCheck(); -$l = OC_L10N::get('core'); +$l = \OC::$server->getL10N('core'); $return = false; diff --git a/apps/files_encryption/files/error.php b/apps/files_encryption/files/error.php index b436587dfaf..c33a5a531f5 100644 --- a/apps/files_encryption/files/error.php +++ b/apps/files_encryption/files/error.php @@ -4,7 +4,7 @@ if (!isset($_)) { //also provide standalone error page require_once __DIR__ . '/../../../lib/base.php'; require_once __DIR__ . '/../lib/crypt.php'; - $l = OC_L10N::get('files_encryption'); + $l = \OC::$server->getL10N('files_encryption'); if (isset($_GET['errorCode'])) { $errorCode = $_GET['errorCode']; diff --git a/apps/files_external/ajax/dropbox.php b/apps/files_external/ajax/dropbox.php index bbedf8e9cac..db417de4b2d 100644 --- a/apps/files_external/ajax/dropbox.php +++ b/apps/files_external/ajax/dropbox.php @@ -5,7 +5,7 @@ require_once __DIR__ . '/../3rdparty/Dropbox/autoload.php'; OCP\JSON::checkAppEnabled('files_external'); OCP\JSON::checkLoggedIn(); OCP\JSON::callCheck(); -$l = OC_L10N::get('files_external'); +$l = \OC::$server->getL10N('files_external'); if (isset($_POST['app_key']) && isset($_POST['app_secret'])) { $oauth = new Dropbox_OAuth_Curl($_POST['app_key'], $_POST['app_secret']); diff --git a/apps/files_external/ajax/google.php b/apps/files_external/ajax/google.php index 13e74071846..40c10aa5d07 100644 --- a/apps/files_external/ajax/google.php +++ b/apps/files_external/ajax/google.php @@ -6,7 +6,7 @@ require_once 'Google_Client.php'; OCP\JSON::checkAppEnabled('files_external'); OCP\JSON::checkLoggedIn(); OCP\JSON::callCheck(); -$l = OC_L10N::get('files_external'); +$l = \OC::$server->getL10N('files_external'); if (isset($_POST['client_id']) && isset($_POST['client_secret']) && isset($_POST['redirect'])) { $client = new Google_Client(); diff --git a/apps/files_external/appinfo/app.php b/apps/files_external/appinfo/app.php index 04c48187e37..50a73bd5f9a 100644 --- a/apps/files_external/appinfo/app.php +++ b/apps/files_external/appinfo/app.php @@ -6,7 +6,7 @@ * later. * See the COPYING-README file. */ -$l = \OC_L10N::get('files_external'); +$l = \OC::$server->getL10N('files_external'); OC::$CLASSPATH['OC\Files\Storage\StreamWrapper'] = 'files_external/lib/streamwrapper.php'; OC::$CLASSPATH['OC\Files\Storage\FTP'] = 'files_external/lib/ftp.php'; diff --git a/apps/files_sharing/ajax/external.php b/apps/files_sharing/ajax/external.php index 37d0607cd3f..544a97e80be 100644 --- a/apps/files_sharing/ajax/external.php +++ b/apps/files_sharing/ajax/external.php @@ -10,7 +10,7 @@ OCP\JSON::callCheck(); OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('files_sharing'); -$l = OC_L10N::get('files_sharing'); +$l = \OC::$server->getL10N('files_sharing'); // check if server admin allows to mount public links from other servers if (OCA\Files_Sharing\Helper::isIncomingServer2serverShareEnabled() === false) { diff --git a/apps/files_sharing/appinfo/app.php b/apps/files_sharing/appinfo/app.php index b22c553ec93..543cae7b0c1 100644 --- a/apps/files_sharing/appinfo/app.php +++ b/apps/files_sharing/appinfo/app.php @@ -1,5 +1,5 @@ getL10N('files_sharing'); OC::$CLASSPATH['OC_Share_Backend_File'] = 'files_sharing/lib/share/file.php'; OC::$CLASSPATH['OC_Share_Backend_Folder'] = 'files_sharing/lib/share/folder.php'; diff --git a/apps/files_trashbin/ajax/delete.php b/apps/files_trashbin/ajax/delete.php index 9d9c1dd100f..a2302802649 100644 --- a/apps/files_trashbin/ajax/delete.php +++ b/apps/files_trashbin/ajax/delete.php @@ -55,7 +55,7 @@ if ( $error ) { foreach ( $error as $e ) { $filelist .= $e.', '; } - $l = OC_L10N::get('files_trashbin'); + $l = \OC::$server->getL10N('files_trashbin'); $message = $l->t("Couldn't delete %s permanently", array(rtrim($filelist, ', '))); OCP\JSON::error(array("data" => array("message" => $message, "success" => $success, "error" => $error))); diff --git a/apps/files_trashbin/ajax/undelete.php b/apps/files_trashbin/ajax/undelete.php index afab79fcac6..02d651925ca 100644 --- a/apps/files_trashbin/ajax/undelete.php +++ b/apps/files_trashbin/ajax/undelete.php @@ -60,7 +60,7 @@ if ( $error ) { foreach ( $error as $e ) { $filelist .= $e.', '; } - $l = OC_L10N::get('files_trashbin'); + $l = OC::$server->getL10N('files_trashbin'); $message = $l->t("Couldn't restore %s", array(rtrim($filelist, ', '))); OCP\JSON::error(array("data" => array("message" => $message, "success" => $success, "error" => $error))); diff --git a/apps/files_trashbin/appinfo/app.php b/apps/files_trashbin/appinfo/app.php index 718c2f45a34..fe428121a25 100644 --- a/apps/files_trashbin/appinfo/app.php +++ b/apps/files_trashbin/appinfo/app.php @@ -1,5 +1,5 @@ getL10N('files_trashbin'); OC::$CLASSPATH['OCA\Files_Trashbin\Exceptions\CopyRecursiveException'] = 'files_trashbin/lib/exceptions.php'; diff --git a/apps/files_trashbin/lib/trashbin.php b/apps/files_trashbin/lib/trashbin.php index ee3969323cf..69eef09d1e9 100644 --- a/apps/files_trashbin/lib/trashbin.php +++ b/apps/files_trashbin/lib/trashbin.php @@ -891,7 +891,7 @@ class Trashbin { private static function getUniqueFilename($location, $filename, $view) { $ext = pathinfo($filename, PATHINFO_EXTENSION); $name = pathinfo($filename, PATHINFO_FILENAME); - $l = \OC_L10N::get('files_trashbin'); + $l = \OC::$server->getL10N('files_trashbin'); // if extension is not empty we set a dot in front of it if ($ext !== '') { diff --git a/apps/files_versions/ajax/rollbackVersion.php b/apps/files_versions/ajax/rollbackVersion.php index 900d8cd6e28..e6133507738 100644 --- a/apps/files_versions/ajax/rollbackVersion.php +++ b/apps/files_versions/ajax/rollbackVersion.php @@ -9,6 +9,6 @@ $revision=(int)$_GET['revision']; if(OCA\Files_Versions\Storage::rollback( $file, $revision )) { OCP\JSON::success(array("data" => array( "revision" => $revision, "file" => $file ))); }else{ - $l = OC_L10N::get('files_versions'); + $l = \OC::$server->getL10N('files_versions'); OCP\JSON::error(array("data" => array( "message" => $l->t("Could not revert: %s", array($file) )))); } diff --git a/apps/user_ldap/ajax/clearMappings.php b/apps/user_ldap/ajax/clearMappings.php index 9118d58c5cf..4e713c59f96 100644 --- a/apps/user_ldap/ajax/clearMappings.php +++ b/apps/user_ldap/ajax/clearMappings.php @@ -30,6 +30,6 @@ $subject = $_POST['ldap_clear_mapping']; if(\OCA\user_ldap\lib\Helper::clearMapping($subject)) { OCP\JSON::success(); } else { - $l=OC_L10N::get('user_ldap'); + $l = \OC::$server->getL10N('user_ldap'); OCP\JSON::error(array('message' => $l->t('Failed to clear the mappings.'))); } diff --git a/apps/user_ldap/ajax/deleteConfiguration.php b/apps/user_ldap/ajax/deleteConfiguration.php index ade57110d34..bca687c81ab 100644 --- a/apps/user_ldap/ajax/deleteConfiguration.php +++ b/apps/user_ldap/ajax/deleteConfiguration.php @@ -30,6 +30,6 @@ $prefix = $_POST['ldap_serverconfig_chooser']; if(\OCA\user_ldap\lib\Helper::deleteServerConfiguration($prefix)) { OCP\JSON::success(); } else { - $l=OC_L10N::get('user_ldap'); + $l = \OC::$server->getL10N('user_ldap'); OCP\JSON::error(array('message' => $l->t('Failed to delete the server configuration'))); } diff --git a/apps/user_ldap/ajax/testConfiguration.php b/apps/user_ldap/ajax/testConfiguration.php index a6375209611..c6372eb2ced 100644 --- a/apps/user_ldap/ajax/testConfiguration.php +++ b/apps/user_ldap/ajax/testConfiguration.php @@ -26,7 +26,7 @@ OCP\JSON::checkAdminUser(); OCP\JSON::checkAppEnabled('user_ldap'); OCP\JSON::callCheck(); -$l=OC_L10N::get('user_ldap'); +$l = \OC::$server->getL10N('user_ldap'); $ldapWrapper = new OCA\user_ldap\lib\LDAP(); $connection = new \OCA\user_ldap\lib\Connection($ldapWrapper, '', null); diff --git a/apps/user_ldap/ajax/wizard.php b/apps/user_ldap/ajax/wizard.php index adbcf6ff414..ef1241b9147 100644 --- a/apps/user_ldap/ajax/wizard.php +++ b/apps/user_ldap/ajax/wizard.php @@ -26,7 +26,7 @@ OCP\JSON::checkAdminUser(); OCP\JSON::checkAppEnabled('user_ldap'); OCP\JSON::callCheck(); -$l=OC_L10N::get('user_ldap'); +$l = \OC::$server->getL10N('user_ldap'); if(!isset($_POST['action'])) { \OCP\JSON::error(array('message' => $l->t('No action specified'))); diff --git a/apps/user_ldap/lib/wizard.php b/apps/user_ldap/lib/wizard.php index 4118b45bc35..dceb2206dbe 100644 --- a/apps/user_ldap/lib/wizard.php +++ b/apps/user_ldap/lib/wizard.php @@ -53,7 +53,7 @@ class Wizard extends LDAPUtility { parent::__construct($ldap); $this->configuration = $configuration; if(is_null(Wizard::$l)) { - Wizard::$l = \OC_L10N::get('user_ldap'); + Wizard::$l = \OC::$server->getL10N('user_ldap'); } $this->access = $access; $this->result = new WizardResult; diff --git a/apps/user_ldap/settings.php b/apps/user_ldap/settings.php index fcde5df3716..e7cdd0d926a 100644 --- a/apps/user_ldap/settings.php +++ b/apps/user_ldap/settings.php @@ -46,7 +46,7 @@ $wControls = $wControls->fetchPage(); $sControls = new OCP\Template('user_ldap', 'part.settingcontrols'); $sControls = $sControls->fetchPage(); -$l = \OC_L10N::get('user_ldap'); +$l = \OC::$server->getL10N('user_ldap'); $wizTabs = array(); $wizTabs[] = array('tpl' => 'part.wizard-server', 'cap' => $l->t('Server')); diff --git a/core/ajax/share.php b/core/ajax/share.php index 451c761c2cd..c6da79a8a42 100644 --- a/core/ajax/share.php +++ b/core/ajax/share.php @@ -90,7 +90,7 @@ if (isset($_POST['action']) && isset($_POST['itemType']) && isset($_POST['itemSo } break; case 'informRecipients': - $l = OC_L10N::get('core'); + $l = \OC::$server->getL10N('core'); $shareType = (int) $_POST['shareType']; $itemType = $_POST['itemType']; $itemSource = $_POST['itemSource']; @@ -153,7 +153,7 @@ if (isset($_POST['action']) && isset($_POST['itemType']) && isset($_POST['itemSo if(empty($result)) { \OCP\JSON::success(); } else { - $l = OC_L10N::get('core'); + $l = \OC::$server->getL10N('core'); OCP\JSON::error(array( 'data' => array( 'message' => $l->t("Couldn't send mail to following users: %s ", @@ -287,7 +287,7 @@ if (isset($_POST['action']) && isset($_POST['itemType']) && isset($_POST['itemSo $count = 0; // enable l10n support - $l = OC_L10N::get('core'); + $l = \OC::$server->getL10N('core'); foreach ($groups as $group) { if ($count < 15) { diff --git a/core/ajax/translations.php b/core/ajax/translations.php index e829453dbcc..c296cea572a 100644 --- a/core/ajax/translations.php +++ b/core/ajax/translations.php @@ -25,6 +25,6 @@ $app = isset($_POST["app"]) ? $_POST["app"] : ""; $app = OC_App::cleanAppId($app); -$l = OC_L10N::get( $app ); +$l = \OC::$server->getL10N($app); OC_JSON::success(array('data' => $l->getTranslations(), 'plural_form' => $l->getPluralFormString())); diff --git a/core/js/config.php b/core/js/config.php index b61694522db..6994f2ed8a2 100644 --- a/core/js/config.php +++ b/core/js/config.php @@ -14,7 +14,7 @@ header("Cache-Control: no-cache, must-revalidate"); header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Enable l10n support -$l = OC_L10N::get('core'); +$l = \OC::$server->getL10N('core'); // Enable OC_Defaults support $defaults = new OC_Defaults(); diff --git a/core/setup/controller.php b/core/setup/controller.php index e764b232e89..91b90e0adef 100644 --- a/core/setup/controller.php +++ b/core/setup/controller.php @@ -132,7 +132,7 @@ class Controller { } if (\OC_Util::runningOnMac()) { - $l10n = \OC_L10N::get('core'); + $l10n = \OC::$server->getL10N('core'); $themeName = \OC_Util::getTheme(); $theme = new \OC_Defaults(); $errors[] = array( diff --git a/core/strings.php b/core/strings.php index 01ab3866089..ebae63bf928 100644 --- a/core/strings.php +++ b/core/strings.php @@ -1,7 +1,7 @@ getL10N('core'); $l->t("Personal"); $l->t("Users"); $l->t("Apps"); diff --git a/lib/base.php b/lib/base.php index 0539814589e..176f799f94d 100644 --- a/lib/base.php +++ b/lib/base.php @@ -193,7 +193,7 @@ class OC { } public static function checkConfig() { - $l = OC_L10N::get('lib'); + $l = \OC::$server->getL10N('lib'); if (file_exists(self::$configDir . "/config.php") and !is_writable(self::$configDir . "/config.php") ) { @@ -574,7 +574,7 @@ class OC { // Check whether the sample configuration has been copied if(OC_Config::getValue('copied_sample_config', false)) { - $l = \OC_L10N::get('lib'); + $l = \OC::$server->getL10N('lib'); header('HTTP/1.1 503 Service Temporarily Unavailable'); header('Status: 503 Service Temporarily Unavailable'); OC_Template::printErrorPage( @@ -672,7 +672,6 @@ class OC { * Handle the request */ public static function handleRequest() { - $l = \OC_L10N::get('lib'); // load all the classpaths from the enabled apps so they are available // in the routing files of each app OC::loadAppClassPaths(); diff --git a/lib/private/app.php b/lib/private/app.php index 70f8980d2c1..d10d352b432 100644 --- a/lib/private/app.php +++ b/lib/private/app.php @@ -359,7 +359,7 @@ class OC_App { * entries are sorted by the key 'order' ascending. */ public static function getSettingsNavigation() { - $l = OC_L10N::get('lib'); + $l = \OC::$server->getL10N('lib'); $settings = array(); // by default, settings only contain the help menu @@ -1094,7 +1094,7 @@ class OC_App { * @throws Exception if no app-name was specified */ public static function installApp($app) { - $l = OC_L10N::get('core'); + $l = \OC::$server->getL10N('core'); $appData=OC_OCSClient::getApplication($app); // check if app is a shipped app or not. OCS apps have an integer as id, shipped apps use a string diff --git a/lib/private/avatar.php b/lib/private/avatar.php index 2286b896878..a9d9346d50a 100644 --- a/lib/private/avatar.php +++ b/lib/private/avatar.php @@ -62,12 +62,12 @@ class OC_Avatar implements \OCP\IAvatar { $type = 'jpg'; } if ($type !== 'jpg' && $type !== 'png') { - $l = \OC_L10N::get('lib'); + $l = \OC::$server->getL10N('lib'); throw new \Exception($l->t("Unknown filetype")); } if (!$img->valid()) { - $l = \OC_L10N::get('lib'); + $l = \OC::$server->getL10N('lib'); throw new \Exception($l->t("Invalid image")); } diff --git a/lib/private/defaults.php b/lib/private/defaults.php index dfd114cd2fe..3996cc081ed 100644 --- a/lib/private/defaults.php +++ b/lib/private/defaults.php @@ -27,7 +27,7 @@ class OC_Defaults { private $defaultMailHeaderColor; function __construct() { - $this->l = OC_L10N::get('lib'); + $this->l = \OC::$server->getL10N('lib'); $version = OC_Util::getVersion(); $this->defaultEntity = 'ownCloud'; /* e.g. company name, used for footers and copyright notices */ diff --git a/lib/private/installer.php b/lib/private/installer.php index dc9a3558b75..02e2190aaf2 100644 --- a/lib/private/installer.php +++ b/lib/private/installer.php @@ -62,7 +62,7 @@ class OC_Installer{ * @return integer */ public static function installApp( $data = array()) { - $l = \OC_L10N::get('lib'); + $l = \OC::$server->getL10N('lib'); list($extractDir, $path) = self::downloadApp($data); $info = self::checkAppsIntegrity($data, $extractDir, $path); @@ -229,7 +229,7 @@ class OC_Installer{ * @throws Exception */ public static function downloadApp($data = array()) { - $l = \OC_L10N::get('lib'); + $l = \OC::$server->getL10N('lib'); if(!isset($data['source'])) { throw new \Exception($l->t("No source specified when installing app")); @@ -285,7 +285,7 @@ class OC_Installer{ * @throws \Exception */ public static function checkAppsIntegrity($data = array(), $extractDir, $path, $isShipped=false) { - $l = \OC_L10N::get('lib'); + $l = \OC::$server->getL10N('lib'); //load the info.xml file of the app if(!is_file($extractDir.'/appinfo/info.xml')) { //try to find it in a subdir diff --git a/lib/private/json.php b/lib/private/json.php index da38654997f..f2719dd2bc7 100644 --- a/lib/private/json.php +++ b/lib/private/json.php @@ -25,7 +25,7 @@ class OC_JSON{ */ public static function checkAppEnabled($app) { if( !OC_App::isEnabled($app)) { - $l = OC_L10N::get('lib'); + $l = \OC::$server->getL10N('lib'); self::error(array( 'data' => array( 'message' => $l->t('Application is not enabled'), 'error' => 'application_not_enabled' ))); exit(); } @@ -36,7 +36,7 @@ class OC_JSON{ */ public static function checkLoggedIn() { if( !OC_User::isLoggedIn()) { - $l = OC_L10N::get('lib'); + $l = \OC::$server->getL10N('lib'); self::error(array( 'data' => array( 'message' => $l->t('Authentication error'), 'error' => 'authentication_error' ))); exit(); } @@ -47,7 +47,7 @@ class OC_JSON{ */ public static function callCheck() { if( !OC_Util::isCallRegistered()) { - $l = OC_L10N::get('lib'); + $l = \OC::$server->getL10N('lib'); self::error(array( 'data' => array( 'message' => $l->t('Token expired. Please reload page.'), 'error' => 'token_expired' ))); exit(); } @@ -58,7 +58,7 @@ class OC_JSON{ */ public static function checkAdminUser() { if( !OC_User::isAdminUser(OC_User::getUser())) { - $l = OC_L10N::get('lib'); + $l = \OC::$server->getL10N('lib'); self::error(array( 'data' => array( 'message' => $l->t('Authentication error'), 'error' => 'authentication_error' ))); exit(); } @@ -70,7 +70,7 @@ class OC_JSON{ */ public static function checkUserExists($user) { if (!OCP\User::userExists($user)) { - $l = OC_L10N::get('lib'); + $l = \OC::$server->getL10N('lib'); OCP\JSON::error(array('data' => array('message' => $l->t('Unknown user'), 'error' => 'unknown_user' ))); exit; } @@ -83,7 +83,7 @@ class OC_JSON{ */ public static function checkSubAdminUser() { if(!OC_SubAdmin::isSubAdmin(OC_User::getUser())) { - $l = OC_L10N::get('lib'); + $l = \OC::$server->getL10N('lib'); self::error(array( 'data' => array( 'message' => $l->t('Authentication error'), 'error' => 'authentication_error' ))); exit(); } diff --git a/lib/private/l10n/factory.php b/lib/private/l10n/factory.php index d0c3799b9c2..fcc3f3e3394 100644 --- a/lib/private/l10n/factory.php +++ b/lib/private/l10n/factory.php @@ -20,12 +20,15 @@ class Factory { /** * get an L10N instance + * * @param string $app * @param string|null $lang * @return \OC_L10N */ - public function get($app) { - if (!isset($this->instances[$app])) { + public function get($app, $lang = null) { + if (!is_null($lang)) { + return new \OC_L10N($app, $lang); + } else if (!isset($this->instances[$app])) { $this->instances[$app] = new \OC_L10N($app); } return $this->instances[$app]; diff --git a/lib/private/server.php b/lib/private/server.php index 53aab7a586a..bf1801a5ce8 100644 --- a/lib/private/server.php +++ b/lib/private/server.php @@ -369,10 +369,11 @@ class Server extends SimpleContainer implements IServerContainer { * get an L10N instance * * @param string $app appid + * @param string $lang * @return \OC_L10N */ - function getL10N($app) { - return $this->query('L10NFactory')->get($app); + function getL10N($app, $lang = null) { + return $this->query('L10NFactory')->get($app, $lang); } /** diff --git a/lib/private/setup.php b/lib/private/setup.php index fdf98ab0959..2e23aae8838 100644 --- a/lib/private/setup.php +++ b/lib/private/setup.php @@ -15,7 +15,7 @@ class OC_Setup { ); public static function getTrans(){ - return OC_L10N::get('lib'); + return \OC::$server->getL10N('lib'); } public static function install($options) { diff --git a/lib/private/share/mailnotifications.php b/lib/private/share/mailnotifications.php index 1f4645eed9f..4a92503bdd3 100644 --- a/lib/private/share/mailnotifications.php +++ b/lib/private/share/mailnotifications.php @@ -52,7 +52,7 @@ class MailNotifications { * @param string $sender user id (if nothing is set we use the currently logged-in user) */ public function __construct($sender = null) { - $this->l = \OC_L10N::get('core'); + $this->l = \OC::$server->getL10N('core'); $this->senderId = $sender; diff --git a/lib/private/share/share.php b/lib/private/share/share.php index c3593beac45..e2e9b94125e 100644 --- a/lib/private/share/share.php +++ b/lib/private/share/share.php @@ -479,7 +479,7 @@ class Share extends \OC\Share\Constants { public static function shareItem($itemType, $itemSource, $shareType, $shareWith, $permissions, $itemSourceName = null, \DateTime $expirationDate = null) { $uidOwner = \OC_User::getUser(); $shareWithinGroupOnly = self::shareWithGroupMembersOnly(); - $l = \OC_L10N::get('lib'); + $l = \OC::$server->getL10N('lib'); if (is_null($itemSourceName)) { $itemSourceName = $itemSource; @@ -849,7 +849,7 @@ class Share extends \OC\Share\Constants { * @return boolean true on success or false on failure */ public static function setPermissions($itemType, $itemSource, $shareType, $shareWith, $permissions) { - $l = \OC_L10N::get('lib'); + $l = \OC::$server->getL10N('lib'); if ($item = self::getItems($itemType, $itemSource, $shareType, $shareWith, \OC_User::getUser(), self::FORMAT_NONE, null, 1, false)) { // Check if this item is a reshare and verify that the permissions @@ -938,7 +938,7 @@ class Share extends \OC\Share\Constants { * @throws \Exception */ private static function validateExpireDate($expireDate, $shareTime, $itemType, $itemSource) { - $l = \OC_L10N::get('lib'); + $l = \OC::$server->getL10N('lib'); $date = new \DateTime($expireDate); $today = new \DateTime('now'); @@ -1083,7 +1083,7 @@ class Share extends \OC\Share\Constants { * @return \OCP\Share_Backend */ public static function getBackend($itemType) { - $l = \OC_L10N::get('lib'); + $l = \OC::$server->getL10N('lib'); if (isset(self::$backends[$itemType])) { return self::$backends[$itemType]; } else if (isset(self::$backendTypes[$itemType]['class'])) { @@ -1516,7 +1516,7 @@ class Share extends \OC\Share\Constants { private static function put($itemType, $itemSource, $shareType, $shareWith, $uidOwner, $permissions, $parentFolder = null, $token = null, $itemSourceName = null, \DateTime $expirationDate = null) { $backend = self::getBackend($itemType); - $l = \OC_L10N::get('lib'); + $l = \OC::$server->getL10N('lib'); // Check if this is a reshare if ($checkReshare = self::getItemSharedWithBySource($itemType, $itemSource, self::FORMAT_NONE, null, true)) { diff --git a/lib/private/tags.php b/lib/private/tags.php index 0b62caf2dd8..0e58789ecd5 100644 --- a/lib/private/tags.php +++ b/lib/private/tags.php @@ -178,7 +178,7 @@ class Tags implements \OCP\ITags { } if($tagId === false) { - $l10n = \OC_L10N::get('core'); + $l10n = \OC::$server->getL10N('core'); throw new \Exception( $l10n->t('Could not find category "%s"', $tag) ); diff --git a/lib/private/template.php b/lib/private/template.php index 73fa53a2fa3..d95943a714c 100644 --- a/lib/private/template.php +++ b/lib/private/template.php @@ -56,7 +56,7 @@ class OC_Template extends \OC\Template\Base { $requesttoken = (OC::$server->getSession() and $registerCall) ? OC_Util::callRegister() : ''; $parts = explode('/', $app); // fix translation when app is something like core/lostpassword - $l10n = OC_L10N::get($parts[0]); + $l10n = \OC::$server->getL10N($parts[0]); $themeDefaults = new OC_Defaults(); list($path, $template) = $this->findTemplate($theme, $app, $name, $fext); diff --git a/lib/private/template/functions.php b/lib/private/template/functions.php index 46e48274001..3cbf0d9748f 100644 --- a/lib/private/template/functions.php +++ b/lib/private/template/functions.php @@ -117,7 +117,7 @@ function strip_time($timestamp){ * @return OC_L10N_String timestamp */ function relative_modified_date($timestamp, $fromTime = null, $dateOnly = false) { - $l=OC_L10N::get('lib'); + $l = \OC::$server->getL10N('lib'); if (!isset($fromTime) || $fromTime === null){ $fromTime = time(); } diff --git a/lib/private/user/manager.php b/lib/private/user/manager.php index a54755e71c5..5c155c27aba 100644 --- a/lib/private/user/manager.php +++ b/lib/private/user/manager.php @@ -237,7 +237,7 @@ class Manager extends PublicEmitter implements IUserManager { * @return bool|\OC\User\User the created user of false */ public function createUser($uid, $password) { - $l = \OC_L10N::get('lib'); + $l = \OC::$server->getL10N('lib'); // Check the name for bad characters // Allowed are: "a-z", "A-Z", "0-9" and "_.@-" if (preg_match('/[^a-zA-Z0-9 _\.@\-]/', $uid)) { diff --git a/lib/private/util.php b/lib/private/util.php index ad078e8a44c..adb7fb83d28 100755 --- a/lib/private/util.php +++ b/lib/private/util.php @@ -392,7 +392,7 @@ class OC_Util { $offset = $clientTimeZone - $systemTimeZone; $timestamp = $timestamp + $offset * 60; } - $l = OC_L10N::get('lib'); + $l = \OC::$server->getL10N('lib'); return $l->l($dateOnly ? 'date' : 'datetime', $timestamp); } @@ -402,7 +402,7 @@ class OC_Util { * @return array arrays with error messages and hints */ public static function checkServer() { - $l = OC_L10N::get('lib'); + $l = \OC::$server->getL10N('lib'); $errors = array(); $CONFIG_DATADIRECTORY = OC_Config::getValue('datadirectory', OC::$SERVERROOT . '/data'); @@ -626,7 +626,7 @@ class OC_Util { * @return array errors array */ public static function checkDatabaseVersion() { - $l = OC_L10N::get('lib'); + $l = \OC::$server->getL10N('lib'); $errors = array(); $dbType = \OC_Config::getValue('dbtype', 'sqlite'); if ($dbType === 'pgsql') { @@ -707,7 +707,7 @@ class OC_Util { * @return array arrays with error messages and hints */ public static function checkDataDirectoryPermissions($dataDirectory) { - $l = OC_L10N::get('lib'); + $l = \OC::$server->getL10N('lib'); $errors = array(); if (self::runningOnWindows()) { //TODO: permissions checks for windows hosts @@ -738,7 +738,7 @@ class OC_Util { * @return bool true if the data directory is valid, false otherwise */ public static function checkDataDirectoryValidity($dataDirectory) { - $l = OC_L10N::get('lib'); + $l = \OC::$server->getL10N('lib'); $errors = array(); if (!file_exists($dataDirectory . '/.ocdata')) { $errors[] = array( diff --git a/lib/public/files/locknotacquiredexception.php b/lib/public/files/locknotacquiredexception.php index 9fb70e7cbe2..647b07bf878 100644 --- a/lib/public/files/locknotacquiredexception.php +++ b/lib/public/files/locknotacquiredexception.php @@ -36,7 +36,7 @@ class LockNotAcquiredException extends \Exception { public $lockType; public function __construct($path, $lockType, $code = 0, \Exception $previous = null) { - $message = \OC_L10N::get('core')->t('Could not obtain lock type %d on "%s".', array($lockType, $path)); + $message = \OC::$server->getL10N('core')->t('Could not obtain lock type %d on "%s".', array($lockType, $path)); parent::__construct($message, $code, $previous); } @@ -44,4 +44,4 @@ class LockNotAcquiredException extends \Exception { public function __toString() { return __CLASS__ . ": [{$this->code}]: {$this->message}\n"; } -} \ No newline at end of file +} diff --git a/lib/public/util.php b/lib/public/util.php index 87b7a4f19db..bc1b90a2c89 100644 --- a/lib/public/util.php +++ b/lib/public/util.php @@ -132,7 +132,7 @@ class Util { * @return \OC_L10N */ public static function getL10N($application, $language = null) { - return \OC_L10N::get($application, $language); + return \OC::$server->getL10N($application, $language); } /** diff --git a/settings/admin/controller.php b/settings/admin/controller.php index 7ced57791e9..395bc7c6e49 100644 --- a/settings/admin/controller.php +++ b/settings/admin/controller.php @@ -27,7 +27,7 @@ class Controller { \OC_Util::checkAdminUser(); \OCP\JSON::callCheck(); - $l = \OC_L10N::get('settings'); + $l = \OC::$server->getL10N('settings'); $smtp_settings = array( 'mail_domain' => null, @@ -80,7 +80,7 @@ class Controller { \OC_Util::checkAdminUser(); \OCP\JSON::callCheck(); - $l = \OC_L10N::get('settings'); + $l = \OC::$server->getL10N('settings'); $email = \OC_Preferences::getValue(\OC_User::getUser(), 'settings', 'email', ''); if (!empty($email)) { $defaults = new \OC_Defaults(); diff --git a/settings/ajax/apps/ocs.php b/settings/ajax/apps/ocs.php index b68083fca6b..aad0690e01c 100644 --- a/settings/ajax/apps/ocs.php +++ b/settings/ajax/apps/ocs.php @@ -8,7 +8,7 @@ OC_JSON::checkAdminUser(); -$l = OC_L10N::get('settings'); +$l = \OC::$server->getL10N('settings'); if(OC_Config::getValue('appstoreenabled', true)==false) { OCP\JSON::success(array('type' => 'external', 'data' => array())); diff --git a/settings/ajax/changedisplayname.php b/settings/ajax/changedisplayname.php index 54c8c05dd4b..1e52182ccf6 100644 --- a/settings/ajax/changedisplayname.php +++ b/settings/ajax/changedisplayname.php @@ -4,7 +4,7 @@ OCP\JSON::callCheck(); OC_JSON::checkLoggedIn(); -$l=OC_L10N::get('settings'); +$l = \OC::$server->getL10N('settings'); $username = isset($_POST["username"]) ? $_POST["username"] : OC_User::getUser(); $displayName = $_POST["displayName"]; diff --git a/settings/ajax/creategroup.php b/settings/ajax/creategroup.php index 854f2c37189..be376bea9dc 100644 --- a/settings/ajax/creategroup.php +++ b/settings/ajax/creategroup.php @@ -4,7 +4,7 @@ OCP\JSON::callCheck(); OC_JSON::checkAdminUser(); $groupname = $_POST["groupname"]; -$l = OC_L10N::get('settings'); +$l = \OC::$server->getL10N('settings'); // Does the group exist? if( in_array( $groupname, OC_Group::getGroups())) { diff --git a/settings/ajax/decryptall.php b/settings/ajax/decryptall.php index 55685f778d1..527e5b8fcee 100644 --- a/settings/ajax/decryptall.php +++ b/settings/ajax/decryptall.php @@ -12,7 +12,7 @@ $params = array('uid' => \OCP\User::getUser(), $view = new OC\Files\View('/'); $util = new \OCA\Encryption\Util($view, \OCP\User::getUser()); -$l = \OC_L10N::get('settings'); +$l = \OC::$server->getL10N('settings'); $result = $util->initEncryption($params); diff --git a/settings/ajax/deletekeys.php b/settings/ajax/deletekeys.php index 1f84452e117..86a45820af9 100644 --- a/settings/ajax/deletekeys.php +++ b/settings/ajax/deletekeys.php @@ -3,7 +3,7 @@ OCP\JSON::checkLoggedIn(); OCP\JSON::callCheck(); -$l = \OC_L10N::get('settings'); +$l = \OC::$server->getL10N('settings'); $user = \OC_User::getUser(); $view = new \OC\Files\View('/' . $user . '/files_encryption'); diff --git a/settings/ajax/installapp.php b/settings/ajax/installapp.php index 47f40f2b0cd..80bc1819724 100644 --- a/settings/ajax/installapp.php +++ b/settings/ajax/installapp.php @@ -14,6 +14,6 @@ $result = OC_App::installApp($appId); if($result !== false) { OC_JSON::success(array('data' => array('appid' => $appId))); } else { - $l = OC_L10N::get('settings'); + $l = \OC::$server->getL10N('settings'); OC_JSON::error(array("data" => array( "message" => $l->t("Couldn't remove app.") ))); } diff --git a/settings/ajax/lostpassword.php b/settings/ajax/lostpassword.php index 15b6cbc0122..395ba31f92b 100644 --- a/settings/ajax/lostpassword.php +++ b/settings/ajax/lostpassword.php @@ -3,7 +3,7 @@ OC_JSON::checkLoggedIn(); OCP\JSON::callCheck(); -$l=OC_L10N::get('settings'); +$l = \OC::$server->getL10N('settings'); // Get data if( isset( $_POST['email'] ) && OC_Mail::validateAddress($_POST['email']) ) { diff --git a/settings/ajax/removeuser.php b/settings/ajax/removeuser.php index 8732c6518a8..eda85238780 100644 --- a/settings/ajax/removeuser.php +++ b/settings/ajax/removeuser.php @@ -11,7 +11,7 @@ if(OC_User::getUser() === $username) { } if(!OC_User::isAdminUser(OC_User::getUser()) && !OC_SubAdmin::isUserAccessible(OC_User::getUser(), $username)) { - $l = OC_L10N::get('core'); + $l = \OC::$server->getL10N('core'); OC_JSON::error(array( 'data' => array( 'message' => $l->t('Authentication error') ))); exit(); } @@ -21,6 +21,6 @@ if( OC_User::deleteUser( $username )) { OC_JSON::success(array("data" => array( "username" => $username ))); } else{ - $l = OC_L10N::get('core'); + $l = \OC::$server->getL10N('core'); OC_JSON::error(array("data" => array( "message" => $l->t("Unable to delete user") ))); } diff --git a/settings/ajax/restorekeys.php b/settings/ajax/restorekeys.php index 68e19c90457..5c263fadab4 100644 --- a/settings/ajax/restorekeys.php +++ b/settings/ajax/restorekeys.php @@ -3,7 +3,7 @@ OCP\JSON::checkLoggedIn(); OCP\JSON::callCheck(); -$l = \OC_L10N::get('settings'); +$l = \OC::$server->getL10N('settings'); $user = \OC_User::getUser(); $view = new \OC\Files\View('/' . $user . '/files_encryption'); diff --git a/settings/ajax/setlanguage.php b/settings/ajax/setlanguage.php index 94773f3dc70..a3988db85bb 100644 --- a/settings/ajax/setlanguage.php +++ b/settings/ajax/setlanguage.php @@ -1,6 +1,6 @@ getL10N('settings'); OC_JSON::checkLoggedIn(); OCP\JSON::callCheck(); diff --git a/settings/ajax/setquota.php b/settings/ajax/setquota.php index 2e6de2b759c..f19506a0456 100644 --- a/settings/ajax/setquota.php +++ b/settings/ajax/setquota.php @@ -13,7 +13,7 @@ $username = isset($_POST["username"])?$_POST["username"]:''; if(($username === '' && !OC_User::isAdminUser(OC_User::getUser())) || (!OC_User::isAdminUser(OC_User::getUser()) && !OC_SubAdmin::isUserAccessible(OC_User::getUser(), $username))) { - $l = OC_L10N::get('core'); + $l = \OC::$server->getL10N('core'); OC_JSON::error(array( 'data' => array( 'message' => $l->t('Authentication error') ))); exit(); } diff --git a/settings/ajax/togglegroups.php b/settings/ajax/togglegroups.php index 6963f9eb43c..27cb2b446ec 100644 --- a/settings/ajax/togglegroups.php +++ b/settings/ajax/togglegroups.php @@ -8,7 +8,7 @@ $username = $_POST["username"]; $group = $_POST["group"]; if($username === OC_User::getUser() && $group === "admin" && OC_User::isAdminUser($username)) { - $l = OC_L10N::get('core'); + $l = \OC::$server->getL10N('core'); OC_JSON::error(array( 'data' => array( 'message' => $l->t('Admins can\'t remove themself from the admin group')))); exit(); } @@ -16,7 +16,7 @@ if($username === OC_User::getUser() && $group === "admin" && OC_User::isAdminUs if(!OC_User::isAdminUser(OC_User::getUser()) && (!OC_SubAdmin::isUserAccessible(OC_User::getUser(), $username) || !OC_SubAdmin::isGroupAccessible(OC_User::getUser(), $group))) { - $l = OC_L10N::get('core'); + $l = \OC::$server->getL10N('core'); OC_JSON::error(array( 'data' => array( 'message' => $l->t('Authentication error') ))); exit(); } @@ -25,7 +25,7 @@ if(!OC_Group::groupExists($group)) { OC_Group::createGroup($group); } -$l = OC_L10N::get('settings'); +$l = \OC::$server->getL10N('settings'); $error = $l->t("Unable to add user to group %s", $group); $action = "add"; diff --git a/settings/ajax/uninstallapp.php b/settings/ajax/uninstallapp.php index 5c6371dc16f..cae7c33f292 100644 --- a/settings/ajax/uninstallapp.php +++ b/settings/ajax/uninstallapp.php @@ -14,6 +14,6 @@ $result = OC_App::removeApp($appId); if($result !== false) { OC_JSON::success(array('data' => array('appid' => $appId))); } else { - $l = OC_L10N::get('settings'); + $l = \OC::$server->getL10N('settings'); OC_JSON::error(array("data" => array( "message" => $l->t("Couldn't remove app.") ))); } diff --git a/settings/ajax/updateapp.php b/settings/ajax/updateapp.php index afaa9318fb2..6375a41024a 100644 --- a/settings/ajax/updateapp.php +++ b/settings/ajax/updateapp.php @@ -40,6 +40,6 @@ $result = OC_Installer::updateAppByOCSId($appId, $isShipped); if($result !== false) { OC_JSON::success(array('data' => array('appid' => $appId))); } else { - $l = OC_L10N::get('settings'); + $l = \OC::$server->getL10N('settings'); OC_JSON::error(array("data" => array( "message" => $l->t("Couldn't update app.") ))); } diff --git a/settings/personal.php b/settings/personal.php index a72b293413a..b290d6a959e 100644 --- a/settings/personal.php +++ b/settings/personal.php @@ -46,7 +46,7 @@ $languageNames=include 'languageCodes.php'; $languages=array(); $commonlanguages = array(); foreach($languageCodes as $lang) { - $l=OC_L10N::get('settings', $lang); + $l = \OC::$server->getL10N('settings', $lang); if(substr($l->t('__language_name__'), 0, 1) !== '_') {//first check if the language name is in the translation file $ln=array('code'=>$lang, 'name'=> (string)$l->t('__language_name__')); }elseif(isset($languageNames[$lang])) { -- cgit v1.2.3