예제 #1
0
 /**
  * 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 (!is_array($info)) {
                 \OCP\Util::writeLog('core', 'Could not read app info file for app "' . $app . '"', \OCP\Util::ERROR);
                 continue;
             }
             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 ? 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;
 }
예제 #2
0
 /**
  * @param array $disabledApps
  * @throws \Exception
  */
 private function upgradeAppStoreApps(array $disabledApps)
 {
     foreach ($disabledApps as $app) {
         try {
             if (Installer::isUpdateAvailable($app)) {
                 $ocsId = \OC::$server->getConfig()->getAppValue($app, 'ocsid', '');
                 $this->emit('\\OC\\Updater', 'upgradeAppStoreApp', array($app));
                 Installer::updateAppByOCSId($ocsId);
             }
         } catch (\Exception $ex) {
             $this->log->logException($ex, ['app' => 'core']);
         }
     }
 }
예제 #3
0
 /**
  * @param string $app
  * @return string|false
  */
 protected function isUpdateAvailable($app)
 {
     return Installer::isUpdateAvailable($app);
 }