blob: 2ca99c1c44553edf91ed90978e71a66641588752 (
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
<?php
/**
* Create or edit a video
*
* @package ElggVideolist
*/
$variables = elgg_get_config('videolist');
$input = array();
foreach ($variables as $name => $type) {
$input[$name] = get_input($name);
if ($name == 'title') {
$input[$name] = strip_tags($input[$name]);
}
if ($type == 'tags') {
$input[$name] = string_to_tag_array($input[$name]);
}
}
// Get guids
$videolist_guid = (int)get_input('videolist_guid');
$container_guid = (int)get_input('container_guid');
elgg_make_sticky_form('videolist');
elgg_load_library('elgg:videolist');
if (!$input['video_url']) {
register_error(elgg_echo('videolist:error:no_url'));
forward(REFERER);
}
$parsed_url = videolist_parseurl($input['video_url']);
if(!$parsed) {
register_error(elgg_echo('videolist:error:invalid_url'));
}
if ($video_guid) {
$video = get_entity($video_guid);
if (!$video || !$video->canEdit()) {
register_error(elgg_echo('videolist:error:no_save'));
forward(REFERER);
}
$new_video = false;
} else {
$video = new ElggObject();
$video->subtype = 'videolist_item';
$new_video = true;
}
$input = array_merge($input, videolist_get_data($parsed_url));
if (sizeof($input) > 0) {
foreach ($input as $name => $value) {
$video->$name = $value;
}
}
$video->container_guid = $container_guid;
if ($video->save()) {
elgg_clear_sticky_form('videolist');
system_message(elgg_echo('videolist:saved'));
if ($new_video) {
add_to_river('river/object/videolist_item/create', 'create', elgg_get_logged_in_user_guid(), $video->guid);
}
forward($video->getURL());
} else {
register_error(elgg_echo('videolist:error:no_save'));
forward(REFERER);
}
|