c28374d0c330909bd9b53f40e78e76d24b4389b5
[atutor.git] / mods / photo_album / instructor_comment.php
1 <?php\r
2 /*==============================================================\r
3   Photo Album\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
8                                                                \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
13  */\r
14 // $Id:\r
15 \r
16 /**\r
17  * @desc        This file generates the comment page for instructor panel\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
21  * @license GNU\r
22  */\r
23 define('AT_INCLUDE_PATH', '../../include/');\r
24 require (AT_INCLUDE_PATH.'vitals.inc.php');\r
25 $_custom_css = $_base_path . 'mods/photo_album/module.css'; // use a custom stylesheet\r
26 require (AT_INCLUDE_PATH.'header.inc.php');\r
27 ?>\r
28 <?php\r
29 require_once ('classes/pa_admin_comment.class.php');\r
30 require_once ('HTML/Template/ITX.php');\r
31 \r
32 $admin=new Pa_Admin_Comment();\r
33 \r
34 if ($admin->isError()!=true){   //no error found, so display the page\r
35         $template=new HTML_Template_ITX("./Template");\r
36         $template->loadTemplateFile("instructor_comment.tpl.php");\r
37         $template->setVariable("ADMIN_NUMBER_OF_COMMENT", ADMIN_NUMBER_OF_COMMENT);\r
38         \r
39         switch ($admin->getVariable('mode')){\r
40                 case POSTED_NEW:\r
41                         $template->setVariable("TITLE", _AT('pa_title_instructor_new_comment'));\r
42                 break;\r
43                 case APPROVED:\r
44                         $template->setVariable("TITLE", _AT('pa_title_instructor_approved_comment'));\r
45                 break;\r
46                 case DISAPPROVED:\r
47                         $template->setVariable("TITLE", _AT('pa_title_instructor_disapproved_comment'));\r
48                 break;\r
49         }\r
50         \r
51         $mode=get_config_mode($admin->getVariable('course_id'));\r
52         $template->setVariable("CONFIG_STRING", _AT('pa_tag_config_string'));\r
53         if ($mode==CONFIG_ENABLED){\r
54                 $template->setVariable("CONFIG_VALUE", _AT('pa_tag_config_enabled'));\r
55         } else {\r
56                 $template->setVariable("CONFIG_VALUE", _AT('pa_tag_config_disabled'));\r
57         }\r
58         \r
59         $template->setCurrentBlock("SELECT_PART");\r
60         $template->setVariable("SELECT_FORM_NAME", "select_form");\r
61         $template->setVariable("SELECT_ACTION", $_SERVER['PHP_SELF']);\r
62         $template->setVariable("SELECT_NAME", "mode");\r
63         $template->setVariable("SELECT_LABEL", _AT('pa_tag_view'));\r
64         \r
65         $template->setCurrentBlock("OPTION_PART");\r
66         $template->setVariable("OPTION_VALUE", POSTED_NEW);\r
67         $template->setVariable("OPTION_STRING", _AT('pa_tag_new_comment'));\r
68         $template->parseCurrentBlock("OPTION_PART");\r
69         \r
70         $template->setCurrentBlock("OPTION_PART");\r
71         $template->setVariable("OPTION_VALUE", APPROVED);\r
72         $template->setVariable("OPTION_STRING", _AT('pa_tag_approved_comment'));\r
73         $template->parseCurrentBlock("OPTION_PART");\r
74         \r
75         $template->setCurrentBlock("OPTION_PART");\r
76         $template->setVariable("OPTION_VALUE", DISAPPROVED);\r
77         $template->setVariable("OPTION_STRING", _AT('pa_tag_disapproved_comment'));\r
78         $template->parseCurrentBlock("OPTION_PART");\r
79         \r
80         $template->setVariable("SELECT_SUBMIT", "select_submit");\r
81         $template->setVariable("SELECT_SUBMIT_VALUE", _AT('pa_tag_go'));\r
82         $template->parseCurrentBlock("SELECT_PART");\r
83         \r
84         $template->setCurrentBlock("COMMENT_TABLE_PART");\r
85         $template->setVariable("COMMENT_TABLE_FORM_NAME", "table_form");\r
86         $action_string=$_SERVER['PHP_SELF']."?mode=".$admin->getVariable('mode')."&amp;current_page=".$admin->getVariable('current_page');\r
87         $template->setVariable("COMMENT_TABLE_ACTION", $action_string);\r
88                 \r
89         /* start display comments */\r
90         $comment_array=$admin->comment_array;\r
91         //      print_r($comment_array);\r
92         //exit;\r
93         for ($i=0; $i<count($comment_array); $i++){\r
94                 $template->setCurrentBlock("COMMENT_TABLE_DATA");\r
95                 $template->setVariable("CHECK_NAME", "commentId".$i);\r
96                 $template->setVariable("CHECK_VALUE", $comment_array[$i]['comment_id']);\r
97                 $template->setVariable("COMMENT_TABLE_DATA1", $comment_array[$i]['comment']);\r
98                 $template->setVariable("COMMENT_TABLE_DATA2", _AT('login').": ".$comment_array[$i]['login']);           \r
99                 $template->setVariable("COMMENT_TABLE_DATA3", _AT('date').": ".$comment_array[$i]['date']);\r
100                 $template->setVariable("COMMENT_TABLE_DATA4", "<a href=\"".BASE_PATH."view.php?image_id=".$comment_array[$i]['image_id']."\">"._AT('pa_tag_view_comment_link')."</a>");\r
101                 $template->parseCurrentBlock("COMMENT_TABLE_DATA");\r
102         }\r
103         $template->setCurrentBlock("COMMENT_BUTTON");\r
104         $template->setVariable("COMMENT_BUTTON_NAME", "button_disapprove");\r
105         $template->setVariable("COMMENT_BUTTON_VALUE", _AT('pa_button_set_disapproved_comment'));\r
106         $template->parseCurrentBlock("COMMENT_BUTTON");\r
107         \r
108         $template->setCurrentBlock("COMMENT_BUTTON");\r
109         $template->setVariable("COMMENT_BUTTON_NAME", "button_approve");\r
110         $template->setVariable("COMMENT_BUTTON_VALUE", _AT('pa_button_set_approved_comment'));\r
111         $template->parseCurrentBlock("COMMENT_BUTTON");\r
112         \r
113         $template->setCurrentBlock("COMMENT_BUTTON");\r
114         $template->setVariable("COMMENT_BUTTON_NAME", "button_post_new");\r
115         $template->setVariable("COMMENT_BUTTON_VALUE", _AT('pa_button_set_new_comment'));\r
116         $template->parseCurrentBlock("COMMENT_BUTTON");\r
117         \r
118         $template->setVariable("CHECK_ALL_MSG", _AT('pa_tag_check_all_comment'));\r
119         \r
120         $template->parseCurrentBlock("COMMENT_TABLE_PART");\r
121         \r
122         // Display page table \r
123         $page_array=$admin->getVariable('page_array');\r
124         $current=$admin->getVariable('current_page');\r
125         if ($admin->getVariable('show_page_left_buttons')==true){\r
126                 $first_button=_AT('pa_tag_first_page_button');\r
127                 $previous_button=_AT('pa_tag_previous_page_button');\r
128                 $template->setCurrentBlock("B_DATA_PART");\r
129                 $template->setVariable("B_DATA", '<li><a href=\''.BASE_PATH.'instructor_comment.php?current_page=1&amp;mode='.$admin->getVariable('mode').'\'><img src=\''.FIRST_PAGE_IMAGE.'\' alt=\''.$first_button.'\' width=\'30\' height=\'20\'/></a></li>');\r
130                 $template->parseCurrentBlock("B_DATA_PART");\r
131                 $template->setCurrentBlock("B_DATA_PART");\r
132                 $template->setVariable("B_DATA", '<li><a href=\''.BASE_PATH.'instructor_comment.php?current_page='.($current-1).SEP.'mode='.$admin->getVariable('mode').'\'><img src=\''.PRE_IMAGE.'\' alt=\''.$previous_button.'\' width=\'30\' height=\'20\'/></a></li>');\r
133                 $template->parseCurrentBlock("B_DATA_PART");\r
134         }\r
135         \r
136         for ($i=$page_array['start']; $i<=$page_array['end']; $i++){\r
137                 if ($i==$current){\r
138                         $template->setCurrentBlock("B_DATA_PART");\r
139                         $template->setVariable("B_DATA", '<li class=\'current\'>'.$i.'</li>');\r
140                         $template->parseCurrentBlock("B_DATA_PART");\r
141                 } else {\r
142                         $template->setCurrentBlock("B_DATA_PART");\r
143                         $template->setVariable("B_DATA", '<li><a href=\''.BASE_PATH.'instructor_comment.php?current_page='.$i.SEP.'mode='.$admin->getVariable('mode').'\'>'.$i.'</a></li>');\r
144                         $template->parseCurrentBlock("B_DATA_PART");\r
145                 }\r
146         }\r
147                 \r
148         if ($admin->getVariable('show_page_right_buttons')==true){\r
149                 $last_button=_AT('pa_tag_last_page_button');\r
150                 $next_button=_AT('pa_tag_next_page_button');\r
151                 $template->setCurrentBlock("B_DATA_PART");\r
152                 $template->setVariable("B_DATA", '<li><a href=\''.BASE_PATH.'instructor_comment.php?current_page='.($current+1).SEP.'mode='.$admin->getVariable('mode').'\'><img src=\''.NEXT_IMAGE.'\' alt=\''.$next_button.'\' width=\'30\' height=\'20\'/></a></li>');\r
153                 $template->parseCurrentBlock("B_DATA_PART");\r
154                 $template->setCurrentBlock("B_DATA_PART");\r
155                 $template->setVariable("B_DATA", '<li><a href=\''.BASE_PATH.'instructor_comment.php?current_page='.$page_array['last_page'].SEP.'mode='.$admin->getVariable('mode').'\'><img src=\''.LAST_PAGE_IMAGE.'\' alt=\''.$last_button.'\' width=\'30\' height=\'20\'/></a></li>');\r
156                 $template->parseCurrentBlock("B_DATA_PART");\r
157         }\r
158                 \r
159 \r
160         $template->parseCurrentBlock();\r
161         $template->show();\r
162         unset($_SESSION['pa']);\r
163         $_SESSION['pa']['course_id'];\r
164         $_SESSION['pa']['instructor_mode']=true;\r
165 } else {\r
166         $msg->addError('pa_obj_pa_admin_comment');\r
167         redirect('index.php');\r
168 }\r
169 \r
170 ?>\r
171 <?php require (AT_INCLUDE_PATH.'footer.inc.php'); ?>