本文整理汇总了PHP中OC_App::getEnabledApps方法的典型用法代码示例。如果您正苦于以下问题:PHP OC_App::getEnabledApps方法的具体用法?PHP OC_App::getEnabledApps怎么用?PHP OC_App::getEnabledApps使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OC_App
的用法示例。
在下文中一共展示了OC_App::getEnabledApps方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getApps
/**
* @param array $parameters
* @return OC_OCS_Result
*/
public function getApps($parameters)
{
$apps = OC_App::listAllApps();
$list = [];
foreach ($apps as $app) {
$list[] = $app['id'];
}
$filter = isset($_GET['filter']) ? $_GET['filter'] : false;
if ($filter) {
switch ($filter) {
case 'enabled':
return new OC_OCS_Result(array('apps' => \OC_App::getEnabledApps()));
break;
case 'disabled':
$enabled = OC_App::getEnabledApps();
return new OC_OCS_Result(array('apps' => array_diff($list, $enabled)));
break;
default:
// Invalid filter variable
return new OC_OCS_Result(null, 101);
break;
}
} else {
return new OC_OCS_Result(array('apps' => $list));
}
}
示例2: testGetEnabledAppsIsSorted
/**
* Tests that the app order is correct
*/
public function testGetEnabledAppsIsSorted()
{
$apps = \OC_App::getEnabledApps(true);
// copy array
$sortedApps = $apps;
sort($sortedApps);
// 'files' is always on top
unset($sortedApps[array_search('files', $sortedApps)]);
array_unshift($sortedApps, 'files');
$this->assertEquals($sortedApps, $apps);
}
示例3: testGetAppsDisabled
public function testGetAppsDisabled()
{
$_GET['filter'] = 'disabled';
$result = \OCA\provisioning_API\Apps::getApps(array('filter' => 'disabled'));
$this->assertTrue($result->succeeded());
$data = $result->getData();
$apps = \OC_App::listAllApps();
$list = array();
foreach ($apps as $app) {
$list[] = $app['id'];
}
$disabled = array_diff($list, \OC_App::getEnabledApps());
$this->assertEquals(count($disabled), count($data['apps']));
}
示例4: getApps
public static function getApps($parameters)
{
$filter = isset($_GET['filter']) ? $_GET['filter'] : false;
if ($filter) {
switch ($filter) {
case 'enabled':
return array('apps' => OC_App::getEnabledApps());
break;
case 'disabled':
$apps = OC_App::getAllApps();
$enabled = OC_App::getEnabledApps();
return array('apps' => array_diff($apps, $enabled));
break;
default:
// Invalid filter variable
return 101;
break;
}
} else {
return array('apps' => OC_App::getAllApps());
}
}
示例5: checkUpgrade
/**
* 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: needUpgrade
/**
* Check whether the instance needs to perform an upgrade,
* either when the core version is higher or any app requires
* an upgrade.
*
* @param \OCP\IConfig $config
* @return bool whether the core or any app needs an upgrade
*/
public static function needUpgrade(\OCP\IConfig $config)
{
if ($config->getSystemValue('installed', false)) {
$installedVersion = $config->getSystemValue('version', '0.0.0');
$currentVersion = implode('.', OC_Util::getVersion());
$versionDiff = version_compare($currentVersion, $installedVersion);
if ($versionDiff > 0) {
return true;
} else {
if ($versionDiff < 0) {
// downgrade attempt, throw exception
throw new \OC\HintException('Downgrading is not supported and is likely to cause unpredictable issues (from ' . $installedVersion . ' to ' . $currentVersion . ')');
}
}
// also check for upgrades for apps (independently from the user)
$apps = \OC_App::getEnabledApps(false, true);
$shouldUpgrade = false;
foreach ($apps as $app) {
if (\OC_App::shouldUpgrade($app)) {
$shouldUpgrade = true;
break;
}
}
return $shouldUpgrade;
} else {
return false;
}
}
示例7: doUpgrade
/**
* 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);
}
}
示例8: 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);
}
}
}
}
示例9: restoreAppConfig
/**
* Restore the original app config service.
*/
private function restoreAppConfig()
{
\OC::$server->registerService('AppConfig', function (\OC\Server $c) {
return new \OC\AppConfig($c->getDatabaseConnection());
});
\OC::$server->registerService('AppManager', function (\OC\Server $c) {
return new \OC\App\AppManager($c->getUserSession(), $c->getAppConfig(), $c->getGroupManager(), $c->getMemCacheFactory());
});
// Remove the cache of the mocked apps list with a forceRefresh
\OC_App::getEnabledApps(true);
}
示例10: 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)));
}
}
}
示例11: systemWebApps
/**
* 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;
}
示例12: checkAppsRequirements
/**
* 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);
}
}
}
示例13: testGetAppsDisabled
public function testGetAppsDisabled()
{
$this->ocsClient->expects($this->any())->method($this->anything())->will($this->returnValue(null));
$_GET['filter'] = 'disabled';
$result = $this->api->getApps(['filter' => 'disabled']);
$this->assertTrue($result->succeeded());
$data = $result->getData();
$apps = \OC_App::listAllApps(false, true, $this->ocsClient);
$list = array();
foreach ($apps as $app) {
$list[] = $app['id'];
}
$disabled = array_diff($list, \OC_App::getEnabledApps());
$this->assertEquals(count($disabled), count($data['apps']));
}
示例14: restoreAppConfig
/**
* Restore the original app config service.
*/
private function restoreAppConfig()
{
$oldService = $this->oldAppConfigService;
\OC::$server->registerService('AppConfig', function ($c) use($oldService) {
return $oldService;
});
// Remove the cache of the mocked apps list with a forceRefresh
\OC_App::getEnabledApps(true);
}
示例15: 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);
}
}
}