本文整理汇总了PHP中OC_App::updateApp方法的典型用法代码示例。如果您正苦于以下问题:PHP OC_App::updateApp方法的具体用法?PHP OC_App::updateApp怎么用?PHP OC_App::updateApp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OC_App
的用法示例。
在下文中一共展示了OC_App::updateApp方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doAppUpgrade
/**
* upgrades all apps within a major ownCloud upgrade. Also loads "priority"
* (types authentication, filesystem, logging, in that order) afterwards.
*
* @throws NeedsUpdateException
*/
protected function doAppUpgrade()
{
$apps = \OC_App::getEnabledApps();
$priorityTypes = array('authentication', 'filesystem', 'logging');
$pseudoOtherType = 'other';
$stacks = array($pseudoOtherType => array());
foreach ($apps as $appId) {
$priorityType = false;
foreach ($priorityTypes as $type) {
if (!isset($stacks[$type])) {
$stacks[$type] = array();
}
if (\OC_App::isType($appId, $type)) {
$stacks[$type][] = $appId;
$priorityType = true;
break;
}
}
if (!$priorityType) {
$stacks[$pseudoOtherType][] = $appId;
}
}
foreach ($stacks as $type => $stack) {
foreach ($stack as $appId) {
if (\OC_App::shouldUpgrade($appId)) {
$this->emit('\\OC\\Updater', 'appUpgradeStarted', [$appId, \OC_App::getAppVersion($appId)]);
\OC_App::updateApp($appId);
$this->emit('\\OC\\Updater', 'appUpgrade', [$appId, \OC_App::getAppVersion($appId)]);
}
if ($type !== $pseudoOtherType) {
// load authentication, filesystem and logging apps after
// upgrading them. Other apps my need to rely on modifying
// user and/or filesystem aspects.
\OC_App::loadApp($appId, false);
}
}
}
}
示例2: updateApp
/**
* @brief Update an application
* @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 $info.
* The following keys are required:
* - source: string, can be "path" or "http"
*
* One of the following keys is required:
* - path: path to the file containing the app
* - href: link to the downloadable file containing the app
*
* The following keys are optional:
* - pretend: boolean, if set true the system won't do anything
* - noupgrade: boolean, if true appinfo/upgrade.php won't be loaded
*
* This function works as follows
* -# fetching the file
* -# removing the old files
* -# unzipping new file
* -# including appinfo/upgrade.php
* -# setting the installed version
*
* upgrade.php can determine the current installed version of the app using
* "OC_Appconfig::getValue($appid, 'installed_version')"
*/
public static function updateApp($info = array(), $isShipped = false)
{
list($extractDir, $path) = self::downloadApp($info);
$info = self::checkAppsIntegrity($info, $extractDir, $path, $isShipped);
$currentDir = OC_App::getAppPath($info['id']);
$basedir = OC_App::getInstallPath();
$basedir .= '/';
$basedir .= $info['id'];
if ($currentDir !== false && is_writable($currentDir)) {
$basedir = $currentDir;
}
if (is_dir($basedir)) {
OC_Helper::rmdirr($basedir);
}
$appInExtractDir = $extractDir;
if (substr($extractDir, -1) !== '/') {
$appInExtractDir .= '/';
}
$appInExtractDir .= $info['id'];
OC_Helper::copyr($appInExtractDir, $basedir);
OC_Helper::rmdirr($extractDir);
return OC_App::updateApp($info['id']);
}
示例3: doAppUpgrade
protected function doAppUpgrade()
{
$apps = \OC_App::getEnabledApps();
foreach ($apps as $appId) {
if (\OC_App::shouldUpgrade($appId)) {
\OC_App::updateApp($appId);
$this->emit('\\OC\\Updater', 'appUpgrade', array($appId, \OC_App::getAppVersion($appId)));
}
}
}
示例4: checkUpgrade
/**
* check if the app needs updating and update when needed
*/
public static function checkUpgrade($app)
{
if (in_array($app, self::$checkedApps)) {
return;
}
self::$checkedApps[] = $app;
$versions = self::getAppVersions();
$currentVersion = OC_App::getAppVersion($app);
if ($currentVersion) {
$installedVersion = $versions[$app];
if (version_compare($currentVersion, $installedVersion, '>')) {
$info = self::getAppInfo($app);
OC_Log::write($app, 'starting app upgrade from ' . $installedVersion . ' to ' . $currentVersion, OC_Log::DEBUG);
try {
OC_App::updateApp($app);
OC_Hook::emit('update', 'success', 'Updated ' . $info['name'] . ' app');
} catch (Exception $e) {
OC_Hook::emit('update', 'failure', 'Failed to update ' . $info['name'] . ' app: ' . $e->getMessage());
$l = OC_L10N::get('lib');
throw new RuntimeException($l->t('Failed to upgrade "%s".', array($app)), 0, $e);
}
OC_Appconfig::setValue($app, 'installed_version', OC_App::getAppVersion($app));
}
}
}
示例5: checkUpgrade
/**
* check if the app need updating and update when needed
*/
public static function checkUpgrade($app)
{
if (in_array($app, self::$checkedApps)) {
return;
}
self::$checkedApps[] = $app;
$versions = self::getAppVersions();
$currentVersion = OC_App::getAppVersion($app);
if ($currentVersion) {
$installedVersion = $versions[$app];
if (version_compare($currentVersion, $installedVersion, '>')) {
OC_Log::write($app, 'starting app upgrade from ' . $installedVersion . ' to ' . $currentVersion, OC_Log::DEBUG);
try {
OC_App::updateApp($app);
} catch (Exception $e) {
echo 'Failed to upgrade "' . $app . '". Exception="' . $e->getMessage() . '"';
die;
}
OC_Appconfig::setValue($app, 'installed_version', OC_App::getAppVersion($app));
}
}
}
示例6: updateApps
/**
* 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);
}
}
}
示例7: updateApps
/**
* 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));
}
}
}
}