Example #1
0
 /**
  * the filterCriteria will filter out all the doSelect methods - ONLY if the filter is turned on.
  * IMPORTANT - the filter is turend on by default and when switched off - should be turned on again manually .
  * 
  * @param      Criteria $criteria The Criteria object used to build the SELECT statement.
  */
 protected static function attachCriteriaFilter(Criteria $criteria)
 {
     categoryEntryPeer::getCriteriaFilter()->applyFilter($criteria);
 }
 private function setAllTemplateEntriesToAdminKuser($partnerId, $kuserId)
 {
     $c = new Criteria();
     $c->addAnd(entryPeer::PARTNER_ID, $partnerId, Criteria::EQUAL);
     entryPeer::setUseCriteriaFilter(false);
     $allEntries = entryPeer::doSelect($c);
     entryPeer::setUseCriteriaFilter(true);
     // set the new partner id into the default category criteria filter
     $defaultCategoryFilter = categoryPeer::getCriteriaFilter()->getFilter();
     $oldPartnerIdCategory = $defaultCategoryFilter->get(categoryPeer::PARTNER_ID);
     $defaultCategoryFilter->remove(categoryPeer::PARTNER_ID);
     $defaultCategoryFilter->addAnd(categoryPeer::PARTNER_ID, $partnerId);
     // set the new partner id into the default category criteria filter
     $defaultCategoryEntryFilter = categoryEntryPeer::getCriteriaFilter()->getFilter();
     $oldPartnerIdCategoryEntry = $defaultCategoryFilter->get(categoryEntryPeer::PARTNER_ID);
     $defaultCategoryEntryFilter->remove(categoryEntryPeer::PARTNER_ID);
     $defaultCategoryEntryFilter->addAnd(categoryEntryPeer::PARTNER_ID, $partnerId);
     foreach ($allEntries as $entry) {
         $entry->setKuserId($kuserId);
         $entry->setCreatorKuserId($kuserId);
         $entry->save();
     }
     kEventsManager::flushEvents();
     // restore the original partner id in the default category criteria filter
     $defaultCategoryFilter->remove(categoryPeer::PARTNER_ID);
     $defaultCategoryFilter->addAnd(categoryPeer::PARTNER_ID, $oldPartnerIdCategory);
     $defaultCategoryEntryFilter->remove(categoryEntryPeer::PARTNER_ID);
     $defaultCategoryEntryFilter->addAnd(categoryEntryPeer::PARTNER_ID, $oldPartnerIdCategoryEntry);
 }