remove old readme
[atutor.git] / docs / mods / _standard / photos / delete_photo.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_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php');     //clr_dir()
18 //include (AT_INCLUDE_PATH.'lib/filemanager.inc.php');  //clr_dir()
19 include (AT_PA_INCLUDE.'lib.inc.php');  //album_filepath
20 include (AT_PA_INCLUDE.'classes/PhotoAlbum.class.php');
21
22 //validates if this is me/have the privilege to delete.
23 $pid = intval($_REQUEST['pid']);
24 $aid = intval($_REQUEST['aid']);
25
26 //_pages
27 $_pages[AT_PA_BASENAME.'albums.php?id='.$aid]['title']    = _AT('pa_albums');
28 $_pages[AT_PA_BASENAME.'albums.php?id='.$aid]['parent']   = AT_PA_BASENAME.'index.php';
29 //$_pages[AT_PA_BASENAME.'albums.php?id='.$aid]['children'] = array(AT_PA_BASENAME.'photo.php');
30 $_pages[AT_PA_BASENAME.'photo.php?pid='.$pid.SEP.'aid='.$aid]['title']    = _AT('pa_photo');
31 $_pages[AT_PA_BASENAME.'photo.php?pid='.$pid.SEP.'aid='.$aid]['parent']    = AT_PA_BASENAME.'albums.php?id='.$aid;
32 $_pages[AT_PA_BASENAME.'delete_photo.php']['parent']    = AT_PA_BASENAME.'photo.php?pid='.$pid.SEP.'aid='.$aid;
33
34
35 //init
36 $pa = new PhotoAlbum($aid);
37
38 if ($pid<1 || $aid <1){
39         $msg->addError('PA_PHOTO_NOT_FOUND');   //no such picture
40         header('Location: index.php');
41         exit;
42 } elseif (!$pa->checkPhotoPriv($pid, $_SESSION['member_id']) && !$pa->checkAlbumPriv($_SESSION['member_id'])){
43         $msg->addError('ACCESS_DENIED');
44         header('Location: albums.php?id='.$aid);
45         exit;
46
47
48 if ($_POST['submit_no']) {
49         $msg->addFeedback('CANCELLED');
50         Header('Location: photo.php?aid='.$aid.SEP.'pid='.$pid);
51         exit;
52 }
53
54 if ($_POST['submit_yes']) {
55         //delete
56         $pa->deletePhoto($pid);
57
58         $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
59         header('Location: albums.php?id='.$aid);
60         exit;
61 }
62
63 require(AT_INCLUDE_PATH.'header.inc.php');
64
65 $hidden_vars['pid'] = $pid;
66 $hidden_vars['aid'] = $aid;
67
68 $msg->addConfirm(array('PA_DELETE_PHOTO'), $hidden_vars);
69 $msg->printConfirm();
70
71 require(AT_INCLUDE_PATH.'footer.inc.php');
72 ?>