Exemple #1
0
 /**
  * Default action. Shows the list of all installed plugins.
  */
 public function index()
 {
     OW::getNavigation()->activateMenuItem(OW_Navigation::ADMIN_PLUGINS, 'admin', 'sidebar_menu_plugins_installed');
     $language = OW::getLanguage();
     $this->setPageTitle($language->text('admin', 'page_title_manage_plugins'));
     $this->setPageHeading($language->text('admin', 'page_title_manage_plugins'));
     $this->setPageHeadingIconClass('ow_ic_gear_wheel');
     $this->pluginService->updatePluginsXmlInfo();
     // get plugins in DB
     $plugins = $this->pluginService->findRegularPlugins();
     usort($plugins, array(__CLASS__, 'sortPlugins'));
     $arrayToAssign['active'] = array();
     $arrayToAssign['inactive'] = array();
     /* @var $plugin BOL_Plugin */
     foreach ($plugins as $plugin) {
         $array = array('title' => $plugin->getTitle(), 'description' => $plugin->getDescription(), 'set_url' => $plugin->isActive && $plugin->getAdminSettingsRoute() !== null ? OW::getRouter()->urlForRoute($plugin->adminSettingsRoute) : false, 'update_url' => (int) $plugin->getUpdate() === 1 && !defined('OW_PLUGIN_XP') ? OW::getRouter()->urlFor('ADMIN_CTRL_Plugins', 'updateRequest', array('key' => $plugin->getKey())) : false);
         if ($plugin->isActive()) {
             $array['deact_url'] = OW::getRouter()->urlFor(__CLASS__, 'deactivate', array('key' => $plugin->getKey()));
             $array['un_url'] = $plugin->getUninstallRoute() === null ? OW::getRouter()->urlFor(__CLASS__, 'uninstallRequest', array('key' => $plugin->getKey())) : OW::getRouter()->urlForRoute($plugin->getUninstallRoute());
             $arrayToAssign['active'][$plugin->getKey()] = $array;
         } else {
             $array['active_url'] = OW::getRouter()->urlFor(__CLASS__, 'activate', array('key' => $plugin->getKey()));
             $arrayToAssign['inactive'][$plugin->getKey()] = $array;
         }
     }
     $event = new OW_Event('admin.plugins_list_view', array('ctrl' => $this, 'type' => 'index'), $arrayToAssign);
     OW::getEventManager()->trigger($event);
     $arrayToAssign = $event->getData();
     $this->assign('plugins', $arrayToAssign);
 }
Exemple #2
0
 /**
  * Retrieves update information for all plugins and themes.
  *
  * @return bool
  */
 public function checkUpdates()
 {
     $requestArray = array("platform" => array(self::URI_VAR_BUILD => OW::getConfig()->getValue("base", "soft_build")), "items" => array());
     $plugins = $this->pluginService->findRegularPlugins();
     /* @var $plugin BOL_Plugin */
     foreach ($plugins as $plugin) {
         $requestArray["items"][] = array(self::URI_VAR_KEY => $plugin->getKey(), self::URI_VAR_DEV_KEY => $plugin->getDeveloperKey(), self::URI_VAR_BUILD => $plugin->getBuild(), self::URI_VAR_LICENSE_KEY => $plugin->getLicenseKey(), self::URI_VAR_ITEM_TYPE => self::URI_VAR_ITEM_TYPE_VAL_PLUGIN);
     }
     //check all manual updates before reading builds in DB
     $this->themeService->checkManualUpdates();
     $themes = $this->themeService->findAllThemes();
     /* @var $dto BOL_Theme */
     foreach ($themes as $dto) {
         $requestArray["items"][] = array(self::URI_VAR_KEY => $dto->getKey(), self::URI_VAR_DEV_KEY => $dto->getDeveloperKey(), self::URI_VAR_BUILD => $dto->getBuild(), self::URI_VAR_LICENSE_KEY => $dto->getLicenseKey(), self::URI_VAR_ITEM_TYPE => self::URI_VAR_ITEM_TYPE_VAL_THEME);
     }
     $data = $this->triggerEventBeforeRequest();
     $data["info"] = json_encode($requestArray);
     $params = new UTIL_HttpClientParams();
     $params->addParams($data);
     $response = UTIL_HttpClient::post($this->getStorageUrl(self::URI_CHECK_ITEMS_FOR_UPDATE), $params);
     if (!$response || $response->getStatusCode() != UTIL_HttpClient::HTTP_STATUS_OK) {
         OW::getLogger()->addEntry(__CLASS__ . "::" . __METHOD__ . "#" . __LINE__ . " storage request status is not OK", "core.update");
         return false;
     }
     $resultArray = array();
     if ($response->getBody()) {
         $resultArray = json_decode($response->getBody(), true);
     }
     if (empty($resultArray) || !is_array($resultArray)) {
         OW::getLogger()->addEntry(__CLASS__ . "::" . __METHOD__ . "#" . __LINE__ . " remote request returned empty result", "core.update");
         return false;
     }
     if (!empty($resultArray["update"])) {
         if (!empty($resultArray["update"]["platform"]) && (bool) $resultArray["update"]["platform"]) {
             OW::getConfig()->saveConfig("base", "update_soft", 1);
         }
         if (!empty($resultArray["update"]["items"])) {
             $this->updateItemsUpdateStatus($resultArray["update"]["items"]);
         }
     }
     $items = !empty($resultArray["invalidLicense"]) ? $resultArray["invalidLicense"] : array();
     $this->updateItemsLicenseStatus($items);
     return true;
 }