Ejemplo n.º 1
0
 public static function setDefaultCriteriaFilter()
 {
     if (self::$s_criteria_filter == null) {
         self::$s_criteria_filter = new criteriaFilter();
     }
     $c = KalturaCriteria::create(entryPeer::OM_CLASS);
     $c->addAnd(entryPeer::STATUS, entryStatus::DELETED, Criteria::NOT_EQUAL);
     $critEntitled = null;
     $ks = ks::fromSecureString(kCurrentContext::$ks);
     //when entitlement is enable and admin session or user session with list:* privilege
     if (kEntitlementUtils::getEntitlementEnforcement() && (kCurrentContext::$is_admin_session || !self::$userContentOnly)) {
         $privacyContexts = kEntitlementUtils::getPrivacyContextSearch();
         $critEntitled = $c->getNewCriterion(self::PRIVACY_BY_CONTEXTS, $privacyContexts, KalturaCriteria::IN_LIKE);
         $critEntitled->addTag(KalturaCriterion::TAG_ENTITLEMENT_ENTRY);
         if (kCurrentContext::getCurrentKsKuserId()) {
             //ENTITLED_KUSERS field includes $this->entitledUserEdit, $this->entitledUserEdit, and users on work groups categories.
             $entitledKuserByPrivacyContext = kEntitlementUtils::getEntitledKuserByPrivacyContext();
             $critEntitledKusers = $c->getNewCriterion(self::ENTITLED_KUSERS, $entitledKuserByPrivacyContext, KalturaCriteria::IN_LIKE);
             $critEntitledKusers->addTag(KalturaCriterion::TAG_ENTITLEMENT_ENTRY);
             $categoriesIds = array();
             $categoriesIds = categoryPeer::retrieveEntitledAndNonIndexedByKuser(kCurrentContext::getCurrentKsKuserId(), kConf::get('category_search_limit'));
             if (count($categoriesIds) >= kConf::get('category_search_limit')) {
                 self::$kuserBlongToMoreThanMaxCategoriesForSearch = true;
             }
             if (count($categoriesIds)) {
                 $critCategories = $c->getNewCriterion(self::CATEGORIES_IDS, $categoriesIds, KalturaCriteria::IN_LIKE);
                 $critCategories->addTag(KalturaCriterion::TAG_ENTITLEMENT_ENTRY);
                 $critEntitled->addOr($critCategories);
             }
             $critEntitled->addOr($critEntitledKusers);
         }
         //user should be able to get all entries s\he uploaded - outside the privacy context
         $kuser = kCurrentContext::getCurrentKsKuserId();
         if ($kuser !== 0) {
             $critKuser = $c->getNewCriterion(entryPeer::KUSER_ID, $kuser, Criteria::EQUAL);
             $critKuser->addTag(KalturaCriterion::TAG_ENTITLEMENT_ENTRY);
             $critEntitled->addOr($critKuser);
         }
     } elseif (self::$userContentOnly) {
         $critEntitled = $c->getNewCriterion(entryPeer::KUSER_ID, kCurrentContext::getCurrentKsKuserId(), Criteria::EQUAL);
         $critEntitled->addTag(KalturaCriterion::TAG_WIDGET_SESSION);
     }
     if ($ks && count($ks->getDisableEntitlementForEntry())) {
         $entryCrit = $c->getNewCriterion(entryPeer::ENTRY_ID, $ks->getDisableEntitlementForEntry(), Criteria::IN);
         $entryCrit->addTag(KalturaCriterion::TAG_ENTITLEMENT_ENTRY);
         if ($critEntitled) {
             $critEntitled->addOr($entryCrit);
         } else {
             $critEntitled = $entryCrit;
         }
     }
     if ($critEntitled) {
         $c->addAnd($critEntitled);
     }
     self::$s_criteria_filter->setFilter($c);
 }