private function getAccessControlScope() { $scope = new accessControlScope(); if ($this->referrer) { $scope->setReferrer($this->referrer); } $scope->setKs($this->ks); $scope->setEntryId($this->entry->getId()); $scope->setContexts($this->contexts); return $scope; }
/** * @param entry $entry * @param SimpleXMLElement $mrss * @return SimpleXMLElement */ public function contribute(entry $entry, SimpleXMLElement $mrss) { $metadatas = MetadataPeer::retrieveAllByObject(Metadata::TYPE_ENTRY, $entry->getId()); foreach ($metadatas as $metadata) { $this->contributeMetadata($metadata, $mrss); } }
/** * @param entry $object * @return bool true if should continue to the next consumer */ public function entryCreated(entry $object) { $mediaType = null; if ($object->getType() == entryType::AUTOMATIC) { KalturaLog::debug("entry id [" . $object->getId() . "] type [" . $object->getType() . "] source link [" . $object->getSourceLink() . "]"); $mediaType = $object->getMediaType(); if (isset(self::$fileExtensions[$mediaType])) { $object->setType(entryType::DOCUMENT); } elseif (is_null($mediaType) || $mediaType == entry::ENTRY_MEDIA_TYPE_ANY || $mediaType == entry::ENTRY_MEDIA_TYPE_AUTOMATIC) { $this->setDocumentType($object); } } if ($object->getType() != entryType::DOCUMENT) { KalturaLog::debug("entry id [" . $object->getId() . "] type [" . $object->getType() . "]"); return true; } if (is_null($mediaType) || $mediaType == entry::ENTRY_MEDIA_TYPE_ANY || $mediaType == entry::ENTRY_MEDIA_TYPE_AUTOMATIC) { $this->setDocumentType($object); } if ($object instanceof DocumentEntry) { KalturaLog::debug("entry id [" . $object->getId() . "] already handled"); return true; } KalturaLog::debug("Handling object [" . get_class($object) . "] type [" . $object->getType() . "] id [" . $object->getId() . "] status [" . $object->getStatus() . "]"); if ($object->getConversionProfileId()) { $object->setStatus(entryStatus::PRECONVERT); $object->save(); } return true; }
protected function initFlavorIds() { $flavorIdsStr = $this->getRequestParameter("flavorIds", null); if ($flavorIdsStr) { $this->flavorIds = explode(",", $flavorIdsStr); } $this->flavorId = $this->getRequestParameter("flavorId", null); if (!$this->flavorId) { $flavorParamIds = $this->getRequestParameter("flavorParamIds", null); if ($flavorParamIds !== null) { $this->flavorIds = assetPeer::retrieveReadyFlavorsIdsByEntryId($this->entry->getId(), explode(",", $flavorParamIds)); if (!$this->flavorIds || count($this->flavorIds) == 0) { KExternalErrors::dieError(KExternalErrors::FLAVOR_NOT_FOUND); } } else { $flavorParamId = $this->getRequestParameter("flavorParamId", null); if ($flavorParamId || $flavorParamId === "0") { $flavorAsset = assetPeer::retrieveByEntryIdAndParams($this->entry->getId(), $flavorParamId); if (!$flavorAsset) { KExternalErrors::dieError(KExternalErrors::FLAVOR_NOT_FOUND); } $this->flavorId = $flavorAsset->getId(); } } } }
private function fixIsmManifestForReplacedEntry($path) { $fileData = file_get_contents($path); $xml = new SimpleXMLElement($fileData); $ismcFileName = $xml->head->meta['content']; list($ismcObjectId, $version, $subType, $isAsset, $entryId) = $this->parseObjectId($ismcFileName); if ($entryId != $this->entry->getId()) { //replacement flow $flavorAssets = assetPeer::retrieveByEntryIdAndStatus($this->entry->getId(), asset::ASSET_STATUS_READY); foreach ($flavorAssets as $asset) { if ($asset->hasTag(assetParams::TAG_ISM_MANIFEST)) { list($replacingFileName, $fileName) = $this->getReplacedAndReplacingFileNames($asset, flavorAsset::FILE_SYNC_ASSET_SUB_TYPE_ISMC); if ($replacingFileName && $fileName) { $fileData = str_replace("content=\"{$replacingFileName}\"", "content=\"{$fileName}\"", $fileData); } } else { list($replacingFileName, $fileName) = $this->getReplacedAndReplacingFileNames($asset, flavorAsset::FILE_SYNC_ASSET_SUB_TYPE_ASSET); if ($replacingFileName && $fileName) { $fileData = str_replace("src=\"{$replacingFileName}\"", "src=\"{$fileName}\"", $fileData); } } } return $fileData; } else { return $fileData; } }
/** * @param entry $entry * @param SimpleXMLElement $mrss * @return SimpleXMLElement */ public function contribute(entry $entry, SimpleXMLElement $mrss) { $entryDistributions = EntryDistributionPeer::retrieveByEntryId($entry->getId()); foreach ($entryDistributions as $entryDistribution) { $this->contributeDistribution($entryDistribution, $mrss); } }
public function copyAssets(entry $toEntry, ThumbCuePoint $toCuePoint, $adjustedStartTime = null) { $timedThumbAsset = assetPeer::retrieveById($this->getAssetId()); if (!$timedThumbAsset) { KalturaLog::debug("Can't retrieve timedThumbAsset with id: {$this->getAssetId()}"); return; } // Offset the startTime according to the duration gap between the live and VOD entries if (!is_null($adjustedStartTime)) { $toCuePoint->setStartTime($adjustedStartTime); } $toCuePoint->save(); // Must save in order to produce an id $timedThumbAsset->setCuePointID($toCuePoint->getId()); // Set the destination cue point's id $timedThumbAsset->setCustomDataObj(); // Write the cached custom data object into the thumb asset // Make a copy of the current thumb asset // copyToEntry will create a filesync softlink to the original filesync $toTimedThumbAsset = $timedThumbAsset->copyToEntry($toEntry->getId(), $toEntry->getPartnerId()); $toCuePoint->setAssetId($toTimedThumbAsset->getId()); $toCuePoint->save(); // Restore the thumb asset's prev. cue point id (for good measures) $timedThumbAsset->setCuePointID($this->getId()); $timedThumbAsset->setCustomDataObj(); // Save the destination entry's thumb asset $toTimedThumbAsset->setCuePointID($toCuePoint->getId()); $toTimedThumbAsset->save(); KalturaLog::log("Saved cue point [{$toCuePoint->getId()}] and timed thumb asset [{$toTimedThumbAsset->getId()}]"); }
private function setContextDataFlavorAssets($flavorTags) { $flavorParamsIds = null; $flavorParamsNotIn = false; if (!$this->isAdmin) { foreach ($this->contextDataResult->getActions() as $action) { if ($action->getType() == RuleActionType::BLOCK) { //in case of block action do not set the list of flavors return; } if ($action->getType() == RuleActionType::LIMIT_FLAVORS) { /* @var $action kAccessControlLimitFlavorsAction */ $flavorParamsIds = explode(',', $action->getFlavorParamsIds()); $flavorParamsNotIn = $action->getIsBlockedList(); } } } $flavorAssets = array(); if (is_null($this->asset)) { if (count($flavorParamsIds)) { $flavorAssets = assetPeer::retrieveReadyByEntryIdAndFlavorParams($this->entry->getId(), $flavorParamsIds, $flavorParamsNotIn); } else { $flavorAssets = assetPeer::retrieveFlavorsByEntryIdAndStatus($this->entry->getId(), null, array(flavorAsset::ASSET_STATUS_READY)); } } else { $flavorAllowed = true; if (count($flavorParamsIds)) { $flavorAllowed = $this->isFlavorAllowed($this->asset->getFlavorParamsId(), $flavorParamsIds, $flavorParamsNotIn); } if ($flavorAllowed) { $flavorAssets[] = $this->asset; } } $this->filterFlavorAssetsByTags($flavorAssets, $flavorTags); }
protected function handleEntry($context, $feed, entry $entry, Entrydistribution $entryDistribution) { $fields = $this->profile->getAllFieldValues($entryDistribution); $flavorAssets = assetPeer::retrieveByIds(explode(',', $entryDistribution->getFlavorAssetIds())); $thumbAssets = assetPeer::retrieveByIds(explode(',', $entryDistribution->getThumbAssetIds())); $captionAssets = null; if ($this->profile instanceof ComcastMrssDistributionProfile && $this->profile->getShouldIncludeCaptions()) { KalturaLog::info("Adding entry captions."); $captionAssets = $this->getCaptions($entry->getPartnerId(), $entry->getId()); } $cuePoints = null; if ($this->profile instanceof ComcastMrssDistributionProfile && $this->profile->getShouldIncludeCuePoints()) { KalturaLog::info("Adding entry cue points."); $cuePoints = $this->getCuePoints($entry->getPartnerId(), $entry->getId()); } return $feed->getItemXml($fields, $flavorAssets, $thumbAssets, $captionAssets, $cuePoints); }
private function getAccessControlScope() { $accessControlScope = accessControlScope::partialInit(); if ($this->_referrer) { $accessControlScope->setReferrer($this->_referrer); } $accessControlScope->setKs($this->_ks); $accessControlScope->setEntryId($this->_entry->getId()); return $accessControlScope; }
public function getBroadcastUrl(entry $entry, $mediaServerIndex) { $mediaServerConfig = kConf::get($mediaServerIndex, 'broadcast'); $app = $mediaServerConfig['application']; $partnerId = $this->partnerId; $url = "rtmp://{$partnerId}.{$mediaServerIndex}." . kConf::get('domain', 'broadcast'); $entryId = $entry->getId(); $token = $entry->getStreamPassword(); return "{$url}/{$app}/p/{$partnerId}/e/{$entryId}/i/{$mediaServerIndex}/t/{$token}"; }
public static function updateAdminTags(entry $entry) { // be ready to update the admin_tags if the admin_tags OR the status was modified if ($entry->isColumnModified(entryPeer::ADMIN_TAGS) || $entry->isColumnModified(entryPeer::STATUS)) { $partner_id = $entry->getPartnerId(); $admin_tags_str = self::getAdminTags($partner_id, null, true, $entry->getId()); $admin_tags = explode(self::TAG_SEPARATOR, $admin_tags_str); $admin_tags = self::mergeAdminTags($admin_tags, $entry->getAdminTags()); $after_change = self::sortAndSetAdminTags($partner_id, $admin_tags); } }
private function setContextDataFlavorAssets($flavorTags) { if ($this->entry->getType() == entryType::PLAYLIST && $this->entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_TEXT) { list($entryIds, $durations, $mediaEntry) = myPlaylistUtils::executeStitchedPlaylist($this->entry); if (!$mediaEntry) { return; } $mediaEntryId = $mediaEntry->getId(); $this->msDuration = array_sum($durations); } else { $mediaEntryId = $this->entry->getId(); $this->msDuration = $this->entry->getLengthInMsecs(); } $flavorParamsIds = null; $flavorParamsNotIn = false; if (!$this->isAdmin) { foreach ($this->contextDataResult->getActions() as $action) { if ($action->getType() == RuleActionType::BLOCK) { //in case of block action do not set the list of flavors return; } if ($action->getType() == RuleActionType::LIMIT_FLAVORS) { /* @var $action kAccessControlLimitFlavorsAction */ $flavorParamsIds = explode(',', $action->getFlavorParamsIds()); $flavorParamsNotIn = $action->getIsBlockedList(); } } } $flavorAssets = array(); if (is_null($this->asset)) { if (count($flavorParamsIds)) { $flavorAssets = assetPeer::retrieveReadyByEntryIdAndFlavorParams($mediaEntryId, $flavorParamsIds, $flavorParamsNotIn); } else { $flavorAssets = assetPeer::retrieveFlavorsByEntryIdAndStatus($mediaEntryId, null, array(flavorAsset::ASSET_STATUS_READY)); } if ($mediaEntryId != $this->entry->getId()) { // hack: setting the entry id of the flavors to the original playlist id // since the player uses it in the playManifest url foreach ($flavorAssets as $flavorAsset) { $flavorAsset->setEntryId($this->entry->getId()); } } } else { $flavorAllowed = true; if (count($flavorParamsIds)) { $flavorAllowed = $this->isFlavorAllowed($this->asset->getFlavorParamsId(), $flavorParamsIds, $flavorParamsNotIn); } if ($flavorAllowed) { $flavorAssets[] = $this->asset; } } $this->filterFlavorAssetsByTags($flavorAssets, $flavorTags); }
public function syncCategoryEntries(entry $vodEntry, LiveEntry $liveEntry) { $liveCategoryEntryArray = categoryEntryPeer::selectByEntryId($liveEntry->getId()); if (!count($liveCategoryEntryArray)) { return; } foreach ($liveCategoryEntryArray as $categoryEntry) { /* @var $categoryEntry categoryEntry */ $vodCategoryEntry = $categoryEntry->copy(); $vodCategoryEntry->setEntryId($vodEntry->getId()); $vodCategoryEntry->save(); } }
/** * @param entry $entry */ protected function entryDeleted(entry $entry) { $this->syncableDeleted($entry->getId(), FileSyncObjectType::ENTRY); // delete flavor assets $c = new Criteria(); $c->add(assetPeer::ENTRY_ID, $entry->getId()); $c->add(assetPeer::STATUS, asset::FLAVOR_ASSET_STATUS_DELETED, Criteria::NOT_EQUAL); $c->add(assetPeer::DELETED_AT, null, Criteria::ISNULL); assetPeer::resetInstanceCriteriaFilter(); $assets = assetPeer::doSelect($c); foreach ($assets as $asset) { $asset->setStatus(asset::FLAVOR_ASSET_STATUS_DELETED); $asset->setDeletedAt(time()); $asset->save(); } $c = new Criteria(); $c->add(flavorParamsOutputPeer::ENTRY_ID, $entry->getId()); $c->add(flavorParamsOutputPeer::DELETED_AT, null, Criteria::ISNULL); $flavorParamsOutputs = flavorParamsOutputPeer::doSelect($c); foreach ($flavorParamsOutputs as $flavorParamsOutput) { $flavorParamsOutput->setDeletedAt(time()); $flavorParamsOutput->save(); } }
public function postInsert(PropelPDO $con = null) { parent::postInsert($con); if (!$this->getFeedId() || !$this->getId()) { return; } $syndicationFeed = syndicationFeedPeer::retrieveByPK($this->getFeedId()); if (!$syndicationFeed || !$syndicationFeed instanceof genericSyndicationFeed) { return; } // "Creates advanced filter on distribution profile $distributionAdvancedSearch = new ContentDistributionSearchFilter(); $distributionAdvancedSearch->setDistributionProfileId($this->getId()); $distributionAdvancedSearch->setDistributionSunStatus(EntryDistributionSunStatus::AFTER_SUNRISE); $distributionAdvancedSearch->setEntryDistributionStatus(EntryDistributionStatus::READY); $distributionAdvancedSearch->setEntryDistributionFlag(EntryDistributionDirtyStatus::NONE); //Creates entry filter with advanced filter $entryFilter = new entryFilter(); $entryFilter->setPartnerIdEquel($this->getPartnerId()); $entryFilter->setAdvancedSearch($distributionAdvancedSearch); // Creates playlist with entry filter $playlistXml = new SimpleXMLElement("<playlist/>"); $filtersXml = $playlistXml->addChild("filters"); $filterXml = $filtersXml->addChild("filter"); $entryFilter->toXml($filterXml); $playlistContent = $playlistXml->asXML(); // creates playlist based on the filter XML $playlist = new entry(); $playlist->setKuserId(kCurrentContext::$uid); $playlist->setDisplayInSearch(mySearchUtils::DISPLAY_IN_SEARCH_NONE); $playlist->setPartnerId($this->getPartnerId()); $playlist->setStatus(entryStatus::READY); $playlist->setKshowId(null); $playlist->setType(entryType::PLAYLIST); $playlist->setMediaType(entry::ENTRY_MEDIA_TYPE_XML); $playlist->setDataContent($playlistContent); $playlist->save(); KalturaLog::log("Playlist [" . $playlist->getId() . "] created"); // creates feed based on the playlist $syndicationFeed->setPlaylistId($playlist->getId()); $syndicationFeed->save(); }
public function executeImpl(kshow $kshow, entry &$entry) { $genericWidget = ""; $myspaceWidget = ""; $kshow_id = $kshow->getId(); $entry_id = $entry->getId(); if (!$kshow->getPartnerId() && !$this->forceViewPermissions($kshow, $kshow_id, false, false)) { die; } $this->kshow_category = $kshow->getTypeText(); $this->kshow_description = $kshow->getDescription(); $this->kshow_name = $kshow->getName(); $this->kshow_tags = $kshow->getTags(); $kdata = @$_REQUEST["kdata"]; if ($kdata == "null") { $kdata = ""; } $this->widget_type = @$_REQUEST["widget_type"]; list($genericWidget, $myspaceWidget) = myKshowUtils::getEmbedPlayerUrl($kshow_id, $entry_id, false, $kdata); if ($entry_id == 1002) { $this->share_url = requestUtils::getHost() . "/index.php/corp/kalturaPromo"; } else { if ($kdata) { $this->share_url = myKshowUtils::getWidgetCmdUrl($kdata, "share"); } else { $this->share_url = myKshowUtils::getUrl($kshow_id) . "&entry_id={$entry_id}"; } } //list($status, $kmediaType, $kmediaData) = myContentRender::createPlayerMedia($entry); // myContentRender class removed, old code $status = $entry->getStatus(); $kmediaType = $entry->getMediaType(); $kmediaData = ""; $this->message = $kmediaType == entry::ENTRY_MEDIA_TYPE_TEXT ? $kmediaData : ""; $this->generic_embed_code = $genericWidget; $this->myspace_embed_code = $myspaceWidget; $this->thumbnail = $entry ? $entry->getBigThumbnailPath(true) : ""; $this->kuser = $entry->getKuser(); $this->entry = $entry; }
/** * @param entry $entry */ public static function onEntryDeleted(entry $entry) { if (!ContentDistributionPlugin::isAllowedPartner($entry->getPartnerId())) { return true; } $entryDistributions = EntryDistributionPeer::retrieveByEntryId($entry->getId()); foreach ($entryDistributions as $entryDistribution) { if ($entryDistribution->getStatus() == EntryDistributionStatus::DELETING) { KalturaLog::log("Entry distribution [" . $entryDistribution->getId() . "] already deleting"); continue; } if ($entryDistribution->getDirtyStatus() == EntryDistributionDirtyStatus::DELETE_REQUIRED) { KalturaLog::log("Entry distribution [" . $entryDistribution->getId() . "] already flaged for deletion"); continue; } $distributionProfileId = $entryDistribution->getDistributionProfileId(); $distributionProfile = DistributionProfilePeer::retrieveByPK($distributionProfileId); if (!$distributionProfile || $distributionProfile->getDeleteEnabled() != DistributionProfileActionStatus::AUTOMATIC) { KalturaLog::log("Entry distribution [" . $entryDistribution->getId() . "] should not be deleted automatically"); continue; } self::submitDeleteEntryDistribution($entryDistribution, $distributionProfile); } return true; }
/** * @param entry $entry */ public function attachPendingMediaEntry(entry $entry, $requiredDuration, $offset, $duration) { $attachedPendingMediaEntries = $this->getAttachedPendingMediaEntries(); $attachedPendingMediaEntries[$entry->getId()] = new kPendingMediaEntry($entry->getId(), kDataCenterMgr::getCurrentDcId(), $requiredDuration, $offset, $duration); $this->setAttachedPendingMediaEntries($attachedPendingMediaEntries); }
/** * decideThumbGenerate is the decision layer for a single thumbnail generation * * @param entry $entry * @param thumbParams $destThumbParams * @param BatchJob $parentJob * @return thumbAsset */ public static function decideThumbGenerate(entry $entry, thumbParams $destThumbParams, BatchJob $parentJob = null, $sourceAssetId = null, $runSync = false) { $srcAsset = null; assetPeer::resetInstanceCriteriaFilter(); if ($sourceAssetId) { $srcAsset = assetPeer::retrieveById($sourceAssetId); } else { if ($destThumbParams->getSourceParamsId()) { KalturaLog::debug("Look for flavor params [" . $destThumbParams->getSourceParamsId() . "]"); $srcAsset = assetPeer::retrieveByEntryIdAndParams($entry->getId(), $destThumbParams->getSourceParamsId()); } if (is_null($srcAsset)) { KalturaLog::debug("Look for original flavor"); $srcAsset = flavorAssetPeer::retrieveOriginalByEntryId($entry->getId()); } if (is_null($srcAsset) || $srcAsset->getStatus() != flavorAsset::FLAVOR_ASSET_STATUS_READY) { KalturaLog::debug("Look for highest bitrate flavor"); $srcAsset = flavorAssetPeer::retrieveHighestBitrateByEntryId($entry->getId()); } } if (is_null($srcAsset)) { throw new APIException(APIErrors::FLAVOR_ASSET_IS_NOT_READY); } $errDescription = null; $mediaInfo = mediaInfoPeer::retrieveByFlavorAssetId($srcAsset->getId()); $destThumbParamsOutput = self::validateThumbAndMediaInfo($destThumbParams, $mediaInfo, $errDescription); $thumbAsset = thumbAssetPeer::retrieveByEntryIdAndParams($entry->getId(), $destThumbParams->getId()); if ($thumbAsset) { $description = $thumbAsset->getDescription() . "\n" . $errDescription; $thumbAsset->setDescription($description); } else { $thumbAsset = new thumbAsset(); $thumbAsset->setPartnerId($entry->getPartnerId()); $thumbAsset->setEntryId($entry->getId()); $thumbAsset->setDescription($errDescription); $thumbAsset->setFlavorParamsId($destThumbParams->getId()); } $thumbAsset->incrementVersion(); $thumbAsset->setStatus(flavorAsset::FLAVOR_ASSET_STATUS_CONVERTING); $thumbAsset->setTags($destThumbParamsOutput->getTags()); $thumbAsset->setFileExt($destThumbParamsOutput->getFileExt()); if (!$destThumbParamsOutput) { $thumbAsset->setStatus(thumbAsset::FLAVOR_ASSET_STATUS_ERROR); $thumbAsset->save(); return null; } $thumbAsset->save(); // save flavor params $destThumbParamsOutput->setPartnerId($entry->getPartnerId()); $destThumbParamsOutput->setEntryId($entry->getId()); $destThumbParamsOutput->setFlavorAssetId($thumbAsset->getId()); $destThumbParamsOutput->setFlavorAssetVersion($thumbAsset->getVersion()); $destThumbParamsOutput->save(); $srcSyncKey = $srcAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); $srcAssetType = $srcAsset->getType(); if (!$runSync) { $job = kJobsManager::addCapturaThumbJob($parentJob, $entry->getPartnerId(), $entry->getId(), $thumbAsset->getId(), $srcSyncKey, $srcAssetType, $destThumbParamsOutput); return $thumbAsset; } $errDescription = null; $capturedPath = self::generateThumbnail($srcAsset, $destThumbParamsOutput, $errDescription); // failed if (!$capturedPath) { $thumbAsset->incrementVersion(); $thumbAsset->setStatus(thumbAsset::FLAVOR_ASSET_STATUS_ERROR); $thumbAsset->setDescription($thumbAsset->getDescription() . "\n{$errDescription}"); $thumbAsset->save(); return $thumbAsset; } $thumbAsset->incrementVersion(); $thumbAsset->setStatus(thumbAsset::FLAVOR_ASSET_STATUS_READY); if (file_exists($capturedPath)) { list($width, $height, $type, $attr) = getimagesize($capturedPath); $thumbAsset->setWidth($width); $thumbAsset->setHeight($height); $thumbAsset->setSize(filesize($capturedPath)); } $logPath = $capturedPath . '.log'; if (file_exists($logPath)) { $thumbAsset->incLogFileVersion(); $thumbAsset->save(); // creats the file sync $logSyncKey = $thumbAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_CONVERT_LOG); kFileSyncUtils::moveFromFile($logPath, $logSyncKey); KalturaLog::debug("Log archived file to: " . kFileSyncUtils::getLocalFilePathForKey($logSyncKey)); } else { $thumbAsset->save(); } $syncKey = $thumbAsset->getSyncKey(thumbAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); kFileSyncUtils::moveFromFile($capturedPath, $syncKey); KalturaLog::debug("Thumbnail archived file to: " . kFileSyncUtils::getLocalFilePathForKey($syncKey)); if ($thumbAsset->hasTag(thumbParams::TAG_DEFAULT_THUMB)) { // increment thumbnail version $entry->setThumbnail(".jpg"); $entry->save(); $entrySyncKey = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB); $syncFile = kFileSyncUtils::createSyncFileLinkForKey($entrySyncKey, $syncKey, false); if ($syncFile) { // removes the DEFAULT_THUMB tag from all other thumb assets $entryThumbAssets = thumbAssetPeer::retrieveByEntryId($thumbAsset->getEntryId()); foreach ($entryThumbAssets as $entryThumbAsset) { if ($entryThumbAsset->getId() == $thumbAsset->getId()) { continue; } if (!$entryThumbAsset->hasTag(thumbParams::TAG_DEFAULT_THUMB)) { continue; } $entryThumbAsset->removeTags(array(thumbParams::TAG_DEFAULT_THUMB)); $entryThumbAsset->save(); } } } if (!is_null($thumbAsset->getFlavorParamsId())) { kFlowHelper::generateThumbnailsFromFlavor($thumbAsset->getEntryId(), null, $thumbAsset->getFlavorParamsId()); } return $thumbAsset; }
public static function getEntrySearchValues(entry $entry) { if (!ContentDistributionPlugin::isAllowedPartner($entry->getPartnerId())) { return null; } $entryDistributions = EntryDistributionPeer::retrieveByEntryId($entry->getId()); if (!count($entryDistributions)) { return self::getSearchStringNoDistributionProfiles(); } $searchValues = array(); foreach ($entryDistributions as $entryDistribution) { $distributionProfileId = $entryDistribution->getDistributionProfileId(); $searchValues[] = self::getSearchStringDistributionProfile($distributionProfileId); $searchValues[] = self::getSearchStringDistributionStatus($entryDistribution->getStatus(), $distributionProfileId); $searchValues[] = self::getSearchStringDistributionFlag($entryDistribution->getDirtyStatus(), $distributionProfileId); $searchValues[] = self::getSearchStringDistributionSunStatus($entryDistribution->getSunStatus(), $distributionProfileId); $validationErrors = $entryDistribution->getValidationErrors(); if (count($validationErrors)) { $searchValues[] = self::getSearchStringDistributionHasValidationError($distributionProfileId); } foreach ($validationErrors as $validationError) { $searchValues[] = self::getSearchStringDistributionValidationError($validationError->getErrorType(), $distributionProfileId); } } return implode(' ', $searchValues); }
/** * This helps create special entries in a kshow - the show_entry & intro * $type can be either entry::ENTRY_MEDIA_TYPE_SHOW (for the show_entry) or entry::ENTRY_MEDIA_TYPE_VIDEO (for the intro) */ public function createEntry($type, $kuser_id, $thumbnail = null, $entry_name = null) { // for invites we use the default invites from the kaltura gallery show if ($type != entry::ENTRY_MEDIA_TYPE_SHOW) { $kshow_type = $this->getType(); $intros = array(kshow::KSHOW_TYPE_MASHUP, kshow::KSHOW_TYPE_MUSIC_VIDEO, kshow::KSHOW_TYPE_HOWTO, kshow::KSHOW_TYPE_CALL_FOR_ACTION, kshow::KSHOW_TYPE_CONTEST, kshow::KSHOW_TYPE_GROUP_GREETING, kshow::KSHOW_TYPE_SPORTS, kshow::KSHOW_TYPE_DIGITAL_STORY, kshow::KSHOW_TYPE_GROUP_TRAVELOGUE); $id = 0; if (in_array($kshow_type, $intros)) { $id = $kshow_type; } $id = 120 + $id; $entry = entryPeer::retrieveByPK($id); if ($entry) { $this->setIntroId($entry->getId()); $this->m_intro = $entry; } return $entry; } $kshow = $this; $entry = new entry(); $entry->setKshowId($kshow->getId()); $entry->setKuserId($kuser_id); $entry->setCreatorKuserId($kuser_id); if ($this->getPartnerId() !== null) { $entry->setPartnerId($this->getPartnerId()); } // inherit partner_id from kshow if ($this->getSubpId() !== null) { $entry->setSubpId($this->getSubpId()); } // inherit subp_id from kshow $entry->setStatus(entryStatus::READY); if ($entry_name) { $type_text = $entry_name; } else { $type_text = "Kaltura Video"; } //$entry->setData ( "&kal_show.flv"); $entry->setThumbnail($thumbnail ? $thumbnail : "&kal_show.jpg"); $entry->setCreateThumb(false); $entry->setType(entryType::MIX); $entry->setMediaType(entry::ENTRY_MEDIA_TYPE_SHOW); $entry->setEditorType(myMetadataUtils::METADATA_EDITOR_SIMPLE); $entry->setName($type_text); $entry->setTags($type_text . "," . $kshow->getTags()); $entry->save(); $this->setShowEntryId($entry->getId()); $this->m_show_entry = $entry; return $entry; }
public static function toQueryString(entry $playlist, $should_append_filter_to_url = false) { $query = "playlist_id={$playlist->getId()}"; if ($playlist->getMediaType() != entry::ENTRY_MEDIA_TYPE_XML) { return $query; } if (!$should_append_filter_to_url) { return $query; } $xml = $playlist->getDataContent(); list($total_results, $list_of_filters) = self::getPlaylistFilterListStruct($xml); $entry_filters = array(); $partner_id = $playlist->getPartnerId(); // add ks=_KS_ for the playlist to replace it before hitting the executePlaylist $query .= "&fp=f"; // make sure the filter prefix is short if (!$list_of_filters) { return $query; } $i = 1; // the extra_filter is 1-based foreach ($list_of_filters as $entry_filter_xml) { $prefix = "f{$i}_"; // in general this service can fetch entries from kaltura networks. // for each filter we should decide if thie assumption is true... $allow_partner_only = true; // compile all the filters - only then execute them if not yet reached the total_results // TODO - optimize - maybe create them only when needed. - For now it's safer to compile all even if not needed. $entry_filter = new entryFilter(); // add the desired prefix "_" because the XML is not expected to have it while the entryFilter class expects it $entry_filter->fillObjectFromXml($entry_filter_xml, "_"); // make sure there is alway a limit for each filter - if not an explicit one - the system limit should be used if ($entry_filter->getLimit() == null || $entry_filter->getLimit() < 1) { $entry_filter->setLimit(self::TOTAL_RESULTS); } $entry_filter->setPartnerSearchScope(baseObjectFilter::MATCH_KALTURA_NETWORK_AND_PRIVATE); self::updateEntryFilter($entry_filter, $partner_id); //$entry_filters[] = $entry_filter; $fields = $entry_filter->fields; foreach ($fields as $field => $value) { if ($value) { $query .= "&" . $prefix . $field . "=" . $value; } } $i++; } return $query; }
protected function addEntryFromFlavorAsset(KalturaBaseEntry $newEntry, entry $srcEntry, flavorAsset $srcFlavorAsset) { $newEntry->type = $srcEntry->getType(); if ($newEntry->name === null) { $newEntry->name = $srcEntry->getName(); } if ($newEntry->description === null) { $newEntry->description = $srcEntry->getDescription(); } if ($newEntry->creditUrl === null) { $newEntry->creditUrl = $srcEntry->getSourceLink(); } if ($newEntry->creditUserName === null) { $newEntry->creditUserName = $srcEntry->getCredit(); } if ($newEntry->tags === null) { $newEntry->tags = $srcEntry->getTags(); } $newEntry->sourceType = KalturaSourceType::SEARCH_PROVIDER; $newEntry->searchProviderType = KalturaSearchProviderType::KALTURA; $dbEntry = $this->prepareEntryForInsert($newEntry); $dbEntry->setSourceId($srcEntry->getId()); $kshow = $this->createDummyKShow(); $kshowId = $kshow->getId(); $msg = null; $flavorAsset = kFlowHelper::createOriginalFlavorAsset($this->getPartnerId(), $dbEntry->getId(), $msg); if (!$flavorAsset) { KalturaLog::err("Flavor asset not created for entry [" . $dbEntry->getId() . "] reason [{$msg}]"); if ($dbEntry->getStatus() == entryStatus::NO_CONTENT) { $dbEntry->setStatus(entryStatus::ERROR_CONVERTING); $dbEntry->save(); } throw new KalturaAPIException(KalturaErrors::ORIGINAL_FLAVOR_ASSET_NOT_CREATED, $msg); } $srcSyncKey = $srcFlavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); $newSyncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); kFileSyncUtils::createSyncFileLinkForKey($newSyncKey, $srcSyncKey); kEventsManager::raiseEvent(new kObjectAddedEvent($flavorAsset)); myNotificationMgr::createNotification(kNotificationJobData::NOTIFICATION_TYPE_ENTRY_ADD, $dbEntry); $newEntry->fromObject($dbEntry, $this->getResponseProfile()); return $newEntry; }
/** * @param entry $entry * @param PropelPDO $con * @return mixed The copied cuepoint */ public function copyToEntry($entry, PropelPDO $con = null) { $cuePointCopy = $this->copy(); $cuePointCopy->setEntryId($entry->getId()); return $cuePointCopy; }
public static function updateAdminTags(entry $entry) { // be ready to update the admin_tags if the admin_tags OR the status was modified if ($entry->isColumnModified(entryPeer::ADMIN_TAGS) || $entry->isColumnModified(entryPeer::STATUS)) { $partner_id = $entry->getPartnerId(); // TODO - add the delta of the tags to the cache $admin_tags_str = self::getAdminTags($partner_id, null, true, $entry->getId()); //KalturaLog::log( "1 adminTags for partner [$partner_id]\n$admin_tags_str"); $admin_tags = explode(self::TAG_SEPARATOR, $admin_tags_str); $admin_tags = self::mergeAdminTags($admin_tags, $entry->getAdminTags()); $after_change = self::sortAndSetAdminTags($partner_id, $admin_tags); //KalturaLog::log( "2 adminTags for partner [$partner_id]\n$after_change"); } }
/** * Declares an association between this object and a entry object. * * @param entry $v * @return asset The current object (for fluent API support) * @throws PropelException */ public function setentry(entry $v = null) { if ($v === null) { $this->setEntryId(NULL); } else { $this->setEntryId($v->getId()); } $this->aentry = $v; // Add binding for other direction of this n:n relationship. // If this object has already been added to the entry object, it will not be re-added. if ($v !== null) { $v->addasset($this); } return $this; }
public static function syncEntriesCategories(entry $entry, $isCategoriesModified) { self::$skipEntrySave = true; if ($entry->getNewCategories() != null && $entry->getNewCategories() !== "") { $newCats = explode(entry::ENTRY_CATEGORY_SEPARATOR, $entry->getNewCategories()); } else { $newCats = array(); } if (!$isCategoriesModified) { if ($entry->getNewCategoriesIds() != null && $entry->getNewCategoriesIds() !== "") { $newCatsIds = explode(entry::ENTRY_CATEGORY_SEPARATOR, $entry->getNewCategoriesIds()); } else { $newCatsIds = array(); } KalturaCriterion::disableTag(KalturaCriterion::TAG_ENTITLEMENT_CATEGORY); $dbCategories = categoryPeer::retrieveByPKs($newCatsIds); KalturaCriterion::restoreTag(KalturaCriterion::TAG_ENTITLEMENT_CATEGORY); foreach ($dbCategories as $dbCategory) { //skip categoy with privacy contexts. if ($dbCategory->getPrivacyContexts() != null && $dbCategory->getPrivacyContexts() != '') { continue; } $newCats[] = $dbCategory->getFullName(); } } $newCats = array_unique($newCats); $allIds = array(); $allCats = array(); $allIdsWithParents = array(); $addedCats = array(); $removedCats = array(); $remainingCats = array(); $oldCats = array(); $oldCatsIds = array(); $dbOldCategoriesEntry = categoryEntryPeer::selectByEntryId($entry->getId()); foreach ($dbOldCategoriesEntry as $dbOldCategoryEntry) { $oldCatsIds[] = $dbOldCategoryEntry->getCategoryId(); } $oldCategoris = categoryPeer::retrieveByPKsNoFilter($oldCatsIds); foreach ($oldCategoris as $category) { if ($category->getPrivacyContexts() != '' && $category->getPrivacyContexts() != null) { continue; } $oldCats[] = $category->getFullName(); } foreach ($oldCats as $cat) { if (array_search($cat, $newCats) === false) { $removedCats[] = $cat; } } foreach ($newCats as $cat) { if (array_search($cat, $oldCats) === false) { $addedCats[] = $cat; } else { $remainingCats[] = $cat; } } foreach ($remainingCats as $cat) { KalturaCriterion::disableTag(KalturaCriterion::TAG_ENTITLEMENT_CATEGORY); $category = categoryPeer::getByFullNameExactMatch($cat); KalturaCriterion::restoreTag(KalturaCriterion::TAG_ENTITLEMENT_CATEGORY); if ($category) { if ($category->getPrivacyContext() == '' || $category->getPrivacyContext() == null) { $allCats[] = $category->getFullName(); $allIds[] = $category->getId(); } $allIdsWithParents[] = $category->getId(); $allIdsWithParents = array_merge($allIdsWithParents, $category->getAllParentsIds()); } } $alreadyAddedCatIds = $allIdsWithParents; foreach ($addedCats as $cat) { $category = categoryPeer::getByFullNameExactMatch($cat); if (!$category) { KalturaCriterion::disableTag(KalturaCriterion::TAG_ENTITLEMENT_CATEGORY); $unentitedCategory = categoryPeer::getByFullNameExactMatch($cat); KalturaCriterion::restoreTag(KalturaCriterion::TAG_ENTITLEMENT_CATEGORY); if (!$unentitedCategory) { $category = category::createByPartnerAndFullName($entry->getPartnerId(), $cat); //it is possible to add on an entry a few new categories on the same new parent - //and we need to sync sphinx once we add so the category will not be duplicated kEventsManager::flushEvents(); } } else { $categoryKuser = categoryKuserPeer::retrieveByCategoryIdAndActiveKuserId($category->getId(), kCurrentContext::$ks_kuser_id); if (kEntitlementUtils::getEntitlementEnforcement() && $category->getContributionPolicy() != ContributionPolicyType::ALL && (!$categoryKuser || $categoryKuser->getPermissionLevel() == CategoryKuserPermissionLevel::MEMBER)) { //user is not entitled to add entry to this category $category = null; } } if (!$category) { continue; } //when use caetgoryEntry->add categoryEntry object was alreay created - and no need to create it. //when using baseEntry->categories = 'my category' will need to add the new category. $categoryEntry = categoryEntryPeer::retrieveByCategoryIdAndEntryId($category->getId(), $entry->getId()); if (!$categoryEntry) { $categoryEntry = new categoryEntry(); $categoryEntry->setEntryId($entry->getId()); $categoryEntry->setCategoryId($category->getId()); $categoryEntry->setEntryCategoriesAddedIds($alreadyAddedCatIds); $categoryEntry->setPartnerId($entry->getPartnerId()); $categoryEntry->setStatus(CategoryEntryStatus::ACTIVE); $categoryEntry->save(); } if ($category->getPrivacyContext() == '' || $category->getPrivacyContext() == null) { // only categories with no context should be set on entry->categories and entry->categoriesIds $allCats[] = $category->getFullName(); $allIds[] = $category->getId(); } $alreadyAddedCatIds[] = $category->getId(); $alreadyAddedCatIds = array_merge($alreadyAddedCatIds, $category->getAllParentsIds()); } $alreadyRemovedCatIds = $allIdsWithParents; foreach ($removedCats as $cat) { $category = categoryPeer::getByFullNameExactMatch($cat); if ($category) { $categoryEntryToDelete = categoryEntryPeer::retrieveByCategoryIdAndEntryId($category->getId(), $entry->getId()); if ($categoryEntryToDelete) { $categoryKuser = categoryKuserPeer::retrieveByCategoryIdAndActiveKuserId($categoryEntryToDelete->getCategoryId(), kCurrentContext::$ks_kuser_id); if ($category->getPrivacyContexts() && (!$categoryKuser || $categoryKuser->getPermissionLevel() == CategoryKuserPermissionLevel::MEMBER)) { //not entiteld to delete - should be set back on the entry. $allCats[] = $category->getFullName(); $allIds[] = $category->getId(); } else { $categoryEntryToDelete->setEntryCategoriesRemovedIds($alreadyRemovedCatIds); $categoryEntryToDelete->setStatus(CategoryEntryStatus::DELETED); $categoryEntryToDelete->save(); } } $alreadyRemovedCatIds[] = $category->getId(); $alreadyRemovedCatIds = array_merge($alreadyRemovedCatIds, $category->getAllParentsIds()); } else { //category was not found - it could be that user is not entitled to remove it KalturaCriterion::disableTag(KalturaCriterion::TAG_ENTITLEMENT_CATEGORY); $category = categoryPeer::getByFullNameExactMatch($cat); KalturaCriterion::restoreTag(KalturaCriterion::TAG_ENTITLEMENT_CATEGORY); if ($category) { $allCats[] = $category->getFullName(); $allIds[] = $category->getId(); } } } self::$skipEntrySave = false; $entry->parentSetCategories(implode(",", $allCats)); $entry->parentSetCategoriesIds(implode(',', $allIds)); }
/** * Convert all drop folder files' status from PROCESSING to HANDLED/DELETED in case of DropFolderFileDeletePolicy::AUTO_DELETE_WHEN_ENTRY_IS_READY * * Note that if the entry reached entryStatus::ERROR_CONVERTING, then the drop folder files' * conversions already failed, so there's no need to change their status (thus they won't be handled here). * * @param entry $entry */ private function onEntryStatusChanged($entry) { // Handle only files that are still in the PROCESSING state, which were left // in this state due to AUTO_DELETE_WHEN_ENTRY_IS_READY delete policy. $dropFolderFiles = DropFolderFilePeer::retrieveByEntryIdPartnerIdAndStatuses($entry->getId(), $entry->getPartnerId(), array(DropFolderFileStatus::PROCESSING)); $dropFolderIdToDropFolderCache = array(); $entryStatus = $entry->getStatus(); foreach ($dropFolderFiles as $dropFolderFile) { $newDropFolderFileStatus = null; if ($entryStatus == entryStatus::ERROR_CONVERTING) { $newDropFolderFileStatus = DropFolderFileStatus::ERROR_HANDLING; } elseif ($entryStatus == entryStatus::READY) { // Get the associated drop folder $dropFolderId = $dropFolderFile->getDropFolderId(); if (key_exists($dropFolderId, $dropFolderIdToDropFolderCache)) { $dropFolder = $dropFolderIdToDropFolderCache[$dropFolderId]; } else { $dropFolder = DropFolderPeer::retrieveByPK($dropFolderId); $dropFolderIdToDropFolderCache[$dropFolderId] = $dropFolder; } if ($dropFolder->getFileDeletePolicy() == DropFolderFileDeletePolicy::AUTO_DELETE_WHEN_ENTRY_IS_READY) { if ($dropFolder->getAutoFileDeleteDays() == 0) { $newDropFolderFileStatus = DropFolderFileStatus::DELETED; // Mark for immediate deletion } else { $newDropFolderFileStatus = DropFolderFileStatus::HANDLED; } } } KalturaLog::info("Entry id [{$entry->getId()}] status [{$entryStatus}], drop folder file id [{$dropFolderFile->getId()}] status [{$dropFolderFile->getStatus()}] => [" . ($newDropFolderFileStatus ? $newDropFolderFileStatus : "{$dropFolderFile->getStatus()} (unchanged)") . "]"); if ($newDropFolderFileStatus) { $dropFolderFile->setStatus($newDropFolderFileStatus); $dropFolderFile->save(); } } }
/** * @param flavorAsset $originalFlavorAsset * @param entry $entry * @param BatchJob $convertProfileJob * @return BatchJob */ public static function bypassConversion(flavorAsset $originalFlavorAsset, entry $entry, BatchJob $convertProfileJob) { if (!$originalFlavorAsset->hasTag(flavorParams::TAG_MBR)) { $mediaInfo = mediaInfoPeer::retrieveByFlavorAssetId($originalFlavorAsset->getId()); if ($mediaInfo) { $tagsArray = $originalFlavorAsset->getTagsArray(); $finalTagsArray = KDLWrap::CDLMediaInfo2Tags($mediaInfo, $tagsArray); $originalFlavorAsset->setTagsArray($finalTagsArray); } } if (!$entry->getCreateThumb()) { // mark the asset as ready $originalFlavorAsset->setStatusLocalReady(); $originalFlavorAsset->save(); kFlowHelper::generateThumbnailsFromFlavor($entry->getId(), null, $originalFlavorAsset->getFlavorParamsId()); kBusinessPostConvertDL::handleConvertFinished(null, $originalFlavorAsset); return null; } $offset = $entry->getThumbOffset(); // entry getThumbOffset now takes the partner DefThumbOffset into consideration $srcSyncKey = $originalFlavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); $srcFileSyncLocalPath = kFileSyncUtils::getLocalFilePathForKey($srcSyncKey); $srcFileSyncWamsAssetId = kFileSyncUtils::getWamsAssetIdForKey($srcSyncKey); $postConvertAssetType = BatchJob::POSTCONVERT_ASSET_TYPE_BYPASS; return kJobsManager::addPostConvertJob($convertProfileJob, $postConvertAssetType, $srcFileSyncLocalPath, $originalFlavorAsset->getId(), null, true, $offset, null, $srcFileSyncWamsAssetId); }