public function execute() { $update_counter = 0; $model = new waAppSettingsModel(); $license = $model->get('webasyst', 'license', false); $apps = new waInstallerApps($license); $app_list = array(); $this->view->assign('error', false); try { $app_list = $apps->getApplicationsList(false, array(), wa()->getDataPath('images', true)); $update_counter = waInstallerApps::getUpdateCount($app_list); $model->ping(); } catch (Exception $ex) { //$this->view->assign('error', $ex->getMessage()); } $this->redirect(array('module' => $update_counter ? 'update' : 'apps')); $this->view->assign('module', false); }
public function onCount() { $args = func_get_args(); $force = array_shift($args); $model = new waAppSettingsModel(); $app_id = $this->getApplication(); $update_counter = null; if ($force || time() - $model->get($app_id, 'update_counter_timestamp', 0) > 600 || is_null($update_counter = $model->get($app_id, 'update_counter', null))) { $license = $model->get('webasyst', 'license', false); $apps = new waInstallerApps($license, null, 600, $force); $app_list = $apps->getApplicationsList(false); $update_counter = waInstallerApps::getUpdateCount($app_list); $messages = ''; installerHelper::getSystemPlugins($messages, $update_counter); $model->ping(); $model->set($app_id, 'update_counter', $update_counter); $model->set($app_id, 'update_counter_timestamp', time()); } elseif (is_null($update_counter)) { $update_counter = $model->get($app_id, 'update_counter'); } return $update_counter ? $update_counter : null; }
public static function getSystemPlugins(&$messages, &$update_counter = null, $filter = array()) { if ($update_counter !== null) { $update_counter = is_array($update_counter) ? array_merge(array_fill_keys(array('total', 'applicable', 'payware'), 0), $update_counter) : intval($update_counter); } $items = self::getInstaller()->getSystemList(); $types = array(); $icons = array('sms' => 'icon16 mobile', 'payment' => 'icon16 dollar', 'shipping' => 'icon16 box'); $translate = array('sms' => _w('SMS'), 'payment' => _w('Payment'), 'shipping' => _w('Shipping')); foreach ($items as $id => $item) { if (!empty($item['subject']) && $item['subject'] == 'systemplugins') { $t = $item['type_slug']; if (empty($types[$t])) { $types[$t] = array('name' => isset($translate[$t]) ? $translate[$t] : null, 'icon' => isset($icons[$t]) ? $icons[$t] : null, 'plugins' => array()); } $types[$t]['plugins'][$item['id']] = $item; } } $minimize = is_array($update_counter) ? true : false; foreach ($types as &$items) { if ($update_counter !== null) { $update_counter = waInstallerApps::getUpdateCount($items['plugins'], $minimize, $update_counter); self::$model->ping(); } } self::$model->ping(); unset($items); return $types; }