diff options
Diffstat (limited to 'lib')
65 files changed, 534 insertions, 316 deletions
diff --git a/lib/base.php b/lib/base.php index 2feedd81d8c..d3e483f4948 100644 --- a/lib/base.php +++ b/lib/base.php @@ -131,8 +131,8 @@ class OC { OC::$THIRDPARTYROOT = rtrim(dirname(OC::$SERVERROOT), '/'); } else { throw new Exception('3rdparty directory not found! Please put the ownCloud 3rdparty' - .' folder in the ownCloud folder or the folder above.' - .' You can also configure the location in the config.php file.'); + . ' folder in the ownCloud folder or the folder above.' + . ' You can also configure the location in the config.php file.'); } // search the apps folder $config_paths = OC_Config::getValue('apps_paths', array()); @@ -156,7 +156,7 @@ class OC { if (empty(OC::$APPSROOTS)) { throw new Exception('apps directory not found! Please put the ownCloud apps folder in the ownCloud folder' - .' or the folder above. You can also configure the location in the config.php file.'); + . ' or the folder above. You can also configure the location in the config.php file.'); } $paths = array(); foreach (OC::$APPSROOTS as $path) { @@ -176,7 +176,8 @@ class OC { public static function checkConfig() { if (file_exists(OC::$SERVERROOT . "/config/config.php") - and !is_writable(OC::$SERVERROOT . "/config/config.php")) { + and !is_writable(OC::$SERVERROOT . "/config/config.php") + ) { $defaults = new OC_Defaults(); if (self::$CLI) { echo "Can't write into config directory!\n"; @@ -188,7 +189,7 @@ class OC { OC_Template::printErrorPage( "Can't write into config directory!", 'This can usually be fixed by ' - .'<a href="' . \OC_Helper::linkToDocs('admin-dir_permissions') . '" target="_blank">giving the webserver write access to the config directory</a>.' + . '<a href="' . \OC_Helper::linkToDocs('admin-dir_permissions') . '" target="_blank">giving the webserver write access to the config directory</a>.' ); } } @@ -254,30 +255,42 @@ class OC { } } - public static function checkUpgrade($showTemplate = true) { + /** + * check if the instance needs to preform an upgrade + * + * @return bool + */ + public static function needUpgrade() { if (OC_Config::getValue('installed', false)) { $installedVersion = OC_Config::getValue('version', '0.0.0'); $currentVersion = implode('.', OC_Util::getVersion()); - if (version_compare($currentVersion, $installedVersion, '>')) { - if ($showTemplate && !OC_Config::getValue('maintenance', false)) { - OC_Config::setValue('theme', ''); - $minimizerCSS = new OC_Minimizer_CSS(); - $minimizerCSS->clearCache(); - $minimizerJS = new OC_Minimizer_JS(); - $minimizerJS->clearCache(); - OC_Util::addScript('update'); - $tmpl = new OC_Template('', 'update.admin', 'guest'); - $tmpl->assign('version', OC_Util::getVersionString()); - $tmpl->printPage(); - exit(); - } else { - return true; - } - } + return version_compare($currentVersion, $installedVersion, '>'); + } else { return false; } } + public static function checkUpgrade($showTemplate = true) { + if (self::needUpgrade()) { + if ($showTemplate && !OC_Config::getValue('maintenance', false)) { + OC_Config::setValue('theme', ''); + $minimizerCSS = new OC_Minimizer_CSS(); + $minimizerCSS->clearCache(); + $minimizerJS = new OC_Minimizer_JS(); + $minimizerJS->clearCache(); + OC_Util::addScript('config'); // needed for web root + OC_Util::addScript('update'); + $tmpl = new OC_Template('', 'update.admin', 'guest'); + $tmpl->assign('version', OC_Util::getVersionString()); + $tmpl->printPage(); + exit(); + } else { + return true; + } + } + return false; + } + public static function initTemplateEngine() { // Add the stuff we need always OC_Util::addScript("jquery-1.10.0.min"); @@ -461,7 +474,7 @@ class OC { // OC_Util::getInstanceId() for namespacing. See #5409. try { self::$loader->setMemoryCache(\OC\Memcache\Factory::createLowLatency('Autoloader')); - } catch(\Exception $ex) { + } catch (\Exception $ex) { } } OC_Util::isSetLocaleWorking(); @@ -506,7 +519,7 @@ class OC { if (count($errors) > 0) { if (self::$CLI) { foreach ($errors as $error) { - echo $error['error']."\n"; + echo $error['error'] . "\n"; echo $error['hint'] . "\n\n"; } } else { @@ -528,8 +541,8 @@ class OC { OC_Group::useBackend(new OC_Group_Database()); if (isset($_SERVER['PHP_AUTH_USER']) && self::$session->exists('user_id') - && $_SERVER['PHP_AUTH_USER'] != self::$session->get('user_id')) { - $sessionUser = self::$session->get('user_id'); + && $_SERVER['PHP_AUTH_USER'] !== self::$session->get('loginname')) { + $sessionUser = self::$session->get('loginname'); $serverUser = $_SERVER['PHP_AUTH_USER']; OC_Log::write('core', "Session user-id ($sessionUser) doesn't match SERVER[PHP_AUTH_USER] ($serverUser).", @@ -601,13 +614,9 @@ class OC { * register hooks for the cache */ public static function registerCacheHooks() { - if (OC_Config::getValue('installed', false)) { //don't try to do this before we are properly setup - // register cache cleanup jobs - try { //if this is executed before the upgrade to the new backgroundjob system is completed it will throw an exception - \OCP\BackgroundJob::registerJob('OC\Cache\FileGlobalGC'); - } catch (Exception $e) { + if (OC_Config::getValue('installed', false) && !self::needUpgrade()) { //don't try to do this before we are properly setup + \OCP\BackgroundJob::registerJob('OC\Cache\FileGlobalGC'); - } // NOTE: This will be replaced to use OCP $userSession = \OC_User::getUserSession(); $userSession->listen('postLogin', '\OC\Cache\File', 'loginListener'); @@ -618,14 +627,9 @@ class OC { * register hooks for the cache */ public static function registerLogRotate() { - if (OC_Config::getValue('installed', false) && OC_Config::getValue('log_rotate_size', false)) { + if (OC_Config::getValue('installed', false) && OC_Config::getValue('log_rotate_size', false) && !self::needUpgrade()) { //don't try to do this before we are properly setup - // register cache cleanup jobs - try { //if this is executed before the upgrade to the new backgroundjob system is completed it will throw an exception - \OCP\BackgroundJob::registerJob('OC\Log\Rotate', OC_Config::getValue("datadirectory", OC::$SERVERROOT.'/data').'/owncloud.log'); - } catch (Exception $e) { - - } + \OCP\BackgroundJob::registerJob('OC\Log\Rotate', OC_Config::getValue("datadirectory", OC::$SERVERROOT . '/data') . '/owncloud.log'); } } @@ -652,7 +656,7 @@ class OC { * register hooks for sharing */ public static function registerShareHooks() { - if(\OC_Config::getValue('installed')) { + if (\OC_Config::getValue('installed')) { OC_Hook::connect('OC_User', 'post_deleteUser', 'OCP\Share', 'post_deleteUser'); OC_Hook::connect('OC_User', 'post_addToGroup', 'OCP\Share', 'post_addToGroup'); OC_Hook::connect('OC_User', 'post_removeFromGroup', 'OCP\Share', 'post_removeFromGroup'); @@ -675,7 +679,7 @@ class OC { } $request = OC_Request::getPathInfo(); - if(substr($request, -3) !== '.js') {// we need these files during the upgrade + if (substr($request, -3) !== '.js') { // we need these files during the upgrade self::checkMaintenanceMode(); self::checkUpgrade(); } @@ -793,18 +797,16 @@ class OC { // auth possible via apache module? if (OC::tryApacheAuth()) { $error[] = 'apacheauthfailed'; - } - // remember was checked after last login + } // remember was checked after last login elseif (OC::tryRememberLogin()) { $error[] = 'invalidcookie'; - } - // logon via web form + } // logon via web form elseif (OC::tryFormLogin()) { $error[] = 'invalidpassword'; if ( OC_Config::getValue('log_authfailip', false) ) { OC_Log::write('core', 'Login failed: user \''.$_POST["user"].'\' , wrong password, IP:'.$_SERVER['REMOTE_ADDR'], OC_Log::WARN); - } else { + } else { OC_Log::write('core', 'Login failed: user \''.$_POST["user"].'\' , wrong password, IP:set log_authfailip=true in conf', OC_Log::WARN); } @@ -866,7 +868,6 @@ class OC { OC_User::setMagicInCookie($_COOKIE['oc_username'], $token); // login OC_User::setUserId($_COOKIE['oc_username']); - OC_User::setDisplayName($_COOKIE['oc_username'], $_COOKIE['display_name']); OC_Util::redirectToDefaultPage(); // doesn't return } diff --git a/lib/l10n/az.php b/lib/l10n/az.php new file mode 100644 index 00000000000..e7b09649a24 --- /dev/null +++ b/lib/l10n/az.php @@ -0,0 +1,8 @@ +<?php +$TRANSLATIONS = array( +"_%n minute ago_::_%n minutes ago_" => array(""), +"_%n hour ago_::_%n hours ago_" => array(""), +"_%n day go_::_%n days ago_" => array(""), +"_%n month ago_::_%n months ago_" => array("") +); +$PLURAL_FORMS = "nplurals=1; plural=0;"; diff --git a/lib/l10n/ca.php b/lib/l10n/ca.php index e7250befc2f..4755392d271 100644 --- a/lib/l10n/ca.php +++ b/lib/l10n/ca.php @@ -65,7 +65,6 @@ $TRANSLATIONS = array( "last month" => "el mes passat", "_%n month ago_::_%n months ago_" => array("fa %n mes","fa %n mesos"), "last year" => "l'any passat", -"years ago" => "anys enrere", -"Caused by:" => "Provocat per:" +"years ago" => "anys enrere" ); $PLURAL_FORMS = "nplurals=2; plural=(n != 1);"; diff --git a/lib/l10n/cs_CZ.php b/lib/l10n/cs_CZ.php index 96d3660c473..df3a47b5ae3 100644 --- a/lib/l10n/cs_CZ.php +++ b/lib/l10n/cs_CZ.php @@ -65,7 +65,6 @@ $TRANSLATIONS = array( "last month" => "minulý měsíc", "_%n month ago_::_%n months ago_" => array("před %n měsícem","před %n měsíci","před %n měsíci"), "last year" => "minulý rok", -"years ago" => "před lety", -"Caused by:" => "Příčina:" +"years ago" => "před lety" ); $PLURAL_FORMS = "nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;"; diff --git a/lib/l10n/da.php b/lib/l10n/da.php index f95aa30d7a0..074b89a00ea 100644 --- a/lib/l10n/da.php +++ b/lib/l10n/da.php @@ -64,7 +64,6 @@ $TRANSLATIONS = array( "last month" => "sidste måned", "_%n month ago_::_%n months ago_" => array("%n måned siden","%n måneder siden"), "last year" => "sidste år", -"years ago" => "år siden", -"Caused by:" => "Forårsaget af:" +"years ago" => "år siden" ); $PLURAL_FORMS = "nplurals=2; plural=(n != 1);"; diff --git a/lib/l10n/de.php b/lib/l10n/de.php index 5b09d350a7d..b1045892fb1 100644 --- a/lib/l10n/de.php +++ b/lib/l10n/de.php @@ -18,17 +18,17 @@ $TRANSLATIONS = array( "Selected files too large to generate zip file." => "Die gewählten Dateien sind zu groß, um eine ZIP-Datei zu erstellen.", "Please download the files separately in smaller chunks or kindly ask your administrator." => "Bitte lade die Dateien einzeln in kleineren Teilen herunter oder bitte Deinen Administrator.", "No source specified when installing app" => "Für die Installation der Applikation wurde keine Quelle angegeben", -"No href specified when installing app from http" => "Der Link (href) wurde nicht angegeben um die Applikation per http zu installieren", +"No href specified when installing app from http" => "Für die Installation der Applikation über http wurde keine Quelle (href) angegeben", "No path specified when installing app from local file" => "Bei der Installation der Applikation aus einer lokalen Datei wurde kein Pfad angegeben", "Archives of type %s are not supported" => "Archive vom Typ %s werden nicht unterstützt", "Failed to open archive when installing app" => "Das Archiv konnte bei der Installation der Applikation nicht geöffnet werden", "App does not provide an info.xml file" => "Die Applikation enthält keine info,xml Datei", -"App can't be installed because of not allowed code in the App" => "Die Applikation kann auf Grund von unerlaubten Code nicht installiert werden", +"App can't be installed because of not allowed code in the App" => "Die Applikation kann auf Grund von unerlaubtem Code nicht installiert werden", "App can't be installed because it is not compatible with this version of ownCloud" => "Die Anwendung konnte nicht installiert werden, weil Sie nicht mit dieser Version von ownCloud kompatibel ist.", -"App can't be installed because it contains the <shipped>true</shipped> tag which is not allowed for non shipped apps" => "Die Applikation konnte nicht installiert werden, da diese das <shipped>true</shipped> Tag beinhaltet und dieses, bei nicht mitausgelieferten Applikationen, nicht erlaubt ist ist", +"App can't be installed because it contains the <shipped>true</shipped> tag which is not allowed for non shipped apps" => "Die Applikation konnte nicht installiert werden, da diese das <shipped>true</shipped> Tag beinhaltet und dieses, bei nicht mitausgelieferten Applikationen, nicht erlaubt ist", "App can't be installed because the version in info.xml/version is not the same as the version reported from the app store" => "Die Applikation konnte nicht installiert werden, da die Version in der info.xml nicht die gleiche Version wie im App-Store ist", "App directory already exists" => "Das Applikationsverzeichnis existiert bereits", -"Can't create app folder. Please fix permissions. %s" => "Es kann kein Applikationsordner erstellt werden. Bitte passen sie die Berechtigungen an. %s", +"Can't create app folder. Please fix permissions. %s" => "Es kann kein Applikationsordner erstellt werden. Bitte passe die Berechtigungen an. %s", "Application is not enabled" => "Die Anwendung ist nicht aktiviert", "Authentication error" => "Fehler bei der Anmeldung", "Token expired. Please reload page." => "Token abgelaufen. Bitte lade die Seite neu.", @@ -65,7 +65,6 @@ $TRANSLATIONS = array( "last month" => "Letzten Monat", "_%n month ago_::_%n months ago_" => array("Vor %n Monat","Vor %n Monaten"), "last year" => "Letztes Jahr", -"years ago" => "Vor Jahren", -"Caused by:" => "Verursacht durch:" +"years ago" => "Vor Jahren" ); $PLURAL_FORMS = "nplurals=2; plural=(n != 1);"; diff --git a/lib/l10n/de_CH.php b/lib/l10n/de_CH.php index 502791ff578..7325aad931e 100644 --- a/lib/l10n/de_CH.php +++ b/lib/l10n/de_CH.php @@ -52,7 +52,6 @@ $TRANSLATIONS = array( "last month" => "Letzten Monat", "_%n month ago_::_%n months ago_" => array("","Vor %n Monaten"), "last year" => "Letztes Jahr", -"years ago" => "Vor Jahren", -"Caused by:" => "Verursacht durch:" +"years ago" => "Vor Jahren" ); $PLURAL_FORMS = "nplurals=2; plural=(n != 1);"; diff --git a/lib/l10n/de_DE.php b/lib/l10n/de_DE.php index e76718b4117..1a1c9783f42 100644 --- a/lib/l10n/de_DE.php +++ b/lib/l10n/de_DE.php @@ -65,7 +65,6 @@ $TRANSLATIONS = array( "last month" => "Letzten Monat", "_%n month ago_::_%n months ago_" => array("Vor %n Monat","Vor %n Monaten"), "last year" => "Letztes Jahr", -"years ago" => "Vor Jahren", -"Caused by:" => "Verursacht durch:" +"years ago" => "Vor Jahren" ); $PLURAL_FORMS = "nplurals=2; plural=(n != 1);"; diff --git a/lib/l10n/el.php b/lib/l10n/el.php index d536b699a9e..1de06407c32 100644 --- a/lib/l10n/el.php +++ b/lib/l10n/el.php @@ -50,7 +50,6 @@ $TRANSLATIONS = array( "last month" => "τελευταίο μήνα", "_%n month ago_::_%n months ago_" => array("",""), "last year" => "τελευταίο χρόνο", -"years ago" => "χρόνια πριν", -"Caused by:" => "Προκλήθηκε από:" +"years ago" => "χρόνια πριν" ); $PLURAL_FORMS = "nplurals=2; plural=(n != 1);"; diff --git a/lib/l10n/en_GB.php b/lib/l10n/en_GB.php index 295700d234a..e2e8ee2e541 100644 --- a/lib/l10n/en_GB.php +++ b/lib/l10n/en_GB.php @@ -65,7 +65,6 @@ $TRANSLATIONS = array( "last month" => "last month", "_%n month ago_::_%n months ago_" => array("%n month ago","%n months ago"), "last year" => "last year", -"years ago" => "years ago", -"Caused by:" => "Caused by:" +"years ago" => "years ago" ); $PLURAL_FORMS = "nplurals=2; plural=(n != 1);"; diff --git a/lib/l10n/es.php b/lib/l10n/es.php index 1412d49c2f5..f231cd2bb6e 100644 --- a/lib/l10n/es.php +++ b/lib/l10n/es.php @@ -65,7 +65,6 @@ $TRANSLATIONS = array( "last month" => "mes pasado", "_%n month ago_::_%n months ago_" => array("Hace %n mes","Hace %n meses"), "last year" => "año pasado", -"years ago" => "hace años", -"Caused by:" => "Causado por:" +"years ago" => "hace años" ); $PLURAL_FORMS = "nplurals=2; plural=(n != 1);"; diff --git a/lib/l10n/es_AR.php b/lib/l10n/es_AR.php index e2c771d47ad..bc5fcd7e012 100644 --- a/lib/l10n/es_AR.php +++ b/lib/l10n/es_AR.php @@ -64,7 +64,6 @@ $TRANSLATIONS = array( "last month" => "el mes pasado", "_%n month ago_::_%n months ago_" => array("Hace %n mes","Hace %n meses"), "last year" => "el año pasado", -"years ago" => "años atrás", -"Caused by:" => "Provocado por:" +"years ago" => "años atrás" ); $PLURAL_FORMS = "nplurals=2; plural=(n != 1);"; diff --git a/lib/l10n/es_CL.php b/lib/l10n/es_CL.php new file mode 100644 index 00000000000..46158b0ccc7 --- /dev/null +++ b/lib/l10n/es_CL.php @@ -0,0 +1,10 @@ +<?php +$TRANSLATIONS = array( +"Settings" => "Configuración", +"Files" => "Archivos", +"_%n minute ago_::_%n minutes ago_" => array("",""), +"_%n hour ago_::_%n hours ago_" => array("",""), +"_%n day go_::_%n days ago_" => array("",""), +"_%n month ago_::_%n months ago_" => array("","") +); +$PLURAL_FORMS = "nplurals=2; plural=(n != 1);"; diff --git a/lib/l10n/et_EE.php b/lib/l10n/et_EE.php index 7340ee72c28..96fceaa04ed 100644 --- a/lib/l10n/et_EE.php +++ b/lib/l10n/et_EE.php @@ -65,7 +65,6 @@ $TRANSLATIONS = array( "last month" => "viimasel kuul", "_%n month ago_::_%n months ago_" => array("","%n kuud tagasi"), "last year" => "viimasel aastal", -"years ago" => "aastat tagasi", -"Caused by:" => "Põhjustaja:" +"years ago" => "aastat tagasi" ); $PLURAL_FORMS = "nplurals=2; plural=(n != 1);"; diff --git a/lib/l10n/eu.php b/lib/l10n/eu.php index f28a77eeb03..e3f18fca47a 100644 --- a/lib/l10n/eu.php +++ b/lib/l10n/eu.php @@ -1,17 +1,34 @@ <?php $TRANSLATIONS = array( +"App \"%s\" can't be installed because it is not compatible with this version of ownCloud." => "\"%s\" Aplikazioa ezin da instalatu ownCloud bertsio honekin bateragarria ez delako", +"No app name specified" => "Ez da aplikazioaren izena zehaztu", "Help" => "Laguntza", "Personal" => "Pertsonala", "Settings" => "Ezarpenak", "Users" => "Erabiltzaileak", "Admin" => "Admin", "Failed to upgrade \"%s\"." => "Ezin izan da \"%s\" eguneratu.", +"Unknown filetype" => "Fitxategi mota ezezaguna", +"Invalid image" => "Baliogabeko irudia", "web services under your control" => "web zerbitzuak zure kontrolpean", "cannot open \"%s\"" => "ezin da \"%s\" ireki", "ZIP download is turned off." => "ZIP deskarga ez dago gaituta.", "Files need to be downloaded one by one." => "Fitxategiak banan-banan deskargatu behar dira.", "Back to Files" => "Itzuli fitxategietara", "Selected files too large to generate zip file." => "Hautatuko fitxategiak oso handiak dira zip fitxategia sortzeko.", +"Please download the files separately in smaller chunks or kindly ask your administrator." => "Mesedez deskargatu fitzategiak zati txikiagoetan, banan-banan edo eskatu mesedez zure administradoreari.", +"No source specified when installing app" => "Ez da jatorririk zehaztu aplikazioa instalatzerakoan", +"No href specified when installing app from http" => "Ez da href parametrorik zehaztu http bidez aplikazioa instalatzerakoan", +"No path specified when installing app from local file" => "Ez da kokalekurik zehaztu fitxategi lokal moduan aplikazioa instalatzerakoan", +"Archives of type %s are not supported" => "%s motako fitxategiak ez dira onartzen", +"Failed to open archive when installing app" => "Fitxategia irekitzeak huts egin du aplikazioa instalatzerakoan", +"App does not provide an info.xml file" => "Aplikazioak ez du info.xml fitxategia", +"App can't be installed because of not allowed code in the App" => "Aplikazioa ezin da instalatu bertan duen baimendu gabeko kodea dela eta", +"App can't be installed because it is not compatible with this version of ownCloud" => "Aplikazioa ezin da instalatu ownCloud bertsio honekin bateragarria ez delako", +"App can't be installed because it contains the <shipped>true</shipped> tag which is not allowed for non shipped apps" => "Aplikazioa ezin da instalatu <shipped>true</shipped> etiketa duelako eta etiketa hau ez da onartzen banaketan ez datozen aplikazioetan", +"App can't be installed because the version in info.xml/version is not the same as the version reported from the app store" => "Aplikazioa ezin da instalatu info.xml/version bertsioa ez delako \"app store\"an jartzen duenaren berdina", +"App directory already exists" => "Aplikazioaren karpeta dagoeneko existitzen da", +"Can't create app folder. Please fix permissions. %s" => "Ezin izan da aplikazioaren karpeta sortu. Mesdez konpondu baimenak. %s", "Application is not enabled" => "Aplikazioa ez dago gaituta", "Authentication error" => "Autentifikazio errorea", "Token expired. Please reload page." => "Tokena iraungitu da. Mesedez birkargatu orria.", @@ -48,7 +65,6 @@ $TRANSLATIONS = array( "last month" => "joan den hilabetean", "_%n month ago_::_%n months ago_" => array("orain dela hilabete %n","orain dela %n hilabete"), "last year" => "joan den urtean", -"years ago" => "urte", -"Caused by:" => "Honek eraginda:" +"years ago" => "urte" ); $PLURAL_FORMS = "nplurals=2; plural=(n != 1);"; diff --git a/lib/l10n/fi_FI.php b/lib/l10n/fi_FI.php index 68f51d34441..573704da44c 100644 --- a/lib/l10n/fi_FI.php +++ b/lib/l10n/fi_FI.php @@ -16,8 +16,10 @@ $TRANSLATIONS = array( "Back to Files" => "Takaisin tiedostoihin", "Selected files too large to generate zip file." => "Valitut tiedostot ovat liian suurikokoisia mahtuakseen zip-tiedostoon.", "No source specified when installing app" => "Lähdettä ei määritelty sovellusta asennettaessa", +"No href specified when installing app from http" => "Href-määritettä ei asetettu asennettaessa sovellusta http:n yli", "No path specified when installing app from local file" => "Polkua ei määritelty sovellusta asennettaessa paikallisesta tiedostosta", "Archives of type %s are not supported" => "Tyypin %s arkistot eivät ole tuettuja", +"Failed to open archive when installing app" => "Pakettitiedoston avaaminen epäonnistui sovellusta asennettaessa", "App does not provide an info.xml file" => "Sovellus ei sisällä info.xml-tiedostoa", "App can't be installed because of not allowed code in the App" => "Sovellusta ei voi asentaa, koska sovellus sisältää kiellettyä koodia", "App can't be installed because it is not compatible with this version of ownCloud" => "Sovellusta ei voi asentaa, koska se ei ole yhteensopiva käytössä olevan ownCloud-version kanssa", @@ -55,7 +57,6 @@ $TRANSLATIONS = array( "last month" => "viime kuussa", "_%n month ago_::_%n months ago_" => array("%n kuukausi sitten","%n kuukautta sitten"), "last year" => "viime vuonna", -"years ago" => "vuotta sitten", -"Caused by:" => "Aiheuttaja:" +"years ago" => "vuotta sitten" ); $PLURAL_FORMS = "nplurals=2; plural=(n != 1);"; diff --git a/lib/l10n/fr.php b/lib/l10n/fr.php index 82d5739e540..75a4f277271 100644 --- a/lib/l10n/fr.php +++ b/lib/l10n/fr.php @@ -65,7 +65,6 @@ $TRANSLATIONS = array( "last month" => "le mois dernier", "_%n month ago_::_%n months ago_" => array("","Il y a %n mois"), "last year" => "l'année dernière", -"years ago" => "il y a plusieurs années", -"Caused by:" => "Causé par :" +"years ago" => "il y a plusieurs années" ); $PLURAL_FORMS = "nplurals=2; plural=(n > 1);"; diff --git a/lib/l10n/gl.php b/lib/l10n/gl.php index cf13408b2cd..81a62021556 100644 --- a/lib/l10n/gl.php +++ b/lib/l10n/gl.php @@ -65,7 +65,6 @@ $TRANSLATIONS = array( "last month" => "último mes", "_%n month ago_::_%n months ago_" => array("hai %n mes","hai %n meses"), "last year" => "último ano", -"years ago" => "anos atrás", -"Caused by:" => "Causado por:" +"years ago" => "anos atrás" ); $PLURAL_FORMS = "nplurals=2; plural=(n != 1);"; diff --git a/lib/l10n/hu_HU.php b/lib/l10n/hu_HU.php index 0d91b70b51a..efaf2a2fd48 100644 --- a/lib/l10n/hu_HU.php +++ b/lib/l10n/hu_HU.php @@ -16,6 +16,7 @@ $TRANSLATIONS = array( "Files need to be downloaded one by one." => "A fájlokat egyenként kell letölteni.", "Back to Files" => "Vissza a Fájlokhoz", "Selected files too large to generate zip file." => "A kiválasztott fájlok túl nagyok a zip tömörítéshez.", +"Please download the files separately in smaller chunks or kindly ask your administrator." => "A file-t kisebb részekben töltsd le vagy beszélj az adminisztrátorral a megoldás érdekében.", "No source specified when installing app" => "Az alkalmazás telepítéséhez nincs forrás megadva", "No href specified when installing app from http" => "Az alkalmazás http-n keresztül történő telepítéséhez nincs href hivetkozás megadva", "No path specified when installing app from local file" => "Az alkalmazás helyi telepítéséhez nincs útvonal (mappa) megadva", @@ -64,7 +65,6 @@ $TRANSLATIONS = array( "last month" => "múlt hónapban", "_%n month ago_::_%n months ago_" => array("%n hónappal ezelőtt","%n hónappal ezelőtt"), "last year" => "tavaly", -"years ago" => "több éve", -"Caused by:" => "Okozta:" +"years ago" => "több éve" ); $PLURAL_FORMS = "nplurals=2; plural=(n != 1);"; diff --git a/lib/l10n/it.php b/lib/l10n/it.php index b1259a0a874..cd2073bfd0a 100644 --- a/lib/l10n/it.php +++ b/lib/l10n/it.php @@ -65,7 +65,6 @@ $TRANSLATIONS = array( "last month" => "mese scorso", "_%n month ago_::_%n months ago_" => array("%n mese fa","%n mesi fa"), "last year" => "anno scorso", -"years ago" => "anni fa", -"Caused by:" => "Causato da:" +"years ago" => "anni fa" ); $PLURAL_FORMS = "nplurals=2; plural=(n != 1);"; diff --git a/lib/l10n/ja_JP.php b/lib/l10n/ja_JP.php index d7baf176a14..9c5c0ba4763 100644 --- a/lib/l10n/ja_JP.php +++ b/lib/l10n/ja_JP.php @@ -65,7 +65,6 @@ $TRANSLATIONS = array( "last month" => "一月前", "_%n month ago_::_%n months ago_" => array("%n ヶ月前"), "last year" => "一年前", -"years ago" => "年前", -"Caused by:" => "原因:" +"years ago" => "年前" ); $PLURAL_FORMS = "nplurals=1; plural=0;"; diff --git a/lib/l10n/ko.php b/lib/l10n/ko.php index 102bf9f978d..86494c76802 100644 --- a/lib/l10n/ko.php +++ b/lib/l10n/ko.php @@ -64,7 +64,6 @@ $TRANSLATIONS = array( "last month" => "지난 달", "_%n month ago_::_%n months ago_" => array("%n달 전 "), "last year" => "작년", -"years ago" => "년 전", -"Caused by:" => "원인: " +"years ago" => "년 전" ); $PLURAL_FORMS = "nplurals=1; plural=0;"; diff --git a/lib/l10n/lt_LT.php b/lib/l10n/lt_LT.php index 17bbb856e43..25957702d2d 100644 --- a/lib/l10n/lt_LT.php +++ b/lib/l10n/lt_LT.php @@ -65,7 +65,6 @@ $TRANSLATIONS = array( "last month" => "praeitą mėnesį", "_%n month ago_::_%n months ago_" => array("Prieš %n mėnesį","Prieš %n mėnesius","Prieš %n mėnesių"), "last year" => "praeitais metais", -"years ago" => "prieš metus", -"Caused by:" => "Iššaukė:" +"years ago" => "prieš metus" ); $PLURAL_FORMS = "nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && (n%100<10 || n%100>=20) ? 1 : 2);"; diff --git a/lib/l10n/lv.php b/lib/l10n/lv.php index ef5fd2d5ca8..8ecee5bdae8 100644 --- a/lib/l10n/lv.php +++ b/lib/l10n/lv.php @@ -48,7 +48,6 @@ $TRANSLATIONS = array( "last month" => "pagājušajā mēnesī", "_%n month ago_::_%n months ago_" => array("","","Pirms %n mēnešiem"), "last year" => "gājušajā gadā", -"years ago" => "gadus atpakaļ", -"Caused by:" => "Cēlonis:" +"years ago" => "gadus atpakaļ" ); $PLURAL_FORMS = "nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n != 0 ? 1 : 2);"; diff --git a/lib/l10n/nl.php b/lib/l10n/nl.php index 0254ce81886..2f6205fcf1c 100644 --- a/lib/l10n/nl.php +++ b/lib/l10n/nl.php @@ -65,7 +65,6 @@ $TRANSLATIONS = array( "last month" => "vorige maand", "_%n month ago_::_%n months ago_" => array("%n maand geleden","%n maanden geleden"), "last year" => "vorig jaar", -"years ago" => "jaar geleden", -"Caused by:" => "Gekomen door:" +"years ago" => "jaar geleden" ); $PLURAL_FORMS = "nplurals=2; plural=(n != 1);"; diff --git a/lib/l10n/pl.php b/lib/l10n/pl.php index 82d4f753a81..fe3e876916a 100644 --- a/lib/l10n/pl.php +++ b/lib/l10n/pl.php @@ -16,6 +16,7 @@ $TRANSLATIONS = array( "Files need to be downloaded one by one." => "Pliki muszą zostać pobrane pojedynczo.", "Back to Files" => "Wróć do plików", "Selected files too large to generate zip file." => "Wybrane pliki są zbyt duże, aby wygenerować plik zip.", +"Please download the files separately in smaller chunks or kindly ask your administrator." => "Proszę ściągać pliki osobno w mniejszych paczkach lub poprosić administratora.", "No source specified when installing app" => "Nie określono źródła podczas instalacji aplikacji", "No href specified when installing app from http" => "Nie określono linku skąd aplikacja ma być zainstalowana", "No path specified when installing app from local file" => "Nie określono lokalnego pliku z którego miała być instalowana aplikacja", @@ -64,7 +65,6 @@ $TRANSLATIONS = array( "last month" => "w zeszłym miesiącu", "_%n month ago_::_%n months ago_" => array("%n miesiąc temu","%n miesięcy temu","%n miesięcy temu"), "last year" => "w zeszłym roku", -"years ago" => "lat temu", -"Caused by:" => "Spowodowane przez:" +"years ago" => "lat temu" ); $PLURAL_FORMS = "nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);"; diff --git a/lib/l10n/pt_BR.php b/lib/l10n/pt_BR.php index d6912f07110..cc20fb3cb02 100644 --- a/lib/l10n/pt_BR.php +++ b/lib/l10n/pt_BR.php @@ -65,7 +65,6 @@ $TRANSLATIONS = array( "last month" => "último mês", "_%n month ago_::_%n months ago_" => array("","ha %n meses"), "last year" => "último ano", -"years ago" => "anos atrás", -"Caused by:" => "Causados por:" +"years ago" => "anos atrás" ); $PLURAL_FORMS = "nplurals=2; plural=(n > 1);"; diff --git a/lib/l10n/pt_PT.php b/lib/l10n/pt_PT.php index 2b12b4d8a17..bd9165ebb1a 100644 --- a/lib/l10n/pt_PT.php +++ b/lib/l10n/pt_PT.php @@ -16,10 +16,17 @@ $TRANSLATIONS = array( "Files need to be downloaded one by one." => "Os ficheiros precisam de ser descarregados um por um.", "Back to Files" => "Voltar a Ficheiros", "Selected files too large to generate zip file." => "Os ficheiros seleccionados são grandes demais para gerar um ficheiro zip.", +"Please download the files separately in smaller chunks or kindly ask your administrator." => "Por favor descarregue os ficheiros divididos em partes mais pequenas ou peça ajuda ao seu administrador.", +"No source specified when installing app" => "Não foi especificada uma fonte de instalação desta aplicação", +"No href specified when installing app from http" => "Não foi especificada uma href http para instalar esta aplicação", +"No path specified when installing app from local file" => "Não foi especificado o caminho de instalação desta aplicação", "Archives of type %s are not supported" => "Arquivos do tipo %s não são suportados", +"Failed to open archive when installing app" => "Ocorreu um erro ao abrir o ficheiro de instalação desta aplicação", "App does not provide an info.xml file" => "A aplicação não disponibiliza um ficheiro info.xml", "App can't be installed because of not allowed code in the App" => "A aplicação não pode ser instalado devido a código não permitido dentro da aplicação", "App can't be installed because it is not compatible with this version of ownCloud" => "A aplicação não pode ser instalada por não ser compatível com esta versão do ownCloud", +"App can't be installed because it contains the <shipped>true</shipped> tag which is not allowed for non shipped apps" => "Esta aplicação não pode ser instalada por que contém o tag <shipped>true</shipped> que só é permitido para aplicações nativas", +"App can't be installed because the version in info.xml/version is not the same as the version reported from the app store" => "Esta aplicação não pode ser instalada porque a versão no info.xml/version não coincide com a reportada na loja de aplicações", "App directory already exists" => "A directoria da aplicação já existe", "Can't create app folder. Please fix permissions. %s" => "Não foi possível criar a pasta da aplicação. Por favor verifique as permissões. %s", "Application is not enabled" => "A aplicação não está activada", @@ -58,7 +65,6 @@ $TRANSLATIONS = array( "last month" => "ultímo mês", "_%n month ago_::_%n months ago_" => array("","%n meses atrás"), "last year" => "ano passado", -"years ago" => "anos atrás", -"Caused by:" => "Causado por:" +"years ago" => "anos atrás" ); $PLURAL_FORMS = "nplurals=2; plural=(n != 1);"; diff --git a/lib/l10n/ru.php b/lib/l10n/ru.php index baf80cbf24e..34d1730aaf2 100644 --- a/lib/l10n/ru.php +++ b/lib/l10n/ru.php @@ -65,7 +65,6 @@ $TRANSLATIONS = array( "last month" => "в прошлом месяце", "_%n month ago_::_%n months ago_" => array("%n месяц назад","%n месяца назад","%n месяцев назад"), "last year" => "в прошлом году", -"years ago" => "несколько лет назад", -"Caused by:" => "Вызвано:" +"years ago" => "несколько лет назад" ); $PLURAL_FORMS = "nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);"; diff --git a/lib/l10n/sk_SK.php b/lib/l10n/sk_SK.php index 18b455780d1..59c45e2b0bc 100644 --- a/lib/l10n/sk_SK.php +++ b/lib/l10n/sk_SK.php @@ -65,7 +65,6 @@ $TRANSLATIONS = array( "last month" => "minulý mesiac", "_%n month ago_::_%n months ago_" => array("pred %n mesiacom","pred %n mesiacmi","pred %n mesiacmi"), "last year" => "minulý rok", -"years ago" => "pred rokmi", -"Caused by:" => "Príčina:" +"years ago" => "pred rokmi" ); $PLURAL_FORMS = "nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;"; diff --git a/lib/l10n/sl.php b/lib/l10n/sl.php index 69067c2691f..3cc8dd130c8 100644 --- a/lib/l10n/sl.php +++ b/lib/l10n/sl.php @@ -65,7 +65,6 @@ $TRANSLATIONS = array( "last month" => "zadnji mesec", "_%n month ago_::_%n months ago_" => array("pred %n mesecem","pred %n mesecema","pred %n meseci","pred %n meseci"), "last year" => "lansko leto", -"years ago" => "let nazaj", -"Caused by:" => "Vzrok:" +"years ago" => "let nazaj" ); $PLURAL_FORMS = "nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3);"; diff --git a/lib/l10n/sv.php b/lib/l10n/sv.php index 4f04cbe3159..ffffe5956f1 100644 --- a/lib/l10n/sv.php +++ b/lib/l10n/sv.php @@ -65,7 +65,6 @@ $TRANSLATIONS = array( "last month" => "förra månaden", "_%n month ago_::_%n months ago_" => array("%n månad sedan","%n månader sedan"), "last year" => "förra året", -"years ago" => "år sedan", -"Caused by:" => "Orsakad av:" +"years ago" => "år sedan" ); $PLURAL_FORMS = "nplurals=2; plural=(n != 1);"; diff --git a/lib/l10n/tr.php b/lib/l10n/tr.php index 093984bb952..d4abbcd4b3c 100644 --- a/lib/l10n/tr.php +++ b/lib/l10n/tr.php @@ -65,7 +65,6 @@ $TRANSLATIONS = array( "last month" => "geçen ay", "_%n month ago_::_%n months ago_" => array("","%n ay önce"), "last year" => "geçen yıl", -"years ago" => "yıl önce", -"Caused by:" => "Neden olan:" +"years ago" => "yıl önce" ); $PLURAL_FORMS = "nplurals=2; plural=(n > 1);"; diff --git a/lib/l10n/uk.php b/lib/l10n/uk.php index 906c93b567a..32e010f1d40 100644 --- a/lib/l10n/uk.php +++ b/lib/l10n/uk.php @@ -5,6 +5,8 @@ $TRANSLATIONS = array( "Settings" => "Налаштування", "Users" => "Користувачі", "Admin" => "Адмін", +"Unknown filetype" => "Невідомий тип файлу", +"Invalid image" => "Невірне зображення", "web services under your control" => "підконтрольні Вам веб-сервіси", "ZIP download is turned off." => "ZIP завантаження вимкнено.", "Files need to be downloaded one by one." => "Файли повинні бути завантаженні послідовно.", @@ -37,13 +39,13 @@ $TRANSLATIONS = array( "Please double check the <a href='%s'>installation guides</a>." => "Будь ласка, перевірте <a href='%s'>інструкції по встановленню</a>.", "Could not find category \"%s\"" => "Не вдалося знайти категорію \"%s\"", "seconds ago" => "секунди тому", -"_%n minute ago_::_%n minutes ago_" => array("","",""), -"_%n hour ago_::_%n hours ago_" => array("","",""), +"_%n minute ago_::_%n minutes ago_" => array("","","%n хвилин тому"), +"_%n hour ago_::_%n hours ago_" => array("","","%n годин тому"), "today" => "сьогодні", "yesterday" => "вчора", -"_%n day go_::_%n days ago_" => array("","",""), +"_%n day go_::_%n days ago_" => array("","","%n днів тому"), "last month" => "минулого місяця", -"_%n month ago_::_%n months ago_" => array("","",""), +"_%n month ago_::_%n months ago_" => array("","","%n місяців тому"), "last year" => "минулого року", "years ago" => "роки тому" ); diff --git a/lib/l10n/zh_TW.php b/lib/l10n/zh_TW.php index 187d40e540e..35719c8b17e 100644 --- a/lib/l10n/zh_TW.php +++ b/lib/l10n/zh_TW.php @@ -64,7 +64,6 @@ $TRANSLATIONS = array( "last month" => "上個月", "_%n month ago_::_%n months ago_" => array("%n 個月前"), "last year" => "去年", -"years ago" => "幾年前", -"Caused by:" => "原因:" +"years ago" => "幾年前" ); $PLURAL_FORMS = "nplurals=1; plural=0;"; diff --git a/lib/private/allconfig.php b/lib/private/allconfig.php index 72aabf60793..a4aa69d43fb 100644 --- a/lib/private/allconfig.php +++ b/lib/private/allconfig.php @@ -4,7 +4,7 @@ * This file is licensed under the Affero General Public License version 3 or * later. * See the COPYING-README file. - * + * */ namespace OC; @@ -15,6 +15,7 @@ namespace OC; class AllConfig implements \OCP\IConfig { /** * 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 @@ -25,16 +26,19 @@ class AllConfig implements \OCP\IConfig { /** * Looks up a system wide defined value + * * @param string $key the key of the value, under which it was saved + * @param string $default the default value to be returned if the value isn't set * @return string the saved value */ - public function getSystemValue($key) { - return \OCP\Config::getSystemValue($key, ''); + public function getSystemValue($key, $default = '') { + return \OCP\Config::getSystemValue($key, $default); } /** * 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 @@ -45,17 +49,20 @@ class AllConfig implements \OCP\IConfig { /** * 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 + * @param string $default the default value to be returned if the value isn't set * @return string the saved value */ - public function getAppValue($appName, $key) { - return \OCP\Config::getAppValue($appName, $key, ''); + public function getAppValue($appName, $key, $default = '') { + return \OCP\Config::getAppValue($appName, $key, $default); } /** * 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 @@ -67,11 +74,14 @@ class AllConfig implements \OCP\IConfig { /** * 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 $default the default value to be returned if the value isn't set + * @return string */ - public function getUserValue($userId, $appName, $key){ - return \OCP\Config::getUserValue($userId, $appName, $key); + public function getUserValue($userId, $appName, $key, $default = '') { + return \OCP\Config::getUserValue($userId, $appName, $key, $default); } } diff --git a/lib/private/appconfig.php b/lib/private/appconfig.php index 4f170e054e9..dfe03698059 100644 --- a/lib/private/appconfig.php +++ b/lib/private/appconfig.php @@ -37,7 +37,12 @@ * This class provides an easy way for apps to store config values in the * database. */ -class OC_Appconfig{ +class OC_Appconfig { + + private static $cache = array(); + + private static $appsLoaded = array(); + /** * @brief Get all apps using the config * @return array with app ids @@ -47,11 +52,11 @@ class OC_Appconfig{ */ public static function getApps() { // No magic in here! - $query = OC_DB::prepare( 'SELECT DISTINCT `appid` FROM `*PREFIX*appconfig`' ); + $query = OC_DB::prepare('SELECT DISTINCT `appid` FROM `*PREFIX*appconfig`'); $result = $query->execute(); $apps = array(); - while( $row = $result->fetchRow()) { + while ($row = $result->fetchRow()) { $apps[] = $row["appid"]; } @@ -66,19 +71,35 @@ class OC_Appconfig{ * This function gets all keys of an app. Please note that the values are * not returned. */ - public static function getKeys( $app ) { + public static function getKeys($app) { // No magic in here as well - $query = OC_DB::prepare( 'SELECT `configkey` FROM `*PREFIX*appconfig` WHERE `appid` = ?' ); - $result = $query->execute( array( $app )); + $query = OC_DB::prepare('SELECT `configkey` FROM `*PREFIX*appconfig` WHERE `appid` = ?'); + $result = $query->execute(array($app)); $keys = array(); - while( $row = $result->fetchRow()) { + while ($row = $result->fetchRow()) { $keys[] = $row["configkey"]; } return $keys; } + private static function getAppValues($app) { + if (!isset(self::$cache[$app])) { + self::$cache[$app] = array(); + } + if (array_search($app, self::$appsLoaded) === false) { + $query = OC_DB::prepare('SELECT `configvalue`, `configkey` FROM `*PREFIX*appconfig`' + . ' WHERE `appid` = ?'); + $result = $query->execute(array($app)); + while ($row = $result->fetchRow()) { + self::$cache[$app][$row['configkey']] = $row['configvalue']; + } + self::$appsLoaded[] = $app; + } + return self::$cache[$app]; + } + /** * @brief Gets the config value * @param string $app app @@ -89,15 +110,18 @@ class OC_Appconfig{ * This function gets a value from the appconfig table. If the key does * not exist the default value will be returned */ - public static function getValue( $app, $key, $default = null ) { - // At least some magic in here :-) - $query = OC_DB::prepare( 'SELECT `configvalue` FROM `*PREFIX*appconfig`' - .' WHERE `appid` = ? AND `configkey` = ?' ); - $result = $query->execute( array( $app, $key )); - $row = $result->fetchRow(); - if($row) { - return $row["configvalue"]; - }else{ + public static function getValue($app, $key, $default = null) { + if (!isset(self::$cache[$app])) { + self::$cache[$app] = array(); + } + if (isset(self::$cache[$app][$key])) { + return self::$cache[$app][$key]; + } + $values = self::getAppValues($app); + if (isset($values[$key])) { + return $values[$key]; + } else { + self::$cache[$app][$key] = $default; return $default; } } @@ -109,8 +133,11 @@ class OC_Appconfig{ * @return bool */ public static function hasKey($app, $key) { - $exists = self::getKeys( $app ); - return in_array( $key, $exists ); + if (isset(self::$cache[$app]) and isset(self::$cache[$app][$key])) { + return true; + } + $exists = self::getKeys($app); + return in_array($key, $exists); } /** @@ -122,17 +149,16 @@ class OC_Appconfig{ * * Sets a value. If the key did not exist before it will be created. */ - public static function setValue( $app, $key, $value ) { + public static function setValue($app, $key, $value) { // Does the key exist? yes: update. No: insert - if(! self::hasKey($app, $key)) { - $query = OC_DB::prepare( 'INSERT INTO `*PREFIX*appconfig` ( `appid`, `configkey`, `configvalue` )' - .' VALUES( ?, ?, ? )' ); - $query->execute( array( $app, $key, $value )); - } - else{ - $query = OC_DB::prepare( 'UPDATE `*PREFIX*appconfig` SET `configvalue` = ?' - .' WHERE `appid` = ? AND `configkey` = ?' ); - $query->execute( array( $value, $app, $key )); + if (!self::hasKey($app, $key)) { + $query = OC_DB::prepare('INSERT INTO `*PREFIX*appconfig` ( `appid`, `configkey`, `configvalue` )' + . ' VALUES( ?, ?, ? )'); + $query->execute(array($app, $key, $value)); + } else { + $query = OC_DB::prepare('UPDATE `*PREFIX*appconfig` SET `configvalue` = ?' + . ' WHERE `appid` = ? AND `configkey` = ?'); + $query->execute(array($value, $app, $key)); } // TODO where should this be documented? \OC_Hook::emit('OC_Appconfig', 'post_set_value', array( @@ -140,6 +166,10 @@ class OC_Appconfig{ 'key' => $key, 'value' => $value )); + if (!isset(self::$cache[$app])) { + self::$cache[$app] = array(); + } + self::$cache[$app][$key] = $value; } /** @@ -150,10 +180,13 @@ class OC_Appconfig{ * * Deletes a key. */ - public static function deleteKey( $app, $key ) { + public static function deleteKey($app, $key) { // Boring! - $query = OC_DB::prepare( 'DELETE FROM `*PREFIX*appconfig` WHERE `appid` = ? AND `configkey` = ?' ); - $query->execute( array( $app, $key )); + $query = OC_DB::prepare('DELETE FROM `*PREFIX*appconfig` WHERE `appid` = ? AND `configkey` = ?'); + $query->execute(array($app, $key)); + if (isset(self::$cache[$app]) and isset(self::$cache[$app][$key])) { + unset(self::$cache[$app][$key]); + } return true; } @@ -165,44 +198,46 @@ class OC_Appconfig{ * * Removes all keys in appconfig belonging to the app. */ - public static function deleteApp( $app ) { + public static function deleteApp($app) { // Nothing special - $query = OC_DB::prepare( 'DELETE FROM `*PREFIX*appconfig` WHERE `appid` = ?' ); - $query->execute( array( $app )); + $query = OC_DB::prepare('DELETE FROM `*PREFIX*appconfig` WHERE `appid` = ?'); + $query->execute(array($app)); + self::$cache[$app] = array(); return true; } /** * get multiply values, either the app or key can be used as wildcard by setting it to false + * * @param app * @param key * @return array */ public static function getValues($app, $key) { - if($app!==false and $key!==false) { + if ($app !== false and $key !== false) { return false; } - $fields='`configvalue`'; - $where='WHERE'; - $params=array(); - if($app!==false) { - $fields.=', `configkey`'; - $where.=' `appid` = ?'; - $params[]=$app; - $key='configkey'; - }else{ - $fields.=', `appid`'; - $where.=' `configkey` = ?'; - $params[]=$key; - $key='appid'; + $fields = '`configvalue`'; + $where = 'WHERE'; + $params = array(); + if ($app !== false) { + $fields .= ', `configkey`'; + $where .= ' `appid` = ?'; + $params[] = $app; + $key = 'configkey'; + } else { + $fields .= ', `appid`'; + $where .= ' `configkey` = ?'; + $params[] = $key; + $key = 'appid'; } - $queryString='SELECT '.$fields.' FROM `*PREFIX*appconfig` '.$where; - $query=OC_DB::prepare($queryString); - $result=$query->execute($params); - $values=array(); - while($row=$result->fetchRow()) { - $values[$row[$key]]=$row['configvalue']; + $queryString = 'SELECT ' . $fields . ' FROM `*PREFIX*appconfig` ' . $where; + $query = OC_DB::prepare($queryString); + $result = $query->execute($params); + $values = array(); + while ($row = $result->fetchRow()) { + $values[$row[$key]] = $row['configvalue']; } return $values; } diff --git a/lib/private/backgroundjob/job.php b/lib/private/backgroundjob/job.php index 49fbffbd684..92bd0f8fdbd 100644 --- a/lib/private/backgroundjob/job.php +++ b/lib/private/backgroundjob/job.php @@ -9,16 +9,35 @@ namespace OC\BackgroundJob; abstract class Job { + /** + * @var int $id + */ protected $id; + + /** + * @var int $lastRun + */ protected $lastRun; + + /** + * @var mixed $argument + */ protected $argument; /** * @param JobList $jobList + * @param \OC\Log $logger */ - public function execute($jobList) { + public function execute($jobList, $logger = null) { $jobList->setLastRun($this); - $this->run($this->argument); + try { + $this->run($this->argument); + } catch (\Exception $e) { + if ($logger) { + $logger->error('Error while running background job: ' . $e->getMessage()); + } + $jobList->remove($this, $this->argument); + } } abstract protected function run($argument); diff --git a/lib/private/backgroundjob/queuedjob.php b/lib/private/backgroundjob/queuedjob.php index 1714182820d..799eac47848 100644 --- a/lib/private/backgroundjob/queuedjob.php +++ b/lib/private/backgroundjob/queuedjob.php @@ -20,9 +20,10 @@ abstract class QueuedJob extends Job { * run the job, then remove it from the joblist * * @param JobList $jobList + * @param \OC\Log $logger */ - public function execute($jobList) { + public function execute($jobList, $logger = null) { $jobList->remove($this); - $this->run($this->argument); + parent::execute($jobList, $logger); } } diff --git a/lib/private/backgroundjob/timedjob.php b/lib/private/backgroundjob/timedjob.php index ae9f33505ab..09e05f1d846 100644 --- a/lib/private/backgroundjob/timedjob.php +++ b/lib/private/backgroundjob/timedjob.php @@ -31,11 +31,11 @@ abstract class TimedJob extends Job { * run the job if * * @param JobList $jobList + * @param \OC\Log $logger */ - public function execute($jobList) { + public function execute($jobList, $logger = null) { if ((time() - $this->lastRun) > $this->interval) { - $jobList->setLastRun($this); - $this->run($this->argument); + parent::execute($jobList, $logger); } } } diff --git a/lib/private/db.php b/lib/private/db.php index 1e5d12649df..562065259fa 100644 --- a/lib/private/db.php +++ b/lib/private/db.php @@ -101,6 +101,9 @@ class OC_DB { ); $connectionParams['adapter'] = '\OC\DB\Adapter'; $connectionParams['wrapperClass'] = 'OC\DB\Connection'; + // Send "SET NAMES utf8". Only required on PHP 5.3 below 5.3.6. + // See http://stackoverflow.com/questions/4361459/php-pdo-charset-set-names#4361485 + $eventManager->addEventSubscriber(new \Doctrine\DBAL\Event\Listeners\MysqlSessionInit); break; case 'pgsql': $connectionParams = array( diff --git a/lib/private/db/mdb2schemareader.php b/lib/private/db/mdb2schemareader.php index 511bd1c90bd..b1fd2454cb0 100644 --- a/lib/private/db/mdb2schemareader.php +++ b/lib/private/db/mdb2schemareader.php @@ -183,6 +183,14 @@ class MDB2SchemaReader { $primary = $this->asBool($child); $options['primary'] = $primary; break; + case 'precision': + $precision = (string)$child; + $options['precision'] = $precision; + break; + case 'scale': + $scale = (string)$child; + $options['scale'] = $scale; + break; default: throw new \DomainException('Unknown element: ' . $child->getName()); diff --git a/lib/private/eventsource.php b/lib/private/eventsource.php index a83084d9251..4df0bc2e7cd 100644 --- a/lib/private/eventsource.php +++ b/lib/private/eventsource.php @@ -64,13 +64,13 @@ class OC_EventSource{ } if($this->fallback) { $response='<script type="text/javascript">window.parent.OC.EventSource.fallBackCallBack(' - .$this->fallBackId.',"'.$type.'",'.json_encode($data).')</script>'.PHP_EOL; + .$this->fallBackId.',"' . $type . '",' . OCP\JSON::encode($data) . ')</script>' . PHP_EOL; echo $response; }else{ if($type) { - echo 'event: '.$type.PHP_EOL; + echo 'event: ' . $type.PHP_EOL; } - echo 'data: '.json_encode($data).PHP_EOL; + echo 'data: ' . OCP\JSON::encode($data) . PHP_EOL; } echo PHP_EOL; flush(); diff --git a/lib/private/files.php b/lib/private/files.php index 8b8ff81ec5e..6ffa14c0d91 100644 --- a/lib/private/files.php +++ b/lib/private/files.php @@ -109,6 +109,9 @@ class OC_Files { $zip = false; $filename = $dir . '/' . $files; $name = $files; + if ($xsendfile && OC_App::isEnabled('files_encryption')) { + $xsendfile = false; + } } OC_Util::obEnd(); if ($zip or \OC\Files\Filesystem::isReadable($filename)) { diff --git a/lib/private/files/cache/cache.php b/lib/private/files/cache/cache.php index ac50a988e32..8e682a96b75 100644 --- a/lib/private/files/cache/cache.php +++ b/lib/private/files/cache/cache.php @@ -178,6 +178,10 @@ class Cache { if ($file['storage_mtime'] == 0) { $file['storage_mtime'] = $file['mtime']; } + if ($file['encrypted']) { + $file['encrypted_size'] = $file['size']; + $file['size'] = $file['unencrypted_size']; + } } return $files; } else { diff --git a/lib/private/files/cache/scanner.php b/lib/private/files/cache/scanner.php index 34184c68c64..a8c069ee99f 100644 --- a/lib/private/files/cache/scanner.php +++ b/lib/private/files/cache/scanner.php @@ -286,7 +286,7 @@ class Scanner extends BasicEmitter { public function backgroundScan() { $lastPath = null; while (($path = $this->cache->getIncomplete()) !== false && $path !== $lastPath) { - $this->scan($path); + $this->scan($path, self::SCAN_RECURSIVE, self::REUSE_ETAG); $this->cache->correctFolderSize($path); $lastPath = $path; } diff --git a/lib/private/group/group.php b/lib/private/group/group.php index bcd2419b309..8d2aa87a788 100644 --- a/lib/private/group/group.php +++ b/lib/private/group/group.php @@ -18,7 +18,12 @@ class Group { /** * @var \OC\User\User[] $users */ - private $users; + private $users = array(); + + /** + * @var bool $usersLoaded + */ + private $usersLoaded; /** * @var \OC_Group_Backend[] | \OC_Group_Database[] $backend @@ -26,7 +31,7 @@ class Group { private $backends; /** - * @var \OC\Hooks\PublicEmitter $emitter; + * @var \OC\Hooks\PublicEmitter $emitter */ private $emitter; @@ -58,7 +63,7 @@ class Group { * @return \OC\User\User[] */ public function getUsers() { - if ($this->users) { + if ($this->usersLoaded) { return $this->users; } @@ -74,6 +79,7 @@ class Group { } $this->users = $this->getVerifiedUsers($userIds); + $this->usersLoaded = true; return $this->users; } @@ -84,8 +90,12 @@ class Group { * @return bool */ public function inGroup($user) { + if (isset($this->users[$user->getUID()])) { + return true; + } foreach ($this->backends as $backend) { if ($backend->inGroup($user->getUID(), $this->gid)) { + $this->users[$user->getUID()] = $user; return true; } } @@ -185,6 +195,7 @@ class Group { * @return \OC\User\User[] */ public function searchDisplayName($search, $limit = null, $offset = null) { + $users = array(); foreach ($this->backends as $backend) { if ($backend->implementsActions(OC_GROUP_BACKEND_GET_DISPLAYNAME)) { $userIds = array_keys($backend->displayNamesInGroup($this->gid, $search, $limit, $offset)); @@ -229,17 +240,17 @@ class Group { /** * @brief returns all the Users from an array that really exists - * @param $userIds an array containing user IDs - * @return an Array with the userId as Key and \OC\User\User as value + * @param string[] $userIds an array containing user IDs + * @return \OC\User\User[] an Array with the userId as Key and \OC\User\User as value */ private function getVerifiedUsers($userIds) { - if(!is_array($userIds)) { + if (!is_array($userIds)) { return array(); } $users = array(); foreach ($userIds as $userId) { $user = $this->userManager->get($userId); - if(!is_null($user)) { + if (!is_null($user)) { $users[$userId] = $user; } } diff --git a/lib/private/json.php b/lib/private/json.php index 6ba0b13806b..6a9e5a2df5e 100644 --- a/lib/private/json.php +++ b/lib/private/json.php @@ -109,7 +109,16 @@ class OC_JSON{ if($setContentType) { self::setContentTypeHeader(); } - array_walk_recursive($data, array('OC_JSON', 'to_string')); - echo json_encode($data); + echo self::encode($data); + } + + /** + * Encode JSON + */ + public static function encode($data) { + if (is_array($data)) { + array_walk_recursive($data, array('OC_JSON', 'to_string')); + } + return json_encode($data); } } diff --git a/lib/private/l10n.php b/lib/private/l10n.php index 2d440850459..98665c84c55 100644 --- a/lib/private/l10n.php +++ b/lib/private/l10n.php @@ -262,7 +262,7 @@ class OC_L10N implements \OCP\IL10N { */ public function n($text_singular, $text_plural, $count, $parameters = array()) { $this->init(); - $identifier = "_${text_singular}__${text_plural}_"; + $identifier = "_${text_singular}_::_${text_plural}_"; if( array_key_exists($identifier, $this->translations)) { return new OC_L10N_String( $this, $identifier, $parameters, $count ); } diff --git a/lib/private/memcache/xcache.php b/lib/private/memcache/xcache.php index 33de30562f9..1337a7ad612 100644 --- a/lib/private/memcache/xcache.php +++ b/lib/private/memcache/xcache.php @@ -8,9 +8,13 @@ namespace OC\Memcache; +/** + * See http://xcache.lighttpd.net/wiki/XcacheApi for provided constants and + * functions etc. + */ class XCache extends Cache { /** - * entries in XCache gets namespaced to prevent collisions between owncloud instances and users + * entries in XCache gets namespaced to prevent collisions between ownCloud instances and users */ protected function getNameSpace() { return $this->prefix; @@ -37,24 +41,32 @@ class XCache extends Cache { } public function clear($prefix='') { - xcache_unset_by_prefix($this->getNamespace().$prefix); + if (function_exists('xcache_unset_by_prefix')) { + return xcache_unset_by_prefix($this->getNamespace().$prefix); + } else { + // Since we can not clear by prefix, we just clear the whole cache. + xcache_clear_cache(\XC_TYPE_VAR, 0); + } return true; } static public function isAvailable(){ if (!extension_loaded('xcache')) { return false; - } elseif (\OC::$CLI) { + } + if (\OC::$CLI) { return false; - }else{ - return true; } - } -} - -if(!function_exists('xcache_unset_by_prefix')) { - function xcache_unset_by_prefix($prefix) { - // Since we can't clear targetted cache, we'll clear all. :( - xcache_clear_cache(\XC_TYPE_VAR, 0); + if (!function_exists('xcache_unset_by_prefix') && ini_get('xcache.admin.enable_auth')) { + // We do not want to use XCache if we can not clear it without + // using the administration function xcache_clear_cache() + // AND administration functions are password-protected. + return false; + } + $var_size = (int) ini_get('xcache.var_size'); + if (!$var_size) { + return false; + } + return true; } } diff --git a/lib/private/mimetypes.list.php b/lib/private/mimetypes.list.php index 8ab8ac81bd8..3034c2777f7 100644 --- a/lib/private/mimetypes.list.php +++ b/lib/private/mimetypes.list.php @@ -82,7 +82,7 @@ return array( 'mov'=>'video/quicktime', 'webm'=>'video/webm', 'wmv'=>'video/x-ms-asf', - 'py'=>'text/x-script.phyton', + 'py'=>'text/x-script.python', 'vcf' => 'text/vcard', 'vcard' => 'text/vcard', 'doc'=>'application/msword', @@ -103,5 +103,9 @@ return array( 'markdown' => 'text/markdown', 'mdown' => 'text/markdown', 'mdwn' => 'text/markdown', - 'reveal' => 'text/reveal' + 'reveal' => 'text/reveal', + 'c' => 'text/x-c', + 'cc' => 'text/x-c', + 'cpp' => 'text/x-c++src', + 'c++' => 'text/x-c++src', ); diff --git a/lib/private/session/internal.php b/lib/private/session/internal.php index 60aecccc8aa..a7c9e2fdefd 100644 --- a/lib/private/session/internal.php +++ b/lib/private/session/internal.php @@ -26,10 +26,21 @@ class Internal extends Memory { } public function __destruct() { - $_SESSION = $this->data; + $_SESSION = array_merge($_SESSION, $this->data); session_write_close(); } + /** + * @param string $key + */ + public function remove($key) { + // also remove it from $_SESSION to prevent re-setting the old value during the merge + if (isset($_SESSION[$key])) { + unset($_SESSION[$key]); + } + parent::remove($key); + } + public function clear() { session_unset(); @session_regenerate_id(true); diff --git a/lib/private/session/memory.php b/lib/private/session/memory.php index c148ff4b9b9..134cee582ed 100644 --- a/lib/private/session/memory.php +++ b/lib/private/session/memory.php @@ -11,7 +11,7 @@ namespace OC\Session; /** * Class Internal * - * store session data in an in-memory array, not persistance + * store session data in an in-memory array, not persistent * * @package OC\Session */ diff --git a/lib/private/tags.php b/lib/private/tags.php index 9fdb35a7d6e..fe7de1073a0 100644 --- a/lib/private/tags.php +++ b/lib/private/tags.php @@ -480,7 +480,7 @@ class Tags implements \OCP\ITags { return $this->getIdsForTag(self::TAG_FAVORITE); } catch(\Exception $e) { \OCP\Util::writeLog('core', __METHOD__.', exception: ' . $e->getMessage(), - \OCP\Util::ERROR); + \OCP\Util::DEBUG); return array(); } } diff --git a/lib/private/template.php b/lib/private/template.php index 9b2c1211e61..b2c3a20f281 100644 --- a/lib/private/template.php +++ b/lib/private/template.php @@ -292,9 +292,8 @@ class OC_Template extends \OC\Template\Base { if (!empty($hint)) { $hint = '<pre>'.$hint.'</pre>'; } - $l = OC_L10N::get('lib'); while (method_exists($exception, 'previous') && $exception = $exception->previous()) { - $error_msg .= '<br/>'.$l->t('Caused by:').' '; + $error_msg .= '<br/>Caused by:' . ' '; if ($exception->getCode()) { $error_msg .= '['.$exception->getCode().'] '; } diff --git a/lib/private/user/database.php b/lib/private/user/database.php index 3db770f9898..c99db3b27ca 100644 --- a/lib/private/user/database.php +++ b/lib/private/user/database.php @@ -42,13 +42,13 @@ class OC_User_Database extends OC_User_Backend { /** * @var PasswordHash */ - static private $hasher=null; + static private $hasher = null; private function getHasher() { - if(!self::$hasher) { + if (!self::$hasher) { //we don't want to use DES based crypt(), since it doesn't return a hash with a recognisable prefix - $forcePortable=(CRYPT_BLOWFISH!=1); - self::$hasher=new PasswordHash(8, $forcePortable); + $forcePortable = (CRYPT_BLOWFISH != 1); + self::$hasher = new PasswordHash(8, $forcePortable); } return self::$hasher; @@ -63,14 +63,14 @@ class OC_User_Database extends OC_User_Backend { * Creates a new user. Basic checking of username is done in OC_User * itself, not in its subclasses. */ - public function createUser( $uid, $password ) { - if( $this->userExists($uid) ) { + public function createUser($uid, $password) { + if ($this->userExists($uid)) { return false; - }else{ - $hasher=$this->getHasher(); - $hash = $hasher->HashPassword($password.OC_Config::getValue('passwordsalt', '')); - $query = OC_DB::prepare( 'INSERT INTO `*PREFIX*users` ( `uid`, `password` ) VALUES( ?, ? )' ); - $result = $query->execute( array( $uid, $hash)); + } else { + $hasher = $this->getHasher(); + $hash = $hasher->HashPassword($password . OC_Config::getValue('passwordsalt', '')); + $query = OC_DB::prepare('INSERT INTO `*PREFIX*users` ( `uid`, `password` ) VALUES( ?, ? )'); + $result = $query->execute(array($uid, $hash)); return $result ? true : false; } @@ -83,10 +83,10 @@ class OC_User_Database extends OC_User_Backend { * * Deletes a user */ - public function deleteUser( $uid ) { + public function deleteUser($uid) { // Delete user-group-relation - $query = OC_DB::prepare( 'DELETE FROM `*PREFIX*users` WHERE `uid` = ?' ); - $query->execute( array( $uid )); + $query = OC_DB::prepare('DELETE FROM `*PREFIX*users` WHERE `uid` = ?'); + $query->execute(array($uid)); return true; } @@ -98,15 +98,15 @@ class OC_User_Database extends OC_User_Backend { * * Change the password of a user */ - public function setPassword( $uid, $password ) { - if( $this->userExists($uid) ) { - $hasher=$this->getHasher(); - $hash = $hasher->HashPassword($password.OC_Config::getValue('passwordsalt', '')); - $query = OC_DB::prepare( 'UPDATE `*PREFIX*users` SET `password` = ? WHERE `uid` = ?' ); - $query->execute( array( $hash, $uid )); + public function setPassword($uid, $password) { + if ($this->userExists($uid)) { + $hasher = $this->getHasher(); + $hash = $hasher->HashPassword($password . OC_Config::getValue('passwordsalt', '')); + $query = OC_DB::prepare('UPDATE `*PREFIX*users` SET `password` = ? WHERE `uid` = ?'); + $query->execute(array($hash, $uid)); return true; - }else{ + } else { return false; } } @@ -119,12 +119,12 @@ class OC_User_Database extends OC_User_Backend { * * Change the display name of a user */ - public function setDisplayName( $uid, $displayName ) { - if( $this->userExists($uid) ) { - $query = OC_DB::prepare( 'UPDATE `*PREFIX*users` SET `displayname` = ? WHERE `uid` = ?' ); - $query->execute( array( $displayName, $uid )); + public function setDisplayName($uid, $displayName) { + if ($this->userExists($uid)) { + $query = OC_DB::prepare('UPDATE `*PREFIX*users` SET `displayname` = ? WHERE LOWER(`uid`) = ?'); + $query->execute(array($displayName, $uid)); return true; - }else{ + } else { return false; } } @@ -132,18 +132,16 @@ class OC_User_Database extends OC_User_Backend { /** * @brief get display name of the user * @param $uid user ID of the user - * @return display name + * @return string display name */ public function getDisplayName($uid) { - if( $this->userExists($uid) ) { - $query = OC_DB::prepare( 'SELECT `displayname` FROM `*PREFIX*users` WHERE `uid` = ?' ); - $result = $query->execute( array( $uid ))->fetchAll(); - $displayName = trim($result[0]['displayname'], ' '); - if ( !empty($displayName) ) { - return $displayName; - } else { - return $uid; - } + $query = OC_DB::prepare('SELECT `displayname` FROM `*PREFIX*users` WHERE `uid` = ?'); + $result = $query->execute(array($uid))->fetchAll(); + $displayName = trim($result[0]['displayname'], ' '); + if (!empty($displayName)) { + return $displayName; + } else { + return $uid; } } @@ -156,9 +154,9 @@ class OC_User_Database extends OC_User_Backend { public function getDisplayNames($search = '', $limit = null, $offset = null) { $displayNames = array(); $query = OC_DB::prepare('SELECT `uid`, `displayname` FROM `*PREFIX*users`' - .' WHERE LOWER(`displayname`) LIKE LOWER(?) OR ' - .'LOWER(`uid`) LIKE LOWER(?)', $limit, $offset); - $result = $query->execute(array($search.'%', $search.'%')); + . ' WHERE LOWER(`displayname`) LIKE LOWER(?) OR ' + . 'LOWER(`uid`) LIKE LOWER(?)', $limit, $offset); + $result = $query->execute(array($search . '%', $search . '%')); $users = array(); while ($row = $result->fetchRow()) { $displayNames[$row['uid']] = $row['displayname']; @@ -176,30 +174,30 @@ class OC_User_Database extends OC_User_Backend { * Check if the password is correct without logging in the user * returns the user id or false */ - public function checkPassword( $uid, $password ) { - $query = OC_DB::prepare( 'SELECT `uid`, `password` FROM `*PREFIX*users` WHERE LOWER(`uid`) = LOWER(?)' ); - $result = $query->execute( array( $uid)); + public function checkPassword($uid, $password) { + $query = OC_DB::prepare('SELECT `uid`, `password` FROM `*PREFIX*users` WHERE LOWER(`uid`) = LOWER(?)'); + $result = $query->execute(array($uid)); - $row=$result->fetchRow(); - if($row) { - $storedHash=$row['password']; - if ($storedHash[0]=='$') {//the new phpass based hashing - $hasher=$this->getHasher(); - if($hasher->CheckPassword($password.OC_Config::getValue('passwordsalt', ''), $storedHash)) { + $row = $result->fetchRow(); + if ($row) { + $storedHash = $row['password']; + if ($storedHash[0] == '$') { //the new phpass based hashing + $hasher = $this->getHasher(); + if ($hasher->CheckPassword($password . OC_Config::getValue('passwordsalt', ''), $storedHash)) { return $row['uid']; - }else{ + } else { return false; } - }else{//old sha1 based hashing - if(sha1($password)==$storedHash) { + } else { //old sha1 based hashing + if (sha1($password) == $storedHash) { //upgrade to new hashing $this->setPassword($row['uid'], $password); return $row['uid']; - }else{ + } else { return false; } } - }else{ + } else { return false; } } @@ -212,7 +210,7 @@ class OC_User_Database extends OC_User_Backend { */ public function getUsers($search = '', $limit = null, $offset = null) { $query = OC_DB::prepare('SELECT `uid` FROM `*PREFIX*users` WHERE LOWER(`uid`) LIKE LOWER(?)', $limit, $offset); - $result = $query->execute(array($search.'%')); + $result = $query->execute(array($search . '%')); $users = array(); while ($row = $result->fetchRow()) { $users[] = $row['uid']; @@ -226,8 +224,8 @@ class OC_User_Database extends OC_User_Backend { * @return boolean */ public function userExists($uid) { - $query = OC_DB::prepare( 'SELECT COUNT(*) FROM `*PREFIX*users` WHERE LOWER(`uid`) = LOWER(?)' ); - $result = $query->execute( array( $uid )); + $query = OC_DB::prepare('SELECT COUNT(*) FROM `*PREFIX*users` WHERE LOWER(`uid`) = LOWER(?)'); + $result = $query->execute(array($uid)); if (OC_DB::isError($result)) { OC_Log::write('core', OC_DB::getErrorMessage($result), OC_Log::ERROR); return false; @@ -236,14 +234,14 @@ class OC_User_Database extends OC_User_Backend { } /** - * @brief get the user's home directory - * @param string $uid the username - * @return boolean - */ + * @brief get the user's home directory + * @param string $uid the username + * @return boolean + */ public function getHome($uid) { - if($this->userExists($uid)) { - return OC_Config::getValue( "datadirectory", OC::$SERVERROOT."/data" ) . '/' . $uid; - }else{ + if ($this->userExists($uid)) { + return OC_Config::getValue("datadirectory", OC::$SERVERROOT . "/data") . '/' . $uid; + } else { return false; } } diff --git a/lib/private/user/session.php b/lib/private/user/session.php index 9c9bee3da25..c2885d00413 100644 --- a/lib/private/user/session.php +++ b/lib/private/user/session.php @@ -113,6 +113,38 @@ class Session implements Emitter, \OCP\IUserSession { } /** + * set the login name + * + * @param string login name for the logged in user + */ + public function setLoginname($loginname) { + if (is_null($loginname)) { + $this->session->remove('loginname'); + } else { + $this->session->set('loginname', $loginname); + } + } + + /** + * get the login name of the current user + * + * @return string + */ + public function getLoginname() { + if ($this->activeUser) { + return $this->session->get('loginname'); + } else { + $uid = $this->session->get('user_id'); + if ($uid) { + $this->activeUser = $this->manager->get($uid); + return $this->session->get('loginname'); + } else { + return null; + } + } + } + + /** * try to login with the provided credentials * * @param string $uid @@ -126,6 +158,7 @@ class Session implements Emitter, \OCP\IUserSession { if (!is_null($user)) { if ($user->isEnabled()) { $this->setUser($user); + $this->setLoginname($uid); $this->manager->emit('\OC\User', 'postLogin', array($user, $password)); return true; } else { @@ -143,6 +176,7 @@ class Session implements Emitter, \OCP\IUserSession { public function logout() { $this->manager->emit('\OC\User', 'logout'); $this->setUser(null); + $this->setLoginname(null); $this->unsetMagicInCookie(); } diff --git a/lib/private/user/user.php b/lib/private/user/user.php index e773473ec41..b4f33fa73cc 100644 --- a/lib/private/user/user.php +++ b/lib/private/user/user.php @@ -38,6 +38,11 @@ class User { private $emitter; /** + * @var string $home + */ + private $home; + + /** * @param string $uid * @param \OC_User_Backend $backend * @param Emitter $emitter @@ -133,10 +138,14 @@ class User { * @return string */ public function getHome() { - if ($this->backend->implementsActions(\OC_USER_BACKEND_GET_HOME) and $home = $this->backend->getHome($this->uid)) { - return $home; + if (!$this->home) { + if ($this->backend->implementsActions(\OC_USER_BACKEND_GET_HOME) and $home = $this->backend->getHome($this->uid)) { + $this->home = $home; + } else { + $this->home = \OC_Config::getValue("datadirectory", \OC::$SERVERROOT . "/data") . '/' . $this->uid; //TODO switch to Config object once implemented + } } - return \OC_Config::getValue("datadirectory", \OC::$SERVERROOT . "/data") . '/' . $this->uid; //TODO switch to Config object once implemented + return $this->home; } /** @@ -145,7 +154,7 @@ class User { * @return bool */ public function canChangeAvatar() { - if($this->backend->implementsActions(\OC_USER_BACKEND_PROVIDE_AVATAR)) { + if ($this->backend->implementsActions(\OC_USER_BACKEND_PROVIDE_AVATAR)) { return $this->backend->canChangeAvatar($this->uid); } return true; diff --git a/lib/private/util.php b/lib/private/util.php index a73564b3f68..c0e618cc863 100755 --- a/lib/private/util.php +++ b/lib/private/util.php @@ -1085,7 +1085,11 @@ class OC_Util { } // XCache if (function_exists('xcache_clear_cache')) { - xcache_clear_cache(XC_TYPE_VAR, 0); + if (ini_get('xcache.admin.enable_auth')) { + OC_Log::write('core', 'XCache opcode cache will not be cleared because "xcache.admin.enable_auth" is enabled.', \OC_Log::WARN); + } else { + xcache_clear_cache(XC_TYPE_PHP, 0); + } } // Opcache (PHP >= 5.5) if (function_exists('opcache_reset')) { diff --git a/lib/public/backgroundjob.php b/lib/public/backgroundjob.php index 1788c4e293d..a7f54491dfa 100644 --- a/lib/public/backgroundjob.php +++ b/lib/public/backgroundjob.php @@ -45,6 +45,7 @@ use \OC\BackgroundJob\JobList; class BackgroundJob { /** * get the execution type of background jobs + * * @return string * * This method returns the type how background jobs are executed. If the user @@ -56,6 +57,7 @@ class BackgroundJob { /** * sets the background jobs execution type + * * @param string $type execution type * @return boolean * @@ -83,8 +85,10 @@ class BackgroundJob { * @return true */ public static function addRegularTask($klass, $method) { - self::registerJob('OC\BackgroundJob\Legacy\RegularJob', array($klass, $method)); - return true; + if (!\OC::needUpgrade()) { + self::registerJob('OC\BackgroundJob\Legacy\RegularJob', array($klass, $method)); + return true; + } } /** diff --git a/lib/public/db.php b/lib/public/db.php index c9997c79c3c..4a19d78d444 100644 --- a/lib/public/db.php +++ b/lib/public/db.php @@ -39,9 +39,9 @@ class DB { * @param string $query Query string * @param int $limit Limit of the SQL statement * @param int $offset Offset of the SQL statement - * @return \MDB2_Statement_Common prepared SQL query + * @return \Doctrine\DBAL\Statement prepared SQL query * - * SQL query via MDB2 prepare(), needs to be execute()'d! + * SQL query via Doctrine prepare(), needs to be execute()'d! */ static public function prepare( $query, $limit=null, $offset=null ) { return(\OC_DB::prepare($query, $limit, $offset)); @@ -73,7 +73,7 @@ class DB { * @param $table string The optional table name (will replace *PREFIX*) and add sequence suffix * @return int * - * MDB2 lastInsertID() + * \Doctrine\DBAL\Connection lastInsertID() * * Call this method right after the insert command or other functions may * cause trouble! @@ -86,18 +86,18 @@ class DB { * Start a transaction */ public static function beginTransaction() { - return(\OC_DB::beginTransaction()); + \OC_DB::beginTransaction(); } /** * Commit the database changes done during a transaction that is in progress */ public static function commit() { - return(\OC_DB::commit()); + \OC_DB::commit(); } /** - * Check if a result is an error, works with MDB2 and PDOException + * Check if a result is an error, works with Doctrine * @param mixed $result * @return bool */ diff --git a/lib/public/iconfig.php b/lib/public/iconfig.php index da6b6c54843..1d0f8e0015c 100644 --- a/lib/public/iconfig.php +++ b/lib/public/iconfig.php @@ -36,6 +36,7 @@ namespace OCP; interface IConfig { /** * 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 @@ -44,14 +45,17 @@ interface IConfig { /** * Looks up a system wide defined value + * * @param string $key the key of the value, under which it was saved + * @param string $default the default value to be returned if the value isn't set * @return string the saved value */ - public function getSystemValue($key); + public function getSystemValue($key, $default = ''); /** * 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 @@ -60,15 +64,18 @@ interface IConfig { /** * 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 + * @param string $default the default value to be returned if the value isn't set * @return string the saved value */ - public function getAppValue($appName, $key); + public function getAppValue($appName, $key, $default = ''); /** * 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 @@ -78,9 +85,11 @@ interface IConfig { /** * 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 $default the default value to be returned if the value isn't set */ - public function getUserValue($userId, $appName, $key); + public function getUserValue($userId, $appName, $key, $default = ''); } diff --git a/lib/public/json.php b/lib/public/json.php index 134f724b0e6..831e3ef1cf6 100644 --- a/lib/public/json.php +++ b/lib/public/json.php @@ -169,4 +169,12 @@ class JSON { public static function checkAdminUser() { return(\OC_JSON::checkAdminUser()); } + + /** + * Encode JSON + * @param array $data + */ + public static function encode($data) { + return(\OC_JSON::encode($data)); + } } diff --git a/lib/public/share.php b/lib/public/share.php index 6dbcd5b67bf..f0fd8e1ab1b 100644 --- a/lib/public/share.php +++ b/lib/public/share.php @@ -423,11 +423,13 @@ class Share { * @param string Item source * @param string Owner * @param bool Include collections + * @praram bool check expire date * @return Return array of users */ - public static function getUsersItemShared($itemType, $itemSource, $uidOwner, $includeCollections = false) { + public static function getUsersItemShared($itemType, $itemSource, $uidOwner, $includeCollections = false, $checkExpireDate = true) { + $users = array(); - $items = self::getItems($itemType, $itemSource, null, null, $uidOwner, self::FORMAT_NONE, null, -1, $includeCollections); + $items = self::getItems($itemType, $itemSource, null, null, $uidOwner, self::FORMAT_NONE, null, -1, $includeCollections, false, $checkExpireDate); if ($items) { foreach ($items as $item) { if ((int)$item['share_type'] === self::SHARE_TYPE_USER) { @@ -848,9 +850,8 @@ class Share { protected static function expireItem(array $item) { if (!empty($item['expiration'])) { $now = new \DateTime(); - $expirationDate = \Doctrine\DBAL\Types\Type::getType('datetime') - ->convertToPhpValue($item['expiration'], \OC_DB::getConnection()->getDatabasePlatform()); - if ($now > $expirationDate) { + $expires = new \DateTime($item['expiration']); + if ($now > $expires) { self::unshareItem($item); return true; } @@ -866,12 +867,14 @@ class Share { protected static function unshareItem(array $item) { // Pass all the vars we have for now, they may be useful $hookParams = array( - 'itemType' => $item['item_type'], - 'itemSource' => $item['item_source'], - 'shareType' => $item['share_type'], - 'shareWith' => $item['share_with'], - 'itemParent' => $item['parent'], + 'itemType' => $item['item_type'], + 'itemSource' => $item['item_source'], + 'shareType' => $item['share_type'], + 'shareWith' => $item['share_with'], + 'itemParent' => $item['parent'], + 'uidOwner' => $item['uid_owner'], ); + \OC_Hook::emit('OCP\Share', 'pre_unshare', $hookParams + array( 'fileSource' => $item['file_source'], )); @@ -961,6 +964,7 @@ class Share { * @param int Number of items to return, -1 to return all matches (optional) * @param bool Include collection item types (optional) * @param bool TODO (optional) + * @prams bool check expire date * @return mixed * * See public functions getItem(s)... for parameter usage @@ -968,7 +972,7 @@ class Share { */ private static function getItems($itemType, $item = null, $shareType = null, $shareWith = null, $uidOwner = null, $format = self::FORMAT_NONE, $parameters = null, $limit = -1, - $includeCollections = false, $itemShareWithBySource = false) { + $includeCollections = false, $itemShareWithBySource = false, $checkExpireDate = true) { if (!self::isEnabled()) { if ($limit == 1 || (isset($uidOwner) && isset($item))) { return false; @@ -1108,19 +1112,19 @@ class Share { if ($format == self::FORMAT_STATUSES) { if ($itemType == 'file' || $itemType == 'folder') { $select = '`*PREFIX*share`.`id`, `item_type`, `item_source`, `*PREFIX*share`.`parent`,' - .' `share_type`, `file_source`, `path`, `expiration`, `storage`, `mail_send`'; + .' `share_type`, `file_source`, `path`, `expiration`, `storage`, `share_with`, `mail_send`, `uid_owner`'; } else { - $select = '`id`, `item_type`, `item_source`, `parent`, `share_type`, `expiration`, `mail_send`'; + $select = '`id`, `item_type`, `item_source`, `parent`, `share_type`, `share_with`, `expiration`, `mail_send`, `uid_owner`'; } } else { if (isset($uidOwner)) { if ($itemType == 'file' || $itemType == 'folder') { $select = '`*PREFIX*share`.`id`, `item_type`, `item_source`, `*PREFIX*share`.`parent`,' .' `share_type`, `share_with`, `file_source`, `path`, `permissions`, `stime`,' - .' `expiration`, `token`, `storage`, `mail_send`'; + .' `expiration`, `token`, `storage`, `mail_send`, `uid_owner`'; } else { $select = '`id`, `item_type`, `item_source`, `parent`, `share_type`, `share_with`, `permissions`,' - .' `stime`, `file_source`, `expiration`, `token`, `mail_send`'; + .' `stime`, `file_source`, `expiration`, `token`, `mail_send`, `uid_owner`'; } } else { if ($fileDependent) { @@ -1234,8 +1238,10 @@ class Share { } } } - if (self::expireItem($row)) { - continue; + if($checkExpireDate) { + if (self::expireItem($row)) { + continue; + } } // Check if resharing is allowed, if not remove share permission if (isset($row['permissions']) && !self::isResharingAllowed()) { diff --git a/lib/public/util.php b/lib/public/util.php index 1d76fd1e1f7..8e85f9afc3f 100644 --- a/lib/public/util.php +++ b/lib/public/util.php @@ -103,9 +103,8 @@ class Util { } // include cause - $l = \OC_L10N::get('lib'); while (method_exists($ex, 'getPrevious') && $ex = $ex->getPrevious()) { - $message .= ' - '.$l->t('Caused by:').' '; + $message .= ' - Caused by:' . ' '; $message .= $ex->getMessage(); if ($ex->getCode()) { $message .= '[' . $ex->getCode() . '] '; |