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 view page used to display an image and its thread of comments
\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
23 define('AT_INCLUDE_PATH', '../../include/');
\r
24 require_once(AT_INCLUDE_PATH.'vitals.inc.php');
\r
25 $_custom_css = $_base_path . 'mods/photo_album/module.css'; // use a custom stylesheet
\r
26 require_once (AT_INCLUDE_PATH.'header.inc.php');
\r
31 require_once ('define.php');
\r
32 require_once ('HTML/Template/ITX.php');
\r
33 require_once ('classes/pa_view.class.php');
\r
36 $admin_mode=$_SESSION['pa']['administrator_mode']; //save the admin mode if it is true;
\r
37 $instructor_mode=$_SESSION['pa']['instructor_mode']; //save the instructor mode if it is true;
\r
38 unset($_SESSION['pa']);
\r
39 $_SESSION['pa']['administrator_mode']=$admin_mode;
\r
40 $_SESSION['pa']['instructor_mode']=$instructor_mode;
\r
42 if ($view->isError()!=true){ //no error is occured with the view object, so display view page.
\r
43 $_SESSION['pa']['course_id']=$view->getVariable('course_id');
\r
44 $_SESSION['pa']['image_id']=$view->getVariable('image_id');
\r
46 $image_array=$view->getVariable('image_array');
\r
47 $template=new HTML_Template_ITX("./Template");
\r
48 $template->loadTemplatefile("view.tpl.php", true, true);
\r
50 $template->setVariable("IMAGE_TITLE_STRING", _AT('pa_tag_image_title'));
\r
51 $template->setVariable("IMAGE_TITLE", $image_array['title']);
\r
52 $template->setCurrentBlock("IMAGE");
\r
54 /* display delete and edit buttons for the image */
\r
55 if (user_own(IMAGE, $_SESSION['pa']['image_id'], $_SESSION['pa']['course_id'])==true){
\r
56 $template->setCurrentBlock("IMAGE_MODIFY_BUTTONS");
\r
57 $template->setVariable("IMAGE_CHOOSE", IMAGE);
\r
58 $template->setVariable("EDIT_FORM", "edit_form");
\r
59 $template->setVariable("EDIT_ACTION", UPLOAD_ACTION);
\r
60 $template->setVariable("EDIT_DISPLAY", _AT('pa_button_edit_image'));
\r
61 $template->setVariable("DEL_FORM", "DEL_action");
\r
62 $template->setVariable("DEL_ACTION", DELETE_CONFIRM_ACTION);
\r
63 $template->setVariable("DEL_DISPLAY", _AT('pa_button_del_image'));
\r
64 $template->setVariable("IMAGE_ID", $image_array['image_id']);
\r
65 $template->parseCurrentBlock("IMAGE_MODIFY_BUTTONS");
\r
68 /* display the image */
\r
69 $template->setVariable("IMAGE_SRC", $get_file.$image_array['location'].urlencode($image_array['view_image_name']));
\r
70 $template->setVariable("ALT", $image_array['alt']);
\r
71 $template->parseCurrentBlock("IMAGE");
\r
74 /* display image information */
\r
75 $template->setCurrentBlock("TABLE");
\r
76 $template->setVariable("IMAGE_DISPLAY", _AT('pa_tag_image_description'));
\r
77 $image_owner_name=get_member_name($image_array['login']);
\r
78 $template->setVariable("IMAGE_NAME_STRING", _AT('name'));
\r
79 $template->setVariable("IMAGE_NAME", $image_owner_name);
\r
80 $template->setVariable("IMAGE_DESC", convert_newlines($image_array['description']));
\r
81 $template->setVariable("IMAGE_DATE_STRING", _AT('date'));
\r
82 $template->setVariable("IMAGE_DATE", $image_array['date']);
\r
83 $template->parseCurrentBlock("TABLE");
\r
85 if ($view->getVariable('show_modification_buttons')==true){
\r
86 $template->setCurrentBlock("ADD_COMMENT_BUTTON");
\r
87 $template->setVariable("ADD_FORM", "add_form");
\r
88 $template->setVariable("ADD_ACTION", ADD_ACTION);
\r
89 $template->setVariable("ADD_DISPLAY", _AT('pa_button_add_comment'));
\r
90 $template->setVariable("COMMENT_CHOOSE", COMMENT);
\r
91 $template->parseCurrentBlock("ADD_COMMENT_BUTTON");
\r
94 /* display comments */
\r
95 $comment_array=$view->comment_array;
\r
96 if (count($comment_array) >= 1){
\r
97 $template->setCurrentBlock("COMMENT_HEAD");
\r
98 $template->setVariable("COMMENT_DISPLAY", _AT('pa_tag_comment_description'));
\r
100 for ($i=0; $i<count($comment_array); $i++){
\r
101 $blog_owner_name=get_member_name($comment_array[$i]['login']);
\r
102 $user_own=user_own(COMMENT, $comment_array[$i]['image_id'], $comment_array[$i]['course_id'], $comment_array[$i]['comment_id']);
\r
103 if (($comment_array[$i]['status']!=APPROVED) && ($user_own!=true)){
\r
106 if (($view->getVariable('show_modification_buttons')) && ($user_own==true)){
\r
107 $template->setCurrentBlock("COMMENT_START");
\r
109 if ((is_admin_for_course()==true) || ($user_own==true)){
\r
110 if ($comment_array[$i]['status']==DISAPPROVED){
\r
111 $color="disapproved";
\r
112 $template->setVariable("MESSAGE", _AT('pa_note_comment_disapproved'));
\r
113 } else if ($comment_array[$i]['status']==POSTED_NEW){
\r
114 $color="posted_new";
\r
115 $template->setVariable("MESSAGE", _AT('pa_note_comment_posted_new'));
\r
118 $COMMENT_DEL_FORM="blog_del_form";
\r
119 $COMMENT_DEL_ACTION=DELETE_CONFIRM_ACTION;
\r
120 $COMMENT_DEL=_AT('pa_button_del_comment');
\r
122 $COMMENT_EDIT_FORM="blog_edit_form";
\r
123 $COMMENT_EDIT_ACTION=EDIT_ACTION;
\r
124 $COMMENT_EDIT=_AT('pa_button_edit_comment');
\r
125 $COMMENT_ID=$comment_array[$i]['comment_id'];
\r
126 $COMMENT_CHOOSE=COMMENT;
\r
129 $template->setVariable("COLOR", $color);
\r
130 $template->setVariable("COMMENT_NAME", $blog_owner_name);
\r
131 $template->setVariable("COMMENT_VALUE", convert_newlines($comment_array[$i]['comment']));
\r
132 $template->setVariable("COMMENT_DATE", $comment_array[$i]['date']);
\r
134 $control_button="<div class=\"row buttons\">";
\r
135 $control_button.="<form name=\"blog_del_form\" method=\"post\" action=\"".$COMMENT_DEL_ACTION."\">";
\r
136 $control_button.="<input type=\"submit\" name=\"delete\" value=\"".$COMMENT_DEL."\"/>";
\r
137 $control_button.="<input type=\"hidden\" name=\"mode\" value=\"delete\"/>";
\r
138 $control_button.="<input type=\"hidden\" name=\"comment_id\" value=\"".$COMMENT_ID."\"/>";
\r
139 $control_button.="<input type=\"hidden\" name=\"choose\" value=\"".$COMMENT_CHOOSE."\"/>";
\r
140 $control_button.="</form>";
\r
143 $control_button.="<form name=\"blog_edit_form\" method=\"post\" action=\"".$COMMENT_EDIT_ACTION."\">";
\r
144 $control_button.="<input type=\"submit\" name=\"edit\" value=\"".$COMMENT_EDIT."\"/>";
\r
145 $control_button.="<input type=\"hidden\" name=\"mode\" value=\"edit\"/>";
\r
146 $control_button.="<input type=\"hidden\" name=\"comment_id\" value=\"".$COMMENT_ID."\"/>";
\r
147 $control_button.="<input type=\"hidden\" name=\"choose\" value=\"".$COMMENT_CHOOSE."\"/>";
\r
148 $control_button.="</form>";
\r
149 $control_button.="</div>";
\r
152 $template->setVariable("CONTROL_BUTTONS", $control_button);
\r
153 $template->parseCurrentBlock("COMMENT_START");
\r
155 $template->setCurrentBlock("COMMENT_START");
\r
156 $template->setVariable("COMMENT_NAME", $blog_owner_name);
\r
157 $template->setVariable("COMMENT_VALUE", convert_newlines($comment_array[$i]['comment']));
\r
158 $template->setVariable("COMMENT_DATE", $comment_array[$i]['date']);
\r
159 $template->parseCurrentBlock("COMMENT_START");
\r
162 $template->parseCurrentBlock("COMMENT_HEAD");
\r
165 $template->parseCurrentBlock();
\r
168 $msg->addError('pa_obj_view');
\r
169 redirect('index.php');
\r
173 <?php require_once(AT_INCLUDE_PATH.'footer.inc.php'); ?>
\r