diff options
Diffstat (limited to 'lib')
102 files changed, 1141 insertions, 518 deletions
diff --git a/lib/base.php b/lib/base.php index baf73b2fb9f..af78b4e4eb1 100644 --- a/lib/base.php +++ b/lib/base.php @@ -57,6 +57,9 @@ class OC { * web path in 'url' */ public static $APPSROOTS = array(); + + public static $configDir; + /* * requested app */ @@ -100,6 +103,13 @@ class OC { get_include_path() ); + if(defined('PHPUNIT_RUN') and PHPUNIT_RUN and is_dir(OC::$SERVERROOT . '/tests/config/')) { + self::$configDir = OC::$SERVERROOT . '/tests/config/'; + } else { + self::$configDir = OC::$SERVERROOT . '/config/'; + } + OC_Config::$object = new \OC\Config(self::$configDir); + OC::$SUBURI = str_replace("\\", "/", substr(realpath($_SERVER["SCRIPT_FILENAME"]), strlen(OC::$SERVERROOT))); $scriptName = OC_Request::scriptName(); if (substr($scriptName, -1) == '/') { @@ -131,8 +141,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 +166,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) { @@ -175,8 +185,9 @@ class OC { } public static function checkConfig() { - if (file_exists(OC::$SERVERROOT . "/config/config.php") - and !is_writable(OC::$SERVERROOT . "/config/config.php")) { + if (file_exists(self::$configDir . "/config.php") + and !is_writable(self::$configDir . "/config.php") + ) { $defaults = new OC_Defaults(); if (self::$CLI) { echo "Can't write into config directory!\n"; @@ -188,7 +199,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,32 +265,45 @@ 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 + // TODO: read from core/js/core.json OC_Util::addScript("jquery-1.10.0.min"); OC_Util::addScript("jquery-migrate-1.2.1.min"); OC_Util::addScript("jquery-ui-1.10.0.custom"); @@ -308,6 +332,7 @@ class OC { } OC_Util::addStyle("styles"); + OC_Util::addStyle("icons"); OC_Util::addStyle("apps"); OC_Util::addStyle("fixes"); OC_Util::addStyle("multiselect"); @@ -397,8 +422,6 @@ class OC { self::$loader->registerPrefix('Doctrine\\DBAL', 'doctrine/dbal/lib'); self::$loader->registerPrefix('Symfony\\Component\\Routing', 'symfony/routing'); self::$loader->registerPrefix('Symfony\\Component\\Console', 'symfony/console'); - self::$loader->registerPrefix('Sabre\\VObject', '3rdparty'); - self::$loader->registerPrefix('Sabre_', '3rdparty'); self::$loader->registerPrefix('Patchwork', '3rdparty'); spl_autoload_register(array(self::$loader, 'load')); @@ -461,11 +484,17 @@ 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(); + // setup 3rdparty autoloader + $vendorAutoLoad = OC::$THIRDPARTYROOT . '/3rdparty/autoload.php'; + if (file_exists($vendorAutoLoad)) { + require_once $vendorAutoLoad; + } + // set debug mode if an xdebug session is active if (!defined('DEBUG') || !DEBUG) { if (isset($_COOKIE['XDEBUG_SESSION'])) { @@ -506,7 +535,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 { @@ -527,12 +556,12 @@ class OC { OC_User::useBackend(new OC_User_Database()); 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'); + if (isset($_SERVER['PHP_AUTH_USER']) && self::$session->exists('loginname') + && $_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).", + "Session loginname ($sessionUser) doesn't match SERVER[PHP_AUTH_USER] ($serverUser).", OC_Log::WARN); OC_User::logout(); } @@ -601,13 +630,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 +643,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 +672,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 +695,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 +813,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); } diff --git a/lib/l10n/ak.php b/lib/l10n/ak.php new file mode 100644 index 00000000000..4124ad0d880 --- /dev/null +++ b/lib/l10n/ak.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=2; plural=n > 1;"; 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/be.php b/lib/l10n/be.php index 1570411eb86..b1cf270aba2 100644 --- a/lib/l10n/be.php +++ b/lib/l10n/be.php @@ -1,8 +1,15 @@ <?php $TRANSLATIONS = array( +"Settings" => "Налады", +"seconds ago" => "Секунд таму", "_%n minute ago_::_%n minutes ago_" => array("","","",""), "_%n hour ago_::_%n hours ago_" => array("","","",""), +"today" => "Сёння", +"yesterday" => "Ўчора", "_%n day go_::_%n days ago_" => array("","","",""), -"_%n month ago_::_%n months ago_" => array("","","","") +"last month" => "У мінулым месяцы", +"_%n month ago_::_%n months ago_" => array("","","",""), +"last year" => "У мінулым годзе", +"years ago" => "Гадоў таму" ); $PLURAL_FORMS = "nplurals=4; 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/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..65eb7466b6a 100644 --- a/lib/l10n/da.php +++ b/lib/l10n/da.php @@ -16,6 +16,7 @@ $TRANSLATIONS = array( "Files need to be downloaded one by one." => "Filer skal downloades en for en.", "Back to Files" => "Tilbage til Filer", "Selected files too large to generate zip file." => "De markerede filer er for store til at generere en ZIP-fil.", +"Please download the files separately in smaller chunks or kindly ask your administrator." => "Hent venligst filerne hver for sig i mindre dele eller spørg din administrator.", "No source specified when installing app" => "Ingen kilde angivet under installation af app", "No href specified when installing app from http" => "Ingen href angivet under installation af app via http", "No path specified when installing app from local file" => "Ingen sti angivet under installation af app fra lokal fil", @@ -64,7 +65,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 8ee4cb71d30..b1045892fb1 100644 --- a/lib/l10n/de.php +++ b/lib/l10n/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/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..7f7797bbc7a 100644 --- a/lib/l10n/el.php +++ b/lib/l10n/el.php @@ -1,5 +1,7 @@ <?php $TRANSLATIONS = array( +"App \"%s\" can't be installed because it is not compatible with this version of ownCloud." => "Η εφαρμογή \"%s\" δεν μπορεί να εγκατασταθεί επειδή δεν είναι συμβατή με αυτή την έκδοση του ownCloud.", +"No app name specified" => "Δεν προδιορίστηκε όνομα εφαρμογής", "Help" => "Βοήθεια", "Personal" => "Προσωπικά", "Settings" => "Ρυθμίσεις", @@ -14,6 +16,18 @@ $TRANSLATIONS = array( "Files need to be downloaded one by one." => "Τα αρχεία πρέπει να ληφθούν ένα-ένα.", "Back to Files" => "Πίσω στα Αρχεία", "Selected files too large to generate zip file." => "Τα επιλεγμένα αρχεία είναι μεγάλα ώστε να δημιουργηθεί αρχείο zip.", +"Please download the files separately in smaller chunks or kindly ask your administrator." => "Παρακαλώ κάντε λήψη των αρχείων σε μικρότερα κομμάτια ή ζητήστε το από το διαχειριστή σας.", +"No source specified when installing app" => "Δεν προσδιορίστηκε πηγή κατά την εγκατάσταση της εφαρμογής", +"No href specified when installing app from http" => "Δεν προσδιορίστηκε href κατά την εγκατάσταση της εφαρμογής μέσω http ", +"No path specified when installing app from local file" => "Δεν προσδιορίστηκε μονοπάτι κατά την εγκατάσταση εφαρμογής από τοπικό αρχείο", +"Archives of type %s are not supported" => "Συλλογές αρχείων τύπου %s δεν υποστηρίζονται", +"Failed to open archive when installing app" => "Αποτυχία ανοίγματος συλλογής αρχείων κατά την εγκατάσταση εφαρμογής", +"App does not provide an info.xml file" => "Η εφαρμογή δεν παρέχει αρχείο info.xml", +"App can't be installed because of not allowed code in the App" => "Η εφαρμογή δεν μπορεί να εγκατασταθεί λόγω μη-επιτρεπόμενου κώδικα μέσα στην Εφαρμογή", +"App can't be installed because it is not compatible with this version of ownCloud" => "Η εφαρμογή δεν μπορεί να εγκατασταθεί επειδή δεν είναι συμβατή με αυτή την έκδοση ownCloud", +"App can't be installed because the version in info.xml/version is not the same as the version reported from the app store" => "Η εφαρμογή δεν μπορεί να εγκατασταθεί επειδή η έκδοση στο info.xml/version δεν είναι η ίδια με την έκδοση που αναφέρεται στο κατάστημα εφαρμογών", +"App directory already exists" => "Ο κατάλογος εφαρμογών υπάρχει ήδη", +"Can't create app folder. Please fix permissions. %s" => "Δεν είναι δυνατόν να δημιουργηθεί ο φάκελος εφαρμογής. Παρακαλώ διορθώστε τις άδειες πρόσβασης. %s", "Application is not enabled" => "Δεν ενεργοποιήθηκε η εφαρμογή", "Authentication error" => "Σφάλμα πιστοποίησης", "Token expired. Please reload page." => "Το αναγνωριστικό έληξε. Παρακαλώ φορτώστε ξανά την σελίδα.", @@ -43,14 +57,13 @@ $TRANSLATIONS = array( "Could not find category \"%s\"" => "Αδυναμία εύρεσης κατηγορίας \"%s\"", "seconds ago" => "δευτερόλεπτα πριν", "_%n minute ago_::_%n minutes ago_" => array("","%n λεπτά πριν"), -"_%n hour ago_::_%n hours ago_" => array("",""), +"_%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" => "χρόνια πριν", -"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/es_MX.php b/lib/l10n/es_MX.php index 15f78e0bce6..7454d4966d8 100644 --- a/lib/l10n/es_MX.php +++ b/lib/l10n/es_MX.php @@ -1,8 +1,70 @@ <?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("","") +"App \"%s\" can't be installed because it is not compatible with this version of ownCloud." => "La aplicación \"%s\" no puede ser instalada porque no es compatible con esta versión de ownCloud", +"No app name specified" => "No se ha especificado nombre de la aplicación", +"Help" => "Ayuda", +"Personal" => "Personal", +"Settings" => "Ajustes", +"Users" => "Usuarios", +"Admin" => "Administración", +"Failed to upgrade \"%s\"." => "Falló la actualización \"%s\".", +"Unknown filetype" => "Tipo de archivo desconocido", +"Invalid image" => "Imagen inválida", +"web services under your control" => "Servicios web bajo su control", +"cannot open \"%s\"" => "No se puede abrir \"%s\"", +"ZIP download is turned off." => "La descarga en ZIP está desactivada.", +"Files need to be downloaded one by one." => "Los archivos deben ser descargados uno por uno.", +"Back to Files" => "Volver a Archivos", +"Selected files too large to generate zip file." => "Los archivos seleccionados son demasiado grandes para generar el archivo zip.", +"Please download the files separately in smaller chunks or kindly ask your administrator." => "Descargue los archivos en trozos más pequeños, por separado o solicítelos amablemente a su administrador.", +"No source specified when installing app" => "No se ha especificado origen cuando se ha instalado la aplicación", +"No href specified when installing app from http" => "No href especificado cuando se ha instalado la aplicación", +"No path specified when installing app from local file" => "Sin path especificado cuando se ha instalado la aplicación desde el archivo local", +"Archives of type %s are not supported" => "Archivos de tipo %s no son soportados", +"Failed to open archive when installing app" => "Fallo de abrir archivo mientras se instala la aplicación", +"App does not provide an info.xml file" => "La aplicación no suministra un archivo info.xml", +"App can't be installed because of not allowed code in the App" => "La aplicación no puede ser instalada por tener código no autorizado en la aplicación", +"App can't be installed because it is not compatible with this version of ownCloud" => "La aplicación no se puede instalar porque no es compatible con esta versión de ownCloud", +"App can't be installed because it contains the <shipped>true</shipped> tag which is not allowed for non shipped apps" => "La aplicación no se puede instalar porque contiene la etiqueta\n<shipped>\ntrue\n</shipped>\nque no está permitida para aplicaciones no distribuidas", +"App can't be installed because the version in info.xml/version is not the same as the version reported from the app store" => "La aplicación no puede ser instalada por que la versión en info.xml/version no es la misma que la establecida en la app store", +"App directory already exists" => "El directorio de la aplicación ya existe", +"Can't create app folder. Please fix permissions. %s" => "No se puede crear la carpeta de la aplicación. Corrija los permisos. %s", +"Application is not enabled" => "La aplicación no está habilitada", +"Authentication error" => "Error de autenticación", +"Token expired. Please reload page." => "Token expirado. Por favor, recarga la página.", +"Files" => "Archivos", +"Text" => "Texto", +"Images" => "Imágenes", +"%s enter the database username." => "%s ingresar el usuario de la base de datos.", +"%s enter the database name." => "%s ingresar el nombre de la base de datos", +"%s you may not use dots in the database name" => "%s puede utilizar puntos en el nombre de la base de datos", +"MS SQL username and/or password not valid: %s" => "Usuario y/o contraseña de MS SQL no válidos: %s", +"You need to enter either an existing account or the administrator." => "Tiene que ingresar una cuenta existente o la del administrador.", +"MySQL username and/or password not valid" => "Usuario y/o contraseña de MySQL no válidos", +"DB Error: \"%s\"" => "Error BD: \"%s\"", +"Offending command was: \"%s\"" => "Comando infractor: \"%s\"", +"MySQL user '%s'@'localhost' exists already." => "Usuario MySQL '%s'@'localhost' ya existe.", +"Drop this user from MySQL" => "Eliminar este usuario de MySQL", +"MySQL user '%s'@'%%' already exists" => "Usuario MySQL '%s'@'%%' ya existe", +"Drop this user from MySQL." => "Eliminar este usuario de MySQL.", +"Oracle connection could not be established" => "No se pudo establecer la conexión a Oracle", +"Oracle username and/or password not valid" => "Usuario y/o contraseña de Oracle no válidos", +"Offending command was: \"%s\", name: %s, password: %s" => "Comando infractor: \"%s\", nombre: %s, contraseña: %s", +"PostgreSQL username and/or password not valid" => "Usuario y/o contraseña de PostgreSQL no válidos", +"Set an admin username." => "Configurar un nombre de usuario del administrador", +"Set an admin password." => "Configurar la contraseña del administrador.", +"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "Su servidor web aún no está configurado adecuadamente para permitir sincronización de archivos ya que la interfaz WebDAV parece no estar funcionando.", +"Please double check the <a href='%s'>installation guides</a>." => "Por favor, vuelva a comprobar las <a href='%s'>guías de instalación</a>.", +"Could not find category \"%s\"" => "No puede encontrar la categoria \"%s\"", +"seconds ago" => "hace segundos", +"_%n minute ago_::_%n minutes ago_" => array("Hace %n minuto","Hace %n minutos"), +"_%n hour ago_::_%n hours ago_" => array("Hace %n hora","Hace %n horas"), +"today" => "hoy", +"yesterday" => "ayer", +"_%n day go_::_%n days ago_" => array("Hace %n día","Hace %n días"), +"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" ); $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 67a80d90caa..e3f18fca47a 100644 --- a/lib/l10n/eu.php +++ b/lib/l10n/eu.php @@ -65,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/id.php b/lib/l10n/id.php index 0cbcddcc6dd..27d7843104b 100644 --- a/lib/l10n/id.php +++ b/lib/l10n/id.php @@ -1,49 +1,69 @@ <?php $TRANSLATIONS = array( +"App \"%s\" can't be installed because it is not compatible with this version of ownCloud." => "Apl \"%s\" tidak dapat diinstal karena tidak kompatibel dengan versi ownCloud.", +"No app name specified" => "Tidak ada nama apl yang ditentukan", "Help" => "Bantuan", "Personal" => "Pribadi", -"Settings" => "Setelan", +"Settings" => "Pengaturan", "Users" => "Pengguna", "Admin" => "Admin", -"web services under your control" => "layanan web dalam kontrol Anda", +"Failed to upgrade \"%s\"." => "Gagal memperbarui \"%s\".", +"Unknown filetype" => "Tipe berkas tak dikenal", +"Invalid image" => "Gambar tidak sah", +"web services under your control" => "layanan web dalam kendali anda", +"cannot open \"%s\"" => "tidak dapat membuka \"%s\"", "ZIP download is turned off." => "Pengunduhan ZIP dimatikan.", "Files need to be downloaded one by one." => "Berkas harus diunduh satu persatu.", -"Back to Files" => "Kembali ke Daftar Berkas", +"Back to Files" => "Kembali ke Berkas", "Selected files too large to generate zip file." => "Berkas yang dipilih terlalu besar untuk dibuat berkas zip-nya.", +"Please download the files separately in smaller chunks or kindly ask your administrator." => "Silahkan unduh berkas secara terpisah dalam bentuk potongan kecil atau meminta ke administrator anda.", +"No source specified when installing app" => "Tidak ada sumber yang ditentukan saat menginstal apl", +"No href specified when installing app from http" => "Href tidak ditentukan saat menginstal apl dari http", +"No path specified when installing app from local file" => "Lokasi tidak ditentukan saat menginstal apl dari berkas lokal", +"Archives of type %s are not supported" => "Arsip dengan tipe %s tidak didukung", +"Failed to open archive when installing app" => "Gagal membuka arsip saat menginstal apl", +"App does not provide an info.xml file" => "Apl tidak menyediakan berkas info.xml", +"App can't be installed because of not allowed code in the App" => "Apl tidak dapat diinstal karena terdapat kode yang tidak diizinkan didalam Apl", +"App can't be installed because it is not compatible with this version of ownCloud" => "Apl tidak dapat diinstal karena tidak kompatibel dengan versi ownCloud", +"App can't be installed because it contains the <shipped>true</shipped> tag which is not allowed for non shipped apps" => "Apl tidak dapat diinstal karena mengandung tag <shipped>true</shipped> yang tidak diizinkan untuk apl yang bukan bawaan.", +"App can't be installed because the version in info.xml/version is not the same as the version reported from the app store" => "Apl tidak dapat diinstal karena versi di info.xml/versi tidak sama dengan versi yang dilansir dari toko apl", +"App directory already exists" => "Direktori Apl sudah ada", +"Can't create app folder. Please fix permissions. %s" => "Tidak dapat membuat folder apl. Silakan perbaiki perizinan. %s", "Application is not enabled" => "Aplikasi tidak diaktifkan", -"Authentication error" => "Galat saat autentikasi", -"Token expired. Please reload page." => "Token kedaluwarsa. Silakan muat ulang halaman.", +"Authentication error" => "Galat saat otentikasi", +"Token expired. Please reload page." => "Token sudah kedaluwarsa. Silakan muat ulang halaman.", "Files" => "Berkas", "Text" => "Teks", "Images" => "Gambar", "%s enter the database username." => "%s masukkan nama pengguna basis data.", "%s enter the database name." => "%s masukkan nama basis data.", -"%s you may not use dots in the database name" => "%sAnda tidak boleh menggunakan karakter titik pada nama basis data", -"MS SQL username and/or password not valid: %s" => "Nama pengguna dan/atau sandi MySQL tidak valid: %s", +"%s you may not use dots in the database name" => "%s anda tidak boleh menggunakan karakter titik pada nama basis data", +"MS SQL username and/or password not valid: %s" => "Nama pengguna dan/atau sandi MySQL tidak sah: %s", "You need to enter either an existing account or the administrator." => "Anda harus memasukkan akun yang sudah ada atau administrator.", -"MySQL username and/or password not valid" => "Nama pengguna dan/atau sandi MySQL tidak valid", +"MySQL username and/or password not valid" => "Nama pengguna dan/atau sandi MySQL tidak sah", "DB Error: \"%s\"" => "Galat Basis Data: \"%s\"", "Offending command was: \"%s\"" => "Perintah yang bermasalah: \"%s\"", "MySQL user '%s'@'localhost' exists already." => "Pengguna MySQL '%s'@'localhost' sudah ada.", "Drop this user from MySQL" => "Hapus pengguna ini dari MySQL", "MySQL user '%s'@'%%' already exists" => "Pengguna MySQL '%s'@'%%' sudah ada.", "Drop this user from MySQL." => "Hapus pengguna ini dari MySQL.", -"Oracle username and/or password not valid" => "Nama pengguna dan/atau sandi Oracle tidak valid", +"Oracle connection could not be established" => "Koneksi Oracle tidak dapat dibuat", +"Oracle username and/or password not valid" => "Nama pengguna dan/atau sandi Oracle tidak sah", "Offending command was: \"%s\", name: %s, password: %s" => "Perintah yang bermasalah: \"%s\", nama pengguna: %s, sandi: %s", "PostgreSQL username and/or password not valid" => "Nama pengguna dan/atau sandi PostgreSQL tidak valid", -"Set an admin username." => "Setel nama pengguna admin.", -"Set an admin password." => "Setel sandi admin.", +"Set an admin username." => "Atur nama pengguna admin.", +"Set an admin password." => "Atur sandi admin.", "Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "Web server Anda belum dikonfigurasikan dengan baik untuk mengizinkan sinkronisasi berkas karena tampaknya antarmuka WebDAV rusak.", "Please double check the <a href='%s'>installation guides</a>." => "Silakan periksa ulang <a href='%s'>panduan instalasi</a>.", -"Could not find category \"%s\"" => "Tidak dapat menemukan kategori \"%s\"", +"Could not find category \"%s\"" => "Tidak menemukan kategori \"%s\"", "seconds ago" => "beberapa detik yang lalu", -"_%n minute ago_::_%n minutes ago_" => array(""), -"_%n hour ago_::_%n hours ago_" => array(""), +"_%n minute ago_::_%n minutes ago_" => array("%n menit yang lalu"), +"_%n hour ago_::_%n hours ago_" => array("%n jam yang lalu"), "today" => "hari ini", "yesterday" => "kemarin", -"_%n day go_::_%n days ago_" => array(""), +"_%n day go_::_%n days ago_" => array("%n hari yang lalu"), "last month" => "bulan kemarin", -"_%n month ago_::_%n months ago_" => array(""), +"_%n month ago_::_%n months ago_" => array("%n bulan yang lalu"), "last year" => "tahun kemarin", "years ago" => "beberapa tahun lalu" ); 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..b33ad01546f 100644 --- a/lib/l10n/ko.php +++ b/lib/l10n/ko.php @@ -8,50 +8,51 @@ $TRANSLATIONS = array( "Users" => "사용자", "Admin" => "관리자", "Failed to upgrade \"%s\"." => "\"%s\" 업그레이드에 실패했습니다.", -"Unknown filetype" => "알수없는 파일형식", +"Unknown filetype" => "알 수 없는 파일 형식", "Invalid image" => "잘못된 그림", "web services under your control" => "내가 관리하는 웹 서비스", "cannot open \"%s\"" => "\"%s\"을(를) 열 수 없습니다.", -"ZIP download is turned off." => "ZIP 다운로드가 비활성화되었습니다.", +"ZIP download is turned off." => "ZIP 다운로드가 비활성화 되었습니다.", "Files need to be downloaded one by one." => "파일을 개별적으로 다운로드해야 합니다.", "Back to Files" => "파일로 돌아가기", "Selected files too large to generate zip file." => "선택한 파일들은 ZIP 파일을 생성하기에 너무 큽니다.", +"Please download the files separately in smaller chunks or kindly ask your administrator." => "작은 조각들 안에 들어있는 파일들을 받고자 하신다면, 나누어서 받으시거나 혹은 시스템 관리자에게 정중하게 물어보십시오", "No source specified when installing app" => "앱을 설치할 때 소스가 지정되지 않았습니다.", -"No href specified when installing app from http" => "http에서 앱을 설치할 대 href가 지정되지 않았습니다.", +"No href specified when installing app from http" => "http에서 앱을 설치할 때 href가 지정되지 않았습니다.", "No path specified when installing app from local file" => "로컬 파일에서 앱을 설치할 때 경로가 지정되지 않았습니다.", "Archives of type %s are not supported" => "%s 타입 아카이브는 지원되지 않습니다.", "Failed to open archive when installing app" => "앱을 설치할 때 아카이브를 열지 못했습니다.", "App does not provide an info.xml file" => "앱에서 info.xml 파일이 제공되지 않았습니다.", -"App can't be installed because of not allowed code in the App" => "앱에 허용되지 않는 코드가 있어서 앱을 설치할 수 없습니다. ", +"App can't be installed because of not allowed code in the App" => "앱에 허용되지 않는 코드가 있어서 앱을 설치할 수 없습니다.", "App can't be installed because it is not compatible with this version of ownCloud" => "현재 ownCloud 버전과 호환되지 않기 때문에 앱을 설치할 수 없습니다.", -"App can't be installed because it contains the <shipped>true</shipped> tag which is not allowed for non shipped apps" => "출하되지 않은 앱에 허용되지 않는 <shipped>true</shipped> 태그를 포함하고 있기 때문에 앱을 설치할 수 없습니다.", -"App can't be installed because the version in info.xml/version is not the same as the version reported from the app store" => "info.xml/version에 포함된 버전과 앱 스토어에 보고된 버전이 같지 않아서 앱을 설치할 수 없습니다. ", -"App directory already exists" => "앱 디렉토리가 이미 존재합니다. ", -"Can't create app folder. Please fix permissions. %s" => "앱 폴더를 만들 수 없습니다. 권한을 수정하십시오. %s ", +"App can't be installed because it contains the <shipped>true</shipped> tag which is not allowed for non shipped apps" => "출시되지 않은 앱에 허용되지 않는 <shipped>true</shipped> 태그를 포함하고 있기 때문에 앱을 설치할 수 없습니다.", +"App can't be installed because the version in info.xml/version is not the same as the version reported from the app store" => "info.xml/version에 포함된 버전과 앱 스토어에 보고된 버전이 같지 않아서 앱을 설치할 수 없습니다.", +"App directory already exists" => "앱 디렉터리가 이미 존재합니다.", +"Can't create app folder. Please fix permissions. %s" => "앱 폴더를 만들 수 없습니다. 권한을 수정하십시오. %s", "Application is not enabled" => "앱이 활성화되지 않았습니다", "Authentication error" => "인증 오류", "Token expired. Please reload page." => "토큰이 만료되었습니다. 페이지를 새로 고치십시오.", "Files" => "파일", "Text" => "텍스트", "Images" => "그림", -"%s enter the database username." => "데이터베이스 사용자 명을 %s 에 입력해주십시오", -"%s enter the database name." => "데이터베이스 명을 %s 에 입력해주십시오", -"%s you may not use dots in the database name" => "%s 에 적으신 데이터베이스 이름에는 점을 사용할수 없습니다", +"%s enter the database username." => "%s 데이터베이스 사용자 이름을 입력해 주십시오.", +"%s enter the database name." => "%s 데이터베이스 이름을 입력하십시오.", +"%s you may not use dots in the database name" => "%s 데이터베이스 이름에는 마침표를 사용할 수 없습니다", "MS SQL username and/or password not valid: %s" => "MS SQL 사용자 이름이나 암호가 잘못되었습니다: %s", "You need to enter either an existing account or the administrator." => "기존 계정이나 administrator(관리자)를 입력해야 합니다.", "MySQL username and/or password not valid" => "MySQL 사용자 이름이나 암호가 잘못되었습니다.", "DB Error: \"%s\"" => "DB 오류: \"%s\"", "Offending command was: \"%s\"" => "잘못된 명령: \"%s\"", "MySQL user '%s'@'localhost' exists already." => "MySQL 사용자 '%s'@'localhost'이(가) 이미 존재합니다.", -"Drop this user from MySQL" => "이 사용자를 MySQL에서 뺍니다.", -"MySQL user '%s'@'%%' already exists" => "MySQL 사용자 '%s'@'%%'이(가) 이미 존재합니다. ", -"Drop this user from MySQL." => "이 사용자를 MySQL에서 뺍니다.", +"Drop this user from MySQL" => "이 사용자를 MySQL에서 삭제하십시오", +"MySQL user '%s'@'%%' already exists" => "MySQL 사용자 '%s'@'%%'이(가) 이미 존재합니다.", +"Drop this user from MySQL." => "이 사용자를 MySQL에서 삭제하십시오.", "Oracle connection could not be established" => "Oracle 연결을 수립할 수 없습니다.", "Oracle username and/or password not valid" => "Oracle 사용자 이름이나 암호가 잘못되었습니다.", "Offending command was: \"%s\", name: %s, password: %s" => "잘못된 명령: \"%s\", 이름: %s, 암호: %s", -"PostgreSQL username and/or password not valid" => "PostgreSQL의 사용자 명 혹은 비밀번호가 잘못되었습니다", -"Set an admin username." => "관리자 이름 설정", -"Set an admin password." => "관리자 비밀번호 설정", +"PostgreSQL username and/or password not valid" => "PostgreSQL의 사용자 이름 또는 암호가 잘못되었습니다", +"Set an admin username." => "관리자의 사용자 이름을 설정합니다.", +"Set an admin password." => "관리자의 암호를 설정합니다.", "Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "WebDAV 인터페이스가 제대로 작동하지 않습니다. 웹 서버에서 파일 동기화를 사용할 수 있도록 설정이 제대로 되지 않은 것 같습니다.", "Please double check the <a href='%s'>installation guides</a>." => "<a href='%s'>설치 가이드</a>를 다시 한 번 확인하십시오.", "Could not find category \"%s\"" => "분류 \"%s\"을(를) 찾을 수 없습니다.", @@ -64,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/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/nb_NO.php b/lib/l10n/nb_NO.php index eb5e8d766fd..5da36f9be37 100644 --- a/lib/l10n/nb_NO.php +++ b/lib/l10n/nb_NO.php @@ -5,6 +5,8 @@ $TRANSLATIONS = array( "Settings" => "Innstillinger", "Users" => "Brukere", "Admin" => "Admin", +"Unknown filetype" => "Ukjent filtype", +"Invalid image" => "Ugyldig bilde", "web services under your control" => "web tjenester du kontrollerer", "ZIP download is turned off." => "ZIP-nedlasting av avslått", "Files need to be downloaded one by one." => "Filene må lastes ned en om gangen", @@ -20,13 +22,13 @@ $TRANSLATIONS = array( "Please double check the <a href='%s'>installation guides</a>." => "Vennligst dobbelsjekk <a href='%s'>installasjonsguiden</a>.", "Could not find category \"%s\"" => "Kunne ikke finne kategori \"%s\"", "seconds ago" => "sekunder siden", -"_%n minute ago_::_%n minutes ago_" => array("",""), -"_%n hour ago_::_%n hours ago_" => array("",""), +"_%n minute ago_::_%n minutes ago_" => array("","%n minutter siden"), +"_%n hour ago_::_%n hours ago_" => array("","%n timer siden"), "today" => "i dag", "yesterday" => "i går", -"_%n day go_::_%n days ago_" => array("",""), +"_%n day go_::_%n days ago_" => array("","%n dager siden"), "last month" => "forrige måned", -"_%n month ago_::_%n months ago_" => array("",""), +"_%n month ago_::_%n months ago_" => array("","%n dager siden"), "last year" => "forrige år", "years ago" => "år siden" ); 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 55845cf2ae9..bd9165ebb1a 100644 --- a/lib/l10n/pt_PT.php +++ b/lib/l10n/pt_PT.php @@ -65,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/ru_RU.php b/lib/l10n/ru_RU.php deleted file mode 100644 index 23e900721e8..00000000000 --- a/lib/l10n/ru_RU.php +++ /dev/null @@ -1,12 +0,0 @@ -<?php -$TRANSLATIONS = array( -"Help" => "Помощь", -"Settings" => "Настройки", -"Files" => "Файлы", -"Text" => "Текст", -"_%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=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.php b/lib/l10n/sk.php index 54812b15a6f..5cfafe6ca0c 100644 --- a/lib/l10n/sk.php +++ b/lib/l10n/sk.php @@ -1,5 +1,7 @@ <?php $TRANSLATIONS = array( +"Personal" => "Osobné", +"Settings" => "Nastavenia", "_%n minute ago_::_%n minutes ago_" => array("","",""), "_%n hour ago_::_%n hours ago_" => array("","",""), "_%n day go_::_%n days ago_" => array("","",""), 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..7d25836f7d8 100644 --- a/lib/l10n/tr.php +++ b/lib/l10n/tr.php @@ -10,16 +10,16 @@ $TRANSLATIONS = array( "Failed to upgrade \"%s\"." => "\"%s\" yükseltme başarısız oldu.", "Unknown filetype" => "Bilinmeyen dosya türü", "Invalid image" => "Geçersiz resim", -"web services under your control" => "Bilgileriniz güvenli ve şifreli", +"web services under your control" => "kontrolünüzün altındaki web hizmetleri", "cannot open \"%s\"" => "\"%s\" açılamıyor", -"ZIP download is turned off." => "ZIP indirmeleri kapatılmıştır.", +"ZIP download is turned off." => "ZIP indirmeleri kapatıldı.", "Files need to be downloaded one by one." => "Dosyaların birer birer indirilmesi gerekmektedir.", "Back to Files" => "Dosyalara dön", -"Selected files too large to generate zip file." => "Seçilen dosyalar bir zip dosyası oluşturmak için fazla büyüktür.", +"Selected files too large to generate zip file." => "Seçilen dosyalar bir zip dosyası oluşturmak için fazla büyük.", "Please download the files separately in smaller chunks or kindly ask your administrator." => "Dosyaları ayrı ayrı, küçük parçalar halinde indirin veya yöneticinizden yardım isteyin. ", "No source specified when installing app" => "Uygulama kurulurken bir kaynak belirtilmedi", "No href specified when installing app from http" => "Uygulama kuruluyorken http'de href belirtilmedi", -"No path specified when installing app from local file" => "Uygulama yerel dosyadan kuruluyorken dosya yolu belirtilmedi", +"No path specified when installing app from local file" => "Uygulama yerel dosyadan kurulurken dosya yolu belirtilmedi", "Archives of type %s are not supported" => "%s arşiv türü desteklenmiyor", "Failed to open archive when installing app" => "Uygulama kuruluyorken arşiv dosyası açılamadı", "App does not provide an info.xml file" => "Uygulama info.xml dosyası sağlamıyor", @@ -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/ur.php b/lib/l10n/ur.php new file mode 100644 index 00000000000..15f78e0bce6 --- /dev/null +++ b/lib/l10n/ur.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=2; plural=(n != 1);"; 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/api.php b/lib/private/api.php index 03d7b7382a5..c713368125c 100644 --- a/lib/private/api.php +++ b/lib/private/api.php @@ -33,7 +33,7 @@ class OC_API { const USER_AUTH = 1; const SUBADMIN_AUTH = 2; const ADMIN_AUTH = 3; - + /** * API Response Codes */ @@ -41,13 +41,13 @@ class OC_API { const RESPOND_SERVER_ERROR = 996; const RESPOND_NOT_FOUND = 998; const RESPOND_UNKNOWN_ERROR = 999; - + /** * api actions */ protected static $actions = array(); private static $logoutRequired = false; - + /** * registers an api call * @param string $method the http method @@ -58,7 +58,7 @@ class OC_API { * @param array $defaults * @param array $requirements */ - public static function register($method, $url, $action, $app, + public static function register($method, $url, $action, $app, $authLevel = OC_API::USER_AUTH, $defaults = array(), $requirements = array()) { @@ -75,7 +75,7 @@ class OC_API { } self::$actions[$name][] = array('app' => $app, 'action' => $action, 'authlevel' => $authLevel); } - + /** * handles an api call * @param array $parameters @@ -125,7 +125,7 @@ class OC_API { self::respond($response, $format); } - + /** * merge the returned result objects into one response * @param array $responses @@ -166,32 +166,31 @@ class OC_API { // Maybe any that are not OC_API::RESPOND_SERVER_ERROR // Merge failed responses if more than one $data = array(); - $meta = array(); foreach($shipped['failed'] as $failure) { $data = array_merge_recursive($data, $failure['response']->getData()); } $picked = reset($shipped['failed']); $code = $picked['response']->getStatusCode(); - $response = new OC_OCS_Result($data, $code); + $meta = $picked['response']->getMeta(); + $response = new OC_OCS_Result($data, $code, $meta['message']); return $response; } elseif(!empty($shipped['succeeded'])) { $responses = array_merge($shipped['succeeded'], $thirdparty['succeeded']); } elseif(!empty($thirdparty['failed'])) { // Merge failed responses if more than one $data = array(); - $meta = array(); foreach($thirdparty['failed'] as $failure) { $data = array_merge_recursive($data, $failure['response']->getData()); } $picked = reset($thirdparty['failed']); $code = $picked['response']->getStatusCode(); - $response = new OC_OCS_Result($data, $code); + $meta = $picked['response']->getMeta(); + $response = new OC_OCS_Result($data, $code, $meta['message']); return $response; } else { $responses = $thirdparty['succeeded']; } // Merge the successful responses - $meta = array(); $data = array(); foreach($responses as $app => $response) { @@ -200,22 +199,25 @@ class OC_API { } else { $data = array_merge_recursive($data, $response['response']->getData()); } - $codes[] = $response['response']->getStatusCode(); + $codes[] = array('code' => $response['response']->getStatusCode(), + 'meta' => $response['response']->getMeta()); } // Use any non 100 status codes $statusCode = 100; + $statusMessage = null; foreach($codes as $code) { - if($code != 100) { - $statusCode = $code; + if($code['code'] != 100) { + $statusCode = $code['code']; + $statusMessage = $code['meta']['message']; break; } } - $result = new OC_OCS_Result($data, $statusCode); + $result = new OC_OCS_Result($data, $statusCode, $statusMessage); return $result; } - + /** * authenticate the api call * @param array $action the action details as supplied to OC_API::register() @@ -261,8 +263,8 @@ class OC_API { return false; break; } - } - + } + /** * http basic auth * @return string|false (username, or false on failure) @@ -294,7 +296,7 @@ class OC_API { return false; } - + /** * respond to a call * @param OC_OCS_Result $result @@ -343,5 +345,5 @@ class OC_API { } } } - + } diff --git a/lib/private/app.php b/lib/private/app.php index eca40a81cc1..0c60557914a 100644 --- a/lib/private/app.php +++ b/lib/private/app.php @@ -166,20 +166,22 @@ class OC_App{ * get all enabled apps */ private static $enabledAppsCache = array(); - public static function getEnabledApps() { + public static function getEnabledApps($forceRefresh = false) { if(!OC_Config::getValue('installed', false)) { return array(); } - if(!empty(self::$enabledAppsCache)) { + if(!$forceRefresh && !empty(self::$enabledAppsCache)) { return self::$enabledAppsCache; } $apps=array('files'); $sql = 'SELECT `appid` FROM `*PREFIX*appconfig`' - .' WHERE `configkey` = \'enabled\' AND `configvalue`=\'yes\''; + . ' WHERE `configkey` = \'enabled\' AND `configvalue`=\'yes\'' + . ' ORDER BY `appid`'; if (OC_Config::getValue( 'dbtype', 'sqlite' ) === 'oci') { //FIXME oracle hack: need to explicitly cast CLOB to CHAR for comparison $sql = 'SELECT `appid` FROM `*PREFIX*appconfig`' - .' WHERE `configkey` = \'enabled\' AND to_char(`configvalue`)=\'yes\''; + . ' WHERE `configkey` = \'enabled\' AND to_char(`configvalue`)=\'yes\'' + . ' ORDER BY `appid`'; } $query = OC_DB::prepare( $sql ); $result=$query->execute(); @@ -553,6 +555,10 @@ class OC_App{ }elseif($child->getName()=='description') { $xml=(string)$child->asXML(); $data[$child->getName()]=substr($xml, 13, -14);//script <description> tags + }elseif($child->getName()=='documentation') { + foreach($child as $subchild) { + $data["documentation"][$subchild->getName()] = (string)$subchild; + } }else{ $data[$child->getName()]=(string)$child; } diff --git a/lib/private/appconfig.php b/lib/private/appconfig.php index 4f170e054e9..da0b2ff8604 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` ORDER BY `appid`'); $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/appframework/utility/simplecontainer.php b/lib/private/appframework/utility/simplecontainer.php index 7e4db63bde5..e631e657756 100644 --- a/lib/private/appframework/utility/simplecontainer.php +++ b/lib/private/appframework/utility/simplecontainer.php @@ -3,7 +3,7 @@ namespace OC\AppFramework\Utility; // register 3rdparty autoloaders -require_once __DIR__ . '/../../../../3rdparty/Pimple/Pimple.php'; +require_once 'Pimple/Pimple.php'; /** * Class SimpleContainer diff --git a/lib/private/config.php b/lib/private/config.php index caf7b1d7066..8a9d5ca6158 100644 --- a/lib/private/config.php +++ b/lib/private/config.php @@ -50,7 +50,7 @@ class Config { protected $debugMode; /** - * @param $configDir path to the config dir, needs to end with '/' + * @param string $configDir path to the config dir, needs to end with '/' */ public function __construct($configDir) { $this->configDir = $configDir; diff --git a/lib/private/connector/sabre/exceptionloggerplugin.php b/lib/private/connector/sabre/exceptionloggerplugin.php new file mode 100644 index 00000000000..8e77afaf207 --- /dev/null +++ b/lib/private/connector/sabre/exceptionloggerplugin.php @@ -0,0 +1,50 @@ +<?php + +/** + * ownCloud + * + * @author Vincent Petry + * @copyright 2014 Vincent Petry <pvince81@owncloud.com> + * + * @license AGPL3 + */ + +class OC_Connector_Sabre_ExceptionLoggerPlugin extends Sabre_DAV_ServerPlugin +{ + private $appName; + + /** + * @param string $loggerAppName app name to use when logging + */ + public function __construct($loggerAppName = 'webdav') { + $this->appName = $loggerAppName; + } + + /** + * This initializes the plugin. + * + * This function is called by Sabre_DAV_Server, after + * addPlugin is called. + * + * This method should set up the required event subscriptions. + * + * @param Sabre_DAV_Server $server + * @return void + */ + public function initialize(Sabre_DAV_Server $server) { + + $server->subscribeEvent('exception', array($this, 'logException'), 10); + } + + /** + * Log exception + * + * @internal param Exception $e exception + */ + public function logException($e) { + $exceptionClass = get_class($e); + if ($exceptionClass !== 'Sabre_DAV_Exception_NotAuthenticated') { + \OCP\Util::logException($this->appName, $e); + } + } +} diff --git a/lib/private/connector/sabre/file.php b/lib/private/connector/sabre/file.php index 295575f0af6..ed27cef440d 100644 --- a/lib/private/connector/sabre/file.php +++ b/lib/private/connector/sabre/file.php @@ -64,7 +64,7 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D } // mark file as partial while uploading (ignored by the scanner) - $partpath = $this->path . '.part'; + $partpath = $this->path . '.ocTransferId' . rand() . '.part'; // if file is located in /Shared we write the part file to the users // root folder because we can't create new files in /shared @@ -79,7 +79,7 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D \OC_Log::write('webdav', '\OC\Files\Filesystem::file_put_contents() failed', \OC_Log::ERROR); $fs->unlink($partpath); // because we have no clue about the cause we can only throw back a 500/Internal Server Error - throw new Sabre_DAV_Exception(); + throw new Sabre_DAV_Exception('Could not write file contents'); } } catch (\OCP\Files\NotPermittedException $e) { // a more general case - due to whatever reason the content could not be written @@ -105,7 +105,7 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D if ($renameOkay === false || $fileExists === false) { \OC_Log::write('webdav', '\OC\Files\Filesystem::rename() failed', \OC_Log::ERROR); $fs->unlink($partpath); - throw new Sabre_DAV_Exception(); + throw new Sabre_DAV_Exception('Could not rename part file to final file'); } // allow sync clients to send the mtime along in a header @@ -242,8 +242,11 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D $fileExists = $fs->file_exists($targetPath); if ($renameOkay === false || $fileExists === false) { \OC_Log::write('webdav', '\OC\Files\Filesystem::rename() failed', \OC_Log::ERROR); - $fs->unlink($targetPath); - throw new Sabre_DAV_Exception(); + // only delete if an error occurred and the target file was already created + if ($fileExists) { + $fs->unlink($targetPath); + } + throw new Sabre_DAV_Exception('Could not rename part file assembled from chunks'); } // allow sync clients to send the mtime along in a header 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/db/statementwrapper.php b/lib/private/db/statementwrapper.php index b8da1afc0e5..5e89261d936 100644 --- a/lib/private/db/statementwrapper.php +++ b/lib/private/db/statementwrapper.php @@ -30,25 +30,6 @@ class OC_DB_StatementWrapper { } /** - * provide numRows - */ - public function numRows() { - $type = OC_Config::getValue( "dbtype", "sqlite" ); - if ($type == 'oci') { - // OCI doesn't have a queryString, just do a rowCount for now - return $this->statement->rowCount(); - } - $regex = '/^SELECT\s+(?:ALL\s+|DISTINCT\s+)?(?:.*?)\s+FROM\s+(.*)$/i'; - $queryString = $this->statement->getWrappedStatement()->queryString; - if (preg_match($regex, $queryString, $output) > 0) { - $query = OC_DB::prepare("SELECT COUNT(*) FROM {$output[1]}"); - return $query->execute($this->lastArguments)->fetchColumn(); - }else{ - return $this->statement->rowCount(); - } - } - - /** * make execute return the result instead of a bool */ public function execute($input=array()) { 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/fileproxy.php b/lib/private/fileproxy.php index 52ec79b4bdb..2997aaf81b6 100644 --- a/lib/private/fileproxy.php +++ b/lib/private/fileproxy.php @@ -67,7 +67,11 @@ class OC_FileProxy{ self::$proxies[]=$proxy; } - public static function getProxies($operation) { + public static function getProxies($operation = null) { + if ($operation === null) { + // return all + return self::$proxies; + } $proxies=array(); foreach(self::$proxies as $proxy) { if(method_exists($proxy, $operation)) { diff --git a/lib/private/files.php b/lib/private/files.php index 6ffa14c0d91..8ce632013cf 100644 --- a/lib/private/files.php +++ b/lib/private/files.php @@ -83,7 +83,7 @@ class OC_Files { if ($basename) { $name = $basename . '.zip'; } else { - $name = 'owncloud.zip'; + $name = 'download.zip'; } set_time_limit($executionTime); @@ -115,12 +115,7 @@ class OC_Files { } OC_Util::obEnd(); if ($zip or \OC\Files\Filesystem::isReadable($filename)) { - if ( preg_match( "/MSIE/", $_SERVER["HTTP_USER_AGENT"] ) ) { - header( 'Content-Disposition: attachment; filename="' . rawurlencode($name) . '"' ); - } else { - header( 'Content-Disposition: attachment; filename*=UTF-8\'\'' . rawurlencode($name) - . '; filename="' . rawurlencode($name) . '"' ); - } + OC_Response::setContentDispositionHeader($name, 'attachment'); header('Content-Transfer-Encoding: binary'); OC_Response::disableCaching(); if ($zip) { diff --git a/lib/private/files/cache/cache.php b/lib/private/files/cache/cache.php index 8e682a96b75..1e7936ca26d 100644 --- a/lib/private/files/cache/cache.php +++ b/lib/private/files/cache/cache.php @@ -178,7 +178,7 @@ class Cache { if ($file['storage_mtime'] == 0) { $file['storage_mtime'] = $file['mtime']; } - if ($file['encrypted']) { + if ($file['encrypted'] or ($file['unencrypted_size'] > 0 and $file['mimetype'] === 'httpd/unix-directory')) { $file['encrypted_size'] = $file['size']; $file['size'] = $file['unencrypted_size']; } @@ -511,22 +511,34 @@ class Cache { $entry = $this->get($path); if ($entry && $entry['mimetype'] === 'httpd/unix-directory') { $id = $entry['fileid']; - $sql = 'SELECT SUM(`size`) AS f1, MIN(`size`) AS f2 FROM `*PREFIX*filecache` '. + $sql = 'SELECT SUM(`size`) AS f1, MIN(`size`) AS f2, ' . + 'SUM(`unencrypted_size`) AS f3 ' . + 'FROM `*PREFIX*filecache` ' . 'WHERE `parent` = ? AND `storage` = ?'; $result = \OC_DB::executeAudited($sql, array($id, $this->getNumericStorageId())); if ($row = $result->fetchRow()) { - list($sum, $min) = array_values($row); + list($sum, $min, $unencryptedSum) = array_values($row); $sum = (int)$sum; $min = (int)$min; + $unencryptedSum = (int)$unencryptedSum; if ($min === -1) { $totalSize = $min; } else { $totalSize = $sum; } + $update = array(); if ($entry['size'] !== $totalSize) { - $this->update($id, array('size' => $totalSize)); + $update['size'] = $totalSize; + } + if ($entry['unencrypted_size'] !== $unencryptedSum) { + $update['unencrypted_size'] = $unencryptedSum; + } + if (count($update) > 0) { + $this->update($id, $update); + } + if ($totalSize !== -1 and $unencryptedSum > 0) { + $totalSize = $unencryptedSum; } - } } return $totalSize; diff --git a/lib/private/files/cache/homecache.php b/lib/private/files/cache/homecache.php index 18dfbfe3191..71bb944da71 100644 --- a/lib/private/files/cache/homecache.php +++ b/lib/private/files/cache/homecache.php @@ -16,7 +16,7 @@ class HomeCache extends Cache { * @return int */ public function calculateFolderSize($path) { - if ($path !== '/' and $path !== '') { + if ($path !== '/' and $path !== '' and $path !== 'files') { return parent::calculateFolderSize($path); } diff --git a/lib/private/files/cache/scanner.php b/lib/private/files/cache/scanner.php index a8c069ee99f..92a4c01841b 100644 --- a/lib/private/files/cache/scanner.php +++ b/lib/private/files/cache/scanner.php @@ -122,7 +122,7 @@ class Scanner extends BasicEmitter { $propagateETagChange = true; } // only reuse data if the file hasn't explicitly changed - if (isset($data['mtime']) && isset($cacheData['mtime']) && $data['mtime'] === $cacheData['mtime']) { + if (isset($data['storage_mtime']) && isset($cacheData['storage_mtime']) && $data['storage_mtime'] === $cacheData['storage_mtime']) { if (($reuseExisting & self::REUSE_SIZE) && ($data['size'] === -1)) { $data['size'] = $cacheData['size']; } diff --git a/lib/private/files/cache/watcher.php b/lib/private/files/cache/watcher.php index 58f624c8990..251ecbe7071 100644 --- a/lib/private/files/cache/watcher.php +++ b/lib/private/files/cache/watcher.php @@ -40,7 +40,7 @@ class Watcher { * check $path for updates * * @param string $path - * @return boolean true if path was updated, false otherwise + * @return boolean | array true if path was updated, otherwise the cached data is returned */ public function checkUpdate($path) { $cachedEntry = $this->cache->get($path); @@ -56,7 +56,7 @@ class Watcher { $this->cache->correctFolderSize($path); return true; } - return false; + return $cachedEntry; } /** diff --git a/lib/private/files/storage/local.php b/lib/private/files/storage/local.php index 02e8df4af4e..db3c6bfca3a 100644 --- a/lib/private/files/storage/local.php +++ b/lib/private/files/storage/local.php @@ -256,7 +256,7 @@ if (\OC_Util::runningOnWindows()) { public function free_space($path) { $space = @disk_free_space($this->datadir . $path); - if ($space === false) { + if ($space === false || is_null($space)) { return \OC\Files\SPACE_UNKNOWN; } return $space; diff --git a/lib/private/files/storage/wrapper/quota.php b/lib/private/files/storage/wrapper/quota.php index 43016e0892f..a430e3e4617 100644 --- a/lib/private/files/storage/wrapper/quota.php +++ b/lib/private/files/storage/wrapper/quota.php @@ -95,7 +95,7 @@ class Quota extends Wrapper { public function fopen($path, $mode) { $source = $this->storage->fopen($path, $mode); $free = $this->free_space(''); - if ($free >= 0 && $mode !== 'r') { + if ($source && $free >= 0 && $mode !== 'r' && $mode !== 'rb') { return \OC\Files\Stream\Quota::wrap($source, $free); } else { return $source; diff --git a/lib/private/files/view.php b/lib/private/files/view.php index ac45a881331..d97544b865e 100644 --- a/lib/private/files/view.php +++ b/lib/private/files/view.php @@ -336,6 +336,19 @@ class View { } public function unlink($path) { + if ($path === '' || $path === '/') { + // do not allow deleting the root + return false; + } + $postFix = (substr($path, -1, 1) === '/') ? '/' : ''; + $absolutePath = Filesystem::normalizePath($this->getAbsolutePath($path)); + list($storage, $internalPath) = Filesystem::resolvePath($absolutePath . $postFix); + if (!$internalPath || $internalPath === '' || $internalPath === '/') { + // do not allow deleting the storage's root / the mount point + // because for some storages it might delete the whole contents + // but isn't supposed to work that way + return false; + } return $this->basicOperation('unlink', $path, array('delete')); } @@ -788,6 +801,7 @@ class View { * @var string $internalPath */ list($storage, $internalPath) = Filesystem::resolvePath($path); + $data = null; if ($storage) { $cache = $storage->getCache($internalPath); $permissionsCache = $storage->getPermissionsCache($internalPath); @@ -798,10 +812,12 @@ class View { $scanner->scan($internalPath, Cache\Scanner::SCAN_SHALLOW); } else { $watcher = $storage->getWatcher($internalPath); - $watcher->checkUpdate($internalPath); + $data = $watcher->checkUpdate($internalPath); } - $data = $cache->get($internalPath); + if (!is_array($data)) { + $data = $cache->get($internalPath); + } if ($data and $data['fileid']) { if ($includeMountPoints and $data['mimetype'] === 'httpd/unix-directory') { 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/helper.php b/lib/private/helper.php index 0bef427c6c1..917200f2f4a 100644 --- a/lib/private/helper.php +++ b/lib/private/helper.php @@ -161,6 +161,7 @@ class OC_Helper { 'application/vnd.oasis.opendocument.text-template' => 'x-office/document', 'application/vnd.oasis.opendocument.text-web' => 'x-office/document', 'application/vnd.oasis.opendocument.text-master' => 'x-office/document', + 'application/mspowerpoint' => 'x-office/presentation', 'application/vnd.ms-powerpoint' => 'x-office/presentation', 'application/vnd.openxmlformats-officedocument.presentationml.presentation' => 'x-office/presentation', 'application/vnd.openxmlformats-officedocument.presentationml.template' => 'x-office/presentation', @@ -171,6 +172,7 @@ class OC_Helper { 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12' => 'x-office/presentation', 'application/vnd.oasis.opendocument.presentation' => 'x-office/presentation', 'application/vnd.oasis.opendocument.presentation-template' => 'x-office/presentation', + 'application/msexcel' => 'x-office/spreadsheet', 'application/vnd.ms-excel' => 'x-office/spreadsheet', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' => 'x-office/spreadsheet', 'application/vnd.openxmlformats-officedocument.spreadsheetml.template' => 'x-office/spreadsheet', @@ -180,6 +182,7 @@ class OC_Helper { 'application/vnd.ms-excel.sheet.binary.macroEnabled.12' => 'x-office/spreadsheet', 'application/vnd.oasis.opendocument.spreadsheet' => 'x-office/spreadsheet', 'application/vnd.oasis.opendocument.spreadsheet-template' => 'x-office/spreadsheet', + 'application/msaccess' => 'database', ); if (isset($alias[$mimetype])) { @@ -252,7 +255,7 @@ class OC_Helper { if ($bytes < 1024) { return "$bytes B"; } - $bytes = round($bytes / 1024, 1); + $bytes = round($bytes / 1024, 0); if ($bytes < 1024) { return "$bytes kB"; } @@ -874,11 +877,13 @@ class OC_Helper { if (!function_exists($function_name)) { return false; } - $disabled = explode(', ', ini_get('disable_functions')); + $disabled = explode(',', ini_get('disable_functions')); + $disabled = array_map('trim', $disabled); if (in_array($function_name, $disabled)) { return false; } - $disabled = explode(', ', ini_get('suhosin.executor.func.blacklist')); + $disabled = explode(',', ini_get('suhosin.executor.func.blacklist')); + $disabled = array_map('trim', $disabled); if (in_array($function_name, $disabled)) { return false; } diff --git a/lib/private/hook.php b/lib/private/hook.php index 8516cf0dcff..b63b442c31b 100644 --- a/lib/private/hook.php +++ b/lib/private/hook.php @@ -97,4 +97,12 @@ class OC_Hook{ self::$registered=array(); } } + + /** + * DO NOT USE! + * For unit tests ONLY! + */ + static public function getHooks() { + return self::$registered; + } } diff --git a/lib/private/installer.php b/lib/private/installer.php index 8375b231e9b..835b6b4c01a 100644 --- a/lib/private/installer.php +++ b/lib/private/installer.php @@ -407,6 +407,9 @@ class OC_Installer{ include OC_App::getAppPath($app)."/appinfo/install.php"; } $info=OC_App::getAppInfo($app); + if (is_null($info)) { + return false; + } OC_Appconfig::setValue($app, 'installed_version', OC_App::getAppVersion($app)); //set remote/public handelers diff --git a/lib/private/json.php b/lib/private/json.php index 6ba0b13806b..5c5d7e3a3da 100644 --- a/lib/private/json.php +++ b/lib/private/json.php @@ -65,6 +65,20 @@ class OC_JSON{ } /** + * Check is a given user exists - send json error msg if not + * @param string $user + */ + public static function checkUserExists($user) { + if (!OCP\User::userExists($user)) { + $l = OC_L10N::get('lib'); + OCP\JSON::error(array('data' => array('message' => $l->t('Unknown user')))); + exit; + } + } + + + + /** * Check if the user is a subadmin, send json error msg if not */ public static function checkSubAdminUser() { @@ -109,7 +123,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/legacy/config.php b/lib/private/legacy/config.php index c457979113e..ab67c8d3020 100644 --- a/lib/private/legacy/config.php +++ b/lib/private/legacy/config.php @@ -38,7 +38,6 @@ * This class is responsible for reading and writing config.php, the very basic * configuration file of ownCloud. */ -OC_Config::$object = new \OC\Config(OC::$SERVERROOT.'/config/'); class OC_Config { /** diff --git a/lib/private/memcache/apc.php b/lib/private/memcache/apc.php index 575ee4427db..e995cbc526e 100644 --- a/lib/private/memcache/apc.php +++ b/lib/private/memcache/apc.php @@ -50,6 +50,8 @@ class APC extends Cache { static public function isAvailable() { if (!extension_loaded('apc')) { return false; + } elseif (!ini_get('apc.enabled')) { + return false; } elseif (!ini_get('apc.enable_cli') && \OC::$CLI) { return false; } else { diff --git a/lib/private/memcache/apcu.php b/lib/private/memcache/apcu.php index ccc1aa6e562..dac0f5f208a 100644 --- a/lib/private/memcache/apcu.php +++ b/lib/private/memcache/apcu.php @@ -12,7 +12,7 @@ class APCu extends APC { public function clear($prefix = '') { $ns = $this->getNamespace() . $prefix; $ns = preg_quote($ns, '/'); - $iter = new \APCIterator('/^'.$ns.'/'); + $iter = new \APCIterator('user', '/^'.$ns.'/'); return apc_delete($iter); } 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..40fb1d2d97d 100644 --- a/lib/private/mimetypes.list.php +++ b/lib/private/mimetypes.list.php @@ -21,87 +21,91 @@ */ /** - * list of mimetypes by extension + * Array mapping file extensions to mimetypes (in alphabetical order). */ - return array( + 'accdb'=>'application/msaccess', + 'ai' => 'application/illustrator', + 'avi'=>'video/x-msvideo', + 'bash' => 'text/x-shellscript', + 'blend'=>'application/x-blender', + 'cc' => 'text/x-c', + 'cdr' => 'application/coreldraw', + 'cpp' => 'text/x-c++src', 'css'=>'text/css', + 'c' => 'text/x-c', + 'c++' => 'text/x-c++src', + 'doc'=>'application/msword', + 'docx'=>'application/vnd.openxmlformats-officedocument.wordprocessingml.document', + 'dot'=>'application/msword', + 'dotx'=>'application/vnd.openxmlformats-officedocument.wordprocessingml.template', + 'dv'=>'video/dv', + 'epub' => 'application/epub+zip', + 'exe'=>'application/x-ms-dos-executable', 'flac'=>'audio/flac', 'gif'=>'image/gif', - 'gzip'=>'application/x-gzip', 'gz'=>'application/x-gzip', + 'gzip'=>'application/x-gzip', 'html'=>'text/html', 'htm'=>'text/html', - 'ics'=>'text/calendar', 'ical'=>'text/calendar', + 'ics'=>'text/calendar', + 'impress' => 'text/impress', 'jpeg'=>'image/jpeg', 'jpg'=>'image/jpeg', 'js'=>'application/javascript', + 'keynote'=>'application/x-iwork-keynote-sffkey', + 'kra'=>'application/x-krita', + 'm2t'=>'video/mp2t', + 'm4v'=>'video/mp4', + 'markdown' => 'text/markdown', + 'mdown' => 'text/markdown', + 'md' => 'text/markdown', + 'mdb'=>'application/msaccess', + 'mdwn' => 'text/markdown', + 'mobi' => 'application/x-mobipocket-ebook', + 'mov'=>'video/quicktime', + 'mp3'=>'audio/mpeg', + 'mp4'=>'video/mp4', + 'mpeg'=>'video/mpeg', + 'mpg'=>'video/mpeg', + 'msi'=>'application/x-msi', + 'numbers'=>'application/x-iwork-numbers-sffnumbers', + 'odg'=>'application/vnd.oasis.opendocument.graphics', + 'odp'=>'application/vnd.oasis.opendocument.presentation', + 'ods'=>'application/vnd.oasis.opendocument.spreadsheet', + 'odt'=>'application/vnd.oasis.opendocument.text', 'oga'=>'audio/ogg', 'ogg'=>'audio/ogg', 'ogv'=>'video/ogg', + 'pages'=>'application/x-iwork-pages-sffpages', 'pdf'=>'application/pdf', + 'php'=>'application/x-php', + 'pl'=>'application/x-pearl', 'png'=>'image/png', + 'ppt'=>'application/mspowerpoint', + 'pptx'=>'application/vnd.openxmlformats-officedocument.presentationml.presentation', + 'psd'=>'application/x-photoshop', + 'py'=>'text/x-script.python', + 'reveal' => 'text/reveal', + 'sgf' => 'application/sgf', + 'sh-lib' => 'text/x-shellscript', + 'sh' => 'text/x-shellscript', 'svg'=>'image/svg+xml', 'tar'=>'application/x-tar', - 'tgz'=>'application/x-compressed', 'tar.gz'=>'application/x-compressed', - 'tif'=>'image/tiff', + 'tgz'=>'application/x-compressed', 'tiff'=>'image/tiff', + 'tif'=>'image/tiff', 'txt'=>'text/plain', - 'zip'=>'application/zip', + 'vcard' => 'text/vcard', + 'vcf' => 'text/vcard', 'wav'=>'audio/wav', - 'odt'=>'application/vnd.oasis.opendocument.text', - 'ods'=>'application/vnd.oasis.opendocument.spreadsheet', - 'odg'=>'application/vnd.oasis.opendocument.graphics', - 'odp'=>'application/vnd.oasis.opendocument.presentation', - 'pages'=>'application/x-iwork-pages-sffpages', - 'numbers'=>'application/x-iwork-numbers-sffnumbers', - 'keynote'=>'application/x-iwork-keynote-sffkey', - 'kra'=>'application/x-krita', - 'mp3'=>'audio/mpeg', - 'doc'=>'application/msword', - 'docx'=>'application/msword', - 'xls'=>'application/msexcel', - 'xlsx'=>'application/msexcel', - 'php'=>'application/x-php', - 'exe'=>'application/x-ms-dos-executable', - 'pl'=>'application/x-pearl', - 'py'=>'application/x-python', - 'blend'=>'application/x-blender', - 'xcf'=>'application/x-gimp', - 'psd'=>'application/x-photoshop', - 'xml'=>'application/xml', - 'avi'=>'video/x-msvideo', - 'dv'=>'video/dv', - 'm2t'=>'video/mp2t', - 'mp4'=>'video/mp4', - 'm4v'=>'video/mp4', - 'mpg'=>'video/mpeg', - 'mpeg'=>'video/mpeg', - 'mov'=>'video/quicktime', 'webm'=>'video/webm', 'wmv'=>'video/x-ms-asf', - 'py'=>'text/x-script.phyton', - 'vcf' => 'text/vcard', - 'vcard' => 'text/vcard', - 'doc'=>'application/msword', - 'docx'=>'application/vnd.openxmlformats-officedocument.wordprocessingml.document', + 'xcf'=>'application/x-gimp', 'xls'=>'application/msexcel', 'xlsx'=>'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', - 'ppt'=>'application/mspowerpoint', - 'pptx'=>'application/vnd.openxmlformats-officedocument.presentationml.presentation', - 'sgf' => 'application/sgf', - 'cdr' => 'application/coreldraw', - 'impress' => 'text/impress', - 'ai' => 'application/illustrator', - 'epub' => 'application/epub+zip', - 'mobi' => 'application/x-mobipocket-ebook', - 'exe' => 'application', - 'msi' => 'application', - 'md' => 'text/markdown', - 'markdown' => 'text/markdown', - 'mdown' => 'text/markdown', - 'mdwn' => 'text/markdown', - 'reveal' => 'text/reveal' + 'xml'=>'application/xml', + 'zip'=>'application/zip', ); diff --git a/lib/private/preview/movies.php b/lib/private/preview/movies.php index ac771deb413..71cd3bae057 100644 --- a/lib/private/preview/movies.php +++ b/lib/private/preview/movies.php @@ -18,7 +18,7 @@ function findBinaryPath($program) { // movie preview is currently not supported on Windows if (!\OC_Util::runningOnWindows()) { - $isExecEnabled = !in_array('exec', explode(', ', ini_get('disable_functions'))); + $isExecEnabled = \OC_Helper::is_function_enabled('exec'); $ffmpegBinary = null; $avconvBinary = null; diff --git a/lib/private/preview/office.php b/lib/private/preview/office.php index 318ab51f851..7a4826c76ec 100644 --- a/lib/private/preview/office.php +++ b/lib/private/preview/office.php @@ -7,7 +7,7 @@ */ //both, libreoffice backend and php fallback, need imagick if (extension_loaded('imagick')) { - $isShellExecEnabled = !in_array('shell_exec', explode(', ', ini_get('disable_functions'))); + $isShellExecEnabled = \OC_Helper::is_function_enabled('shell_exec'); // LibreOffice preview is currently not supported on Windows if (!\OC_Util::runningOnWindows()) { diff --git a/lib/private/request.php b/lib/private/request.php index b2afda35922..d9d5ae08e28 100755 --- a/lib/private/request.php +++ b/lib/private/request.php @@ -7,6 +7,11 @@ */ class OC_Request { + + const USER_AGENT_IE = '/MSIE/'; + // Android Chrome user agent: https://developers.google.com/chrome/mobile/docs/user-agent + const USER_AGENT_ANDROID_MOBILE_CHROME = '#Android.*Chrome/[.0-9]*#'; + /** * @brief Check overwrite condition * @param string $type @@ -210,4 +215,22 @@ class OC_Request { return false; } } + + /** + * Checks whether the user agent matches a given regex + * @param string|array $agent agent name or array of agent names + * @return boolean true if at least one of the given agent matches, + * false otherwise + */ + static public function isUserAgent($agent) { + if (!is_array($agent)) { + $agent = array($agent); + } + foreach ($agent as $regex) { + if (preg_match($regex, $_SERVER['HTTP_USER_AGENT'])) { + return true; + } + } + return false; + } } diff --git a/lib/private/response.php b/lib/private/response.php index 674176d078b..04746437347 100644 --- a/lib/private/response.php +++ b/lib/private/response.php @@ -148,6 +148,20 @@ class OC_Response { } /** + * Sets the content disposition header (with possible workarounds) + * @param string $filename file name + * @param string $type disposition type, either 'attachment' or 'inline' + */ + static public function setContentDispositionHeader( $filename, $type = 'attachment' ) { + if (OC_Request::isUserAgent(array(OC_Request::USER_AGENT_IE, OC_Request::USER_AGENT_ANDROID_MOBILE_CHROME))) { + header( 'Content-Disposition: ' . rawurlencode($type) . '; filename="' . rawurlencode( $filename ) . '"' ); + } else { + header( 'Content-Disposition: ' . rawurlencode($type) . '; filename*=UTF-8\'\'' . rawurlencode( $filename ) + . '; filename="' . rawurlencode( $filename ) . '"' ); + } + } + + /** * @brief Send file as response, checking and setting caching headers * @param $filepath of file to send */ diff --git a/lib/private/router.php b/lib/private/router.php index dbaca9e0d5d..19c1e4473ec 100644 --- a/lib/private/router.php +++ b/lib/private/router.php @@ -67,7 +67,8 @@ class OC_Router { $this->useCollection($app); require_once $file; $collection = $this->getCollection($app); - $this->root->addCollection($collection, '/apps/'.$app); + $collection->addPrefix('/apps/'.$app); + $this->root->addCollection($collection); } $this->useCollection('root'); require_once 'settings/routes.php'; @@ -76,7 +77,8 @@ class OC_Router { // include ocs routes require_once 'ocs/routes.php'; $collection = $this->getCollection('ocs'); - $this->root->addCollection($collection, '/ocs'); + $collection->addPrefix('/ocs'); + $this->root->addCollection($collection); } protected function getCollection($name) { diff --git a/lib/private/server.php b/lib/private/server.php index 77c3732a9ca..2cbd37a97d7 100644 --- a/lib/private/server.php +++ b/lib/private/server.php @@ -69,10 +69,18 @@ class Server extends SimpleContainer implements IServerContainer { return new Root($manager, $view, $user); }); $this->registerService('UserManager', function($c) { - return new \OC\User\Manager(); + /** + * @var SimpleContainer $c + * @var \OC\AllConfig $config + */ + $config = $c->query('AllConfig'); + return new \OC\User\Manager($config); }); $this->registerService('UserSession', function($c) { - /** @var $c SimpleContainer */ + /** + * @var SimpleContainer $c + * @var \OC\User\Manager $manager + */ $manager = $c->query('UserManager'); $userSession = new \OC\User\Session($manager, \OC::$session); $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { @@ -120,7 +128,9 @@ class Server extends SimpleContainer implements IServerContainer { return new \OC\L10N\Factory(); }); $this->registerService('URLGenerator', function($c) { - return new \OC\URLGenerator(); + /** @var $c SimpleContainer */ + $config = $c->query('AllConfig'); + return new \OC\URLGenerator($config); }); $this->registerService('AppHelper', function($c) { return new \OC\AppHelper(); @@ -249,7 +259,7 @@ class Server extends SimpleContainer implements IServerContainer { } /** - * @return \OC\Config + * @return \OCP\IConfig */ function getConfig() { return $this->query('AllConfig'); 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/setup.php b/lib/private/setup.php index b5c530a091f..5232398d1d7 100644 --- a/lib/private/setup.php +++ b/lib/private/setup.php @@ -159,6 +159,9 @@ class OC_Setup { $content.= "</IfModule>\n"; $content.= "AddDefaultCharset utf-8\n"; $content.= "Options -Indexes\n"; + $content.= "<IfModule pagespeed_module>\n"; + $content.= "ModPagespeed Off\n"; + $content.= "</IfModule>\n"; @file_put_contents(OC::$SERVERROOT.'/.htaccess', $content); //supress errors in case we don't have permissions for it self::protectDataDirectory(); 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/templatelayout.php b/lib/private/templatelayout.php index 625f3424a04..d5cd5039753 100644 --- a/lib/private/templatelayout.php +++ b/lib/private/templatelayout.php @@ -46,6 +46,7 @@ class OC_TemplateLayout extends OC_Template { $user_displayname = OC_User::getDisplayName(); $this->assign( 'user_displayname', $user_displayname ); $this->assign( 'user_uid', OC_User::getUser() ); + $this->assign( 'appsmanagement_active', strpos(OC_Request::requestUri(), OC_Helper::linkToRoute('settings_apps')) === 0 ); $this->assign('enableAvatars', \OC_Config::getValue('enable_avatars', true)); } else if ($renderas == 'guest' || $renderas == 'error') { parent::__construct('core', 'layout.guest'); diff --git a/lib/private/urlgenerator.php b/lib/private/urlgenerator.php index 7795011fd06..4e3c1109000 100644 --- a/lib/private/urlgenerator.php +++ b/lib/private/urlgenerator.php @@ -15,6 +15,19 @@ use RuntimeException; * Class to generate URLs */ class URLGenerator implements IURLGenerator { + + /** + * @var \OCP\IConfig + */ + private $config; + + /** + * @param \OCP\IConfig $config + */ + public function __construct($config) { + $this->config = $config; + } + /** * @brief Creates an url using a defined route * @param $route @@ -41,12 +54,18 @@ class URLGenerator implements IURLGenerator { * Returns a url to the given app and file. */ public function linkTo( $app, $file, $args = array() ) { + $frontControllerActive=($this->config->getSystemValue('front_controller_active', 'false') == 'true'); + if( $app != '' ) { $app_path = \OC_App::getAppPath($app); // Check if the app is in the app folder if ($app_path && file_exists($app_path . '/' . $file)) { if (substr($file, -3) == 'php' || substr($file, -3) == 'css') { + $urlLinkTo = \OC::$WEBROOT . '/index.php/apps/' . $app; + if ($frontControllerActive) { + $urlLinkTo = \OC::$WEBROOT . '/apps/' . $app; + } $urlLinkTo .= ($file != 'index.php') ? '/' . $file : ''; } else { $urlLinkTo = \OC_App::getAppWebPath($app) . '/' . $file; @@ -58,7 +77,11 @@ class URLGenerator implements IURLGenerator { if (file_exists(\OC::$SERVERROOT . '/core/' . $file)) { $urlLinkTo = \OC::$WEBROOT . '/core/' . $file; } else { - $urlLinkTo = \OC::$WEBROOT . '/' . $file; + if ($frontControllerActive && $file === 'index.php') { + $urlLinkTo = \OC::$WEBROOT; + } else { + $urlLinkTo = \OC::$WEBROOT . '/' . $file; + } } } diff --git a/lib/private/user.php b/lib/private/user.php index e0d6b9f3f51..98ebebbe5c1 100644 --- a/lib/private/user.php +++ b/lib/private/user.php @@ -246,6 +246,8 @@ class OC_User { session_regenerate_id(true); self::setUserId($uid); self::setDisplayName($uid); + self::getUserSession()->setLoginName($uid); + OC_Hook::emit( "OC_User", "post_login", array( "uid" => $uid, 'password'=>'' )); return true; } diff --git a/lib/private/user/backend.php b/lib/private/user/backend.php index 02c93d13bdf..f4e5618e04a 100644 --- a/lib/private/user/backend.php +++ b/lib/private/user/backend.php @@ -31,13 +31,15 @@ define('OC_USER_BACKEND_NOT_IMPLEMENTED', -501); /** * actions that user backends can define */ -define('OC_USER_BACKEND_CREATE_USER', 0x0000001); -define('OC_USER_BACKEND_SET_PASSWORD', 0x0000010); -define('OC_USER_BACKEND_CHECK_PASSWORD', 0x0000100); -define('OC_USER_BACKEND_GET_HOME', 0x0001000); -define('OC_USER_BACKEND_GET_DISPLAYNAME', 0x0010000); -define('OC_USER_BACKEND_SET_DISPLAYNAME', 0x0100000); -define('OC_USER_BACKEND_PROVIDE_AVATAR', 0x1000000); +define('OC_USER_BACKEND_CREATE_USER', 0x00000001); +define('OC_USER_BACKEND_SET_PASSWORD', 0x00000010); +define('OC_USER_BACKEND_CHECK_PASSWORD', 0x00000100); +define('OC_USER_BACKEND_GET_HOME', 0x00001000); +define('OC_USER_BACKEND_GET_DISPLAYNAME', 0x00010000); +define('OC_USER_BACKEND_SET_DISPLAYNAME', 0x00100000); +define('OC_USER_BACKEND_PROVIDE_AVATAR', 0x01000000); +define('OC_USER_BACKEND_COUNT_USERS', 0x10000000); +//more actions cannot be defined without breaking 32bit platforms! /** * Abstract base class for user management. Provides methods for querying backend @@ -55,6 +57,7 @@ abstract class OC_User_Backend implements OC_User_Interface { OC_USER_BACKEND_GET_DISPLAYNAME => 'getDisplayName', OC_USER_BACKEND_SET_DISPLAYNAME => 'setDisplayName', OC_USER_BACKEND_PROVIDE_AVATAR => 'canChangeAvatar', + OC_USER_BACKEND_COUNT_USERS => 'countUsers', ); /** diff --git a/lib/private/user/database.php b/lib/private/user/database.php index 3db770f9898..1a63755b980 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; } } @@ -255,4 +253,19 @@ class OC_User_Database extends OC_User_Backend { return true; } + /** + * counts the users in the database + * + * @return int | bool + */ + public function countUsers() { + $query = OC_DB::prepare('SELECT COUNT(*) FROM `*PREFIX*users`'); + $result = $query->execute(); + if (OC_DB::isError($result)) { + OC_Log::write('core', OC_DB::getErrorMessage($result), OC_Log::ERROR); + return false; + } + return $result->fetchOne(); + } + } diff --git a/lib/private/user/dummy.php b/lib/private/user/dummy.php index 52be7edfa75..fc15a630cf3 100644 --- a/lib/private/user/dummy.php +++ b/lib/private/user/dummy.php @@ -123,4 +123,13 @@ class OC_User_Dummy extends OC_User_Backend { public function hasUserListings() { return true; } + + /** + * counts the users in the database + * + * @return int | bool + */ + public function countUsers() { + return 0; + } } diff --git a/lib/private/user/manager.php b/lib/private/user/manager.php index 703c8cd7413..90970ef9963 100644 --- a/lib/private/user/manager.php +++ b/lib/private/user/manager.php @@ -35,7 +35,16 @@ class Manager extends PublicEmitter { */ private $cachedUsers = array(); - public function __construct() { + /** + * @var \OC\AllConfig $config + */ + private $config; + + /** + * @param \OC\AllConfig $config + */ + public function __construct($config = null) { + $this->config = $config; $cachedUsers = $this->cachedUsers; $this->listen('\OC\User', 'postDelete', function ($user) use (&$cachedUsers) { $i = array_search($user, $cachedUsers); @@ -103,7 +112,7 @@ class Manager extends PublicEmitter { if (isset($this->cachedUsers[$uid])) { return $this->cachedUsers[$uid]; } - $this->cachedUsers[$uid] = new User($uid, $backend, $this); + $this->cachedUsers[$uid] = new User($uid, $backend, $this, $this->config); return $this->cachedUsers[$uid]; } @@ -141,7 +150,7 @@ class Manager extends PublicEmitter { */ public function checkPassword($loginname, $password) { foreach ($this->backends as $backend) { - if($backend->implementsActions(\OC_USER_BACKEND_CHECK_PASSWORD)) { + if ($backend->implementsActions(\OC_USER_BACKEND_CHECK_PASSWORD)) { $uid = $backend->checkPassword($loginname, $password); if ($uid !== false) { return $this->getUserObject($uid, $backend); @@ -234,7 +243,7 @@ class Manager extends PublicEmitter { // Allowed are: "a-z", "A-Z", "0-9" and "_.@-" if (preg_match('/[^a-zA-Z0-9 _\.@\-]/', $uid)) { throw new \Exception('Only the following characters are allowed in a username:' - . ' "a-z", "A-Z", "0-9", and "_.@-"'); + . ' "a-z", "A-Z", "0-9", and "_.@-"'); } // No empty username if (trim($uid) == '') { @@ -261,4 +270,26 @@ class Manager extends PublicEmitter { } return false; } + + /** + * returns how many users per backend exist (if supported by backend) + * + * @return array with backend class as key and count number as value + */ + public function countUsers() { + $userCountStatistics = array(); + foreach ($this->backends as $backend) { + if ($backend->implementsActions(\OC_USER_BACKEND_COUNT_USERS)) { + $backendusers = $backend->countUsers(); + if($backendusers !== false) { + if(isset($userCountStatistics[get_class($backend)])) { + $userCountStatistics[get_class($backend)] += $backendusers; + } else { + $userCountStatistics[get_class($backend)] = $backendusers; + } + } + } + } + return $userCountStatistics; + } } diff --git a/lib/private/user/session.php b/lib/private/user/session.php index 9c9bee3da25..1e299416fb3 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 $loginName 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..ef5364cbf7b 100644 --- a/lib/private/user/user.php +++ b/lib/private/user/user.php @@ -38,11 +38,22 @@ class User { private $emitter; /** + * @var string $home + */ + private $home; + + /** + * @var \OC\AllConfig $config + */ + private $config; + + /** * @param string $uid * @param \OC_User_Backend $backend - * @param Emitter $emitter + * @param \OC\Hooks\Emitter $emitter + * @param \OC\AllConfig $config */ - public function __construct($uid, $backend, $emitter = null) { + public function __construct($uid, $backend, $emitter = null, $config = null) { $this->uid = $uid; if ($backend and $backend->implementsActions(OC_USER_BACKEND_GET_DISPLAYNAME)) { $this->displayName = $backend->getDisplayName($uid); @@ -51,8 +62,13 @@ class User { } $this->backend = $backend; $this->emitter = $emitter; - $enabled = \OC_Preferences::getValue($uid, 'core', 'enabled', 'true'); //TODO: DI for OC_Preferences - $this->enabled = ($enabled === 'true'); + $this->config = $config; + if ($this->config) { + $enabled = $this->config->getUserValue($uid, 'core', 'enabled', 'true'); + $this->enabled = ($enabled === 'true'); + } else { + $this->enabled = true; + } } /** @@ -133,10 +149,16 @@ 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; + } elseif ($this->config) { + $this->home = $this->config->getSystemValue('datadirectory') . '/' . $this->uid; + } else { + $this->home = \OC::$SERVERROOT . '/data/' . $this->uid; + } } - return \OC_Config::getValue("datadirectory", \OC::$SERVERROOT . "/data") . '/' . $this->uid; //TODO switch to Config object once implemented + return $this->home; } /** @@ -145,7 +167,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; @@ -166,7 +188,11 @@ class User { * @return bool */ public function canChangeDisplayName() { - return $this->backend->implementsActions(\OC_USER_BACKEND_SET_DISPLAYNAME); + if ($this->config and $this->config->getSystemValue('allow_user_to_change_display_name') === false) { + return false; + } else { + return $this->backend->implementsActions(\OC_USER_BACKEND_SET_DISPLAYNAME); + } } /** @@ -185,7 +211,9 @@ class User { */ public function setEnabled($enabled) { $this->enabled = $enabled; - $enabled = ($enabled) ? 'true' : 'false'; - \OC_Preferences::setValue($this->uid, 'core', 'enabled', $enabled); + if ($this->config) { + $enabled = ($enabled) ? 'true' : 'false'; + $this->config->setUserValue($this->uid, 'core', 'enabled', $enabled); + } } } diff --git a/lib/private/util.php b/lib/private/util.php index a73564b3f68..8aa7a074d0d 100755 --- a/lib/private/util.php +++ b/lib/private/util.php @@ -51,6 +51,10 @@ class OC_Util { self::$rootMounted = true; } + if ($user != '' && !OCP\User::userExists($user)) { + return false; + } + //if we aren't logged in, there is no use to set up the filesystem if( $user != "" ) { \OC\Files\Filesystem::addStorageWrapper(function($mountPoint, $storage){ @@ -312,7 +316,7 @@ class OC_Util { .'" target="_blank">giving the webserver write access to the root directory</a>.'; // Check if config folder is writable. - if(!is_writable(OC::$SERVERROOT."/config/") or !is_readable(OC::$SERVERROOT."/config/")) { + if(!is_writable(OC::$configDir) or !is_readable(OC::$configDir)) { $errors[] = array( 'error' => "Can't write into config directory", 'hint' => 'This can usually be fixed by ' @@ -580,7 +584,7 @@ class OC_Util { // Check if we are a user if( !OC_User::isLoggedIn()) { header( 'Location: '.OC_Helper::linkToAbsolute( '', 'index.php', - array('redirectUrl' => OC_Request::requestUri()) + array('redirect_url' => OC_Request::requestUri()) )); exit(); } @@ -892,6 +896,11 @@ class OC_Util { return false; } + // in case the connection is via proxy return true to avoid connecting to owncloud.org + if(OC_Config::getValue('proxy', '') != '') { + return true; + } + // try to connect to owncloud.org to see if http connections to the internet are possible. $connected = @fsockopen("www.owncloud.org", 80); if ($connected) { @@ -1085,7 +1094,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..cd5d233ef90 100644 --- a/lib/public/json.php +++ b/lib/public/json.php @@ -167,6 +167,22 @@ class JSON { * @return string json formatted string if not admin user. */ public static function checkAdminUser() { - return(\OC_JSON::checkAdminUser()); + \OC_JSON::checkAdminUser(); + } + + /** + * Encode JSON + * @param array $data + */ + public static function encode($data) { + return(\OC_JSON::encode($data)); + } + + /** + * Check is a given user exists - send json error msg if not + * @param string $user + */ + public static function checkUserExists($user) { + \OC_JSON::checkUserExists($user); } } diff --git a/lib/public/response.php b/lib/public/response.php index 2ca0a0c9fa4..24d3c81d628 100644 --- a/lib/public/response.php +++ b/lib/public/response.php @@ -55,6 +55,15 @@ class Response { } /** + * Sets the content disposition header (with possible workarounds) + * @param string $filename file name + * @param string $type disposition type, either 'attachment' or 'inline' + */ + static public function setContentDispositionHeader( $filename, $type = 'attachment' ) { + \OC_Response::setContentDispositionHeader( $filename, $type ); + } + + /** * Disable browser caching * @see enableCaching with cache_time = 0 */ diff --git a/lib/public/share.php b/lib/public/share.php index 6b3397c85c6..f832d04a70f 100644 --- a/lib/public/share.php +++ b/lib/public/share.php @@ -347,20 +347,29 @@ class Share { } /** - * Get the item shared by a token - * @param string token - * @return Item + * Based on the given token the share information will be returned - password protected shares will be verified + * @param string $token + * @return array | bool false will be returned in case the token is unknown or unauthorized */ - public static function getShareByToken($token) { + public static function getShareByToken($token, $checkPasswordProtection = true) { $query = \OC_DB::prepare('SELECT * FROM `*PREFIX*share` WHERE `token` = ?', 1); $result = $query->execute(array($token)); if (\OC_DB::isError($result)) { \OC_Log::write('OCP\Share', \OC_DB::getErrorMessage($result) . ', token=' . $token, \OC_Log::ERROR); } $row = $result->fetchRow(); + if ($row === false) { + return false; + } if (is_array($row) and self::expireItem($row)) { return false; } + + // password protected shares need to be authenticated + if ($checkPasswordProtection && !\OCP\Share::checkPasswordProtectedShare($row)) { + return false; + } + return $row; } @@ -655,7 +664,15 @@ class Share { * @return Returns true on success or false on failure */ public static function unshareAll($itemType, $itemSource) { - if ($shares = self::getItemShared($itemType, $itemSource)) { + // Get all of the owners of shares of this item. + $query = \OC_DB::prepare( 'SELECT `uid_owner` from `*PREFIX*share` WHERE `item_type`=? AND `item_source`=?' ); + $result = $query->execute(array($itemType, $itemSource)); + $shares = array(); + // Add each owner's shares to the array of all shares for this item. + while ($row = $result->fetchRow()) { + $shares = array_merge($shares, self::getItems($itemType, $itemSource, null, null, $row['uid_owner'])); + } + if (!empty($shares)) { // Pass all the vars we have for now, they may be useful $hookParams = array( 'itemType' => $itemType, @@ -850,9 +867,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; } @@ -1881,6 +1897,34 @@ class Share { } } + /** + * In case a password protected link is not yet authenticated this function will return false + * + * @param array $linkItem + * @return bool + */ + public static function checkPasswordProtectedShare(array $linkItem) { + if (!isset($linkItem['share_with'])) { + return true; + } + if (!isset($linkItem['share_type'])) { + return true; + } + if (!isset($linkItem['id'])) { + return true; + } + + if ($linkItem['share_type'] != \OCP\Share::SHARE_TYPE_LINK) { + return true; + } + + if ( \OC::$session->exists('public_link_authenticated') + && \OC::$session->get('public_link_authenticated') === $linkItem['id'] ) { + return true; + } + + return false; + } } /** diff --git a/lib/public/util.php b/lib/public/util.php index cf7ac63ba51..d8497e29cfc 100644 --- a/lib/public/util.php +++ b/lib/public/util.php @@ -88,14 +88,18 @@ class Util { * @param Exception $ex exception to log */ public static function logException( $app, \Exception $ex ) { - $message = $ex->getMessage(); + $class = get_class($ex); + if ($class !== 'Exception') { + $message = $class . ': '; + } + $message .= $ex->getMessage(); if ($ex->getCode()) { $message .= ' [' . $ex->getCode() . ']'; } \OCP\Util::writeLog($app, 'Exception: ' . $message, \OCP\Util::FATAL); if (defined('DEBUG') and DEBUG) { // also log stack trace - $stack = explode('#', $ex->getTraceAsString()); + $stack = explode("\n", $ex->getTraceAsString()); // first element is empty array_shift($stack); foreach ($stack as $s) { @@ -103,9 +107,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() . '] '; @@ -255,8 +258,13 @@ class Util { * Example: when given lostpassword-noreply as $user_part param, * and is currently accessed via http(s)://example.com/, * it would return 'lostpassword-noreply@example.com' + * + * If the configuration value 'mail_from_address' is set in + * config.php, this value will override the $user_part that + * is passed to this function */ public static function getDefaultEmailAddress($user_part) { + $user_part = \OC_Config::getValue('mail_from_address', $user_part); $host_name = self::getServerHostName(); $host_name = \OC_Config::getValue('mail_domain', $host_name); $defaultEmailAddress = $user_part.'@'.$host_name; |