예제 #1
0
 /**
  * Returns the instance of menu. Subsequent calls return the same object.
  *
  * @return OA_Admin_Menu
  */
 function &singleton()
 {
     $accountType = OA_Permission::getAccountType();
     if (isset($GLOBALS['_MAX']['MENU_OBJECT'][$accountType])) {
         $oMenu =& $GLOBALS['_MAX']['MENU_OBJECT'][$accountType];
     } elseif ($GLOBALS['_MAX']['CONF']['debug']['production'] != 0 && ($oMenu = OA_Admin_Menu::_loadFromCache($accountType))) {
         $GLOBALS['_MAX']['MENU_OBJECT'][$accountType] =& $oMenu;
     } else {
         $oMenu = new OA_Admin_Menu();
         if (empty($oMenu->aAllSections)) {
             include_once MAX_PATH . '/lib/OA/Admin/Menu/config.php';
             $oMenu = _buildNavigation(OA_Permission::getAccountType());
         }
         require_once LIB_PATH . '/Plugin/ComponentGroupManager.php';
         $oPluginManager = new OX_Plugin_ComponentGroupManager();
         $oPluginManager->mergeMenu($oMenu, $accountType);
         $GLOBALS['_MAX']['MENU_OBJECT'][$accountType] =& $oMenu;
         $oMenu->_saveToCache($accountType);
     }
     // Filter against user-account-preferences...
     return $oMenu;
 }
 function test_mergeMenu()
 {
     $oPluginManager = new OX_Plugin_ComponentGroupManager();
     $oPluginManager->pathPackages = $this->testpathPackages;
     $oMenu = new OA_Admin_Menu();
     $GLOBALS['_MAX']['CONF']['pluginGroupComponents'] = array('testPlugin' => 1);
     $oPluginManager->mergeMenu($oMenu, OA_ACCOUNT_ADMIN);
     $this->assertEqual(count($oMenu->aAllSections), 3);
     $this->assertTrue(array_key_exists('test-menu-admin', $oMenu->aAllSections));
     $this->assertTrue(array_key_exists('test-menu-admin-1', $oMenu->aAllSections));
     $this->assertTrue(array_key_exists('test-menu-admin-2', $oMenu->aAllSections));
     $oPluginManager->mergeMenu($oMenu, OA_ACCOUNT_MANAGER);
     $this->assertEqual(count($oMenu->aAllSections), 5);
     $this->assertTrue(array_key_exists('test-menu-mgr', $oMenu->aAllSections));
     $this->assertTrue(array_key_exists('test-menu-mgr-1', $oMenu->aAllSections));
     TestEnv::restoreConfig();
 }