changed git call from https to git readonly
[atutor.git] / mods / photo_album / handler / delete_begin.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 delete confirm message before deleting the image/comment\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_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
27 ?>\r
28 \r
29 <?php\r
30         define('PATH', '../');\r
31         require_once (PATH.'define.php');\r
32         require_once (PATH.'include/general_func.php');\r
33         require_once (PATH.'include/data_func.php');\r
34         require_once (PATH.'HTML/Template/ITX.php');\r
35         \r
36         $template= new HTML_Template_ITX("../Template");\r
37         if ($_POST['mode']=='delete'){\r
38                 /* delete image */\r
39                 if ($_POST['choose']==IMAGE){\r
40                         $auth=user_own(IMAGE, $_SESSION['pa']['image_id'], $_SESSION['pa']['course_id']);\r
41                         if (!$auth){\r
42                                 $msg->addError('pa_user_image_not_allowed');\r
43                                 redirect('../view.php?image_id='.$_SESSION['pa']['image_id']);\r
44                         } else {\r
45                                 $_SESSION['pa']['mode']='delete';\r
46                                 $_SESSION['pa']['choose']=IMAGE;\r
47                                 $data_array=get_single_data(IMAGE,$_SESSION['pa']['image_id'], $_SESSION['pa']['course_id']);\r
48                                                 \r
49                                 /* display the image delete confirm here. */\r
50                                 $template->loadTemplatefile("delete_confirm.tpl.php");\r
51                                 $template->setVariable("MESSAGE", _AT('pa_tag_image_delete_confirm'));\r
52                                 $template->setVariable("CONFIRM_FORM", "delete_image");\r
53                                 $template->setVariable("CONFIRM_ACTION", DELETE_ACTION);\r
54                                 $template->setVariable("CONFIRM_DISPLAY", _AT('yes'));\r
55                                 $template->setVariable("CANCEL_FORM", "cancel_image");\r
56                                 $template->setVariable("CANCEL_ACTION", BASE_PATH.'view.php?image_id='.$_SESSION['pa']['image_id']);\r
57                                 $template->setVariable("CANCEL_DISPLAY", _AT('no'));\r
58                                 \r
59                                 $template->setCurrentBlock("IMAGE_DISPLAY");\r
60                                 $template->setVariable("ALT", $data_array['alt']);\r
61                                 $image_src=$get_file.$data_array['location'].urlencode($data_array['thumb_image_name']);\r
62                                 $template->setVariable("IMAGE_SRC", $image_src);\r
63                                 $template->parseCurrentBlock("IMAGE_DISPLAY");\r
64                                 \r
65                                 $member_name=get_member_name($data_array['login']);\r
66                                 $template->setCurrentBlock("TABLE");\r
67                                 $template->setVariable("NAME_STRING", _AT('name'));\r
68                                 $template->setVariable("NAME", $member_name);\r
69                                 $template->setVariable("DESC", convert_newlines($data_array['description']));\r
70                                 $template->setVariable("DATE_STRING", _AT('date'));\r
71                                 $template->setVariable("DATE", $data_array['date']);\r
72                                 $template->parseCurrentBlock("TABLE");\r
73                                 $template->parseCurrentBlock();\r
74                                 $template->show();\r
75                         }\r
76                         /* delete comment */\r
77                 } else if ($_POST['choose']==COMMENT){\r
78                         $auth=user_own(COMMENT, $_SESSION['pa']['image_id'], $_SESSION['pa']['course_id'], $_POST['comment_id']);\r
79                         If (!$auth){\r
80                                 $msg->addError('pa_user_comment_not_allowed');\r
81                                 redirect('view.php?image_id='.$_SESSION['pa']['image_id']);\r
82                         } else {\r
83                                 $_SESSION['pa']['mode']='delete';\r
84                                 $_SESSION['pa']['choose']=COMMENT;\r
85                                 $_SESSION['pa']['comment_id']=$_POST['comment_id'];\r
86                                 $data_array=get_single_data(COMMENT, $_SESSION['pa']['image_id'], $_SESSION['pa']['course_id'], $_SESSION['pa']['comment_id']);\r
87                                 \r
88                                 /* display comment delete confirm here */\r
89                                 $template->loadTemplatefile("delete_confirm.tpl.php");\r
90                                 $template->setVariable("MESSAGE", _AT('pa_tag_comment_delete_confirm'));\r
91                                 $template->setVariable("CONFIRM_FORM", "blog_confirm");\r
92                                 $template->setVariable("CONFIRM_ACTION", DELETE_ACTION);\r
93                                 $template->setVariable("CONFIRM_DISPLAY", _AT('yes'));\r
94                                 $template->setVariable("CANCEL_FORM", "blog_cancel");\r
95                                 $template->setVariable("CANCEL_ACTION", BASE_PATH.'view.php?image_id='.$_SESSION['pa']['image_id']);\r
96                                 $template->setVariable("CANCEL_DISPLAY", _AT('no'));\r
97                                 \r
98                                 $member_name=get_member_name($data_array['login']);\r
99                                 $template->setCurrentBlock("TABLE");\r
100                                 $template->setVariable("NAME_STRING", _AT('name'));\r
101                                 $template->setVariable("NAME", $member_name);\r
102                                 $template->setVariable("DESC", convert_newlines($data_array['comment']));       \r
103                                 $template->setVariable("DATE_STRING", _AT('date'));\r
104                                 $template->setVariable("DATE", $data_array['date']);\r
105                                 $template->parseCurrentBlock("TABLE");\r
106                                 $template->parseCurrentBlock();\r
107                                 $template->show();\r
108                         }\r
109                 } else {\r
110                         $msg->addError('pa_var_unauthorized');\r
111                         redirect('index.php');\r
112                 }\r
113         } else {\r
114                 $msg->addError('pa_var_unauthorized');\r
115                 redirect('index.php');\r
116         }\r
117 ?>\r
118 \r
119 <?php require_once(AT_INCLUDE_PATH.'footer.inc.php'); ?>