aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/l10n/cs_CZ.php8
-rw-r--r--lib/l10n/sk_SK.php2
-rw-r--r--lib/private/group.php7
-rw-r--r--lib/private/group/manager.php12
-rw-r--r--lib/private/repair.php68
-rw-r--r--lib/private/repairstep.php44
-rw-r--r--lib/private/updater.php83
7 files changed, 175 insertions, 49 deletions
diff --git a/lib/l10n/cs_CZ.php b/lib/l10n/cs_CZ.php
index 0c5a21c1274..f81256785d8 100644
--- a/lib/l10n/cs_CZ.php
+++ b/lib/l10n/cs_CZ.php
@@ -61,7 +61,15 @@ $TRANSLATIONS = array(
"You need to provide a password to create a public link, only protected links are allowed" => "Pro vytvoření veřejného odkazu je nutné zadat heslo, jsou povoleny pouze chráněné odkazy",
"Sharing %s failed, because sharing with links is not allowed" => "Sdílení položky %s selhalo, protože sdílení pomocí linků není povoleno",
"Share type %s is not valid for %s" => "Sdílení typu %s není korektní pro %s",
+"Setting permissions for %s failed, because the permissions exceed permissions granted to %s" => "Nastavení oprávnění pro %s selhalo, protože jsou k tomu nutná vyšší oprávnění, než jaká byla povolena pro %s",
"Setting permissions for %s failed, because the item was not found" => "Nastavení práv pro %s selhalo, protože položka nebyla nalezena",
+"Sharing backend %s not found" => "Podpůrná vrstva sdílení %s nenalezena",
+"Sharing backend for %s not found" => "Podpůrná vrstva sdílení pro %s nenalezena",
+"Sharing %s failed, because the user %s is the original sharer" => "Sdílení položky %s selhalo, protože byla sdílena uživatelem %s jako první.",
+"Sharing %s failed, because the permissions exceed permissions granted to %s" => "Sdílení položky %s selhalo, protože jsou k tomu nutná vyšší oprávnění, než jaká byla %s povolena.",
+"Sharing %s failed, because resharing is not allowed" => "Sdílení položky %s selhalo, protože sdílení dále není povoleno",
+"Sharing %s failed, because the sharing backend for %s could not find its source" => "Sdílení položky %s selhalo, protože podpůrná vrstva sdílení nenalezla zdrojový %s",
+"Sharing %s failed, because the file could not be found in the file cache" => "Sdílení položky %s selhalo, protože soubor nebyl nalezen v dočasném úložišti",
"Could not find category \"%s\"" => "Nelze nalézt kategorii \"%s\"",
"seconds ago" => "před pár sekundami",
"_%n minute ago_::_%n minutes ago_" => array("před %n minutou","před %n minutami","před %n minutami"),
diff --git a/lib/l10n/sk_SK.php b/lib/l10n/sk_SK.php
index cfb81d9e438..5ef42f8fdfe 100644
--- a/lib/l10n/sk_SK.php
+++ b/lib/l10n/sk_SK.php
@@ -54,6 +54,7 @@ $TRANSLATIONS = array(
"You are not allowed to share %s" => "Nemôžete zdieľať %s",
"Sharing %s failed, because the user %s is the item owner" => "Zdieľanie %s zlyhalo, pretože používateľ %s je vlastníkom položky",
"Sharing %s failed, because the user %s does not exist" => "Zdieľanie %s zlyhalo, pretože používateľ %s neexistuje",
+"Sharing %s failed, because the user %s is not a member of any groups that %s is a member of" => "Zdieľanie %s zlyhalo, pretože používateľ %s nie je členom žiadnej skupiny spoločnej s používateľom %s",
"Sharing %s failed, because this item is already shared with %s" => "Zdieľanie %s zlyhalo, pretože táto položka už je zdieľaná s %s",
"Sharing %s failed, because the group %s does not exist" => "Zdieľanie %s zlyhalo, pretože skupina %s neexistuje",
"Sharing %s failed, because %s is not a member of the group %s" => "Zdieľanie %s zlyhalo, pretože %s nie je členom skupiny %s",
@@ -65,6 +66,7 @@ $TRANSLATIONS = array(
"Sharing %s failed, because the user %s is the original sharer" => "Zdieľanie %s zlyhalo, pretože používateľ %s je pôvodcom zdieľania",
"Sharing %s failed, because the permissions exceed permissions granted to %s" => "Zdieľanie %s zlyhalo, pretože povolenia prekračujú povolenia udelené %s",
"Sharing %s failed, because resharing is not allowed" => "Zdieľanie %s zlyhalo, pretože zdieľanie ďalším nie je povolené",
+"Sharing %s failed, because the sharing backend for %s could not find its source" => "Zdieľanie %s zlyhalo, backend zdieľania nenašiel zdrojový %s",
"Sharing %s failed, because the file could not be found in the file cache" => "Zdieľanie %s zlyhalo, pretože súbor sa nenašiel vo vyrovnávacej pamäti súborov",
"Could not find category \"%s\"" => "Nemožno nájsť danú kategóriu \"%s\"",
"seconds ago" => "pred sekundami",
diff --git a/lib/private/group.php b/lib/private/group.php
index 8dc38129205..bd9e3d37d1f 100644
--- a/lib/private/group.php
+++ b/lib/private/group.php
@@ -187,12 +187,7 @@ class OC_Group {
public static function getUserGroups($uid) {
$user = self::$userManager->get($uid);
if ($user) {
- $groups = self::getManager()->getUserGroups($user);
- $groupIds = array();
- foreach ($groups as $group) {
- $groupIds[] = $group->getGID();
- }
- return $groupIds;
+ return self::getManager()->getUserGroupIds($user);
} else {
return array();
}
diff --git a/lib/private/group/manager.php b/lib/private/group/manager.php
index dae6443e9d4..3613c7547bd 100644
--- a/lib/private/group/manager.php
+++ b/lib/private/group/manager.php
@@ -182,6 +182,18 @@ class Manager extends PublicEmitter {
$this->cachedUserGroups[$uid] = array_values($groups);
return $this->cachedUserGroups[$uid];
}
+ /**
+ * @param \OC\User\User $user
+ * @return array with group names
+ */
+ public function getUserGroupIds($user) {
+ $groupIds = array();
+ foreach ($this->backends as $backend) {
+ $groupIds = array_merge($groupIds, $backend->getUserGroups($user->getUID()));
+
+ }
+ return $groupIds;
+ }
/**
* get a list of all display names in a group
diff --git a/lib/private/repair.php b/lib/private/repair.php
index e9de3baa7ce..23d1c2b831e 100644
--- a/lib/private/repair.php
+++ b/lib/private/repair.php
@@ -9,13 +9,75 @@
namespace OC;
use OC\Hooks\BasicEmitter;
+use OC\Hooks\Emitter;
class Repair extends BasicEmitter {
/**
- * run a series of repair steps for common problems
- * progress can be reported by emitting \OC\Repair::step events
+ * @var array
+ **/
+ private $repairSteps;
+
+ /**
+ * Creates a new repair step runner
+ *
+ * @param array $repairSteps array of RepairStep instances
+ */
+ public function __construct($repairSteps = array()) {
+ $this->repairSteps = $repairSteps;
+ }
+
+ /**
+ * Run a series of repair steps for common problems
*/
public function run() {
- $this->emit('\OC\Repair', 'step', array('No repair steps configured at the moment'));
+ $self = $this;
+ if (count($this->repairSteps) === 0) {
+ $this->emit('\OC\Repair', 'info', array('No repair steps available'));
+ return;
+ }
+ // run each repair step
+ foreach ($this->repairSteps as $step) {
+ $this->emit('\OC\Repair', 'step', array($step->getName()));
+
+ if ($step instanceof Emitter) {
+ $step->listen('\OC\Repair', 'warning', function ($description) use ($self) {
+ $self->emit('\OC\Repair', 'warning', array($description));
+ });
+ $step->listen('\OC\Repair', 'info', function ($description) use ($self) {
+ $self->emit('\OC\Repair', 'info', array($description));
+ });
+ }
+
+ $step->run();
+ }
+ }
+
+ /**
+ * Add repair step
+ *
+ * @param RepairStep $repairStep repair step
+ */
+ public function addStep($repairStep) {
+ $this->repairSteps[] = $repairStep;
+ }
+
+ /**
+ * Returns the default repair steps to be run on the
+ * command line or after an upgrade.
+ *
+ * @return array of RepairStep instances
+ */
+ public static function getRepairSteps() {
+ return array();
+ }
+
+ /**
+ * Returns the repair steps to be run before an
+ * upgrade.
+ *
+ * @return array of RepairStep instances
+ */
+ public static function getBeforeUpgradeRepairSteps() {
+ return array();
}
}
diff --git a/lib/private/repairstep.php b/lib/private/repairstep.php
new file mode 100644
index 00000000000..3c00cdb44a7
--- /dev/null
+++ b/lib/private/repairstep.php
@@ -0,0 +1,44 @@
+<?php
+/**
+ * ownCloud
+ *
+ * @author Vincent Petry
+ * @copyright 2014 Vincent Petry pvince81@owncloud.com
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+namespace OC;
+
+/**
+ * Repair step
+ */
+interface RepairStep {
+
+ /**
+ * Returns the step's name
+ *
+ * @return string
+ */
+ public function getName();
+
+ /**
+ * Run repair step.
+ * Must throw exception on error.
+ *
+ * @throws \Exception in case of failure
+ */
+ public function run();
+
+}
diff --git a/lib/private/updater.php b/lib/private/updater.php
index 9cc1b3322eb..d50c2554c75 100644
--- a/lib/private/updater.php
+++ b/lib/private/updater.php
@@ -125,6 +125,7 @@ class Updater extends BasicEmitter {
public function upgrade() {
\OC_DB::enableCaching(false);
\OC_Config::setValue('maintenance', true);
+
$installedVersion = \OC_Config::getValue('version', '0.0.0');
$currentVersion = implode('.', \OC_Util::getVersion());
if ($this->log) {
@@ -132,6 +133,26 @@ class Updater extends BasicEmitter {
}
$this->emit('\OC\Updater', 'maintenanceStart');
+ try {
+ $this->doUpgrade($currentVersion, $installedVersion);
+ } catch (\Exception $exception) {
+ $this->emit('\OC\Updater', 'failure', array($exception->getMessage()));
+ }
+
+ \OC_Config::setValue('maintenance', false);
+ $this->emit('\OC\Updater', 'maintenanceEnd');
+ }
+
+ /**
+ * runs the update actions in maintenance mode, does not upgrade the source files
+ * except the main .htaccess file
+ *
+ * @param string $currentVersion current version to upgrade to
+ * @param string $installedVersion previous version from which to upgrade from
+ *
+ * @return bool true if the operation succeeded, false otherwise
+ */
+ private function doUpgrade($currentVersion, $installedVersion) {
// Update htaccess files for apache hosts
if (isset($_SERVER['SERVER_SOFTWARE']) && strstr($_SERVER['SERVER_SOFTWARE'], 'Apache')) {
\OC_Setup::updateHtaccess();
@@ -155,35 +176,28 @@ class Updater extends BasicEmitter {
* STOP CONFIG CHANGES FOR OLDER VERSIONS
*/
- $canUpgrade = false;
+ // pre-upgrade repairs
+ $repair = new \OC\Repair(\OC\Repair::getBeforeUpgradeRepairSteps());
+ $repair->run();
// simulate DB upgrade
if ($this->simulateStepEnabled) {
- try {
- // simulate core DB upgrade
- \OC_DB::simulateUpdateDbFromStructure(\OC::$SERVERROOT . '/db_structure.xml');
-
- // simulate apps DB upgrade
- $version = \OC_Util::getVersion();
- $apps = \OC_App::getEnabledApps();
- foreach ($apps as $appId) {
- $info = \OC_App::getAppInfo($appId);
- if (\OC_App::isAppCompatible($version, $info) && \OC_App::shouldUpgrade($appId)) {
- if (file_exists(\OC_App::getAppPath($appId) . '/appinfo/database.xml')) {
- \OC_DB::simulateUpdateDbFromStructure(\OC_App::getAppPath($appId) . '/appinfo/database.xml');
- }
+ // simulate core DB upgrade
+ \OC_DB::simulateUpdateDbFromStructure(\OC::$SERVERROOT . '/db_structure.xml');
+
+ // simulate apps DB upgrade
+ $version = \OC_Util::getVersion();
+ $apps = \OC_App::getEnabledApps();
+ foreach ($apps as $appId) {
+ $info = \OC_App::getAppInfo($appId);
+ if (\OC_App::isAppCompatible($version, $info) && \OC_App::shouldUpgrade($appId)) {
+ if (file_exists(\OC_App::getAppPath($appId) . '/appinfo/database.xml')) {
+ \OC_DB::simulateUpdateDbFromStructure(\OC_App::getAppPath($appId) . '/appinfo/database.xml');
}
}
-
- $this->emit('\OC\Updater', 'dbSimulateUpgrade');
-
- $canUpgrade = true;
- } catch (\Exception $exception) {
- $this->emit('\OC\Updater', 'failure', array($exception->getMessage()));
}
- }
- else {
- $canUpgrade = true;
+
+ $this->emit('\OC\Updater', 'dbSimulateUpgrade');
}
// upgrade from OC6 to OC7
@@ -193,17 +207,11 @@ class Updater extends BasicEmitter {
\OC_Appconfig::setValue('core', 'shareapi_only_share_with_group_members', 'yes');
}
- if ($this->updateStepEnabled && $canUpgrade) {
- // proceed with real upgrade
- try {
- // do the real upgrade
- \OC_DB::updateDbFromStructure(\OC::$SERVERROOT . '/db_structure.xml');
- $this->emit('\OC\Updater', 'dbUpgrade');
+ if ($this->updateStepEnabled) {
+ // do the real upgrade
+ \OC_DB::updateDbFromStructure(\OC::$SERVERROOT . '/db_structure.xml');
+ $this->emit('\OC\Updater', 'dbUpgrade');
- } catch (\Exception $exception) {
- $this->emit('\OC\Updater', 'failure', array($exception->getMessage()));
- return false;
- }
// TODO: why not do this at the end ?
\OC_Config::setValue('version', implode('.', \OC_Util::getVersion()));
$disabledApps = \OC_App::checkAppsRequirements();
@@ -213,18 +221,13 @@ class Updater extends BasicEmitter {
// load all apps to also upgrade enabled apps
\OC_App::loadApps();
- $repair = new Repair();
+ // post-upgrade repairs
+ $repair = new \OC\Repair(\OC\Repair::getRepairSteps());
$repair->run();
//Invalidate update feed
\OC_Appconfig::setValue('core', 'lastupdatedat', 0);
}
-
- \OC_Config::setValue('maintenance', false);
- $this->emit('\OC\Updater', 'maintenanceEnd');
-
- return $canUpgrade;
}
-
}