public function __construct() { $editor = getInput("editor_id"); // Check if General album exists $album = getEntity(array("type" => "Videoalbum", "metadata_name_value_pairs" => array(array("name" => "owner_guid", "value" => getLoggedInUserGuid()), array("name" => "title", "value" => "General")))); $logged_in_user = getLoggedInUser(); $logged_in_user_guid = $logged_in_user->guid; $title = getInput("title"); $description = getInput("description"); if (!file_exists($_FILES['video_file']['tmp_name']) || !is_uploaded_file($_FILES['video_file']['tmp_name'])) { $video_type = "youtube"; } else { $video_type = "upload"; } $video = new Video(); $video->video_type = $video_type; $video->title = $title; $video->description = $description; $video->owner_guid = getLoggedInUserGuid(); $video->access_id = getInput("access_id"); $video->save(); if ($video_type == "youtube") { $video->url = getInput("url"); } else { $guid = VideosPlugin::processUploadedVideo("video_file", $video); $video->video_guid = $guid; $video->save(); $video->createAvatar(); } $video->save(); new Activity(getLoggedInUserGuid(), "activity:video:add", array(getLoggedInUser()->getURL(), getLoggedInUser()->full_name, $video->getURL(), $video->title, $video->getURL(), $video->icon(LARGE, "img-responsive"))); new SystemMessage("Your video has been uploaded."); if (!$album) { $album = new Videoalbum(); $album->title = "General"; $album->owner_guid = getLoggedInUserGuid(); $album->save(); } $video->container_guid = $album->guid; $video->save(); forward(false, array("insertvideo" => $video->guid, "editor" => $editor)); }
public function __construct() { $logged_in_user = getLoggedInUser(); $logged_in_user_guid = $logged_in_user->guid; $container_guid = getInput("container_guid"); $title = getInput("title"); $description = getInput("description"); if (isset($_FILES) && !empty($_FILES)) { $video_type = "upload"; } else { $video_type = "youtube"; } if ($video_type == "youtube" && !getInput("url")) { forward(); } $video = new Video(); $video->video_type = $video_type; $video->title = $title; $video->description = $description; $video->container_guid = $container_guid; $video->owner_guid = getLoggedInUserGuid(); $video->access_id = getInput("access_id"); if ($video_type == "youtube") { $video->url = getInput("url"); } else { $guid = VideosPlugin::processUploadedVideo("video_file", $video); $video->video_guid = $guid; $video->save(); $video->createAvatar(); } $video->save(); new Activity(getLoggedInUserGuid(), "activity:video:add", array(getLoggedInUser()->getURL(), getLoggedInUser()->full_name, $video->getURL(), $video->title, $video->getURL(), $video->icon(LARGE, "img-responsive", NULL, NULL, false))); new SystemMessage("Your video has been uploaded."); $album = getEntity($container_guid); forward($album->getURL()); }