function test_cacheMergedMenu() { Mock::generatePartial('OX_Plugin_ComponentGroupManager', $oMockGroupManager = 'OX_Plugin_ComponentGroupManager' . rand(), array('mergeMenu')); $oGroupManager = new $oMockGroupManager($this); $oGroupManager->setReturnValue('mergeMenu', true); Mock::generatePartial('OX_Extension_admin', $oMockExtensionManager = 'OX_Extension_admin' . rand(), array('_getMenuObjectForAccount', '_getGroupManagerObject')); $oMockExtensionManager = new $oMockExtensionManager($this); $oMenu = new OA_Admin_Menu('TEST'); $oMenu->add(new OA_Admin_Menu_Section("test", 'test root', "test-root.php", false, "")); $oMockExtensionManager->setReturnValue('_getMenuObjectForAccount', $oMenu); $oMockExtensionManager->setReturnValue('_getGroupManagerObject', $oGroupManager); OA_Admin_Menu::_clearCache('TEST'); $this->assertTrue($oMockExtensionManager->_cacheMergedMenu('TEST')); $oMenuCache = $oMenu->_loadFromCache('TEST'); $this->assertTrue(is_a($oMenuCache, 'OA_Admin_Menu')); $this->assertEqual(count($oMenuCache->aAllSections), 1); $this->assertTrue(array_key_exists('test', $oMenuCache->aAllSections)); OA_Admin_Menu::_clearCache('TEST'); TestEnv::restoreConfig(); }
// Dashboard Settings $aElements += array('authentication_type' => array('authentication' => 'type')); // Create a new settings object, and save the settings! $oSettings = new OA_Admin_Settings(); $result = $oSettings->processSettingsFromForm($aElements); if ($result) { // Delete all the sessions if the UI is disabled // to force all the users to be logged out if (!$GLOBALS['ui_enabled']) { $doSession = OA_Dal::factoryDO('session'); $doSession->whereAdd('1=1'); $doSession->delete(DB_DATAOBJECT_WHEREADD_ONLY); } // Rebuild the menu because the Enable Dashboard setting could been changed OA_Admin_Menu::_clearCache(OA_ACCOUNT_ADMIN); OA_Admin_Menu::_clearCache(OA_ACCOUNT_MANAGER); // Queue confirmation message $setPref = $oOptions->getSettingsPreferences($prefSection); $title = $setPref[$prefSection]['name']; $translation = new OX_Translation(); $translated_message = $translation->translate($GLOBALS['strXSettingsHaveBeenUpdated'], array(htmlspecialchars($title))); OA_Admin_UI::queueMessage($translated_message, 'local', 'confirm', 0); // The settings configuration file was written correctly, OX_Admin_Redirect::redirect(basename($_SERVER['SCRIPT_NAME'])); } // Could not write the settings configuration file, store this // error message and continue $aErrormessage[0][] = $strUnableToWriteConfig; } // Set the correct section of the settings pages and display the drop-down menu $setPref = $oOptions->getSettingsPreferences($prefSection);
/** * Process input from user and creates/upgrades DB etc.... * * @param OA_Admin_UI_Component_Form $oForm * @param OX_Admin_UI_Install_Wizard $oWizard */ protected function processDatabaseAction($oForm, $oWizard) { $oUpgrader = $this->getUpgrader(); $upgraderSuccess = false; $aDbConfig = $oForm->populateDbConfig(); if ($oUpgrader->canUpgradeOrInstall()) { $installStatus = $oUpgrader->existing_installation_status; define('DISABLE_ALL_EMAILS', 1); OA_Permission::switchToSystemProcessUser('Installer'); if ($installStatus == OA_STATUS_NOT_INSTALLED) { if ($oUpgrader->install($aDbConfig)) { $message = $GLOBALS['strDBInstallSuccess']; $upgraderSuccess = true; } } else { if ($oUpgrader->upgrade($oUpgrader->package_file)) { // Timezone support - hack if ($oUpgrader->versionInitialSchema['tables_core'] < 538 && empty($aDbConfig['noTzAlert'])) { OA_Dal_ApplicationVariables::set('utc_update', OA::getNowUTC()); } // Clear the menu cache to built a new one with the new settings OA_Admin_Menu::_clearCache(OA_ACCOUNT_ADMIN); OA_Admin_Menu::_clearCache(OA_ACCOUNT_MANAGER); OA_Admin_Menu::_clearCache(OA_ACCOUNT_ADVERTISER); OA_Admin_Menu::_clearCache(OA_ACCOUNT_TRAFFICKER); OA_Admin_Menu::singleton(); $message = $GLOBALS['strDBUpgradeSuccess']; $upgraderSuccess = true; } } OA_Permission::switchToSystemProcessUser(); //get back to normal user previously logged in } else { if ($oUpgrader->existing_installation_status == OA_STATUS_CURRENT_VERSION) { $upgraderSuccess = true; //rare but can occur if DB has been installed and user revisits the screen } } $dbSuccess = $upgraderSuccess && !$oUpgrader->oLogger->errorExists; if ($dbSuccess) { //show success status OA_Admin_UI::getInstance()->queueMessage($message, 'global', 'info'); } else { //sth went wrong, display messages from upgrader $aMessages = OX_Admin_UI_Install_InstallUtils::getMessagesWithType($oUpgrader->getMessages()); $this->setModelProperty('aMessages', $aMessages); } return $dbSuccess; }
function test_checkMenus() { OA_Admin_Menu::_clearCache(OA_ACCOUNT_ADMIN); $oPluginManager = new OX_Plugin_ComponentGroupManager(); $aMenus[OA_ACCOUNT_ADMIN] = array(0 => array('insertafter' => "999")); $this->assertFalse($oPluginManager->_checkMenus('testPlugin', $aMenus)); $aMenus[OA_ACCOUNT_ADMIN] = array(0 => array('insertbefore' => "999")); $this->assertFalse($oPluginManager->_checkMenus('testPlugin', $aMenus)); $aMenus[OA_ACCOUNT_ADMIN] = array(0 => array('addto' => "999")); $this->assertFalse($oPluginManager->_checkMenus('testPlugin', $aMenus)); $aMenus[OA_ACCOUNT_ADMIN] = array(0 => array('add' => "test-plugin-root", 'link' => "plugins/testPlugin/testPlugin.php", 'data' => 'Test Plugin'), 1 => array('addto' => "test-plugin-root", 'index' => "test-plugin-1", 'link' => "plugins/testPlugin/testPlugin-page.php?action=1", 'data' => 'Test Menu 1'), 2 => array('insertafter' => "test-plugin-1", 'index' => "test-plugin-3", 'link' => "plugins/testPlugin/testPlugin.php?action=3", 'data' => 'Test Menu 3'), 3 => array('insertbefore' => "test-plugin-3", 'index' => "test-plugin-2", 'link' => "plugins/testPlugin/testPlugin.php?action=2", 'data' => 'Test Menu 2')); $oMenu = $oPluginManager->_checkMenus('testPlugin', $aMenus); $this->assertIsA($oMenu, 'OA_Admin_Menu'); $oSection = $oMenu->get('test-plugin-root', false); $this->assertIsA($oSection, 'OA_Admin_Menu_Section'); $this->assertEqual(count($oSection->aSections), 3); $this->assertEqual($oSection->aSections[0]->id, 'test-plugin-1'); $this->assertEqual($oSection->aSections[1]->id, 'test-plugin-2'); $this->assertEqual($oSection->aSections[2]->id, 'test-plugin-3'); $oSection1 = $oMenu->get('test-plugin-1', false); $this->assertIsA($oSection1, 'OA_Admin_Menu_Section'); $this->assertEqual($oSection->aSections[0]->id, $oSection1->id); $oSection2 = $oMenu->get('test-plugin-2', false); $this->assertIsA($oSection2, 'OA_Admin_Menu_Section'); $this->assertEqual($oSection->aSections[1]->id, $oSection2->id); $oSection3 = $oMenu->get('test-plugin-3', false); $this->assertIsA($oSection3, 'OA_Admin_Menu_Section'); $this->assertEqual($oSection->aSections[2]->id, $oSection3->id); $this->assertTrue($oMenu->_saveToCache(OA_ACCOUNT_ADMIN)); $oMenu = $oMenu->_loadFromCache(OA_ACCOUNT_ADMIN); $this->assertIsA($oMenu, 'OA_Admin_Menu'); $oSection = $oMenu->get('test-plugin-root', false); $this->assertIsA($oSection, 'OA_Admin_Menu_Section'); $this->assertEqual(count($oSection->aSections), 3); $this->assertEqual($oSection->aSections[0]->id, 'test-plugin-1'); $this->assertEqual($oSection->aSections[1]->id, 'test-plugin-2'); $this->assertEqual($oSection->aSections[2]->id, 'test-plugin-3'); $oSection1 = $oMenu->get('test-plugin-1', false); $this->assertIsA($oSection1, 'OA_Admin_Menu_Section'); $this->assertEqual($oSection->aSections[0]->id, $oSection1->id); $oSection2 = $oMenu->get('test-plugin-2', false); $this->assertIsA($oSection2, 'OA_Admin_Menu_Section'); $this->assertEqual($oSection->aSections[1]->id, $oSection2->id); $oSection3 = $oMenu->get('test-plugin-3', false); $this->assertIsA($oSection3, 'OA_Admin_Menu_Section'); $this->assertEqual($oSection->aSections[2]->id, $oSection3->id); }
} else { if (empty($_COOKIE['oat']) || $_COOKIE['oat'] != OA_UPGRADE_UPGRADE) { // Hey, what's going on, we shouldn't be here, go back to login! $action = OA_UPGRADE_LOGIN; } elseif ($oUpgrader->upgrade($oUpgrader->package_file)) { $message = $strUpgradeComplete; $action = OA_UPGRADE_UPGRADE; // Timezone support - hack if ($oUpgrader->versionInitialSchema['tables_core'] < 538 && empty($_POST['noTzAlert'])) { OA_Dal_ApplicationVariables::set('utc_update', OA::getNowUTC()); } // Clear the menu cache to built a new one with the new settings OA_Admin_Menu::_clearCache(OA_ACCOUNT_ADMIN); OA_Admin_Menu::_clearCache(OA_ACCOUNT_MANAGER); OA_Admin_Menu::_clearCache(OA_ACCOUNT_ADVERTISER); OA_Admin_Menu::_clearCache(OA_ACCOUNT_TRAFFICKER); OA_Admin_Menu::singleton(); } } } if ($action != OA_UPGRADE_UPGRADE && $action != OA_UPGRADE_INSTALL && $action != OA_UPGRADE_LOGIN || $oUpgrader->oLogger->errorExists) { // if they're being redirected from an install, they will have DB info in POST, otherwise they will have DBinfo in CONF if ($_POST['aConfig']) { $aDatabase = $_POST['aConfig']; } else { $aDatabase['database'] = $GLOBALS['_MAX']['CONF']['database']; $aDatabase['table'] = $GLOBALS['_MAX']['CONF']['table']; } $displayError = true; $action = OA_UPGRADE_DBSETUP; }