示例#1
0
 /**
  * delete custom fields for an application
  *
  * @param string|Tinebase_Model_Application $_applicationId
  * @return integer numer of deleted custom fields
  */
 public function deleteCustomFieldsForApplication($_applicationId)
 {
     $this->_clearCache();
     $applicationId = Tinebase_Model_Application::convertApplicationIdToInt($_applicationId);
     $filterValues = array(array('field' => 'application_id', 'operator' => 'equals', 'value' => $applicationId));
     $filter = new Tinebase_Model_CustomField_ConfigFilter($filterValues);
     $filter->customfieldACLChecks(FALSE);
     $customFields = $this->_backendConfig->search($filter);
     $deletedCount = 0;
     foreach ($customFields as $customField) {
         $this->deleteCustomField($customField);
         $deletedCount++;
     }
     return $deletedCount;
 }
示例#2
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');
 }