/** * Endpoint for the update-check cronjob. * Loads beacons, checks for updates from hp.o, and saves any updates to the DB. * * @param null $cronjob Unused. The CronJob object being executed when being run as cron. * @return boolean True on successful check, false on any failure (so cron runs again). */ public static function cron($cronjob = null) { // register the beacons self::register_beacons(); // save the list of beacons we are using to check with Options::set('updates_beacons', self::instance()->beacons); try { // run the check $updates = Update::check(); // save the list of updates Options::set('updates_available', $updates); EventLog::log(_t('Updates check CronJob completed successfully.'), 'info', 'update', 'habari'); // return true, we succeeded return true; } catch (\Exception $e) { // catch any exceptions generated by RemoteRequest or XML parsing EventLog::log(_t('Updates check CronJob failed!'), 'err', 'update', 'habari', $e->getMessage()); // tell cron the check failed return false; } }
/** * Handles GET requests for the theme listing */ public function get_themes() { $all_themes = Themes::get_all_data(); foreach ($all_themes as $name => $theme) { if (isset($all_themes[$name]['info']->update) && $all_themes[$name]['info']->update != '' && isset($all_themes[$name]['info']->version) && $all_themes[$name]['info']->version != '') { Update::add($name, $all_themes[$name]['info']->update, $all_themes[$name]['info']->version); } } $updates = Update::check(); foreach ($all_themes as $name => $theme) { if (isset($all_themes[$name]['info']->update) && isset($updates[$all_themes[$name]['info']->update])) { $all_themes[$name]['info']->update = $updates[$all_themes[$name]['info']->update]['latest_version']; } else { $all_themes[$name]['info']->update = ''; } } $this->theme->all_themes = $all_themes; $this->theme->active_theme = Themes::get_active_data(true); $this->theme->active_theme_dir = $this->theme->active_theme['path']; // If the active theme is configurable, allow it to configure $this->theme->active_theme_name = $this->theme->active_theme['info']->name; $this->theme->configurable = Plugins::filter('theme_config', false, $this->active_theme); $this->theme->assign('configure', Controller::get_var('configure')); $activedata = Themes::get_active_data(true); $areas = array(); if (isset($activedata['info']->areas->area)) { foreach ($activedata['info']->areas->area as $area) { $areas[] = (string) $area; } } $this->theme->areas = $areas; $this->theme->previewed = Themes::get_theme_dir(false); $this->theme->blocks = Plugins::filter('block_list', array()); $this->theme->block_instances = DB::get_results('SELECT b.* FROM {blocks} b ORDER BY b.title ASC', array(), 'Block'); $blocks_areas_t = DB::get_results('SELECT b.*, ba.scope_id, ba.area, ba.display_order FROM {blocks} b INNER JOIN {blocks_areas} ba ON ba.block_id = b.id ORDER BY ba.scope_id ASC, ba.area ASC, ba.display_order ASC', array()); $blocks_areas = array(); foreach ($blocks_areas_t as $block) { if (!isset($blocks_areas[$block->scope_id])) { $blocks_areas[$block->scope_id] = array(); } $blocks_areas[$block->scope_id][$block->area][$block->display_order] = $block; } $this->theme->blocks_areas = $blocks_areas; $this->theme->scopes = DB::get_results('SELECT * FROM {scopes} ORDER BY id ASC;'); $this->theme->theme_loader = Plugins::filter('theme_loader', '', $this->theme); $this->theme->display('themes'); }
/** * Handles GET requests for the theme listing */ public function get_themes() { $all_themes = Themes::get_all_data(); foreach ($all_themes as $name => $theme) { if (isset($all_themes[$name]['info']->update) && $all_themes[$name]['info']->update != '' && isset($all_themes[$name]['info']->version) && $all_themes[$name]['info']->version != '') { Update::add($name, $all_themes[$name]['info']->update, $all_themes[$name]['info']->version); } } $updates = Update::check(); foreach ($all_themes as $name => $theme) { if (isset($all_themes[$name]['info']->update) && isset($updates[$all_themes[$name]['info']->update])) { $all_themes[$name]['info']->update = $updates[$all_themes[$name]['info']->update]['latest_version']; } else { $all_themes[$name]['info']->update = ''; } } $this->theme->all_themes = $all_themes; $this->theme->active_theme = Themes::get_active_data(); $this->theme->active_theme_dir = $this->theme->active_theme['path']; // If the active theme is configurable, allow it to configure $this->theme->active_theme_name = $this->theme->active_theme['info']->name; $this->theme->configurable = Plugins::filter('theme_config', false, $this->active_theme); $this->theme->assign('configure', Controller::get_var('configure')); $this->theme->display('themes'); }