Beispiel #1
0
 /**
  *  Callback method for setting a property
  */
 function __set($prop_name, $prop_value)
 {
     if (isset($this->model->fields[$prop_name])) {
         if (isset($this->fields[$prop_name])) {
             $this->fields[$prop_name]->equals($prop_value);
         } else {
             $result = new FilterField($this, $this->model->fields[$prop_name]);
             $result->and = $this->grouplevel == 0;
             $result->equals($prop_value);
             $this->fields[$prop_name] =& $result;
             if ($this->grouplevel > 0) {
                 $this->grouplevel--;
             }
         }
         return true;
     } else {
         if ($prop_name == $this->model->primary_key) {
             if (isset($this->fields[$prop_name])) {
                 $this->fields[$prop_name]->equals($prop_value);
             } else {
                 $field = new Field($prop_name, Field::NUMBER);
                 $result = new FilterField($this, $field);
                 $result->equals($prop_value);
                 $this->fields[$prop_name] =& $result;
                 $result->and = $this->grouplevel == 0;
                 if ($this->grouplevel > 0) {
                     $this->grouplevel--;
                 }
             }
             return true;
         } else {
             return false;
         }
     }
     //throw new ModelException("Field '$prop_name' doesn't exist in this filter.");
 }
    /**
     * Save a created filter
     * @param sfWebRequest $request
     * @return <type>
     */
    public function executeSaveFilter(sfWebRequest $request) {
		
        $sender_id = $request->getPostParameter('filter_sender') == '' ? -1 : $request->getPostParameter('filter_sender');
        $currentStation_id = $request->getPostParameter('filter_currentstation') == '' ? -1 : $request->getPostParameter('filter_currentstation');
        $mailingList = $request->getPostParameter('filter_mailinglist') == '' ? -1 : $request->getPostParameter('filter_mailinglist');
        $documentTemplate = $request->getPostParameter('filter_documenttemplate') == '' ? -1 : $request->getPostParameter('filter_documenttemplate');

        $filter = new Filter();
        $filter->setFiltername($request->getPostParameter('filter_hiddenname',''));
        $filter->setName($request->getPostParameter('filter_name',''));
        $filter->setSenderId($sender_id);
        $filter->setDaysfrom($request->getPostParameter('filter_daysinprogress_from',''));
        $filter->setDaysto($request->getPostParameter('filter_daysinprogress_to',''));
        $filter->setSendetfrom($request->getPostParameter('filter_sendet_from',''));
        $filter->setSendetto($request->getPostParameter('filter_sendet_to',''));
        $filter->setWorkflowprocessuserId($currentStation_id);
        $filter->setMailinglistversionId($mailingList);
        $filter->setDocumenttemplateversionId($documentTemplate);
        $filter->save();
        $filterId = $filter->getId();
        // save the field grid
        if($request->hasParameter('field')) {
            $fields = $request->getParameter('field');
            $operators = $request->getParameter('operator');
            $values = $request->getParameter('value');
            foreach($fields as $key => $field) {
                $operator = $operators[$key];
                $value = $values[$key];
                if($field != '' AND $operator != '' AND $value != '') {
                    $filterField = new FilterField();
                    $filterField->setFilterId($filterId);
                    $filterField->setFieldId($field);
                    $filterField->setOperator($operator);
                    $filterField->setValue($value);
                    $filterField->save();
                }
                
            }
        }


        $this->renderText('{success:true}');
        return sfView::NONE;
    }
 private static function parseFilterBlueprint($xml)
 {
     $blueprint = new FilterBlueprint((string) $xml['key']);
     $blueprint->setName((string) $xml['name']);
     // iterate through blueprints fields, defining them in blueprint object
     foreach ($xml->field as $f) {
         $field = new FilterField((string) $f['key']);
         $field->setDisplayName((string) $f->displayName);
         $field->setFilterType((string) $f->filterType);
         $field->setDisplay((string) $f->display);
         $field->setWhere((string) $f->where);
         $blueprint->add($field);
     }
     return $blueprint;
 }
 /**
  * @param $data
  * @return FilterExpression
  */
 public static function createFrom($data)
 {
     $result = new FilterExpression();
     if (isset($data['children']) && is_array($data['children'])) {
         foreach ($data['children'] as $child) {
             $result->add(FilterField::createFrom($child));
         }
     }
     return $result;
 }
Beispiel #5
0
 /**
  * @param $data
  * @return FilterField
  */
 public static function createFrom($data)
 {
     if (isset($data['field']) && preg_match('/^\\[([a-z_]+)\\]\\[([a-z_]+)\\]$/', $data['field'], $matches)) {
         $result = new FilterField($matches[2]);
         $result->setAttribute('tableName', $matches[1]);
         if (isset($data['type'])) {
             $result->setAttribute('type', $data['type']);
             if (isset($data['condition'])) {
                 $result->condition = $data['condition'];
             }
             if (isset($data['value'])) {
                 $result->value = $data['value'];
             }
             if (isset($data['operator'])) {
                 $result->operator = $data['operator'];
             }
         }
     }
     return $result;
 }