forked from SynapseTechnologies/BuckysRoom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
photo_album_edit.php
executable file
·72 lines (56 loc) · 2.32 KB
/
photo_album_edit.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
require(dirname(__FILE__) . '/includes/bootstrap.php');
//Getting Current User ID
if( !($userID = buckys_is_logged_in()) )
{
buckys_redirect('/index.php', MSG_NOT_LOGGED_IN_USER, MSG_TYPE_ERROR);
}
$albumID = isset($_REQUEST['albumID']) ? $_REQUEST['albumID'] : '';
if( !$albumID || !BuckysAlbum::checkAlbumOwner($albumID, $userID) )
{
buckys_redirect("/photo_albums.php", MSG_INVALID_REQUEST, MSG_TYPE_ERROR);
}
//Getting UserData from Id
$userData = BuckysUser::getUserData($profileID);
//Getting Album
$album = BuckysAlbum::getAlbum($albumID);
//Getting Photos
$myphotos = BuckysPost::getPhotosByUserID($userID, $userID, BuckysPost::INDEPENDENT_POST_PAGE_ID, true);
$albumPhotos = BuckysAlbum::getPhotos($albumID);
//Getting Album Photos
if( isset($_POST['action']) )
{
//Create New Album
if( $_POST['action'] == 'save-album' )
{
//If the album title is empty, throw error
//If the album title is empty, throw error
if( trim($_POST['album_name']) == '' )
{
buckys_redirect('/photo_album_edit.php?albumID=' . $_POST['albumID'], MSG_ALBUM_TITLE_EMPTY, MSG_TYPE_ERROR);
}
BuckysAlbum::updateAlbum($_POST['albumID'], trim($_POST['album_name']), $_POST['visibility'], $_POST['photos']);
buckys_redirect("/photo_album_edit.php?albumID=" . $_POST['albumID'], MSG_ALBUM_UPDATED);
}else if($_POST['action'] == 'remove-from-album' || $_POST['action'] == 'add-to-album'){
$photoID = $_POST['photoID'];
$photo = BuckysPost::getPostById($photoID);
//Check Photo Owner
if($photo['poster'] != $userID)
{
echo MSG_INVALID_REQUEST;
exit;
}
if($_POST['action'] == 'remove-from-album')
BuckysAlbum::removePhotoFromAlbum($albumID, $photoID); //Remove
else
BuckysAlbum::addPhotoToAlbum($albumID, $photoID); //Add
echo 'success';
exit;
}
}
buckys_enqueue_stylesheet('account.css');
buckys_enqueue_stylesheet('posting.css');
buckys_enqueue_javascript('album.js');
$BUCKYS_GLOBALS['content'] = 'photo_album_edit';
$BUCKYS_GLOBALS['title'] = "Edit Photo Album - BuckysRoom";
require(DIR_FS_TEMPLATE . $BUCKYS_GLOBALS['template'] . "/" . $BUCKYS_GLOBALS['layout'] . ".php");