Example #1
0
 public function addVideo($userId, $embed, $title, $description, $thumbnailUrl, $text, $addToFeed = true)
 {
     if (!$this->isActive()) {
         return null;
     }
     $title = empty($title) ? $text : $title;
     $title = empty($title) ? '' : $title;
     $description = empty($description) ? '' : $description;
     $clipService = VIDEO_BOL_ClipService::getInstance();
     $clip = new VIDEO_BOL_Clip();
     $clip->title = $title;
     $description = UTIL_HtmlTag::stripJs($description);
     $description = UTIL_HtmlTag::stripTags($description, array('frame', 'style'), array(), true);
     $clip->description = $description;
     $clip->userId = $userId;
     $clip->code = UTIL_HtmlTag::stripJs($embed);
     $prov = new VideoProviders($clip->code);
     $privacy = OW::getEventManager()->call('plugin.privacy.get_privacy', array('ownerId' => $clip->userId, 'action' => 'video_view_video'));
     $clip->provider = $prov->detectProvider();
     $clip->addDatetime = time();
     $clip->status = 'approved';
     $clip->privacy = mb_strlen($privacy) ? $privacy : 'everybody';
     $thumbUrl = empty($thumbnailUrl) ? $prov->getProviderThumbUrl($clip->provider) : $thumbnailUrl;
     if ($thumbUrl != VideoProviders::PROVIDER_UNDEFINED) {
         $clip->thumbUrl = $thumbUrl;
     }
     $clip->thumbCheckStamp = time();
     $clipId = $clipService->addClip($clip);
     if ($addToFeed) {
         // Newsfeed
         $event = new OW_Event('feed.action', array('pluginKey' => 'video', 'entityType' => 'video_comments', 'entityId' => $clipId, 'userId' => $clip->userId), array("content" => array("vars" => array("status" => $text))));
         OW::getEventManager()->trigger($event);
     }
     return $clipId;
 }
Example #2
0
 /**
  * Default action
  */
 public function index()
 {
     $language = OW::getLanguage();
     $clipService = VIDEO_BOL_ClipService::getInstance();
     $userId = OW::getUser()->getId();
     if (!OW::getUser()->isAuthorized('video', 'add')) {
         $status = BOL_AuthorizationService::getInstance()->getActionStatus('video', 'add');
         throw new AuthorizationException($status['msg']);
     }
     if (!($clipService->findUserClipsCount($userId) <= $clipService->getUserQuotaConfig())) {
         $this->assign('auth_msg', $language->text('video', 'quota_exceeded', array('limit' => $clipService->getUserQuotaConfig())));
     } else {
         $this->assign('auth_msg', null);
         $videoAddForm = new videoAddForm();
         $this->addForm($videoAddForm);
         if (OW::getRequest()->isPost() && $videoAddForm->isValid($_POST)) {
             $values = $videoAddForm->getValues();
             $code = $clipService->validateClipCode($values['code']);
             if (!mb_strlen($code)) {
                 OW::getFeedback()->warning($language->text('video', 'resource_not_allowed'));
                 $this->redirect();
             }
             $res = $videoAddForm->process();
             OW::getFeedback()->info($language->text('video', 'clip_added'));
             $this->redirect(OW::getRouter()->urlForRoute('view_clip', array('id' => $res['id'])));
         }
     }
     if (!OW::getRequest()->isAjax()) {
         OW::getNavigation()->activateMenuItem(OW_Navigation::MAIN, 'video', 'video');
     }
     OW::getDocument()->setHeading($language->text('video', 'page_title_add_video'));
     OW::getDocument()->setHeadingIconClass('ow_ic_video');
     OW::getDocument()->setTitle($language->text('video', 'meta_title_video_add'));
     OW::getDocument()->setDescription($language->text('video', 'meta_description_video_add'));
 }
Example #3
0
 /**
  * Adds video clip
  *
  * @return boolean
  */
 public function process()
 {
     $values = $this->getValues();
     $clipService = VIDEO_BOL_ClipService::getInstance();
     $clip = new VIDEO_BOL_Clip();
     $clip->title = htmlspecialchars($values['title']);
     $description = UTIL_HtmlTag::stripJs($values['description']);
     $description = UTIL_HtmlTag::stripTags($description, array('frame', 'style'), array(), true);
     $description = nl2br($description, true);
     $clip->description = $description;
     $clip->userId = OW::getUser()->getId();
     $clip->code = '<iframe src="' . (OW::getRouter()->getBaseUrl() . 'spvideo/proxy/Allmyvideos/pending/') . $values['token'] . '" width="540" height="315" frameborder="0"></iframe>';
     $privacy = OW::getEventManager()->call('plugin.privacy.get_privacy', array('ownerId' => $clip->userId, 'action' => 'video_view_video'));
     $clip->provider = 'allmyvideos';
     $clip->addDatetime = time();
     $clip->status = 'approved';
     $clip->privacy = mb_strlen($privacy) ? $privacy : 'everybody';
     $eventParams = array('pluginKey' => 'video', 'action' => 'add_video');
     if (OW::getEventManager()->call('usercredits.check_balance', $eventParams) === true) {
         OW::getEventManager()->call('usercredits.track_action', $eventParams);
     }
     if ($clipService->addClip($clip)) {
         SPVIDEOLITE_PRO_ALLMYVIDEOS_CLASS_Processing::processTemporaryUpload($values['token'], $values['filename']);
         BOL_TagService::getInstance()->updateEntityTags($clip->id, 'video', $values['tags']);
         return array('result' => true, 'id' => $clip->id);
     }
     return false;
 }
Example #4
0
 /**
  * Returns class instance
  *
  * @return VIDEO_BOL_ClipService
  */
 public static function getInstance()
 {
     if (null === self::$classInstance) {
         self::$classInstance = new self();
     }
     return self::$classInstance;
 }
Example #5
0
 /**
  * Class constructor
  *
  * @param array $params
  */
 public function __construct(array $params)
 {
     parent::__construct();
     $exclude = $params['exclude'];
     $itemsNum = $params['itemsNum'];
     $this->clipService = VIDEO_BOL_ClipService::getInstance();
     $userId = $this->clipService->findClipOwner($exclude);
     if (!$userId) {
         $this->setVisible(false);
     } else {
         $clips = $this->clipService->findUserClipsList($userId, 1, $itemsNum, $exclude);
         if (!$clips) {
             $this->setVisible(false);
         }
         $this->assign('clips', $clips);
     }
 }
Example #6
0
 /**
  * Class constructor
  *
  * @param array $params
  */
 public function __construct(array $params)
 {
     parent::__construct();
     $clipId = $params['id'];
     $this->clipService = VIDEO_BOL_ClipService::getInstance();
     $clip = $this->clipService->findClipById($clipId);
     $code = $this->clipService->validateClipCode($clip->code, $clip->provider);
     $code = $this->clipService->addCodeParam($code, 'wmode', 'transparent');
     $config = OW::getConfig();
     $playerWidth = $config->getValue('video', 'player_width');
     $playerHeight = $config->getValue('video', 'player_height');
     $code = $this->clipService->formatClipDimensions($code, $playerWidth, $playerHeight);
     if ($clip->provider == 'youtube') {
         $code = preg_replace('/src="([^"]+)"/i', 'src="$1?wmode=transparent&origin=http://ow"', $code);
     }
     $this->assign('clipCode', $code);
 }
 public function onDelete(OW_Event $event)
 {
     $params = $event->getParams();
     if ($params["entityType"] != self::ENTITY_TYPE) {
         return;
     }
     foreach ($params["entityIds"] as $entityId) {
         $this->service->deleteClip($entityId);
     }
 }
Example #8
0
 public function __construct($clipId)
 {
     parent::__construct();
     $videoEditForm = new GVIDEOVIEWER_CLASS_EditForm($clipId);
     $this->addForm($videoEditForm);
     $clip = VIDEO_BOL_ClipService::getInstance()->findClipById($clipId);
     $videoEditForm->getElement('id')->setValue($clip->id);
     $videoEditForm->getElement('title')->setValue($clip->title);
     $videoEditForm->getElement('description')->setValue($clip->description);
     $videoEditForm->getElement('code')->setValue($clip->code);
 }
Example #9
0
 public function getPageMenu($isMobile = 0)
 {
     $language = OW::getLanguage();
     $menuItems = array();
     if (OW::getPluginManager()->isPluginActive('videoplus') && $isMobile == 0) {
         $menuItems = VIDEOPLUS_BOL_Service::getInstance()->getMenu();
         $item = new BASE_MenuItem();
         $item->setLabel($language->text('ivideo', 'video_uploads'));
         $item->setUrl(OW::getRouter()->urlForRoute('ivideo_view_list', array('type' => 'latest')));
         $item->setKey('uploads');
         $item->setIconClass("ow_ic_video");
         if (OW::getConfig()->getValue('ivideo', 'makeUploaderMain') == '1') {
             array_unshift($menuItems, $item);
         } else {
             $item->setOrder(count($menuItems) + 1);
             array_push($menuItems, $item);
         }
         $menu = new BASE_CMP_ContentMenu($menuItems);
         return $menu;
     }
     if (!OW::getPluginManager()->isPluginActive('video')) {
         return FALSE;
     }
     $validLists = array('featured', 'latest', 'toprated', 'tagged');
     $classes = array('ow_ic_push_pin', 'ow_ic_clock', 'ow_ic_star', 'ow_ic_tag');
     if (!VIDEO_BOL_ClipService::getInstance()->findClipsCount('featured')) {
         array_shift($validLists);
         array_shift($classes);
     }
     $order = 0;
     foreach ($validLists as $type) {
         $item = new BASE_MenuItem();
         $item->setLabel($language->text('video', 'menu_' . $type));
         $item->setUrl(OW::getRouter()->urlForRoute('video_view_list', array('listType' => $type)));
         $item->setKey($type);
         $item->setIconClass($classes[$order]);
         $item->setOrder($order);
         array_push($menuItems, $item);
         $order++;
     }
     $item = new BASE_MenuItem();
     $item->setLabel($language->text('ivideo', 'video_uploads'));
     $item->setUrl(OW::getRouter()->urlForRoute('ivideo_view_list', array('type' => 'latest')));
     $item->setKey('uploads');
     $item->setIconClass("ow_ic_video");
     $item->setOrder($order);
     array_push($menuItems, $item);
     $menu = new BASE_CMP_ContentMenu($menuItems);
     return $menu;
 }
Example #10
0
 public function onInfoRender(OW_Event $event)
 {
     $language = OW::getLanguage();
     $params = $event->getParams();
     if ($params["entityType"] != HINT_BOL_Service::ENTITY_TYPE_USER) {
         return;
     }
     $userId = $params["entityId"];
     if ($params["key"] != "video-count") {
         return;
     }
     $count = VIDEO_BOL_ClipService::getInstance()->findUserClipsCount($userId);
     $url = OW::getRouter()->urlForRoute("video_user_video_list", array("user" => BOL_UserService::getInstance()->getUserName($userId)));
     $event->setData($language->text("hint", "info_vide_count", array("count" => $count, "url" => $url)));
 }
Example #11
0
 /**
  * Class constructor
  *
  * @param array $params
  */
 public function __construct(array $params)
 {
     parent::__construct();
     $listType = isset($params['type']) ? $params['type'] : '';
     $count = isset($params['count']) ? $params['count'] : 5;
     $tag = isset($params['tag']) ? $params['tag'] : '';
     $userId = isset($params['userId']) ? $params['userId'] : null;
     $this->clipService = VIDEO_BOL_ClipService::getInstance();
     $page = !empty($_GET['page']) && (int) $_GET['page'] ? abs((int) $_GET['page']) : 1;
     $clipsPerPage = $this->clipService->getClipPerPageConfig();
     if ($userId) {
         $clips = $this->clipService->findUserClipsList($userId, $page, $clipsPerPage);
         $records = $this->clipService->findUserClipsCount($userId);
     } else {
         if (strlen($tag)) {
             $clips = $this->clipService->findTaggedClipsList($tag, $page, $clipsPerPage);
             $records = $this->clipService->findTaggedClipsCount($tag);
         } else {
             $clips = $this->clipService->findClipsList($listType, $page, $clipsPerPage);
             $records = $this->clipService->findClipsCount($listType);
         }
     }
     $this->assign('listType', $listType);
     if ($clips) {
         $this->assign('no_content', null);
         $this->assign('clips', $clips);
         $userIds = array();
         foreach ($clips as $clip) {
             if (!in_array($clip['userId'], $userIds)) {
                 array_push($userIds, $clip['userId']);
             }
         }
         $names = BOL_UserService::getInstance()->getDisplayNamesForList($userIds);
         $this->assign('displayNames', $names);
         $usernames = BOL_UserService::getInstance()->getUserNamesForList($userIds);
         $this->assign('usernames', $usernames);
         // Paging
         $pages = (int) ceil($records / $clipsPerPage);
         $paging = new BASE_CMP_Paging($page, $pages, 10);
         $this->assign('paging', $paging->render());
         $this->assign('count', $count);
     } else {
         $this->assign('no_content', OW::getLanguage()->text('video', 'no_video_found'));
     }
 }
Example #12
0
 public function findUserVideos($userId, $start, $offset)
 {
     $clipDao = VIDEO_BOL_ClipDao::getInstance();
     $example = new OW_Example();
     $example->andFieldEqual('status', 'approved');
     $example->andFieldEqual('userId', $userId);
     $example->setOrder('`addDatetime` DESC');
     $example->setLimitClause($start, $offset);
     $list = $clipDao->findListByExample($example);
     $out = array();
     foreach ($list as $video) {
         $id = $video->id;
         $videoThumb = VIDEO_BOL_ClipService::getInstance()->getClipThumbUrl($id);
         $out[$id] = array('id' => $id, 'embed' => $video->code, 'title' => UTIL_String::truncate($video->title, 65, ' ...'), 'description' => UTIL_String::truncate($video->description, 130, ' ...'), 'thumb' => $videoThumb == 'undefined' ? null : $videoThumb, 'date' => UTIL_DateTime::formatDate($video->addDatetime), 'permalink' => OW::getRouter()->urlForRoute('view_clip', array('id' => $id)));
         $out[$id]['oembed'] = json_encode(array('type' => 'video', 'thumbnail_url' => $out[$id]['thumb'], 'html' => $out[$id]['embed'], 'title' => $out[$id]['title'], 'description' => $out[$id]['description']));
     }
     return $out;
 }
Example #13
0
 /**
  * Adds parameter to embed code
  *
  * @param string $code
  * @param string $name
  * @param string $value
  * @return string
  */
 public static function addCodeParam($code, $name = 'wmode', $value = 'transparent')
 {
     if (!ATTACHMENTS_CLASS_VideoBridge::getInstance()->isActive()) {
         return $code;
     }
     $out = VIDEO_BOL_ClipService::getInstance()->addCodeParam($code, $name, $value);
     $matches = array();
     if (preg_match("/<iframe[^>]*src=['\"]([^'\"]+)['\"]/i", !empty($out) ? $out : $code, $matches)) {
         $src = null;
         if (strpos($matches[1], "//") === 0) {
             $src = "http:" . $matches[1];
             $src = OW::getRequest()->buildUrlQueryString($src, array($name => $value));
             $src = substr($src, 5);
         } else {
             $src = OW::getRequest()->buildUrlQueryString($matches[1], array($name => $value));
         }
         $repl = preg_replace("/(<iframe[^>]*)src=['\"]([^'\"]+)['\"]/i", "\$1src=\"" . $src . "\"", $code);
     }
     return $repl;
 }
Example #14
0
 public function getService($pluginKey)
 {
     switch ($pluginKey) {
         case 'newsfeed':
             return NEWSFEED_BOL_Service::getInstance();
         case 'blogs':
             return PostService::getInstance();
         case 'groups':
             return GROUPS_BOL_Service::getInstance();
         case 'event':
             return EVENT_BOL_EventService::getInstance();
         case 'links':
             return LinkService::getInstance();
         case 'video':
             return VIDEO_BOL_ClipService::getInstance();
         case 'forum':
             return FORUM_BOL_ForumService::getInstance();
         case 'photo':
             return PHOTO_BOL_PhotoService::getInstance();
     }
 }
 public function collectSnippets(BASE_CLASS_EventCollector $event)
 {
     $language = OW::getLanguage();
     $params = $event->getParams();
     if ($params["entityType"] != SNIPPETS_CLASS_EventHandler::ENTITY_TYPE_USER) {
         return;
     }
     $userId = $params["entityId"];
     $preview = $params["preview"];
     $snippet = new SNIPPETS_CMP_Snippet(self::WIDGET_NAME, $userId);
     if ($preview) {
         $snippet->setLabel($language->text("snippets", "snippet_video_preview"));
         $snippet->setIconClass("ow_ic_video");
         $event->add($snippet);
         return;
     }
     // Privacy check
     $eventParams = array('action' => "video_view_video", 'ownerId' => $userId, 'viewerId' => OW::getUser()->getId());
     try {
         OW::getEventManager()->getInstance()->call('privacy_check_permission', $eventParams);
     } catch (RedirectException $exception) {
         return;
     }
     $service = VIDEO_BOL_ClipService::getInstance();
     $total = $service->findUserClipsCount($userId);
     $list = $service->findUserClipsList($userId, 1, 3);
     if (empty($list)) {
         return;
     }
     $images = array();
     foreach ($list as $clip) {
         $images[] = $clip["thumb"];
     }
     $url = OW::getRouter()->urlForRoute("video_user_video_list", array("user" => BOL_UserService::getInstance()->getUserName($userId)));
     $snippet->setImages($images);
     $snippet->setLabel($language->text("snippets", "snippet_video", array("count" => '<span class="ow_txt_value">' . $total . '</span>')));
     $snippet->setUrl($url);
     $event->add($snippet);
 }
Example #16
0
 public function ajaxUpdateVideo()
 {
     if (OW::getRequest()->isAjax()) {
         $clipId = (int) $_POST['id'];
         $form = new GVIDEOVIEWER_CLASS_EditForm($clipId);
         if ($form->isValid($_POST)) {
             $values = $form->getValues();
             $clip = $this->clipService->findClipById($clipId);
             if ($clip) {
                 $clip->title = htmlspecialchars($values['title']);
                 $description = UTIL_HtmlTag::stripJs($values['description']);
                 $description = UTIL_HtmlTag::stripTags($description, array('frame', 'style'), array(), true);
                 $clip->description = $description;
                 $clip->code = $values['code'];
                 if ($this->clipService->updateClip($clip)) {
                     BOL_TagService::getInstance()->updateEntityTags($clip->id, 'video', $values['tags']);
                     exit(json_encode(array('result' => true, 'id' => $clip->id)));
                 }
             }
         }
     }
 }
Example #17
0
 public function thumbsCacheProcess()
 {
     VIDEO_BOL_ClipService::getInstance()->cacheThumbnails(self::THUMBS_PER_RUN);
 }
Example #18
0
 /**
  * Updates video clip
  *
  * @return boolean
  */
 public function process()
 {
     $values = $this->getValues();
     $clipService = VIDEO_BOL_ClipService::getInstance();
     if ($values['id']) {
         $clip = $clipService->findClipById($values['id']);
         if ($clip) {
             $clip->title = htmlspecialchars($values['title']);
             $description = UTIL_HtmlTag::stripJs($values['description']);
             $description = UTIL_HtmlTag::stripTags($description, array('frame', 'style'), array(), true);
             $clip->description = $description;
             if ($clip->code != $values['code']) {
                 $prov = new VideoProviders($values['code']);
                 $clip->provider = $prov->detectProvider();
                 $thumbUrl = $prov->getProviderThumbUrl($clip->provider);
                 if ($thumbUrl != VideoProviders::PROVIDER_UNDEFINED) {
                     $clip->thumbUrl = $thumbUrl;
                 }
                 $clip->thumbCheckStamp = time();
             }
             $clip->code = UTIL_HtmlTag::stripJs($values['code']);
             if ($clipService->updateClip($clip)) {
                 BOL_TagService::getInstance()->updateEntityTags($clip->id, 'video', $values['tags']);
                 return array('result' => true, 'id' => $clip->id);
             }
         }
     } else {
         return array('result' => false, 'id' => null);
     }
     return false;
 }
Example #19
0
 private function prepareClipCode($code, $provider)
 {
     $clipService = VIDEO_BOL_ClipService::getInstance();
     $code = $clipService->validateClipCode($code, $provider);
     $code = $clipService->addCodeParam($code, 'wmode', 'transparent');
     $config = OW::getConfig();
     $playerWidth = $config->getValue('video', 'player_width');
     $playerHeight = $config->getValue('video', 'player_height');
     $code = $clipService->formatClipDimensions($code, $playerWidth, $playerHeight);
     return $code;
 }
Example #20
0
 /**
  * Marks clip as unfeatured
  * 
  * @param int $clipId
  * @return boolean
  */
 public function markUnfeatured($clipId)
 {
     $marked = $this->clipFeaturedDao->markUnfeatured($clipId);
     if ($marked) {
         VIDEO_BOL_ClipService::getInstance()->cleanListCache();
     }
     $event = new OW_Event(VIDEO_BOL_ClipService::EVENT_AFTER_EDIT, array('clipId' => $clipId));
     OW::getEventManager()->trigger($event);
     return $marked;
 }
Example #21
0
 private function prepareClipCode($code, $provider)
 {
     $clipService = VIDEO_BOL_ClipService::getInstance();
     $code = $clipService->validateClipCode($code, $provider);
     $code = $clipService->addCodeParam($code, 'wmode', 'transparent');
     return $code;
 }
 /**
  * Adds video clip
  *
  * @return boolean
  */
 public function process()
 {
     $language = OW::getLanguage();
     $data = $_POST['data'];
     $resp = array('result' => FALSE);
     $ids = array();
     foreach ($data as $key => $values) {
         $code = VIDEO_BOL_ClipService::getInstance()->validateClipCode($values["code"]);
         if (!BOL_TextFormatService::getInstance()->isCodeResourceValid($code)) {
             return array('result' => false, 'msg' => $language->text('video', 'resource_not_allowed'));
         }
         $clipId = $this->addClip($values);
         if ($clipId) {
             array_push($ids, $clipId);
         }
     }
     if (count($ids) > 1) {
         $resp['msg'] = $language->text('spvideolite', 'clips_added');
     } else {
         $resp['msg'] = $language->text('video', 'clip_added');
     }
     if (count($ids)) {
         $resp['result'] = TRUE;
         $resp['id'] = $ids;
         return $resp;
     }
     return false;
 }
Example #23
0
 /**
  * Adds video clip
  *
  * @return boolean
  */
 public function process()
 {
     $values = $this->getValues();
     $clipService = VIDEO_BOL_ClipService::getInstance();
     $clip = new VIDEO_BOL_Clip();
     $clip->title = htmlspecialchars($values['title']);
     $description = UTIL_HtmlTag::stripJs($values['description']);
     $description = UTIL_HtmlTag::stripTags($description, array('frame', 'style'), array(), true);
     $description = nl2br($description, true);
     $clip->description = $description;
     $clip->userId = OW::getUser()->getId();
     $clip->thumbUrl = preg_replace("#(http://|https://)#i", "//", $values['thumbnail']);
     $clip->code = UTIL_HtmlTag::stripJs($values['code']);
     $prov = new VideoProviders($clip->code);
     $privacy = OW::getEventManager()->call('plugin.privacy.get_privacy', array('ownerId' => $clip->userId, 'action' => 'video_view_video'));
     $clip->provider = $prov->detectProvider();
     $clip->addDatetime = time();
     $clip->status = 'approved';
     $clip->privacy = mb_strlen($privacy) ? $privacy : 'everybody';
     $eventParams = array('pluginKey' => 'video', 'action' => 'add_video');
     if (OW::getEventManager()->call('usercredits.check_balance', $eventParams) === true) {
         OW::getEventManager()->call('usercredits.track_action', $eventParams);
     }
     if ($clipService->addClip($clip)) {
         BOL_TagService::getInstance()->updateEntityTags($clip->id, 'video', $values['tags']);
         // Newsfeed
         $event = new OW_Event('feed.action', array('pluginKey' => 'video', 'entityType' => 'video_comments', 'entityId' => $clip->id, 'userId' => $clip->userId));
         OW::getEventManager()->trigger($event);
         return array('result' => true, 'id' => $clip->id);
     }
     return false;
 }
Example #24
0
<?php

/**
 * This software is intended for use with Oxwall Free Community Software http://www.oxwall.org/ and is
 * licensed under The BSD license.
 * ---
 * Copyright (c) 2011, Oxwall Foundation
 * All rights reserved.
 * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
 * following conditions are met:
 *
 *  - Redistributions of source code must retain the above copyright notice, this list of conditions and
 *  the following disclaimer.
 *
 *  - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
 *  the following disclaimer in the documentation and/or other materials provided with the distribution.
 *
 *  - Neither the name of the Oxwall Foundation nor the names of its contributors may be used to endorse or promote products
 *  derived from this software without specific prior written permission.
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
VIDEO_BOL_ClipService::getInstance()->cleanupPluginContent();
 public function addClip(OW_Event $e)
 {
     $params = $e->getParams();
     if (empty($params['userId']) || empty($params['title']) || empty($params['code'])) {
         $e->setData(array('result' => false));
     } else {
         $clipService = VIDEO_BOL_ClipService::getInstance();
         $clip = new VIDEO_BOL_Clip();
         $clip->title = htmlspecialchars($params['title']);
         if (!empty($params['description'])) {
             $clip->description = UTIL_HtmlTag::stripJs($params['description']);
             $clip->description = UTIL_HtmlTag::stripTags($clip->description, array('frame', 'style'), array(), true);
         }
         $clip->userId = $params['userId'];
         $privacy = OW::getEventManager()->call('plugin.privacy.get_privacy', array('ownerId' => $clip->userId, 'action' => 'video_view_video'));
         $clip->privacy = mb_strlen($privacy) ? $privacy : 'everybody';
         $prov = new VideoProviders($params['code']);
         $clip->provider = $prov->detectProvider();
         $clip->addDatetime = time();
         $clip->status = 'approved';
         $thumbUrl = $prov->getProviderThumbUrl($clip->provider);
         if ($thumbUrl != VideoProviders::PROVIDER_UNDEFINED) {
             $clip->thumbUrl = $thumbUrl;
         }
         $clip->thumbCheckStamp = time();
         $clip->code = $clipService->validateClipCode($params['code'], $clip->provider);
         if ($clipService->addClip($clip)) {
             BOL_AuthorizationService::getInstance()->trackAction('video', 'add');
             if (!empty($params['tags'])) {
                 BOL_TagService::getInstance()->updateEntityTags($clip->id, 'video', $params['tags']);
             }
             // Newsfeed
             $event = new OW_Event('feed.action', array('pluginKey' => 'video', 'entityType' => VIDEO_BOL_ClipService::ENTITY_TYPE, 'entityId' => $clip->id, 'userId' => $clip->userId));
             OW::getEventManager()->trigger($event);
             OW::getEventManager()->trigger(new OW_Event(VIDEO_BOL_ClipService::EVENT_AFTER_ADD, array('clipId' => $clip->id)));
             $status = $clipService->findClipById($clip->id)->status;
             $e->setData(array('result' => true, 'id' => $clip->id, "status" => $status));
         }
     }
 }
Example #26
0
 public function sosialSharingGetVideoInfo(OW_Event $event)
 {
     $params = $event->getParams();
     $data = $event->getData();
     $data['display'] = false;
     if (empty($params['entityId'])) {
         return;
     }
     if ($params['entityType'] == 'video') {
         $clipDto = VIDEO_BOL_ClipService::getInstance()->findClipById($params['entityId']);
         if (!empty($clipDto)) {
             $data['display'] = BOL_AuthorizationService::getInstance()->isActionAuthorizedForGuest('video', 'view') && $clipDto->privacy == 'everybody';
         }
         $event->setData($data);
     }
 }
Example #27
0
 public function __construct(array $params)
 {
     parent::__construct();
     $id = $params['videoId'];
     $this->clipService = VIDEO_BOL_ClipService::getInstance();
     $clip = $this->clipService->findClipById($id);
     if (!$clip) {
         throw new Redirect404Exception();
     }
     $contentOwner = (int) $this->clipService->findClipOwner($id);
     $language = OW_Language::getInstance();
     $description = $clip->description;
     $clip->description = UTIL_HtmlTag::autoLink($clip->description);
     $this->assign('clip', $clip);
     $is_featured = VIDEO_BOL_ClipFeaturedService::getInstance()->isFeatured($clip->id);
     $this->assign('featured', $is_featured);
     // is moderator
     $modPermissions = OW::getUser()->isAuthorized('video');
     $this->assign('moderatorMode', $modPermissions);
     $userId = OW::getUser()->getId();
     $ownerMode = $contentOwner == $userId;
     $this->assign('ownerMode', $ownerMode);
     if (!$ownerMode && !OW::getUser()->isAuthorized('video', 'view') && !$modPermissions) {
         $this->setTemplate(OW::getPluginManager()->getPlugin('base')->getCtrlViewDir() . 'authorization_failed.html');
         return;
     }
     $this->assign('auth_msg', null);
     // permissions check
     if (!$ownerMode && !$modPermissions) {
         $privacyParams = array('action' => 'video_view_video', 'ownerId' => $contentOwner, 'viewerId' => $userId);
         $event = new OW_Event('privacy_check_permission', $privacyParams);
         OW::getEventManager()->trigger($event);
     }
     $cmtParams = new BASE_CommentsParams('video', 'video_comments');
     $cmtParams->setEntityId($id);
     $cmtParams->setOwnerId($contentOwner);
     $cmtParams->setDisplayType(BASE_CommentsParams::DISPLAY_TYPE_BOTTOM_FORM_WITH_FULL_LIST);
     $videoCmts = new BASE_CMP_Comments($cmtParams);
     $this->addComponent('comments', $videoCmts);
     $videoRates = new BASE_CMP_Rate('video', 'video_rates', $id, $contentOwner);
     $this->addComponent('rate', $videoRates);
     $videoTags = new BASE_CMP_EntityTagCloud('video');
     $videoTags->setEntityId($id);
     $videoTags->setRouteName('view_tagged_list');
     $this->addComponent('tags', $videoTags);
     $this->assign('canEdit', false);
     $this->assign('canReport', false);
     $this->assign('canMakeFeature', false);
     OW::getLanguage()->addKeyForJs('video', 'tb_edit_clip');
     OW::getLanguage()->addKeyForJs('video', 'confirm_delete');
     OW::getLanguage()->addKeyForJs('video', 'mark_featured');
     OW::getLanguage()->addKeyForJs('video', 'remove_from_featured');
     OW::getLanguage()->addKeyForJs('base', 'approve');
     OW::getLanguage()->addKeyForJs('base', 'disapprove');
     $toolbar = array();
     $toolbarEvent = new BASE_CLASS_EventCollector('video.collect_video_toolbar_items', array('clipId' => $clip->id, 'clipDto' => $clip));
     OW::getEventManager()->trigger($toolbarEvent);
     foreach ($toolbarEvent->getData() as $toolbarItem) {
         array_push($toolbar, $toolbarItem);
     }
     if (OW::getUser()->isAuthenticated() && !$ownerMode) {
         array_push($toolbar, array('href' => 'javascript://', 'id' => 'btn-video-flag', 'label' => $language->text('base', 'flag')));
         $this->assign('canReport', true);
     }
     if ($ownerMode || $modPermissions) {
         array_push($toolbar, array('href' => OW::getRouter()->urlForRoute('edit_clip', array('id' => $clip->id)), 'label' => $language->text('base', 'edit')));
         array_push($toolbar, array('href' => 'javascript://', 'id' => 'clip-delete', 'label' => $language->text('base', 'delete')));
         $this->assign('canEdit', true);
     }
     if ($modPermissions) {
         if ($is_featured) {
             array_push($toolbar, array('href' => 'javascript://', 'id' => 'clip-mark-featured', 'rel' => 'remove_from_featured', 'label' => $language->text('video', 'remove_from_featured')));
             $this->assign('isFeature', true);
         } else {
             array_push($toolbar, array('href' => 'javascript://', 'id' => 'clip-mark-featured', 'rel' => 'mark_featured', 'label' => $language->text('video', 'mark_featured')));
             $this->assign('isFeature', false);
         }
         $this->assign('canMakeFeature', true);
         /*
         if ( $clip->status == 'approved' )
         {
             array_push($toolbar, array(
                 'href' => 'javascript://',
                 'id' => 'clip-set-approval-staus',
                 'rel' => 'disapprove',
                 'label' => $language->text('base', 'disapprove')
             ));
         }
         else
         {
             array_push($toolbar, array(
                 'href' => 'javascript://',
                 'id' => 'clip-set-approval-staus',
                 'rel' => 'approve',
                 'label' => $language->text('base', 'approve')
             ));
         }
         */
     }
     $this->assign('toolbar', $toolbar);
     /*
             $js = UTIL_JsGenerator::newInstance()
                     ->jQueryEvent('#btn-video-flag', 'click', 'OW.flagContent(e.data.entity, e.data.id, e.data.title, e.data.href, "video+flags");', array('e'),
                         array('entity' => 'video_clip', 'id' => $clip->id, 'title' => $clip->title, 'href' => OW::getRouter()->urlForRoute('view_clip', array('id' => $clip->id))
                     ));
     
             OW::getDocument()->addOnloadScript($js, 1001);
     */
     //avatar
     $avatar = BOL_AvatarService::getInstance()->getDataForUserAvatars(array($contentOwner), true, true, true, false);
     $this->assign('avatar', $avatar[$contentOwner]);
     /*
             $config = OW::getConfig();
             $lang = OW::getLanguage();
     
             $this->videoService = VIDEO_BOL_VideoService::getInstance();
             $this->videoAlbumService = VIDEO_BOL_VideoAlbumService::getInstance();
     
             $video = $this->videoService->findVideoById($videoId);
             $album = $this->videoAlbumService->findAlbumById($video->albumId);
             $this->assign('album', $album);
     $this->assign('video', $video);
     
             // is owner
             $contentOwner = $this->videoService->findVideoOwner($video->id);
             $userId = OW::getUser()->getId();
             $ownerMode = $contentOwner == $userId;
             $this->assign('ownerMode', $ownerMode);
     
             // is moderator
             $modPermissions = OW::getUser()->isAuthorized('video');
             $this->assign('moderatorMode', $modPermissions);
     
             $canView = true;
             if ( !$ownerMode && !$modPermissions && !OW::getUser()->isAuthorized('video', 'view') )
             {
                 $canView = false;
             }
     
             $this->assign('canView', $canView);
     $this->assign('canDownload', $config->getValue('gvideoviewer', 'can_users_to_download_videos'));
     
             $cmtParams = new BASE_CommentsParams('video', 'video_comments');
             $cmtParams->setEntityId($video->id);
             $cmtParams->setOwnerId($contentOwner);
             $cmtParams->setDisplayType(BASE_CommentsParams::DISPLAY_TYPE_BOTTOM_FORM_WITH_FULL_LIST);
     
             $videoCmts = new BASE_CMP_Comments($cmtParams);
             $this->addComponent('comments', $videoCmts);
     
             $videoRates = new BASE_CMP_Rate('video', 'video_rates', $video->id, $contentOwner);
             $this->addComponent('rate', $videoRates);
     
             $videoTags = new BASE_CMP_EntityTagCloud('video');
             $videoTags->setEntityId($video->id);
             $videoTags->setRouteName('view_tagged_video_list');
             $this->addComponent('tags', $videoTags);
     
             $description = $video->description;
             $video->description = UTIL_HtmlTag::autoLink($video->description);
     
             $this->assign('video', $video);
             $this->assign('url', $this->videoService->getVideoUrl($video->id));
             $this->assign('ownerName', BOL_UserService::getInstance()->getUserName($album->userId));
     
             $is_featured = VIDEO_BOL_VideoFeaturedService::getInstance()->isFeatured($video->id);
     
             if ( (int) $config->getValue('video', 'store_fullsize') && $video->hasFullsize )
             {
                 $this->assign('fullsizeUrl', $this->videoService->getVideoFullsizeUrl($video->id));
             }
             else
             {
                 $this->assign('fullsizeUrl', null);
             }
     
             $action = new BASE_ContextAction();
             $action->setKey('video-moderate');
     
             $context = new BASE_CMP_ContextAction();
             $context->addAction($action);
     
             $contextEvent = new BASE_CLASS_EventCollector('video.collect_video_context_actions', array(
                 'videoId' => $videoId,
                 'videoDto' => $video
             ));
     
             OW::getEventManager()->trigger($contextEvent);
     $this->assign('canEdit', false);
     $this->assign('canReport', false);
     $this->assign('canMakeFeature', false);
             foreach ( $contextEvent->getData() as $contextAction )
             {
     	
                 $action = new BASE_ContextAction();
                 $action->setKey(empty($contextAction['key']) ? uniqid() : $contextAction['key']);
                 $action->setParentKey('video-moderate');
                 $action->setLabel($contextAction['label']);
     
                 if ( !empty($contextAction['id']) )
                 {
                     $action->setId($contextAction['id']);
                 }
     
                 if ( !empty($contextAction['order']) )
                 {
                     $action->setOrder($contextAction['order']);
                 }
     
                 if ( !empty($contextAction['class']) )
                 {
                     $action->setClass($contextAction['class']);
                 }
     
                 if ( !empty($contextAction['url']) )
                 {
                     $action->setUrl($contextAction['url']);
                 }
     
                 $attributes = empty($contextAction['attributes']) ? array() : $contextAction['attributes'];
                 foreach ( $attributes as $key => $value )
                 {
                     $action->addAttribute($key, $value);
                 }
     
                 $context->addAction($action);
             }
     
             if ( $userId && !$ownerMode )
             {
                 $action = new BASE_ContextAction();
                 $action->setKey('flag');
                 $action->setParentKey('video-moderate');
                 $action->setLabel($lang->text('base', 'flag'));
                 $action->setId('btn-video-flag');
                 $action->addAttribute('rel', $videoId);
                 $action->addAttribute('url', OW::getRouter()->urlForRoute('view_video', array('id' => $video->id)));
     
                 $context->addAction($action);
     	$this->assign('canReport', true);
             }
     
             if ( $ownerMode || $modPermissions )
             {
                 $action = new BASE_ContextAction();
                 $action->setKey('edit');
                 $action->setParentKey('video-moderate');
                 $action->setLabel($lang->text('base', 'edit'));
                 $action->setId('btn-video-edit');
                 $action->addAttribute('rel', $videoId);
     
                 $context->addAction($action);
     
                 $action = new BASE_ContextAction();
                 $action->setKey('delete');
                 $action->setParentKey('video-moderate');
                 $action->setLabel($lang->text('base', 'delete'));
                 $action->setId('video-delete');
                 $action->addAttribute('rel', $videoId);
     
                 $context->addAction($action);
     	
     	$this->assign('canEdit', true);
             }
     
             if ( $modPermissions )
             {
                 if ( $is_featured )
                 {
                     $action = new BASE_ContextAction();
                     $action->setKey('unmark-featured');
                     $action->setParentKey('video-moderate');
                     $action->setLabel($lang->text('video', 'remove_from_featured'));
                     $action->setId('video-mark-featured');
                     $action->addAttribute('rel', 'remove_from_featured');
                     $action->addAttribute('video-id', $videoId);
     
                     $context->addAction($action);
     		$this->assign('isFeature', true);
                 }
                 else
                 {
                     $action = new BASE_ContextAction();
                     $action->setKey('mark-featured');
                     $action->setParentKey('video-moderate');
                     $action->setLabel($lang->text('video', 'mark_featured'));
                     $action->setId('video-mark-featured');
                     $action->addAttribute('rel', 'mark_featured');
                     $action->addAttribute('video-id', $videoId);
     
                     $context->addAction($action);
     		$this->assign('isFeature', false);
                 }
     	$this->assign('canMakeFeature', true);
             }
     
             $this->addComponent('contextAction', $context);
             $avatar = BOL_AvatarService::getInstance()->getDataForUserAvatars(array($contentOwner), true, true, true, false);
             $this->assign('avatar', $avatar[$contentOwner]);
     */
 }
Example #28
0
 private function __construct()
 {
     $this->originalClassInstance = VIDEO_BOL_ClipService::getInstance();
 }
Example #29
0
 /**
  * Adds vwvr clip
  *
  * @return boolean
  */
 public function process()
 {
     $values = $this->getValues();
     $clipService = VWVR_BOL_ClipService::getInstance();
     $clip = new VWVR_BOL_Clip();
     $clip->room_name = htmlspecialchars($values['room_name']);
     $description = UTIL_HtmlTag::stripJs($values['description']);
     $description = UTIL_HtmlTag::stripTags($description, array('frame', 'style'), array(), true);
     $clip->description = $description;
     $clip->userId = OW::getUser()->getId();
     $room_nameArr = explode("-", $_COOKIE["video_recorded"]);
     $room_namex = $room_nameArr[0];
     // title
     $recordingIdx = $room_nameArr[1];
     $clip->recordingId = "-" . $recordingIdx;
     $clip->title = $room_namex;
     //        $clip->code = UTIL_HtmlTag::stripJs($values['code']);
     //        $prov = new VideoProviders($clip->code);
     $privacy = OW::getEventManager()->call('plugin.privacy.get_privacy', array('ownerId' => $clip->userId, 'action' => 'videorecorder_view_video'));
     //        $clip->provider = $prov->detectProvider();
     $clip->addDatetime = time();
     $config = OW::getConfig();
     $status = $config->getValue('vwvr', 'status');
     $clip->status = $status;
     $clip->privacy = mb_strlen($privacy) ? $privacy : 'everybody';
     $eventParams = array('pluginKey' => 'vwvr', 'action' => 'add_vwvr');
     if (OW::getEventManager()->call('usercredits.check_balance', $eventParams) === true) {
         OW::getEventManager()->call('usercredits.track_action', $eventParams);
     }
     // add clip to video plugin
     $isVideoActive = OW::getPluginManager()->isPluginActive('video');
     if ($isVideoActive) {
         $clipServiceVideo = VIDEO_BOL_ClipService::getInstance();
         $clipVideo = new VIDEO_BOL_Clip();
         $clipVideo->title = htmlspecialchars($values['room_name']);
         $clipVideo->description = $description;
         $clipVideo->userId = OW::getUser()->getId();
         $clipVideo->code = '<iframe width="420" height="315" src="' . $config->getValue('vwvr', 'baseSwf_url') . 'streamplayer.swf?streamName=' . $room_namex . $clip->recordingId . '&serverRTMP=' . $config->getValue('vwvr', 'server') . '&templateURL=" frameborder="0" allowfullscreen="allowfullscreen"></iframe>';
         $prov = new VideoProviders($clipVideo->code);
         $clipVideo->provider = $prov->detectProvider();
         $privacy = OW::getEventManager()->call('plugin.privacy.get_privacy', array('ownerId' => $clipVideo->userId, 'action' => 'video_view_video'));
         $clipVideo->addDatetime = time();
         $clipVideo->status = 'approved';
         $clipVideo->privacy = mb_strlen($privacy) ? $privacy : 'everybody';
         $clipServiceVideo->addClip($clipVideo);
     }
     // videowhisper
     // get record path
     $recordPath = $config->getValue('vwvr', 'recordPath');
     $recordPathArr = explode('/', $recordPath);
     $recordPathArrCount = count($recordPathArr);
     for ($i = 1; $i < $recordPathArrCount; $i++) {
         $recorded .= "/" . $recordPathArr[$i];
         if (!is_dir($recorded)) {
             mkdir($recorded);
         }
     }
     // get streams directory
     $dirname = 'streams';
     if (file_exists('../../' . $dirname)) {
         $dir = '../../' . $dirname;
     } elseif (file_exists('../../../' . $dirname)) {
         $dir = '../../../' . $dirname;
     } elseif (file_exists('../../../../' . $dirname)) {
         $dir = '../../../../' . $dirname;
     } elseif (file_exists('../../../../../' . $dirname)) {
         $dir = '../../../../../' . $dirname;
     } elseif (file_exists('../../../../../../' . $dirname)) {
         $dir = '../../../../../../' . $dirname;
     }
     // $streamsPath = realpath($dir);
     $streamsPath = realpath("../" . $dir);
     // convert and copy, or just copy
     $filename = $_COOKIE["video_recorded"];
     $old = $streamsPath . "/streams/" . $filename;
     $new = $recordPath . "/" . $filename;
     $ffmpeg = trim(shell_exec('type -P ffmpeg'));
     if (empty($ffmpeg)) {
         copy($old . '.flv', $new . '.flv');
     } else {
         shell_exec($ffmpeg . ' -i ' . $old . '.flv -sameq -ar 22050 ' . $new . '.mp4');
     }
     if ($clipService->addClip($clip)) {
         BOL_TagService::getInstance()->updateEntityTags($clip->id, 'vwvr', TagsField::getTags($values['tags']));
         // Newsfeed
         $event = new OW_Event('feed.action', array('pluginKey' => 'vwvr', 'entityType' => 'vwvr_comments', 'entityId' => $clip->id, 'userId' => $clip->userId));
         OW::getEventManager()->trigger($event);
         return array('result' => true, 'id' => $clip->id);
     }
     return false;
 }