本文整理汇总了PHP中kEntitlementUtils类的典型用法代码示例。如果您正苦于以下问题:PHP kEntitlementUtils类的具体用法?PHP kEntitlementUtils怎么用?PHP kEntitlementUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了kEntitlementUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doFromObject
public function doFromObject($dbObject, KalturaDetachedResponseProfile $responseProfile = null)
{
parent::doFromObject($dbObject, $responseProfile);
$dbEntry = entryPeer::retrieveByPK($dbObject->getEntryId());
if (!kEntitlementUtils::isEntitledForEditEntry($dbEntry)) {
/**
* @var kQuiz $kQuiz
*/
$kQuiz = QuizPlugin::validateAndGetQuiz($dbEntry);
$dbUserEntry = UserEntryPeer::retrieveByPK($this->quizUserEntryId);
if ($dbUserEntry && $dbUserEntry->getStatus() == QuizPlugin::getCoreValue('UserEntryStatus', QuizUserEntryStatus::QUIZ_SUBMITTED)) {
if (!$kQuiz->getShowCorrectAfterSubmission()) {
$this->isCorrect = KalturaNullableBoolean::NULL_VALUE;
$this->correctAnswerKeys = null;
$this->explanation = null;
}
} else {
if (!$kQuiz->getShowResultOnAnswer()) {
$this->isCorrect = KalturaNullableBoolean::NULL_VALUE;
}
if (!$kQuiz->getShowCorrectKeyOnAnswer()) {
$this->correctAnswerKeys = null;
$this->explanation = null;
}
}
}
}
示例2: validateForInsert
public function validateForInsert($propertiesToSkip = array())
{
parent::validateForInsert($propertiesToSkip);
$dbEntry = entryPeer::retrieveByPK($this->entryId);
QuizPlugin::validateAndGetQuiz($dbEntry);
if (!kEntitlementUtils::isEntitledForEditEntry($dbEntry)) {
throw new KalturaAPIException(KalturaErrors::INVALID_USER_ID);
}
}
示例3: validateForResponseProfile
public function validateForResponseProfile()
{
if (kEntitlementUtils::getEntitlementEnforcement()) {
if (PermissionPeer::isValidForPartner(PermissionName::FEATURE_ENABLE_RESPONSE_PROFILE_USER_CACHE, kCurrentContext::getCurrentPartnerId())) {
KalturaResponseProfileCacher::useUserCache();
return;
}
throw new KalturaAPIException(KalturaErrors::CANNOT_LIST_RELATED_ENTITLED_WHEN_ENTITLEMENT_IS_ENABLE, get_class($this));
}
}
示例4: setDefaultCriteriaFilter
/**
* Creates default criteria filter
*/
public static function setDefaultCriteriaFilter()
{
if (self::$s_criteria_filter == null) {
self::$s_criteria_filter = new criteriaFilter();
}
$c = KalturaCriteria::create(self::OM_CLASS);
if (kEntitlementUtils::getEntitlementEnforcement()) {
$privacyContexts = kEntitlementUtils::getKsPrivacyContextArray();
$c->addAnd(self::PRIVACY_CONTEXT, $privacyContexts, Criteria::IN);
}
$c->addAnd(self::INSTANCE_COUNT, 0, Criteria::GREATER_THAN);
self::$s_criteria_filter->setFilter($c);
}
示例5: validateAndUpdateQuizData
/**
* if user is entitled for this action will update quizData on entry
* @param entry $dbEntry
* @param KalturaQuiz $quiz
* @param int $currentVersion
* @param kQuiz|null $newQuiz
* @return KalturaQuiz
* @throws KalturaAPIException
*/
private function validateAndUpdateQuizData(entry $dbEntry, KalturaQuiz $quiz, $currentVersion = 0, kQuiz $newQuiz = null)
{
if (!kEntitlementUtils::isEntitledForEditEntry($dbEntry)) {
KalturaLog::debug('Update quiz allowed only with admin KS or entry owner or co-editor');
throw new KalturaAPIException(KalturaErrors::INVALID_USER_ID);
}
$quizData = $quiz->toObject($newQuiz);
$quizData->setVersion($currentVersion + 1);
QuizPlugin::setQuizData($dbEntry, $quizData);
$dbEntry->setIsTrimDisabled(true);
$dbEntry->save();
$quiz->fromObject($quizData);
return $quiz;
}
示例6: getListResponse
public function getListResponse(KalturaFilterPager $pager, KalturaDetachedResponseProfile $responseProfile = null)
{
if (kEntitlementUtils::getEntitlementEnforcement() && (is_null($this->objectIdIn) && is_null($this->objectIdEqual))) {
throw new KalturaAPIException(MetadataErrors::MUST_FILTER_ON_OBJECT_ID);
}
if (!$this->metadataObjectTypeEqual) {
throw new KalturaAPIException(MetadataErrors::MUST_FILTER_ON_OBJECT_TYPE);
}
if ($this->metadataObjectTypeEqual == MetadataObjectType::CATEGORY) {
if ($this->objectIdEqual) {
$categoryIds = array($this->objectIdEqual);
} else {
if ($this->objectIdIn) {
$categoryIds = explode(',', $this->objectIdIn);
}
}
if ($categoryIds) {
$categories = categoryPeer::retrieveByPKs($categoryIds);
if (!count($categories)) {
KalturaLog::debug("No categories found");
$response = new KalturaMetadataListResponse();
$response->objects = new KalturaMetadataArray();
$response->totalCount = 0;
return $response;
}
$categoryIds = array();
foreach ($categories as $category) {
$categoryIds[] = $category->getId();
}
$this->objectIdEqual = null;
$this->objectIdIn = implode(',', $categoryIds);
}
}
$metadataFilter = $this->toObject();
$c = KalturaCriteria::create(MetadataPeer::OM_CLASS);
$metadataFilter->attachToCriteria($c);
$pager->attachToCriteria($c);
$list = MetadataPeer::doSelect($c);
$response = new KalturaMetadataListResponse();
$response->objects = KalturaMetadataArray::fromDbArray($list, $responseProfile);
if ($c instanceof SphinxMetadataCriteria) {
$response->totalCount = $c->getRecordsCount();
} elseif ($pager->pageIndex == 1 && count($response->objects) < $pager->pageSize) {
$response->totalCount = count($response->objects);
} else {
$pager->detachFromCriteria($c);
$response->totalCount = MetadataPeer::doCount($c);
}
return $response;
}
示例7: getObjectSpecificCacheKey
private static function getObjectSpecificCacheKey(IBaseObject $object, $responseProfileKey)
{
$userRoles = kPermissionManager::getCurrentRoleIds();
sort($userRoles);
$objectType = get_class($object);
$objectId = $object->getPrimaryKey();
$partnerId = $object->getPartnerId();
$profileKey = $responseProfileKey;
$protocol = infraRequestUtils::getProtocol();
$ksType = kCurrentContext::getCurrentSessionType();
$userRoles = implode('-', $userRoles);
$host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '';
$entitlement = (int) kEntitlementUtils::getEntitlementEnforcement();
return "obj_rp{$profileKey}_p{$partnerId}_o{$objectType}_i{$objectId}_h{$protocol}_k{$ksType}_u{$userRoles}_w{$host}_e{$entitlement}";
}
示例8: isLiveAction
/**
* Delivering the status of a live stream (on-air/offline) if it is possible
*
* @action isLive
* @param string $id ID of the live stream
* @param KalturaPlaybackProtocol $protocol protocol of the stream to test.
* @return bool
*
* @throws KalturaErrors::LIVE_STREAM_STATUS_CANNOT_BE_DETERMINED
* @throws KalturaErrors::INVALID_ENTRY_ID
*/
public function isLiveAction($id, $protocol)
{
if (!kCurrentContext::$ks) {
kEntitlementUtils::initEntitlementEnforcement(null, false);
$liveStreamEntry = kCurrentContext::initPartnerByEntryId($id);
if (!$liveStreamEntry || $liveStreamEntry->getStatus() == entryStatus::DELETED) {
throw new KalturaAPIException(KalturaErrors::INVALID_ENTRY_ID, $id);
}
// enforce entitlement
$this->setPartnerFilters(kCurrentContext::getCurrentPartnerId());
} else {
$liveStreamEntry = entryPeer::retrieveByPK($id);
}
if (!$liveStreamEntry || $liveStreamEntry->getType() != entryType::LIVE_STREAM) {
throw new KalturaAPIException(KalturaErrors::INVALID_ENTRY_ID, $id);
}
if (!in_array($liveStreamEntry->getSource(), LiveEntry::$kalturaLiveSourceTypes)) {
KalturaResponseCacher::setConditionalCacheExpiry(self::ISLIVE_ACTION_NON_KALTURA_LIVE_CONDITIONAL_CACHE_EXPIRY);
}
/* @var $liveStreamEntry LiveStreamEntry */
if (in_array($liveStreamEntry->getSource(), array(KalturaSourceType::LIVE_STREAM, KalturaSourceType::LIVE_STREAM_ONTEXTDATA_CAPTIONS))) {
return $this->responseHandlingIsLive($liveStreamEntry->hasMediaServer());
}
$dpda = new DeliveryProfileDynamicAttributes();
$dpda->setEntryId($id);
$dpda->setFormat($protocol);
switch ($protocol) {
case KalturaPlaybackProtocol::HLS:
case KalturaPlaybackProtocol::APPLE_HTTP:
$url = $liveStreamEntry->getHlsStreamUrl();
foreach (array(KalturaPlaybackProtocol::HLS, KalturaPlaybackProtocol::APPLE_HTTP) as $hlsProtocol) {
$config = $liveStreamEntry->getLiveStreamConfigurationByProtocol($hlsProtocol, requestUtils::getProtocol());
if ($config) {
$url = $config->getUrl();
$protocol = $hlsProtocol;
break;
}
}
KalturaLog::info('Determining status of live stream URL [' . $url . ']');
$urlManager = DeliveryProfilePeer::getLiveDeliveryProfileByHostName(parse_url($url, PHP_URL_HOST), $dpda);
if ($urlManager) {
return $this->responseHandlingIsLive($urlManager->isLive($url));
}
break;
case KalturaPlaybackProtocol::HDS:
case KalturaPlaybackProtocol::AKAMAI_HDS:
$config = $liveStreamEntry->getLiveStreamConfigurationByProtocol($protocol, requestUtils::getProtocol());
if ($config) {
$url = $config->getUrl();
KalturaLog::info('Determining status of live stream URL [' . $url . ']');
$urlManager = DeliveryProfilePeer::getLiveDeliveryProfileByHostName(parse_url($url, PHP_URL_HOST), $dpda);
if ($urlManager) {
return $this->responseHandlingIsLive($urlManager->isLive($url));
}
}
break;
}
throw new KalturaAPIException(KalturaErrors::LIVE_STREAM_STATUS_CANNOT_BE_DETERMINED, $protocol);
}
示例9: __construct
public function __construct($feedId, $feedProcessingKey = null, $ks = null)
{
$this->feedProcessingKey = $feedProcessingKey;
myDbHelper::$use_alternative_con = myDbHelper::DB_HELPER_CONN_PROPEL3;
$microTimeStart = microtime(true);
KalturaLog::info("syndicationFeedRenderer- initialize ");
$this->syndicationFeedDb = $syndicationFeedDB = syndicationFeedPeer::retrieveByPK($feedId);
if (!$syndicationFeedDB) {
throw new Exception("Feed Id not found");
}
kCurrentContext::initKsPartnerUser($ks, $syndicationFeedDB->getPartnerId(), '');
kPermissionManager::init();
kEntitlementUtils::initEntitlementEnforcement($syndicationFeedDB->getPartnerId(), $syndicationFeedDB->getEnforceEntitlement());
if (!is_null($syndicationFeedDB->getPrivacyContext()) && $syndicationFeedDB->getPrivacyContext() != '') {
kEntitlementUtils::setPrivacyContextSearch($syndicationFeedDB->getPrivacyContext());
}
$tmpSyndicationFeed = KalturaSyndicationFeedFactory::getInstanceByType($syndicationFeedDB->getType());
$tmpSyndicationFeed->fromObject($syndicationFeedDB);
$this->syndicationFeed = $tmpSyndicationFeed;
// add partner to default criteria
myPartnerUtils::addPartnerToCriteria('category', $this->syndicationFeed->partnerId, true);
myPartnerUtils::addPartnerToCriteria('asset', $this->syndicationFeed->partnerId, true);
myPartnerUtils::resetPartnerFilter('entry');
$this->baseCriteria = clone entryPeer::getDefaultCriteriaFilter();
$startDateCriterion = $this->baseCriteria->getNewCriterion(entryPeer::START_DATE, time(), Criteria::LESS_EQUAL);
$startDateCriterion->addOr($this->baseCriteria->getNewCriterion(entryPeer::START_DATE, null));
$this->baseCriteria->addAnd($startDateCriterion);
$endDateCriterion = $this->baseCriteria->getNewCriterion(entryPeer::END_DATE, time(), Criteria::GREATER_EQUAL);
$endDateCriterion->addOr($this->baseCriteria->getNewCriterion(entryPeer::END_DATE, null));
$this->baseCriteria->addAnd($endDateCriterion);
$this->baseCriteria->addAnd(entryPeer::PARTNER_ID, $this->syndicationFeed->partnerId);
$this->baseCriteria->addAnd(entryPeer::STATUS, entryStatus::READY);
$this->baseCriteria->addAnd(entryPeer::TYPE, array(entryType::MEDIA_CLIP, entryType::MIX), Criteria::IN);
$this->baseCriteria->addAnd(entryPeer::MODERATION_STATUS, array(entry::ENTRY_MODERATION_STATUS_REJECTED, entry::ENTRY_MODERATION_STATUS_PENDING_MODERATION), Criteria::NOT_IN);
if ($this->syndicationFeed->playlistId) {
$this->entryFilters = myPlaylistUtils::getPlaylistFiltersById($this->syndicationFeed->playlistId);
foreach ($this->entryFilters as $entryFilter) {
$entryFilter->setPartnerSearchScope(baseObjectFilter::MATCH_KALTURA_NETWORK_AND_PRIVATE);
// partner scope already attached
}
$playlist = entryPeer::retrieveByPK($this->syndicationFeed->playlistId);
if ($playlist) {
if ($playlist->getMediaType() != entry::ENTRY_MEDIA_TYPE_XML) {
$this->staticPlaylist = true;
$this->staticPlaylistEntriesIdsOrder = explode(',', $playlist->getDataContent());
}
}
} else {
$this->entryFilters = array();
}
$microTimeEnd = microtime(true);
KalturaLog::info("syndicationFeedRenderer- initialization done [" . ($microTimeEnd - $microTimeStart) . "]");
}
示例10: indexAction
/**
* Index CategoryUser by userid and category id
*
* @action index
* @param string $userId
* @param int $categoryId
* @param bool $shouldUpdate
* @throws KalturaErrors::INVALID_CATEGORY_USER_ID
* @return int
*/
public function indexAction($userId, $categoryId, $shouldUpdate = true)
{
if (kEntitlementUtils::getEntitlementEnforcement()) {
throw new KalturaAPIException(KalturaErrors::CANNOT_INDEX_OBJECT_WHEN_ENTITLEMENT_IS_ENABLE);
}
$partnerId = kCurrentContext::$partner_id ? kCurrentContext::$partner_id : kCurrentContext::$ks_partner_id;
$kuser = kuserPeer::getActiveKuserByPartnerAndUid($partnerId, $userId);
if (!$kuser) {
throw new KalturaAPIException(KalturaErrors::INVALID_USER_ID);
}
$dbCategoryKuser = categoryKuserPeer::retrievePermittedKuserInCategory($categoryId, $kuser->getId(), null, false);
if (!$dbCategoryKuser) {
throw new KalturaAPIException(KalturaErrors::INVALID_CATEGORY_USER_ID);
}
if (!$shouldUpdate) {
$dbCategoryKuser->setUpdatedAt(time());
$dbCategoryKuser->save();
return $dbCategoryKuser->getId();
}
$dbCategoryKuser->reSetCategoryFullIds();
$dbCategoryKuser->reSetScreenName();
$dbCategoryKuser->save();
return $dbCategoryKuser->getId();
}
示例11: searchEntriesAction
/**
* Search caption asset items by filter, pager and free text
*
* @action searchEntries
* @param KalturaBaseEntryFilter $entryFilter
* @param KalturaCaptionAssetItemFilter $captionAssetItemFilter
* @param KalturaFilterPager $captionAssetItemPager
* @return KalturaBaseEntryListResponse
*/
public function searchEntriesAction(KalturaBaseEntryFilter $entryFilter = null, KalturaCaptionAssetItemFilter $captionAssetItemFilter = null, KalturaFilterPager $captionAssetItemPager = null)
{
if (!$captionAssetItemPager) {
$captionAssetItemPager = new KalturaFilterPager();
}
if (!$captionAssetItemFilter) {
$captionAssetItemFilter = new KalturaCaptionAssetItemFilter();
}
$captionAssetItemFilter->validatePropertyNotNull(array("contentLike", "contentMultiLikeOr", "contentMultiLikeAnd"));
$captionAssetItemCoreFilter = new CaptionAssetItemFilter();
$captionAssetItemFilter->toObject($captionAssetItemCoreFilter);
$entryIdChunks = array(NULL);
if ($entryFilter || kEntitlementUtils::getEntitlementEnforcement()) {
$entryCoreFilter = new entryFilter();
if ($entryFilter) {
$entryFilter->toObject($entryCoreFilter);
}
$entryCoreFilter->setPartnerSearchScope($this->getPartnerId());
$this->addEntryAdvancedSearchFilter($captionAssetItemFilter, $entryCoreFilter);
$entryCriteria = KalturaCriteria::create(entryPeer::OM_CLASS);
$entryCoreFilter->attachToCriteria($entryCriteria);
$entryCriteria->setLimit(self::MAX_NUMBER_OF_ENTRIES);
$entryCriteria->applyFilters();
$entryIds = $entryCriteria->getFetchedIds();
if (!$entryIds || !count($entryIds)) {
$entryIds = array('NOT_EXIST');
}
$entryIdChunks = array_chunk($entryIds, self::SIZE_OF_ENTRIES_CHUNK);
}
$entries = array();
$counter = 0;
$shouldSortCaptionFiltering = $entryFilter->orderBy ? true : false;
$captionAssetItemCriteria = KalturaCriteria::create(CaptionAssetItemPeer::OM_CLASS);
$captionAssetItemCoreFilter->attachToCriteria($captionAssetItemCriteria);
$captionAssetItemCriteria->setGroupByColumn('str_entry_id');
$captionAssetItemCriteria->setSelectColumn('str_entry_id');
foreach ($entryIdChunks as $chunk) {
$currCriteria = clone $captionAssetItemCriteria;
if ($chunk) {
$currCriteria->add(CaptionAssetItemPeer::ENTRY_ID, $chunk, KalturaCriteria::IN);
} else {
$captionAssetItemPager->attachToCriteria($currCriteria);
}
$currCriteria->applyFilters();
$currEntries = $currCriteria->getFetchedIds();
//sorting this chunk according to results of first sphinx query
if ($shouldSortCaptionFiltering) {
$currEntries = array_intersect($entryIds, $currEntries);
}
$entries = array_merge($entries, $currEntries);
$counter += $currCriteria->getRecordsCount();
}
$inputPageSize = $captionAssetItemPager->pageSize;
$inputPageIndex = $captionAssetItemPager->pageIndex;
//page index & size validation - no negative values & size not too big
$pageSize = max(min($inputPageSize, baseObjectFilter::getMaxInValues()), 0);
$pageIndex = max($captionAssetItemPager::MIN_PAGE_INDEX, $inputPageIndex) - 1;
$firstIndex = $pageSize * $pageIndex;
$entries = array_slice($entries, $firstIndex, $pageSize);
$dbList = entryPeer::retrieveByPKs($entries);
if ($shouldSortCaptionFiltering) {
//results ids mapping
$entriesMapping = array();
foreach ($dbList as $item) {
$entriesMapping[$item->getId()] = $item;
}
$dbList = array();
foreach ($entries as $entryId) {
if (isset($entriesMapping[$entryId])) {
$dbList[] = $entriesMapping[$entryId];
}
}
}
$list = KalturaBaseEntryArray::fromDbArray($dbList, $this->getResponseProfile());
$response = new KalturaBaseEntryListResponse();
$response->objects = $list;
$response->totalCount = $counter;
return $response;
}
示例12: retrieveEntitledAndNonIndexedByKuser
/**
* Return all categories kuser is entitled to view the content.
* (User may call category->get to view a category - but not to view its content)
*
* @param int $kuserId
* @param int $limit
* @return array<category>
*/
public static function retrieveEntitledAndNonIndexedByKuser($kuserId, $limit)
{
$partnerId = kCurrentContext::$partner_id ? kCurrentContext::$partner_id : kCurrentContext::$ks_partner_id;
$partner = PartnerPeer::retrieveByPK($partnerId);
$categoryGroupSize = kConf::get('max_number_of_memebrs_to_be_indexed_on_entry');
if ($partner && $partner->getCategoryGroupSize()) {
$categoryGroupSize = $partner->getCategoryGroupSize();
}
$c = KalturaCriteria::create(categoryPeer::OM_CLASS);
$filteredCategoriesIds = entryPeer::getFilterdCategoriesIds();
if (count($filteredCategoriesIds)) {
$c->addAnd(categoryPeer::ID, $filteredCategoriesIds, Criteria::IN);
}
$membersCountCrit = $c->getNewCriterion(categoryPeer::MEMBERS_COUNT, $categoryGroupSize, Criteria::GREATER_THAN);
$membersCountCrit->addOr($c->getNewCriterion(categoryPeer::ENTRIES_COUNT, kConf::get('category_entries_count_limit_to_be_indexed'), Criteria::GREATER_THAN));
$c->addAnd($membersCountCrit);
$c->setLimit($limit);
$c->addDescendingOrderByColumn(categoryPeer::UPDATED_AT);
//all fields needed from default criteria
//here we cannot use the default criteria, as we need to get all categories user is entitled to view the content.
//not deleted or purged
$c->add(self::STATUS, array(CategoryStatus::DELETED, CategoryStatus::PURGED), Criteria::NOT_IN);
$c->add(self::PARTNER_ID, $partnerId, Criteria::EQUAL);
//add privacy context
$privacyContextCrit = $c->getNewCriterion(self::PRIVACY_CONTEXTS, kEntitlementUtils::getKsPrivacyContext(), KalturaCriteria::IN_LIKE);
$privacyContextCrit->addTag(KalturaCriterion::TAG_ENTITLEMENT_CATEGORY);
$c->addAnd($privacyContextCrit);
//set privacy by ks and type
$crit = $c->getNewCriterion(self::PRIVACY, kEntitlementUtils::getPrivacyForKs($partnerId), Criteria::IN);
$crit->addTag(KalturaCriterion::TAG_ENTITLEMENT_CATEGORY);
//user is entitled to view all cantent that belong to categoires he is a membr of
$kuser = null;
$ksString = kCurrentContext::$ks ? kCurrentContext::$ks : '';
if ($ksString != '') {
$kuser = kCurrentContext::getCurrentKsKuser();
}
if ($kuser) {
// get the groups that the user belongs to in case she is not associated to the category directly
$kgroupIds = KuserKgroupPeer::retrieveKgroupIdsByKuserId($kuser->getId());
$kgroupIds[] = $kuser->getId();
$membersCrit = $c->getNewCriterion(self::MEMBERS, $kgroupIds, KalturaCriteria::IN_LIKE);
$membersCrit->addTag(KalturaCriterion::TAG_ENTITLEMENT_CATEGORY);
$crit->addOr($membersCrit);
}
$c->addAnd($crit);
$c->applyFilters();
$categoryIds = $c->getFetchedIds();
return $categoryIds;
}
示例13: validateCategories
/**
* To validate if user is entitled to the category � all needed is to select from the db.
*
* @throws KalturaErrors::ENTRY_CATEGORY_FIELD_IS_DEPRECATED
*/
public function validateCategories()
{
$partnerId = kCurrentContext::$ks_partner_id ? kCurrentContext::$ks_partner_id : kCurrentContext::$partner_id;
if (implode(',', kEntitlementUtils::getKsPrivacyContext()) != kEntitlementUtils::DEFAULT_CONTEXT . $partnerId && ($this->categoriesIds != null || $this->categories != null)) {
throw new KalturaAPIException(KalturaErrors::ENTRY_CATEGORY_FIELD_IS_DEPRECATED);
}
if ($this->categoriesIds != null) {
$catsNames = array();
$cats = explode(",", $this->categoriesIds);
foreach ($cats as $cat) {
$catName = categoryPeer::retrieveByPK($cat);
if (is_null($catName)) {
throw new KalturaAPIException(KalturaErrors::CATEGORY_NOT_FOUND, $cat);
}
}
}
if ($this->categories != null) {
$catsNames = array();
$cats = explode(",", $this->categories);
foreach ($cats as $cat) {
$catName = categoryPeer::getByFullNameExactMatch($cat);
if (is_null($catName)) {
KalturaCriterion::disableTag(KalturaCriterion::TAG_ENTITLEMENT_CATEGORY);
$catName = categoryPeer::getByFullNameExactMatch($cat);
if ($catName) {
throw new KalturaAPIException(KalturaErrors::CATEGORY_NOT_PERMITTED, $cat);
}
KalturaCriterion::restoreTag(KalturaCriterion::TAG_ENTITLEMENT_CATEGORY);
}
}
}
}
示例14: serveAction
/**
* Serve XML rendition of the Kaltura Live Transcoding Profile usable by the Wowza transcoding add-on
*
* @action serve
* @param string $streamName the id of the live entry with it's stream suffix
* @param string $hostname the media server host name
* @return file
*
* @throws KalturaErrors::ENTRY_ID_NOT_FOUND
* @throws WowzaErrors::INVALID_STREAM_NAME
*/
public function serveAction($streamName, $hostname = null)
{
$matches = null;
if (!preg_match('/^(\\d_.{8})_(\\d+)$/', $streamName, $matches)) {
throw new KalturaAPIException(WowzaErrors::INVALID_STREAM_NAME, $streamName);
}
$entryId = $matches[1];
$suffix = $matches[2];
$entry = null;
if (!kCurrentContext::$ks) {
kEntitlementUtils::initEntitlementEnforcement(null, false);
$entry = kCurrentContext::initPartnerByEntryId($entryId);
if (!$entry || $entry->getStatus() == entryStatus::DELETED) {
throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId);
}
// enforce entitlement
$this->setPartnerFilters(kCurrentContext::getCurrentPartnerId());
} else {
$entry = entryPeer::retrieveByPK($entryId);
}
if (!$entry || $entry->getType() != KalturaEntryType::LIVE_STREAM || !in_array($entry->getSource(), array(KalturaSourceType::LIVE_STREAM, KalturaSourceType::LIVE_STREAM_ONTEXTDATA_CAPTIONS))) {
throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId);
}
$mediaServer = null;
if ($hostname) {
$mediaServer = MediaServerPeer::retrieveByHostname($hostname);
}
$conversionProfileId = $entry->getConversionProfileId();
$liveParams = assetParamsPeer::retrieveByProfile($conversionProfileId);
$liveParamsInput = null;
$disableIngested = true;
foreach ($liveParams as $liveParamsItem) {
/* @var $liveParamsItem liveParams */
if ($liveParamsItem->getStreamSuffix() == $suffix) {
$liveParamsInput = $liveParamsItem;
if (!$liveParamsInput->hasTag(assetParams::TAG_SOURCE)) {
$liveParams = array($liveParamsInput);
$disableIngested = false;
}
break;
}
}
$ignoreLiveParamsIds = array();
if ($disableIngested) {
$conversionProfileAssetParams = flavorParamsConversionProfilePeer::retrieveByConversionProfile($conversionProfileId);
foreach ($conversionProfileAssetParams as $conversionProfileAssetParamsItem) {
/* @var $conversionProfileAssetParamsItem flavorParamsConversionProfile */
if ($conversionProfileAssetParamsItem->getOrigin() == assetParamsOrigin::INGEST) {
$ignoreLiveParamsIds[] = $conversionProfileAssetParamsItem->getFlavorParamsId();
}
}
}
// translate the $liveParams to XML according to doc: http://www.wowza.com/forums/content.php?304#configTemplate
$root = new SimpleXMLElement('<Root/>');
$transcode = $root->addChild('Transcode');
$encodes = $transcode->addChild('Encodes');
$groups = array();
foreach ($liveParams as $liveParamsItem) {
/* @var $liveParamsItem liveParams */
if (!$liveParamsItem->hasTag(assetParams::TAG_SOURCE) && in_array($liveParamsItem->getId(), $ignoreLiveParamsIds)) {
continue;
}
$this->appendLiveParams($entry, $mediaServer, $encodes, $liveParamsItem);
$tags = $liveParamsItem->getTagsArray();
$tags[] = 'all';
foreach ($tags as $tag) {
if (!isset($groups[$tag])) {
$groups[$tag] = array();
}
$systemName = $liveParamsItem->getSystemName() ? $liveParamsItem->getSystemName() : $liveParamsItem->getId();
$groups[$tag][] = $systemName;
}
}
$decode = $transcode->addChild('Decode');
$video = $decode->addChild('Video');
$video->addChild('Deinterlace', 'false');
$streamNameGroups = $transcode->addChild('StreamNameGroups');
foreach ($groups as $groupName => $groupMembers) {
$streamNameGroup = $streamNameGroups->addChild('StreamNameGroup');
$streamNameGroup->addChild('Name', $groupName);
$streamNameGroup->addChild('StreamName', '${SourceStreamName}_' . $groupName);
$members = $streamNameGroup->addChild('Members');
foreach ($groupMembers as $groupMember) {
$member = $members->addChild('Member');
$member->addChild('EncodeName', $groupMember);
}
}
$properties = $transcode->addChild('Properties');
$dom = new DOMDocument("1.0");
//.........这里部分代码省略.........
示例15: execute
/**
* 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");
$fileName = basename($fileName);
$ksStr = $this->getRequestParameter("ks");
$referrer = $this->getRequestParameter("referrer");
$referrer = base64_decode($referrer);
if (!is_string($referrer)) {
// base64_decode can return binary data
$referrer = "";
}
$entry = null;
if ($ksStr) {
try {
kCurrentContext::initKsPartnerUser($ksStr);
} catch (Exception $ex) {
KExternalErrors::dieError(KExternalErrors::INVALID_KS);
}
} else {
$entry = kCurrentContext::initPartnerByEntryId($entryId);
if (!$entry) {
KExternalErrors::dieError(KExternalErrors::ENTRY_NOT_FOUND);
}
}
kEntitlementUtils::initEntitlementEnforcement();
if (!$entry) {
$entry = entryPeer::retrieveByPK($entryId);
if (!$entry) {
KExternalErrors::dieError(KExternalErrors::ENTRY_NOT_FOUND);
}
} else {
if (!kEntitlementUtils::isEntryEntitled($entry)) {
KExternalErrors::dieError(KExternalErrors::ENTRY_NOT_FOUND);
}
}
myPartnerUtils::blockInactivePartner($entry->getPartnerId());
$securyEntryHelper = new KSecureEntryHelper($entry, $ksStr, $referrer, accessControlContextType::DOWNLOAD);
$securyEntryHelper->validateForDownload($entry, $ksStr);
$flavorAsset = null;
if ($flavorId) {
// get flavor asset
$flavorAsset = assetPeer::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 = assetPeer::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 = assetPeer::retrieveOriginalByEntryId($entryId);
}
if ($flavorAsset) {
$syncKey = $this->getSyncKeyAndForFlavorAsset($entry, $flavorAsset);
} else {
$syncKey = $this->getBestSyncKeyForEntry($entry);
}
if (is_null($syncKey)) {
KExternalErrors::dieError(KExternalErrors::FILE_NOT_FOUND);
}
$this->handleFileSyncRedirection($syncKey);
$filePath = kFileSyncUtils::getReadyLocalFilePathForKey($syncKey);
$wamsAssetId = kFileSyncUtils::getWamsAssetIdForKey($syncKey);
$wamsURL = kFileSyncUtils::getWamsURLForKey($syncKey);
list($fileBaseName, $fileExt) = $this->getFileName($entry, $flavorAsset);
if (!$fileName) {
$fileName = $fileBaseName;
}
if ($fileExt && !is_dir($filePath)) {
$fileName = $fileName . '.' . $fileExt;
}
//enable downloading file_name which inside the flavor asset directory
if (is_dir($filePath)) {
$filePath = $filePath . DIRECTORY_SEPARATOR . $fileName;
}
$this->dumpFile($filePath, $fileName, $wamsAssetId, $wamsURL);
die;
// no view
}