<?php
  class cStudentPage extends cPage
  {
  	protected $userId;
		 
    function __construct( $smarty, $db, $action, $postParams, $getParams )
    {
      parent::__construct( $smarty, $db, $action, $postParams, $getParams );
    	$this->bLoggedIn = $this->LoggedAs("student");
			$this->userId = (isset($_SESSION['userId'])?$_SESSION['userId']:0);
    }

    function Process()
    {
      if ( !$this->bLoggedIn ) 
			{
        return false;
      }
      else
			{ 
				return true;
			}
    }
    
    function Draw()
    {
      if ( !$this->bLoggedIn )
      {
        $this->smarty->display("login.tpl");
      }
      else
      {
				$this->smarty->assign("userFullName",$_SESSION["userFullName"]);
        $this->smarty->display("main.tpl");        
      }
    }

    function AssignQueryResult($query, $name, $type)
    {
      if ( $type=='array' ) 
			{
				$data = $this->db->QueryToArray($query);
			}
			else
			{
				$data = $this->db->QueryToRow($query);
			}
      if ( $data != 0 )
      {
        $this->smarty->assign($name, $data);
      }
      else
      {
				$this->smarty->assign($name, ($type=='array')?array():'');
      } 
    }
    
  }
?>
