aboutsummaryrefslogtreecommitdiff
path: root/pages/photos/image/upload.php
blob: 7d9db5ed8e2252a641617a8cb75e6d494ec9fba2 (plain)
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
<?php
/**
 * Upload images
 *
 * @author Cash Costello
 * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2
 */

gatekeeper();

$album_guid = (int) get_input('guid');
if (!$album_guid) {
	// @todo
	forward();
}

if (elgg_get_plugin_setting('uploader', 'tidypics') != "disabled") {
	$uploader = get_input('uploader', 'ajax');
} else {
	$uploader = 'basic';
}

$album = get_entity($album_guid);
if (!$album) {
	// @todo
	// throw warning and forward to previous page
	forward(REFERER);
}

if (!$album->getContainerEntity()->canWriteToContainer()) {
	// @todo have to be able to edit album to upload photos
	forward(REFERER);
}

// set page owner based on container (user or group)
elgg_set_page_owner_guid($album->getContainerGUID());
$owner = elgg_get_page_owner_entity();

$title = elgg_echo('album:addpix');

// set up breadcrumbs
elgg_push_breadcrumb(elgg_echo('photos'), "photos/all");
elgg_push_breadcrumb($owner->name, "photos/owner/$owner->username");
elgg_push_breadcrumb($album->getTitle(), $album->getURL());
elgg_push_breadcrumb(elgg_echo('album:addpix'));


if ($uploader == 'basic') {
	$content = elgg_view('forms/photos/basic_upload', array('entity' => $album));
} else {
	$content = elgg_view('forms/photos/ajax_upload', array('entity' => $album));
}

$body = elgg_view_layout('content', array(
	'content' => $content,
	'title' => $title,
	'filter' => '',
));

echo elgg_view_page($title, $body);