/** * Will anipulate a single entry */ public function execute() { $this->forceSystemAuthentication(); myDbHelper::$use_alternative_con = null; $command = $this->getP("command"); if ($command == "updateEntry") { $id = $this->getP("id"); $entry = entryPeer::retrieveByPK($id); if ($entry) { $name = $this->getP("name"); $value = $this->getP("value"); $obj_wrapper = objectWrapperBase::getWrapperClass($entry, 0); $updateable_fields = $obj_wrapper->getUpdateableFields("2"); if (!in_array($name, $updateable_fields)) { die; } if ($name) { $setter = "set" . $name; call_user_func(array($entry, $setter), $value); $entry->save(); } } } die; }
public function postUpdate(PropelPDO $con = null) { parent::postUpdate($con); categoryPeer::setUseCriteriaFilter(false); $category = categoryPeer::retrieveByPK($this->getCategoryId()); categoryPeer::setUseCriteriaFilter(true); if (!$category) { throw new kCoreException('category id [' . $this->getCategoryId() . 'was not found', kCoreException::ID_NOT_FOUND); } $entry = entryPeer::retrieveByPK($this->getEntryId()); if (!$entry && $this->getStatus() != CategoryEntryStatus::DELETED) { throw new kCoreException('entry id [' . $this->getEntryId() . 'was not found', kCoreException::ID_NOT_FOUND); } if ($entry && $this->getStatus() == CategoryEntryStatus::ACTIVE && $this->getColumnsOldValue(categoryEntryPeer::STATUS) == CategoryEntryStatus::PENDING) { $entry = $this->setEntryOnCategory($category, $entry); } if ($this->getStatus() == CategoryEntryStatus::REJECTED && $this->getColumnsOldValue(categoryEntryPeer::STATUS) == CategoryEntryStatus::PENDING) { $category->decrementPendingEntriesCount(); } if ($this->getStatus() == CategoryEntryStatus::PENDING && $this->getColumnsOldValue(categoryEntryPeer::STATUS) == CategoryEntryStatus::REJECTED) { $category->incrementPendingEntriesCount(); } if ($this->getStatus() == CategoryEntryStatus::DELETED) { if ($this->getColumnsOldValue(categoryEntryPeer::STATUS) == CategoryEntryStatus::ACTIVE) { $category->decrementEntriesCount($this->getEntryId()); $category->decrementDirectEntriesCount($this->getEntryId()); if ($entry && !categoryEntryPeer::getSkipSave()) { $categories = array(); if (trim($entry->getCategories()) != '') { $categories = explode(entry::ENTRY_CATEGORY_SEPARATOR, $entry->getCategories()); foreach ($categories as $index => $entryCategoryFullName) { if ($entryCategoryFullName == $category->getFullName()) { unset($categories[$index]); } } } $categoriesIds = array(); if (trim($entry->getCategoriesIds()) != '') { $categoriesIds = explode(entry::ENTRY_CATEGORY_SEPARATOR, $entry->getCategoriesIds()); foreach ($categories as $index => $entryCategoryId) { if ($entryCategoryId == $category->getId()) { unset($categoriesIds[$index]); } } } $entry->setCategories(implode(entry::ENTRY_CATEGORY_SEPARATOR, $categories)); $entry->setCategoriesIds(implode(entry::ENTRY_CATEGORY_SEPARATOR, $categoriesIds)); $entry->save(); } kEventsManager::raiseEvent(new kObjectDeletedEvent($this)); } if ($this->getColumnsOldValue(categoryEntryPeer::STATUS) == CategoryEntryStatus::PENDING) { $category->decrementPendingEntriesCount(); } } $category->save(); if ($entry && !categoryEntryPeer::getSkipSave()) { $entry->indexToSearchIndex(); } }
public function getLocalThumbFilePath($version, $width, $height, $type, $bgcolor = "ffffff", $crop_provider = null, $quality = 0, $src_x = 0, $src_y = 0, $src_w = 0, $src_h = 0, $vid_sec = -1, $vid_slice = 0, $vid_slices = -1, $density = 0, $stripProfiles = false, $flavorId = null, $fileName = null) { if ($this->getStatus() == entryStatus::DELETED || $this->getModerationStatus() == moderation::MODERATION_STATUS_BLOCK) { KalturaLog::log("rejected live stream entry - not serving thumbnail"); KExternalErrors::dieError(KExternalErrors::ENTRY_DELETED_MODERATED); } $contentPath = myContentStorage::getFSContentRootPath(); $liveEntryExist = false; $liveThumbEntry = null; $liveThumbEntryId = null; $partner = $this->getPartner(); if ($partner) { $liveThumbEntryId = $partner->getLiveThumbEntryId(); } if ($liveThumbEntryId) { $liveThumbEntry = entryPeer::retrieveByPK($liveThumbEntryId); } if ($liveThumbEntry && $liveThumbEntry->getMediaType() == entry::ENTRY_MEDIA_TYPE_IMAGE) { $fileSyncVersion = $partner->getLiveThumbEntryVersion(); $liveEntryKey = $liveThumbEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA, $fileSyncVersion); $contentPath = kFileSyncUtils::getLocalFilePathForKey($liveEntryKey); if ($contentPath) { $msgPath = $contentPath; $liveEntryExist = true; } else { KalturaLog::err('no local file sync for audio entry id'); } } if (!$liveEntryExist) { $msgPath = $contentPath . "content/templates/entry/thumbnail/live_thumb.jpg"; } return myEntryUtils::resizeEntryImage($this, $version, $width, $height, $type, $bgcolor, $crop_provider, $quality, $src_x, $src_y, $src_w, $src_h, $vid_sec, $vid_slice, $vid_slices, $msgPath, $density, $stripProfiles); }
public function __construct(KalturaDistributionJobData $distributionJobData = null) { parent::__construct($distributionJobData); if (!$distributionJobData) { return; } if (!$distributionJobData->distributionProfile instanceof KalturaDailymotionDistributionProfile) { return; } $flavorAssets = assetPeer::retrieveByIds(explode(',', $distributionJobData->entryDistribution->flavorAssetIds)); if (count($flavorAssets)) { // if we have specific flavor assets for this distribution, grab the first one $flavorAsset = reset($flavorAssets); } else { // take the source asset $flavorAsset = assetPeer::retrieveOriginalReadyByEntryId($distributionJobData->entryDistribution->entryId); } if ($flavorAsset) { $syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); $this->videoAssetFilePath = kFileSyncUtils::getLocalFilePathForKey($syncKey, false); } // look for krule with action block and condition of country $entry = entryPeer::retrieveByPK($distributionJobData->entryDistribution->entryId); if ($entry && $entry->getAccessControl()) { $this->setGeoBlocking($entry->getAccessControl()); } $this->addCaptionsData($distributionJobData); }
/** * @return entry */ public function getEntry() { if (!$this->aEntry && $this->getEntryId()) { $this->aEntry = entryPeer::retrieveByPK($this->getEntryId()); } return $this->aEntry; }
public function createQuestionPdf() { $dbEntry = entryPeer::retrieveByPK($this->entryId); $title = "Here are the questions from [" . $dbEntry->getName() . "]"; KalturaLog::debug("Questions from [" . $dbEntry->getName() . "]"); $this->pdf->addTitle($title, $this->titleStyle); $questionType = QuizPlugin::getCuePointTypeCoreValue(QuizCuePointType::QUIZ_QUESTION); $questions = CuePointPeer::retrieveByEntryId($this->entryId, array($questionType)); //arange the array so that the questions will be the key for the array $questArray = array(); foreach ($questions as $question) { $questArray[$question->getName()] = $question; } //sort the array alphabetically according to its key; i.e. the question ksort($questArray, SORT_LOCALE_STRING); $questNum = 0; foreach ($questArray as $question) { $questNum += 1; $this->pdf->addList($questNum, $question->getName(), $this->listWithAddLineBeforeStyle); $this->pdf->addHeadline(6, "Optional Answers:", $this->heading6Style); $ansNum = 0; foreach ($question->getOptionalAnswers() as $optionalAnswer) { $ansNum += 1; $this->pdf->addList($ansNum, $optionalAnswer->getText(), $this->indentListStyle); } } }
/** * @param string $cdnHost * @param string $entryId * @return kUrlManager */ public static function getUrlManagerByCdn($cdnHost, $entryId) { $class = 'kUrlManager'; $cdnHost = preg_replace('/https?:\\/\\//', '', $cdnHost); $cdnHost = preg_replace('/:\\d+$/', '', $cdnHost); $params = null; $urlManagers = kConf::getMap('url_managers'); if (isset($urlManagers[$cdnHost])) { $class = $urlManagers[$cdnHost]["class"]; $params = @$urlManagers[$cdnHost]["params"]; $entry = entryPeer::retrieveByPK($entryId); $urlManagersMap = kConf::getMap('url_managers'); if ($entry && isset($urlManagersMap["override"])) { $overrides = $urlManagersMap["override"]; $partnerId = $entry->getPartnerId(); if (array_key_exists($partnerId, $overrides)) { $overrides = $overrides[$partnerId]; foreach ($overrides as $override) { if ($override['domain'] == $cdnHost) { $params = array_merge($params, $override["params"]); } } } } } KalturaLog::log("Uses url manager [{$class}]"); return new $class(null, $params, $entryId); }
protected function applyFilterFields(baseObjectFilter $filter) { /* @var $filter cuePointFilter */ // Reduce the cache expiry when fetching live stream cuepoints $entryId = $filter->get('_in_entry_id'); if ($entryId && strpos($entryId, ',') === false) { $entry = entryPeer::retrieveByPK($entryId); if ($entry && $entry->getType() == entryType::LIVE_STREAM) { kApiCache::setExpiry(self::LIVE_ENTRY_CUE_POINT_CACHE_EXPIRY_SECONDS); } } if ($filter->get('_free_text')) { $this->sphinxSkipped = false; $freeTexts = $filter->get('_free_text'); KalturaLog::debug("Attach free text [{$freeTexts}]"); $this->addFreeTextToMatchClauseByMatchFields($freeTexts, CuePointFilter::FREE_TEXT_FIELDS); } $filter->unsetByName('_free_text'); if ($filter->get('_eq_is_public')) { $this->sphinxSkipped = false; $isPublic = $filter->get('_eq_is_public'); $this->addCondition('is_public' . " = " . $isPublic); } $filter->unsetByName('_eq_is_public'); return parent::applyFilterFields($filter); }
public function getObject() { if ($this->m_object) { return $this->m_object; } $object_id = $this->object_id; if ($object_id == null) { return null; } switch ($this->getObjectType()) { case self::MODERATION_OBJECT_TYPE_KSHOW: $this->m_object = kshowPeer::retrieveByPK($object_id); break; case self::MODERATION_OBJECT_TYPE_ENTRY: // be able to fetch entries that are deleted entryPeer::allowDeletedInCriteriaFilter(); $this->m_object = entryPeer::retrieveByPK($object_id); entryPeer::blockDeletedInCriteriaFilter(); break; case self::MODERATION_OBJECT_TYPE_USER: // $object_id is the puser_id $puser_kuser = PuserKuserPeer::retrieveByPartnerAndUid($this->getPartnerId(), NULL, $object_id, true); if ($puser_kuser && $puser_kuser->getKuser()) { $this->m_object = $puser_kuser->getKuser(); } // $this->m_object = kuserPeer::retrieveByPK( $object_id ); break; } return $this->m_object; }
public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser) { $entry_id = $this->getPM("entry_id"); $detailed = $this->getP("detailed", false); $entry = null; if ($entry_id) { $entry = entryPeer::retrieveByPK($entry_id); } if (!$entry) { $this->addError(APIErrors::INVALID_ENTRY_ID, $entry_id); } else { $kshow_id = $entry->getKshowId(); $kshow = $entry->getKshow(); if (!$kshow) { $this->addError(APIErrors::INVALID_KSHOW_ID, $kshow_id); } else { $newKshow = myKshowUtils::shalowCloneById($kshow_id, $puser_kuser->getKuserId()); if (!$newKshow) { $this->addError(APIErrors::KSHOW_CLONE_FAILED, $kshow_id); } else { $newEntry = $newKshow->getShowEntry(); $level = $detailed ? objectWrapperBase::DETAIL_LEVEL_DETAILED : objectWrapperBase::DETAIL_LEVEL_REGULAR; $wrapper = objectWrapperBase::getWrapperClass($newEntry, $level); // TODO - remove this code when cache works properly when saving objects (in their save method) $wrapper->removeFromCache("entry", $newEntry->getId()); $this->addMsg("entry", $wrapper); } } } }
/** * @return kUrlTokenizer */ public function getTokenizer() { switch ($this->protocol) { case StorageProfile::PLAY_FORMAT_HTTP: $name = isset($this->params['http_auth_param_name']) ? $this->params['http_auth_param_name'] : "h"; $key = isset($this->params['http_auth_key']) ? $this->params['http_auth_key'] : false; $gen = isset($this->params['http_auth_gen']) ? $this->params['http_auth_gen'] : false; $window = 0; $entry = entryPeer::retrieveByPK($this->entryId); if ($entry && $entry->getSecurityPolicy()) { $window = 30; } if ($name && $key !== false && $gen !== false) { return new kLevel3UrlTokenizer($name, $key, $gen, false, $window); } break; case StorageProfile::PLAY_FORMAT_RTMP: $name = isset($this->params['rtmp_auth_param_name']) ? $this->params['rtmp_auth_param_name'] : "h"; $key = isset($this->params['rtmp_auth_key']) ? $this->params['rtmp_auth_key'] : false; $gen = isset($this->params['rtmp_auth_gen']) ? $this->params['rtmp_auth_gen'] : false; if ($name && $key !== false && $gen !== false) { return new kLevel3UrlTokenizer($name, $key, $gen, true); } break; } return null; }
/** * Creates perioding metadata sync-point events on a live stream * * @action createPeriodicSyncPoints * @actionAlias liveStream.createPeriodicSyncPoints * @param string $entryId Kaltura live-stream entry id * @param int $interval Events interval in seconds * @param int $duration Duration in seconds * * @throws KalturaErrors::ENTRY_ID_NOT_FOUND * @throws KalturaErrors::NO_MEDIA_SERVER_FOUND * @throws KalturaErrors::MEDIA_SERVER_SERVICE_NOT_FOUND */ function createPeriodicSyncPoints($entryId, $interval, $duration) { $entryDc = substr($entryId, 0, 1); if ($entryDc != kDataCenterMgr::getCurrentDcId()) { $remoteDCHost = kDataCenterMgr::getRemoteDcExternalUrlByDcId($entryDc); kFileUtils::dumpApiRequest($remoteDCHost, true); } $dbEntry = entryPeer::retrieveByPK($entryId); if (!$dbEntry || $dbEntry->getType() != KalturaEntryType::LIVE_STREAM || !in_array($dbEntry->getSource(), array(KalturaSourceType::LIVE_STREAM, KalturaSourceType::LIVE_STREAM_ONTEXTDATA_CAPTIONS))) { throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId); } /* @var $dbEntry LiveStreamEntry */ $mediaServers = $dbEntry->getMediaServers(); if (!count($mediaServers)) { throw new KalturaAPIException(KalturaErrors::NO_MEDIA_SERVER_FOUND, $entryId); } foreach ($mediaServers as $key => $kMediaServer) { if ($kMediaServer && $kMediaServer instanceof kLiveMediaServer) { $mediaServer = $kMediaServer->getMediaServer(); $mediaServerCuePointsService = $mediaServer->getWebService(MediaServer::WEB_SERVICE_CUE_POINTS); KalturaLog::debug("Sending sync points for DC [" . $mediaServer->getDc() . "] "); if ($mediaServerCuePointsService && $mediaServerCuePointsService instanceof KalturaMediaServerCuePointsService) { KalturaLog::debug("Call createTimeCuePoints on DC [" . $mediaServer->getDc() . "] "); $mediaServerCuePointsService->createTimeCuePoints($entryId, $interval, $duration); } else { KalturaLog::debug("Media server service not found on DC: [" . $mediaServer->getDc() . "] "); } } } }
/** * @param SimpleXMLElement $mrss * @param SimpleXMLElement $metadata * @param kMrssParameters $mrssParams * @return SimpleXMLElement */ public function contributeMetadataObject(SimpleXMLElement $mrss, SimpleXMLElement $metadata, kMrssParameters $mrssParams = null, $currentXPath) { $currentXPath .= "/*[local-name()='" . $metadata->getName() . "']"; $metadataObject = $mrss->addChild($metadata->getName()); foreach ($metadata->attributes() as $attributeField => $attributeValue) { $metadataObject->addAttribute($attributeField, $attributeValue); } foreach ($metadata as $metadataField => $metadataValue) { if ($metadataValue instanceof SimpleXMLElement && count($metadataValue)) { $this->contributeMetadataObject($metadataObject, $metadataValue, $mrssParams, $currentXPath); } else { $metadataObject->addChild($metadataField, kString::stringToSafeXml($metadataValue)); $itemXPath = $currentXPath . "/*[local-name()='{$metadataField}']"; if ($mrssParams && is_array($mrssParams->getItemXpathsToExtend()) && in_array($itemXPath, $mrssParams->getItemXpathsToExtend())) { $relatedEntry = entryPeer::retrieveByPK((string) $metadataValue); if ($relatedEntry) { $relatedItemField = $metadataObject->addChild($metadataField . '_item'); $recursionMrssParams = null; if ($mrssParams) { $recursionMrssParams = clone $mrssParams; $recursionMrssParams->setItemXpathsToExtend(array()); // stop the recursion } $relatedEntryMrss = kMrssManager::getEntryMrssXml($relatedEntry, $relatedItemField, $recursionMrssParams); } } } } }
/** const SUBJECT_TYPE_KSHOW = '1'; const SUBJECT_TYPE_ENTRY = '2'; const SUBJECT_TYPE_USER = '******'; */ public static function addFavorite(favorite $favorite) { self::add($favorite); $type = $favorite->getSubjectType(); $id = $favorite->getSubjectId(); if ($type == favorite::SUBJECT_TYPE_ENTRY) { $obj = entryPeer::retrieveByPK($id); if ($obj) { $v = $obj->getFavorites(); self::inc($v); $obj->setFavorites($v); } } elseif ($type == favorite::SUBJECT_TYPE_KSHOW) { $obj = kshowPeer::retrieveByPK($id); if ($obj) { $v = $obj->getFavorites(); self::inc($v); $obj->setFavorites($v); } } elseif ($type == favorite::SUBJECT_TYPE_USER) { $obj = kuserPeer::retrieveByPK($id); if ($obj) { $v = $obj->getFans(); self::inc($v); $obj->setFans($v); } } // don't forget to save the modified object self::add($obj); }
/** * Will return the first virus scan profile of the entry's partner, that defines an entry filter suitable for the given entry. * @param int $entryId * @return VirusScanProfile the suitable profile object, or null if none found */ public static function getSuitableProfile($entryId) { $entry = entryPeer::retrieveByPK($entryId); if (!$entry) { KalturaLog::err('Cannot find entry with id [' . $entryId . ']'); return null; } if ($entry->getSource() == entry::ENTRY_MEDIA_SOURCE_WEBCAM) { return null; } $cProfile = new Criteria(); $cProfile->addAnd(VirusScanProfilePeer::PARTNER_ID, $entry->getPartnerId()); $cProfile->addAnd(VirusScanProfilePeer::STATUS, VirusScanProfileStatus::ENABLED, Criteria::EQUAL); $profiles = VirusScanProfilePeer::doSelect($cProfile); if (!$profiles) { KalturaLog::debug('No virus scan profiles found for partner [' . $entry->getPartnerId() . ']'); return null; } foreach ($profiles as $profile) { $virusEntryFilter = $profile->getEntryFilterObject(); if ($virusEntryFilter->matches($entry)) { KalturaLog::debug('Returning profile with id [' . $profile->getId() . ']'); return $profile; } } return null; }
/** * Called on the server side and enables you to populate the object with any data from the DB * * @param KalturaDistributionJobData $distributionJobData */ public function __construct(KalturaDistributionJobData $distributionJobData = null) { parent::__construct($distributionJobData); if (!$distributionJobData) { return; } if (!$distributionJobData->distributionProfile instanceof KalturaQuickPlayDistributionProfile) { return; } $this->videoFilePaths = new KalturaStringArray(); $this->thumbnailFilePaths = new KalturaStringArray(); // loads all the flavor assets that should be submitted to the remote destination site $flavorAssets = assetPeer::retrieveByIds(explode(',', $distributionJobData->entryDistribution->flavorAssetIds)); $thumbAssets = assetPeer::retrieveByIds(explode(',', $distributionJobData->entryDistribution->thumbAssetIds)); $entry = entryPeer::retrieveByPK($distributionJobData->entryDistribution->entryId); foreach ($flavorAssets as $asset) { $syncKey = $asset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); if (kFileSyncUtils::fileSync_exists($syncKey)) { $str = new KalturaString(); $str->value = kFileSyncUtils::getLocalFilePathForKey($syncKey, false); $this->videoFilePaths[] = $str; } } foreach ($thumbAssets as $asset) { $syncKey = $asset->getSyncKey(thumbAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); if (kFileSyncUtils::fileSync_exists($syncKey)) { $str = new KalturaString(); $str->value = kFileSyncUtils::getLocalFilePathForKey($syncKey, false); $this->thumbnailFilePaths[] = $str; } } $feed = new QuickPlayFeed($distributionJobData, $this, $flavorAssets, $thumbAssets, $entry); $this->xml = $feed->getXml(); }
/** * getAccessAction * input: flavor ids, drmProvider * Get Access Action * @action getAccess * @param string $entryId * @param string $flavorIds * @param string $referrer * @return KalturaDrmLicenseAccessDetails **/ public function getAccessAction($entryId, $flavorIds, $referrer) { $response = new KalturaDrmLicenseAccessDetails(); $response->policy = ""; $response->duration = 0; $response->absolute_duration = 0; $flavorIdsArr = explode(",", $flavorIds); $entry = entryPeer::retrieveByPK($entryId); if (isset($entry)) { try { $drmLU = new DrmLicenseUtils($entry, $referrer); if ($this->validateFlavorAssetssAllowed($drmLU, $flavorIdsArr) == true) { $policyId = $drmLU->getPolicyId(); KalturaLog::info("policy_id is '{$policyId}'"); $dbPolicy = DrmPolicyPeer::retrieveByPK($policyId); if (isset($dbPolicy)) { $expirationDate = DrmLicenseUtils::calculateExpirationDate($dbPolicy, $entry); $response->policy = $dbPolicy->getName(); $response->duration = $expirationDate; $response->absolute_duration = $expirationDate; KalturaLog::info("response is '" . print_r($response, true) . "' "); } else { KalturaLog::err("Could not get DRM policy from DB"); } } } catch (Exception $e) { KalturaLog::err("Could not validate license access, returned with message '" . $e->getMessage() . "'"); } } else { KalturaLog::err("Entry '{$entryId}' not found"); } return $response; }
public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser) { $obj_type = $this->getPM("obj_type"); $obj_id = $this->getPM("obj_id"); $command = $this->getPM("command"); $value = $this->getP("value"); $extra_info = $this->getP("extra_info"); if ($obj_type == "entry") { $entry = entryPeer::retrieveByPK($obj_id); if ($command == "view") { PartnerActivity::incrementActivity($partner_id, PartnerActivity::PARTNER_ACTIVITY_KDP, PartnerActivity::PARTNER_SUB_ACTIVITY_KDP_VIEWS); myStatisticsMgr::incEntryViews($entry); } elseif ($command == "play") { PartnerActivity::incrementActivity($partner_id, PartnerActivity::PARTNER_ACTIVITY_KDP, PartnerActivity::PARTNER_SUB_ACTIVITY_KDP_PLAYS); myStatisticsMgr::incEntryPlays($entry); } } elseif ($obj_type == "kshow") { $kshow = kshowPeer::retrieveByPK($obj_id); if ($command == "view") { PartnerActivity::incrementActivity($partner_id, PartnerActivity::PARTNER_ACTIVITY_KDP, PartnerActivity::PARTNER_SUB_ACTIVITY_KDP_VIEWS); myStatisticsMgr::incKshowViews($kshow); } elseif ($command == "play") { PartnerActivity::incrementActivity($partner_id, PartnerActivity::PARTNER_ACTIVITY_KDP, PartnerActivity::PARTNER_SUB_ACTIVITY_KDP_PLAYS); myStatisticsMgr::incKshowPlays($kshow); } } $this->addMsg("collectedStats", "{$obj_type}, {$obj_id}, {$command}, {$value}, {$extra_info}"); }
/** * Will forward to the regular swf player according to the widget_id */ public function execute() { $entryId = $this->getRequestParameter("entry_id"); $flavorId = $this->getRequestParameter("flavor"); $fileName = $this->getRequestParameter("file_name"); $ksStr = $this->getRequestParameter("ks"); $referrer = $this->getRequestParameter("referrer"); $referrer = base64_decode($referrer); if (!is_string($referrer)) { // base64_decode can return binary data $referrer = ""; } // get entry $entry = entryPeer::retrieveByPK($entryId); if (is_null($entry)) { KExternalErrors::dieError(KExternalErrors::ENTRY_NOT_FOUND); } myPartnerUtils::blockInactivePartner($entry->getPartnerId()); $securyEntryHelper = new KSecureEntryHelper($entry, $ksStr, $referrer); $securyEntryHelper->validateForDownload($entry, $ksStr); $flavorAsset = null; if ($flavorId) { // get flavor asset $flavorAsset = flavorAssetPeer::retrieveById($flavorId); if (is_null($flavorAsset) || $flavorAsset->getStatus() != flavorAsset::FLAVOR_ASSET_STATUS_READY) { KExternalErrors::dieError(KExternalErrors::FLAVOR_NOT_FOUND); } // the request flavor should belong to the requested entry if ($flavorAsset->getEntryId() != $entryId) { KExternalErrors::dieError(KExternalErrors::FLAVOR_NOT_FOUND); } } else { $flavorAsset = flavorAssetPeer::retrieveBestPlayByEntryId($entry->getId()); } // Gonen 26-04-2010: in case entry has no flavor with 'mbr' tag - we return the source if (!$flavorAsset && ($entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_VIDEO || $entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_AUDIO)) { $flavorAsset = flavorAssetPeer::retrieveOriginalByEntryId($entryId); } if ($flavorAsset) { $syncKey = $this->getSyncKeyAndForFlavorAsset($entry, $flavorAsset); } else { $syncKey = $this->getBestSyncKeyForEntry($entry); } list($fileBaseName, $fileExt) = $this->getFileName($entry, $flavorAsset); if (!$fileName) { $fileName = $fileBaseName; } if ($fileExt) { $fileName = $fileName . '.' . $fileExt; } if (is_null($syncKey)) { KExternalErrors::dieError(KExternalErrors::FILE_NOT_FOUND); } $this->handleFileSyncRedirection($syncKey); $filePath = kFileSyncUtils::getReadyLocalFilePathForKey($syncKey); $this->dumpFile($filePath, $fileName); die; // no view }
/** * Will forward to the regular swf player according to the widget_id */ public function execute() { $entry_id = $this->getRequestParameter("entry_id"); $entry = entryPeer::retrieveByPK($entry_id); if ($entry) { $this->redirect($entry->getUserLandingPage()); } die; }
public function retrieveByIdentifier($value) { switch ($this->identifier) { case EntryIdentifierField::ID: return entryPeer::retrieveByPK($value); case EntryIdentifierField::REFERENCE_ID: return entryPeer::retrieveByReferenceId($value); } }
public function validateForInsert($propertiesToSkip = array()) { parent::validateForInsert($propertiesToSkip); $dbEntry = entryPeer::retrieveByPK($this->entryId); QuizPlugin::validateAndGetQuiz($dbEntry); if (!QuizPlugin::validateUserEntitledForQuizEdit($dbEntry)) { throw new KalturaAPIException(KalturaErrors::INVALID_USER_ID); } }
public function execute() { $this->forceSystemAuthentication(); $kshow_id = @$_REQUEST["kshow_id"]; $this->kshow_id = $kshow_id; $this->kshow = NULL; $entry_id = @$_REQUEST["entry_id"]; $this->entry_id = $entry_id; $this->entry = NULL; $this->message = ""; if (!empty($kshow_id)) { $this->kshow = kshowPeer::retrieveByPK($kshow_id); if (!$this->kshow) { $this->message = "Cannot find kshow [{$kshow_id}]"; } else { $this->entry = $this->kshow->getShowEntry(); } } elseif (!empty($kshow_id)) { $this->entry = entryPeer::retrieveByPK($entry_id); if (!$this->entry) { $this->message = "Cannot find entry [{$entry_id}]"; } else { $this->kshow = $this->{$this}->entry->getKshow(); } } if ($this->kshow) { $this->metadata = $this->kshow->getMetadata(); } else { $this->metadata = ""; } $pending_str = $this->getP("pending"); $remove_pending = $this->getP("remove_pending"); if ($this->metadata && ($remove_pending || $pending_str)) { if ($remove_pending) { $pending_str = ""; } $xml_doc = new DOMDocument(); $xml_doc->loadXML($this->metadata); $metadata = kXml::getFirstElement($xml_doc, "MetaData"); $should_save = kXml::setChildElement($xml_doc, $metadata, "Pending", $pending_str, true); if ($remove_pending) { $should_save = kXml::setChildElement($xml_doc, $metadata, "LastPendingTimeStamp", "", true); } if ($should_save) { $fixed_content = $xml_doc->saveXML(); $content_dir = myContentStorage::getFSContentRootPath(); $file_name = realpath($content_dir . $this->entry->getDataPath()); $res = file_put_contents($file_name, $fixed_content); // sync - NOTOK $this->metadata = $fixed_content; } } $this->pending = $pending_str; $this->kshow_id = $kshow_id; $this->entry_id = $entry_id; }
public function __construct(KalturaDistributionJobData $distributionJobData = null) { parent::__construct($distributionJobData); if (!$distributionJobData || !$distributionJobData->distributionProfile instanceof KalturaTvinciDistributionProfile || !$distributionJobData->entryDistribution) { return; } $entry = null; if ($distributionJobData->entryDistribution->entryId) { $entry = entryPeer::retrieveByPK($distributionJobData->entryDistribution->entryId); } if (!$entry) { KalturaLog::err("Can't find entry with id: {$distributionJobData->entryDistribution->entryId}"); return; } $feedHelper = new TvinciDistributionFeedHelper($distributionJobData->distributionProfile); $feedHelper->setEntryId($entry->getId()); $feedHelper->setReferenceId($entry->getReferenceID()); $feedHelper->setDescription($entry->getDescription()); $feedHelper->setTitleName($entry->getName()); $feedHelper->setSunrise($distributionJobData->entryDistribution->sunrise); $feedHelper->setSunset($distributionJobData->entryDistribution->sunset); $thumbAssets = assetPeer::retrieveByIds(explode(',', $distributionJobData->entryDistribution->thumbAssetIds)); $picRatios = array(); $defaultThumbUrl = null; foreach ($thumbAssets as $thumbAsset) { $thumbDownloadUrl = $this->getAssetDownloadUrl($thumbAsset); $ratio = KDLVideoAspectRatio::ConvertFrameSize($thumbAsset->getWidth(), $thumbAsset->getHeight()); $picRatios[] = array('url' => $thumbDownloadUrl, 'ratio' => $ratio); if ($thumbAsset->hasTag(thumbParams::TAG_DEFAULT_THUMB)) { $defaultThumbUrl = $thumbDownloadUrl; } } $feedHelper->setPicRatiosArray($picRatios); if (!$defaultThumbUrl && count($picRatios)) { // Choose the URL of the first resource in the array $defaultThumbUrl = $picRatios[0]['url']; } $feedHelper->setDefaultThumbnailUrl($defaultThumbUrl); $this->createPlayManifestURLs($distributionJobData->entryDistribution, $entry, $feedHelper); $metadatas = MetadataPeer::retrieveAllByObject(MetadataObjectType::ENTRY, $distributionJobData->entryDistribution->entryId); $fullMetadataXML = ''; foreach ($metadatas as $metadataField) { $syncKey = $metadataField->getSyncKey(Metadata::FILE_SYNC_METADATA_DATA); $currMetaXML = kFileSyncUtils::file_get_contents($syncKey, true, false); $fullMetadataXML .= $currMetaXML; } $feedHelper->setMetasXML($fullMetadataXML); if ($distributionJobData instanceof KalturaDistributionSubmitJobData) { $this->xml = $feedHelper->buildSubmitFeed(); } elseif ($distributionJobData instanceof KalturaDistributionUpdateJobData) { $this->xml = $feedHelper->buildUpdateFeed(); } elseif ($distributionJobData instanceof KalturaDistributionDeleteJobData) { $this->xml = $feedHelper->buildDeleteFeed(); } KalturaLog::debug("XML Constructed by the Tvinci feed helper :{$this->xml}"); }
public function validateForInsert($propertiesToSkip = array()) { parent::validateForInsert($propertiesToSkip); $dbEntry = entryPeer::retrieveByPK($this->entryId); QuizPlugin::validateAndGetQuiz($dbEntry); if (!QuizPlugin::validateUserEntitledForQuizEdit($dbEntry)) { KalturaLog::debug('Update quiz questions is allowed only with admin KS or entry owner or co-editor'); throw new KalturaAPIException(KalturaErrors::INVALID_USER_ID); } }
/** * * Gets the kuser for the given entry id * @param string $entryId */ private function getKuserIdFromEntry($entryId) { entryPeer::clearInstancePool(); $entry = entryPeer::retrieveByPK($entryId); print "in getKuserIdFromEntry kuserId [ " . $entry->getKuserId() . "]\n"; $kuserId = null; if ($entry) { $kuserId = $entry->getKuserId(); } return $kuserId; }
private static function renderEntry($entry_id) { $xml = '<?xml version="1.0" encoding="ISO-8859-1"?>'; $xml .= "<Video>"; $entry = entryPeer::retrieveByPK($entry_id); if ($entry) { $seconds = (int) ($entry->getLengthInMsecs() / 1000); $xml .= "<PartnerId>" . $entry->getPartnerId() . "</PartnerId>" . "<Duration>" . $seconds . "</Duration>"; } $xml .= "</Video>"; return $xml; }
public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser, $create_cachekey = false) { myDbHelper::$use_alternative_con = myDbHelper::DB_HELPER_CONN_PROPEL3; // TODO - verify permissions for viewing lists $detailed = $this->getP("detailed", false); $limit = $this->getP("page_size", 10); $limit = $this->maxPageSize($limit); $page = $this->getP("page", 1); $user_filter_prefix = $this->getP("fp", "filter"); $offset = ($page - 1) * $limit; // TODO - should limit search to partner ?? // kuserPeer::setUseCriteriaFilter( false ); // entryPeer::setUseCriteriaFilter( false ); $playlist_id = $this->getPM("playlist_id"); $input_params = $this->getInputParams(); $extra_filters = array(); for ($i = 1; $i < self::MAX_FILTER_COUNT; $i++) { // filter $extra_filter = new entryFilter(); $fields_set = $extra_filter->fillObjectFromRequest($input_params, "{$user_filter_prefix}{$i}_", null); if ($fields_set) { $extra_filters[$i] = $extra_filter; } } // this service is executed twice! (first time for the cache key, second time for the execution) if (is_null($this->playlist)) { $playlist = entryPeer::retrieveByPK($playlist_id); if (!$playlist) { throw new APIException(APIErrors::INVALID_ENTRY_ID, "Playlist", $playlist_id); } myPartnerUtils::addPartnerToCriteria(new accessControlPeer(), $playlist->getPartnerId(), $this->getPrivatePartnerData(), $this->partnerGroup2(), null); $this->playlist = $playlist; } if ($create_cachekey) { if ($this->isAdmin()) { return null; } $cache_key_arr = array("playlist_id" => $playlist_id, "filters" => $extra_filters); $cahce_key = new executionCacheKey(); $cahce_key->expiry = 600; $cahce_key->key = md5(print_r($cache_key_arr, true)); return $cahce_key; } if ($this->isAdmin()) { myPlaylistUtils::setIsAdminKs(true); } $entry_list = myPlaylistUtils::executePlaylistById($partner_id, $playlist_id, $extra_filters, $detailed); myEntryUtils::updatePuserIdsForEntries($entry_list); $level = $detailed ? objectWrapperBase::DETAIL_LEVEL_DETAILED : objectWrapperBase::DETAIL_LEVEL_REGULAR; $wrapper = objectWrapperBase::getWrapperClass($entry_list, $level); $this->addMsg("count", count($entry_list)); $this->addMsg($this->getObjectPrefix(), $wrapper); }
/** * @param EntryDistribution $entryDistribution * @param $action * @param array $validationErrors * since entry distribution and entry are validated in the parent of validateForSubmission we will not add an error for them */ private function validateReferenceId(EntryDistribution $entryDistribution, $action, array &$validationErrors) { if ($entryDistribution && $entryDistribution->getEntryId()) { $entry = entryPeer::retrieveByPK($entryDistribution->getEntryId()); if ($entry && !$entry->getReferenceID()) { $validationError = $this->createValidationError($action, DistributionErrorType::MISSING_METADATA, "Reference ID", "is a mandatory field"); $validationError->setValidationErrorType(DistributionValidationErrorType::STRING_EMPTY); $validationError->setValidationErrorParam("Reference ID is a mandatory field"); $validationErrors[] = $validationError; } } }
public function toObject($dbObject = null, $skip = array()) { $this->validate(); if (!$dbObject) { $dbObject = new kEntryContext(); } parent::toObject($dbObject); if (!is_null($this->entryId)) { $dbObject->setEntry(entryPeer::retrieveByPK($this->entryId)); } return $dbObject; }