public function getIndexFieldType($field)
 {
     if (!self::$indexFieldTypes) {
         self::$indexFieldTypes = array('category_id' => IIndexable::FIELD_TYPE_STRING, 'kuser_id' => IIndexable::FIELD_TYPE_STRING, 'category_full_ids' => IIndexable::FIELD_TYPE_STRING, 'permission_names' => IIndexable::FIELD_TYPE_STRING, 'puser_id' => IIndexable::FIELD_TYPE_STRING, 'screen_name' => IIndexable::FIELD_TYPE_STRING, 'category_kuser_status' => IIndexable::FIELD_TYPE_STRING, 'partner_id' => IIndexable::FIELD_TYPE_STRING, 'update_method' => IIndexable::FIELD_TYPE_STRING, 'created_at' => IIndexable::FIELD_TYPE_DATETIME, 'updated_at' => IIndexable::FIELD_TYPE_DATETIME);
     }
     if (isset(self::$indexFieldTypes[$field])) {
         return self::$indexFieldTypes[$field];
     }
     return null;
 }
Example #2
0
 public function toObject($dbObject = null, $skip = array())
 {
     if (is_null($dbObject)) {
         $dbObject = new categoryKuser();
     }
     /* @var $dbObject categoryKuser */
     if (!$this->permissionNames && !is_null($this->permissionLevel) && $this->permissionLevel !== $dbObject->getPermissionLevel()) {
         $permissionNames = $dbObject->getPermissionNames();
         if ($permissionNames) {
             $permissionNamesArr = explode(',', $permissionNames);
             $permissionNamesArr = categoryKuser::removeCategoryPermissions($permissionNamesArr);
         } else {
             $permissionNamesArr = array();
         }
         $permissionNamesArr = categoryKuser::getPermissionNamesByPermissionLevel($this->permissionLevel);
         $dbObject->setPermissionNames(implode(',', $permissionNamesArr));
     }
     parent::toObject($dbObject, $skip);
     return $dbObject;
 }
Example #3
0
 protected function addCopyCategoryKuserJob($categoryId)
 {
     $templateCategory = new categoryKuser();
     $templateCategory->setCategoryId($this->getId());
     $filter = new categoryKuserFilter();
     $filter->setCategoryIdEqual($categoryId);
     kJobsManager::addCopyJob($this->getPartnerId(), CopyObjectType::CATEGORY_USER, $filter, $templateCategory);
 }
 public function translateSphinxCriterion(SphinxCriterion $crit)
 {
     $field = $crit->getTable() . '.' . $crit->getColumn();
     $value = $crit->getValue();
     $fieldName = null;
     if ($field == categoryKuserPeer::STATUS) {
         $fieldName = categoryKuserPeer::STATUS;
     }
     if ($fieldName) {
         $partnerIdCrit = $this->getCriterion(categoryKuserPeer::PARTNER_ID);
         if ($partnerIdCrit && $partnerIdCrit->getComparison() == Criteria::EQUAL) {
             $partnerId = $partnerIdCrit->getValue();
         } else {
             $partnerId = kCurrentContext::getCurrentPartnerId();
         }
         if (is_array($value)) {
             foreach ($value as &$singleValue) {
                 $singleValue = categoryKuser::getSearchIndexFieldValue($fieldName, $singleValue, $partnerId);
             }
         } else {
             $value = categoryKuser::getSearchIndexFieldValue($fieldName, $value, $partnerId);
         }
     }
     return array($field, $crit->getComparison(), $value);
 }
 public function toObject($dbObject = null, $skip = array())
 {
     if (is_null($dbObject)) {
         $dbObject = new categoryKuser();
     }
     /* @var $dbObject categoryKuser */
     if (!$this->permissionNames && !is_null($this->permissionLevel) && $this->permissionLevel !== $dbObject->getPermissionLevel()) {
         $permissionNames = $dbObject->getPermissionNames();
         if ($permissionNames) {
             $permissionNamesArr = explode(',', $permissionNames);
             $permissionNamesArr = categoryKuser::removeCategoryPermissions($permissionNamesArr);
         } else {
             $permissionNamesArr = array();
         }
         switch ($this->permissionLevel) {
             case CategoryKuserPermissionLevel::MEMBER:
                 $permissionNamesArr[] = PermissionName::CATEGORY_VIEW;
                 break;
             case CategoryKuserPermissionLevel::CONTRIBUTOR:
                 $permissionNamesArr[] = PermissionName::CATEGORY_CONTRIBUTE;
                 $permissionNamesArr[] = PermissionName::CATEGORY_VIEW;
                 break;
             case CategoryKuserPermissionLevel::MANAGER:
                 $permissionNamesArr[] = PermissionName::CATEGORY_EDIT;
                 $permissionNamesArr[] = PermissionName::CATEGORY_MODERATE;
                 $permissionNamesArr[] = PermissionName::CATEGORY_CONTRIBUTE;
                 $permissionNamesArr[] = PermissionName::CATEGORY_VIEW;
                 break;
             case CategoryKuserPermissionLevel::MODERATOR:
                 $permissionNamesArr[] = PermissionName::CATEGORY_MODERATE;
                 $permissionNamesArr[] = PermissionName::CATEGORY_VIEW;
                 break;
         }
         $dbObject->setPermissionNames(implode(',', $permissionNamesArr));
     }
     parent::toObject($dbObject, $skip);
     return $dbObject;
 }
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      categoryKuser $value A categoryKuser object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(categoryKuser $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         if (isset(self::$instances[$key]) || count(self::$instances) < kConf::get('max_num_instances_in_pool')) {
             self::$instances[$key] = $obj;
             kMemoryManager::registerPeer('categoryKuserPeer');
         }
     }
 }
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      categoryKuser $value A categoryKuser object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(categoryKuser $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }
 protected function applyFilterFields(baseObjectFilter $filter)
 {
     $partnerId = kCurrentContext::$partner_id ? kCurrentContext::$partner_id : kCurrentContext::$ks_partner_id;
     if ($filter->get('_in_status')) {
         $statusList = explode(',', $filter->get('_in_status'));
         foreach ($statusList as &$status) {
             $status = categoryKuser::getSearchIndexFieldValue(categoryKuserPeer::STATUS, $status, $partnerId);
         }
         $filter->set('_in_status', implode(',', $statusList));
     }
     if ($filter->get('_eq_status')) {
         $filter->set('_eq_status', categoryKuser::getSearchIndexFieldValue(categoryKuserPeer::STATUS, $filter->get('_eq_status'), $partnerId));
     }
     if ($filter->get('_in_update_method')) {
         $updateMethodList = explode(',', $filter->get('_in_update_method'));
         foreach ($updateMethodList as &$updateMethod) {
             $updateMethod = categoryKuser::getSearchIndexFieldValue(categoryKuserPeer::UPDATE_METHOD, $updateMethod, $partnerId);
         }
         $filter->set('_in_update_method', implode(',', $updateMethodList));
     }
     if ($filter->get('_eq_update_method')) {
         $filter->set('_eq_update_method', categoryKuser::getSearchIndexFieldValue(categoryKuserPeer::UPDATE_METHOD, $filter->get('_eq_update_method'), $partnerId));
     }
     if ($filter->get('_matchor_permission_names')) {
         $permissionNamesList = explode(',', $filter->get('_matchor_permission_names'));
         foreach ($permissionNamesList as &$permissionName) {
             $permissionName = categoryKuser::getSearchIndexFieldValue(categoryKuserPeer::PERMISSION_NAMES, $permissionName, $partnerId);
         }
         $filter->set('_matchor_permission_names', implode(',', $permissionNamesList));
     }
     if ($filter->get('_matchand_permission_names')) {
         $permissionNamesList = explode(',', $filter->get('_matchand_permission_names'));
         foreach ($permissionNamesList as &$permissionName) {
             $permissionName = categoryKuser::getSearchIndexFieldValue(categoryKuserPeer::PERMISSION_NAMES, $permissionName, $partnerId);
         }
         $filter->set('_matchand_permission_names', implode(',', $permissionNamesList));
     }
     if ($filter->get('_notcontains_permission_names')) {
         $permissionNamesList = explode(',', $filter->get('_notcontains_permission_names'));
         foreach ($permissionNamesList as &$permissionName) {
             $permissionName = categoryKuser::getSearchIndexFieldValue(categoryKuserPeer::PERMISSION_NAMES, $permissionName, $partnerId);
         }
         $filter->set('_notcontains_permission_names', $permissionNamesList);
     }
     if ($filter->get('_eq_category_full_ids')) {
         $filter->set('_eq_category_full_ids', $filter->get('_eq_category_full_ids') . category::FULL_IDS_EQUAL_MATCH_STRING);
     }
     return parent::applyFilterFields($filter);
 }