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; }
public static function detectThumbnail($code) { if (!ATTACHMENTS_CLASS_VideoBridge::getInstance()->isActive()) { return null; } $prov = new VideoProviders($code); $provider = $prov->detectProvider(); $thumbUrl = $prov->getProviderThumbUrl($provider); if ($thumbUrl == VideoProviders::PROVIDER_UNDEFINED) { return null; } return $thumbUrl; }
/** * 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; }
/** * 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); $clip->description = $description; $clip->userId = OW::getUser()->getId(); $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'; $thumbUrl = $prov->getProviderThumbUrl($clip->provider); if ($thumbUrl != VideoProviders::PROVIDER_UNDEFINED) { $clip->thumbUrl = $thumbUrl; } $clip->thumbCheckStamp = time(); $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; }
public function cacheThumbnails($limit) { $clips = $this->clipDao->getUncachedThumbsClipsList($limit); if (!$clips) { return true; } foreach ($clips as $clip) { $prov = new VideoProviders($clip->code); if (!$clip->provider) { $clip->provider = $prov->detectProvider(); } $thumbUrl = $prov->getProviderThumbUrl($clip->provider); if ($thumbUrl != VideoProviders::PROVIDER_UNDEFINED) { $clip->thumbUrl = $thumbUrl; } $clip->thumbCheckStamp = time(); $this->clipDao->save($clip); } return true; }
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)); } } }