remove old readme
[atutor.git] / docs / mods / _standard / photos / include / edit_album.inc.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 if (!defined('AT_INCLUDE_PATH')) { exit; }
15
16 include (AT_PA_INCLUDE.'classes/PhotoAlbum.class.php');
17 include (AT_PA_INCLUDE.'lib.inc.php');
18
19 $aid = intval($_REQUEST['id']);
20 $pa = new PhotoAlbum($aid);
21
22 if (!$pa->checkAlbumPriv($_SESSION['member_id'])){
23         $msg->addError('ACCESS_DENIED');
24         header('location: index.php');
25         exit;
26 }
27
28 //Set pages/submenu
29 /*
30 if ($isadmin) {
31         //this is admin
32         $_pages[AT_PA_BASENAME.'edit_album.php']['parent']   = AT_PA_BASENAME.'index_admin.php';
33
34 }
35 */
36 $album_info = $pa->getAlbumInfo();
37
38 //handle Edit album info.
39 if(isset($_POST['submit'])){
40         $pa = new PhotoAlbum($_POST['aid']);    //new object
41         if (isset($_POST['album_type'])){
42                 $album_type     = (intval($_POST['album_type'])==AT_PA_TYPE_MY_ALBUM)?AT_PA_TYPE_MY_ALBUM:AT_PA_TYPE_COURSE_ALBUM;
43         } else {
44                 //default is "my album" 'cause normally user can't create course album.
45                 $album_type     = AT_PA_TYPE_MY_ALBUM;
46         }
47
48         //private or shared album?
49         if (isset($_POST['album_permission'])){
50                 $album_permission = ($_POST['album_permission']==AT_PA_SHARED_ALBUM)?AT_PA_SHARED_ALBUM:AT_PA_PRIVATE_ALBUM;
51         } else {
52                 $album_permission = AT_PA_PRIVATE_ALBUM;
53         }
54
55         if (isset($_POST['album_name']) && $_POST['album_name']!=''){
56                 //TODO: photo_id = 0, should default to use the first one after multi-file uploader works
57                 $result = $pa->editAlbum($_POST['album_name'], $_POST['album_location'], $_POST['album_description'], $album_type, $album_permission);
58
59                 if (!$result){
60                         $msg->addError('PA_EDIT_ALBUM_FAILED');
61                 }
62         } else {
63                 //album name can't be empty
64                 $msg->addError('EMPTY_ALBUM_NAME');
65
66         }
67         $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
68         if ($isadmin) {
69                 //if admin
70                 header('Location: '.AT_PA_INCLUDE.'../index_admin.php');
71                 exit;
72         } 
73         //header('Location: albums.php?id='.intval($_POST['aid']));
74         header('Location: index.php');
75         exit;
76 } elseif (isset($_POST['cancel'])){
77         $msg->addFeedback('CANCELLED');
78         if ($isadmin) {
79                 //if admin
80                 header('Location: '.AT_PA_INCLUDE.'../index_admin.php');
81                 exit;
82         }
83         header('Location: '.AT_PA_BASE);
84         exit;
85 }
86
87 //template goes here
88 $savant->assign('album_info', $album_info);
89 $savant->display('photos/pa_edit_album.tmpl.php');
90 ?>