Merge branch '2015.11' into 2015.11-develop
authorPhilipp Schüle <p.schuele@metaways.de>
Wed, 16 Nov 2016 14:42:52 +0000 (15:42 +0100)
committerPhilipp Schüle <p.schuele@metaways.de>
Wed, 16 Nov 2016 14:42:52 +0000 (15:42 +0100)
Change-Id: Ic9a4d3e4a88e8816212daf0f0f7a15967fa3bc03

1  2 
tine20/Addressbook/Controller.php
tine20/Calendar/Controller.php
tine20/Tinebase/Container.php
tine20/Tinebase/Model/Container.php
tine20/Tinebase/Setup/Update/Release9.php
tine20/Tinebase/Setup/setup.xml

Simple merge
Simple merge
Simple merge
Simple merge
@@@ -59,176 -59,72 +59,246 @@@ class Tinebase_Setup_Update_Release9 ex
      }
  
      /**
 -    public function update_4()
 +     * update to 9.5
 +     */
 +    public function update_4()
 +    {
 +        $declaration = new Setup_Backend_Schema_Field_Xml('<field>
 +                    <name>order</name>
 +                    <type>integer</type>
 +                    <default>0</default>
 +                    <notnull>false</notnull>
 +            </field>');
 +        $this->_backend->addCol('container', $declaration);
 +        $this->setTableVersion('container', 10);
 +        $this->setApplicationVersion('Tinebase', '9.5');
 +    }
 +
 +    /**
 +     * update to 9.6
 +     *
 +     * - rename relation degree (fix direction)
 +     * - add type to constrain
 +     */
 +    public function update_5()
 +    {
 +        if (!$this->_backend->columnExists('related_degree', 'relations')) {
 +            $declaration = new Setup_Backend_Schema_Field_Xml('
 +                <field>
 +                    <name>related_degree</name>
 +                    <type>text</type>
 +                    <length>32</length>
 +                    <notnull>true</notnull>
 +                </field>
 +            ');
 +            $this->_backend->alterCol('relations', $declaration, 'own_degree');
 +        }
 +
 +        // delete index unique-fields
 +        try {
 +            $this->_backend->dropIndex('relations', 'unique-fields');
 +        } catch (Exception $e) {
 +        }
 +        $declaration = new Setup_Backend_Schema_Index_Xml('
 +            <index>
 +                <name>unique-fields</name>
 +                <unique>true</unique>
 +                <field>
 +                    <name>own_model</name>
 +                </field>
 +                <field>
 +                    <name>own_backend</name>
 +                </field>
 +                <field>
 +                    <name>own_id</name>
 +                </field>
 +                <field>
 +                    <name>related_model</name>
 +                </field>
 +                <field>
 +                    <name>related_backend</name>
 +                </field>
 +                <field>
 +                    <name>related_id</name>
 +                </field>
 +                <field>
 +                    <name>type</name>
 +                </field>
 +            </index>'
 +        );
 +
 +        $this->_backend->addIndex('relations', $declaration);
 +
 +        $this->setTableVersion('relations', '9');
 +        $this->setApplicationVersion('Tinebase', '9.6');
 +    }
 +
 +    /**
 +     * update to 9.7
 +     *
 +     * @see 0011620: add "path" filter for records
 +     */
 +    public function update_6()
 +    {
 +        $declaration = new Setup_Backend_Schema_Table_Xml('<table>
 +            <name>path</name>
 +            <version>1</version>
 +            <declaration>
 +                <field>
 +                    <name>id</name>
 +                    <type>text</type>
 +                    <length>40</length>
 +                    <notnull>true</notnull>
 +                </field>
 +                <field>
 +                    <name>record_id</name>
 +                    <type>text</type>
 +                    <length>40</length>
 +                    <notnull>true</notnull>
 +                </field>
 +                <field>
 +                    <name>path</name>
 +                    <type>text</type>
 +                    <length>255</length>
 +                    <notnull>true</notnull>
 +                </field>
 +                <field>
 +                    <name>shadow_path</name>
 +                    <type>text</type>
 +                    <length>255</length>
 +                    <notnull>true</notnull>
 +                </field>
 +                <field>
 +                    <name>creation_time</name>
 +                    <type>datetime</type>
 +                </field>
 +                <index>
 +                    <name>id</name>
 +                    <primary>true</primary>
 +                    <field>
 +                        <name>id</name>
 +                    </field>
 +                </index>
 +                <index>
 +                    <name>path</name>
 +                    <field>
 +                        <name>path</name>
 +                    </field>
 +                </index>
 +                <index>
 +                    <name>shadow_path</name>
 +                    <unique>true</unique>
 +                    <field>
 +                        <name>shadow_path</name>
 +                    </field>
 +                </index>
 +                <index>
 +                    <name>record_id</name>
 +                    <field>
 +                        <name>record_id</name>
 +                    </field>
 +                </index>
 +            </declaration>
 +        </table>');
 +
 +        $this->createTable('path', $declaration);
 +        $this->setApplicationVersion('Tinebase', '9.7');
 +    }
 +
 +    /**
 +     * update to 9.8
 +     *
 +     * adds failcount+lastfail to scheduled imports
 +     *
 +     * @see 0012082: deactivate failing scheduled imports
 +     */
 +    public function update_7()
 +    {
 +        if ($this->getTableVersion('import') < 2) {
 +            $declaration = new Setup_Backend_Schema_Field_Xml('<field>
 +                    <name>failcount</name>
 +                    <type>integer</type>
 +                </field>');
 +            $this->_backend->addCol('import', $declaration);
 +
 +            $declaration = new Setup_Backend_Schema_Field_Xml('<field>
 +                    <name>lastfail</name>
 +                    <type>text</type>
 +                </field>');
 +            $this->_backend->addCol('import', $declaration);
 +        }
 +
 +        $this->setTableVersion('import', '2');
 +        $this->setApplicationVersion('Tinebase', '9.8');
 +    }
++
++    /**
+      * update to 9.9
+      *
+      * @see 0012300: add container owner column
+      */
 -        $this->setApplicationVersion('Tinebase', '9.5');
++    public function update_8()
+     {
+         if ($this->getTableVersion('container') < 10) {
+             $declaration = new Setup_Backend_Schema_Field_Xml(
+             '<field>
+                 <name>owner_id</name>
+                 <type>text</type>
+                 <length>40</length>
+                 <notnull>false</notnull>
+             </field>
+             ');
+             $this->_backend->addCol('container', $declaration);
+             $declaration = new Setup_Backend_Schema_Index_Xml('
+                 <index>
+                     <name>owner_id</name>
+                     <field>
+                         <name>owner_id</name>
+                     </field>
+                 </index>
+             ');
+             $this->_backend->addIndex('container', $declaration);
+             $this->setTableVersion('relations', '8');
+         }
+         $this->setTableVersion('container', '10');
+         //Tinebase_Core::getCache()->clean();
+         $this->_setContainerOwners();
++        $this->setApplicationVersion('Tinebase', '9.9');
+     }
+     /**
+      * write owner to all personal containers
+      */
+     protected function _setContainerOwners()
+     {
+         $filter = new Tinebase_Model_ContainerFilter(array(
+             array('field' => 'type', 'operator' => 'equals', 'value' => Tinebase_Model_Container::TYPE_PERSONAL),
+             array('field' => 'owner_id', 'operator' => 'isnull', 'value' => ''),
+         ));
+         $count = 0;
+         $paging = new Tinebase_Model_Pagination(array(
+             'start' => 0,
+             'limit' => 100,
+         ));
+         $containers = Tinebase_Container::getInstance()->search($filter, $paging);
+         while (count($containers) > 0) {
+             foreach ($containers as $container) {
+                 $ownerId = Tinebase_Container::getInstance()->getContainerOwner($container);
+                 if ($ownerId) {
+                     $container->owner_id = $ownerId;
+                     Tinebase_Container::getInstance()->update($container);
+                     $count++;
+                 }
+             }
+             $paging->start += $paging->limit;
+             $containers = Tinebase_Container::getInstance()->search($filter, $paging);
+         }
+         if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__
+             . ' Set owner for ' . $count . ' containers.');
+     }
  }
@@@ -1,7 -1,7 +1,7 @@@
  <?xml version="1.0" encoding="utf-8"?>
  <application>
      <name>Tinebase</name>
-     <version>9.8</version>
 -    <version>9.5</version>
++    <version>9.9</version>
      <tables>
          <table>
              <name>applications</name>