/** * Get all available categories * @param int $category * @return array */ public function listApps($category = 0) { $apps = array(); switch ($category) { // installed apps case 0: $apps = \OC_App::listAllApps(true); $apps = array_filter($apps, function ($app) { return $app['active']; }); break; // not-installed apps // not-installed apps case 1: $apps = \OC_App::listAllApps(true); $apps = array_filter($apps, function ($app) { return !$app['active']; }); break; default: if ($category === 2) { $apps = \OC_App::getAppstoreApps('approved'); $apps = array_filter($apps, function ($app) { return isset($app['internalclass']) && $app['internalclass'] === 'recommendedapp'; }); } else { $apps = \OC_App::getAppstoreApps('approved', $category); } if (!$apps) { $apps = array(); } usort($apps, function ($a, $b) { $a = (int) $a['score']; $b = (int) $b['score']; if ($a === $b) { return 0; } return $a > $b ? -1 : 1; }); break; } // fix groups to be an array $apps = array_map(function ($app) { $groups = array(); if (is_string($app['groups'])) { $groups = json_decode($app['groups']); } $app['groups'] = $groups; $app['canUnInstall'] = !$app['active'] && $app['removable']; return $app; }, $apps); return array('apps' => $apps, 'status' => 'success'); }
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'])); }
/** * @return array */ private function getInactiveApps() { $inactiveApps = \OC_App::listAllApps(true, false, $this->ocsClient); $inactiveApps = array_filter($inactiveApps, function ($app) { return !$app['active']; }); $inactiveApps = array_map(function ($app) { if (isset($app['ocsid'])) { return $app['ocsid']; } return $app['id']; }, $inactiveApps); return $inactiveApps; }
/** * @return array */ private function getInstalledApps() { $apps = \OC_App::listAllApps(true); $apps = array_filter($apps, function ($app) { return $app['active']; }); return $apps; }
* * @author Frank Karlitschek * @copyright 2012 Frank Karlitschek frank@owncloud.org * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE * License as published by the Free Software Foundation; either * version 3 of the License, or any later version. * * 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(); // Load the files we need OC_Util::addStyle("settings", "settings"); OC_Util::addScript("core", "multiselect"); OC_App::setActiveNavigationEntry("core_apps"); $combinedApps = OC_App::listAllApps(); $groups = \OC_Group::getGroups(); $tmpl = new OC_Template("settings", "apps", "user"); $tmpl->assign('apps', $combinedApps); $tmpl->assign('groups', $groups); $appid = isset($_GET['appid']) ? strip_tags($_GET['appid']) : ''; $tmpl->assign('appid', $appid); $tmpl->printPage();
/** * @param bool $includeUpdateInfo Should we check whether there is an update * in the app store? * @return array */ private function getInstalledApps($includeUpdateInfo = true) { $apps = \OC_App::listAllApps(true, $includeUpdateInfo); $apps = array_filter($apps, function ($app) { return $app['active']; }); return $apps; }
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'])); }
/** * Get all available categories * @param int $category * @return array */ public function listApps($category = 0) { if (!is_null($this->cache->get('listApps-' . $category))) { $apps = $this->cache->get('listApps-' . $category); } else { switch ($category) { // installed apps case 0: $apps = \OC_App::listAllApps(true); $apps = array_filter($apps, function ($app) { return $app['active']; }); usort($apps, function ($a, $b) { $a = (string) $a['name']; $b = (string) $b['name']; if ($a === $b) { return 0; } return $a < $b ? -1 : 1; }); break; // not-installed apps // not-installed apps case 1: $apps = \OC_App::listAllApps(true); $apps = array_filter($apps, function ($app) { return !$app['active']; }); usort($apps, function ($a, $b) { $a = (string) $a['name']; $b = (string) $b['name']; if ($a === $b) { return 0; } return $a < $b ? -1 : 1; }); break; default: if ($category === 2) { $apps = \OC_App::getAppstoreApps('approved'); if ($apps) { $apps = array_filter($apps, function ($app) { return isset($app['internalclass']) && $app['internalclass'] === 'recommendedapp'; }); } } else { $apps = \OC_App::getAppstoreApps('approved', $category); } if (!$apps) { $apps = array(); } usort($apps, function ($a, $b) { $a = (int) $a['score']; $b = (int) $b['score']; if ($a === $b) { return 0; } return $a > $b ? -1 : 1; }); break; } } // fix groups to be an array $dependencyAnalyzer = new DependencyAnalyzer(new Platform($this->config), $this->l10n); $apps = array_map(function ($app) use($dependencyAnalyzer) { // fix groups $groups = array(); if (is_string($app['groups'])) { $groups = json_decode($app['groups']); } $app['groups'] = $groups; $app['canUnInstall'] = !$app['active'] && $app['removable']; // fix licence vs license if (isset($app['license']) && !isset($app['licence'])) { $app['licence'] = $app['license']; } // analyse dependencies $missing = $dependencyAnalyzer->analyze($app); $app['canInstall'] = empty($missing); $app['missingDependencies'] = $missing; return $app; }, $apps); $this->cache->set('listApps-' . $category, $apps, 300); return ['apps' => $apps, 'status' => 'success']; }