/** * returns array with the filter settings of this filter * * @param bool $_valueToJson resolve value for json api? * @return array */ public function toArray($_valueToJson = false) { $result = parent::toArray($_valueToJson); if ($this->_userOperator && $this->_userOperator == 'inGroup') { $result['operator'] = $this->_userOperator; $result['value'] = $this->_userValue; } if ($_valueToJson == true) { if ($this->_userOperator && $this->_userOperator == 'inGroup' && $this->_userValue) { $result['value'] = Tinebase_Group::getInstance()->getGroupById($this->_userValue)->toArray(); } else { switch ($this->_operator) { case 'equals': $result['value'] = $result['value'] ? Tinebase_User::getInstance()->getUserById($this->_value)->toArray() : $result['value']; break; case 'in': $result['value'] = array(); foreach ($this->_value as $userId) { $result['value'][] = Tinebase_User::getInstance()->getUserById($userId)->toArray(); } break; default: break; } } } return $result; }
/** * returns array with the filter settings of this filter * * @param bool $_valueToJson resolve value for json api? * @return array */ public function toArray($_valueToJson = false) { $result = parent::toArray($_valueToJson); if ($this->_userOperator && $this->_userOperator == 'inGroup') { $result['operator'] = $this->_userOperator; $result['value'] = $this->_userValue; } else { if ($this->_userValue === Tinebase_Model_User::CURRENTACCOUNT) { // switch back to CURRENTACCOUNT to make sure filter is saved and shown in client correctly $result['value'] = $this->_userValue; } } if ($_valueToJson == true) { if ($this->_userOperator && $this->_userOperator == 'inGroup' && $this->_userValue) { $result['value'] = Tinebase_Group::getInstance()->getGroupById($this->_userValue)->toArray(); } else { switch ($this->_operator) { case 'equals': $result['value'] = $result['value'] ? Tinebase_User::getInstance()->getUserById($this->_value)->toArray() : $result['value']; break; case 'in': $result['value'] = array(); foreach ($this->_value as $userId) { $result['value'][] = Tinebase_User::getInstance()->getUserById($userId)->toArray(); } break; default: break; } } } return $result; }
/** * returns array with the filter settings of this filter * * @param bool $_valueToJson resolve value for json api? * @return array */ public function toArray($_valueToJson = false) { $result = Tinebase_Model_Filter_Text::toArray($_valueToJson); if ($this->_value === '/' || $this->_value === '') { $node = new Tinebase_Model_Tree_Node(array('name' => 'root', 'path' => '/'), TRUE); } else { $node = new Tinebase_Model_Tree_Node(array('path' => $this->_value, 'name' => 'nodeName', 'object_id' => 1)); } $result['value'] = $node->toArray(); return $result; }
/** * get a new single filter action * * @param string|array $_fieldOrData * @param string $_operator * @param mixed $_value * @param array $_options */ public function __construct($_fieldOrData, $_operator = NULL, $_value = NULL, array $_options = array()) { // no legacy handling if (!is_array($_fieldOrData)) { throw new Tinebase_Exception_InvalidArgument('$_fieldOrDatamust be an array!'); } $be = new Tinebase_CustomField_Config(); $this->_cfRecord = $be->get($_fieldOrData['value']['cfId']); $type = $this->_cfRecord->definition['type']; if ($type == 'date' || $type == 'datetime') { $this->_subFilter = new Tinebase_Model_CustomField_ValueFilter(array()); $this->_subFilter->addFilter(new Tinebase_Model_Filter_Text(array('field' => 'customfield_id', 'operator' => 'equals', 'value' => $_fieldOrData['value']['cfId']))); $valueFilter = new Tinebase_Model_Filter_Date(array('field' => 'value', 'operator' => $_fieldOrData['operator'], 'value' => $_fieldOrData['value']['value'])); $this->_subFilter->addFilter($valueFilter); } elseif ($type == 'integer') { $valueFilter = new Tinebase_Model_Filter_Int($_fieldOrData, $_operator, $_value, $_options); } else { $valueFilter = new Tinebase_Model_Filter_Text($_fieldOrData, $_operator, $_value, $_options); } $this->_valueFilter = $valueFilter; $this->_operators = $valueFilter->getOperators(); $this->_opSqlMap = $valueFilter->getOpSqlMap(); parent::__construct($_fieldOrData, $_operator, $_value, $_options); }
/** * adds container type filter sql * * @param Zend_Db_Select $_select * @param Tinebase_Backend_Sql_Abstract $_backend */ protected function _addContainerTypeFilter($_select, $_backend) { $currentAccount = Tinebase_Core::getUser(); $appName = $this->_path->application->name; $ignoreAcl = $this->_options['ignoreAcl']; switch ($this->_path->containerType) { case Tinebase_Model_Container::TYPE_PERSONAL: if (!$this->_path->containerOwner) { throw new Tinebase_Exception_InvalidArgument('Container owner not set.'); } if ($this->_path->containerOwner == $currentAccount->accountLoginName) { $names = Tinebase_Container::getInstance()->getPersonalContainer($currentAccount, $appName, $currentAccount, $this->_requiredGrants, $ignoreAcl)->getArrayOfIds(); } else { $owner = Tinebase_User::getInstance()->getFullUserByLoginName($this->_path->containerOwner); $names = Tinebase_Container::getInstance()->getPersonalContainer($currentAccount, $appName, $owner, $this->_requiredGrants, $ignoreAcl)->getArrayOfIds(); } break; case Tinebase_Model_Container::TYPE_SHARED: $names = Tinebase_Container::getInstance()->getSharedContainer($currentAccount, $appName, $this->_requiredGrants, $ignoreAcl)->getArrayOfIds(); break; } if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) { Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Filter names: ' . print_r($names, TRUE)); } $nameFilter = new Tinebase_Model_Filter_Text('name', 'in', $names); $nameFilter->appendFilterSql($_select, $_backend); }
/** * you can define default filters here * @param Tinebase_Model_Filter_FilterGroup $_filter */ protected function _addDefaultFilter(Tinebase_Model_Filter_FilterGroup $_filter = NULL) { $lines = Sipgate_Controller_Line::getInstance()->search(new Sipgate_Model_LineFilter()); if ($lines->count()) { $aclFilter = new Tinebase_Model_Filter_Text(array('field' => 'line_id', 'operator' => 'in', 'value' => $lines->id)); $aclFilter->setIsImplicit(true); $_filter->addFilter($aclFilter); } else { $_filter->addFilter(new Tinebase_Model_Filter_Text(array('field' => 'entry_id', 'operator' => 'equals', 'value' => 'impossible'))); } }