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 comment data for the mycomment mode
\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 Mycomment class.
\r
34 class Mycomment extends Pa{
\r
35 var $mode=POSTED_NEW;
\r
36 var $comment_array=Array();
\r
37 var $page_array=Array();
\r
38 var $current_page=-1;
\r
39 var $show_page_left_buttons=false;
\r
40 var $show_page_right_buttons=false;
\r
42 var $last_page=NOT_SET;
\r
47 function Mycomment(){
\r
50 $this->checkCurrentPage();
\r
51 $this->setComments();
\r
57 * @desc This function decides whether to display left arrow and right arrow buttons in the page table
\r
59 function setPages(){
\r
60 $temp=get_page_array(MYCOMMENT_NUMBER_OF_COMMENT, MYCOMMENT_NUMBER_OF_COMMENT_PAGE, $this->getVariable('current_page'), $this->getVariable('last_page'));
\r
61 $current=$this->getVariable('current_page');
\r
63 $this->setVariable('show_page_left_buttons', true);
\r
65 if ($current < $temp['last_page']){
\r
66 $this->setVariable('show_page_right_buttons', true);
\r
68 $this->page_array=&$temp;
\r
73 * @desc This function sets the mode value for the comments displayed. The mode value can be one of POSTED_NEW, APPROVED, DISAPPROVED
\r
76 if (isset($_GET['mode'])){
\r
77 $this->setVariable('mode', intval($_GET['mode']));
\r
82 * @desc This function checks the current page is valid. Otherwise, the current page is 1
\r
84 function checkCurrentPage(){
\r
85 $total=get_total_comment_number(MY_COMMENT, $this->getVariable('course_id'), $this->getVariable('mode'));
\r
86 $last_page=get_last_page(MYCOMMENT_NUMBER_OF_COMMENT, $total);
\r
87 $this->setVariable('total', $total);
\r
88 $this->setVariable('last_page', $last_page);
\r
90 if (!isset($_GET['current_page'])){
\r
91 $this->setVariable('current_page', FIRST_PAGE);
\r
93 $current_page=to_pos_int($_GET['current_page']);
\r
94 if ($current_page > $last_page){
\r
95 $this->setVariable('current_page',$last_page);
\r
97 $this->setVariable('current_page', $current_page);
\r
103 * @desc This function sets the comment array
\r
105 function setComments(){
\r
106 $array=get_comment_array(MY_COMMENT, parent::getVariable('course_id'), $this->getVariable('mode'), NOT_SET, MYCOMMENT_NUMBER_OF_COMMENT, $this->getVariable('current_page'));
\r
107 $this->comment_array=&$array;
\r
111 * @desc This function sets the given string value for the class object
\r
112 * @param String $string string name to set
\r
113 * @param mixed $value string value
\r
115 function setVariable($string, $value){
\r
118 if ($value==APPROVED || $value==DISAPPROVED || $value==POSTED_NEW){
\r
119 $this->{$string}=$value;
\r
122 case 'current_page':
\r
125 if (is_int($value)){
\r
126 $this->{$string}=$value;
\r
128 parent::storeError("value ".$string." is not integer");
\r
131 case 'show_page_left_buttons':
\r
132 case 'show_page_right_buttons':
\r
133 if (is_bool($value)){
\r
134 $this->{$string}=$value;
\r
136 parent::storeError("value ".$string." is not boolean");
\r