本文整理汇总了PHP中categoryPeer::doSelectOne方法的典型用法代码示例。如果您正苦于以下问题:PHP categoryPeer::doSelectOne方法的具体用法?PHP categoryPeer::doSelectOne怎么用?PHP categoryPeer::doSelectOne使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类categoryPeer
的用法示例。
在下文中一共展示了categoryPeer::doSelectOne方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getByFullNameExactMatch
/**
* Get category by full name using exact match (returns null or category object)
*
* @param $partnerId
* @param $fullName
* @param $con
* @return category
*/
public static function getByFullNameExactMatch($fullName, $con = null)
{
$fullName = self::getParsedFullName($fullName);
$c = new Criteria();
$c->add(categoryPeer::FULL_NAME, $fullName);
return categoryPeer::doSelectOne($c, $con);
}
示例2: getByFullNameExactMatch
/**
* Get category by full name using exact match (returns null or category object)
*
* @param $fullName
* @param $ignoreCategoryId
* @param $partnerId
* @return category
*/
public static function getByFullNameExactMatch($fullName, $ignoreCategoryId = null, $partnerId = null)
{
$fullName = self::getParsedFullName($fullName);
if (trim($fullName) == '') {
return null;
}
$c = KalturaCriteria::create(categoryPeer::OM_CLASS);
$c->add(categoryPeer::FULL_NAME, $fullName);
if ($ignoreCategoryId) {
$c->add(categoryPeer::ID, $ignoreCategoryId, Criteria::NOT_EQUAL);
}
$tagDisabled = false;
if (!is_null($partnerId)) {
$tagDisabled = true;
KalturaCriterion::disableTag(KalturaCriterion::TAG_PARTNER_SESSION);
$c->add(categoryPeer::PARTNER_ID, $partnerId);
}
$ret = categoryPeer::doSelectOne($c);
if ($tagDisabled) {
KalturaCriterion::restoreTag(KalturaCriterion::TAG_PARTNER_SESSION);
}
return $ret;
}
示例3: isEntryEntitled
/**
* Returns true if kuser or current kuser is entitled to entryId
* @param entry $entry
* @param int $kuser
* @return bool
*/
public static function isEntryEntitled(entry $entry, $kuserId = null)
{
$ks = ks::fromSecureString(kCurrentContext::$ks);
// entry is entitled when entitlement is disable
// for actions with no ks - need to check if partner have default entitlement feature enable.
if (!self::getEntitlementEnforcement() && $ks) {
KalturaLog::debug('Entry entitled: entitlement disabled');
return true;
}
$partner = $entry->getPartner();
if (!$ks && !$partner->getDefaultEntitlementEnforcement()) {
KalturaLog::debug('Entry [' . print_r($entry->getId(), true) . '] entitled: no ks and default is with no enforcement');
return true;
}
if ($ks && $ks->isWidgetSession() && $ks->getDisableEntitlementForEntry() == $entry->getId()) {
KalturaLog::debug('Entry [' . print_r($entry->getId(), true) . '] entitled: widget session that disble entitlement for this entry');
return true;
}
$allCategoriesEntry = categoryEntryPeer::retrieveActiveAndPendingByEntryId($entry->getId());
$categories = array();
foreach ($allCategoriesEntry as $categoryEntry) {
$categories[] = $categoryEntry->getCategoryId();
}
//if entry doesn't belong to any category.
$categories[] = category::CATEGORY_ID_THAT_DOES_NOT_EXIST;
$c = KalturaCriteria::create(categoryPeer::OM_CLASS);
$c->add(categoryPeer::ID, $categories, Criteria::IN);
$privacy = array(PrivacyType::ALL);
if ($ks && !$ks->isWidgetSession()) {
$privacy[] = PrivacyType::AUTHENTICATED_USERS;
}
$crit = $c->getNewCriterion(categoryPeer::PRIVACY, $privacy, Criteria::IN);
$ksPrivacyContexts = null;
// entry that doesn't belong to any category is public
//when ks is not provided - the entry is still public (for example - download action)
$categoryEntries = categoryEntryPeer::retrieveActiveByEntryId($entry->getId());
if (!count($categoryEntries) && !$ks) {
KalturaLog::debug('Entry [' . print_r($entry->getId(), true) . '] entitled: entry does not belong to any category');
return true;
}
if ($ks) {
$ksPrivacyContexts = $ks->getPrivacyContext();
if (!$ksPrivacyContexts || trim($ksPrivacyContexts) == '') {
$ksPrivacyContexts = self::DEFAULT_CONTEXT . $partner->getId();
if (!count($allCategoriesEntry)) {
// entry that doesn't belong to any category is public
KalturaLog::debug('Entry [' . print_r($entry->getId(), true) . '] entitled: entry does not belong to any category and privacy context on the ks is not set');
return true;
}
}
$c->add(categoryPeer::PRIVACY_CONTEXTS, $ksPrivacyContexts, KalturaCriteria::IN_LIKE);
if (!$kuserId) {
$partnerId = kCurrentContext::$partner_id ? kCurrentContext::$partner_id : kCurrentContext::$ks_partner_id;
$kuser = kuserPeer::getKuserByPartnerAndUid($partnerId, kCurrentContext::$ks_uid, true);
if ($kuser) {
$kuserId = $kuser->getId();
}
}
if ($kuserId) {
// kuser is set on the entry as creator or uploader
if ($kuserId != '' && $entry->getKuserId() == $kuserId) {
KalturaLog::debug('Entry [' . print_r($entry->getId(), true) . '] entitled: ks user is the same as entry->kuserId or entry->creatorKuserId [' . $kuserId . ']');
return true;
}
// kuser is set on the entry entitled users edit or publish
$entitledKusers = array_merge(explode(',', $entry->getEntitledKusersEdit()), explode(',', $entry->getEntitledKusersPublish()));
if (in_array($kuserId, $entitledKusers)) {
KalturaLog::debug('Entry [' . print_r($entry->getId(), true) . '] entitled: ks user is the same as entry->entitledKusersEdit or entry->entitledKusersPublish');
return true;
}
}
// kuser is set on the category as member
// this ugly code is temporery - since we have a bug in sphinxCriteria::getAllCriterionFields
if ($kuserId) {
$membersCrit = $c->getNewCriterion(categoryPeer::MEMBERS, $kuserId, Criteria::LIKE);
$membersCrit->addOr($crit);
$crit = $membersCrit;
}
} else {
//no ks = set privacy context to default.
$c->add(categoryPeer::PRIVACY_CONTEXTS, array(self::DEFAULT_CONTEXT . $partner->getId()), KalturaCriteria::IN_LIKE);
}
$c->addAnd($crit);
//remove default FORCED criteria since categories that has display in search = public - doesn't mean that all of their entries are public
KalturaCriterion::disableTag(KalturaCriterion::TAG_ENTITLEMENT_CATEGORY);
$category = categoryPeer::doSelectOne($c);
KalturaCriterion::restoreTag(KalturaCriterion::TAG_ENTITLEMENT_CATEGORY);
if ($category) {
KalturaLog::debug('Entry [' . print_r($entry->getId(), true) . '] entitled: ks user is a member of this category or category privacy is set to public of authenticated');
return true;
}
KalturaLog::debug('Entry [' . print_r($entry->getId(), true) . '] not entitled');
return false;
}
示例4: isMemberOfCategory
private static function isMemberOfCategory($allCategoriesEntry, entry $entry, Partner $partner, $kuserId = null, $ks = null, $ksPrivacyContexts = null)
{
$categories = array();
foreach ($allCategoriesEntry as $categoryEntry) {
$categories[] = $categoryEntry->getCategoryId();
}
//if entry doesn't belong to any category.
$categories[] = category::CATEGORY_ID_THAT_DOES_NOT_EXIST;
$c = KalturaCriteria::create(categoryPeer::OM_CLASS);
$c->add(categoryPeer::ID, $categories, Criteria::IN);
$privacy = array(category::formatPrivacy(PrivacyType::ALL, $partner->getId()));
if ($ks && !$ks->isAnonymousSession()) {
$privacy[] = category::formatPrivacy(PrivacyType::AUTHENTICATED_USERS, $partner->getId());
}
$crit = $c->getNewCriterion(categoryPeer::PRIVACY, $privacy, Criteria::IN);
if ($ks) {
if (!$ksPrivacyContexts || trim($ksPrivacyContexts) == '') {
$ksPrivacyContexts = self::DEFAULT_CONTEXT . $partner->getId();
}
$c->add(categoryPeer::PRIVACY_CONTEXTS, $ksPrivacyContexts, KalturaCriteria::IN_LIKE);
// kuser is set on the category as member
// this ugly code is temporery - since we have a bug in sphinxCriteria::getAllCriterionFields
if ($kuserId) {
// get the groups that the user belongs to in case she is not associated to the category directly
$kgroupIds = KuserKgroupPeer::retrieveKgroupIdsByKuserId($kuserId);
$kgroupIds[] = $kuserId;
$membersCrit = $c->getNewCriterion(categoryPeer::MEMBERS, $kgroupIds, KalturaCriteria::IN_LIKE);
$membersCrit->addOr($crit);
$crit = $membersCrit;
}
} else {
//no ks = set privacy context to default.
$c->add(categoryPeer::PRIVACY_CONTEXTS, array(self::DEFAULT_CONTEXT . $partner->getId()), KalturaCriteria::IN_LIKE);
}
$c->addAnd($crit);
//remove default FORCED criteria since categories that has display in search = public - doesn't mean that all of their entries are public
KalturaCriterion::disableTag(KalturaCriterion::TAG_ENTITLEMENT_CATEGORY);
$category = categoryPeer::doSelectOne($c);
KalturaCriterion::restoreTag(KalturaCriterion::TAG_ENTITLEMENT_CATEGORY);
if ($category) {
KalturaLog::debug('Entry [' . print_r($entry->getId(), true) . '] entitled: ks user is a member of this category or category privacy is set to public of authenticated');
return true;
}
KalturaLog::debug('Entry [' . print_r($entry->getId(), true) . '] not entitled');
return false;
}