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 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
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
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
36 if ($_SESSION['enroll']!=true){
\r
37 $msg->addError('pa_var_unauthorized');
\r
38 redirect('index.php');
\r
40 $my=new Mycomment();
\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
48 $template=new HTML_Template_ITX("./Template");
\r
49 $template->loadTemplateFile("my_comment.tpl.php");
\r
51 switch ($my->getVariable('mode')){
\r
53 $template->setVariable("TITLE", _AT('pa_title_my_comment_new'));
\r
56 $template->setVariable("TITLE", _AT('pa_title_my_comment_approved'));
\r
59 $template->setVariable("TITLE", _AT('pa_title_my_comment_disapproved'));
\r
63 $template->setVariable("MAIN_URL", BASE_PATH.'index.php');
\r
64 $template->setVariable("MAIN_TITLE", _AT('pa_tag_course_photo_alt'));
\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
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
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
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
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
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
103 $template->setVariable("COMMENT_TABLE_DATA4", _AT('pa_tag_image_not_approved'));
\r
105 $template->parseCurrentBlock("COMMENT_TABLE_DATA");
\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&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
123 for ($i=$page_array['start']; $i<=$page_array['end']; $i++){
\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
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
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
146 $template->parseCurrentBlock("PAGE_TABLE_PART");
\r
147 $template->parseCurrentBlock();
\r
150 $msg->addError('pa_obj_mypic');
\r
151 redirect('index.php');
\r
156 <?php require_once(AT_INCLUDE_PATH.'footer.inc.php'); ?>