Пример #1
0
 public function onProcessPermissionWhere(PermissionWhereEvent $event)
 {
     $idObject = intval(HU::get(self::URL_PARAM_OBJECT));
     $idInstance = intval(HU::get(self::URL_PARAM_INSTANCE));
     $where = $event->where;
     if ($idObject && $idInstance) {
         $where = HText::addCondition($where, 'id_object = :id_object_banner AND id_instance = :id_instance_banner');
         $event->params[':id_object_banner'] = $idObject;
         $event->params[':id_instance_banner'] = $idInstance;
     }
     $event->where = $where;
 }
 public function onProcessPermissionWhere(PermissionWhereEvent $event)
 {
     $where = $event->where;
     $idObject = HU::get(PhotogalleryPhoto::URL_PARAM_OBJECT);
     $idInstance = intval(HU::get(PhotogalleryPhoto::URL_PARAM_INSTANCE));
     if ($idObject && $idInstance) {
         $where = HText::addCondition($where, 'id_photogallery_object = :id_object_gallery');
         $where = HText::addCondition($where, 'id_photogallery_instance = :id_instance_gallery');
         $event->params[':id_object_gallery'] = $idObject;
         $event->params[':id_instance_gallery'] = $idInstance;
     }
     $event->where = $where;
 }
Пример #3
0
 public function onProcessPermissionWhere(PermissionWhereEvent $event)
 {
     //Формирование условия отбора
     $pkey = HU::get(ObjectUrlRule::PARAM_OBJECT_PARENT);
     $where = $event->where;
     if ($pkey == "") {
         //$where .= "id_object IS NULL OR id_object IN(SELECT id_object FROM da_object WHERE object_type<>".DA_OBJECT_TYPE_HEIR.")";
         $where = HText::addCondition($where, "id_module_parent IS NULL");
     } else {
         //$where .= "id_object IN(SELECT id_object FROM da_object WHERE object_type=".DA_OBJECT_TYPE_HEIR." AND table_name=$pkey)";
         $where = HText::addCondition($where, "id_module_parent=" . $pkey);
     }
     $event->where = $where;
 }
Пример #4
0
 public function getSearchCriteria()
 {
     $criteria = new CDbCriteria();
     if (!($objParameter = $this->getSearchObjectParamter())) {
         return $criteria;
     }
     switch ($objParameter->getType()) {
         case DataType::VARCHAR:
         case DataType::EDITOR:
         case DataType::TEXTAREA:
             $criteria->compare($objParameter->getFieldName(), $this->value, true);
             break;
         case DataType::INT:
         case DataType::PRIMARY_KEY:
             $criteria->compare($objParameter->getFieldName(), $this->value);
             break;
         case DataType::OBJECT:
             $objS = DaObject::getById($objParameter->getAdditionalParameter());
             $primParamS = $objS->getFieldByType(DataType::PRIMARY_KEY);
             $parametersSearch = $objS->parameters;
             $whereSearch = null;
             $i = 0;
             foreach ($parametersSearch as $param) {
                 $type = $param->getType();
                 if ($type == DataType::VARCHAR) {
                     $i++;
                     $whereSearch = HText::addCondition($whereSearch, $param->getFieldName() . ' LIKE :search' . $i, 'OR');
                     $criteria->params[':search' . $i] = '%' . $this->value . '%';
                 }
             }
             if ($whereSearch != null) {
                 $condition = HText::addCondition('', "t." . $objParameter->getFieldName() . " IN (SELECT " . $primParamS . " FROM " . $objS->table_name . " WHERE (" . $whereSearch . ") )");
                 $criteria->addCondition($condition, $condition);
             }
             break;
         case DataType::TIMESTAMP:
             if ($this->_tsBeginValue && $this->_tsEndValue) {
                 $criteria->addBetweenCondition($objParameter->getFieldName(), $this->_tsBeginValue, $this->_tsEndValue);
             } else {
                 $criteria->compare($objParameter->getFieldName(), $this->_tsOperator . $this->_tsBeginValue);
             }
             break;
     }
     return $criteria;
 }
Пример #5
0
 public function checkObjectInstance($authItem, $userId, $idObject, $idInstance, $checkEventWhere = true)
 {
     if (!$this->checkObject($authItem, $userId, $idObject, $params = array('idInstance' => $idInstance))) {
         return false;
     }
     if ($checkEventWhere) {
         $criteria = new CDbCriteria();
         $event = new PermissionWhereEvent(Yii::app()->controller, $idObject, null);
         $event->criteria = $criteria;
         Yii::app()->controller->raiseEvent(DefaultController::EVENT_ON_PROCESS_PERMISSION_WHERE, $event);
         $where = $event->where;
         if ($where != null || $criteria->condition != null) {
             $object = DaObject::getById($idObject);
             $field = $object->getFieldByType(DataType::PRIMARY_KEY);
             $where = HText::addCondition($where, $field . '=:id');
             $criteria->addCondition($where);
             $criteria->params = array_merge($criteria->params, $event->params);
             $criteria->params[':id'] = $idInstance;
             return $object->getModel()->exists($criteria);
         }
     }
     return true;
 }