Example #1
0
 /**
  * get customfield config ids by grant
  * 
  * @param string $_grant
  * @return array of ids
  */
 public function getCustomfieldConfigIdsByAcl($_grant)
 {
     $user = Tinebase_Core::getUser();
     if (is_object($user)) {
         $result = $this->_backendConfig->getByAcl($_grant, $user->getId());
     } else {
         $result = array();
     }
     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);
 }
Example #3
0
 /**
  * update to 3.16
  * - add customfield_acl table
  */
 public function update_15()
 {
     $declaration = new Setup_Backend_Schema_Table_Xml('<table>
         <name>customfield_acl</name>
         <version>1</version>
         <declaration>
             <field>
                 <name>id</name>
                 <type>text</type>
                 <length>40</length>
                 <notnull>true</notnull>
             </field>
             <field>
                 <name>customfield_id</name>
                 <type>text</type>
                 <length>40</length>
                 <notnull>true</notnull>
             </field>
             <field>
                 <name>account_type</name>
                 <type>enum</type>
                 <value>anyone</value>
                 <value>user</value>
                 <value>group</value>
                 <notnull>true</notnull>
             </field>
             <field>
                 <name>account_id</name>
                 <type>text</type>
                 <length>40</length>
                 <notnull>true</notnull>
             </field>
             <field>
                 <name>account_grant</name>
                 <type>text</type>
                 <length>40</length>
                 <notnull>true</notnull>
             </field>
             <index>
                 <name>customfield_id-account-type-account_id-account_grant</name>
                 <primary>true</primary>
                 <field>
                     <name>id</name>
                 </field>
                 <field>
                     <name>customfield_id</name>
                 </field>
                 <field>
                     <name>account_type</name>
                 </field>
                 <field>
                     <name>account_id</name>
                 </field>
                 <field>
                     <name>account_grant</name>
                 </field>
             </index>
             <index>
                 <name>id-account_type-account_id</name>
                 <field>
                     <name>customfield_id</name>
                 </field>
                 <field>
                     <name>account_type</name>
                 </field>
                 <field>
                     <name>account_id</name>
                 </field>
             </index>
             <index>
                 <name>customfield_acl::customfield_id--customfield_config::id</name>
                 <field>
                     <name>customfield_id</name>
                 </field>
                 <foreign>true</foreign>
                 <reference>
                     <table>customfield_config</table>
                     <field>id</field>
                     <ondelete>cascade</ondelete>
                 </reference>
             </index>
         </declaration>
     </table>');
     $this->createTable('customfield_acl', $declaration);
     // add grants to existing customfields
     $configBackend = new Tinebase_CustomField_Config();
     $allCfConfigs = $configBackend->search();
     foreach ($allCfConfigs as $cfConfig) {
         Tinebase_CustomField::getInstance()->setGrants($cfConfig, Tinebase_Model_CustomField_Grant::getAllGrants());
     }
     $this->setApplicationVersion('Tinebase', '3.16');
 }