Merge pull request #6920 from nextcloud/appmanager-usage

Use appmanager instead of OC_App for check for enabled app
This commit is contained in:
Morris Jobke 2017-10-24 13:53:17 +02:00 committed by GitHub
commit 3eaf23f29f
7 changed files with 12 additions and 9 deletions

View File

@ -70,7 +70,7 @@ class UpdaterTest extends TestCase {
* that the mount point doesn't end up at the trash bin
*/
public function testDeleteParentFolder() {
$status = \OC_App::isEnabled('files_trashbin');
$status = \OC::$server->getAppManager()->isEnabledForUser('files_trashbin');
(new \OC_App())->enable('files_trashbin');

View File

@ -78,9 +78,10 @@ class Repair extends Command {
}
}
$apps = \OC::$server->getAppManager()->getInstalledApps();
$appManager = \OC::$server->getAppManager();
$apps = $appManager->getInstalledApps();
foreach ($apps as $app) {
if (!\OC_App::isEnabled($app)) {
if (!$appManager->isEnabledForUser($app)) {
continue;
}
$info = \OC_App::getAppInfo($app);

View File

@ -1159,7 +1159,7 @@ class OC_App {
* @return \OC\Files\View|false
*/
public static function getStorage($appId) {
if (OC_App::isEnabled($appId)) { //sanity check
if (\OC::$server->getAppManager()->isEnabledForUser($appId)) { //sanity check
if (\OC::$server->getUserSession()->isLoggedIn()) {
$view = new \OC\Files\View('/' . OC_User::getUser());
if (!$view->file_exists($appId)) {

View File

@ -55,7 +55,7 @@ class OC_JSON{
* @suppress PhanDeprecatedFunction
*/
public static function checkAppEnabled($app) {
if( !OC_App::isEnabled($app)) {
if( !\OC::$server->getAppManager()->isEnabledForUser($app)) {
$l = \OC::$server->getL10N('lib');
self::error(array( 'data' => array( 'message' => $l->t('Application is not enabled'), 'error' => 'application_not_enabled' )));
exit();

View File

@ -297,7 +297,7 @@ class OC_Template extends \OC\Template\Base {
* @suppress PhanAccessMethodInternal
*/
public static function printErrorPage( $error_msg, $hint = '' ) {
if (\OC_App::isEnabled('theming') && !\OC_App::isAppLoaded('theming')) {
if (\OC::$server->getAppManager()->isEnabledForUser('theming') && !\OC_App::isAppLoaded('theming')) {
\OC_App::loadApp('theming');
}

View File

@ -127,9 +127,10 @@ class App {
*
* This function checks whether or not an app is enabled.
* @since 4.0.0
* @deprecated 13.0.0 use \OC::$server->getAppManager()->isEnabledForUser($appId)
*/
public static function isEnabled( $app ) {
return \OC_App::isEnabled( $app );
return \OC::$server->getAppManager()->isEnabledForUser( $app );
}
/**

View File

@ -41,6 +41,7 @@ OC_Util::checkSubAdminUser();
$userManager = \OC::$server->getUserManager();
$groupManager = \OC::$server->getGroupManager();
$appManager = \OC::$server->getAppManager();
// Set the sort option: SORT_USERCOUNT or SORT_GROUPNAME
$sortGroupsBy = \OC\Group\MetaData::SORT_USERCOUNT;
@ -51,7 +52,7 @@ if ($config->getSystemValue('sort_groups_by_name', false)) {
$sortGroupsBy = \OC\Group\MetaData::SORT_GROUPNAME;
} else {
$isLDAPUsed = false;
if (\OC_App::isEnabled('user_ldap')) {
if ($appManager->isEnabledForUser('user_ldap')) {
$isLDAPUsed =
$groupManager->isBackendUsed('\OCA\User_LDAP\Group_LDAP')
|| $groupManager->isBackendUsed('\OCA\User_LDAP\Group_Proxy');
@ -76,7 +77,7 @@ $groupsInfo = new \OC\Group\MetaData(
$groupsInfo->setSorting($sortGroupsBy);
list($adminGroup, $groups) = $groupsInfo->get();
$recoveryAdminEnabled = OC_App::isEnabled('encryption') &&
$recoveryAdminEnabled = $appManager->isEnabledForUser('encryption') &&
$config->getAppValue( 'encryption', 'recoveryAdminEnabled', '0');
if($isAdmin) {