本文整理汇总了PHP中KalturaFilterPager::detachFromCriteria方法的典型用法代码示例。如果您正苦于以下问题:PHP KalturaFilterPager::detachFromCriteria方法的具体用法?PHP KalturaFilterPager::detachFromCriteria怎么用?PHP KalturaFilterPager::detachFromCriteria使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KalturaFilterPager
的用法示例。
在下文中一共展示了KalturaFilterPager::detachFromCriteria方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getListResponse
/**
* @param KalturaFilterPager $pager
* @param KalturaDetachedResponseProfile $responseProfile
* @return KalturaListResponse
*/
public function getListResponse(KalturaFilterPager $pager, KalturaDetachedResponseProfile $responseProfile = null)
{
$response = new KalturaUserEntryListResponse();
if (in_array(kCurrentContext::getCurrentSessionType(), array(kSessionBase::SESSION_TYPE_NONE, kSessionBase::SESSION_TYPE_WIDGET))) {
$response->totalCount = 0;
return $response;
}
$c = new Criteria();
if (!is_null($this->userIdEqualCurrent) && $this->userIdEqualCurrent) {
$this->userIdEqual = kCurrentContext::getCurrentKsKuserId();
} else {
$this->fixFilterUserId();
}
$userEntryFilter = $this->toObject();
$userEntryFilter->attachToCriteria($c);
$pager->attachToCriteria($c);
$list = UserEntryPeer::doSelect($c);
$resultCount = count($list);
if ($resultCount && $resultCount < $pager->pageSize) {
$totalCount = ($pager->pageIndex - 1) * $pager->pageSize + $resultCount;
} else {
KalturaFilterPager::detachFromCriteria($c);
$totalCount = UserEntryPeer::doCount($c);
}
$response->totalCount = $totalCount;
$response->objects = KalturaUserEntryArray::fromDbArray($list, $responseProfile);
return $response;
}
示例2: doGetListResponse
protected function doGetListResponse(KalturaFilterPager $pager, array $types = null)
{
$this->validateEntryIdFiltered();
myDbHelper::$use_alternative_con = myDbHelper::DB_HELPER_CONN_PROPEL2;
// verify access to the relevant entries - either same partner as the KS or kaltura network
if ($this->entryIdEqual) {
$entryIds = array($this->entryIdEqual);
} else {
if ($this->entryIdIn) {
$entryIds = explode(',', $this->entryIdIn);
} else {
throw new KalturaAPIException(KalturaErrors::PROPERTY_VALIDATION_CANNOT_BE_NULL, 'KalturaAssetFilter::entryIdEqual/KalturaAssetFilter::entryIdIn');
}
}
$entryIds = array_slice($entryIds, 0, baseObjectFilter::getMaxInValues());
$c = KalturaCriteria::create(entryPeer::OM_CLASS);
$c->addAnd(entryPeer::ID, $entryIds, Criteria::IN);
$criterionPartnerOrKn = $c->getNewCriterion(entryPeer::PARTNER_ID, kCurrentContext::getCurrentPartnerId());
$criterionPartnerOrKn->addOr($c->getNewCriterion(entryPeer::DISPLAY_IN_SEARCH, mySearchUtils::DISPLAY_IN_SEARCH_KALTURA_NETWORK));
$c->addAnd($criterionPartnerOrKn);
$dbEntries = entryPeer::doSelect($c);
if (!$dbEntries) {
return array(array(), 0);
}
$entryIds = array();
foreach ($dbEntries as $dbEntry) {
$entryIds[] = $dbEntry->getId();
}
$this->entryIdEqual = null;
$this->entryIdIn = implode(',', $entryIds);
// get the flavors
$flavorAssetFilter = new AssetFilter();
$this->toObject($flavorAssetFilter);
$c = new Criteria();
$flavorAssetFilter->attachToCriteria($c);
if ($types) {
$c->add(assetPeer::TYPE, $types, Criteria::IN);
}
$pager->attachToCriteria($c);
$list = assetPeer::doSelect($c);
$resultCount = count($list);
if ($resultCount && $resultCount < $pager->pageSize) {
$totalCount = ($pager->pageIndex - 1) * $pager->pageSize + $resultCount;
} else {
KalturaFilterPager::detachFromCriteria($c);
$totalCount = assetPeer::doCount($c);
}
myDbHelper::$use_alternative_con = null;
return array($list, $totalCount);
}
示例3: doGetListResponse
protected function doGetListResponse(KalturaFilterPager $pager, array $types = null)
{
$this->validateEntryIdFiltered();
myDbHelper::$use_alternative_con = myDbHelper::DB_HELPER_CONN_PROPEL2;
// verify access to the relevant entries - either same partner as the KS or kaltura network
if ($this->entryIdEqual) {
$entryIds = array($this->entryIdEqual);
} else {
if ($this->entryIdIn) {
$entryIds = explode(',', $this->entryIdIn);
} else {
throw new KalturaAPIException(KalturaErrors::PROPERTY_VALIDATION_CANNOT_BE_NULL, 'KalturaAssetFilter::entryIdEqual/KalturaAssetFilter::entryIdIn');
}
}
$entryIds = entryPeer::filterEntriesByPartnerOrKalturaNetwork($entryIds, kCurrentContext::getCurrentPartnerId());
if (!$entryIds) {
return array(array(), 0);
}
$this->entryIdEqual = null;
$this->entryIdIn = implode(',', $entryIds);
// get the flavors
$flavorAssetFilter = new AssetFilter();
$this->toObject($flavorAssetFilter);
$c = new Criteria();
$flavorAssetFilter->attachToCriteria($c);
if ($types) {
$c->add(assetPeer::TYPE, $types, Criteria::IN);
}
$pager->attachToCriteria($c);
$list = assetPeer::doSelect($c);
$resultCount = count($list);
if ($resultCount && $resultCount < $pager->pageSize) {
$totalCount = ($pager->pageIndex - 1) * $pager->pageSize + $resultCount;
} else {
KalturaFilterPager::detachFromCriteria($c);
$totalCount = assetPeer::doCount($c);
}
myDbHelper::$use_alternative_con = null;
return array($list, $totalCount);
}
示例4: getListResponse
public function getListResponse(KalturaFilterPager $pager, KalturaDetachedResponseProfile $responseProfile = null)
{
$this->validateUserIdOrGroupIdFiltered();
if ($this->groupIdEqual) {
$partnerId = kCurrentContext::getCurrentPartnerId();
$c = new Criteria();
$c->add(kuserPeer::PARTNER_ID, $partnerId);
$c->add(kuserPeer::PUSER_ID, $this->groupIdEqual);
$c->add(kuserPeer::TYPE, KuserType::GROUP);
if (kCurrentContext::$ks_partner_id == Partner::BATCH_PARTNER_ID) {
//batch should be able to get categoryUser of deleted users.
kuserPeer::setUseCriteriaFilter(false);
}
// in case of more than one deleted kusers - get the last one
$c->addDescendingOrderByColumn(kuserPeer::UPDATED_AT);
$kuser = kuserPeer::doSelectOne($c);
kuserPeer::setUseCriteriaFilter(true);
if (!$kuser) {
$response = new KalturaGroupUserListResponse();
$response->objects = new KalturaGroupUserArray();
$response->totalCount = 0;
return $response;
}
$this->groupIdEqual = $kuser->getId();
}
if ($this->userIdEqual) {
$partnerId = kCurrentContext::getCurrentPartnerId();
$c = new Criteria();
$c->add(kuserPeer::PARTNER_ID, $partnerId);
$c->add(kuserPeer::PUSER_ID, $this->userIdEqual);
$c->add(kuserPeer::TYPE, KuserType::USER);
$kuser = kuserPeer::doSelectOne($c);
if (!$kuser) {
$response = new KalturaGroupUserListResponse();
$response->objects = new KalturaGroupUserArray();
$response->totalCount = 0;
return $response;
}
$this->userIdEqual = $kuser->getId();
}
if ($this->userIdIn) {
$usersIds = explode(',', $this->userIdIn);
$partnerId = kCurrentContext::getCurrentPartnerId();
$c = new Criteria();
$c->add(kuserPeer::PARTNER_ID, $partnerId, Criteria::EQUAL);
$c->add(kuserPeer::PUSER_ID, $usersIds, Criteria::IN);
$c->add(kuserPeer::TYPE, KuserType::USER);
$kusers = kuserPeer::doSelect($c);
if (!$kusers) {
$response = new KalturaGroupUserListResponse();
$response->objects = new KalturaGroupUserArray();
$response->totalCount = 0;
return $response;
}
$usersIds = array();
foreach ($kusers as $kuser) {
/* @var $kuser kuser */
$usersIds[] = $kuser->getId();
}
$this->userIdIn = implode(',', $usersIds);
}
if ($this->groupIdIn) {
$groupIdIn = explode(',', $this->groupIdIn);
$partnerId = kCurrentContext::getCurrentPartnerId();
$c = new Criteria();
$c->add(kuserPeer::PARTNER_ID, $partnerId, Criteria::EQUAL);
$c->add(kuserPeer::PUSER_ID, $groupIdIn, Criteria::IN);
$c->add(kuserPeer::TYPE, KuserType::GROUP);
$kusers = kuserPeer::doSelect($c);
if (!$kusers) {
$response = new KalturaGroupUserListResponse();
$response->objects = new KalturaGroupUserArray();
$response->totalCount = 0;
return $response;
}
$groupIdIn = array();
foreach ($kusers as $kuser) {
/* @var $kuser kuser */
$groupIdIn[] = $kuser->getId();
}
$this->groupIdIn = implode(',', $groupIdIn);
}
$kuserKgroupFilter = $this->toObject();
$c = KalturaCriteria::create(KuserKgroupPeer::OM_CLASS);
$kuserKgroupFilter->attachToCriteria($c);
$pager->attachToCriteria($c);
$c->applyFilters();
$list = KuserKgroupPeer::doSelect($c);
$newList = KalturaGroupUserArray::fromDbArray($list, $responseProfile);
$response = new KalturaGroupUserListResponse();
$response->objects = $newList;
$resultCount = count($newList);
if ($resultCount && $resultCount < $pager->pageSize) {
$totalCount = ($pager->pageIndex - 1) * $pager->pageSize + $resultCount;
} else {
KalturaFilterPager::detachFromCriteria($c);
$totalCount = KuserKgroupPeer::doCount($c);
}
$response->totalCount = $totalCount;
return $response;
//.........这里部分代码省略.........
示例5: getListResponse
public function getListResponse(KalturaFilterPager $pager, KalturaDetachedResponseProfile $responseProfile = null)
{
if ($this->entryIdEqual == null && $this->categoryIdIn == null && $this->categoryIdEqual == null && (kEntitlementUtils::getEntitlementEnforcement() || !kCurrentContext::$is_admin_session)) {
throw new KalturaAPIException(KalturaErrors::MUST_FILTER_ON_ENTRY_OR_CATEGORY);
}
if (kEntitlementUtils::getEntitlementEnforcement()) {
//validate entitl for entry
if ($this->entryIdEqual != null) {
$entry = entryPeer::retrieveByPK($this->entryIdEqual);
if (!$entry) {
throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $this->entryIdEqual);
}
}
//validate entitl for entryIn
if ($this->entryIdIn != null) {
$entry = entryPeer::retrieveByPKs($this->entryIdIn);
if (!$entry) {
throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $this->entryIdIn);
}
}
//validate entitl categories
if ($this->categoryIdIn != null) {
$categoryIdInArr = explode(',', $this->categoryIdIn);
if (!categoryKuserPeer::areCategoriesAllowed($categoryIdInArr)) {
$categoryIdInArr = array_unique($categoryIdInArr);
}
$entitledCategories = categoryPeer::retrieveByPKs($categoryIdInArr);
if (!count($entitledCategories) || count($entitledCategories) != count($categoryIdInArr)) {
throw new KalturaAPIException(KalturaErrors::CATEGORY_NOT_FOUND, $this->categoryIdIn);
}
$categoriesIdsUnlisted = array();
foreach ($entitledCategories as $category) {
if ($category->getDisplayInSearch() == DisplayInSearchType::CATEGORY_MEMBERS_ONLY) {
$categoriesIdsUnlisted[] = $category->getId();
}
}
if (count($categoriesIdsUnlisted)) {
if (!categoryKuserPeer::areCategoriesAllowed($categoriesIdsUnlisted)) {
throw new KalturaAPIException(KalturaErrors::CATEGORY_NOT_FOUND, $this->categoryIdIn);
}
}
}
//validate entitl category
if ($this->categoryIdEqual != null) {
$category = categoryPeer::retrieveByPK($this->categoryIdEqual);
if (!$category && kCurrentContext::$master_partner_id != Partner::BATCH_PARTNER_ID) {
throw new KalturaAPIException(KalturaErrors::CATEGORY_NOT_FOUND, $this->categoryIdEqual);
}
if ($category->getDisplayInSearch() == DisplayInSearchType::CATEGORY_MEMBERS_ONLY && !categoryKuserPeer::retrievePermittedKuserInCategory($category->getId(), kCurrentContext::getCurrentKsKuserId())) {
throw new KalturaAPIException(KalturaErrors::CATEGORY_NOT_FOUND, $this->categoryIdEqual);
}
}
}
$categoryEntryFilter = $this->toObject();
$c = KalturaCriteria::create(categoryEntryPeer::OM_CLASS);
$categoryEntryFilter->attachToCriteria($c);
if (!kEntitlementUtils::getEntitlementEnforcement() || $this->entryIdEqual == null) {
$pager->attachToCriteria($c);
}
$dbCategoriesEntry = categoryEntryPeer::doSelect($c);
if (kEntitlementUtils::getEntitlementEnforcement() && count($dbCategoriesEntry) && $this->entryIdEqual != null) {
//remove unlisted categories: display in search is set to members only
$categoriesIds = array();
foreach ($dbCategoriesEntry as $dbCategoryEntry) {
$categoriesIds[] = $dbCategoryEntry->getCategoryId();
}
$c = KalturaCriteria::create(categoryPeer::OM_CLASS);
$c->add(categoryPeer::ID, $categoriesIds, Criteria::IN);
$pager->attachToCriteria($c);
$c->applyFilters();
$categoryIds = $c->getFetchedIds();
foreach ($dbCategoriesEntry as $key => $dbCategoryEntry) {
if (!in_array($dbCategoryEntry->getCategoryId(), $categoryIds)) {
KalturaLog::info('Category [' . print_r($dbCategoryEntry->getCategoryId(), true) . '] is not listed to user');
unset($dbCategoriesEntry[$key]);
}
}
$totalCount = $c->getRecordsCount();
} else {
$resultCount = count($dbCategoriesEntry);
if ($resultCount && $resultCount < $pager->pageSize) {
$totalCount = ($pager->pageIndex - 1) * $pager->pageSize + $resultCount;
} else {
KalturaFilterPager::detachFromCriteria($c);
$totalCount = categoryEntryPeer::doCount($c);
}
}
$categoryEntrylist = KalturaCategoryEntryArray::fromDbArray($dbCategoriesEntry, $responseProfile);
$response = new KalturaCategoryEntryListResponse();
$response->objects = $categoryEntrylist;
$response->totalCount = $totalCount;
// no pager since category entry is limited to ENTRY::MAX_CATEGORIES_PER_ENTRY
return $response;
}
示例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: listAction
/**
* List application authentication tokens by filter and pager
*
* @action list
* @param KalturaFilterPager $filter
* @param KalturaAppTokenFilter $pager
* @return KalturaAppTokenListResponse
*/
function listAction(KalturaAppTokenFilter $filter = null, KalturaFilterPager $pager = null)
{
if (!$filter) {
$filter = new KalturaAppTokenFilter();
}
if (!$pager) {
$pager = new KalturaFilterPager();
}
$c = new Criteria();
$appTokenFilter = $filter->toObject();
$appTokenFilter->attachToCriteria($c);
$pager->attachToCriteria($c);
$list = AppTokenPeer::doSelect($c);
$totalCount = null;
$resultCount = count($list);
if ($resultCount && $resultCount < $pager->pageSize) {
$totalCount = ($pager->pageIndex - 1) * $pager->pageSize + $resultCount;
} else {
KalturaFilterPager::detachFromCriteria($c);
$totalCount = AppTokenPeer::doCount($c);
}
$response = new KalturaAppTokenListResponse();
$response->totalCount = $totalCount;
$response->objects = KalturaAppTokenArray::fromDbArray($list, $this->getResponseProfile());
return $response;
}