コード例 #1
0
ファイル: updater.php プロジェクト: CDN-Sparks/owncloud
 public static function prepare($version)
 {
     $tempDir = self::getTempDir();
     $sources = Helper::getSources($version);
     $destinations = Helper::getDirectories();
     if (preg_match('/^\\d+\\.\\d+/', $version, $ver)) {
         $ver = $ver[0];
     } else {
         $ver = $version;
     }
     //  read the list of shipped apps
     $appLocation = $sources[Helper::APP_DIRNAME];
     $shippedApps = array_keys(Helper::getFilteredContent($appLocation));
     self::$appsToRemove = array();
     try {
         $locations = Helper::getPreparedLocations();
         foreach ($locations as $type => $dirs) {
             if (isset($sources[$type])) {
                 $sourceBaseDir = $sources[$type];
             } else {
                 //  Extra app directories
                 $sourceBaseDir = false;
             }
             $tempBaseDir = $tempDir . '/' . $type;
             Helper::mkdir($tempBaseDir, true);
             // Collect old sources
             foreach ($dirs as $name => $path) {
                 //skip compatible, not shipped apps
                 if (strpos($type, Helper::APP_DIRNAME) === 0 && !in_array($name, $shippedApps)) {
                     //Read compatibility info
                     $info = \OC_App::getAppInfo($name);
                     if (isset($info['require']) && version_compare($ver, $info['require']) >= 0) {
                         continue;
                     }
                     self::$appsToRemove[] = $name;
                 }
                 self::$locations[] = array('src' => $path, 'dst' => $tempBaseDir . '/' . $name);
             }
             //Collect new sources
             if (!$sourceBaseDir) {
                 continue;
             }
             foreach (Helper::getFilteredContent($sourceBaseDir) as $basename => $path) {
                 self::$locations[] = array('src' => $path, 'dst' => $destinations[$type] . '/' . $basename);
             }
         }
     } catch (\Exception $e) {
         App::log('Apps check was interrupted. Upgrade cancelled.');
         throw $e;
     }
     return self::$locations;
 }
コード例 #2
0
ファイル: Repair.php プロジェクト: GitHubUser4234/core
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $includeExpensive = $input->getOption('include-expensive');
     if ($includeExpensive) {
         foreach ($this->repair->getExpensiveRepairSteps() as $step) {
             $this->repair->addStep($step);
         }
     }
     $apps = \OC::$server->getAppManager()->getInstalledApps();
     foreach ($apps as $app) {
         if (!\OC_App::isEnabled($app)) {
             continue;
         }
         $info = \OC_App::getAppInfo($app);
         if (!is_array($info)) {
             continue;
         }
         $steps = $info['repair-steps']['post-migration'];
         foreach ($steps as $step) {
             try {
                 $this->repair->addStep($step);
             } catch (Exception $ex) {
                 $output->writeln("<error>Failed to load repair step for {$app}: {$ex->getMessage()}</error>");
             }
         }
     }
     $maintenanceMode = $this->config->getSystemValue('maintenance', false);
     $this->config->setSystemValue('maintenance', true);
     $this->progress = new ProgressBar($output);
     $this->output = $output;
     $this->dispatcher->addListener('\\OC\\Repair::startProgress', [$this, 'handleRepairFeedBack']);
     $this->dispatcher->addListener('\\OC\\Repair::advance', [$this, 'handleRepairFeedBack']);
     $this->dispatcher->addListener('\\OC\\Repair::finishProgress', [$this, 'handleRepairFeedBack']);
     $this->dispatcher->addListener('\\OC\\Repair::step', [$this, 'handleRepairFeedBack']);
     $this->dispatcher->addListener('\\OC\\Repair::info', [$this, 'handleRepairFeedBack']);
     $this->dispatcher->addListener('\\OC\\Repair::warning', [$this, 'handleRepairFeedBack']);
     $this->dispatcher->addListener('\\OC\\Repair::error', [$this, 'handleRepairFeedBack']);
     $this->repair->run();
     $this->config->setSystemValue('maintenance', $maintenanceMode);
 }
コード例 #3
0
ファイル: appmanager.php プロジェクト: jlschillinger/core
 /**
  * Returns the app information from "appinfo/info.xml".
  *
  * If no version was present in "appinfo/info.xml", reads it
  * from the external "appinfo/version" file instead.
  *
  * @param string $appId app id
  *
  * @return array app iinfo
  *
  * @internal
  */
 public function getAppInfo($appId)
 {
     $appInfo = \OC_App::getAppInfo($appId);
     if (!isset($appInfo['version'])) {
         // read version from separate file
         $appInfo['version'] = \OC_App::getAppVersion($appId);
     }
     return $appInfo;
 }
コード例 #4
0
ファイル: app.php プロジェクト: enoch85/owncloud-testserver
 /**
  * Read app metadata from the info.xml file
  * @param string $app id of the app or the path of the info.xml file
  * @param boolean $path (optional)
  * @return array
  * @since 4.0.0
  */
 public static function getAppInfo($app, $path = false)
 {
     return \OC_App::getAppInfo($app, $path);
 }
コード例 #5
0
ファイル: base.php プロジェクト: andyboeh/core
 /**
  * Checks if the version requires an update and shows
  * @param bool $showTemplate Whether an update screen should get shown
  * @return bool|void
  */
 public static function checkUpgrade($showTemplate = true)
 {
     if (\OCP\Util::needUpgrade()) {
         $systemConfig = \OC::$server->getSystemConfig();
         if ($showTemplate && !$systemConfig->getValue('maintenance', false)) {
             $version = OC_Util::getVersion();
             $oldTheme = $systemConfig->getValue('theme');
             $systemConfig->setValue('theme', '');
             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());
             // get third party apps
             $apps = OC_App::getEnabledApps();
             $incompatibleApps = array();
             foreach ($apps as $appId) {
                 $info = OC_App::getAppInfo($appId);
                 if (!OC_App::isAppCompatible($version, $info)) {
                     $incompatibleApps[] = $info;
                 }
             }
             $tmpl->assign('appList', $incompatibleApps);
             $tmpl->assign('productName', 'ownCloud');
             // for now
             $tmpl->assign('oldTheme', $oldTheme);
             $tmpl->printPage();
             exit;
         } else {
             return true;
         }
     }
     return false;
 }
コード例 #6
0
ファイル: app.php プロジェクト: adolfo2103/hcloudfilem
 /**
  * List all apps, this is used in apps.php
  *
  * @param bool $onlyLocal
  * @return array
  */
 public static function listAllApps($onlyLocal = false)
 {
     $installedApps = OC_App::getAllApps();
     //TODO which apps do we want to blacklist and how do we integrate
     // blacklisting with the multi apps folder feature?
     $blacklist = array('files');
     //we don't want to show configuration for these
     $appList = array();
     $l = \OC::$server->getL10N('core');
     foreach ($installedApps as $app) {
         if (array_search($app, $blacklist) === false) {
             $info = OC_App::getAppInfo($app);
             if (!isset($info['name'])) {
                 OC_Log::write('core', 'App id "' . $app . '" has no name in appinfo', OC_Log::ERROR);
                 continue;
             }
             $enabled = OC_Appconfig::getValue($app, 'enabled', 'no');
             $info['groups'] = null;
             if ($enabled === 'yes') {
                 $active = true;
             } else {
                 if ($enabled === 'no') {
                     $active = false;
                 } else {
                     $active = true;
                     $info['groups'] = $enabled;
                 }
             }
             $info['active'] = $active;
             if (isset($info['shipped']) and $info['shipped'] == 'true') {
                 $info['internal'] = true;
                 $info['level'] = self::officialApp;
                 $info['removable'] = false;
             } else {
                 $info['internal'] = false;
                 $info['removable'] = true;
             }
             $info['update'] = OC_Installer::isUpdateAvailable($app);
             $appIcon = self::getAppPath($app) . '/img/' . $app . '.svg';
             if (file_exists($appIcon)) {
                 $info['preview'] = OC_Helper::imagePath($app, $app . '.svg');
                 $info['previewAsIcon'] = true;
             } else {
                 $appIcon = self::getAppPath($app) . '/img/app.svg';
                 if (file_exists($appIcon)) {
                     $info['preview'] = OC_Helper::imagePath($app, 'app.svg');
                     $info['previewAsIcon'] = true;
                 }
             }
             $info['version'] = OC_App::getAppVersion($app);
             $appList[] = $info;
         }
     }
     if ($onlyLocal) {
         $remoteApps = [];
     } else {
         $remoteApps = OC_App::getAppstoreApps();
     }
     if ($remoteApps) {
         // Remove duplicates
         foreach ($appList as $app) {
             foreach ($remoteApps as $key => $remote) {
                 if ($app['name'] === $remote['name'] || isset($app['ocsid']) && $app['ocsid'] === $remote['id']) {
                     unset($remoteApps[$key]);
                 }
             }
         }
         $combinedApps = array_merge($appList, $remoteApps);
     } else {
         $combinedApps = $appList;
     }
     return $combinedApps;
 }
コード例 #7
0
ファイル: app.php プロジェクト: hjimmy/owncloud
 /**
  * check if the current enabled apps are compatible with the current
  * ownCloud version. disable them if not.
  * This is important if you upgrade ownCloud and have non ported 3rd
  * party apps installed.
  */
 public static function checkAppsRequirements($apps = array())
 {
     if (empty($apps)) {
         $apps = OC_App::getEnabledApps();
     }
     $version = OC_Util::getVersion();
     foreach ($apps as $app) {
         // check if the app is compatible with this version of ownCloud
         $info = OC_App::getAppInfo($app);
         if (!isset($info['require']) or !self::isAppVersionCompatible($version, $info['require'])) {
             OC_Log::write('core', 'App "' . $info['name'] . '" (' . $app . ') can\'t be used because it is' . ' not compatible with this version of ownCloud', OC_Log::ERROR);
             OC_App::disable($app);
             OC_Hook::emit('update', 'success', 'Disabled ' . $info['name'] . ' app because it is not compatible');
         }
     }
 }
コード例 #8
0
ファイル: util.php プロジェクト: pinoniq/core
 /**
  * Check if it is allowed to remember login.
  *
  * @note Every app can set 'rememberlogin' to 'false' to disable the remember login feature
  *
  * @return bool
  */
 public static function rememberLoginAllowed()
 {
     $apps = OC_App::getEnabledApps();
     foreach ($apps as $app) {
         $appInfo = OC_App::getAppInfo($app);
         if (isset($appInfo['rememberlogin']) && $appInfo['rememberlogin'] === 'false') {
             return false;
         }
     }
     return true;
 }
コード例 #9
0
 /**
  * check if any apps need updating and update those
  */
 public static function updateApps()
 {
     $versions = self::getAppVersions();
     //ensure files app is installed for upgrades
     if (!isset($versions['files'])) {
         $versions['files'] = '0';
     }
     foreach ($versions as $app => $installedVersion) {
         $currentVersion = OC_App::getAppVersion($app);
         if ($currentVersion) {
             if (version_compare($currentVersion, $installedVersion, '>')) {
                 OC_Log::write($app, 'starting app upgrade from ' . $installedVersion . ' to ' . $currentVersion, OC_Log::DEBUG);
                 OC_App::updateApp($app);
                 OC_Appconfig::setValue($app, 'installed_version', OC_App::getAppVersion($app));
             }
         }
     }
     // check if the current enabled apps are compatible with the current ownCloud version. disable them if not.
     // this is important if you upgrade ownCloud and have non ported 3rd party apps installed
     $apps = OC_App::getEnabledApps();
     $version = OC_Util::getVersion();
     foreach ($apps as $app) {
         // check if the app is compatible with this version of ownCloud
         $info = OC_App::getAppInfo($app);
         if (!isset($info['require']) or $version[0] > $info['require']) {
             OC_Log::write('core', 'App "' . $info['name'] . '" can\'t be used because it is not compatible with this version of ownCloud', OC_Log::ERROR);
             OC_App::disable($app);
         }
     }
 }
コード例 #10
0
ファイル: ocs.php プロジェクト: ryanshoover/core
 /**
  * get a list of installed web apps
  * @param string $format
  * @return string xml/json
  */
 private static function systemWebApps($format)
 {
     $login = OC_OCS::checkpassword();
     $apps = OC_App::getEnabledApps();
     $values = array();
     foreach ($apps as $app) {
         $info = OC_App::getAppInfo($app);
         if (isset($info['standalone'])) {
             $newvalue = array('name' => $info['name'], 'url' => OC_Helper::linkToAbsolute($app, ''), 'icon' => '');
             $values[] = $newvalue;
         }
     }
     $txt = OC_OCS::generatexml($format, 'ok', 100, '', $values, 'cloud', '', 2, 0, 0);
     echo $txt;
 }
コード例 #11
0
ファイル: migrate.php プロジェクト: Romua1d/core
 /**
  * creates a migration.db in the users data dir with their app data in
  * @return bool whether operation was successfull
  */
 private static function exportAppData()
 {
     $success = true;
     $return = array();
     // Foreach provider
     foreach (self::$providers as $provider) {
         // Check if the app is enabled
         if (OC_App::isEnabled($provider->getID())) {
             $success = true;
             // Does this app use the database?
             if (file_exists(OC_App::getAppPath($provider->getID()) . '/appinfo/database.xml')) {
                 // Create some app tables
                 $tables = self::createAppTables($provider->getID());
                 if (is_array($tables)) {
                     // Save the table names
                     foreach ($tables as $table) {
                         $return['apps'][$provider->getID()]['tables'][] = $table;
                     }
                 } else {
                     // It failed to create the tables
                     $success = false;
                 }
             }
             // Run the export function?
             if ($success) {
                 // Set the provider properties
                 $provider->setData(self::$uid, self::$content);
                 $return['apps'][$provider->getID()]['success'] = $provider->export();
             } else {
                 $return['apps'][$provider->getID()]['success'] = false;
                 $return['apps'][$provider->getID()]['message'] = 'failed to create the app tables';
             }
             // Now add some app info the the return array
             $appinfo = OC_App::getAppInfo($provider->getID());
             $return['apps'][$provider->getID()]['version'] = OC_App::getAppVersion($provider->getID());
         }
     }
     return $return;
 }
コード例 #12
0
 /**
  * install an app already placed in the app folder
  * @param string $app id of the app to install
  * @returns array see OC_App::getAppInfo
  */
 public static function installShippedApp($app)
 {
     //install the database
     if (is_file(OC::$APPSROOT . "/apps/{$app}/appinfo/database.xml")) {
         OC_DB::createDbFromStructure(OC::$APPSROOT . "/apps/{$app}/appinfo/database.xml");
     }
     //run appinfo/install.php
     if (is_file(OC::$APPSROOT . "/apps/{$app}/appinfo/install.php")) {
         include OC::$APPSROOT . "/apps/{$app}/appinfo/install.php";
     }
     $info = OC_App::getAppInfo($app);
     OC_Appconfig::setValue($app, 'installed_version', OC_App::getAppVersion($app));
     //set remote/public handelers
     foreach ($info['remote'] as $name => $path) {
         OCP\CONFIG::setAppValue('core', 'remote_' . $name, '/apps/' . $app . '/' . $path);
     }
     foreach ($info['public'] as $name => $path) {
         OCP\CONFIG::setAppValue('core', 'public_' . $name, '/apps/' . $app . '/' . $path);
     }
     OC_App::setAppTypes($info['id']);
     return $info;
 }
コード例 #13
0
ファイル: installer.php プロジェクト: ZverAleksey/core
 /**
  * install an app already placed in the app folder
  * @param string $app id of the app to install
  * @return integer
  */
 public static function installShippedApp($app)
 {
     //install the database
     $appPath = OC_App::getAppPath($app);
     if (is_file("{$appPath}/appinfo/database.xml")) {
         OC_DB::createDbFromStructure("{$appPath}/appinfo/database.xml");
     }
     //run appinfo/install.php
     \OC::$loader->addValidRoot($appPath);
     self::includeAppScript("{$appPath}/appinfo/install.php");
     $info = OC_App::getAppInfo($app);
     if (is_null($info)) {
         return false;
     }
     $config = \OC::$server->getConfig();
     $config->setAppValue($app, 'installed_version', OC_App::getAppVersion($app));
     if (array_key_exists('ocsid', $info)) {
         $config->setAppValue($app, 'ocsid', $info['ocsid']);
     }
     //set remote/public handlers
     foreach ($info['remote'] as $name => $path) {
         $config->setAppValue('core', 'remote_' . $name, $app . '/' . $path);
     }
     foreach ($info['public'] as $name => $path) {
         $config->setAppValue('core', 'public_' . $name, $app . '/' . $path);
     }
     OC_App::setAppTypes($info['id']);
     return $info['id'];
 }
コード例 #14
0
ファイル: app.php プロジェクト: ryanshoover/core
 /**
  * check if the current enabled apps are compatible with the current
  * ownCloud version. disable them if not.
  * This is important if you upgrade ownCloud and have non ported 3rd
  * party apps installed.
  */
 public static function checkAppsRequirements($apps = array())
 {
     if (empty($apps)) {
         $apps = OC_App::getEnabledApps();
     }
     $version = OC_Util::getVersion();
     foreach ($apps as $app) {
         // check if the app is compatible with this version of ownCloud
         $info = OC_App::getAppInfo($app);
         if (!isset($info['require']) or $version[0] . '.' . $version[1] > $info['require']) {
             OC_Log::write('core', 'App "' . $info['name'] . '" (' . $app . ') can\'t be used because it is not compatible with this version of ownCloud', OC_Log::ERROR);
             OC_App::disable($app);
         }
     }
 }
 /**
  * install an app already placed in the app folder
  * @param string $app id of the app to install
  * @returns array see OC_App::getAppInfo
  */
 public static function installShippedApp($app)
 {
     //install the database
     if (is_file(OC::$SERVERROOT . "/apps/{$app}/appinfo/database.xml")) {
         OC_DB::createDbFromStructure(OC::$SERVERROOT . "/apps/{$app}/appinfo/database.xml");
     }
     //run appinfo/install.php
     if (is_file(OC::$SERVERROOT . "/apps/{$app}/appinfo/install.php")) {
         include OC::$SERVERROOT . "/apps/{$app}/appinfo/install.php";
     }
     $info = OC_App::getAppInfo(OC::$SERVERROOT . "/apps/{$app}/appinfo/info.xml");
     OC_Appconfig::setValue($app, 'installed_version', $info['version']);
     return $info;
 }
コード例 #16
0
ファイル: apps.php プロジェクト: netcon-source/apps
 public static function getAppInfo($parameters)
 {
     $app = $parameters['appid'];
     return OC_App::getAppInfo($app);
 }
コード例 #17
0
ファイル: app.php プロジェクト: pierreozoux/core
 /**
  * List all apps, this is used in apps.php
  *
  * @param bool $onlyLocal
  * @param bool $includeUpdateInfo Should we check whether there is an update
  *                                in the app store?
  * @param OCSClient $ocsClient
  * @return array
  */
 public static function listAllApps($onlyLocal = false, $includeUpdateInfo = true, OCSClient $ocsClient)
 {
     $installedApps = OC_App::getAllApps();
     //TODO which apps do we want to blacklist and how do we integrate
     // blacklisting with the multi apps folder feature?
     //we don't want to show configuration for these
     $blacklist = \OC::$server->getAppManager()->getAlwaysEnabledApps();
     $appList = array();
     foreach ($installedApps as $app) {
         if (array_search($app, $blacklist) === false) {
             $info = OC_App::getAppInfo($app);
             if (!isset($info['name'])) {
                 \OCP\Util::writeLog('core', 'App id "' . $app . '" has no name in appinfo', \OCP\Util::ERROR);
                 continue;
             }
             $enabled = \OC::$server->getAppConfig()->getValue($app, 'enabled', 'no');
             $info['groups'] = null;
             if ($enabled === 'yes') {
                 $active = true;
             } else {
                 if ($enabled === 'no') {
                     $active = false;
                 } else {
                     $active = true;
                     $info['groups'] = $enabled;
                 }
             }
             $info['active'] = $active;
             if (self::isShipped($app)) {
                 $info['internal'] = true;
                 $info['level'] = self::officialApp;
                 $info['removable'] = false;
             } else {
                 $info['internal'] = false;
                 $info['removable'] = true;
             }
             $info['update'] = $includeUpdateInfo ? OC_Installer::isUpdateAvailable($app) : null;
             $appPath = self::getAppPath($app);
             if ($appPath !== false) {
                 $appIcon = $appPath . '/img/' . $app . '.svg';
                 if (file_exists($appIcon)) {
                     $info['preview'] = \OC::$server->getURLGenerator()->imagePath($app, $app . '.svg');
                     $info['previewAsIcon'] = true;
                 } else {
                     $appIcon = $appPath . '/img/app.svg';
                     if (file_exists($appIcon)) {
                         $info['preview'] = \OC::$server->getURLGenerator()->imagePath($app, 'app.svg');
                         $info['previewAsIcon'] = true;
                     }
                 }
             }
             $info['version'] = OC_App::getAppVersion($app);
             $appList[] = $info;
         }
     }
     if ($onlyLocal) {
         $remoteApps = [];
     } else {
         $remoteApps = OC_App::getAppstoreApps('approved', null, $ocsClient);
     }
     if ($remoteApps) {
         // Remove duplicates
         foreach ($appList as $app) {
             foreach ($remoteApps as $key => $remote) {
                 if ($app['name'] === $remote['name'] || isset($app['ocsid']) && $app['ocsid'] === $remote['id']) {
                     unset($remoteApps[$key]);
                 }
             }
         }
         $combinedApps = array_merge($appList, $remoteApps);
     } else {
         $combinedApps = $appList;
     }
     return $combinedApps;
 }
コード例 #18
0
ファイル: installer.php プロジェクト: riso/owncloud-core
 /**
  * install an app already placed in the app folder
  * @param string $app id of the app to install
  * @return integer
  */
 public static function installShippedApp($app)
 {
     //install the database
     if (is_file(OC_App::getAppPath($app) . "/appinfo/database.xml")) {
         OC_DB::createDbFromStructure(OC_App::getAppPath($app) . "/appinfo/database.xml");
     }
     //run appinfo/install.php
     if (is_file(OC_App::getAppPath($app) . "/appinfo/install.php")) {
         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));
     if (array_key_exists('ocsid', $info)) {
         OC_Appconfig::setValue($app, 'ocsid', $info['ocsid']);
     }
     //set remote/public handelers
     foreach ($info['remote'] as $name => $path) {
         OCP\CONFIG::setAppValue('core', 'remote_' . $name, $app . '/' . $path);
     }
     foreach ($info['public'] as $name => $path) {
         OCP\CONFIG::setAppValue('core', 'public_' . $name, $app . '/' . $path);
     }
     OC_App::setAppTypes($info['id']);
     return $info['id'];
 }
コード例 #19
0
	$updater->listen('\OC\Updater', 'dbUpgrade', function () use ($eventSource, $l) {
		$eventSource->send('success', (string)$l->t('Updated database'));
	});
	$updater->listen('\OC\Updater', 'dbSimulateUpgrade', function () use ($eventSource, $l) {
		$eventSource->send('success', (string)$l->t('Checked database schema update'));
	});
	$updater->listen('\OC\Updater', 'appUpgradeCheck', function () use ($eventSource, $l) {
		$eventSource->send('success', (string)$l->t('Checked database schema update for apps'));
	});
	$updater->listen('\OC\Updater', 'appUpgrade', function ($app, $version) use ($eventSource, $l) {
		$eventSource->send('success', (string)$l->t('Updated "%s" to %s', array($app, $version)));
	});
	$updater->listen('\OC\Updater', 'disabledApps', function ($appList) use ($eventSource, $l) {
		$list = array();
		foreach ($appList as $appId) {
			$info = OC_App::getAppInfo($appId);
			$list[] = $info['name'] . ' (' . $info['id'] . ')';
		}
		$eventSource->send('success', (string)$l->t('Disabled incompatible apps: %s', implode(', ', $list)));
	});
	$updater->listen('\OC\Updater', 'failure', function ($message) use ($eventSource) {
		$eventSource->send('failure', $message);
		$eventSource->close();
		OC_Config::setValue('maintenance', false);
	});

	$updater->upgrade();

	$eventSource->send('done', '');
	$eventSource->close();
}
コード例 #20
0
ファイル: updater.php プロジェクト: Combustible/core
 /**
  * @param string $version the oc version to check app compatibilty with
  */
 protected function checkAppUpgrade($version)
 {
     $apps = \OC_App::getEnabledApps();
     foreach ($apps as $appId) {
         if ($version) {
             $info = \OC_App::getAppInfo($appId);
             $compatible = \OC_App::isAppCompatible($version, $info);
         } else {
             $compatible = true;
         }
         if ($compatible && \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', 'appUpgradeCheck');
 }
コード例 #21
0
ファイル: Updater.php プロジェクト: stweil/owncloud-core
 /**
  * @param string $version the oc version to check app compatibility with
  */
 protected function checkAppUpgrade($version)
 {
     $apps = \OC_App::getEnabledApps();
     $this->emit('\\OC\\Updater', 'appUpgradeCheckBefore');
     foreach ($apps as $appId) {
         $info = \OC_App::getAppInfo($appId);
         $compatible = \OC_App::isAppCompatible($version, $info);
         $isShipped = \OC_App::isShipped($appId);
         if ($compatible && $isShipped && \OC_App::shouldUpgrade($appId)) {
             /**
              * FIXME: The preupdate check is performed before the database migration, otherwise database changes
              * are not possible anymore within it. - Consider this when touching the code.
              * @link https://github.com/owncloud/core/issues/10980
              * @see \OC_App::updateApp
              */
             if (file_exists(\OC_App::getAppPath($appId) . '/appinfo/preupdate.php')) {
                 $this->includePreUpdate($appId);
             }
             if (file_exists(\OC_App::getAppPath($appId) . '/appinfo/database.xml')) {
                 $this->emit('\\OC\\Updater', 'appSimulateUpdate', array($appId));
                 \OC_DB::simulateUpdateDbFromStructure(\OC_App::getAppPath($appId) . '/appinfo/database.xml');
             }
         }
     }
     $this->emit('\\OC\\Updater', 'appUpgradeCheck');
 }
コード例 #22
0
ファイル: updater.php プロジェクト: olucao/owncloud-core
 /**
  * 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();
     }
     // create empty file in data dir, so we can later find
     // out that this is indeed an ownCloud data directory
     // (in case it didn't exist before)
     file_put_contents(\OC_Config::getValue('datadirectory', \OC::$SERVERROOT . '/data') . '/.ocdata', '');
     /*
      * START CONFIG CHANGES FOR OLDER VERSIONS
      */
     if (!\OC::$CLI && version_compare($installedVersion, '6.90.1', '<')) {
         // Add the trusted_domains config if it is not existant
         // This is added to prevent host header poisoning
         \OC_Config::setValue('trusted_domains', \OC_Config::getValue('trusted_domains', array(\OC_Request::serverHost())));
     }
     /*
      * STOP CONFIG CHANGES FOR OLDER VERSIONS
      */
     // pre-upgrade repairs
     $repair = new \OC\Repair(\OC\Repair::getBeforeUpgradeRepairSteps());
     $repair->run();
     // simulate DB upgrade
     if ($this->simulateStepEnabled) {
         // 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');
     }
     // upgrade from OC6 to OC7
     // TODO removed it again for OC8
     $sharePolicy = \OC_Appconfig::getValue('core', 'shareapi_share_policy', 'global');
     if ($sharePolicy === 'groups_only') {
         \OC_Appconfig::setValue('core', 'shareapi_only_share_with_group_members', 'yes');
     }
     if ($this->updateStepEnabled) {
         // do the real upgrade
         \OC_DB::updateDbFromStructure(\OC::$SERVERROOT . '/db_structure.xml');
         $this->emit('\\OC\\Updater', 'dbUpgrade');
         // TODO: why not do this at the end ?
         \OC_Config::setValue('version', implode('.', \OC_Util::getVersion()));
         $disabledApps = \OC_App::checkAppsRequirements();
         if (!empty($disabledApps)) {
             $this->emit('\\OC\\Updater', 'disabledApps', array($disabledApps));
         }
         // load all apps to also upgrade enabled apps
         \OC_App::loadApps();
         // post-upgrade repairs
         $repair = new \OC\Repair(\OC\Repair::getRepairSteps());
         $repair->run();
         //Invalidate update feed
         \OC_Appconfig::setValue('core', 'lastupdatedat', 0);
     }
 }
コード例 #23
0
ファイル: app.php プロジェクト: kebenxiaoming/owncloudRedis
 /**
  * Lists all apps, this is used in apps.php
  * @return array
  */
 public static function listAllApps($onlyLocal = false)
 {
     $installedApps = OC_App::getAllApps();
     //TODO which apps do we want to blacklist and how do we integrate
     // blacklisting with the multi apps folder feature?
     $blacklist = array('files');
     //we don't want to show configuration for these
     $appList = array();
     $l = \OC::$server->getL10N('core');
     foreach ($installedApps as $app) {
         if (array_search($app, $blacklist) === false) {
             $info = OC_App::getAppInfo($app);
             if (!isset($info['name'])) {
                 OC_Log::write('core', 'App id "' . $app . '" has no name in appinfo', OC_Log::ERROR);
                 continue;
             }
             $enabled = OC_Appconfig::getValue($app, 'enabled', 'no');
             $info['groups'] = null;
             if ($enabled === 'yes') {
                 $active = true;
             } else {
                 if ($enabled === 'no') {
                     $active = false;
                 } else {
                     $active = true;
                     $info['groups'] = $enabled;
                 }
             }
             $info['active'] = $active;
             if (isset($info['shipped']) and $info['shipped'] == 'true') {
                 $info['internal'] = true;
                 $info['internallabel'] = (string) $l->t('Recommended');
                 $info['internalclass'] = 'recommendedapp';
                 $info['removable'] = false;
             } else {
                 $info['internal'] = false;
                 $info['removable'] = true;
             }
             $info['update'] = OC_Installer::isUpdateAvailable($app);
             $appIcon = self::getAppPath($app) . '/img/' . $app . '.svg';
             if (file_exists($appIcon)) {
                 $info['preview'] = OC_Helper::imagePath($app, $app . '.svg');
                 $info['previewAsIcon'] = true;
             } else {
                 $appIcon = self::getAppPath($app) . '/img/app.svg';
                 if (file_exists($appIcon)) {
                     $info['preview'] = OC_Helper::imagePath($app, 'app.svg');
                     $info['previewAsIcon'] = true;
                 }
             }
             $info['version'] = OC_App::getAppVersion($app);
             $appList[] = $info;
         }
     }
     if ($onlyLocal) {
         $remoteApps = array();
     } else {
         $remoteApps = OC_App::getAppstoreApps();
     }
     if ($remoteApps) {
         // Remove duplicates
         foreach ($appList as $app) {
             foreach ($remoteApps as $key => $remote) {
                 if ($app['name'] === $remote['name'] || isset($app['ocsid']) && $app['ocsid'] === $remote['id']) {
                     unset($remoteApps[$key]);
                 }
             }
         }
         $combinedApps = array_merge($appList, $remoteApps);
     } else {
         $combinedApps = $appList;
     }
     // bring the apps into the right order with a custom sort function
     usort($combinedApps, function ($a, $b) {
         // priority 1: active
         if ($a['active'] != $b['active']) {
             return $b['active'] - $a['active'];
         }
         // priority 2: shipped
         $aShipped = array_key_exists('shipped', $a) && $a['shipped'] === 'true' ? 1 : 0;
         $bShipped = array_key_exists('shipped', $b) && $b['shipped'] === 'true' ? 1 : 0;
         if ($aShipped !== $bShipped) {
             return $bShipped - $aShipped;
         }
         // priority 3: recommended
         $internalClassA = isset($a['internalclass']) ? $a['internalclass'] : '';
         $internalClassB = isset($b['internalclass']) ? $b['internalclass'] : '';
         if ($internalClassA != $internalClassB) {
             $aTemp = $internalClassA == 'recommendedapp' ? 1 : 0;
             $bTemp = $internalClassB == 'recommendedapp' ? 1 : 0;
             return $bTemp - $aTemp;
         }
         // priority 4: alphabetical
         return strcasecmp($a['name'], $b['name']);
     });
     return $combinedApps;
 }
コード例 #24
0
ファイル: Notifier.php プロジェクト: rchicoli/owncloud-core
 protected function getAppInfo($appId)
 {
     return \OC_App::getAppInfo($appId);
 }