/** * Checks all installed extensions to see any have an outstanding update. If any do * an Alert will be added to the current page directing the Author to the Extension page * * @since Symphony 2.5.2 */ public function checkExtensionsForUpdates() { $extensions = Symphony::ExtensionManager()->listInstalledHandles(); if (is_array($extensions) && !empty($extensions)) { foreach ($extensions as $name) { $about = Symphony::ExtensionManager()->about($name); if (array_key_exists('status', $about) && in_array(EXTENSION_REQUIRES_UPDATE, $about['status'])) { $this->Page->pageAlert(__('An extension requires updating.') . ' <a href="' . SYMPHONY_URL . '/system/extensions/">' . __('View extensions') . '</a>'); break; } } } }
/** * Given the URL path of a Symphony backend page, this function will * attempt to resolve the URL to a Symphony content page in the backend * or a page provided by an extension. This function checks to ensure a user * is logged in, otherwise it will direct them to the login page * * @param string $page * The URL path after the root of the Symphony installation, including a starting * slash, such as '/login/' * @throws SymphonyErrorPage * @throws Exception * @return HTMLPage */ private function __buildPage($page) { $is_logged_in = self::isLoggedIn(); if (empty($page) || is_null($page)) { if (!$is_logged_in) { $page = "/login"; } else { // Will redirect an Author to their default area of the Backend // Integers are indicative of section's, text is treated as the path // to the page after `SYMPHONY_URL` $default_area = null; if (is_numeric(Symphony::Author()->get('default_area'))) { $default_section = SectionManager::fetch(Symphony::Author()->get('default_area')); if ($default_section instanceof Section) { $section_handle = $default_section->get('handle'); } if (!$section_handle) { $all_sections = SectionManager::fetch(); if (!empty($all_sections)) { $section_handle = $all_sections[0]->get('handle'); } else { $section_handle = null; } } if (!is_null($section_handle)) { $default_area = "/publish/{$section_handle}/"; } } elseif (!is_null(Symphony::Author()->get('default_area'))) { $default_area = preg_replace('/^' . preg_quote(SYMPHONY_URL, '/') . '/i', '', Symphony::Author()->get('default_area')); } if (is_null($default_area)) { if (Symphony::Author()->isDeveloper()) { $all_sections = SectionManager::fetch(); $section_handle = !empty($all_sections) ? $all_sections[0]->get('handle') : null; if (!is_null($section_handle)) { // If there are sections created, redirect to the first one (sortorder) redirect(SYMPHONY_URL . "/publish/{$section_handle}/"); } else { // If there are no sections created, default to the Section page redirect(SYMPHONY_URL . '/blueprints/sections/'); } } else { redirect(SYMPHONY_URL . "/system/authors/edit/" . Symphony::Author()->get('id') . "/"); } } else { redirect(SYMPHONY_URL . $default_area); } } } if (!($this->_callback = $this->getPageCallback($page))) { if ($page === '/publish/') { $sections = SectionManager::fetch(null, 'ASC', 'sortorder'); $section = current($sections); redirect(SYMPHONY_URL . '/publish/' . $section->get('handle')); } else { $this->errorPageNotFound(); } } include_once $this->_callback['driver_location']; $this->Page = new $this->_callback['classname'](); if (!$is_logged_in && $this->_callback['driver'] != 'login') { if (is_callable(array($this->Page, 'handleFailedAuthorisation'))) { $this->Page->handleFailedAuthorisation(); } else { include_once CONTENT . '/content.login.php'; $this->Page = new contentLogin(); $this->Page->build(array('redirect' => $page)); } } else { if (!is_array($this->_callback['context'])) { $this->_callback['context'] = array(); } // Do any extensions need updating? $extensions = Symphony::ExtensionManager()->listInstalledHandles(); if (is_array($extensions) && !empty($extensions) && $this->__canAccessAlerts()) { foreach ($extensions as $name) { $about = Symphony::ExtensionManager()->about($name); if (array_key_exists('status', $about) && in_array(EXTENSION_REQUIRES_UPDATE, $about['status'])) { $this->Page->pageAlert(__('An extension requires updating.') . ' <a href="' . SYMPHONY_URL . '/system/extensions/">' . __('View extensions') . '</a>'); break; } } } // Check for update Alert // Scan install/migrations directory for the most recent updater and compare if ($this->isInstallerAvailable() && $this->__canAccessAlerts()) { try { // The updater contains a version higher than the current Symphony version. if ($this->isUpgradeAvailable()) { $message = __('An update has been found in your installation to upgrade Symphony to %s.', array($this->getMigrationVersion())) . ' <a href="' . URL . '/install/">' . __('View update.') . '</a>'; // The updater contains a version lower than the current Symphony version. // The updater is the same version as the current Symphony install. } else { $message = __('Your Symphony installation is up to date, but the installer was still detected. For security reasons, it should be removed.') . ' <a href="' . URL . '/install/?action=remove">' . __('Remove installer?') . '</a>'; } // Can't detect update Symphony version } catch (Exception $e) { $message = __('An update script has been found in your installation.') . ' <a href="' . URL . '/install/">' . __('View update.') . '</a>'; } $this->Page->pageAlert($message, Alert::NOTICE); } $this->Page->build($this->_callback['context']); } return $this->Page; }
/** * Given the URL path of a Symphony backend page, this function will * attempt to resolve the URL to a Symphony content page in the backend * or a page provided by an extension. This function checks to ensure a user * is logged in, otherwise it will direct them to the login page * * @param string $page * The URL path after the root of the Symphony installation, including a starting * slash, such as '/login/' * @return HTMLPage */ private function __buildPage($page) { $is_logged_in = $this->isLoggedIn(); if (empty($page) || is_null($page)) { if (!$is_logged_in) { $page = "/login"; } else { // Will redirect an Author to their default area of the Backend // Integers are indicative of section's, text is treated as the path // to the page after `SYMPHONY_URL` $default_area = null; if (is_numeric($this->Author->get('default_area'))) { $section_handle = Symphony::Database()->fetchVar('handle', 0, "SELECT `handle` FROM `tbl_sections` WHERE `id` = '" . $this->Author->get('default_area') . "' LIMIT 1"); if (!$section_handle) { $section_handle = Symphony::Database()->fetchVar('handle', 0, "SELECT `handle` FROM `tbl_sections` ORDER BY `sortorder` LIMIT 1"); } if (!is_null($section_handle)) { $default_area = "/publish/{$section_handle}/"; } } else { if (!is_null($this->Author->get('default_area'))) { $default_area = preg_replace('/^' . preg_quote(SYMPHONY_URL, '/') . '/i', '', $this->Author->get('default_area')); } } if (is_null($default_area)) { if ($this->Author->isDeveloper()) { $section_handle = Symphony::Database()->fetchVar('handle', 0, "SELECT `handle` FROM `tbl_sections` ORDER BY `sortorder` LIMIT 1"); if (!is_null($section_handle)) { // If there are sections created, redirect to the first one (sortorder) redirect(SYMPHONY_URL . "/publish/{$section_handle}/"); } else { // If there are no sections created, default to the Section page redirect(SYMPHONY_URL . '/blueprints/sections/'); } } else { redirect(SYMPHONY_URL . "/system/authors/edit/" . $this->Author->get('id') . "/"); } } else { redirect(SYMPHONY_URL . $default_area); } } } if (!($this->_callback = $this->getPageCallback($page))) { $this->errorPageNotFound(); } include_once (isset($this->_callback['driverlocation']) ? $this->_callback['driverlocation'] : CONTENT) . '/content.' . $this->_callback['driver'] . '.php'; $this->Page = new $this->_callback['classname']($this); if (!$is_logged_in && $this->_callback['driver'] != 'login') { if (is_callable(array($this->Page, 'handleFailedAuthorisation'))) { $this->Page->handleFailedAuthorisation(); } else { include_once CONTENT . '/content.login.php'; $this->Page = new contentLogin($this); $this->Page->build(); } } else { if (!is_array($this->_callback['context'])) { $this->_callback['context'] = array(); } // Check for update Alert if (file_exists(DOCROOT . '/update.php') && $this->__canAccessAlerts()) { if (file_exists(DOCROOT . '/README.markdown') && is_readable(DOCROOT . '/README.markdown')) { $readme = file(DOCROOT . '/README.markdown', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); $readme = trim(str_replace('- Version:', '', $readme[1])); $current_version = Symphony::Configuration()->get('version', 'symphony'); // The updater contains a version higher than the current Symphony version. if (version_compare($current_version, $readme, '<')) { $message = __('Run the updater to update Symphony to %s. <a href="%s">View Update</a>', array($readme, URL . "/update.php")); } else { $message = __('Your Symphony installation is up to date, but an updater script was still detected. For security reasons, it should be removed. <a href="%s/update.php?action=remove">Remove Update Script</a>', array(URL)); } } else { $message = __('An updater script has been found in your installation. <a href="%s">View Update</a>', array(URL . "/update.php")); } $this->Page->pageAlert($message, Alert::NOTICE); } // Do any extensions need updating? $extensions = Symphony::ExtensionManager()->listInstalledHandles(); if (is_array($extensions) && !empty($extensions) && $this->__canAccessAlerts()) { foreach ($extensions as $name) { $about = Symphony::ExtensionManager()->about($name); if ($about['status'] == EXTENSION_REQUIRES_UPDATE) { $this->Page->pageAlert(__('An extension requires updating. <a href="%s">View Extensions</a>', array(SYMPHONY_URL . '/system/extensions/'))); break; } } } $this->Page->build($this->_callback['context']); } return $this->Page; }