2 /***********************************************************************/
4 /***********************************************************************/
5 /* Copyright (c) 2002-2010 */
6 /* Inclusive Design Institute */
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 /***********************************************************************/
16 include (AT_PA_INCLUDE.'classes/PhotoAlbum.class.php');
17 include (AT_PA_INCLUDE.'lib.inc.php');
19 $aid = intval($_GET['aid']);
20 $pid = intval($_GET['pid']);
21 if(isset($_POST['aid'])){
22 $aid = intval($_POST['aid']);
24 if(isset($_POST['pid'])){
25 $pid = intval($_POST['pid']);
29 $pa = new PhotoAlbum($aid);
32 if(!($pa->checkPhotoPriv($pid, $_SESSION['member_id']) || $pa->checkAlbumPriv($_SESSION['member_id']))){
33 $msg->addError("ACCESS_DENIED");
34 header('location: index.php');
41 $photos = array($pa->getPhotoInfo($pid));
43 $photos = $pa->getAlbumPhotos();
45 $album_info = $pa->getAlbumInfo();
49 $_pages[AT_PA_BASENAME.'albums.php?id='.$aid]['title'] = _AT('pa_albums') .' - '.$album_info['name'];
50 $_pages[AT_PA_BASENAME.'albums.php?id='.$aid]['parent'] = AT_PA_BASENAME.'index.php';
51 $_pages[AT_PA_BASENAME.'albums.php?id='.$aid]['children'] = array(
52 AT_PA_BASENAME.'edit_photos.php',
54 $_pages[AT_PA_BASENAME.'edit_photos.php']['parent'] = AT_PA_BASENAME.'albums.php?id='.$aid;
56 $_pages[AT_PA_BASENAME.'albums.php?id='.$aid]['parent'] = AT_PA_BASENAME.'index_admin.php';
62 if (isset($_POST['submit'])){
63 //update photo description
64 foreach($photos as $index=>$photo_array){
65 $alt_text = $_POST['alt_text_'.$photo_array['id']];
66 $description = $_POST['description_'.$photo_array['id']];
67 $deletion = $_POST['delete_'.$photo_array['id']];
68 //don't have to update description if it's deleted
69 if (isset($deletion)){
70 $pa->deletePhoto($photo_array['id']);
71 } elseif (isset($description)){
72 $result = $pa->editPhoto($photo_array['id'], $description, $alt_text);
75 $msg->addError('PA_EDIT_PHOTO_FAILED');
81 if (isset($_POST['album_cover'])){
82 $result = $pa->editAlbumCover($_POST['album_cover']);
85 $msg->addError('PA_EDIT_PHOTO_FAILED');
90 if ($_POST['submit'] == 'ajax'){
91 //ajax, return 200 status
92 header('HTTP/1.1 200 OK');
95 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
98 header('Location: '.AT_PA_INCLUDE.'../index_admin.php');
101 header('Location: albums.php?id='.$aid);
103 } elseif (isset($_POST['cancel'])){
104 $msg->addFeedback('CANCELLED');
107 header('Location: '.AT_PA_INCLUDE.'../index_admin.php');
110 header('Location: albums.php?id='.$aid);
115 $savant->assign('album_info', $album_info);
116 $savant->assign('photos', $photos);
117 $savant->display('photos/pa_edit_photos.tmpl.php');