+++ /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 file generates all the image data to be used for the admin / instructor pages\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
-require_once ('define.php');\r
-require_once ('classes/pa.class.php');\r
-require_once ('include/general_func.php');\r
-require_once ('include/data_func.php');\r
-\r
-/**\r
- * @desc Pa_admin_image class. \r
- * @see class Pa\r
- */\r
-class Pa_Admin_Image extends PA{\r
- var $mode=POSTED_NEW;\r
- var $image_array=Array();\r
- var $page_array=Array();\r
- var $current_page=-1;\r
- var $show_page_left_buttons=false;\r
- var $show_page_right_buttons=false;\r
- var $total=NOT_SET;\r
- var $last_page=NOT_SET;\r
- \r
- /** \r
- * @desc constructor\r
- */\r
- function Pa_Admin_Image(){\r
- $this->checkAuthority();\r
- parent::init();\r
- $this->checkRequest();\r
- $this->setMode();\r
- $this->checkCurrentPage();\r
- $this->setImages();\r
- $this->setPages();\r
- \r
- }\r
- \r
- /**\r
- * @desc This function checks the request to change the image status. The request could be make approved, make disapproved, or make new\r
- */\r
- function checkRequest(){\r
- if (isset($_POST['button_disapprove'])){\r
- for ($i=0; $i < ADMIN_NUMBER_OF_IMAGE_PAGE; $i++){\r
- $string="imageId".$i;\r
- if (isset($_POST[$string])){\r
- modify_image_status($_POST[$string], $this->getVariable('course_id'), DISAPPROVED); \r
- }\r
- }\r
- } else if (isset($_POST['button_approve'])){\r
- for ($i=0; $i< ADMIN_NUMBER_OF_IMAGE_PAGE; $i++){\r
- $string="imageId".$i;\r
- if (isset($_POST[$string])){\r
- modify_image_status($_POST[$string], $this->getVariable('course_id'), APPROVED);\r
- }\r
- }\r
- } else if (isset($_POST['button_post_new'])){\r
- for ($i=0; $i < ADMIN_NUMBER_OF_IMAGE_PAGE; $i++){\r
- $string="imageId".$i; \r
- if (isset($_POST[$string])){\r
- modify_image_status($_POST[$string], $this->getVariable('course_id'), POSTED_NEW);\r
- }\r
- } \r
- }\r
- }\r
- \r
- /**\r
- * @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
- */\r
- function checkAuthority(){\r
- if (is_admin_for_course()!=true){\r
- redirect('index.php');\r
- }\r
- }\r
- \r
- /**\r
- * @desc This function decides whether to display left arrow and right arrow buttons on the page table\r
- */\r
- function setPages(){\r
- $temp=get_page_array(ADMIN_NUMBER_OF_IMAGE, ADMIN_NUMBER_OF_IMAGE_PAGE, $this->getVariable('current_page'), $this->getVariable('last_page'));\r
- $current=$this->getVariable('current_page');\r
- if ($current > 1){\r
- $this->setVariable('show_page_left_buttons', true);\r
- } \r
- if ($current < $temp['last_page']){\r
- $this->setVariable('show_page_right_buttons', true);\r
- }\r
- $this->page_array=&$temp;\r
- \r
- } \r
- \r
- /**\r
- * @desc This function sets the mode value for the image display. The mode value can be POSTED_NEW, APPROVED, or DISAPPROVED\r
- */\r
- function setMode(){\r
- if (isset($_GET['mode'])){\r
- $this->setVariable('mode', intval($_GET['mode']));\r
- } \r
- }\r
- \r
- /**\r
- * @desc This function checks if the current page is valid. Otherwise, the current page is set to 1\r
- */\r
- function checkCurrentPage(){\r
- $total=get_total_image_number(ADMIN_PANEL, $this->getVariable('course_id'), $this->getVariable('mode'));\r
- $last_page=get_last_page(ADMIN_NUMBER_OF_IMAGE, $total);\r
- $this->setVariable('total', $total);\r
- $this->setVariable('last_page', $last_page);\r
- if (!isset($_GET['current_page'])){\r
- $this->setVariable('current_page', FIRST_PAGE);\r
- } else {\r
- $current_page=to_pos_int($_GET['current_page']);\r
- if ($current_page > $last_page){\r
- $this->setVariable('current_page',$last_page);\r
- } else {\r
- $this->setVariable('current_page', $current_page);\r
- }\r
- }\r
- }\r
- \r
- /**\r
- * @desc This function sets the image array\r
- */\r
- function setImages(){\r
- $temp=get_image_array(ADMIN_PANEL, parent::getVariable('course_id'), $this->getVariable('mode'), $this->getVariable('current_page'), ADMIN_NUMBER_OF_IMAGE);\r
- $this->image_array=&$temp;\r
- }\r
- \r
- /**\r
- * @desc This function sets the given string value for the class object\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 'mode':\r
- if ($value==APPROVED || $value==DISAPPROVED || $value==POSTED_NEW){\r
- $this->{$string}=$value;\r
- }\r
- break;\r
- case 'current_page':\r
- case 'last_page':\r
- case 'total':\r
- if (is_int($value)){\r
- $this->{$string}=$value;\r
- } else {\r
- parent::storeError("value ".$string." is not integer");\r
- }\r
- break;\r
- case 'show_page_left_buttons':\r
- case 'show_page_right_buttons':\r
- if (is_bool($value)){\r
- $this->{$string}=$value;\r
- } else {\r
- parent::storeError("value ".$string." is not boolean");\r
- }\r
- break;\r
- }\r
- }\r
-}
\ No newline at end of file