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 all the image data to be used for the admin / instructor pages
\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/general_func.php');
\r
27 require_once ('include/data_func.php');
\r
30 * @desc Pa_admin_image class.
\r
33 class Pa_Admin_Image extends PA{
\r
34 var $mode=POSTED_NEW;
\r
35 var $image_array=Array();
\r
36 var $page_array=Array();
\r
37 var $current_page=-1;
\r
38 var $show_page_left_buttons=false;
\r
39 var $show_page_right_buttons=false;
\r
41 var $last_page=NOT_SET;
\r
46 function Pa_Admin_Image(){
\r
47 $this->checkAuthority();
\r
49 $this->checkRequest();
\r
51 $this->checkCurrentPage();
\r
58 * @desc This function checks the request to change the image status. The request could be make approved, make disapproved, or make new
\r
60 function checkRequest(){
\r
61 if (isset($_POST['button_disapprove'])){
\r
62 for ($i=0; $i < ADMIN_NUMBER_OF_IMAGE_PAGE; $i++){
\r
63 $string="imageId".$i;
\r
64 if (isset($_POST[$string])){
\r
65 modify_image_status($_POST[$string], $this->getVariable('course_id'), DISAPPROVED);
\r
68 } else if (isset($_POST['button_approve'])){
\r
69 for ($i=0; $i< ADMIN_NUMBER_OF_IMAGE_PAGE; $i++){
\r
70 $string="imageId".$i;
\r
71 if (isset($_POST[$string])){
\r
72 modify_image_status($_POST[$string], $this->getVariable('course_id'), APPROVED);
\r
75 } else if (isset($_POST['button_post_new'])){
\r
76 for ($i=0; $i < ADMIN_NUMBER_OF_IMAGE_PAGE; $i++){
\r
77 $string="imageId".$i;
\r
78 if (isset($_POST[$string])){
\r
79 modify_image_status($_POST[$string], $this->getVariable('course_id'), POSTED_NEW);
\r
86 * @desc This function checks if the user is an instructor or an administrator. If the user is neither instructor nor administrator, it redirects the user to the index page
\r
88 function checkAuthority(){
\r
89 if (is_admin_for_course()!=true){
\r
90 redirect('index.php');
\r
95 * @desc This function decides whether to display left arrow and right arrow buttons on the page table
\r
97 function setPages(){
\r
98 $temp=get_page_array(ADMIN_NUMBER_OF_IMAGE, ADMIN_NUMBER_OF_IMAGE_PAGE, $this->getVariable('current_page'), $this->getVariable('last_page'));
\r
99 $current=$this->getVariable('current_page');
\r
101 $this->setVariable('show_page_left_buttons', true);
\r
103 if ($current < $temp['last_page']){
\r
104 $this->setVariable('show_page_right_buttons', true);
\r
106 $this->page_array=&$temp;
\r
111 * @desc This function sets the mode value for the image display. The mode value can be POSTED_NEW, APPROVED, or DISAPPROVED
\r
113 function setMode(){
\r
114 if (isset($_GET['mode'])){
\r
115 $this->setVariable('mode', intval($_GET['mode']));
\r
120 * @desc This function checks if the current page is valid. Otherwise, the current page is set to 1
\r
122 function checkCurrentPage(){
\r
123 $total=get_total_image_number(ADMIN_PANEL, $this->getVariable('course_id'), $this->getVariable('mode'));
\r
124 $last_page=get_last_page(ADMIN_NUMBER_OF_IMAGE, $total);
\r
125 $this->setVariable('total', $total);
\r
126 $this->setVariable('last_page', $last_page);
\r
127 if (!isset($_GET['current_page'])){
\r
128 $this->setVariable('current_page', FIRST_PAGE);
\r
130 $current_page=to_pos_int($_GET['current_page']);
\r
131 if ($current_page > $last_page){
\r
132 $this->setVariable('current_page',$last_page);
\r
134 $this->setVariable('current_page', $current_page);
\r
140 * @desc This function sets the image array
\r
142 function setImages(){
\r
143 $temp=get_image_array(ADMIN_PANEL, parent::getVariable('course_id'), $this->getVariable('mode'), $this->getVariable('current_page'), ADMIN_NUMBER_OF_IMAGE);
\r
144 $this->image_array=&$temp;
\r
148 * @desc This function sets the given string value for the class object
\r
149 * @param String $string string name to be set
\r
150 * @param mixed $value string value
\r
152 function setVariable($string, $value){
\r
155 if ($value==APPROVED || $value==DISAPPROVED || $value==POSTED_NEW){
\r
156 $this->{$string}=$value;
\r
159 case 'current_page':
\r
162 if (is_int($value)){
\r
163 $this->{$string}=$value;
\r
165 parent::storeError("value ".$string." is not integer");
\r
168 case 'show_page_left_buttons':
\r
169 case 'show_page_right_buttons':
\r
170 if (is_bool($value)){
\r
171 $this->{$string}=$value;
\r
173 parent::storeError("value ".$string." is not boolean");
\r