/** * Requests an update list used for checking for new updates. * @param boolean $force Request application and plugins hash list regardless of version. * @return array */ public function requestUpdateList($force = false) { $installed = PluginVersion::all(); $versions = $installed->lists('version', 'code'); $names = $installed->lists('name', 'code'); $icons = $installed->lists('icon', 'code'); $frozen = $installed->lists('is_frozen', 'code'); $build = Parameters::get('system::core.build'); $params = ['core' => $this->getHash(), 'plugins' => serialize($versions), 'build' => $build, 'force' => $force]; if ($projectId = Parameters::get('system::project.id')) { $params['project'] = $projectId; } $result = $this->requestServerData('core/update', $params); $updateCount = (int) array_get($result, 'update', 0); /* * Inject known core build */ if ($core = array_get($result, 'core')) { $core['old_build'] = Parameters::get('system::core.build'); $result['core'] = $core; } /* * Inject the application's known plugin name and version */ $plugins = []; foreach (array_get($result, 'plugins', []) as $code => $info) { $info['name'] = isset($names[$code]) ? $names[$code] : $code; $info['old_version'] = isset($versions[$code]) ? $versions[$code] : false; $info['icon'] = isset($icons[$code]) ? $icons[$code] : false; /* * If plugin has updates frozen, do not add it to the list * and discount an update unit. */ if (isset($frozen[$code]) && $frozen[$code]) { $updateCount = max(0, --$updateCount); } else { $plugins[$code] = $info; } } $result['plugins'] = $plugins; /* * Strip out themes that have been installed before */ $themes = []; foreach (array_get($result, 'themes', []) as $code => $info) { if (!$this->themeManager->isInstalled($code)) { $themes[$code] = $info; } } $result['themes'] = $themes; /* * If there is a core update and core updates are disabled, * remove the entry and discount an update unit. */ if (array_get($result, 'core') && $this->disableCoreUpdates) { $updateCount = max(0, --$updateCount); unset($result['core']); } /* * Recalculate the update counter */ $updateCount += count($themes); $result['hasUpdates'] = $updateCount > 0; $result['update'] = $updateCount; Parameters::set('system::update.count', $updateCount); return $result; }
/** * Requests an update list used for checking for new updates. * @param boolean $force Request application and plugins hash list regardless of version. * @return array */ public function requestUpdateList($force = false) { $installed = PluginVersion::all(); $versions = $installed->lists('version', 'code'); $names = $installed->lists('name', 'code'); $params = ['core' => $this->getHash(), 'plugins' => serialize($versions), 'force' => $force]; if ($projectId = Parameters::get('system::project.id')) { $params['project'] = $projectId; } $result = $this->requestServerData('core/update', $params); /* * Inject known core build */ if ($core = array_get($result, 'core')) { $core['old_build'] = Parameters::get('system::core.build'); $result['core'] = $core; } /* * Inject the application's known plugin name and version */ $plugins = []; foreach (array_get($result, 'plugins', []) as $code => $info) { $info['name'] = isset($names[$code]) ? $names[$code] : $code; $info['old_version'] = isset($versions[$code]) ? $versions[$code] : false; $plugins[$code] = $info; } $result['plugins'] = $plugins; /* * Strip out themes that have been installed before */ $themes = []; foreach (array_get($result, 'themes', []) as $code => $info) { if (!$this->isThemeInstalled($code)) { $themes[$code] = $info; } } $result['themes'] = $themes; /* * There are updates if update count is empty * or if uninstalled themes are found. */ $result['hasUpdates'] = array_get($result, 'update') || count($themes); Parameters::set('system::update.count', array_get($result, 'update', 0)); return $result; }