<?php

/************************************************************************/
/* DOCEBO LMS - Learning Managment System                               */
/* ============================================                         */
/*                                                                      */
/* Copyright (c) 2004                                                   */
/* http://www.docebo.com                                                */
/*                                                                      */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License.       */
/************************************************************************/

if(1 == 2) {

	$lang = DoceboLanguage::createInstance('menu_over');

	$GLOBALS['page']->add('<li><a href="#main_menu">'.$lang->def('_BLIND_MAINMENU_OPTION').'</a></li>', 'blind_navigation');

	$GLOBALS['page']->add(
		'<div id="main_menu" class="info_strip'.( isset($_SESSION['idCourse']) ? '' : ' info_strip_bottom_border' ).'">'

		.'<a class="general_voice" href="index.php?modname=course&amp;op=unregistercourse" '
		.( $GLOBALS['framework']['use_accesskey'] == 'on' ?
			'accesskey="c">'.$lang->def('_MENUCOURSE').' <em class="shortcut">[c]</em>' :
			'>'.$lang->def('_MENUCOURSE') ).'</a>'
	, 'menu_over');
	if(isset($_SESSION['idCourse'])) {

		$GLOBALS['page']->add('<h1 class="course_name">'.$GLOBALS['course_descriptor']->getValue('name').'</h1>', 'menu_over');
	}
	$GLOBALS['page']->add(
		'<a class="logout_voice" href="index.php?modname=login&amp;op=logout" '
		.( $GLOBALS['framework']['use_accesskey'] == 'on' ?
			'accesskey="l">'.$lang->def('_LOGOUT').' <em class="shortcut">[L]</em>' :
			'>'.$lang->def('_LOGOUT') )
		.'</a>'

		.'<div class="no_float"></div>'
		.'</div>'."\n", 'menu_over');

	//second line
	if(isset($_SESSION['idCourse'])) {

		$query_under = "
		SELECT mu.idMain, m.module_name, m.token_associated
		FROM ".$GLOBALS['prefix_crm']."_publicmenu_under AS mu JOIN ".$GLOBALS['prefix_crm']."_module AS m
		WHERE mu.idModule = m.idModule AND mu.idCourse = '".$_SESSION ['idCourse']."'";
		$re_under = mysql_query($query_under);
		echo doDebug($query_under);

		$main_perm = array();
		while(list($id_main, $module_name, $token) = mysql_fetch_row($re_under)) {

			if(!isset($main_perm[$id_main])) $main_perm[$id_main] = checkPerm($token, true, $module_name);
			else $main_perm[$id_main] |= checkPerm($token, true, $module_name);
		}
		$query = "
		SELECT idMain, name, image
		FROM ".$GLOBALS['prefix_crm']."_public_menu
		WHERE ".( isset($_SESSION ['idCourse']) ? "idCourse = '".$_SESSION ['idCourse']."'" : "idCourse = '0'" )."
		ORDER BY sequence";
		$reMain = mysql_query($query);

		$GLOBALS['page']->add('<li><a href="#menu_course">'.$lang->def('_BLIND_COURSE_MENU').'</a></li>', 'blind_navigation');

		$GLOBALS['page']->add(
			'<div id="menu_course" class="menu_strip">'."\n"
			.'<ul class="menu_list_strip">', 'menu_over' );
			$access_key = 0;
			while(list($idMain, $name, $image) = mysql_fetch_row($reMain)) {

				if(isset($main_perm[$idMain]) && ($main_perm[$idMain] == true)) {

					if($idMain == $_SESSION['current_main_menu']) {

						$GLOBALS['current_main_info']['name']  = ( $lang->isDef($name) ? $lang->def($name) : $name );
						$GLOBALS['current_main_info']['image'] = $image;
					}
					if($idMain == $_SESSION['current_main_menu']) {

						$GLOBALS['page']->add( '<li>'
							.'<em class="bar select">'
								.( $lang->isDef($name) ? $lang->def($name) : $name )
							.'</em></li>', 'menu_over');
						$access_key++;
					} else {

						$GLOBALS['page']->add( '<li>'
							.'<a class="bar'.( $idMain == $_SESSION['current_main_menu'] ? ' select' : '' )
							.'" href="index.php?op=selectMain&amp;idMain='.$idMain.'"'
							.( $GLOBALS['framework']['use_accesskey'] == 'on' && $access_key < 10 ? ' accesskey="'.$access_key.'"' : '' ).'>'
							.( $lang->isDef($name) ? $lang->def($name) : $name )
							.( $GLOBALS['framework']['use_accesskey'] == 'on' && $access_key < 10 ?
								' <em class="shortcut">['.$access_key++.']</em>' :
								'' )
							.'</a></li>', 'menu_over');
					}
				}
			}
		$GLOBALS['page']->add( '</ul>'
			.'</div>', 'menu_over');
	}
}









if(!$GLOBALS['current_user']->isAnonymous()) {

	$lang = DoceboLanguage::createInstance('menu_over');

	$GLOBALS['page']->add('<li><a href="#main_menu">'.$lang->def('_BLIND_MAINMENU_OPTION').'</a></li>', 'blind_navigation');

	$GLOBALS['page']->add('<div id="main_menu" class="info_strip">', 'menu_over');

	$GLOBALS['page']->add(
		'<a class="logout_voice" href="index.php?modname=login&amp;op=logout" '
		.( $GLOBALS['framework']['use_accesskey'] == 'on' ?
			'accesskey="l">'.$lang->def('_LOGOUT').' <em class="shortcut">[L]</em>' :
			'>'.$lang->def('_LOGOUT') )
		.'</a>'

		.'<div class="no_float"></div>'
		.'</div>'."\n", 'menu_over');
}

?>