aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--actions/videolist/delete.php62
-rw-r--r--pages/videolist/edit.php75
-rw-r--r--start.php4
-rw-r--r--views/default/object/videolist_item.php7
-rw-r--r--views/default/videolist/group_module.php43
-rw-r--r--views/default/videolist/groupprofile_videolist.php47
6 files changed, 123 insertions, 115 deletions
diff --git a/actions/videolist/delete.php b/actions/videolist/delete.php
index 221109ec4..191d7546c 100644
--- a/actions/videolist/delete.php
+++ b/actions/videolist/delete.php
@@ -1,33 +1,39 @@
<?php
/**
- * Elgg Videolist Plugin -
- * This plugin allows users to delete videos
- *
- * @package Elgg
- * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
- * @author Prateek Choudhary <synapticfield@gmail.com>
- * @copyright Prateek Choudhary
- */
-// Make sure we're logged in (send us to the front page if not)
-gatekeeper();
+* Elgg videolist item delete
+*
+* @package ElggVideolist
+*/
-// Get input data
-$guid = (int) get_input('video');
+$guid = (int) get_input('guid');
-// Make sure we actually have permission to edit
-$video = get_entity($guid);
-if ($video->getSubtype() == "videolist" && $video->canEdit()) {
- // Get owning user
- $owner = get_entity($video->getOwner());
+$videolist_item = get_entity($guid);
+if (!$videolist_item->guid) {
+ register_error(elgg_echo("videolist:deletefailed"));
+ forward('videolist/all');
+}
- // Delete it!
- $rowsaffected = $video->delete();
- if ($rowsaffected > 0) {
- // Success message
- system_message(elgg_echo("videos:deleted"));
- } else {
- register_error(elgg_echo("videos:notdeleted"));
- }
- // Forward to the main video list page
- forward($_SERVER['HTTP_REFERER']);
-} \ No newline at end of file
+if (!$videolist_item->canEdit()) {
+ register_error(elgg_echo("videolist:deletefailed"));
+ forward($videolist_item->getURL());
+}
+
+$container = $videolist_item->getContainerEntity();
+$url = $videolist_item->getURL();
+
+if (!$videolist_item->delete()) {
+ register_error(elgg_echo("videolist:deletefailed"));
+} else {
+ system_message(elgg_echo("videolist:deleted"));
+}
+
+// we can't come back to video url because it's deleted
+if($url != REFERER) {
+ forward(REFERER);
+}
+
+if (elgg_instanceof($container, 'group')) {
+ forward("videolist/group/$container->guid/all");
+} else {
+ forward("videolist/owner/$container->username");
+}
diff --git a/pages/videolist/edit.php b/pages/videolist/edit.php
index cc06dd9c4..5ca1e4b64 100644
--- a/pages/videolist/edit.php
+++ b/pages/videolist/edit.php
@@ -1,43 +1,48 @@
<?php
/**
-* Elgg Edit Video
-*/
-
-require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
+ * Edit a videolist item
+ *
+ * @package ElggVideolist
+ */
gatekeeper();
-$video_file = (int) get_input('video');
-if ($video_file = get_entity($video_file)) {
-
- // Set the page owner
- $page_owner = page_owner_entity();
- if ($page_owner === false || is_null($page_owner)) {
- $container_guid = $video_file->container_guid;
- if (!empty($container_guid))
- if ($page_owner = get_entity($container_guid)) {
- set_page_owner($container_guid->guid);
- }
- if (empty($page_owner)) {
- $page_owner = $_SESSION['user'];
- set_page_owner($_SESSION['guid']);
- }
- }
-
- if ($video_file->canEdit()) {
- // set up breadcrumbs
- elgg_push_breadcrumb(elgg_echo('videolist:all'), elgg_get_site_url()."videolist/all.php");
- elgg_push_breadcrumb(sprintf(elgg_echo("videolist:user"),$page_owner->name), elgg_get_site_url()."videolist/".$page_owner->username);
- elgg_push_breadcrumb(sprintf(elgg_echo("videolist:edit")));
-
- $area1 = elgg_view('navigation/breadcrumbs');
- $area1 .= elgg_view_title($title = elgg_echo('videolist:edit'));
- $area2 = elgg_view("forms/edit",array('entity' => $video_file));
- $body = elgg_view_layout('one_column_with_sidebar', $area1.$area2, $area3);
- page_draw(elgg_echo("videolist:edit"), $body);
- }
-} else {
+$guid = (int) get_input('guid');
+$videolist_item = get_entity($guid);
+if (!$videolist_item) {
+ forward();
+}
+if (!$videolist_item->canEdit()) {
forward();
}
-?>
+$title = elgg_echo('videolist:edit');
+$container = get_entity($videolist_item->getContainerGUID());
+
+elgg_push_breadcrumb(elgg_echo('videolist'), "videolist/all");
+if(elgg_instanceof($container, 'user')){
+ elgg_push_breadcrumb($container->name, "videolist/owner/$container->username/");
+} else {
+ elgg_push_breadcrumb($container->name, "videolist/group/$container->guid/");
+}
+elgg_push_breadcrumb($videolist_item->title, $videolist_item->getURL());
+elgg_push_breadcrumb($title);
+
+elgg_set_page_owner_guid($container->guid);
+
+$form_vars = array();
+$body_vars = array('guid' => $guid);
+
+foreach(array_keys(elgg_get_config('videolist')) as $variable) {
+ $body_vars[$variable] = $videolist_item->$variable;
+}
+
+$content = elgg_view_form('videolist/edit', $form_vars, $body_vars);
+
+$body = elgg_view_layout('content', array(
+ 'content' => $content,
+ 'title' => $title,
+ 'filter' => '',
+));
+
+echo elgg_view_page($title, $body);
diff --git a/start.php b/start.php
index 2c21bec83..f0fe8253c 100644
--- a/start.php
+++ b/start.php
@@ -37,8 +37,8 @@ function videolist_init() {
'access_id' => 'access',
));
- //extend this plugin for groups
- elgg_extend_view('groups/tool_latest','videolist/groupprofile_videolist');
+ // extend group main page
+ elgg_extend_view('groups/tool_latest', 'videolist/group_module');
if (is_callable('register_notification_object')) {
register_notification_object('object', 'videolist', elgg_echo('videolist:new'));
diff --git a/views/default/object/videolist_item.php b/views/default/object/videolist_item.php
index f2543dd19..63f3e6334 100644
--- a/views/default/object/videolist_item.php
+++ b/views/default/object/videolist_item.php
@@ -22,7 +22,7 @@ $base_type = substr($mime, 0, strpos($mime,'/'));
$body = elgg_view('output/longtext', array('value' => $entity->description));
$owner_link = elgg_view('output/url', array(
- 'href' => "file/owner/$owner->username",
+ 'href' => "videolist/owner/$owner->username",
'text' => $owner->name,
));
$author_text = elgg_echo('byline', array($owner_link));
@@ -38,7 +38,7 @@ $comments_count = $entity->countComments();
if ($comments_count != 0) {
$text = elgg_echo("comments") . " ($comments_count)";
$comments_link = elgg_view('output/url', array(
- 'href' => $entity->getURL() . '#file-comments',
+ 'href' => $entity->getURL() . '#videolist-item-comments',
'text' => $text,
));
} else {
@@ -47,7 +47,7 @@ if ($comments_count != 0) {
$metadata = elgg_view_menu('entity', array(
'entity' => $vars['entity'],
- 'handler' => 'file',
+ 'handler' => 'videolist',
'sort_by' => 'priority',
'class' => 'elgg-menu-hz',
));
@@ -57,6 +57,7 @@ $subtitle = "$author_text $date $categories $comments_link";
// do not show the metadata and controls in widget view
if (elgg_in_context('widgets')) {
$metadata = '';
+ $excerpt = '';
}
if ($full && !elgg_in_context('gallery')) {
diff --git a/views/default/videolist/group_module.php b/views/default/videolist/group_module.php
new file mode 100644
index 000000000..0e0a1ab63
--- /dev/null
+++ b/views/default/videolist/group_module.php
@@ -0,0 +1,43 @@
+<?php
+/**
+ * Group videolist module
+ */
+
+$group = elgg_get_page_owner_entity();
+
+if ($group->videolist_enable == "no") {
+ return true;
+}
+
+$all_link = elgg_view('output/url', array(
+ 'href' => "videolist/group/$group->guid/all",
+ 'text' => elgg_echo('link:view:all'),
+));
+
+elgg_push_context('widgets');
+$options = array(
+ 'type' => 'object',
+ 'subtype' => 'videolist_item',
+ 'container_guid' => elgg_get_page_owner_guid(),
+ 'limit' => 6,
+ 'full_view' => false,
+ 'pagination' => false,
+);
+$content = elgg_list_entities($options);
+elgg_pop_context();
+
+if (!$content) {
+ $content = '<p>' . elgg_echo('videolist:none') . '</p>';
+}
+
+$new_link = elgg_view('output/url', array(
+ 'href' => "videolist/add/$group->guid",
+ 'text' => elgg_echo('videolist:add'),
+));
+
+echo elgg_view('groups/profile/module', array(
+ 'title' => elgg_echo('videolist:group'),
+ 'content' => $content,
+ 'all_link' => $all_link,
+ 'add_link' => $new_link,
+));
diff --git a/views/default/videolist/groupprofile_videolist.php b/views/default/videolist/groupprofile_videolist.php
deleted file mode 100644
index 33a22ab68..000000000
--- a/views/default/videolist/groupprofile_videolist.php
+++ /dev/null
@@ -1,47 +0,0 @@
-<?php
-/**
- * Elgg Video Plugin
- * This plugin allows users to create a library of videos for groups
- *
- * @package ElggProfile
- * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
- * @author Prateek Choudhary <synapticfield@gmail.com>
- * @copyright Prateek Choudhary
- */
-
-?>
-<div class="group_tool_widget video">
-<span class="group_widget_link"><a href="<?php echo $vars['url'] . "videolist/owned/" . page_owner_entity()->username; ?>"><?php echo elgg_echo('link:view:all')?></a></span>
-<h3><?php echo elgg_echo("videolist:group"); ?></h3>
-
-<?php
-
-//the number of files to display
-$number = (int) $vars['entity']->num_display;
-if (!$number)
- $number = 5;
-
-//get the user's files
-$videos = elgg_get_entities(array('types' => 'object', 'subtypes' => 'videolist', 'container_guids' => page_owner(), 'limit' => $number));
-
-//if there are some files, go get them
-if ($videos) {
- foreach($videos as $f){
- $mime = $f->mimetype;
- $owner = get_entity($f->getOwner());
- $numcomments = elgg_count_comments($f);
- echo "<div class='entity_listing clearfloat'>";
- echo "<div class='entity_listing_icon'><a href=\"{$vars['url']}videolist/watch/{$f->guid}\"><img src=\"".$f->thumbnail."\" border=\"0\" width=\"85\" /></a></div>";
- echo "<div class='entity_listing_info'>";
- echo "<p class='entity_title'><a href=\"{$vars['url']}videolist/watch/{$f->guid}\">" . $f->title ."</a></p><p class='entity_subtext'><a href=\"{$vars['url']}profile/{$owner->username}\">{$owner->name}</a> ";
- echo friendly_time($f->time_created) . "</p>";
- echo "</div></div>";
-
- }
-
-} else {
- $upload_video = $vars['url'] . "videolist/browse/" . page_owner_entity()->username;
- echo "<p class='margin_top'><a href=\"{$upload_video}\">" . elgg_echo("videolist:add") . "</a></p>";
-}
-echo "</div>";
-?>