/** * Constructor * Work out which addon we're running so we can show it in the breadcrum trail amongst other things * * @return Void */ public function __construct() { if (isset($_REQUEST['addon'])) { $addon_folder = str_replace("addon_", "", $_REQUEST['addon']); if (!GetAddonsModule($this->_addon, strtolower($addon_folder))) { $this->_BadAddon(sprintf(GetLang('InvalidAddon'), $addon_folder)); } } else { // No addon specified $this->_BadAddon(GetLang('NoAddonSpecified')); } }
private function SaveUpdatedAddonSettings() { // Delete existing module configuration $GLOBALS['ISC_CLASS_DB']->DeleteQuery('module_vars', "WHERE modulename LIKE 'addon\\_%'"); $enabledStack = array(); $messages = array(); // Can the selected addons be enabled? if (!isset($_POST['addonpackages']) || !is_array($_POST['addonpackages'])) { $_POST['addonpackages'] = array(); } foreach ($_POST['addonpackages'] as $package) { $id = explode('_', $package, 2); GetAddonsModule($module, $id[1]); if (is_object($module)) { // Is this addon supported on this server? if ($module->IsSupported() == false) { $errors = $module->GetErrors(); foreach ($errors as $error) { FlashMessage($error, MSG_ERROR); } continue; } // Otherwise, this addon is fine, so add it to the stack of enabled $enabledStack[] = 'addon_' . $id[1]; } } $addonpackages = implode(",", $enabledStack); // Push everything to globals and save $GLOBALS['ISC_NEW_CFG']['AddonModules'] = $addonpackages; $messages = array(); if ($this->CommitSettings($messages)) { // Now get all addon variables (they are in an array from $_POST) foreach ($enabledStack as $module_id) { $vars = array(); if (isset($_POST[$module_id])) { $vars = $_POST[$module_id]; } GetModuleById('addon', $module, $module_id); $module->SaveModuleSettings($vars); } $tab = 0; if (isset($_POST['currentTab'])) { $tab = (int) $_POST['currentTab']; } if ($GLOBALS['ISC_CLASS_DB']->Error() == "") { // Log this action $GLOBALS['ISC_CLASS_LOG']->LogAdminAction(); // Redirect them so that any new modules appear in the menu straight away $success = true; $message = GetLang('AddonSettingsSavedSuccessfully'); } else { $success = false; $message = GetLang('AddonSettingsNotSaved'); } } else { $success = false; $message = GetLang('AddonSettingsNotSaved'); } if ($success == true) { $msgType = MSG_SUCCESS; } else { $msgType = MSG_ERROR; } // Rebuild the cache of the addon module variables $GLOBALS['ISC_CLASS_DATA_STORE']->UpdateAddonModuleVars(); FlashMessage($message, $msgType, 'index.php?ToDo=viewAddonSettings'); }