Merge branch '2012.10'
authorPhilipp Schüle <p.schuele@metaways.de>
Mon, 11 Feb 2013 11:22:30 +0000 (12:22 +0100)
committerPhilipp Schüle <p.schuele@metaways.de>
Mon, 11 Feb 2013 11:22:30 +0000 (12:22 +0100)
Conflicts:
tine20/ActiveSync/Setup/Update/Release6.php
tine20/ActiveSync/Setup/setup.xml

1  2 
tine20/ActiveSync/Setup/Update/Release6.php
tine20/ActiveSync/Setup/Update/Release7.php
tine20/ActiveSync/Setup/setup.xml

@@@ -27,9 -27,9 +27,9 @@@ class ActiveSync_Setup_Update_Release6 
       */
      public function update_0()
      {
--        $this->validateTableVersion('acsync_device', 3);\r
++        $this->validateTableVersion('acsync_device', 3);
  
--        // remove all policy_id's and remove foreign key\r
++        // remove all policy_id's and remove foreign key
          $this->_backend->dropForeignKey('acsync_device', 'acsync_device::policy_id--acsync_policy::id');
          
          $declaration = new Setup_Backend_Schema_Field_Xml('
@@@ -41,9 -41,9 +41,9 @@@
          ');
          $this->_backend->alterCol('acsync_device', $declaration);
          
--        $this->_db->update(SQL_TABLE_PREFIX . 'acsync_device', array(\r
--            'policy_id' => null,\r
--        ));\r
++        $this->_db->update(SQL_TABLE_PREFIX . 'acsync_device', array(
++            'policy_id' => null,
++        ));
          
          $activeSyncAppId = Tinebase_Application::getInstance()->getApplicationByName('ActiveSync')->getId();
          $this->_backend->dropTable('acsync_policy', $activeSyncAppId);
      }
      
      /**
-     public function update_3()
+      * update to 6.4
+      * 
+      * @see 0007452: use json encoded array for saving of policy settings
+      */
+     public function update_3()
+     {
+         $fieldsToRemove = array(
+             'allow_bluetooth',
+             'allow_browser',
+             'allow_camera',
+             'allow_consumer_email',
+             'allow_desktop_sync',
+             'allow_h_t_m_l_email',
+             'allow_internet_sharing',
+             'allow_ir_d_a',
+             'allow_p_o_p_i_m_a_p_email',
+             'allow_remote_desktop',
+             'allow_simple_device_password',
+             'allow_s_m_i_m_e_encryption_algorithm_negotiation',
+             'allow_s_m_i_m_e_soft_certs',
+             'allow_storage_card',
+             'allow_text_messaging',
+             'allow_unsigned_applications',
+             'allow_unsigned_installation_packages',
+             'allow_wifi',
+             'alphanumeric_device_password_required',
+             'approved_application_list',
+             'attachments_enabled',
+             'device_password_enabled',
+             'device_password_expiration',
+             'device_password_history',
+             'max_attachment_size',
+             'max_calendar_age_filter',
+             'max_device_password_failed_attempts',
+             'max_email_age_filter',
+             'max_email_body_truncation_size',
+             'max_email_h_t_m_l_body_truncation_size',
+             'max_inactivity_time_device_lock',
+             'min_device_password_complex_characters',
+             'min_device_password_length',
+             'password_recovery_enabled',
+             'require_device_encryption',
+             'require_encrypted_s_m_i_m_e_messages',
+             'require_encryption_s_m_i_m_e_algorithm',
+             'require_manual_sync_when_roaming',
+             'require_signed_s_m_i_m_e_algorithm',
+             'require_signed_s_m_i_m_e_messages',
+             'require_storage_card_encryption',
+             'unapproved_in_r_o_m_application_list'
+         );
+         
+         $declaration = new Setup_Backend_Schema_Field_Xml('
+             <field>
+                 <name>json_policy</name>
+                 <type>blob</type>
+             </field>
+         ');
+         $this->_backend->addCol('acsync_policy', $declaration);
+         
+         // read values from old columns and convert to JSON encoded array
+         $select = $this->_db->select()
+             ->from(
+                 array('acsync_policy' => SQL_TABLE_PREFIX . 'acsync_policy')
+             );
+         $result = $this->_db->fetchAll($select);
+         
+         foreach ($result as $row) {
+             $policy = array();
+             
+             foreach ($row as $key => $value) {
+                 if (! in_array($key, $fieldsToRemove)) {
+                     continue;
+                 }
+                 
+                 if ($value !== null) {
+                     $policy[$this->_toCamelCase($key)] = $value;
+                 }
+             }
+             
+             // update json_policy
+             $this->_db->update(
+                 SQL_TABLE_PREFIX . 'acsync_policy', 
+                 array(
+                     'json_policy' => Zend_Json::encode($policy)
+                 ), 
+                 $this->_db->quoteInto("id = ?", $row['id']));
+         }
+         
+         // drop old columns
+         foreach ($fieldsToRemove as $fieldName) {
+             $this->_backend->dropCol('acsync_policy', $fieldName);
+         }
+         
+         $this->setTableVersion('acsync_policy', 3);
+         
+         $this->setApplicationVersion('ActiveSync', '6.4');
+     }
+     
+     /**
+      * convert from camel_case to camelCase
+      * 
+      * @param  string $string
+      * @param  bool   $ucFirst
+      * @return string
+      */
+     protected function _toCamelCase($string, $ucFirst = true)
+     {
+         if ($ucFirst === true) {
+             $string = ucfirst($string);
+         }
+         
+         return preg_replace_callback('/_([a-z])/', function ($string) {return strtoupper($string[1]);}, $string);
+     }
++    
++    /**
 +    * update to 7.0
 +    *
 +    * @return void
 +    */
++    public function update_4()
 +    {
 +        $this->setApplicationVersion('ActiveSync', '7.0');
 +    }
  }
index 0000000,0000000..ef1dd44
new file mode 100644 (file)
--- /dev/null
--- /dev/null
@@@ -1,0 -1,0 +1,36 @@@
++<?php
++/**
++ * Tine 2.0
++ *
++ * @package     ActiveSync
++ * @subpackage  Setup
++ * @license     http://www.gnu.org/licenses/agpl.html AGPL Version 3
++ * @copyright   Copyright (c) 2013 Metaways Infosystems GmbH (http://www.metaways.de)
++ * @author      Philipp Schüle <p.schuele@metaways.de>
++ */
++
++/**
++ * updates for major release 7
++ *
++ * @package     ActiveSync
++ * @subpackage  Setup
++ */
++class ActiveSync_Setup_Update_Release7 extends Setup_Update_Abstract
++{
++    /**
++     * update to 7.1
++     * 
++     * @see 0007452: use json encoded array for saving of policy settings
++     * 
++     * @return void
++     */
++    public function update_0()
++    {
++        if ($this->getTableVersion('acsync_policy') != 3) {
++            $release6 = new ActiveSync_Setup_Update_Release6($this->_backend);
++            $release6->update_3();
++        }
++        
++        $this->setApplicationVersion('ActiveSync', '7.1');
++    }
++}
@@@ -1,7 -1,7 +1,7 @@@
  <?xml version="1.0" encoding="utf-8"?>
  <application>
      <name>ActiveSync</name>
-     <version>7.0</version>
 -    <version>6.4</version>
++    <version>7.1</version>
      <order>90</order>
      <depends>
          <application>Tinebase</application>