remove old readme
[atutor.git] / docs / mods / _standard / photos / delete_comment.php
1 <?php
2 /***********************************************************************/
3 /* ATutor                                                                                                                          */
4 /***********************************************************************/
5 /* Copyright (c) 2002-2010                                             */
6 /* Inclusive Design Institute                                          */
7 /* http://atutor.ca                                                                                                        */
8 /*                                                                                                                                         */
9 /* This program is free software. You can redistribute it and/or           */
10 /* modify it under the terms of the GNU General Public License             */
11 /* as published by the Free Software Foundation.                                           */
12 /***********************************************************************/
13 // $Id$
14 $_user_location = 'public';
15 define('AT_INCLUDE_PATH', '../../../include/');
16 require (AT_INCLUDE_PATH.'vitals.inc.php');
17 include (AT_PA_INCLUDE.'classes/PhotoAlbum.class.php');
18
19 //validates if this is me/have the privilege to delete.
20 $pid = intval($_REQUEST['pid']);
21 $aid = intval($_REQUEST['aid']);
22 $comment_id = intval($_REQUEST['comment_id']);
23
24 //_pages
25 $_pages[AT_PA_BASENAME.'albums.php?id='.$aid]['title']    = _AT('pa_albums');
26 $_pages[AT_PA_BASENAME.'albums.php?id='.$aid]['parent']   = AT_PA_BASENAME.'index.php';
27 //$_pages[AT_PA_BASENAME.'albums.php?id='.$aid]['children'] = array(AT_PA_BASENAME.'photo.php');
28 $_pages[AT_PA_BASENAME.'photo.php?pid='.$pid.SEP.'aid='.$aid]['title']    = _AT('pa_photo');
29 $_pages[AT_PA_BASENAME.'photo.php?pid='.$pid.SEP.'aid='.$aid]['parent']    = AT_PA_BASENAME.'albums.php?id='.$aid;
30 $_pages[AT_PA_BASENAME.'delete_comment.php']['parent']    = AT_PA_BASENAME.'photo.php?pid='.$pid.SEP.'aid='.$aid;
31
32 //init
33 $pa = new PhotoAlbum($aid);
34
35 if ($pid==0){
36         //not a photo
37         $isPhoto = false;
38 } else {
39         $isPhoto = true;
40 }
41
42 //Check permission
43 //owner of comments and album owner can delete comments.
44 if (!$pa->checkCommentPriv($comment_id, $_SESSION['member_id'], $isPhoto) && 
45         !$pa->checkAlbumPriv($_SESSION['member_id'])){
46         $msg->addError('ACCESS_DENIED');
47         header('Location: index.php');
48         exit;
49 }
50
51 if ($_POST['submit_no']) {
52         $msg->addFeedback('CANCELLED');
53         if ($isPhoto){
54                 header('Location: photo.php?pid='.$pid.SEP.'aid='.$aid);
55         } else {
56                 header('Location: albums.php?id='.$aid);
57         }
58         exit;
59 }
60
61 if ($_POST['submit_yes']) {
62         //delete
63         if ($pid==0){
64                 //not a photo
65                 $pa->deleteComment($comment_id, false);
66                 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
67                 Header('Location: albums.php?id='.$aid);
68                 exit;
69         } else {
70                 $pa->deleteComment($comment_id, true);
71                 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
72                 Header('Location: photo.php?pid='.$pid.SEP.'aid='.$aid);
73                 exit;
74         }       
75 }
76
77 require(AT_INCLUDE_PATH.'header.inc.php');
78
79 $hidden_vars['comment_id'] = $comment_id;
80 $hidden_vars['aid'] = $aid;
81 $hidden_vars['pid'] = $pid;
82
83
84 $msg->addConfirm(array('PA_DELETE_COMMENT'), $hidden_vars);
85 $msg->printConfirm();
86
87 require(AT_INCLUDE_PATH.'footer.inc.php');
88 ?>