changed git call from https to git readonly
[atutor.git] / mods / photo_album / my_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 displays the my comment 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_once(AT_INCLUDE_PATH.'vitals.inc.php');\r
26 $_custom_css = $_base_path . 'mods/photo_album/module.css'; // use a custom stylesheet\r
27 require_once (AT_INCLUDE_PATH.'header.inc.php');\r
28 ?>\r
29 \r
30 <?php\r
31 require_once ('define.php');\r
32 require_once ('classes/pa_mycomment.class.php');\r
33 require_once ('include/general_func.php');\r
34 require_once ('HTML/Template/ITX.php');\r
35 \r
36 if ($_SESSION['enroll']!=true){\r
37         $msg->addError('pa_var_unauthorized');\r
38         redirect('index.php');\r
39 }\r
40 $my=new Mycomment();\r
41 \r
42 if ($my->isError()!=true){      //no error is occured\r
43         $course_id=$_SESSION['pa']['course_id'];        //store course_id temporarily\r
44         unset($_SESSION['pa']);                                         //clear pa session variables\r
45         $_SESSION['pa']['course_id']=$course_id;\r
46         $_SESSION['pa']['my_pic_mode']=true;\r
47         \r
48         $template=new HTML_Template_ITX("./Template");\r
49         $template->loadTemplateFile("my_comment.tpl.php");\r
50                 \r
51         switch ($my->getVariable('mode')){\r
52                 case POSTED_NEW:\r
53                         $template->setVariable("TITLE", _AT('pa_title_my_comment_new'));\r
54                 break;\r
55                 case APPROVED:\r
56                         $template->setVariable("TITLE", _AT('pa_title_my_comment_approved'));\r
57                 break;\r
58                 case DISAPPROVED:\r
59                         $template->setVariable("TITLE", _AT('pa_title_my_comment_disapproved'));\r
60                 break;\r
61         }\r
62         \r
63         $template->setVariable("MAIN_URL", BASE_PATH.'index.php');\r
64         $template->setVariable("MAIN_TITLE", _AT('pa_tag_course_photo_alt'));\r
65         \r
66         $template->setVariable("MY_PHOTO_URL", BASE_PATH.'my_photo.php');\r
67         $template->setVariable("MY_PHOTO_TITLE", _AT('pa_tag_my_photo_alt'));\r
68         \r
69         $template->setVariable("MY_COMMENT_URL", BASE_PATH.'my_comment.php');\r
70         $template->setVariable("MY_COMMENT_TITLE", _AT('pa_tag_my_comment_alt'));\r
71         \r
72         \r
73         $template->setCurrentBlock("SELECT_PART");\r
74         $template->setVariable("DESTINATION", BASE_PATH.'my_comment.php?mode='.POSTED_NEW.SEP.'current_page='.$my->getVariable('current_page'));\r
75         $template->setVariable("LINK_TEXT", _AT('pa_tag_new_comment').' | ');\r
76         $template->parseCurrentBlock("SELECT_PART");\r
77         \r
78         $template->setCurrentBlock("SELECT_PART");\r
79         $template->setVariable("DESTINATION", BASE_PATH.'my_comment.php?mode='.APPROVED.SEP.'current_page='.$my->getVariable('current_page'));\r
80         $template->setVariable("LINK_TEXT", _AT('pa_tag_approved_comment').' | ');\r
81         $template->parseCurrentBlock("SELECT_PART");\r
82         \r
83         $template->setCurrentBlock("SELECT_PART");\r
84         $template->setVariable("DESTINATION", BASE_PATH.'my_comment.php?mode='.DISAPPROVED.SEP.'current_page='.$my->getVariable('current_page'));\r
85         $template->setVariable("LINK_TEXT", _AT('pa_tag_disapproved_comment'));\r
86         $template->parseCurrentBlock("SELECT_PART");\r
87         \r
88         \r
89                 \r
90         /* start display comments */\r
91         $comment_array=$my->comment_array;\r
92         for ($i=0; $i<count($comment_array); $i++){\r
93                 $template->setCurrentBlock("COMMENT_TABLE_DATA");\r
94                 $template->setVariable("CHECK_NAME", "commentId".$i);\r
95                 $template->setVariable("CHECK_VALUE", $comment_array[$i]['comment_id']);\r
96                 $template->setVariable("COMMENT_TABLE_DATA1", $comment_array[$i]['comment']);\r
97                 $img_data=get_single_data(IMAGE, $comment_array[$i]['image_id'], $comment_array[$i]['course_id']);\r
98                 $template->setVariable("COMMENT_TABLE_DATA2", _AT('title').": ".$img_data['title']);\r
99                 $template->setVariable("COMMENT_TABLE_DATA3", _AT('date').": ".$comment_array[$i]['date']);\r
100                 if ($img_data['status']==APPROVED){\r
101                         $template->setVariable("COMMENT_TABLE_DATA4", "<a href=\"".BASE_PATH."view.php?image_id=".$img_data['image_id']."\">"._AT('pa_tag_view_comment_link')."</a>");\r
102                 } else {\r
103                         $template->setVariable("COMMENT_TABLE_DATA4", _AT('pa_tag_image_not_approved'));\r
104                 }\r
105                 $template->parseCurrentBlock("COMMENT_TABLE_DATA");\r
106         }\r
107         \r
108         // Display page table \r
109         $page_array=$my->getVariable('page_array');\r
110         $current=$my->getVariable('current_page');\r
111         $template->setCurrentBlock("PAGE_TABLE_PART");\r
112         if ($my->getVariable('show_page_left_buttons')==true){\r
113                 $first_button=_AT('pa_tag_first_page_button');\r
114                 $previous_button=_AT('pa_tag_previous_page_button');\r
115                 $template->setCurrentBlock("B_DATA_PART");\r
116                 $template->setVariable("B_DATA", '<li><a href=\''.BASE_PATH.'my_comment.php?current_page=1&amp;mode='.$my->getVariable('mode').'\'><img src=\''.FIRST_PAGE_IMAGE.'\' alt=\''.$first_button.'\' width=\'30\' height=\'20\'/></a></li>');\r
117                 $template->parseCurrentBlock("B_DATA_PART");\r
118                 $template->setCurrentBlock("B_DATA_PART");\r
119                 $template->setVariable("B_DATA", '<li><a href=\''.BASE_PATH.'my_comment.php?current_page='.($current-1).SEP.'mode='.$my->getVariable('mode').'\'><img src=\''.PRE_IMAGE.'\' alt=\''.$previous_button.'\' width=\'30\' height=\'20\'/></a></li>');\r
120                 $template->parseCurrentBlock("B_DATA_PART");\r
121         }\r
122         \r
123         for ($i=$page_array['start']; $i<=$page_array['end']; $i++){\r
124                 if ($i==$current){\r
125                         $template->setCurrentBlock("B_DATA_PART");\r
126                         $template->setVariable("B_DATA", '<li class=\'current\'>'.$i.'</li>');\r
127                         $template->parseCurrentBlock("B_DATA_PART");\r
128                 } else {\r
129                         $template->setCurrentBlock("B_DATA_PART");\r
130                         $template->setVariable("B_DATA", '<li><a href=\''.BASE_PATH.'my_comment.php?current_page='.$i.SEP.'mode='.$my->getVariable('mode').'\'>'.$i.'</a></li>');\r
131                         $template->parseCurrentBlock("B_DATA_PART");\r
132                 }\r
133         }\r
134                 \r
135         if ($my->getVariable('show_page_right_buttons')==true){\r
136                 $next_button=_AT('pa_tag_next_page_button');\r
137                 $last_button=_AT('pa_tag_last_page_button');\r
138                 $template->setCurrentBlock("B_DATA_PART");\r
139                 $template->setVariable("B_DATA", '<li><a href=\''.BASE_PATH.'my_comment.php?current_page='.($current+1).SEP.'mode='.$my->getVariable('mode').'\'><img src=\''.NEXT_IMAGE.'\' alt=\''.$next_button.'\' width=\'30\' height=\'20\'/></a></li>');\r
140                 $template->parseCurrentBlock("B_DATA_PART");\r
141                 $template->setCurrentBlock("B_DATA_PART");\r
142                 $template->setVariable("B_DATA", '<li><a href=\''.BASE_PATH.'my_comment.php?current_page='.$page_array['last_page'].SEP.'mode='.$my->getVariable('mode').'\'><img src=\''.LAST_PAGE_IMAGE.'\' alt=\''.$last_button.'\' width=\'30\' height=\'20\'/></a></li>');\r
143                 $template->parseCurrentBlock("B_DATA_PART");\r
144         }\r
145                 \r
146         $template->parseCurrentBlock("PAGE_TABLE_PART");\r
147         $template->parseCurrentBlock();\r
148         $template->show();\r
149 } else {\r
150         $msg->addError('pa_obj_mypic');\r
151         redirect('index.php');\r
152 }\r
153 \r
154 ?>\r
155 \r
156 <?php require_once(AT_INCLUDE_PATH.'footer.inc.php'); ?>