+++ /dev/null
-<?php\r
-/*===============================================================\r
- Photo Album \r
- ===============================================================\r
- Copyright (c) 2006 by Dylan Cheon & Kelvin Wong \r
- Institute for Assistive Technology / University of Victoria \r
- http://www.canassist.ca/ \r
- \r
- This program is free software. You can redistribute it and/or\r
- modify it under the terms of the GNU General Public License \r
- as published by the Free Software Foundation. \r
- ===============================================================\r
- */\r
-// $Id:\r
-\r
-/**\r
- * @desc This class structure is the general class to be used for every other class. This class defines the course id, guest check, enrollment check, etc.\r
- * @author Dylan Cheon & Kelvin Wong\r
- * @copyright 2006, Institute for Assistive Technology / University of Victoria \r
- * @link http://www.canassist.ca/ \r
- * @license GNU\r
- */\r
- \r
-if (!defined('PATH')){\r
- if (preg_match('/'.AT_PRETTY_URL_HANDLER.'\/.*\/(mods\/.*\/)/', $_SERVER['PHP_SELF'], $matches) > 0){\r
- define('PATH', $matches[1]);\r
- } else {\r
- define('PATH', './');\r
- }\r
-}\r
-\r
-require_once (PATH.'define.php');\r
-require_once (PATH.'include/data_func.php');\r
-require_once (PATH.'include/general_func.php');\r
-require_once (PATH.'HTML/Template/ITX.php');\r
-\r
-/**\r
- * @desc This class is called Pa. This class is used by every other class\r
- */\r
-class Pa {\r
- var $course_id=-1;\r
- var $error=0;\r
- var $error_array=Array();\r
- \r
- /**\r
- * @desc constructor. \r
- */\r
- function Pa (){\r
- Pa::init();\r
- }\r
- \r
- /**\r
- * @desc This function initializes the class object \r
- */\r
- function init(){\r
- Pa::checkGuest();\r
- Pa::checkEnrolled();\r
- Pa::setCourseId();\r
- }\r
- \r
- /**\r
- * @desc This function checks whether the user is enrolled in the course or not\r
- */\r
- function checkEnrolled(){\r
- if ($_SESSION['privileges']>0){\r
- Pa::setVariable('show_modification_buttons', true);\r
- } else if (isset($_SESSION['enroll']) && ($_SESSION['enroll']==true)){\r
- Pa::setVariable('show_modification_buttons', true);\r
- }\r
- }\r
- \r
- /**\r
- * @desc This function checks whether the user is guest. If the user is guest, it redirects the user to login page\r
- */\r
- function checkGuest(){\r
- if (isset($_SESSION['is_guest']) && ($_SESSION['is_guest']==true)){\r
- redirect('../../'.PATH.'login.php');\r
- }\r
- }\r
- \r
- /**\r
- * @desc This function sets the course id\r
- */\r
- function setCourseId(){\r
- if (isset($_POST['course_id']) && course_exist($_POST['course_id'])){\r
- Pa::setVariable('course_id', intval($_POST['course_id']));\r
- } else if ($_SESSION['course_id']==-1){\r
- Pa::setVariable('course_id', intval($_SESSION['pa']['course_id']));\r
- } else {\r
- Pa::setVariable('course_id', intval($_SESSION['course_id']));\r
- }\r
- }\r
- \r
- /**\r
- * @desc This function sets the given input string for the class object variable\r
- * @param String $string string name to be set\r
- * @param mixed $value string value\r
- */ \r
- function setVariable($string, $value){\r
- switch ($string){\r
- case 'course_id':\r
- if (is_int($value) && ($value > 0) && course_exist($value)){\r
- $this->{$string}=$value;\r
- } else {\r
- $this->storeError("course value is not valid");\r
- }\r
- break;\r
- case 'error':\r
- if (is_int($value) && ($value > 0)){\r
- $this->{$string}=$value;\r
- } else {\r
- $this->storeError("value ".$value." is not int");\r
- }\r
- break;\r
- case 'show_modification_buttons':\r
- if (is_bool($value)){\r
- $this->{$string}=$value;\r
- } else {\r
- $this->storeError("value ".$value." is not boolean");\r
- }\r
- break;\r
- }\r
- }\r
- \r
- /**\r
- * @desc This function returns the given variable value\r
- * @param String $string name of string to be returned\r
- * @return mixed the required variable value \r
- */\r
- function getVariable($string){\r
- return $this->{$string};\r
- }\r
- \r
- \r
- /**\r
- * @desc This function stores the fatal error for the class object. This function is only called when a fatal error is occured.\r
- * @param String $string error string to be stored\r
- */\r
- function storeError($string){ \r
- $error=&Pa::getVariable('error');\r
- $array=&$this->error_array;\r
- $array[$error]=$string;\r
- Pa::setVariable('error', $error+1);\r
- }\r
- \r
- /**\r
- * @desc This function checks if a fatal error has occurred or not in the class object\r
- * @return boolean true if there is fatal error\r
- */\r
- function isError(){\r
- if (Pa::getVariable('error')==0){\r
- return false;\r
- } else {\r
- return true;\r
- }\r
- }\r
-}
\ No newline at end of file