<?php
	class cCoursePage extends cTeacherPage
	{
    	 
    function __construct( $smarty, $db, $action, $postParams, $getParams )
    {
      parent::__construct( $smarty, $db, $action, $postParams, $getParams );
      $this->menu=new cMainTeacherMenu;
      $this->menu->GenerateMenu("");
      $menuItem=$this->menu->GetItemByLabel("predmety");
      $menuItem->bSelected=true;
    }
		
    function Process()
    {
      return true;
    }
    
    function Draw()
    {
      if ($this->bLoggedInAsTeacher) 
      {
        $query = "SELECT tC.id, tC.name FROM tCourse AS tC, tUser AS tU, tCourseToUser AS tCTU WHERE ".
                 "tU.id=tCTU.id_user AND tCTU.id_course=tC.id AND ".
                 "tU.id=".$_SESSION["userID"]." ORDER BY tC.name ASC;";
        
        $result = $this->db->QueryToArray($query);
        if ( $result != 0 )
        {
          $this->smarty->assign("listOfCourses",$result);
        }
      }
      else
      {
        $this->bAccessDenied=true;
      }
      $this->smarty->assign("content","course.tpl");
      parent::Draw();
    }
	}
?>
