本文整理汇总了PHP中categoryPeer::getByFullNameExactMatch方法的典型用法代码示例。如果您正苦于以下问题:PHP categoryPeer::getByFullNameExactMatch方法的具体用法?PHP categoryPeer::getByFullNameExactMatch怎么用?PHP categoryPeer::getByFullNameExactMatch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类categoryPeer
的用法示例。
在下文中一共展示了categoryPeer::getByFullNameExactMatch方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: retrieveByIdentifier
public function retrieveByIdentifier($value)
{
switch ($this->identifier) {
case CategoryIdentifierField::FULL_NAME:
return categoryPeer::getByFullNameExactMatch($value);
case CategoryIdentifierField::ID:
return categoryPeer::retrieveByPK($value);
case CategoryIdentifierField::REFERENCE_ID:
$objects = categoryPeer::getByReferenceId($value);
return $objects[0];
}
}
示例2: 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);
}
}
}
}
示例3: categoryFullNamesToIdsParsed
/**
* Convert the categories to categories ids
* to make search query shorter and to solve search problem when category tree is big.
*
* let's say entry belong to 2 categories with these full_ids
* 111>222>333
* 111>444
* Old categories fields was:
* 333,444
*
* New categories filed:
* pc111,p111,pc222,p222,pc333,c333,pc444,c444
*
* so why do we need pc111?
* If baseEntry->list with filter categoriesMatchOr= "111" you need to search for match pc111
*
* so why do we need p111?
* If baseEntry->list with filter categoriesMatchOr= "111>" you need to search for match p111
*
* @param string $cats Categories full names
* @param string $statuses comma seperated
* @return string Categogories indexes ids
*/
public static function categoryFullNamesToIdsParsed($cats, $statuses = null)
{
if ($cats === "") {
$cats = array();
} else {
$cats = explode(",", $cats);
}
kArray::trim($cats);
if ($statuses == null || trim($statuses) == '') {
$statuses = CategoryEntryStatus::ACTIVE;
}
$statuses = explode(',', trim($statuses));
$categoryFullNamesToIds = array();
foreach ($cats as $cat) {
if (substr($cat, -1) == '>') {
//entries that doesn't belog directly to this category - but only to the sub categories.
$categorySearchPrefix = entry::CATEGORY_PARENT_SEARCH_PERFIX;
$cat = substr($cat, 0, strlen($cat) - 1);
} else {
//entries that belog directly to this category or to a sub categories.
$categorySearchPrefix = entry::CATEGORY_OR_PARENT_SEARCH_PERFIX;
}
$category = categoryPeer::getByFullNameExactMatch($cat);
$categoryId = null;
if (!$category) {
$categoryId = category::CATEGORY_ID_THAT_DOES_NOT_EXIST;
} else {
$categoryId = $category->getId();
}
foreach ($statuses as $status) {
$categoryFullNamesToIds[] = $categorySearchPrefix . $categoryId . entry::CATEGORY_SEARCH_STATUS . $status;
}
}
return implode(",", $categoryFullNamesToIds);
}
示例4: checkAdminOnlyInsertProperties
/**
* Throws an error if trying to update admin only properties with normal user session
*
* @param KalturaBaseEntry $entry
*/
protected function checkAdminOnlyInsertProperties(KalturaBaseEntry $entry)
{
if ($entry->adminTags !== null) {
$this->validateAdminSession("adminTags");
}
if ($entry->categories !== null) {
$cats = explode(entry::ENTRY_CATEGORY_SEPARATOR, $entry->categories);
foreach ($cats as $cat) {
if (!categoryPeer::getByFullNameExactMatch($cat)) {
$this->validateAdminSession("categories");
}
}
}
if ($entry->startDate !== null) {
$this->validateAdminSession("startDate");
}
if ($entry->endDate !== null) {
$this->validateAdminSession("endDate");
}
if ($entry->accessControlId !== null) {
$this->validateAdminSession("accessControlId");
}
}
示例5: syncEntriesCategories
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());
//.........这里部分代码省略.........
示例6: categoryFullNamesToIdsParsed
/**
* Convert the categories to categories ids
* to make search query shorter and to solve search problem when category tree is big.
*
* let's say entry belong to 2 categories with these full_ids
* 111>222>333
* 111>444
* Old categories fields was:
* 333,444
*
* New categories filed:
* pc111,p111,pc222,p222,pc333,c333,pc444,c444
*
* so why do we need pc111?
* If baseEntry->list with filter categoriesMatchOr= "111" you need to search for match pc111
*
* so why do we need p111?
* If baseEntry->list with filter categoriesMatchOr= "111>" you need to search for match p111
*
* @param string $cats Categories full names
* @param string $statuses comma seperated statuses.null = no status filtering (default criteria still applies)
* @return string Categogories indexes ids
*/
public static function categoryFullNamesToIdsParsed($cats, $commaSeparatedStatuses = null)
{
if ($cats === "") {
$cats = array();
} else {
$cats = explode(",", $cats);
}
kArray::trim($cats);
$commaSeparatedStatuses = trim($commaSeparatedStatuses);
if (empty($commaSeparatedStatuses)) {
$statuses = null;
} else {
$statuses = explode(",", $commaSeparatedStatuses);
}
$categoryFullNamesToIds = array();
foreach ($cats as $cat) {
if (substr($cat, -1) == '>') {
//entries that doesn't belog directly to this category - but only to the sub categories.
$categorySearchPrefix = entry::CATEGORY_PARENT_SEARCH_PERFIX;
$cat = substr($cat, 0, strlen($cat) - 1);
} else {
//entries that belog directly to this category or to a sub categories.
$categorySearchPrefix = entry::CATEGORY_OR_PARENT_SEARCH_PERFIX;
}
$category = categoryPeer::getByFullNameExactMatch($cat);
$categoryId = null;
if (!$category) {
$categoryId = category::CATEGORY_ID_THAT_DOES_NOT_EXIST;
} else {
$categoryId = $category->getId();
}
if ($statuses) {
foreach ($statuses as $status) {
$categoryFullNamesToIds[] = $categorySearchPrefix . $categoryId . entry::CATEGORY_SEARCH_STATUS . $status;
}
} else {
$categoryFullNamesToIds[] = $categoryId;
// The cat. id AS-IS, no status filtering applied
}
}
return implode(",", $categoryFullNamesToIds);
}
示例7: addMediaEntryAction
/**
* add KalturaMediaEntry from email ingestion
*
* @action addMediaEntry
* @param KalturaMediaEntry $mediaEntry Media entry metadata
* @param string $uploadTokenId Upload token id
* @param int $emailProfId
* @param string $fromAddress
* @param string $emailMsgId
*
* @return KalturaMediaEntry
*
* @throws KalturaErrors::UPLOADED_FILE_NOT_FOUND_BY_TOKEN
* @throws KalturaErrors::EMAIL_INGESTION_PROFILE_NOT_FOUND
*
*/
function addMediaEntryAction(KalturaMediaEntry $mediaEntry, $uploadTokenId, $emailProfId, $fromAddress, $emailMsgId)
{
try {
// check that the uploaded file exists
$entryFullPath = kUploadTokenMgr::getFullPathByUploadTokenId($uploadTokenId);
if (!file_exists($entryFullPath)) {
throw new KalturaAPIException(KalturaErrors::UPLOADED_FILE_NOT_FOUND_BY_TOKEN);
}
// get the email profile by the given id
$existingEIP = EmailIngestionProfilePeer::retrieveByPK($emailProfId);
if (!$existingEIP) {
throw new KalturaAPIException(KalturaErrors::EMAIL_INGESTION_PROFILE_NOT_FOUND, $emailProfId);
}
$emailIP = new KalturaEmailIngestionProfile();
$emailIP->fromObject($existingEIP, $this->getResponseProfile());
// handle defaults for media entry metadata
$this->changeIfNull($mediaEntry->tags, $emailIP->defaultTags);
$this->changeIfNull($mediaEntry->adminTags, $emailIP->defaultAdminTags);
$this->changeIfNull($mediaEntry->conversionProfileId, $emailIP->conversionProfile2Id);
$this->changeIfNull($mediaEntry->userId, $emailIP->defaultUserId);
if (is_null($mediaEntry->categories) || is_null(categoryPeer::getByFullNameExactMatch($mediaEntry->categories))) {
$mediaEntry->categories = $emailIP->defaultCategory;
}
// validate the input object
//$entry->validatePropertyMinLength("name", 1);
if (!$mediaEntry->name) {
$mediaEntry->name = $this->getPartnerId() . '_' . time();
}
// first copy all the properties to the db entry, then we'll check for security stuff
$dbEntry = $mediaEntry->toObject(new entry());
if ($emailIP->moderationStatus == KalturaEntryModerationStatus::PENDING_MODERATION) {
$dbEntry->setModerate(true);
}
$dbEntry->setType(KalturaEntryType::MEDIA_CLIP);
$dbEntry->setMediaType(entry::ENTRY_MEDIA_TYPE_AUTOMATIC);
$this->checkAndSetValidUserInsert($mediaEntry, $dbEntry);
$this->checkAdminOnlyInsertProperties($mediaEntry);
$this->validateAccessControlId($mediaEntry);
$this->validateEntryScheduleDates($mediaEntry, $dbEntry);
$dbEntry->setPartnerId($this->getPartnerId());
$dbEntry->setSubpId($this->getPartnerId() * 100);
$dbEntry->setSourceId($uploadTokenId);
$dbEntry->setSourceLink($entryFullPath);
$dbEntry->setDefaultModerationStatus();
$dbEntry->save();
$te = new TrackEntry();
$te->setEntryId($dbEntry->getId());
$te->setTrackEventTypeId(TrackEntry::TRACK_ENTRY_EVENT_TYPE_ADD_ENTRY);
$te->setDescription(__METHOD__ . ":" . __LINE__ . "::ENTRY_MEDIA_SOURCE_EMAIL_INGESTION");
$te->setParam1Str($fromAddress);
$te->setParam2Str($emailMsgId);
$te->setParam3Str($emailProfId . '::' . $emailIP->emailAddress . '::' . $emailIP->mailboxId);
TrackEntry::addTrackEntry($te);
$kshow = $this->createDummyKShow();
$kshowId = $kshow->getId();
myEntryUtils::setEntryTypeAndMediaTypeFromFile($dbEntry, $entryFullPath);
// setup the needed params for my insert entry helper
$paramsArray = array("entry_media_source" => KalturaSourceType::FILE, "entry_media_type" => $dbEntry->getMediaType(), "entry_full_path" => $entryFullPath, "entry_license" => $dbEntry->getLicenseType(), "entry_credit" => $dbEntry->getCredit(), "entry_source_link" => $dbEntry->getSourceLink(), "entry_tags" => $dbEntry->getTags());
$token = $this->getKsUniqueString();
$insert_entry_helper = new myInsertEntryHelper(null, $dbEntry->getKuserId(), $kshowId, $paramsArray);
$insert_entry_helper->setPartnerId($this->getPartnerId(), $this->getPartnerId() * 100);
$insert_entry_helper->insertEntry($token, $dbEntry->getType(), $dbEntry->getId(), $dbEntry->getName(), $dbEntry->getTags(), $dbEntry);
$dbEntry = $insert_entry_helper->getEntry();
kUploadTokenMgr::closeUploadTokenById($uploadTokenId);
myNotificationMgr::createNotification(kNotificationJobData::NOTIFICATION_TYPE_ENTRY_ADD, $dbEntry);
$mediaEntry->fromObject($dbEntry, $this->getResponseProfile());
return $mediaEntry;
} catch (kCoreException $ex) {
if ($ex->getCode() == kUploadTokenException::UPLOAD_TOKEN_INVALID_STATUS) {
}
throw new KalturaAPIException(KalturaErrors::UPLOAD_TOKEN_INVALID_STATUS_FOR_ADD_ENTRY);
throw $ex;
}
}
示例8: createByPartnerAndFullName
/**
* Initialize new category using patnerId and fullName, this will also create the needed categories for the fullName
*
* @param $partnerId
* @param $fullName
* @return category
*/
public static function createByPartnerAndFullName($partnerId, $fullName)
{
$fullNameArray = explode(categoryPeer::CATEGORY_SEPARATOR, $fullName);
$fullNameTemp = "";
$parentId = 0;
foreach ($fullNameArray as $name) {
if ($fullNameTemp === "") {
$fullNameTemp .= $name;
} else {
$fullNameTemp .= categoryPeer::CATEGORY_SEPARATOR . $name;
}
$category = categoryPeer::getByFullNameExactMatch($fullNameTemp);
if (!$category) {
$category = new category();
$category->setPartnerId($partnerId);
$category->setParentId($parentId);
$category->setName($name);
$category->save();
}
$parentId = $category->getId();
}
return $category;
}
示例9: syncCategories
public function syncCategories()
{
if (!$this->is_categories_modified) {
return;
}
if ($this->categories != null && $this->categories !== "") {
$newCats = explode(self::ENTRY_CATEGORY_SEPARATOR, $this->categories);
} else {
$newCats = array();
}
if ($this->old_categories !== null && $this->old_categories !== "") {
$oldCats = explode(self::ENTRY_CATEGORY_SEPARATOR, $this->old_categories);
} else {
$oldCats = array();
}
$allIds = array();
$allIdsWithParents = array();
$addedCats = array();
$removedCats = array();
$remainingCats = array();
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) {
$category = categoryPeer::getByFullNameExactMatch($cat);
if ($category) {
$allIds[] = $category->getId();
$allIdsWithParents[] = $category->getId();
$allIdsWithParents = array_merge($allIdsWithParents, $category->getAllParentsIds());
}
}
$alreadyAddedCatIds = $allIdsWithParents;
foreach ($addedCats as $cat) {
$category = categoryPeer::getByFullNameExactMatch($cat);
if (!$category) {
$category = category::createByPartnerAndFullName($this->getPartnerId(), $cat);
}
$category->incrementEntriesCount(1, $alreadyAddedCatIds);
$allIds[] = $category->getId();
$alreadyAddedCatIds[] = $category->getId();
$alreadyAddedCatIds = array_merge($alreadyAddedCatIds, $category->getAllParentsIds());
}
$alreadyRemovedCatIds = $allIdsWithParents;
foreach ($removedCats as $cat) {
$category = categoryPeer::getByFullNameExactMatch($cat);
if ($category) {
$category->decrementEntriesCount(1, $alreadyRemovedCatIds);
$alreadyRemovedCatIds[] = $category->getId();
$alreadyRemovedCatIds = array_merge($alreadyRemovedCatIds, $category->getAllParentsIds());
}
}
$this->setCategoriesIds(implode(",", $allIds));
mySearchUtils::setSearchTextDiscreteForEntry($this);
parent::save();
$this->is_categories_modified = false;
}