public function update(RESTRequest $request) { $stb_list = $request->getConvertedIdentifiers(); if (empty($stb_list)) { throw new RESTCommandException('Empty stb list'); } /*if (count($stb_list) != 1){ throw new RESTCommandException('Only one identifier allowed'); }*/ $uids = $stb_list; $data = $request->getPut(); if (empty($data)) { throw new RESTCommandException('HTTP PUT data is empty'); } if (!key_exists('disabled', $data) && !key_exists('restricted', $data)) { throw new RESTCommandException('Update data is empty'); } if (key_exists('disabled', $data)) { foreach ($uids as $uid) { Stb::setDisabledModulesByUid($uid, $data['disabled']); } } if (key_exists('restricted', $data)) { foreach ($uids as $uid) { Stb::setRestrictedModulesByUid($uid, $data['restricted']); } } return array('disabled' => Stb::getDisabledModulesByUid($uids[0]), 'restricted' => Stb::getRestrictedModulesByUid($uids[0])); }
include "./common.php"; if (empty($_GET['uid'])) { exit; } $file = file_get_contents('../../new/launcher/profile.json'); $profile = json_decode($file, true); $apps = new AppsManager(); $external_apps = $apps->getList(true); $installed_apps = array_values(array_filter($external_apps, function ($app) { return $app['installed'] == 1 && $app['status'] == 1 && !empty($app['alias']); })); $installed_apps_names = array_map(function ($app) { return 'external_' . $app['alias']; }, $installed_apps); $all_modules = array_merge(Config::get('all_modules'), $installed_apps_names); $disabled_modules = Stb::getDisabledModulesByUid((int) $_GET['uid']); $user = Stb::getById((int) $_GET['uid']); // if user is off - return empty menu if ($user['status'] == 1) { $profile['menu'] = array(); echo json_encode($profile); exit; } $profile['apiDomain'] = $profile['stalkerAuthDomain'] = 'http' . (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443 ? 's' : '') . '://' . $_SERVER['HTTP_HOST'] . Config::getSafe('portal_url', '/stalker_portal/') . 'api/api_v2.php?_resource='; $profile['authDomain'] = 'http' . (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443 ? 's' : '') . '://' . $_SERVER['HTTP_HOST'] . Config::getSafe('portal_url', '/stalker_portal/') . 'auth/token/'; $profile['pingTimeout'] = Config::getSafe('watchdog_timeout', 120) * 1000; $available_modules = array_diff($all_modules, $disabled_modules); $available_modules[] = 'portal settings'; $module_to_app_map = array('vclub' => 'video club', 'audioclub' => 'audio club', 'media_browser' => 'explorer', 'weather.day' => 'weather', 'ex' => 'ex.ua', 'game.lines' => 'lines', 'game.memory' => 'memory', 'game.sudoku' => 'sudoku', 'internet' => 'browser', 'game.2048' => '2048'); $available_modules = array_map(function ($module) use($module_to_app_map) { return isset($module_to_app_map[$module]) ? $module_to_app_map[$module] : $module;
public function get(RESTApiRequest $request, $parent_id) { $all_modules = \Config::get('all_modules'); $disabled_modules = \Stb::getDisabledModulesByUid((int) $parent_id); return array_values(array_diff($all_modules, $disabled_modules)); }