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