2 /*==============================================================
\r
4 ==============================================================
\r
5 Copyright (c) 2006 by Dylan Cheon & Kelvin Wong
\r
6 Institute for Assistive Technology / University of Victoria
\r
7 http://www.canassist.ca/
\r
9 This program is free software. You can redistribute it and/or
\r
10 modify it under the terms of the GNU General Public License
\r
11 as published by the Free Software Foundation.
\r
12 ==============================================================
\r
17 * @desc This file generates the image data and comment data to be displayed in the view page
\r
18 * @author Dylan Cheon & Kelvin Wong
\r
19 * @copyright 2006, Institute for Assistive Technology / University of Victoria
\r
20 * @link http://www.canassist.ca/
\r
24 require_once ('define.php');
\r
25 require_once ('classes/pa.class.php');
\r
26 require_once ('include/data_func.php');
\r
27 require_once ('include/general_func.php');
\r
33 class View extends Pa {
\r
34 var $image_id=NOT_SET;
\r
35 var $comment_array=Array();
\r
36 var $image_array=Array();
\r
39 * @desc class constructor
\r
43 $this->checkImageId();
\r
44 $this->checkAuthority();
\r
46 $this->setComments();
\r
50 * @desc This function checks if the image has approved status. If the image is not set to approved and user is neither admin nor instructor, it redirects user to the index page
\r
52 function checkAuthority(){
\r
53 $image_array=get_single_data(IMAGE, $this->getVariable('image_id'), parent::getVariable('course_id'));
\r
54 if (!(($_SESSION['is_admin']==true) || ($_SESSION['privileges'] > 0))){
\r
55 if ($image_array['status']!=APPROVED){
\r
57 $msg->addError('pa_var_unauthorized');
\r
58 redirect('index.php');
\r
64 * @desc This function checks whether the given image_id exists in the database
\r
66 function checkImageId(){
\r
68 if (isset($_GET['image_id'])){
\r
69 if (image_exist(intval($_GET['image_id']), parent::getVariable('course_id'))){
\r
70 $this->setVariable('image_id', intval($_GET['image_id']));
\r
72 $msg->addError('pa_var_unauthorized');
\r
73 redirect('index.php');
\r
76 $msg->addError('pa_var_unauthorized');
\r
77 redirect ('index.php');
\r
82 * @desc This function sets the string to a value
\r
83 * @param String $string string name to set up
\r
84 * @param mixed $value string value
\r
86 function setVariable($string, $value){
\r
89 if (is_int($value) && ($value > 0)){
\r
90 $this->{$string}=$value;
\r
92 parent::storeError("string ".$string." is not integer");
\r
99 * @desc This function sets the image array
\r
101 function setImage(){
\r
102 $this->image_array=&get_single_data(IMAGE, $this->getVariable('image_id'), parent::getVariable('course_id'));
\r
106 * @desc This function sets the comment array
\r
108 function setComments(){
\r
109 $this->comment_array=&get_comment_array(ADMIN_VIEW, $this->getVariable('course_id'), NOT_SET, $this->getVariable('image_id'));
\r