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); }
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); }
protected function applyContext() { $this->contextResult = null; $accessControl = $this->entry->getAccessControl(); if (!$accessControl) { return; } $this->contextResult = new kEntryContextDataResult(); $scope = $this->getAccessControlScope(); if (!$this->isKsAdmin()) { $this->disableCache = $accessControl->applyContext($this->contextResult, $scope); } else { $this->disableCache = false; } if (count($this->contextResult->getActions())) { foreach ($this->contextResult->getActions() as $action) { if (!isset($this->actionLists[$action->getType()])) { $this->actionLists[$action->getType()] = array($action); } else { array_push($this->actionLists[$action->getType()], $action); } } } }
/** * @param kEntryContextDataResult $context * @return boolean */ public function applyContext(kEntryContextDataResult $context) { if (!$this->fulfilled()) { KalturaLog::debug("Rule conditions NOT fulfilled"); return false; } KalturaLog::debug("Rule conditions fulfilled"); if ($this->message) { $context->addAccessControlMessage($this->message); } foreach ($this->actions as $action) { $context->addAccessControlAction($action); } return true; }