Exemple #1
0
 /**
  * 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;
 }
Exemple #2
0
 /**
  * @brief: Lists all apps, this is used in apps.php
  * @return array
  */
 public static function listAllApps()
 {
     $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 dont want to show configuration for these
     $appList = array();
     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;
             }
             if (OC_Appconfig::getValue($app, 'enabled', 'no') == 'yes') {
                 $active = true;
             } else {
                 $active = false;
             }
             $info['active'] = $active;
             if (isset($info['shipped']) and $info['shipped'] == 'true') {
                 $info['internal'] = true;
                 $info['internallabel'] = 'Internal App';
                 $info['internalclass'] = '';
                 $info['update'] = false;
             } else {
                 $info['internal'] = false;
                 $info['internallabel'] = '3rd Party';
                 $info['internalclass'] = 'externalapp';
                 $info['update'] = OC_Installer::isUpdateAvailable($app);
             }
             $info['preview'] = OC_Helper::imagePath('settings', 'trans.png');
             $info['version'] = OC_App::getAppVersion($app);
             $appList[] = $info;
         }
     }
     $remoteApps = OC_App::getAppstoreApps();
     if ($remoteApps) {
         // Remove duplicates
         foreach ($appList as $app) {
             foreach ($remoteApps as $key => $remote) {
                 if ($app['name'] == $remote['name']) {
                     unset($remoteApps[$key]);
                 }
             }
         }
         $combinedApps = array_merge($appList, $remoteApps);
     } else {
         $combinedApps = $appList;
     }
     // bring the apps into the right order with a custom sort funtion
     usort($combinedApps, '\\OC_App::customSort');
     return $combinedApps;
 }
Exemple #3
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 (!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;
 }
Exemple #4
0
 /**
  * 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;
 }