<?php
/**
* @package eFront
* @version 1.0
*/

//General initialization and parameters
session_cache_limiter('none');
session_start();

$path = "../libraries/";

/** Configuration file.*/
include_once $path."configuration.php";

//eF_printHeader(); 
//error_reporting(E_ALL);
//echo "<pre>";print_r($_POST);print_r($_GET);

if (!eF_checkUser($_SESSION['s_login'], $_SESSION['s_password'])) {                           //Must be a valid uesr to access this page
    header("location:index.php");
    exit;
}
    
if (!isset($_GET['content_ID'])) {                                  //The user asked for all lesson content
    $periods = eF_getTableData("periods", "count(*)", "lessons_ID=".$_SESSION['s_lessons_ID']); 
    
    if (isset($_GET['current']) && $periods[0]['count(*)'] != 0) {
        $tree = eF_getContentTree($nouse, $_SESSION['s_lessons_ID'], 0, false, true, true);
    } else {
        $tree = eF_getContentTree($nouse, $_SESSION['s_lessons_ID'], 0, false, true);
    }

    if (sizeof($tree) == 0) {
        $message      = _NOCONTENTFOUNDTOPRINT;
        $message_type = 'failure';
    } else {
        for ($i = 0; $i < sizeof($tree); $i++) {
            if ($tree[$i]['ctg_type'] != "tests") {
                $parents = eF_getParents($tree[$i]['id'], $tree);
                $data[$i]['content_path'] = implode('&nbsp;&raquo;&nbsp;', $parents['name']);
                //$data[$i]['content_path'] = eF_printContentPathFlat($tree[$i]['id']);
                $data[$i]['content_data'] = eF_printContentData($tree[$i]['id']);
            }
        }
        
    }
} elseif (isset($_GET['content_ID']) && eF_checkParameter($_GET['content_ID'], 'id')) {                                                                                          //The user asked for a specific unit
    $parents = eF_getParents($_GET['content_ID']);
    //$data[0]['content_path'] = eF_printContentPathFlat($_GET['content_ID']);
    $data[0]['content_path'] = implode('&nbsp;&raquo;&nbsp;', $parents['name']);
    $data[0]['content_data'] = eF_printContentData($_GET['content_ID']);
} else {
    $message      = _INVALIDID;
    $message_type = 'failure';
}

$smarty -> assign("T_MESSAGE", $message);
$smarty -> assign("T_MESSAGE_TYPE", $message_type);
$smarty -> assign("T_CONTENT", $data);

$smarty -> display("show_print_friendly.tpl");
?>

    