Beispiel #1
0
 /**
  * @action indexCategoryEntryTags
  * 
  * @param int $categoryId 
  * @param string $pcToDecrement
  * @param string $pcToIncrement
  */
 public function indexCategoryEntryTagsAction($categoryId, $pcToDecrement, $pcToIncrement)
 {
     $pcToDecrementArray = explode(',', $pcToDecrement);
     $c = KalturaCriteria::create(TagPeer::OM_CLASS);
     $c->add(TagPeer::PARTNER_ID, kCurrentContext::getCurrentPartnerId());
     $c->add(TagPeer::PRIVACY_CONTEXT, $pcToDecrementArray, KalturaCriteria::IN);
     TagPeer::setUseCriteriaFilter(false);
     $tagsToDecrement = TagPeer::doSelect($c);
     TagPeer::setUseCriteriaFilter(true);
     foreach ($tagsToDecrement as $tag) {
         /* @var $tag Tag */
         $tag->decrementInstanceCount();
     }
     $pcToIncrementArray = explode(',', $pcToIncrement);
     $tagsToIncrement = array();
     $c = new Criteria();
     $c->add(categoryEntryPeer::CATEGORY_ID, $categoryId);
     $catEntries = categoryEntryPeer::doSelect($c);
     foreach ($catEntries as $catEntry) {
         /* @var $catEntry categoryEntry */
         $entry = entryPeer::retrieveByPK($catEntry->getEntryId());
         if ($entry) {
             $tagsToIncrement = array_merge($tagsToIncrement, explode(',', $entry->getTags()));
         }
     }
     $tagsToIncrement = array_unique($tagsToIncrement);
     kTagFlowManager::addOrIncrementTags(implode(",", $tagsToIncrement), kCurrentContext::getCurrentPartnerId(), "entry", $pcToIncrementArray);
 }
if (isset($argv[3])) {
    $c->addAnd(entryPeer::UPDATED_AT, $argv[3], Criteria::GREATER_EQUAL);
}
$c->addAnd(entryPeer::TAGS, null, KalturaCriteria::NOT_EQUAL);
$c->addAnd(entryPeer::STATUS, entryStatus::DELETED, KalturaCriteria::NOT_EQUAL);
$c->setLimit($countLimitEachLoop);
$c->addAscendingOrderByColumn(entryPeer::UPDATED_AT);
$entryResults = entryPeer::doSelect($c, $con);
while ($entryResults && count($entryResults)) {
    foreach ($entryResults as $entry) {
        /* @var $entry entry */
        $entryTags = trimObjectTags($entry->getTags());
        if (!count($entryTags)) {
            continue;
        }
        $c = kTagFlowManager::getTagObjectsByTagStringsCriteria($entryTags, taggedObjectType::ENTRY, $entry->getPartnerId());
        $c->applyFilters();
        $numTagsFound = $c->getRecordsCount();
        if (!$numTagsFound) {
            $requiredTags = $entryTags;
        } else {
            $crit = new Criteria();
            $crit->addAnd(TagPeer::ID, $c->getFetchedIds(), KalturaCriteria::IN);
            $foundTagObjects = TagPeer::doSelect($crit);
            $foundTags = array();
            foreach ($foundTagObjects as $foundTag) {
                $foundTag->incrementInstanceCount();
                $foundTags[] = $foundTag->getTag();
            }
            $requiredTags = array_diff($entryTags, $foundTags);
        }