summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/base.php17
-rw-r--r--lib/l10n/ast.php1
-rw-r--r--lib/l10n/eo.php6
-rw-r--r--lib/l10n/et_EE.php5
-rw-r--r--lib/l10n/fr.php1
-rw-r--r--lib/l10n/ja.php1
-rw-r--r--lib/l10n/nl.php1
-rw-r--r--lib/l10n/pt_BR.php12
-rw-r--r--lib/l10n/ru.php12
-rw-r--r--lib/l10n/sk_SK.php1
-rw-r--r--lib/private/app.php13
-rw-r--r--lib/private/backgroundjob/joblist.php4
-rw-r--r--lib/private/backgroundjob/legacy/queuedjob.php4
-rw-r--r--lib/private/backgroundjob/legacy/regularjob.php4
-rw-r--r--lib/private/connector/sabre/objecttree.php5
-rw-r--r--lib/private/files/storage/dav.php453
-rw-r--r--lib/private/files/utils/scanner.php11
-rw-r--r--lib/private/files/view.php2
-rw-r--r--lib/private/helper.php17
-rw-r--r--lib/private/installer.php6
-rw-r--r--lib/private/repair.php18
-rw-r--r--lib/private/route/router.php4
-rw-r--r--lib/private/setup.php8
-rw-r--r--lib/private/share/helper.php22
-rw-r--r--lib/private/share/share.php60
-rwxr-xr-xlib/private/util.php17
-rw-r--r--lib/public/util.php9
-rw-r--r--lib/repair/repairmimetypes.php125
28 files changed, 785 insertions, 54 deletions
diff --git a/lib/base.php b/lib/base.php
index 7bde1dbeb8f..eef094737b6 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -262,15 +262,10 @@ class OC {
* check if the instance needs to preform an upgrade
*
* @return bool
+ * @deprecated use \OCP\Util::needUpgrade instead
*/
public static function needUpgrade() {
- if (OC_Config::getValue('installed', false)) {
- $installedVersion = OC_Config::getValue('version', '0.0.0');
- $currentVersion = implode('.', OC_Util::getVersion());
- return version_compare($currentVersion, $installedVersion, '>');
- } else {
- return false;
- }
+ return \OCP\Util::needUpgrade();
}
/**
@@ -279,7 +274,7 @@ class OC {
* @return bool|void
*/
public static function checkUpgrade($showTemplate = true) {
- if (self::needUpgrade()) {
+ if (\OCP\Util::needUpgrade()) {
if ($showTemplate && !OC_Config::getValue('maintenance', false)) {
$version = OC_Util::getVersion();
$oldTheme = OC_Config::getValue('theme');
@@ -595,7 +590,7 @@ class OC {
* register hooks for the cache
*/
public static function registerCacheHooks() {
- if (OC_Config::getValue('installed', false) && !self::needUpgrade()) { //don't try to do this before we are properly setup
+ if (OC_Config::getValue('installed', false) && !\OCP\Util::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
@@ -608,7 +603,7 @@ class OC {
* register hooks for the cache
*/
public static function registerLogRotate() {
- if (OC_Config::getValue('installed', false) && OC_Config::getValue('log_rotate_size', false) && !self::needUpgrade()) {
+ if (OC_Config::getValue('installed', false) && OC_Config::getValue('log_rotate_size', false) && !\OCP\Util::needUpgrade()) {
//don't try to do this before we are properly setup
//use custom logfile path if defined, otherwise use default of owncloud.log in data directory
\OCP\BackgroundJob::registerJob('OC\Log\Rotate', OC_Config::getValue('logfile', OC_Config::getValue("datadirectory", OC::$SERVERROOT . '/data') . '/owncloud.log'));
@@ -695,7 +690,7 @@ class OC {
if (!self::$CLI and (!isset($_GET["logout"]) or ($_GET["logout"] !== 'true'))) {
try {
- if (!OC_Config::getValue('maintenance', false) && !self::needUpgrade()) {
+ if (!OC_Config::getValue('maintenance', false) && !\OCP\Util::needUpgrade()) {
OC_App::loadApps(array('authentication'));
OC_App::loadApps(array('filesystem', 'logging'));
OC_App::loadApps();
diff --git a/lib/l10n/ast.php b/lib/l10n/ast.php
index e4214df03f1..273ef27b44a 100644
--- a/lib/l10n/ast.php
+++ b/lib/l10n/ast.php
@@ -8,6 +8,7 @@ $TRANSLATIONS = array(
"Users" => "Usuarios",
"Admin" => "Almin",
"Failed to upgrade \"%s\"." => "Fallu al anovar \"%s\".",
+"App \\\"%s\\\" can't be installed because it is not compatible with this version of ownCloud." => "L'aplicación \\\"%s\\\" nun pue instalase porque nun ye compatible con esta versión d'ownCloud",
"No app name specified" => "Nun s'especificó nome de l'aplicación",
"Unknown filetype" => "Triba de ficheru desconocida",
"Invalid image" => "Imaxe inválida",
diff --git a/lib/l10n/eo.php b/lib/l10n/eo.php
index 071f6a98859..b238cc30508 100644
--- a/lib/l10n/eo.php
+++ b/lib/l10n/eo.php
@@ -5,12 +5,18 @@ $TRANSLATIONS = array(
"Settings" => "Agordo",
"Users" => "Uzantoj",
"Admin" => "Administranto",
+"Failed to upgrade \"%s\"." => "Malsukcesis ĝisdatigo de “%s”.",
+"App \\\"%s\\\" can't be installed because it is not compatible with this version of ownCloud." => "La aplikaĵo “%s” ne povas instaliĝi ĉar ĝi ne kongruas kun ĉi tiu eldono de ownCloud.",
"Unknown filetype" => "Ne konatas dosiertipo",
"Invalid image" => "Ne validas bildo",
"web services under your control" => "TTT-servoj regataj de vi",
+"App directory already exists" => "La dosierujo de la aplikaĵo jam ekzistas",
+"App does not provide an info.xml file" => "La aplikaĵo ne provizas dosieron info.xml",
+"App can't be installed because it is not compatible with this version of ownCloud" => "La aplikaĵo ne povas instaliĝi ĉar ĝi ne kongruas kun ĉi tiu eldono de ownCloud",
"Application is not enabled" => "La aplikaĵo ne estas kapabligita",
"Authentication error" => "Aŭtentiga eraro",
"Token expired. Please reload page." => "Ĵetono eksvalidiĝis. Bonvolu reŝargi la paĝon.",
+"Unknown user" => "Nekonata uzanto",
"%s enter the database username." => "%s enigu la uzantonomon de la datumbazo.",
"%s enter the database name." => "%s enigu la nomon de la datumbazo.",
"%s you may not use dots in the database name" => "%s vi ne povas uzi punktojn en la nomo de la datumbazo",
diff --git a/lib/l10n/et_EE.php b/lib/l10n/et_EE.php
index 61c47f28e3a..30fe1a58aaa 100644
--- a/lib/l10n/et_EE.php
+++ b/lib/l10n/et_EE.php
@@ -8,6 +8,7 @@ $TRANSLATIONS = array(
"Users" => "Kasutajad",
"Admin" => "Admin",
"Failed to upgrade \"%s\"." => "Ebaõnnestunud uuendus \"%s\".",
+"App \\\"%s\\\" can't be installed because it is not compatible with this version of ownCloud." => "Rakendit \\\"%s\\\" ei saa paigaldada, kuna see pole ühilduv selle ownCloud versiooniga.",
"No app name specified" => "Ühegi rakendi nime pole määratletud",
"Unknown filetype" => "Tundmatu failitüüp",
"Invalid image" => "Vigane pilt",
@@ -57,6 +58,7 @@ $TRANSLATIONS = array(
"Sharing %s failed, because this item is already shared with %s" => "%s jagamine ebaõnnestus, kuna see üksus on juba jagatud %s",
"Sharing %s failed, because the group %s does not exist" => "%s jagamine ebaõnnestus, kuna gruppi %s pole olemas",
"Sharing %s failed, because %s is not a member of the group %s" => "%s jagamine ebaõnnestus, kuna %s pole grupi %s liige",
+"You need to provide a password to create a public link, only protected links are allowed" => "Avaliku viite tekitamiseks pead sisestama parooli, ainult kaitstud viited on lubatud",
"Sharing %s failed, because sharing with links is not allowed" => "%s jagamine ebaõnnestus, kuna linkidega jagamine pole lubatud",
"Share type %s is not valid for %s" => "Jagamise tüüp %s ei ole õige %s jaoks",
"Setting permissions for %s failed, because the permissions exceed permissions granted to %s" => "Lubade seadistus %s jaoks ebaõnnestus, kuna antud õigused ületavad %s jaoks määratud õigusi",
@@ -83,6 +85,7 @@ $TRANSLATIONS = array(
"Only the following characters are allowed in a username: \"a-z\", \"A-Z\", \"0-9\", and \"_.@-\"" => "Kasutajanimes on lubatud ainult järgnevad tähemärgid: \"a-z\", \"A-Z\", \"0-9\" ja \"_.@-\"",
"A valid username must be provided" => "Sisesta nõuetele vastav kasutajatunnus",
"A valid password must be provided" => "Sisesta nõuetele vastav parool",
-"The username is already being used" => "Kasutajanimi on juba kasutuses"
+"The username is already being used" => "Kasutajanimi on juba kasutuses",
+"Could not obtain lock type %d on \"%s\"." => "Ei suutnud hankida %d tüüpi lukustust \"%s\"."
);
$PLURAL_FORMS = "nplurals=2; plural=(n != 1);";
diff --git a/lib/l10n/fr.php b/lib/l10n/fr.php
index d753e2cf44e..6b6865184eb 100644
--- a/lib/l10n/fr.php
+++ b/lib/l10n/fr.php
@@ -8,6 +8,7 @@ $TRANSLATIONS = array(
"Users" => "Utilisateurs",
"Admin" => "Administration",
"Failed to upgrade \"%s\"." => "Echec de la mise à niveau \"%s\".",
+"App \\\"%s\\\" can't be installed because it is not compatible with this version of ownCloud." => "L'application \\\"%s\\\" ne peut être installée car elle n'est pas compatible avec cette version de ownCloud.",
"No app name specified" => "Aucun nom d'application spécifié",
"Unknown filetype" => "Type de fichier inconnu",
"Invalid image" => "Image invalide",
diff --git a/lib/l10n/ja.php b/lib/l10n/ja.php
index 29a1ae102ec..aa779d62ce2 100644
--- a/lib/l10n/ja.php
+++ b/lib/l10n/ja.php
@@ -8,6 +8,7 @@ $TRANSLATIONS = array(
"Users" => "ユーザー",
"Admin" => "管理",
"Failed to upgrade \"%s\"." => "\"%s\" へのアップグレードに失敗しました。",
+"App \\\"%s\\\" can't be installed because it is not compatible with this version of ownCloud." => "アプリ \\\"%s\\\" をインストールできません。現在の owncloud のバージョンと互換性がありません。",
"No app name specified" => "アプリ名が未指定",
"Unknown filetype" => "不明なファイルタイプ",
"Invalid image" => "無効な画像",
diff --git a/lib/l10n/nl.php b/lib/l10n/nl.php
index c112d8bf34e..e643cab1162 100644
--- a/lib/l10n/nl.php
+++ b/lib/l10n/nl.php
@@ -8,6 +8,7 @@ $TRANSLATIONS = array(
"Users" => "Gebruikers",
"Admin" => "Beheerder",
"Failed to upgrade \"%s\"." => "Upgrade \"%s\" mislukt.",
+"App \\\"%s\\\" can't be installed because it is not compatible with this version of ownCloud." => "App \\\"%s\\\" kan niet worden geïnstalleerd omdat de app niet compatible is met deze versie van ownCloud.",
"No app name specified" => "De app naam is niet gespecificeerd.",
"Unknown filetype" => "Onbekend bestandsformaat",
"Invalid image" => "Ongeldige afbeelding",
diff --git a/lib/l10n/pt_BR.php b/lib/l10n/pt_BR.php
index 4906a1305a0..e902edb9de5 100644
--- a/lib/l10n/pt_BR.php
+++ b/lib/l10n/pt_BR.php
@@ -4,7 +4,7 @@ $TRANSLATIONS = array(
"Please contact your administrator. If you are an administrator of this instance, configure the \"trusted_domain\" setting in config/config.php. An example configuration is provided in config/config.sample.php." => "Por favor, contate o administrador. Se você é um administrador desta instância, configurre o \"trusted_domain\" em config/config.php. Um exemplo de configuração é fornecido em config/config.sample.php.",
"Help" => "Ajuda",
"Personal" => "Pessoal",
-"Settings" => "Ajustes",
+"Settings" => "Configurações",
"Users" => "Usuários",
"Admin" => "Admin",
"Failed to upgrade \"%s\"." => "Falha na atualização de \"%s\".",
@@ -16,7 +16,7 @@ $TRANSLATIONS = array(
"App directory already exists" => "Diretório App já existe",
"Can't create app folder. Please fix permissions. %s" => "Não é possível criar pasta app. Corrija as permissões. %s",
"No source specified when installing app" => "Nenhuma fonte foi especificada enquanto instalava o aplicativo",
-"No href specified when installing app from http" => "Nenhuma href foi especificada enquanto instalava o aplicativo de httml",
+"No href specified when installing app from http" => "Nenhuma href foi especificada enquanto instalava o aplicativo de http",
"No path specified when installing app from local file" => "Nenhum caminho foi especificado enquanto instalava o aplicativo do arquivo local",
"Archives of type %s are not supported" => "Arquivos do tipo %s não são suportados",
"Failed to open archive when installing app" => "Falha para abrir o arquivo enquanto instalava o aplicativo",
@@ -24,7 +24,7 @@ $TRANSLATIONS = array(
"App can't be installed because of not allowed code in the App" => "O aplicativo não pode ser instalado por causa do código não permitido no Aplivativo",
"App can't be installed because it is not compatible with this version of ownCloud" => "O aplicativo não pode ser instalado porque não é compatível com esta versão do ownCloud",
"App can't be installed because it contains the <shipped>true</shipped> tag which is not allowed for non shipped apps" => "O aplicativo não pode ser instalado porque ele contém a marca <shipped>verdadeiro</shipped> que não é permitido para aplicações não embarcadas",
-"App can't be installed because the version in info.xml/version is not the same as the version reported from the app store" => "O aplicativo não pode ser instalado porque a versão em info.xml /versão não é a mesma que a versão relatada na App Store",
+"App can't be installed because the version in info.xml/version is not the same as the version reported from the app store" => "O aplicativo não pode ser instalado porque a versão em info.xml/versão não é a mesma que a versão relatada na App Store",
"Application is not enabled" => "Aplicação não está habilitada",
"Authentication error" => "Erro de autenticação",
"Token expired. Please reload page." => "Token expirou. Por favor recarregue a página.",
@@ -33,7 +33,7 @@ $TRANSLATIONS = array(
"%s enter the database name." => "%s insira o nome do banco de dados.",
"%s you may not use dots in the database name" => "%s você não pode usar pontos no nome do banco de dados",
"MS SQL username and/or password not valid: %s" => "Nome de usuário e/ou senha MS SQL inválido(s): %s",
-"You need to enter either an existing account or the administrator." => "Você precisa inserir uma conta existente ou o administrador.",
+"You need to enter either an existing account or the administrator." => "Você precisa inserir uma conta existente ou a do administrador.",
"MySQL/MariaDB username and/or password not valid" => "MySQL/MariaDB nome de usuário e/ou senha não é válida",
"DB Error: \"%s\"" => "Erro no BD: \"%s\"",
"Offending command was: \"%s\"" => "Comando ofensivo era: \"%s\"",
@@ -45,9 +45,9 @@ $TRANSLATIONS = array(
"Oracle username and/or password not valid" => "Nome de usuário e/ou senha Oracle inválido(s)",
"Offending command was: \"%s\", name: %s, password: %s" => "Comando ofensivo era: \"%s\", nome: %s, senha: %s",
"PostgreSQL username and/or password not valid" => "Nome de usuário e/ou senha PostgreSQL inválido(s)",
-"Set an admin username." => "Defina um nome de usuário de administrador.",
+"Set an admin username." => "Defina um nome do usuário administrador.",
"Set an admin password." => "Defina uma senha de administrador.",
-"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "Seu servidor web não está configurado corretamente para permitir sincronização de arquivos porque a interface WebDAV parece estar quebrada.",
+"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "Seu servidor web não está configurado corretamente para permitir sincronização de arquivos porque a interface WebDAV parece não estar funcionando.",
"Please double check the <a href='%s'>installation guides</a>." => "Por favor, confira os <a href='%s'>guias de instalação</a>.",
"%s shared »%s« with you" => "%s compartilhou »%s« com você",
"Sharing %s failed, because the file does not exist" => "Compartilhamento %s falhou, porque o arquivo não existe",
diff --git a/lib/l10n/ru.php b/lib/l10n/ru.php
index 59bc2a321fd..f160c0e92e0 100644
--- a/lib/l10n/ru.php
+++ b/lib/l10n/ru.php
@@ -1,11 +1,14 @@
<?php
$TRANSLATIONS = array(
+"You are accessing the server from an untrusted domain." => "Вы пытаетесь получить доступ к серверу с неподтверждённого домена.",
+"Please contact your administrator. If you are an administrator of this instance, configure the \"trusted_domain\" setting in config/config.php. An example configuration is provided in config/config.sample.php." => "Пожалуйста, свяжитесь с администратором. Если вы администратор этого хранилища, сконфигурируйте \"trusted_domain\" в config/config.php. Пример настройки можно найти в /config/config.sample.php.",
"Help" => "Помощь",
"Personal" => "Личное",
"Settings" => "Конфигурация",
"Users" => "Пользователи",
-"Admin" => "Admin",
+"Admin" => "Администрирование",
"Failed to upgrade \"%s\"." => "Не смог обновить \"%s\".",
+"App \\\"%s\\\" can't be installed because it is not compatible with this version of ownCloud." => "Невозможно установить приложение \\\"%s\\\", т.к. оно несовместимо с этой версией ownCloud.",
"No app name specified" => "Не выбрано имя приложения",
"Unknown filetype" => "Неизвестный тип файла",
"Invalid image" => "Изображение повреждено",
@@ -47,15 +50,22 @@ $TRANSLATIONS = array(
"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>.",
"%s shared »%s« with you" => "%s поделился »%s« с вами",
+"Sharing %s failed, because the file does not exist" => "Публикация %s неудачна, т.к. файл не существует",
+"You are not allowed to share %s" => "Вам запрещено публиковать %s",
"Sharing %s failed, because the user %s is the item owner" => "Не удалось установить общий доступ для %s, пользователь %s уже является владельцем",
"Sharing %s failed, because the user %s does not exist" => "Не удалось установить общий доступ для %s, пользователь %s не существует.",
"Sharing %s failed, because this item is already shared with %s" => "Не удалось установить общий доступ для %s ,в виду того что, объект уже находиться в общем доступе с %s",
"Sharing %s failed, because the group %s does not exist" => "Не удалось установить общий доступ для %s, группа %s не существует.",
"Sharing %s failed, because %s is not a member of the group %s" => "Не удалось установить общий доступ для %s, %s не является членом группы %s",
+"You need to provide a password to create a public link, only protected links are allowed" => "Вам нужно задать пароль для создания публичной ссылки. Разрешены только защищённые ссылки",
"Sharing %s failed, because sharing with links is not allowed" => "Не удалось установить общий доступ для %s, потому что обмен со ссылками не допускается",
"Share type %s is not valid for %s" => "Такой втд общего доступа как %s не допустим для %s",
"Setting permissions for %s failed, because the permissions exceed permissions granted to %s" => "Настройка прав доступа для %s невозможна, поскольку права доступа превышают предоставленные права доступа %s",
"Setting permissions for %s failed, because the item was not found" => "Не удалось произвести настройку прав доступа для %s , элемент не был найден.",
+"Sharing backend %s not found" => "Бэкэнд для общего доступа %s не найден",
+"Sharing backend for %s not found" => "Бэкэнд для общего доступа к %s не найден",
+"Sharing %s failed, because the user %s is the original sharer" => "Публикация %s неудачна, т.к. пользователь %s - публикатор оригинала файла",
+"Sharing %s failed, because resharing is not allowed" => "Публикация %s неудачна, т.к републикация запрещена",
"Could not find category \"%s\"" => "Категория \"%s\" не найдена",
"seconds ago" => "несколько секунд назад",
"_%n minute ago_::_%n minutes ago_" => array("%n минута назад","%n минуты назад","%n минут назад"),
diff --git a/lib/l10n/sk_SK.php b/lib/l10n/sk_SK.php
index fc1011b33b3..dae5e3ead59 100644
--- a/lib/l10n/sk_SK.php
+++ b/lib/l10n/sk_SK.php
@@ -8,6 +8,7 @@ $TRANSLATIONS = array(
"Users" => "Používatelia",
"Admin" => "Administrátor",
"Failed to upgrade \"%s\"." => "Zlyhala aktualizácia \"%s\".",
+"App \\\"%s\\\" can't be installed because it is not compatible with this version of ownCloud." => "Aplikáciu \\\"%s\\\" nemožno nainštalovať, pretože nie je kompatibilná s touto verziou systému ownCloud.",
"No app name specified" => "Nešpecifikované meno aplikácie",
"Unknown filetype" => "Neznámy typ súboru",
"Invalid image" => "Chybný obrázok",
diff --git a/lib/private/app.php b/lib/private/app.php
index a62623905ff..9fb0ec2e34f 100644
--- a/lib/private/app.php
+++ b/lib/private/app.php
@@ -174,6 +174,7 @@ class OC_App {
}
$appConfig = \OC::$server->getAppConfig();
$appStatus = $appConfig->getValues(false, 'enabled');
+ $user = \OC_User::getUser();
foreach ($appStatus as $app => $enabled) {
if ($app === 'files') {
continue;
@@ -181,7 +182,6 @@ class OC_App {
if ($enabled === 'yes') {
$apps[] = $app;
} else if ($enabled !== 'no') {
- $user = \OC_User::getUser();
$groups = json_decode($enabled);
if (is_array($groups)) {
foreach ($groups as $group) {
@@ -195,7 +195,12 @@ class OC_App {
}
sort($apps);
array_unshift($apps, 'files');
- self::$enabledAppsCache = $apps;
+ // Only cache the app list, when the user is logged in.
+ // Otherwise we cache the list with disabled apps, although
+ // the apps are enabled for the user after he logged in.
+ if ($user) {
+ self::$enabledAppsCache = $apps;
+ }
return $apps;
}
@@ -504,6 +509,10 @@ class OC_App {
* @return string|false
*/
public static function getAppPath($appid) {
+ if ($appid === null || trim($appid) === '') {
+ return false;
+ }
+
if (($dir = self::findAppInDirectories($appid)) != false) {
return $dir['path'] . '/' . $appid;
}
diff --git a/lib/private/backgroundjob/joblist.php b/lib/private/backgroundjob/joblist.php
index 6641097cf90..211d7e9abfc 100644
--- a/lib/private/backgroundjob/joblist.php
+++ b/lib/private/backgroundjob/joblist.php
@@ -152,6 +152,10 @@ class JobList implements IJobList {
if ($class === 'OC_Cache_FileGlobalGC') {
$class = '\OC\Cache\FileGlobalGC';
}
+ if (!class_exists($class)) {
+ // job from disabled app or old version of an app, no need to do anything
+ return null;
+ }
$job = new $class();
$job->setId($row['id']);
$job->setLastRun($row['last_run']);
diff --git a/lib/private/backgroundjob/legacy/queuedjob.php b/lib/private/backgroundjob/legacy/queuedjob.php
index 2bc001103b8..c5705abb467 100644
--- a/lib/private/backgroundjob/legacy/queuedjob.php
+++ b/lib/private/backgroundjob/legacy/queuedjob.php
@@ -13,6 +13,8 @@ class QueuedJob extends \OC\BackgroundJob\QueuedJob {
$class = $argument['klass'];
$method = $argument['method'];
$parameters = $argument['parameters'];
- call_user_func(array($class, $method), $parameters);
+ if (is_callable(array($class, $method))) {
+ call_user_func(array($class, $method), $parameters);
+ }
}
}
diff --git a/lib/private/backgroundjob/legacy/regularjob.php b/lib/private/backgroundjob/legacy/regularjob.php
index d4cfa348cea..eb85a30b4be 100644
--- a/lib/private/backgroundjob/legacy/regularjob.php
+++ b/lib/private/backgroundjob/legacy/regularjob.php
@@ -10,6 +10,8 @@ namespace OC\BackgroundJob\Legacy;
class RegularJob extends \OC\BackgroundJob\Job {
public function run($argument) {
- call_user_func($argument);
+ if (is_callable($argument)) {
+ call_user_func($argument);
+ }
}
}
diff --git a/lib/private/connector/sabre/objecttree.php b/lib/private/connector/sabre/objecttree.php
index f2578e3c097..54596db3c47 100644
--- a/lib/private/connector/sabre/objecttree.php
+++ b/lib/private/connector/sabre/objecttree.php
@@ -135,10 +135,7 @@ class ObjectTree extends \Sabre\DAV\ObjectTree {
throw new \Sabre\DAV\Exception\Forbidden();
}
if ($sourceDir !== $destinationDir) {
- if (!$this->fileView->isUpdatable($sourceDir)) {
- throw new \Sabre\DAV\Exception\Forbidden();
- }
- if (!$this->fileView->isUpdatable($destinationDir)) {
+ if (!$this->fileView->isCreatable($destinationDir)) {
throw new \Sabre\DAV\Exception\Forbidden();
}
if (!$this->fileView->isDeletable($sourcePath) && !$isMovableMount) {
diff --git a/lib/private/files/storage/dav.php b/lib/private/files/storage/dav.php
new file mode 100644
index 00000000000..8536c65ace9
--- /dev/null
+++ b/lib/private/files/storage/dav.php
@@ -0,0 +1,453 @@
+<?php
+/**
+ * Copyright (c) 2012 Robin Appelman <icewind@owncloud.com>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace OC\Files\Storage;
+
+class DAV extends \OC\Files\Storage\Common {
+ protected $password;
+ protected $user;
+ protected $host;
+ protected $secure;
+ protected $root;
+ protected $certPath;
+ protected $ready;
+ /**
+ * @var \Sabre\DAV\Client
+ */
+ private $client;
+
+ private static $tempFiles = array();
+
+ public function __construct($params) {
+ if (isset($params['host']) && isset($params['user']) && isset($params['password'])) {
+ $host = $params['host'];
+ //remove leading http[s], will be generated in createBaseUri()
+ if (substr($host, 0, 8) == "https://") $host = substr($host, 8);
+ else if (substr($host, 0, 7) == "http://") $host = substr($host, 7);
+ $this->host = $host;
+ $this->user = $params['user'];
+ $this->password = $params['password'];
+ if (isset($params['secure'])) {
+ if (is_string($params['secure'])) {
+ $this->secure = ($params['secure'] === 'true');
+ } else {
+ $this->secure = (bool)$params['secure'];
+ }
+ } else {
+ $this->secure = false;
+ }
+ if ($this->secure === true) {
+ $certPath = \OC_User::getHome(\OC_User::getUser()) . '/files_external/rootcerts.crt';
+ if (file_exists($certPath)) {
+ $this->certPath = $certPath;
+ }
+ }
+ $this->root = isset($params['root']) ? $params['root'] : '/';
+ if (!$this->root || $this->root[0] != '/') {
+ $this->root = '/' . $this->root;
+ }
+ if (substr($this->root, -1, 1) != '/') {
+ $this->root .= '/';
+ }
+ } else {
+ throw new \Exception();
+ }
+ }
+
+ private function init() {
+ if ($this->ready) {
+ return;
+ }
+ $this->ready = true;
+
+ $settings = array(
+ 'baseUri' => $this->createBaseUri(),
+ 'userName' => $this->user,
+ 'password' => $this->password,
+ );
+
+ $this->client = new \Sabre\DAV\Client($settings);
+
+ if ($this->secure === true && $this->certPath) {
+ $this->client->addTrustedCertificates($this->certPath);
+ }
+ }
+
+ public function getId() {
+ return 'webdav::' . $this->user . '@' . $this->host . '/' . $this->root;
+ }
+
+ protected function createBaseUri() {
+ $baseUri = 'http';
+ if ($this->secure) {
+ $baseUri .= 's';
+ }
+ $baseUri .= '://' . $this->host . $this->root;
+ return $baseUri;
+ }
+
+ public function mkdir($path) {
+ $this->init();
+ $path = $this->cleanPath($path);
+ return $this->simpleResponse('MKCOL', $path, null, 201);
+ }
+
+ public function rmdir($path) {
+ $this->init();
+ $path = $this->cleanPath($path) . '/';
+ // FIXME: some WebDAV impl return 403 when trying to DELETE
+ // a non-empty folder
+ return $this->simpleResponse('DELETE', $path, null, 204);
+ }
+
+ public function opendir($path) {
+ $this->init();
+ $path = $this->cleanPath($path);
+ try {
+ $response = $this->client->propfind($this->encodePath($path), array(), 1);
+ $id = md5('webdav' . $this->root . $path);
+ $content = array();
+ $files = array_keys($response);
+ array_shift($files); //the first entry is the current directory
+ foreach ($files as $file) {
+ $file = urldecode(basename($file));
+ $content[] = $file;
+ }
+ \OC\Files\Stream\Dir::register($id, $content);
+ return opendir('fakedir://' . $id);
+ } catch (\Exception $e) {
+ return false;
+ }
+ }
+
+ public function filetype($path) {
+ $this->init();
+ $path = $this->cleanPath($path);
+ try {
+ $response = $this->client->propfind($this->encodePath($path), array('{DAV:}resourcetype'));
+ $responseType = array();
+ if (isset($response["{DAV:}resourcetype"])) {
+ $responseType = $response["{DAV:}resourcetype"]->resourceType;
+ }
+ return (count($responseType) > 0 and $responseType[0] == "{DAV:}collection") ? 'dir' : 'file';
+ } catch (\Exception $e) {
+ error_log($e->getMessage());
+ \OCP\Util::writeLog("webdav client", \OCP\Util::sanitizeHTML($e->getMessage()), \OCP\Util::ERROR);
+ return false;
+ }
+ }
+
+ public function file_exists($path) {
+ $this->init();
+ $path = $this->cleanPath($path);
+ try {
+ $this->client->propfind($this->encodePath($path), array('{DAV:}resourcetype'));
+ return true; //no 404 exception
+ } catch (\Exception $e) {
+ return false;
+ }
+ }
+
+ public function unlink($path) {
+ $this->init();
+ return $this->simpleResponse('DELETE', $path, null, 204);
+ }
+
+ public function fopen($path, $mode) {
+ $this->init();
+ $path = $this->cleanPath($path);
+ switch ($mode) {
+ case 'r':
+ case 'rb':
+ if (!$this->file_exists($path)) {
+ return false;
+ }
+ //straight up curl instead of sabredav here, sabredav put's the entire get result in memory
+ $curl = curl_init();
+ $fp = fopen('php://temp', 'r+');
+ curl_setopt($curl, CURLOPT_USERPWD, $this->user . ':' . $this->password);
+ curl_setopt($curl, CURLOPT_URL, $this->createBaseUri() . $this->encodePath($path));
+ curl_setopt($curl, CURLOPT_FILE, $fp);
+ curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
+ if ($this->secure === true) {
+ curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true);
+ curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);
+ if ($this->certPath) {
+ curl_setopt($curl, CURLOPT_CAINFO, $this->certPath);
+ }
+ }
+
+ curl_exec($curl);
+ $statusCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
+ if ($statusCode !== 200) {
+ \OCP\Util::writeLog("webdav client", 'curl GET ' . curl_getinfo($curl, CURLINFO_EFFECTIVE_URL) . ' returned status code ' . $statusCode, \OCP\Util::ERROR);
+ }
+ curl_close($curl);
+ rewind($fp);
+ return $fp;
+ case 'w':
+ case 'wb':
+ case 'a':
+ case 'ab':
+ case 'r+':
+ case 'w+':
+ case 'wb+':
+ case 'a+':
+ case 'x':
+ case 'x+':
+ case 'c':
+ case 'c+':
+ //emulate these
+ if (strrpos($path, '.') !== false) {
+ $ext = substr($path, strrpos($path, '.'));
+ } else {
+ $ext = '';
+ }
+ if ($this->file_exists($path)) {
+ if (!$this->isUpdatable($path)) {
+ return false;
+ }
+ $tmpFile = $this->getCachedFile($path);
+ } else {
+ if (!$this->isCreatable(dirname($path))) {
+ return false;
+ }
+ $tmpFile = \OCP\Files::tmpFile($ext);
+ }
+ \OC\Files\Stream\Close::registerCallback($tmpFile, array($this, 'writeBack'));
+ self::$tempFiles[$tmpFile] = $path;
+ return fopen('close://' . $tmpFile, $mode);
+ }
+ }
+
+ public function writeBack($tmpFile) {
+ if (isset(self::$tempFiles[$tmpFile])) {
+ $this->uploadFile($tmpFile, self::$tempFiles[$tmpFile]);
+ unlink($tmpFile);
+ }
+ }
+
+ public function free_space($path) {
+ $this->init();
+ $path = $this->cleanPath($path);
+ try {
+ $response = $this->client->propfind($this->encodePath($path), array('{DAV:}quota-available-bytes'));
+ if (isset($response['{DAV:}quota-available-bytes'])) {
+ return (int)$response['{DAV:}quota-available-bytes'];
+ } else {
+ return \OC\Files\SPACE_UNKNOWN;
+ }
+ } catch (\Exception $e) {
+ return \OC\Files\SPACE_UNKNOWN;
+ }
+ }
+
+ public function touch($path, $mtime = null) {
+ $this->init();
+ if (is_null($mtime)) {
+ $mtime = time();
+ }
+ $path = $this->cleanPath($path);
+
+ // if file exists, update the mtime, else create a new empty file
+ if ($this->file_exists($path)) {
+ try {
+ $this->client->proppatch($this->encodePath($path), array('{DAV:}lastmodified' => $mtime));
+ } catch (\Sabre\DAV\Exception\NotImplemented $e) {
+ return false;
+ }
+ } else {
+ $this->file_put_contents($path, '');
+ }
+ return true;
+ }
+
+ protected function uploadFile($path, $target) {
+ $this->init();
+ $source = fopen($path, 'r');
+
+ $curl = curl_init();
+ curl_setopt($curl, CURLOPT_USERPWD, $this->user . ':' . $this->password);
+ curl_setopt($curl, CURLOPT_URL, $this->createBaseUri() . $this->encodePath($target));
+ curl_setopt($curl, CURLOPT_BINARYTRANSFER, true);
+ curl_setopt($curl, CURLOPT_INFILE, $source); // file pointer
+ curl_setopt($curl, CURLOPT_INFILESIZE, filesize($path));
+ curl_setopt($curl, CURLOPT_PUT, true);
+ if ($this->secure === true) {
+ curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true);
+ curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);
+ if ($this->certPath) {
+ curl_setopt($curl, CURLOPT_CAINFO, $this->certPath);
+ }
+ }
+ curl_exec($curl);
+ $statusCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
+ if ($statusCode !== 200) {
+ \OCP\Util::writeLog("webdav client", 'curl GET ' . curl_getinfo($curl, CURLINFO_EFFECTIVE_URL) . ' returned status code ' . $statusCode, \OCP\Util::ERROR);
+ }
+ curl_close($curl);
+ $this->removeCachedFile($target);
+ }
+
+ public function rename($path1, $path2) {
+ $this->init();
+ $path1 = $this->encodePath($this->cleanPath($path1));
+ $path2 = $this->createBaseUri() . $this->encodePath($this->cleanPath($path2));
+ try {
+ $this->client->request('MOVE', $path1, null, array('Destination' => $path2));
+ $this->removeCachedFile($path1);
+ $this->removeCachedFile($path2);
+ return true;
+ } catch (\Exception $e) {
+ return false;
+ }
+ }
+
+ public function copy($path1, $path2) {
+ $this->init();
+ $path1 = $this->encodePath($this->cleanPath($path1));
+ $path2 = $this->createBaseUri() . $this->encodePath($this->cleanPath($path2));
+ try {
+ $this->client->request('COPY', $path1, null, array('Destination' => $path2));
+ $this->removeCachedFile($path2);
+ return true;
+ } catch (\Exception $e) {
+ return false;
+ }
+ }
+
+ public function stat($path) {
+ $this->init();
+ $path = $this->cleanPath($path);
+ try {
+ $response = $this->client->propfind($this->encodePath($path), array('{DAV:}getlastmodified', '{DAV:}getcontentlength'));
+ return array(
+ 'mtime' => strtotime($response['{DAV:}getlastmodified']),
+ 'size' => (int)isset($response['{DAV:}getcontentlength']) ? $response['{DAV:}getcontentlength'] : 0,
+ );
+ } catch (\Exception $e) {
+ return array();
+ }
+ }
+
+ public function getMimeType($path) {
+ $this->init();
+ $path = $this->cleanPath($path);
+ try {
+ $response = $this->client->propfind($this->encodePath($path), array('{DAV:}getcontenttype', '{DAV:}resourcetype'));
+ $responseType = array();
+ if (isset($response["{DAV:}resourcetype"])) {
+ $responseType = $response["{DAV:}resourcetype"]->resourceType;
+ }
+ $type = (count($responseType) > 0 and $responseType[0] == "{DAV:}collection") ? 'dir' : 'file';
+ if ($type == 'dir') {
+ return 'httpd/unix-directory';
+ } elseif (isset($response['{DAV:}getcontenttype'])) {
+ return $response['{DAV:}getcontenttype'];
+ } else {
+ return false;
+ }
+ } catch (\Exception $e) {
+ return false;
+ }
+ }
+
+ /**
+ * @param string $path
+ */
+ public function cleanPath($path) {
+ if ($path === "") {
+ return $path;
+ }
+ $path = \OC\Files\Filesystem::normalizePath($path);
+ // remove leading slash
+ return substr($path, 1);
+ }
+
+ /**
+ * URL encodes the given path but keeps the slashes
+ *
+ * @param string $path to encode
+ * @return string encoded path
+ */
+ private function encodePath($path) {
+ // slashes need to stay
+ return str_replace('%2F', '/', rawurlencode($path));
+ }
+
+ /**
+ * @param string $method
+ * @param string $path
+ * @param integer $expected
+ */
+ private function simpleResponse($method, $path, $body, $expected) {
+ $path = $this->cleanPath($path);
+ try {
+ $response = $this->client->request($method, $this->encodePath($path), $body);
+ return $response['statusCode'] == $expected;
+ } catch (\Exception $e) {
+ return false;
+ }
+ }
+
+ /**
+ * check if curl is installed
+ */
+ public static function checkDependencies() {
+ if (function_exists('curl_init')) {
+ return true;
+ } else {
+ return array('curl');
+ }
+ }
+
+ public function isUpdatable($path) {
+ return (bool)($this->getPermissions($path) & \OCP\PERMISSION_UPDATE);
+ }
+
+ public function isCreatable($path) {
+ return (bool)($this->getPermissions($path) & \OCP\PERMISSION_CREATE);
+ }
+
+ public function isSharable($path) {
+ return (bool)($this->getPermissions($path) & \OCP\PERMISSION_SHARE);
+ }
+
+ public function isDeletable($path) {
+ return (bool)($this->getPermissions($path) & \OCP\PERMISSION_DELETE);
+ }
+
+ public function getPermissions($path) {
+ $this->init();
+ $response = $this->client->propfind($this->encodePath($path), array('{http://owncloud.org/ns}permissions'));
+ if (isset($response['{http://owncloud.org/ns}permissions'])) {
+ $permissions = \OCP\PERMISSION_READ;
+ $permissionsString = $response['{http://owncloud.org/ns}permissions'];
+ if (strpos($permissionsString, 'R') !== false) {
+ $permissions |= \OCP\PERMISSION_SHARE;
+ }
+ if (strpos($permissionsString, 'D') !== false) {
+ $permissions |= \OCP\PERMISSION_DELETE;
+ }
+ if (strpos($permissionsString, 'W') !== false) {
+ $permissions |= \OCP\PERMISSION_UPDATE;
+ }
+ if (strpos($permissionsString, 'C') !== false) {
+ $permissions |= \OCP\PERMISSION_CREATE;
+ }
+ return $permissions;
+ } else if ($this->is_dir($path)) {
+ return \OCP\PERMISSION_ALL;
+ } else if ($this->file_exists($path)) {
+ return \OCP\PERMISSION_ALL - \OCP\PERMISSION_CREATE;
+ } else {
+ return 0;
+ }
+ }
+}
+
diff --git a/lib/private/files/utils/scanner.php b/lib/private/files/utils/scanner.php
index 1bb3e694c96..c2fabf51946 100644
--- a/lib/private/files/utils/scanner.php
+++ b/lib/private/files/utils/scanner.php
@@ -11,6 +11,7 @@ namespace OC\Files\Utils;
use OC\Files\View;
use OC\Files\Cache\ChangePropagator;
use OC\Files\Filesystem;
+use OC\ForbiddenException;
use OC\Hooks\PublicEmitter;
/**
@@ -104,6 +105,7 @@ class Scanner extends PublicEmitter {
/**
* @param string $dir
+ * @throws \OC\ForbiddenException
*/
public function scan($dir) {
$mounts = $this->getMounts($dir);
@@ -111,7 +113,14 @@ class Scanner extends PublicEmitter {
if (is_null($mount->getStorage())) {
continue;
}
- $scanner = $mount->getStorage()->getScanner();
+ $storage = $mount->getStorage();
+ // if the home storage isn't writable then the scanner is run as the wrong user
+ if ($storage->instanceOfStorage('\OC\Files\Storage\Home') and
+ (!$storage->isCreatable('') or !$storage->isCreatable('files'))
+ ) {
+ throw new ForbiddenException();
+ }
+ $scanner = $storage->getScanner();
$this->attachListener($mount);
$scanner->scan('', \OC\Files\Cache\Scanner::SCAN_RECURSIVE, \OC\Files\Cache\Scanner::REUSE_ETAG | \OC\Files\Cache\Scanner::REUSE_SIZE);
}
diff --git a/lib/private/files/view.php b/lib/private/files/view.php
index 91d7ea260d3..ff3cb9ee68b 100644
--- a/lib/private/files/view.php
+++ b/lib/private/files/view.php
@@ -896,7 +896,7 @@ class View {
return false;
}
- if ($mount instanceof MoveableMount) {
+ if ($mount instanceof MoveableMount && $internalPath === '') {
$data['permissions'] |= \OCP\PERMISSION_DELETE | \OCP\PERMISSION_UPDATE;
}
diff --git a/lib/private/helper.php b/lib/private/helper.php
index 243baa46948..f90c38d236c 100644
--- a/lib/private/helper.php
+++ b/lib/private/helper.php
@@ -405,12 +405,17 @@ class OC_Helper {
*/
static function rmdirr($dir) {
if (is_dir($dir)) {
- $files = scandir($dir);
- // FIXME: use flat array instead of recursion to avoid
- // too many levels
- foreach ($files as $file) {
- if ($file !== '' && $file !== "." && $file !== "..") {
- self::rmdirr("$dir/$file");
+ $files = new RecursiveIteratorIterator(
+ new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS),
+ RecursiveIteratorIterator::CHILD_FIRST
+ );
+
+ foreach ($files as $fileInfo) {
+ /** @var SplFileInfo $fileInfo */
+ if ($fileInfo->isDir()) {
+ rmdir($fileInfo->getRealPath());
+ } else {
+ unlink($fileInfo->getRealPath());
}
}
rmdir($dir);
diff --git a/lib/private/installer.php b/lib/private/installer.php
index 466aa4a8f89..29470dbe3a6 100644
--- a/lib/private/installer.php
+++ b/lib/private/installer.php
@@ -143,8 +143,12 @@ class OC_Installer{
* @param array $info
* @param bool $isShipped
*
+ * This function could work like described below, but currently it disables and then
+ * enables the app again. This does result in an updated app.
+ *
+ *
* This function installs an app. All information needed are passed in the
- * associative array $data.
+ * associative array $info.
* The following keys are required:
* - source: string, can be "path" or "http"
*
diff --git a/lib/private/repair.php b/lib/private/repair.php
index 23d1c2b831e..14a917be32c 100644
--- a/lib/private/repair.php
+++ b/lib/private/repair.php
@@ -13,7 +13,7 @@ use OC\Hooks\Emitter;
class Repair extends BasicEmitter {
/**
- * @var array
+ * @var RepairStep[]
**/
private $repairSteps;
@@ -68,7 +68,9 @@ class Repair extends BasicEmitter {
* @return array of RepairStep instances
*/
public static function getRepairSteps() {
- return array();
+ return array(
+ new \OC\Repair\RepairMimeTypes()
+ );
}
/**
@@ -78,6 +80,16 @@ class Repair extends BasicEmitter {
* @return array of RepairStep instances
*/
public static function getBeforeUpgradeRepairSteps() {
- return array();
+ return array(
+ );
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * Redeclared as public to allow invocation from within the closure above in php 5.3
+ */
+ public function emit($scope, $method, $arguments = array()) {
+ parent::emit($scope, $method, $arguments);
}
}
diff --git a/lib/private/route/router.php b/lib/private/route/router.php
index e7c8ad9ebdd..f3a4bc5f3e4 100644
--- a/lib/private/route/router.php
+++ b/lib/private/route/router.php
@@ -192,7 +192,9 @@ class Router implements IRouter {
$this->loadRoutes($app);
} else if (substr($url, 0, 6) === '/core/' or substr($url, 0, 10) === '/settings/') {
\OC::$REQUESTEDAPP = $url;
- \OC_App::loadApps();
+ if (!\OC_Config::getValue('maintenance', false) && !\OCP\Util::needUpgrade()) {
+ \OC_App::loadApps();
+ }
$this->loadRoutes('core');
} else {
$this->loadRoutes();
diff --git a/lib/private/setup.php b/lib/private/setup.php
index 7a08816c4b1..fdf98ab0959 100644
--- a/lib/private/setup.php
+++ b/lib/private/setup.php
@@ -50,6 +50,12 @@ class OC_Setup {
$username = htmlspecialchars_decode($options['adminlogin']);
$password = htmlspecialchars_decode($options['adminpass']);
$datadir = htmlspecialchars_decode($options['directory']);
+ if( isset($options['trusted_domains'])
+ && is_array($options['trusted_domains'])) {
+ $trustedDomains = $options['trusted_domains'];
+ } else {
+ $trustedDomains = array(OC_Request::serverHost());
+ }
if (OC_Util::runningOnWindows()) {
$datadir = rtrim(realpath($datadir), '\\');
@@ -65,7 +71,7 @@ class OC_Setup {
OC_Config::setValue('passwordsalt', $salt);
//write the config file
- OC_Config::setValue('trusted_domains', array(OC_Request::serverHost()));
+ OC_Config::setValue('trusted_domains', $trustedDomains);
OC_Config::setValue('datadirectory', $datadir);
OC_Config::setValue('dbtype', $dbtype);
OC_Config::setValue('version', implode('.', OC_Util::getVersion()));
diff --git a/lib/private/share/helper.php b/lib/private/share/helper.php
index 71c6d8517a9..46e3c280488 100644
--- a/lib/private/share/helper.php
+++ b/lib/private/share/helper.php
@@ -149,17 +149,18 @@ class Helper extends \OC\Share\Constants {
*/
public static function delete($parent, $excludeParent = false, $uidOwner = null) {
$ids = array($parent);
+ $deletedItems = array();
$parents = array($parent);
while (!empty($parents)) {
$parents = "'".implode("','", $parents)."'";
// Check the owner on the first search of reshares, useful for
// finding and deleting the reshares by a single user of a group share
if (count($ids) == 1 && isset($uidOwner)) {
- $query = \OC_DB::prepare('SELECT `id`, `uid_owner`, `item_type`, `item_target`, `parent`'
+ $query = \OC_DB::prepare('SELECT `id`, `share_with`, `item_type`, `share_type`, `item_target`, `file_target`, `parent`'
.' FROM `*PREFIX*share` WHERE `parent` IN ('.$parents.') AND `uid_owner` = ?');
$result = $query->execute(array($uidOwner));
} else {
- $query = \OC_DB::prepare('SELECT `id`, `item_type`, `item_target`, `parent`, `uid_owner`'
+ $query = \OC_DB::prepare('SELECT `id`, `share_with`, `item_type`, `share_type`, `item_target`, `file_target`, `parent`, `uid_owner`'
.' FROM `*PREFIX*share` WHERE `parent` IN ('.$parents.')');
$result = $query->execute();
}
@@ -168,16 +169,29 @@ class Helper extends \OC\Share\Constants {
while ($item = $result->fetchRow()) {
$ids[] = $item['id'];
$parents[] = $item['id'];
+ $tmpItem = array(
+ 'id' => $item['id'],
+ 'shareWith' => $item['share_with'],
+ 'itemTarget' => $item['item_target'],
+ 'itemType' => $item['item_type'],
+ 'shareType' => (int)$item['share_type'],
+ );
+ if (isset($item['file_target'])) {
+ $tmpItem['fileTarget'] = $item['file_target'];
+ }
+ $deletedItems[] = $tmpItem;
}
}
if ($excludeParent) {
unset($ids[0]);
}
if (!empty($ids)) {
- $ids = "'".implode("','", $ids)."'";
- $query = \OC_DB::prepare('DELETE FROM `*PREFIX*share` WHERE `id` IN ('.$ids.')');
+ $idList = "'".implode("','", $ids)."'";
+ $query = \OC_DB::prepare('DELETE FROM `*PREFIX*share` WHERE `id` IN ('.$idList.')');
$query->execute();
}
+
+ return $deletedItems;
}
/**
diff --git a/lib/private/share/share.php b/lib/private/share/share.php
index 26108a937ce..c06ea72c348 100644
--- a/lib/private/share/share.php
+++ b/lib/private/share/share.php
@@ -738,11 +738,24 @@ class Share extends \OC\Share\Constants {
$shares = $result->fetchAll();
+ $listOfUnsharedItems = array();
+
$itemUnshared = false;
foreach ($shares as $share) {
if ((int)$share['share_type'] === \OCP\Share::SHARE_TYPE_USER &&
$share['share_with'] === $uid) {
- Helper::delete($share['id']);
+ $deletedShares = Helper::delete($share['id']);
+ $shareTmp = array(
+ 'id' => $share['id'],
+ 'shareWith' => $share['share_with'],
+ 'itemTarget' => $share['item_target'],
+ 'itemType' => $share['item_type'],
+ 'shareType' => (int)$share['share_type'],
+ );
+ if (isset($share['file_target'])) {
+ $shareTmp['fileTarget'] = $share['file_target'];
+ }
+ $listOfUnsharedItems = array_merge($listOfUnsharedItems, $deletedShares, array($shareTmp));
$itemUnshared = true;
break;
} elseif ((int)$share['share_type'] === \OCP\Share::SHARE_TYPE_GROUP) {
@@ -764,13 +777,40 @@ class Share extends \OC\Share\Constants {
$groupShare['id'], self::$shareTypeGroupUserUnique,
\OC_User::getUser(), $groupShare['uid_owner'], 0, $groupShare['stime'], $groupShare['file_source'],
$groupShare['file_target']));
+ $shareTmp = array(
+ 'id' => $groupShare['id'],
+ 'shareWith' => $groupShare['share_with'],
+ 'itemTarget' => $groupShare['item_target'],
+ 'itemType' => $groupShare['item_type'],
+ 'shareType' => (int)$groupShare['share_type'],
+ );
+ if (isset($groupShare['file_target'])) {
+ $shareTmp['fileTarget'] = $groupShare['file_target'];
+ }
+ $listOfUnsharedItems = array_merge($listOfUnsharedItems, array($groupShare));
$itemUnshared = true;
} elseif (!$itemUnshared && isset($uniqueGroupShare)) {
$query = \OC_DB::prepare('UPDATE `*PREFIX*share` SET `permissions` = ? WHERE `id` = ?');
$query->execute(array(0, $uniqueGroupShare['id']));
+ $shareTmp = array(
+ 'id' => $uniqueGroupShare['id'],
+ 'shareWith' => $uniqueGroupShare['share_with'],
+ 'itemTarget' => $uniqueGroupShare['item_target'],
+ 'itemType' => $uniqueGroupShare['item_type'],
+ 'shareType' => (int)$uniqueGroupShare['share_type'],
+ );
+ if (isset($uniqueGroupShare['file_target'])) {
+ $shareTmp['fileTarget'] = $uniqueGroupShare['file_target'];
+ }
+ $listOfUnsharedItems = array_merge($listOfUnsharedItems, array($uniqueGroupShare));
$itemUnshared = true;
}
+ if ($itemUnshared) {
+ \OC_Hook::emit('OCP\Share', 'post_unshareFromSelf',
+ array('unsharedItems' => $listOfUnsharedItems, 'itemType' => $itemType));
+ }
+
return $itemUnshared;
}
@@ -967,19 +1007,23 @@ class Share extends \OC\Share\Constants {
protected static function unshareItem(array $item) {
// Pass all the vars we have for now, they may be useful
$hookParams = array(
+ 'id' => $item['id'],
'itemType' => $item['item_type'],
'itemSource' => $item['item_source'],
- 'fileSource' => $item['file_source'],
- 'shareType' => $item['share_type'],
+ 'shareType' => (int)$item['share_type'],
'shareWith' => $item['share_with'],
'itemParent' => $item['parent'],
'uidOwner' => $item['uid_owner'],
);
+ if($item['item_type'] === 'file' || $item['item_type'] === 'folder') {
+ $hookParams['fileSource'] = $item['file_source'];
+ $hookParams['fileTarget'] = $item['file_target'];
+ }
- \OC_Hook::emit('OCP\Share', 'pre_unshare', $hookParams + array(
- 'fileSource' => $item['file_source'],
- ));
- Helper::delete($item['id']);
+ \OC_Hook::emit('OCP\Share', 'pre_unshare', $hookParams);
+ $deletedShares = Helper::delete($item['id']);
+ $deletedShares[] = $hookParams;
+ $hookParams['deletedShares'] = $deletedShares;
\OC_Hook::emit('OCP\Share', 'post_unshare', $hookParams);
}
@@ -1788,7 +1832,7 @@ class Share extends \OC\Share\Constants {
if (isset($uidOwner)) {
if ($fileDependent) {
$select = '`*PREFIX*share`.`id`, `item_type`, `item_source`, `*PREFIX*share`.`parent`,'
- . ' `share_type`, `share_with`, `file_source`, `path`, `*PREFIX*share`.`permissions`, `stime`,'
+ . ' `share_type`, `share_with`, `file_source`, `file_target`, `path`, `*PREFIX*share`.`permissions`, `stime`,'
. ' `expiration`, `token`, `storage`, `mail_send`, `uid_owner`';
} else {
$select = '`id`, `item_type`, `item_source`, `parent`, `share_type`, `share_with`, `*PREFIX*share`.`permissions`,'
diff --git a/lib/private/util.php b/lib/private/util.php
index d384eda5f7f..225cd64dbb3 100755
--- a/lib/private/util.php
+++ b/lib/private/util.php
@@ -377,7 +377,7 @@ class OC_Util {
$errors = array();
$CONFIG_DATADIRECTORY = OC_Config::getValue('datadirectory', OC::$SERVERROOT . '/data');
- if (!\OC::needUpgrade() && OC_Config::getValue('installed', false)) {
+ if (!self::needUpgrade() && OC_Config::getValue('installed', false)) {
// this check needs to be done every time
$errors = self::checkDataDirectoryValidity($CONFIG_DATADIRECTORY);
}
@@ -1404,4 +1404,19 @@ class OC_Util {
}
return true;
}
+
+ /**
+ * Check whether 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());
+ return version_compare($currentVersion, $installedVersion, '>');
+ } else {
+ return false;
+ }
+ }
}
diff --git a/lib/public/util.php b/lib/public/util.php
index d1faec3997f..8f4691eeade 100644
--- a/lib/public/util.php
+++ b/lib/public/util.php
@@ -516,4 +516,13 @@ class Util {
public static function isPublicLinkPasswordRequired() {
return \OC_Util::isPublicLinkPasswordRequired();
}
+
+ /**
+ * Checks whether the current version needs upgrade.
+ *
+ * @return bool true if upgrade is needed, false otherwise
+ */
+ public static function needUpgrade() {
+ return \OC_Util::needUpgrade();
+ }
}
diff --git a/lib/repair/repairmimetypes.php b/lib/repair/repairmimetypes.php
new file mode 100644
index 00000000000..f7618c6e060
--- /dev/null
+++ b/lib/repair/repairmimetypes.php
@@ -0,0 +1,125 @@
+<?php
+/**
+ * Copyright (c) 2014 Vincent Petry <pvince81@owncloud.com>
+ * Copyright (c) 2014 Jörn Dreyer jfd@owncloud.com
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace OC\Repair;
+
+use OC\Hooks\BasicEmitter;
+
+class RepairMimeTypes extends BasicEmitter implements \OC\RepairStep {
+
+ public function getName() {
+ return 'Repair mime types';
+ }
+
+ private function fixOfficeMimeTypes() {
+ // update wrong mimetypes
+ $wrongMimetypes = array(
+ 'application/mspowerpoint' => 'application/vnd.ms-powerpoint',
+ 'application/msexcel' => 'application/vnd.ms-excel',
+ );
+
+ $existsStmt = \OC_DB::prepare('
+ SELECT count(`mimetype`)
+ FROM `*PREFIX*mimetypes`
+ WHERE `mimetype` = ?
+ ');
+
+ $getIdStmt = \OC_DB::prepare('
+ SELECT `id`
+ FROM `*PREFIX*mimetypes`
+ WHERE `mimetype` = ?
+ ');
+
+ $insertStmt = \OC_DB::prepare('
+ INSERT INTO `*PREFIX*mimetypes` ( `mimetype` )
+ VALUES ( ? )
+ ');
+
+ $updateWrongStmt = \OC_DB::prepare('
+ UPDATE `*PREFIX*filecache`
+ SET `mimetype` = (
+ SELECT `id`
+ FROM `*PREFIX*mimetypes`
+ WHERE `mimetype` = ?
+ ) WHERE `mimetype` = ?
+ ');
+
+ $deleteStmt = \OC_DB::prepare('
+ DELETE FROM `*PREFIX*mimetypes`
+ WHERE `id` = ?
+ ');
+
+ foreach ($wrongMimetypes as $wrong => $correct) {
+
+
+ // do we need to remove a wrong mimetype?
+ $result = \OC_DB::executeAudited($getIdStmt, array($wrong));
+ $wrongId = $result->fetchOne();
+
+ if ($wrongId !== false) {
+
+ // do we need to insert the correct mimetype?
+ $result = \OC_DB::executeAudited($existsStmt, array($correct));
+ $exists = $result->fetchOne();
+
+ if ( ! $exists ) {
+ // insert mimetype
+ \OC_DB::executeAudited($insertStmt, array($correct));
+ }
+
+ // change wrong mimetype to correct mimetype in filecache
+ \OC_DB::executeAudited($updateWrongStmt, array($correct, $wrongId));
+
+ // delete wrong mimetype
+ \OC_DB::executeAudited($deleteStmt, array($wrongId));
+
+ }
+
+ }
+
+ $updatedMimetypes = array(
+ 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
+ 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
+ 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
+ );
+
+ $updateByNameStmt = \OC_DB::prepare('
+ UPDATE `*PREFIX*filecache`
+ SET `mimetype` = (
+ SELECT `id`
+ FROM `*PREFIX*mimetypes`
+ WHERE `mimetype` = ?
+ ) WHERE `name` LIKE ?
+ ');
+
+ // separate doc from docx etc
+ foreach ($updatedMimetypes as $extension => $mimetype ) {
+ $result = \OC_DB::executeAudited($existsStmt, array($mimetype));
+ $exists = $result->fetchOne();
+
+ if ( ! $exists ) {
+ // insert mimetype
+ \OC_DB::executeAudited($insertStmt, array($mimetype));
+ }
+
+ // change mimetype for files with x extension
+ \OC_DB::executeAudited($updateByNameStmt, array($mimetype, '%.'.$extension));
+ }
+ }
+
+ /**
+ * Fix mime types
+ */
+ public function run() {
+ if ($this->fixOfficeMimeTypes()) {
+ $this->emit('\OC\Repair', 'info', array('Fixed office mime types'));
+ }
+ }
+}
+