function _menuFile() { if (Session::getValue('USERINFO_USER_ID') != null) { $file_name = Session::getValue('menufile'); if (empty($file_name)) { $file_name = 'menu_item_' . Session::getValue('USERINFO_USER_ID') . '_' . date("YmdHis") . '.js'; } $menuFile = Util::formatPath(MIGUELBASE_CACHE_DIR . '/' . $file_name); if (file_exists($menuFile) && time() - filemtime($menuFile) < MIGUELBASE_CACHE_TIME) { File::Touch($menuFile); } else { //Si existe, se borra if (file_exists($menuFile)) { File::Delete($menuFile); } //Se crea, segĂșn el perfil de usuario switch (Session::getValue('USERINFO_PROFILE_ID')) { case 1: $strFile = 'menu_admin'; break; case 2: case 3: $strFile = 'menu_profesor'; break; case 4: $strFile = 'menu_alumno'; break; case 5: $strFile = 'menu_secretaria'; break; default: $strFile = 'menu'; break; } include_once Util::app_Path("common/control/classes/miguel_menubar.class.php"); $menubar = new miguel_MenuBar($strFile . '.xml'); $str_content = 'var MENU_ITEMS = ['; for ($i = 0; $i < $menubar->countMenu(); $i++) { $str_content .= $menubar->getMenuCode($i, $superior); } $str_content .= '];'; if (file_exists($menuFile)) { File::Delete($menuFile); } File::Write($menuFile, $str_content); } $this->setViewVariable('menufile', MIGUEL_URLDIR . 'var/cache/' . "{$file_name}"); Session::setValue('menufile', $file_name); } }