Beispiel #1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if ($input->getOption('shipped') === 'true' || $input->getOption('shipped') === 'false') {
         $shouldFilterShipped = true;
         $shippedFilter = $input->getOption('shipped') === 'true';
     } else {
         $shouldFilterShipped = false;
     }
     $apps = \OC_App::getAllApps();
     $enabledApps = $disabledApps = [];
     $versions = \OC_App::getAppVersions();
     //sort enabled apps above disabled apps
     foreach ($apps as $app) {
         if ($shouldFilterShipped && \OC_App::isShipped($app) !== $shippedFilter) {
             continue;
         }
         if (\OC_App::isEnabled($app)) {
             $enabledApps[] = $app;
         } else {
             $disabledApps[] = $app;
         }
     }
     $apps = ['enabled' => [], 'disabled' => []];
     sort($enabledApps);
     foreach ($enabledApps as $app) {
         $apps['enabled'][$app] = isset($versions[$app]) ? $versions[$app] : true;
     }
     sort($disabledApps);
     foreach ($disabledApps as $app) {
         $apps['disabled'][$app] = null;
     }
     $this->writeAppList($input, $output, $apps);
 }
Beispiel #2
0
 public function collect($dryRun = false)
 {
     foreach (\OC_App::getAllApps() as $appId) {
         if (\OC_App::isShipped($appId)) {
             if ($dryRun || @file_exists($this->newBase . '/' . $appId)) {
                 $this->appsToUpdate[$appId] = $appId;
             } else {
                 $this->appsToDisable[$appId] = $appId;
             }
         }
     }
 }
Beispiel #3
0
 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());
     }
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $apps = \OC_App::getAllApps();
     $enabledApps = array();
     $disabledApps = array();
     //sort enabled apps above disabled apps
     foreach ($apps as $app) {
         if (\OC_App::isEnabled($app)) {
             $enabledApps[] = $app;
         } else {
             $disabledApps[] = $app;
         }
     }
     sort($enabledApps);
     sort($disabledApps);
     $output->writeln('Enabled:');
     foreach ($enabledApps as $app) {
         $output->writeln(' - ' . $app);
     }
     $output->writeln('Disabled:');
     foreach ($disabledApps as $app) {
         $output->writeln(' - ' . $app);
     }
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $apps = \OC_App::getAllApps();
     $enabledApps = $disabledApps = [];
     $versions = \OC_App::getAppVersions();
     //sort enabled apps above disabled apps
     foreach ($apps as $app) {
         if (\OC_App::isEnabled($app)) {
             $enabledApps[] = $app;
         } else {
             $disabledApps[] = $app;
         }
     }
     $apps = ['enabled' => [], 'disabled' => []];
     sort($enabledApps);
     foreach ($enabledApps as $app) {
         $apps['enabled'][$app] = isset($versions[$app]) ? $versions[$app] : true;
     }
     sort($disabledApps);
     foreach ($disabledApps as $app) {
         $apps['disabled'][$app] = null;
     }
     $this->writeAppList($input, $output, $apps);
 }
Beispiel #6
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;
 }
Beispiel #7
0
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with this library.  If not, see <http://www.gnu.org/licenses/>.
*
*/
OC_Util::checkAdminUser();
OC_App::loadApps();
// Load the files we need
OC_Util::addStyle("settings", "settings");
OC_Util::addScript("settings", "apps");
OC_App::setActiveNavigationEntry("core_apps");
$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;
Beispiel #8
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;
 }
Beispiel #9
0
 protected function createSchema(Connection $toDB, InputInterface $input, OutputInterface $output)
 {
     $output->writeln('<info>Creating schema in new database</info>');
     $schemaManager = new \OC\DB\MDB2SchemaManager($toDB);
     $schemaManager->createDbFromStructure(\OC::$SERVERROOT . '/db_structure.xml');
     $apps = $input->getOption('all-apps') ? \OC_App::getAllApps() : \OC_App::getEnabledApps();
     foreach ($apps as $app) {
         if (file_exists(\OC_App::getAppPath($app) . '/appinfo/database.xml')) {
             $schemaManager->createDbFromStructure(\OC_App::getAppPath($app) . '/appinfo/database.xml');
         }
     }
 }
Beispiel #10
0
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with this library.  If not, see <http://www.gnu.org/licenses/>.
*
*/
require_once '../lib/base.php';
OC_Util::checkAdminUser();
// Load the files we need
OC_Util::addStyle("settings", "settings");
OC_Util::addScript("settings", "apps");
OC_App::setActiveNavigationEntry("core_apps");
$registeredApps = OC_App::getAllApps();
$apps = array();
$blacklist = array('files', 'files_imageviewer', 'files_textviewer');
//we dont want to show configuration for these
foreach ($registeredApps as $app) {
    if (array_search($app, $blacklist) === false) {
        $info = OC_App::getAppInfo($app);
        $active = OC_Appconfig::getValue($app, 'enabled', 'no') == 'yes' ? true : false;
        $info['active'] = $active;
        if (isset($info['shipped']) and $info['shipped'] == 'true') {
            $info['internal'] = true;
            $info['internallabel'] = 'Internal App';
        } else {
            $info['internal'] = false;
            $info['internallabel'] = '3rd Party App';
        }
Beispiel #11
0
/**
 * Copyright (c) 2013 Bart Visscher <*****@*****.**>
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 * See the COPYING-README file.
 */
use Symfony\Component\Console\Application;
$RUNTIME_NOAPPS = true;
require_once 'lib/base.php';
// set to run indefinitely if needed
set_time_limit(0);
// Don't do anything if ownCloud has not been installed yet
if (!OC_Config::getValue('installed', false)) {
    echo "Console can only be used once ownCloud has been installed" . PHP_EOL;
    exit(0);
}
if (!OC::$CLI) {
    echo "This script can be run from the command line only" . PHP_EOL;
    exit(0);
}
$defaults = new OC_Defaults();
$application = new Application($defaults->getName(), \OC_Util::getVersionString());
require_once 'core/register_command.php';
foreach (OC_App::getAllApps() as $app) {
    $file = OC_App::getAppPath($app) . '/appinfo/register_command.php';
    if (file_exists($file)) {
        require $file;
    }
}
$application->run();
Beispiel #12
0
 /**
  * @brief replaces the ownCloud tables with a new set
  * @param $file string path to the MDB2 xml db export file
  */
 public function replaceDB($file)
 {
     $apps = \OC_App::getAllApps();
     $this->conn->beginTransaction();
     // Delete the old tables
     $this->removeDBStructure(\OC::$SERVERROOT . '/db_structure.xml');
     foreach ($apps as $app) {
         $path = \OC_App::getAppPath($app) . '/appinfo/database.xml';
         if (file_exists($path)) {
             $this->removeDBStructure($path);
         }
     }
     // Create new tables
     $this->conn->commit();
 }
 /**
  * @brief returns an array of apps that support migration
  * @return array
  */
 public static function getApps()
 {
     $allapps = OC_App::getAllApps();
     foreach ($allapps as $app) {
         $path = OC::$SERVERROOT . '/apps/' . $app . '/lib/migrate.php';
         if (file_exists($path)) {
             $supportsmigration[] = $app;
         }
     }
     return $supportsmigration;
 }
Beispiel #14
0
 /**
  * Providers \OC_App::getAllApps()
  *
  * @return array
  */
 public function getAllApps()
 {
     return \OC_App::getAllApps();
 }
Beispiel #15
0
 /**
  * returns an array of apps that support migration
  * @return array
  */
 public static function getApps()
 {
     $allapps = OC_App::getAllApps();
     foreach ($allapps as $app) {
         $path = self::getAppPath($app) . '/lib/migrate.php';
         if (file_exists($path)) {
             $supportsmigration[] = $app;
         }
     }
     return $supportsmigration;
 }
Beispiel #16
0
 /**
  * @brief replaces the owncloud tables with a new set
  * @param $file string path to the MDB2 xml db export file
  */
 public static function replaceDB($file)
 {
     $apps = OC_App::getAllApps();
     self::beginTransaction();
     // Delete the old tables
     self::removeDBStructure(OC::$SERVERROOT . '/db_structure.xml');
     foreach ($apps as $app) {
         $path = OC::$SERVERROOT . '/apps/' . $app . '/appinfo/database.xml';
         if (file_exists($path)) {
             self::removeDBStructure($path);
         }
     }
     // Create new tables
     self::createDBFromStructure($file);
     self::commit();
 }
Beispiel #17
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;
 }
Beispiel #18
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;
 }
Beispiel #19
0
 public function testGetAllApps()
 {
     $this->assertSame(\OC_App::getAllApps(), $this->locator->getAllApps());
 }