2 /***********************************************************************/
4 /***********************************************************************/
5 /* Copyright (c) 2002-2009 */
6 /* Adaptive Technology Resource Centre / Inclusive Design Institution */
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 /***********************************************************************/
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 include (AT_PA_INCLUDE.'lib.inc.php');
19 $_custom_css = $_base_path . AT_PA_BASENAME . 'module.css'; // use a custom stylesheet
21 $aid = intval($_GET['aid']);
22 $pid = intval($_GET['pid']);
23 if(isset($_POST['aid'])){
24 $aid = intval($_POST['aid']);
26 if(isset($_POST['pid'])){
27 $pid = intval($_POST['pid']);
31 $pa = new PhotoAlbum($aid);
34 if(!($pa->checkPhotoPriv($pid, $_SESSION['member_id']) || $pa->checkAlbumPriv($_SESSION['member_id']))){
35 $msg->addError("ACCESS_DENIED");
36 header('location: index.php');
43 $photos = array($pa->getPhotoInfo($pid));
45 $photos = $pa->getAlbumPhotos();
47 $album_info = $pa->getAlbumInfo();
50 $_pages[AT_PA_BASENAME.'albums.php?id='.$aid]['title'] = _AT('pa_albums') .' - '.$album_info['name'];
51 $_pages[AT_PA_BASENAME.'albums.php?id='.$aid]['parent'] = AT_PA_BASENAME.'index.php';
52 $_pages[AT_PA_BASENAME.'albums.php?id='.$aid]['children'] = array(
53 AT_PA_BASENAME.'edit_photos.php',
55 $_pages[AT_PA_BASENAME.'edit_photos.php']['parent'] = AT_PA_BASENAME.'albums.php?id='.$aid;
59 if(isset($_GET['org'])){
60 $_custom_head .= '<script type="text/javascript" src="'.AT_PA_BASENAME.'include/imageReorderer.js"></script>';
62 $_pages[AT_PA_BASENAME.'edit_photos.php']['title'] = _AT('pa_organize_photos');
64 if (isset($_POST['submit'])){
65 foreach($photos as $index=>$photo_array){
66 $ordering = $_POST['image_'.$photo_array['id']];
68 $result = $pa->editPhotoOrder($photo_array['id'], $ordering);
70 $msg->addError('PA_EDIT_PHOTO_FAILED');
76 include (AT_INCLUDE_PATH.'header.inc.php');
77 $savant->assign('album_info', $album_info);
78 $savant->assign('photos', $photos);
79 $savant->display('pa_organize_photos.tmpl.php');
80 include (AT_INCLUDE_PATH.'footer.inc.php');
85 if (isset($_POST['submit'])){
86 //update photo description
87 foreach($photos as $index=>$photo_array){
88 $alt_text = $_POST['alt_text_'.$photo_array['id']];
89 $description = $_POST['description_'.$photo_array['id']];
90 $deletion = $_POST['delete_'.$photo_array['id']];
91 //don't have to update description if it's deleted
92 if (isset($deletion)){
93 $pa->deletePhoto($photo_array['id']);
94 } elseif (isset($description)){
95 $result = $pa->editPhoto($photo_array['id'], $description, $alt_text);
98 $msg->addError('PA_EDIT_PHOTO_FAILED');
103 //update photo album.
104 if (isset($_POST['album_cover'])){
105 $result = $pa->editAlbumCover($_POST['album_cover']);
108 $msg->addError('PA_EDIT_PHOTO_FAILED');
113 if ($_POST['submit'] == 'ajax'){
114 //ajax, return 200 status
115 header('HTTP/1.1 200 OK');
118 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
119 if (admin_authenticate(AT_ADMIN_PRIV_PHOTO_ALBUM, true)) {
121 header('Location: index_admin.php');
124 header('Location: albums.php?id='.$aid);
126 } elseif (isset($_POST['cancel'])){
127 $msg->addFeedback('CANCELLED');
128 if (admin_authenticate(AT_ADMIN_PRIV_PHOTO_ALBUM, true)) {
130 header('Location: index_admin.php');
133 header('Location: albums.php?id='.$aid);
138 include (AT_INCLUDE_PATH.'header.inc.php');
139 $savant->assign('album_info', $album_info);
140 $savant->assign('photos', $photos);
141 $savant->display('pa_edit_photos.tmpl.php');
142 include (AT_INCLUDE_PATH.'footer.inc.php');