function UpdateCheck(&$Context) { $this->Name = 'UpdateCheck'; $this->ValidActions = array('UpdateCheck', 'ProcessUpdateCheck', 'ProcessUpdateReminder'); $this->Constructor($Context); if (!$this->Context->Session->User->Permission('PERMISSION_CHECK_FOR_UPDATES')) { $this->IsPostBack = 0; } if ($this->IsPostBack) { $this->Context->PageTitle = $this->Context->GetDefinition('UpdatesAndReminders'); $this->ReminderSelect = $this->Context->ObjectFactory->NewObject($this->Context, 'Select'); $this->ReminderSelect->Name = 'ReminderRange'; $this->ReminderSelect->AddOption('', $this->Context->GetDefinition('Never')); $this->ReminderSelect->AddOption('Weekly', $this->Context->GetDefinition('Weekly')); $this->ReminderSelect->AddOption('Monthly', $this->Context->GetDefinition('Monthly')); $this->ReminderSelect->AddOption('Quarterly', $this->Context->GetDefinition('Quarterly')); $this->ReminderSelect->SelectedValue = $this->Context->Configuration['UPDATE_REMINDER']; $SettingsFile = $this->Context->Configuration['APPLICATION_PATH'] . 'conf/settings.php'; } if ($this->IsPostBack && $this->PostBackAction == 'ProcessUpdateCheck') { // Load the extensions $this->Extensions = DefineExtensions($this->Context, true); // Add an onload event to the document body $this->Context->BodyAttributes .= " onload=\"UpdateCheck('" . $this->Context->Configuration['WEB_ROOT'] . "ajax/updatecheck.php', 'Core', '" . $this->Context->Session->GetCsrfValidationKey() . "');\""; // Report that the postback is validated $this->PostBackValidated = 1; } elseif ($this->IsPostBack && $this->PostBackAction == 'ProcessUpdateReminder' && $this->IsValidFormPostBack()) { $ReminderRange = ForceIncomingString('ReminderRange', ''); if (!in_array($ReminderRange, array('Weekly', 'Monthly', 'Quarterly'))) { $ReminderRange = ''; } // Set the Reminder configuration option $ConfigurationManager = $this->Context->ObjectFactory->NewContextObject($this->Context, "ConfigurationManager"); $ConfigurationManager->DefineSetting('UPDATE_REMINDER', $ReminderRange, 1); if ($ConfigurationManager->SaveSettingsToFile($SettingsFile)) { // If everything was successful, Redirect back with saved changes message if ($this->Context->WarningCollector->Iif()) { $Url = GetUrl($this->Context->Configuration, $this->Context->SelfUrl, "", "", "", "", "PostBackAction=UpdateCheck&Saved=1"); Redirect($Url); } } } $this->CallDelegate('Constructor'); }
$ConfigurationManager->SaveSettingsToFile($SettingsFile); // Spit out the core message if ($VersionStatus == "GOOD") { echo 'First|' . $Context->GetDefinition('ApplicationStatusGood'); } else { $aVersionStatus = explode("|", $VersionStatus); if (count($aVersionStatus) == 2) { echo 'First|[OLD]' . str_replace(array('\\1', '\\2'), array($aVersionStatus[0], $aVersionStatus[1]), $Context->GetDefinition('NewVersionAvailable')); } else { // There was some kind of error echo 'First|[ERROR]' . $VersionStatus; } } } else { // Load all extensions for version information $Extensions = DefineExtensions($Context); if (!is_array($Extensions)) { echo $RequestName . '|[ERROR]' . $Context->WarningCollector->GetPlainMessages(); } elseif (count($Extensions) > 0) { // All of the extensions were loaded successfully. // Ping the Lussumo server with the next extension $CheckExtension = ''; while (list($ExtensionKey, $Extension) = each($Extensions)) { if ($RequestName == 'First') { $CheckExtension = $ExtensionKey; $RequestName = ''; break; } else { if ($RequestName == $ExtensionKey) { $RequestName = '[NEXT]'; } else {
/** * Initializes form data and saves submitted settings. * * Unlike most controls this Render() method doesn't actually output * anything because it is called from the 'Page_Init' event. By calling * extension-specific Init_ and Process_ functions as delegates from this * method, we avoid the problem of extensions being included in the * "wrong order" in Vanilla's conf/extensions.php. */ function Render() { global $Page, $Panel; // Parse any SetList.ini files for enabled extensions. $extensions = DefineExtensions($this->Context); foreach ($extensions as $key => $ext) { $iniFile = $this->Context->Configuration['EXTENSIONS_PATH'] . substr($ext->FileName, 0, -11) . 'SetList.ini'; if ($ext->Enabled) { $this->parseIniFile($key, $iniFile); } } // Other delegates might have been added after this control was // created. Grab them all now. $this->Delegates = array(); $this->GetDelegatesFromContext(); // Extensions may add to this delegate to initialize settings. foreach ($this->forms as $key => $formData) { $this->DelegateParameters['Form'] =& $this->forms[$key]; $this->CallDelegate('Init_' . $key); } // Add the settings form links to the side panel. if (!empty($this->forms)) { $extensionOptions = $this->Context->GetDefinition('ExtensionOptions'); $Panel->AddList($extensionOptions, 20); foreach ($this->forms as $key => $val) { // Check permission if (!$val['form']['permission'] || $this->Context->Session->User->Permission($val['form']['permission'])) { $Panel->AddListItem($extensionOptions, $extensions[$key]->Name, GetUrl($this->Context->Configuration, 'settings.php', '', '', '', '', 'PostBackAction=' . $key)); } else { // Permission failed, we can dump the form details unset($this->forms[$key]); } } } // Check the PostBackAction to see if a settings form is needed. $key = ForceIncomingString('PostBackAction', ''); if (substr($key, 0, 7) == 'Process') { $key = substr($key, 7); } if (array_key_exists($key, $this->forms)) { // Create the form. $this->Context->Configuration['SetList.FormData'] =& $this->forms[$key]; $setListForm = $this->Context->ObjectFactory->CreateControl($this->Context, 'SetListForm', $key, $extensions[$key]->Name, 'SetList.FormData'); unset($this->Context->Configuration['SetList.FormData']); if ($setListForm->PostBackValidated) { // Extensions may add to this delegate to process settings changes. $this->DelegateParameters['Form'] =& $this->forms[$key]; $this->CallDelegate('Process_' . $key); // Save configuration settings. if ($this->Context->WarningCollector->Iif()) { $this->_commitSettings($key, $this->Context->Configuration['APPLICATION_PATH'] . 'conf/settings.php'); } // Flag the form if there were warnings. if (!$this->Context->WarningCollector->Iif()) { $setListForm->PostBackValidated = 0; } } // Add the form to the page. $Page->AddRenderControl($setListForm, $this->Context->Configuration['CONTROL_POSITION_BODY_ITEM'] + 1); } }
function ExtensionForm(&$Context) { $this->Name = "ExtensionForm"; $this->ValidActions = array("Extensions", "ProcessExtension"); $this->Constructor($Context); if (!$this->Context->Session->User->Permission("PERMISSION_MANAGE_EXTENSIONS")) { $this->IsPostBack = 0; } elseif ($this->IsPostBack) { $this->Context->PageTitle = $this->Context->GetDefinition('ManageExtensions'); $this->Extensions = DefineExtensions($this->Context); } $this->CallDelegate("Constructor"); }
// Also record that the check occurred $SettingsFile = $Context->Configuration['APPLICATION_PATH'] . 'conf/settings.php'; $ConfigurationManager = $Context->ObjectFactory->NewContextObject($Context, "ConfigurationManager"); $ConfigurationManager->DefineSetting('LAST_UPDATE', mktime(), 1); $ConfigurationManager->SaveSettingsToFile($SettingsFile); // Spit out the core message if ($CurrentVersion <= APPLICATION_VERSION) { echo 'First|' . $Context->GetDefinition('ApplicationStatusGood'); } else { if ($CurrentVersion > APPLICATION_VERSION) { echo 'First|[OLD]' . str_replace(array('\\1', '\\2'), array($CurrentVersion, $Context->Configuration['UPDATE_URL'] . '../'), $Context->GetDefinition('NewVersionAvailable')); } } } else { // Load all extensions for version information $Extensions = DefineExtensions($Context, true); if (!is_array($Extensions)) { echo $SafeRequestName . '|[ERROR]' . $Context->WarningCollector->GetPlainMessages(); } elseif (count($Extensions) > 0) { // All of the extensions were loaded successfully. // Ping the Lussumo server with the next extension $CheckExtension = ''; while (list($ExtensionKey, $Extension) = each($Extensions)) { if ($RequestName == 'First') { $CheckExtension = $ExtensionKey; $RequestName = ''; break; } else { if ($RequestName == $ExtensionKey) { $RequestName = '[NEXT]'; } else {