6b7a01c5288da3f844f6cdc0f08093a9a321e3ea
[atutor.git] / mods / photo_album / handler / delete.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 handles the delete image / comment operations\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         define('PATH', '../');\r
32         require_once (PATH.'define.php');\r
33         require_once (PATH.'include/data_func.php');\r
34         require_once (PATH.'include/general_func.php');\r
35         /* checks whether the user typed 'Yes' button or not \r
36          * If the user clicked 'Yes' to delete the data, delete it\r
37          */\r
38         if (($_POST['confirm']=='Yes') && ($_SESSION['pa']['mode']=='delete')){\r
39                 if ($_SESSION['pa']['completed']==true){\r
40                         if ($_SESSION['pa']['choose']==IMAGE){\r
41                                 if ($_SESSION['pa']['administrator_mode']==true){\r
42                                         $msg->addFeedback('pa_delete_image_success');\r
43                                         redirect('admin_image_list.php');\r
44                                 } else {\r
45                                         $msg->addFeedback('pa_delete_image_success');\r
46                                         redirect('index.php');\r
47                                 }\r
48                         } else {\r
49                                 redirect('view.php?image_id='.$_SESSION['pa']['image_id']);\r
50                         }\r
51                 } else {\r
52                 \r
53                 if ($_SESSION['pa']['choose']==IMAGE){\r
54                         $delete=delete_image($_SESSION['pa']['image_id'], $_SESSION['pa']['course_id']);\r
55                         if ($delete==true){\r
56                                 $_SESSION['pa']['completed']=true;\r
57                                 if ($_SESSION['pa']['administrator_mode']==true){\r
58                                         $msg->addFeedback('pa_delete_image_success');\r
59                                         redirect('admin_image_list.php');\r
60                                 } else {\r
61                                         $msg->addFeedback('pa_delete_image_success');\r
62                                         redirect('index.php');\r
63                                 }\r
64                         } else {\r
65                                 $msg->addError('pa_func_delete_image');\r
66                                 redirect('index.php');\r
67                         }\r
68                 } else if ($_SESSION['pa']['choose']==COMMENT){\r
69                         $delete=delete_blog($_SESSION['pa']['image_id'], $_SESSION['pa']['course_id'], $_SESSION['pa']['comment_id']);\r
70                         if ($delete==true){\r
71                                 $_SESSION['pa']['completed']=true;\r
72                                 $msg->addFeedback('pa_delete_comment_success');\r
73                                 redirect('view.php?image_id='.$_SESSION['pa']['image_id']);\r
74                         } else {\r
75                                 $msg->addError('pa_func_delete_blog');\r
76                                 redirect('index.php');\r
77                         }\r
78                 } else {\r
79                         $msg->addError('pa_var_unauthorized');\r
80                         redirect('index.php');\r
81                 }\r
82         }\r
83         } else {\r
84                 $msg->addError('pa_var_unauthorized');\r
85                 redirect('index.php');\r
86         }\r
87         \r
88 \r
89 ?>\r
90 \r
91 \r
92 <?php require_once(AT_INCLUDE_PATH.'footer.inc.php'); ?>\r