protected function _launch($id) { //$this->getHelper()->run($id); // implemented via remote request because potentially some package's cron task // may use front classes which will cause conflicts if executed from backend side. // otherwise, the only call of iaCore::run() would be enough $cronUrl = IA_CLEAR_URL . 'cron/?_t&t=' . (int) $id; iaUtil::getPageContent($cronUrl, 300); // $this->_iaCore->iaView->setMessages(iaLanguage::get('scheduled_task_ran'), iaView::SUCCESS); iaUtil::go_to($this->getPath()); }
private function _getRemotePlugins($start, $limit, $dir, $filter) { $pluginsData = array(); if ($cachedData = $this->_iaCore->iaCache->get('subrion_plugins', 3600, true)) { $pluginsData = $cachedData; } else { if ($response = iaUtil::getPageContent(iaUtil::REMOTE_TOOLS_URL . 'list/plugin/' . IA_VERSION)) { $response = iaUtil::jsonDecode($response); if (!empty($response['error'])) { $this->addMessage($response['error']); } elseif ($response['total'] > 0) { if (isset($response['extensions']) && is_array($response['extensions'])) { $pluginsData = array(); $installedPlugins = $this->_iaDb->keyvalue(array('name', 'version'), iaDb::convertIds(iaExtra::TYPE_PLUGIN, 'type')); foreach ($response['extensions'] as $entry) { $pluginInfo = (array) $entry; $pluginInfo['install'] = 0; // exclude installed plugins if (!array_key_exists($pluginInfo['name'], $installedPlugins)) { $pluginsData['pluginsList'][$pluginInfo['name']] = $pluginInfo['title']; if (isset($pluginInfo['compatibility']) && version_compare($pluginInfo['compatibility'], IA_VERSION, '<=')) { $pluginInfo['install'] = 1; } $pluginInfo['date'] = gmdate(iaDb::DATE_FORMAT, $pluginInfo['date']); $pluginInfo['file'] = $pluginInfo['name']; $pluginInfo['readme'] = false; $pluginInfo['reinstall'] = false; $pluginInfo['uninstall'] = false; $pluginInfo['remove'] = false; $pluginInfo['removable'] = false; $pluginsData['plugins'][$pluginInfo['name']] = $pluginInfo; } } // cache well-formed results $this->_iaCore->iaCache->write('subrion_plugins', $pluginsData); } else { $this->addMessage('error_incorrect_format_from_subrion'); } } } else { $this->addMessage('error_incorrect_response_from_subrion'); } } return $this->getMessages() ? array('result' => false, 'message' => $this->getMessages()) : $this->_sortPlugins($pluginsData, $start, $limit, $dir, $filter); }
private function _getList() { $templates = $this->getHelper()->getList(); // get list of available local templates $remoteTemplates = array(); if ($this->_iaCore->get('allow_remote_templates')) { if ($cachedData = $this->_iaCore->iaCache->get('subrion_templates', 3600, true)) { $remoteTemplates = $cachedData; // get templates list from cache, cache lives for 1 hour } else { if ($response = iaUtil::getPageContent(iaUtil::REMOTE_TOOLS_URL . 'list/template/' . IA_VERSION)) { $response = iaUtil::jsonDecode($response); if (!empty($response['error'])) { $this->_messages[] = $response['error']; $this->_error = true; } elseif ($response['total'] > 0) { if (isset($response['extensions']) && is_array($response['extensions'])) { foreach ($response['extensions'] as $entry) { $templateInfo = (array) $entry; // exclude installed templates if (!array_key_exists($templateInfo['name'], $templates)) { $templateInfo['date'] = gmdate(iaDb::DATE_FORMAT, $templateInfo['date']); $templateInfo['buttons'] = ''; $templateInfo['notes'] = array(); $templateInfo['remote'] = true; $remoteTemplates[] = $templateInfo; } } // cache well-formed results $this->_iaCore->iaCache->write('subrion_templates', $remoteTemplates); } else { $this->addMessage('error_incorrect_format_from_subrion'); $this->_error = true; } } } else { $this->addMessage('error_incorrect_response_from_subrion'); $this->_error = true; } } } return array_merge($templates, $remoteTemplates); }
private function _checkForUpdates() { $url = sprintf(iaUtil::REMOTE_TOOLS_URL . 'get/updates/%s/', IA_VERSION); $content = iaUtil::getPageContent($url); if (!$content) { return; } $content = iaUtil::jsonDecode($content); if (is_array($content) && $content) { $messages = array(); foreach ($content as $entry) { switch ($entry['type']) { case self::UPDATE_TYPE_INFO: $messages[] = array($entry['id'], $entry['message']); break; case self::UPDATE_TYPE_PATCH: $version = explode('.', $entry['version']); if (count($version) > 3) { if ($this->_iaCore->get('auto_apply_critical_upgrades')) { $result = iaSystem::forceUpgrade($entry['version']); if (is_bool($result) && $result) { $this->_iaCore->factory('cache')->clearGlobalCache(); $message = iaLanguage::getf('script_upgraded', array('version' => $entry['version'])); $this->_iaCore->iaView->setMessages($message, iaView::SUCCESS); iaUtil::go_to(IA_SELF); } else { iaDebug::debug($result, 'Forced upgrade to the version ' . $entry['version']); } } } else { $url = sprintf('%sinstall/upgrade/check/%s/', IA_CLEAR_URL, $entry['version']); $this->_iaCore->iaView->setMessages(iaLanguage::getf('upgrade_available', array('url' => $url, 'version' => $entry['version'])), iaView::SYSTEM); } } } $this->_iaCore->iaView->assign('updatesInfo', $messages); } }
private function getRemoteList($localPackages) { $remotePackages = array(); if ($cachedData = $this->_iaCore->iaCache->get('subrion_packages', 3600 * 24 * 7, true)) { $remotePackages = $cachedData; // get templates list from cache, cache lives for 1 hour } else { if ($response = iaUtil::getPageContent(iaUtil::REMOTE_TOOLS_URL . 'list/package/' . IA_VERSION)) { $response = iaUtil::jsonDecode($response); if (!empty($response['error'])) { $this->_messages[] = $response['error']; $this->_error = true; } elseif ($response['total'] > 0) { if (isset($response['extensions']) && is_array($response['extensions'])) { foreach ($response['extensions'] as $entry) { $packageInfo = (array) $entry; // exclude uploaded packages if (!in_array($packageInfo['name'], $localPackages)) { $packageInfo['date'] = gmdate(iaDb::DATE_FORMAT, $packageInfo['date']); $packageInfo['status'] = ''; $packageInfo['summary'] = $packageInfo['description']; $packageInfo['buttons'] = false; $packageInfo['remote'] = true; $remotePackages[] = $packageInfo; } } // cache well-formed results $this->_iaCore->iaCache->write('subrion_packages', $remotePackages); } else { $this->addMessage('error_incorrect_format_from_subrion'); $this->_error = true; } } } else { $this->addMessage('error_incorrect_response_from_subrion'); $this->_error = true; } } return $remotePackages; }
protected function _indexPage(&$iaView) { $iaView->display('index'); $iaCore =& $this->_iaCore; $iaDb =& $this->_iaDb; if (isset($_GET['reset']) || isset($_GET['save'])) { $data = isset($_GET['list']) ? $_GET['list'] : ''; if ($iaDb->update(array('admin_columns' => $data), iaDb::convertIds(iaUsers::getIdentity()->id), null, iaUsers::getTable())) { iaUsers::reloadIdentity(); } $iaView->setMessages(iaLanguage::get('saved'), iaView::SUCCESS); iaUtil::go_to(IA_SELF); } $disabledWidgets = iaUsers::getIdentity()->admin_columns; $disabledWidgets = empty($disabledWidgets) ? array() : explode(',', trim($disabledWidgets, ',')); $iaView->assign('disabled_widgets', $disabledWidgets); $customizationMode = isset($_GET['customize']) && empty($_GET['customize']); if ($customizationMode) { $iaView->setMessages(iaLanguage::get('customization_mode_alert')); $iaView->assign('customization_mode', true); } // populate statistics $iaItem = $iaCore->factory('item'); $itemsList = $iaItem->getPackageItems(); $validSizes = array('small', 'medium', 'package'); $iaCore->startHook('adminDashboardStatistics', array('items' => &$itemsList)); natcasesort($itemsList); $statistics = array(); foreach ($validSizes as $size) { $statistics[$size] = array(); } foreach ($itemsList as $itemName => $pluginType) { $itemName = substr($itemName, 0, -1); switch ($pluginType) { case 'core': $classInstance = $iaCore->factory('member' == $itemName ? 'users' : $itemName); break; case 'plugin': $array = explode(':', $itemName); $itemName = isset($array[1]) ? $array[1] : $itemName; $classInstance = $iaCore->factoryPlugin($array[0], iaCore::ADMIN, isset($array[1]) ? $array[1] : null); break; default: $classInstance = $iaCore->factoryPackage($itemName, $pluginType, iaCore::ADMIN); } if (!$customizationMode && in_array($itemName, $disabledWidgets)) { continue; } if ($classInstance) { if (method_exists($classInstance, self::STATISTICS_GETTER_METHOD)) { if ($classInstance->dashboardStatistics) { $data = $classInstance->{self::STATISTICS_GETTER_METHOD}(); isset($data['icon']) || ($data['icon'] = $itemName); isset($data['caption']) || ($data['caption'] = $itemName); $data['caption'] = iaLanguage::get($data['caption'], $data['caption']); $widgetFormat = isset($data['_format']) && in_array($data['_format'], $validSizes) ? $data['_format'] : $validSizes[0]; $statistics[$widgetFormat][$itemName] = $data; } } } } $iaView->assign('statistics', $statistics); // if (($customizationMode || !in_array('changelog', $disabledWidgets)) && $iaCore->get('display_changelog') && is_file(IA_HOME . 'changelog.txt')) { $index = 0; $log = array(); $titles = array(); $lines = file(IA_HOME . 'changelog.txt'); foreach ($lines as $line_num => $line) { $line = trim($line); if ($line) { if ($line[0] == '>') { $index++; $log[$index] = array('title' => trim($line, '<> '), 'added' => '', 'modified' => '', 'bugfixes' => '', 'other' => ''); $titles[trim($line, '<> ')] = $index; } elseif ($index > 0) { switch ($line[0]) { case '+': $class = 'added'; break; case '-': $class = 'bugfixes'; break; case '*': $class = 'modified'; break; default: $class = 'other'; } $issue = preg_replace('/#(\\d+)/', '<a href="http://dev.subrion.org/issues/$1" target="_blank">#$1</a>', ltrim($line, '+-* ')); $log[$index][$class] .= '<li>' . $issue . '</li>'; } } } unset($log[0]); ksort($titles); $titles = array_reverse($titles); $iaView->assign('changelog_titles', $titles); $iaView->assign('changelog', $log); } // twitter widget if ($customizationMode || !in_array('twitter', $disabledWidgets)) { $data = iaUtil::getPageContent('http://tools.intelliants.com/timeline/'); $iaView->assign('timeline', iaUtil::jsonDecode($data)); } if ($customizationMode || !in_array('recent-activity', $disabledWidgets)) { $data = $iaCore->factory('log')->get(); $iaView->assign('activity_log', $data); } if ($customizationMode || !in_array('website-visits', $disabledWidgets)) { $data = $iaCore->factory('users')->getVisitorsInfo(); $iaView->assign('online_members', $data); } if ($iaCore->get('check_for_updates')) { if ($content = iaUtil::getPageContent(iaUtil::REMOTE_TOOLS_URL . 'get/patch/')) { $content = iaUtil::jsonDecode($content); if (is_array($content) && $content) { foreach ($content as $versionFrom => $versionTo) { if (version_compare($versionFrom, IA_VERSION) === 0 && version_compare($versionTo, IA_VERSION)) { $version = explode('.', $versionTo); if (count($version) > 3) { if ($iaCore->get('auto_apply_critical_upgrades')) { $result = iaSystem::forceUpgrade($versionTo); if (is_bool($result) && $result) { $iaCore->factory('cache')->clearGlobalCache(); $message = iaLanguage::getf('script_upgraded', array('version' => $versionTo)); $iaView->setMessages($message, iaView::SUCCESS); iaUtil::go_to(IA_SELF); } else { iaDebug::debug($result, 'Forced upgrade to the version ' . $versionTo); } } } else { $url = sprintf('%sinstall/upgrade/check/%s/', IA_CLEAR_URL, $versionTo); $iaView->setMessages(iaLanguage::getf('upgrade_available', array('url' => $url, 'version' => $versionTo)), iaView::SYSTEM); } } } } } } }