13290: Tinebase_Container - container id to uuid
authorPaul Mehrer <p.mehrer@metaways.de>
Fri, 30 Jun 2017 09:42:00 +0000 (11:42 +0200)
committerPaul Mehrer <p.mehrer@metaways.de>
Mon, 3 Jul 2017 10:09:18 +0000 (12:09 +0200)
Change-Id: I273a91c6dc18ae9f325cf5361be699b561fe75d6
Reviewed-on: http://gerrit.tine20.com/customers/4987
Reviewed-by: Paul Mehrer <p.mehrer@metaways.de>
Tested-by: Paul Mehrer <p.mehrer@metaways.de>
29 files changed:
tine20/Addressbook/Setup/Update/Release10.php
tine20/Addressbook/Setup/setup.xml
tine20/Calendar/Model/Attender.php
tine20/Calendar/Model/Resource.php
tine20/Calendar/Setup/Update/Release10.php
tine20/Calendar/Setup/setup.xml
tine20/Crm/Setup/Update/Release10.php
tine20/Crm/Setup/setup.xml
tine20/Events/Setup/Update/Release10.php
tine20/Events/Setup/setup.xml
tine20/HumanResources/Setup/Update/Release10.php
tine20/HumanResources/Setup/setup.xml
tine20/Inventory/Model/InventoryItem.php
tine20/Inventory/Setup/Update/Release10.php
tine20/Inventory/Setup/setup.xml
tine20/Projects/Setup/Update/Release10.php
tine20/Projects/Setup/setup.xml
tine20/Sales/Setup/setup.xml
tine20/SimpleFAQ/Setup/setup.xml
tine20/Tasks/Model/Task.php
tine20/Tasks/Setup/Update/Release10.php
tine20/Tasks/Setup/setup.xml
tine20/Timetracker/Setup/Update/Release10.php
tine20/Timetracker/Setup/setup.xml
tine20/Tinebase/Container.php
tine20/Tinebase/Model/Container.php
tine20/Tinebase/Record/DoctrineMappingDriver.php
tine20/Tinebase/Setup/Update/Release10.php
tine20/Tinebase/Setup/setup.xml

index ddbd987..a80c170 100644 (file)
@@ -104,4 +104,7 @@ class Addressbook_Setup_Update_Release10 extends Setup_Update_Abstract
 
         $this->setApplicationVersion('Addressbook', '10.5');
     }
+
+    public function update_5()
+    {}
 }
index eea4457..a1f90a7 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <application>
     <name>Addressbook</name>
-    <version>10.5</version>
+    <version>10.6</version>
     <order>10</order>
     <depends>
         <application>Admin</application>
@@ -11,7 +11,7 @@
             <name>addressbook</name>
             <engine>InnoDB</engine>
             <charset>utf8</charset>
-            <version>24</version>
+            <version>25</version>
             <declaration>
                 <field>
                     <name>id</name>
                 </field>
                 <field>
                     <name>container_id</name>
-                    <type>integer</type>
+                    <type>text</type>
+                    <length>40</length>
                     <notnull>false</notnull>
                 </field>
                 <field>
         </table>
         <table>
             <name>addressbook_lists</name>
-            <version>5</version>
+            <version>6</version>
             <declaration>
                 <field>
                     <name>id</name>
                 </field>
                 <field>
                     <name>container_id</name>
-                    <type>integer</type>
+                    <type>text</type>
+                    <length>40</length>
                     <notnull>false</notnull>
                 </field>
                 <field>
                 <name>container</name>
             </table>
             <field>
+                <name>id</name>
+                <value special="uid"/>
+            </field>
+            <field>
                 <name>name</name>
                 <value>Internal Contacts</value>
                 <!-- gettext('Internal Contacts') -->
index d7e6701..70f630c 100644 (file)
@@ -96,7 +96,7 @@ class Calendar_Model_Attender extends Tinebase_Record_Abstract
         'quantity'             => array('allowEmpty' => true, 'Int'   ),
         'status'               => array('allowEmpty' => true          ),
         'status_authkey'       => array('allowEmpty' => true, 'Alnum' ),
-        'displaycontainer_id'  => array('allowEmpty' => true, 'Int'   ),
+        'displaycontainer_id'  => array('allowEmpty' => true, 'Alnum' ),
         'transp'               => array(
             'allowEmpty' => true,
             array('InArray', array(Calendar_Model_Event::TRANSP_TRANSP, Calendar_Model_Event::TRANSP_OPAQUE))
index 899dc4e..30a2628 100644 (file)
@@ -40,7 +40,7 @@ class Calendar_Model_Resource extends Tinebase_Record_Abstract
     protected $_validators = array(
         // tine record fields
         'id'                   => array('allowEmpty' => true,  'Alnum'),
-        'container_id'         => array('allowEmpty' => true,  'Int'  ),
+        'container_id'         => array('allowEmpty' => true,  'Alnum'),
         'created_by'           => array('allowEmpty' => true,         ),
         'creation_time'        => array('allowEmpty' => true          ),
         'last_modified_by'     => array('allowEmpty' => true          ),
index 40cf5e0..c6a95ee 100644 (file)
@@ -176,4 +176,7 @@ class Calendar_Setup_Update_Release10 extends Setup_Update_Abstract
 
         $this->setApplicationVersion('Calendar', '10.7');
     }
+
+    public function update_7()
+    {}
 }
index d24ac89..5006651 100644 (file)
@@ -2,14 +2,14 @@
 <application>
     <name>Calendar</name>
     <!-- gettext('Calendar') -->   
-    <version>10.7</version>
+    <version>10.8</version>
     <order>15</order>
     <status>enabled</status>
     <tables>
         <!-- events -->
         <table>
             <name>cal_events</name>
-            <version>13</version>
+            <version>14</version>
             <declaration>
                 <field>
                     <name>id</name>
@@ -19,7 +19,9 @@
                 </field>
                 <field>
                     <name>container_id</name>
-                    <type>integer</type>
+                    <type>text</type>
+                    <length>40</length>
+                    <notnull>false</notnull>
                 </field>
                 <field>
                     <name>created_by</name>
         <!-- attendee -->
         <table>
             <name>cal_attendee</name>
-            <version>5</version>
+            <version>6</version>
             <declaration>
                 <field>
                     <name>id</name>
                 </field>
                 <field>
                     <name>displaycontainer_id</name>
-                    <type>integer</type>
+                    <type>text</type>
+                    <length>40</length>
+                    <notnull>false</notnull>
                 </field>
                 <field>
                     <name>transp</name>
         <!-- resources -->
         <table>
             <name>cal_resources</name>
-            <version>5</version>
+            <version>6</version>
             <declaration>
                 <field>
                     <name>id</name>
                 </field>
                 <field>
                     <name>container_id</name>
-                    <type>integer</type>
+                    <type>text</type>
+                    <length>40</length>
+                    <notnull>false</notnull>
                 </field>
                 <field>
                     <name>created_by</name>
index 1ebae58..0c08577 100644 (file)
@@ -32,4 +32,7 @@ class Crm_Setup_Update_Release10 extends Setup_Update_Abstract
         $this->setTableVersion('metacrm_lead', 9);
         $this->setApplicationVersion('Crm', '10.1');
     }
+
+    public function update_1()
+    {}
 }
index 138d779..ee9829f 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <application>
     <name>Crm</name>
-    <version>10.1</version>
+    <version>10.2</version>
     <order>20</order>
     <depends>
         <application>Admin</application>
@@ -12,7 +12,7 @@
     <tables>
         <table>
             <name>metacrm_lead</name>
-            <version>9</version>
+            <version>10</version>
             <declaration>
                 <field>
                     <name>id</name>
@@ -40,7 +40,8 @@
                 </field>
                 <field>
                     <name>container_id</name>
-                    <type>integer</type>
+                    <type>text</type>
+                    <length>40</length>
                     <notnull>false</notnull>
                 </field>
                 <field>
index 6052863..494dd96 100644 (file)
@@ -33,4 +33,7 @@ class Events_Setup_Update_Release10 extends Setup_Update_Abstract
         $this->setTableVersion('events_event', '2');
         $this->setApplicationVersion('Events', '10.1');
     }
+
+    public function update_1()
+    {}
 }
index 8d3407e..12d1cbf 100644 (file)
@@ -2,13 +2,13 @@
 <application>
     <name>Events</name>
     <!-- gettext('Events') -->   
-    <version>10.1</version>
+    <version>10.2</version>
     <order>60</order>
     <status>enabled</status>
     <tables>
         <table>
             <name>events_event</name>
-            <version>2</version>
+            <version>3</version>
             <declaration>
                 <field>
                     <name>id</name>
@@ -18,7 +18,8 @@
                 </field>
                 <field>
                     <name>container_id</name>
-                    <type>integer</type>
+                    <type>text</type>
+                    <length>40</length>
                     <notnull>false</notnull>
                 </field>
                 <field>
index 0727e36..f33b7bf 100644 (file)
@@ -43,4 +43,19 @@ class HumanResources_Setup_Update_Release10 extends Setup_Update_Abstract
         }
         $this->setApplicationVersion('HumanResources', '10.2');
     }
+
+    public function update_2()
+    {
+        $this->_backend->alterCol('humanresources_contract', new Setup_Backend_Schema_Field_Xml('<field>
+            <name>feast_calendar_id</name>
+            <type>text</type>
+            <length>40</length>
+            <default>null</default>
+            <notnull>false</notnull>
+        </field>'));
+
+        $this->setTableVersion('humanresources_contract', 3);
+
+        $this->setApplicationVersion('HumanResources', '10.3');
+    }
 }
index 23f5d70..2433524 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <application>
     <name>HumanResources</name>
-    <version>10.2</version>
+    <version>10.3</version>
     <order>51</order>
     <depends>
         <application>Calendar</application>
         </table>
         <table>
             <name>humanresources_contract</name>
-            <version>2</version>
+            <version>3</version>
             <declaration>
                 <field>
                     <name>id</name>
                 </field>
                 <field>
                     <name>feast_calendar_id</name>
-                    <type>integer</type>
-                    <length>11</length>
+                    <type>text</type>
+                    <length>40</length>
                     <default>null</default>
                     <notnull>false</notnull>
                 </field>
index dab3c75..8330663 100644 (file)
@@ -33,7 +33,7 @@ class Inventory_Model_InventoryItem extends Tinebase_Record_Abstract
      * @var array
      */
     protected static $_modelConfiguration = array(
-        'version'           => 10,
+        'version'           => 11,
         'recordName'        => 'Inventory item',
         'recordsName'       => 'Inventory items', // ngettext('Inventory item', 'Inventory items', n)
         'containerProperty' => 'container_id',
index bb83eff..5bed423 100644 (file)
@@ -75,4 +75,18 @@ class Inventory_Setup_Update_Release10 extends Setup_Update_Abstract
 
         $this->setApplicationVersion('Inventory', '10.3');
     }
+
+    /**
+     * update to 10.4
+     *
+     * change container_id to uuid
+     *
+     * @return void
+     */
+    public function update_3()
+    {
+        $this->updateSchema('Inventory', array('Inventory_Model_InventoryItem'));
+
+        $this->setApplicationVersion('Inventory', '10.4');
+    }
 }
index 3f536c9..2c4c53e 100644 (file)
@@ -2,7 +2,7 @@
 <application>
     <name>Inventory</name>
     <!-- gettext('Inventory') -->   
-    <version>10.3</version>
+    <version>10.4</version>
     <order>60</order>
     <status>enabled</status>
 </application>
index 0fe06c9..c2fcc55 100644 (file)
@@ -32,4 +32,7 @@ class Projects_Setup_Update_Release10 extends Setup_Update_Abstract
         $this->setTableVersion('projects_project', '3');
         $this->setApplicationVersion('Projects', '10.1');
     }
+
+    public function update_1()
+    {}
 }
index f9b5fa0..e7a2822 100644 (file)
@@ -2,14 +2,14 @@
 <application>
     <name>Projects</name>
     <!-- gettext('Projects') -->   
-    <version>10.1</version>
+    <version>10.2</version>
     <order>60</order>
     <status>enabled</status>
     <tables>
         <!-- project -->
         <table>
             <name>projects_project</name>
-            <version>3</version>
+            <version>4</version>
             <declaration>
                 <field>
                     <name>id</name>
@@ -19,7 +19,8 @@
                 </field>
                 <field>
                     <name>container_id</name>
-                    <type>integer</type>
+                    <type>text</type>
+                    <length>40</length>
                     <notnull>false</notnull>
                 </field>
                 <field>
index 43288cc..0d1b8c2 100644 (file)
@@ -55,7 +55,7 @@
         </table>
         <table>
             <name>sales_contracts</name>
-            <version>9</version>
+            <version>10</version>
             <declaration>
                 <field>
                     <name>id</name>
@@ -65,7 +65,8 @@
                 </field>
                 <field>
                     <name>container_id</name>
-                    <type>integer</type>
+                    <type>text</type>
+                    <length>40</length>
                     <notnull>true</notnull>
                 </field>
                 <field>
index c70dcc5..8ea2ac2 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <application>
     <name>SimpleFAQ</name>
-    <version>10.0</version>
+    <version>10.1</version>
     <order>62</order>
     <status>enabled</status>
     <depends>
@@ -10,7 +10,7 @@
     <tables>
         <table>
             <name>simple_faq</name>
-            <version>2</version>
+            <version>3</version>
             <declaration>
                 <field>
                     <name>id</name>
@@ -20,7 +20,9 @@
                 </field>
                 <field>
                     <name>container_id</name>
-                    <type>integer</type>
+                    <type>text</type>
+                    <length>40</length>
+                    <notnull>false</notnull>
                 </field>
                 <field>
                     <name>faqstatus_id</name>
index ccd0b31..6ea118b 100644 (file)
@@ -58,7 +58,7 @@ class Tasks_Model_Task extends Tinebase_Record_Abstract
      */
     protected $_validators = array(
         // tine record fields
-        'container_id'         => array(Zend_Filter_Input::ALLOW_EMPTY => true,  'Int' ),
+        'container_id'         => array(Zend_Filter_Input::ALLOW_EMPTY => true, 'Alnum'),
         'created_by'           => array(Zend_Filter_Input::ALLOW_EMPTY => true,        ),
         'creation_time'        => array(Zend_Filter_Input::ALLOW_EMPTY => true         ),
         'last_modified_by'     => array(Zend_Filter_Input::ALLOW_EMPTY => true         ),
index af98fd6..b781969 100644 (file)
@@ -32,4 +32,7 @@ class Tasks_Setup_Update_Release10 extends Setup_Update_Abstract
         $this->setTableVersion('tasks', 9);
         $this->setApplicationVersion('Tasks', '10.1');
     }
+
+    public function update_1()
+    {}
 }
index 9547597..b1d29ea 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <application>
     <name>Tasks</name>
-    <version>10.1</version>
+    <version>10.2</version>
     <order>30</order>
     <depends>
         <application>Admin</application>
@@ -9,7 +9,7 @@
     <tables>
         <table>
             <name>tasks</name>
-            <version>9</version>
+            <version>10</version>
             <declaration>
                 <field>
                     <name>id</name>
@@ -19,7 +19,9 @@
                 </field>
                 <field>
                     <name>container_id</name>
-                    <type>integer</type>
+                    <type>text</type>
+                    <length>40</length>
+                    <notnull>false</notnull>
                 </field>
                 <field>
                     <name>created_by</name>
index 3db93cb..7a56d71 100644 (file)
@@ -63,4 +63,7 @@ class Timetracker_Setup_Update_Release10 extends Setup_Update_Abstract
         $this->setTableVersion('timetracker_timeaccount', '11');
         $this->setApplicationVersion('Timetracker', '10.2');
     }
+
+    public function update_2()
+    {}
 }
index 216f72a..d3b6dd3 100644 (file)
@@ -2,7 +2,7 @@
 <application>
     <name>Timetracker</name>
     <!-- gettext('Timetracker') -->   
-    <version>10.2</version>
+    <version>10.3</version>
     <order>60</order>
     <status>enabled</status>
     <depends>
@@ -11,7 +11,7 @@
     <tables>
         <table>
             <name>timetracker_timeaccount</name>
-            <version>11</version>
+            <version>12</version>
             <declaration>
                 <field>
                     <name>id</name>
@@ -21,7 +21,8 @@
                 </field>
                 <field>
                     <name>container_id</name>
-                    <type>integer</type>
+                    <type>text</type>
+                    <length>40</length>
                     <notnull>false</notnull>
                 </field>
                 <field>
index 11758d1..916bffe 100644 (file)
@@ -265,7 +265,7 @@ class Tinebase_Container extends Tinebase_Backend_Sql_Abstract implements Tineba
      */
     public function addGrants($_containerId, $_accountType, $_accountId, array $_grants, $_ignoreAcl = FALSE)
     {
-        $containerId = Tinebase_Model_Container::convertContainerIdToInt($_containerId);
+        $containerId = Tinebase_Model_Container::convertContainerId($_containerId);
         
         if($_ignoreAcl !== TRUE and !$this->hasGrant(Tinebase_Core::getUser(), $_containerId, Tinebase_Model_Grants::GRANT_ADMIN)) {
             throw new Tinebase_Exception_AccessDenied('Permission to manage grants on container denied.');
@@ -482,7 +482,7 @@ class Tinebase_Container extends Tinebase_Backend_Sql_Abstract implements Tineba
      */
     public function getContainerById($_containerId, $_getDeleted = FALSE)
     {
-        $containerId = Tinebase_Model_Container::convertContainerIdToInt($_containerId);
+        $containerId = Tinebase_Model_Container::convertContainerId($_containerId);
         
         $cacheId = $containerId . 'd' . (int)$_getDeleted;
         
@@ -1077,7 +1077,7 @@ class Tinebase_Container extends Tinebase_Backend_Sql_Abstract implements Tineba
      */
     public function deleteContainer($_containerId, $_ignoreAcl = FALSE, $_tryAgain = TRUE)
     {
-        $containerId = Tinebase_Model_Container::convertContainerIdToInt($_containerId);
+        $containerId = Tinebase_Model_Container::convertContainerId($_containerId);
         $container = ($_containerId instanceof Tinebase_Model_Container) ? $_containerId : $this->getContainerById($containerId);
         $this->checkSystemContainer($containerId);
 
@@ -1255,7 +1255,7 @@ class Tinebase_Container extends Tinebase_Backend_Sql_Abstract implements Tineba
         $accountId = Tinebase_Model_User::convertUserIdToInt($_accountId);
         
         try {
-            $containerId = Tinebase_Model_Container::convertContainerIdToInt($_containerId);
+            $containerId = Tinebase_Model_Container::convertContainerId($_containerId);
         } catch (Tinebase_Exception_InvalidArgument $teia) {
             if (Tinebase_Core::isLogLevel(Zend_Log::NOTICE)) Tinebase_Core::getLogger()->notice(__METHOD__ . '::' . __LINE__ . ' ' . $teia->getMessage());
             if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' ' . $teia->getTraceAsString());
@@ -1306,7 +1306,7 @@ class Tinebase_Container extends Tinebase_Backend_Sql_Abstract implements Tineba
     {
         $grants = new Tinebase_Record_RecordSet('Tinebase_Model_Grants');
         
-        $containerId = Tinebase_Model_Container::convertContainerIdToInt($_containerId);
+        $containerId = Tinebase_Model_Container::convertContainerId($_containerId);
         
         $select = $this->_getAclSelectByContainerId($containerId)
             ->group(array('container_acl.container_id', 'container_acl.account_type', 'container_acl.account_id'));
@@ -1364,7 +1364,7 @@ class Tinebase_Container extends Tinebase_Backend_Sql_Abstract implements Tineba
     public function getGrantsOfAccount($_accountId, $_containerId, $_grantModel = 'Tinebase_Model_Grants') 
     {
         $accountId          = Tinebase_Model_User::convertUserIdToInt($_accountId);
-        $containerId        = Tinebase_Model_Container::convertContainerIdToInt($_containerId);
+        $containerId        = Tinebase_Model_Container::convertContainerId($_containerId);
         $container          = ($_containerId instanceof Tinebase_Model_Container) ? $_containerId : $this->getContainerById($_containerId);
         
         $classCacheId = $accountId . $containerId . $container->seq . $_grantModel;
@@ -1448,8 +1448,8 @@ class Tinebase_Container extends Tinebase_Backend_Sql_Abstract implements Tineba
     {
         $containerIds = array();
         foreach ($_records as $record) {
-            if (isset($record[$_containerProperty]) && !isset($containerIds[Tinebase_Model_Container::convertContainerIdToInt($record[$_containerProperty])])) {
-                $containerIds[Tinebase_Model_Container::convertContainerIdToInt($record[$_containerProperty])] = null;
+            if (isset($record[$_containerProperty]) && !isset($containerIds[Tinebase_Model_Container::convertContainerId($record[$_containerProperty])])) {
+                $containerIds[Tinebase_Model_Container::convertContainerId($record[$_containerProperty])] = null;
             }
         }
         
@@ -1513,7 +1513,7 @@ class Tinebase_Container extends Tinebase_Backend_Sql_Abstract implements Tineba
      */
     public function setGrants($_containerId, Tinebase_Record_RecordSet $_grants, $_ignoreAcl = FALSE, $_failSafe = TRUE) 
     {
-        $containerId = Tinebase_Model_Container::convertContainerIdToInt($_containerId);
+        $containerId = Tinebase_Model_Container::convertContainerId($_containerId);
         
         if($_ignoreAcl !== TRUE) {
             if(!$this->hasGrant(Tinebase_Core::getUser(), $containerId, Tinebase_Model_Grants::GRANT_ADMIN)) {
@@ -1655,7 +1655,7 @@ class Tinebase_Container extends Tinebase_Backend_Sql_Abstract implements Tineba
      */
     protected function _clearCache($containerId) 
     {
-        $containerId = Tinebase_Model_Container::convertContainerIdToInt($containerId);
+        $containerId = Tinebase_Model_Container::convertContainerId($containerId);
         $cache = Tinebase_Core::getCache();
         
         if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ 
@@ -1724,7 +1724,7 @@ class Tinebase_Container extends Tinebase_Backend_Sql_Abstract implements Tineba
      */
     public function increaseContentSequence($containerId, $action = NULL, $recordId = NULL)
     {
-        $containerId = Tinebase_Model_Container::convertContainerIdToInt($containerId);
+        $containerId = Tinebase_Model_Container::convertContainerId($containerId);
 
         $newContentSeq = NULL;
         try {
@@ -1789,7 +1789,7 @@ class Tinebase_Container extends Tinebase_Backend_Sql_Abstract implements Tineba
     public function getContentHistory($containerId, $lastContentSeq = -1)
     {
         $filter = new Tinebase_Model_ContainerContentFilter(array(
-            array('field' => 'container_id', 'operator' => 'equals',  'value' => Tinebase_Model_Container::convertContainerIdToInt($containerId)),
+            array('field' => 'container_id', 'operator' => 'equals',  'value' => Tinebase_Model_Container::convertContainerId($containerId)),
             array('field' => 'content_seq',  'operator' => 'greater', 'value' => ($lastContentSeq == -1 ? $lastContentSeq : $lastContentSeq - 1)),
         ));
         $pagination = new Tinebase_Model_Pagination(array(
@@ -1824,7 +1824,7 @@ class Tinebase_Container extends Tinebase_Backend_Sql_Abstract implements Tineba
         }
         
         $containerIds = (! is_array($containerIds))
-            ? Tinebase_Model_Container::convertContainerIdToInt($containerIds)
+            ? Tinebase_Model_Container::convertContainerId($containerIds)
             : $containerIds;
         
         $select = $this->_getSelect(array('id', 'content_seq'), TRUE);
index de8efe8..469cc3c 100644 (file)
@@ -150,24 +150,23 @@ class Tinebase_Model_Container extends Tinebase_Record_Abstract
      * converts a int, string or Tinebase_Model_Container to a containerid
      *
      * @param   int|string|Tinebase_Model_Container $_containerId the containerid to convert
-     * @return  int
+     * @return  string
      * @throws  Tinebase_Exception_InvalidArgument
      */
-    static public function convertContainerIdToInt($_containerId)
+    static public function convertContainerId($_containerId)
     {
+        // null will be string casted to empty string
         if($_containerId instanceof Tinebase_Model_Container) {
-            if($_containerId->getId() === NULL) {
-                throw new Tinebase_Exception_InvalidArgument('No container id set.');
-            }
-            $id = (int) $_containerId->getId();
+            $id = (string)$_containerId->getId();
         } else {
-            $id = (int) $_containerId;
+            $id = (string)$_containerId;
         }
-        
-        if ($id === 0) {
-            throw new Tinebase_Exception_InvalidArgument('Container id can not be 0 (' . $_containerId . ').');
+
+        // ctype_alnum returns false on empty string
+        if(false === ctype_alnum($id)) {
+            throw new Tinebase_Exception_InvalidArgument('No container id set.');
         }
-        
+
         return $id;
     }
 
index 9628d7c..59c210e 100644 (file)
@@ -35,7 +35,7 @@ class Tinebase_Record_DoctrineMappingDriver implements Doctrine\Common\Persisten
         'numberableStr' => 'string',
         'float'         => 'float',
         'json'          => 'text',
-        'container'     => 'integer',
+        'container'     => 'string',
         'record'        => 'string',
         'keyfield'      => 'string',
         'user'          => 'string',
@@ -101,6 +101,9 @@ class Tinebase_Record_DoctrineMappingDriver implements Doctrine\Common\Persisten
     {
         $config['doctrineIgnore'] = true;
         if (isset(self::$_typeMap[$config['type']])) {
+            if ($config['type'] === 'container') {
+                $config['length'] = 40;
+            }
             $config['type'] = self::$_typeMap[$config['type']];
             $config['doctrineIgnore'] = false;
         }
index 0ee361d..b4767b3 100644 (file)
@@ -369,7 +369,7 @@ class Tinebase_Setup_Update_Release10 extends Setup_Update_Abstract
     public function update_9()
     {
         $this->_addIsDeletedToTreeNodes();
-        
+
         $this->dropTable('path');
 
         $declaration = new Setup_Backend_Schema_Table_Xml('<table>
@@ -1053,7 +1053,7 @@ class Tinebase_Setup_Update_Release10 extends Setup_Update_Abstract
     {
         $this->_addNotificationProps();
         $this->_addIsDeletedToTreeNodes();
-        
+
         // get all folder nodes with own acl
         $searchFilter = new Tinebase_Model_Tree_Node_Filter(array(
             array(
@@ -1256,4 +1256,373 @@ class Tinebase_Setup_Update_Release10 extends Setup_Update_Abstract
             $this->setTableVersion('tree_nodes', 4);
         }
     }
+
+    /**
+     * update to 10.32
+     *
+     * change container id from int to uuid
+     */
+    public function update_31()
+    {
+        //ATTENTION foreign constraints
+
+        try {
+            $this->_backend->dropForeignKey('container_acl', 'container_acl::container_id--container::id');
+        } catch (Exception $e) {}
+        try {
+            $this->_backend->dropForeignKey('container_content', 'container_content::container_id--container::id');
+        } catch (Exception $e) {}
+
+        if ($this->_backend->tableExists('addressbook')) {
+            try {
+                $this->_backend->dropForeignKey('addressbook', 'addressbook::container_id--container::id');
+            } catch (Exception $e) {}
+        }
+        if ($this->_backend->tableExists('cal_events')) {
+            try {
+                $this->_backend->dropForeignKey('cal_events', 'cal_events::container_id--container::id');
+            } catch (Exception $e) {}
+        }
+        if ($this->_backend->tableExists('cal_resources')) {
+            try {
+                $this->_backend->dropForeignKey('cal_resources', 'cal_resources::container_id--container::id');
+            } catch (Exception $e) {}
+        }
+        if ($this->_backend->tableExists('cal_attendee')) {
+            try {
+                $this->_backend->dropForeignKey('cal_attendee', 'cal_attendee::displaycontainer_id--container::id');
+            } catch (Exception $e) {}
+        }
+        if ($this->_backend->tableExists('metacrm_lead')) {
+            try {
+                $this->_backend->dropForeignKey('metacrm_lead', 'metacrm_lead::container_id--container::id');
+            } catch (Exception $e) {}
+        }
+        if ($this->_backend->tableExists('sales_contracts')) {
+            try {
+                $this->_backend->dropForeignKey('sales_contracts', 'sales_contracts::container_id--container::id');
+            } catch (Exception $e) {}
+        }
+        if ($this->_backend->tableExists('timetracker_timeaccount')) {
+            try {
+                $this->_backend->dropForeignKey('timetracker_timeaccount', 'timeaccount::container_id--container::id');
+            } catch (Exception $e) {}
+        }
+
+        if (version_compare($this->getApplicationVersion('Tinebase'), '10.31') < 0 ) {
+            if ($this->getTableVersion('container') < 13) {
+                $this->_backend->alterCol('container', new Setup_Backend_Schema_Field_Xml('<field>
+                            <name>id</name>
+                            <type>text</type>
+                            <length>40</length>
+                            <notnull>true</notnull>
+                        </field>'));
+                $this->setTableVersion('container', 13);
+            }
+
+            if ($this->getTableVersion('container_acl') < 4) {
+                $this->_backend->alterCol('container_acl', new Setup_Backend_Schema_Field_Xml('<field>
+                            <name>container_id</name>
+                            <type>text</type>
+                            <length>40</length>
+                            <notnull>true</notnull>
+                        </field>'));
+                $this->setTableVersion('container_acl', 4);
+            }
+
+            if ($this->getTableVersion('container_content') < 3) {
+                $this->_backend->alterCol('container_content', new Setup_Backend_Schema_Field_Xml('<field>
+                            <name>container_id</name>
+                            <type>text</type>
+                            <length>40</length>
+                            <notnull>true</notnull>
+                        </field>'));
+                $this->setTableVersion('container_content', 3);
+            }
+        }
+
+        if (version_compare($this->getApplicationVersion('Addressbook'), '10.6') < 0 ) {
+            if ($this->getTableVersion('addressbook') < 25) {
+                $this->_backend->alterCol('addressbook', new Setup_Backend_Schema_Field_Xml('<field>
+                    <name>container_id</name>
+                    <type>text</type>
+                    <length>40</length>
+                    <notnull>false</notnull>
+                </field>'));
+                $this->setTableVersion('addressbook', 25);
+            }
+
+            if ($this->getTableVersion('addressbook_lists') < 6) {
+                $this->_backend->alterCol('addressbook_lists', new Setup_Backend_Schema_Field_Xml('<field>
+                    <name>container_id</name>
+                    <type>text</type>
+                    <length>40</length>
+                    <notnull>false</notnull>
+                </field>'));
+                $this->setTableVersion('addressbook_lists', 25);
+            }
+
+            $this->setApplicationVersion('Addressbook', '10.6');
+        }
+
+        if (Tinebase_Application::getInstance()->isInstalled('Calendar') &&
+                version_compare($this->getApplicationVersion('Calendar'), '10.8') < 0 ) {
+            if ($this->getTableVersion('cal_events') < 14) {
+                $this->_backend->alterCol('cal_events', new Setup_Backend_Schema_Field_Xml('<field>
+                    <name>container_id</name>
+                    <type>text</type>
+                    <length>40</length>
+                    <notnull>false</notnull>
+                </field>'));
+                $this->setTableVersion('cal_events', 14);
+            }
+
+            if ($this->getTableVersion('cal_attendee') < 6) {
+                $this->_backend->alterCol('cal_attendee', new Setup_Backend_Schema_Field_Xml('<field>
+                    <name>displaycontainer_id</name>
+                    <type>text</type>
+                    <length>40</length>
+                    <notnull>false</notnull>
+                </field>'));
+                $this->setTableVersion('cal_attendee', 6);
+            }
+
+            if ($this->getTableVersion('cal_resources') < 6) {
+                $this->_backend->alterCol('cal_resources', new Setup_Backend_Schema_Field_Xml('<field>
+                    <name>container_id</name>
+                    <type>text</type>
+                    <length>40</length>
+                    <notnull>false</notnull>
+                </field>'));
+                $this->setTableVersion('cal_resources', 6);
+            }
+
+            $this->setApplicationVersion('Calendar', '10.8');
+        }
+
+        if (Tinebase_Application::getInstance()->isInstalled('Crm') &&
+            version_compare($this->getApplicationVersion('Crm'), '10.2') < 0 ) {
+            if ($this->getTableVersion('metacrm_lead') < 10) {
+                $this->_backend->alterCol('metacrm_lead', new Setup_Backend_Schema_Field_Xml('<field>
+                    <name>container_id</name>
+                    <type>text</type>
+                    <length>40</length>
+                    <notnull>false</notnull>
+                </field>'));
+                $this->setTableVersion('metacrm_lead', 10);
+            }
+            $this->setApplicationVersion('Crm', '10.2');
+        }
+
+        if (Tinebase_Application::getInstance()->isInstalled('Events') &&
+            version_compare($this->getApplicationVersion('Events'), '10.2') < 0 ) {
+            if ($this->getTableVersion('events_event') < 3) {
+                $this->_backend->alterCol('events_event', new Setup_Backend_Schema_Field_Xml('<field>
+                    <name>container_id</name>
+                    <type>text</type>
+                    <length>40</length>
+                    <notnull>false</notnull>
+                </field>'));
+                $this->setTableVersion('events_event', 3);
+            }
+            $this->setApplicationVersion('Events', '10.2');
+        }
+
+        if (Tinebase_Application::getInstance()->isInstalled('Projects') &&
+            version_compare($this->getApplicationVersion('Projects'), '10.2') < 0 ) {
+            if ($this->getTableVersion('projects_project') < 4) {
+                $this->_backend->alterCol('projects_project', new Setup_Backend_Schema_Field_Xml('<field>
+                    <name>container_id</name>
+                    <type>text</type>
+                    <length>40</length>
+                    <notnull>false</notnull>
+                </field>'));
+                $this->setTableVersion('projects_project', 4);
+            }
+            $this->setApplicationVersion('Projects', '10.2');
+        }
+
+        if (Tinebase_Application::getInstance()->isInstalled('Sales') &&
+            version_compare($this->getApplicationVersion('Sales'), '10.9') < 0 ) {
+            if ($this->getTableVersion('sales_contracts') < 10) {
+                $this->_backend->alterCol('sales_contracts', new Setup_Backend_Schema_Field_Xml('<field>
+                    <name>container_id</name>
+                    <type>text</type>
+                    <length>40</length>
+                    <notnull>true</notnull>
+                </field>'));
+                $this->setTableVersion('sales_contracts', 10);
+            }
+            $this->setApplicationVersion('Sales', '10.9');
+        }
+
+        if (Tinebase_Application::getInstance()->isInstalled('SimpleFAQ') &&
+            version_compare($this->getApplicationVersion('SimpleFAQ'), '10.1') < 0 ) {
+            if ($this->getTableVersion('simple_faq') < 3) {
+                $this->_backend->alterCol('simple_faq', new Setup_Backend_Schema_Field_Xml('<field>
+                    <name>container_id</name>
+                    <type>text</type>
+                    <length>40</length>
+                    <notnull>false</notnull>
+                </field>'));
+                $this->setTableVersion('simple_faq', 3);
+            }
+            $this->setApplicationVersion('SimpleFAQ', '10.1');
+        }
+
+        if (Tinebase_Application::getInstance()->isInstalled('Tasks') &&
+            version_compare($this->getApplicationVersion('Tasks'), '10.2') < 0 ) {
+            if ($this->getTableVersion('tasks') < 10) {
+                $this->_backend->alterCol('tasks', new Setup_Backend_Schema_Field_Xml('<field>
+                    <name>container_id</name>
+                    <type>text</type>
+                    <length>40</length>
+                    <notnull>false</notnull>
+                </field>'));
+                $this->setTableVersion('tasks', 10);
+            }
+            $this->setApplicationVersion('Tasks', '10.2');
+        }
+
+        if (Tinebase_Application::getInstance()->isInstalled('Timetracker') &&
+            version_compare($this->getApplicationVersion('Timetracker'), '10.3') < 0 ) {
+            if ($this->getTableVersion('timetracker_timeaccount') < 12) {
+                $this->_backend->alterCol('timetracker_timeaccount', new Setup_Backend_Schema_Field_Xml('<field>
+                    <name>container_id</name>
+                    <type>text</type>
+                    <length>40</length>
+                    <notnull>false</notnull>
+                </field>'));
+                $this->setTableVersion('timetracker_timeaccount', 12);
+            }
+            $this->setApplicationVersion('Timetracker', '10.3');
+        }
+
+        $this->_backend->addForeignKey('container_content', new Setup_Backend_Schema_Index_Xml('<index>
+                    <name>container_content::container_id--container::id</name>
+                    <field>
+                        <name>container_id</name>
+                    </field>
+                    <foreign>true</foreign>
+                    <reference>
+                        <table>container</table>
+                        <field>id</field>
+                        <ondelete>cascade</ondelete>
+                    </reference>
+                </index>'));
+
+        $this->_backend->addForeignKey('container_acl', new Setup_Backend_Schema_Index_Xml('<index>
+                    <name>container_acl::container_id--container::id</name>
+                    <field>
+                        <name>container_id</name>
+                    </field>
+                    <foreign>true</foreign>
+                    <reference>
+                        <table>container</table>
+                        <field>id</field>
+                        <ondelete>cascade</ondelete>
+                        <!-- add onupdate? -->
+                    </reference>
+                </index>'));
+
+        if ($this->_backend->tableExists('timeaccount')) {
+            $this->_backend->addForeignKey('timeaccount', new Setup_Backend_Schema_Index_Xml('<index>
+                    <name>timeaccount::container_id--container::id</name>
+                    <field>
+                        <name>container_id</name>
+                    </field>
+                    <foreign>true</foreign>
+                    <reference>
+                        <table>container</table>
+                        <field>id</field>
+                    </reference>
+                </index>'));
+        }
+
+        if ($this->_backend->tableExists('sales_contracts')) {
+            $this->_backend->addForeignKey('sales_contracts', new Setup_Backend_Schema_Index_Xml('<index>
+                    <name>sales_contracts::container_id--container::id</name>
+                    <field>
+                        <name>container_id</name>
+                    </field>
+                    <foreign>true</foreign>
+                    <reference>
+                        <table>container</table>
+                        <field>id</field>
+                    </reference>
+                </index>'));
+        }
+
+        if ($this->_backend->tableExists('metacrm_lead')) {
+            $this->_backend->addForeignKey('metacrm_lead', new Setup_Backend_Schema_Index_Xml('<index>
+                    <name>metacrm_lead::container_id--container::id</name>
+                    <field>
+                        <name>container_id</name>
+                    </field>
+                    <foreign>true</foreign>
+                    <reference>
+                        <table>container</table>
+                        <field>id</field>
+                    </reference>
+                </index>'));
+        }
+
+        if ($this->_backend->tableExists('cal_events')) {
+            $this->_backend->addForeignKey('cal_events', new Setup_Backend_Schema_Index_Xml('<index>
+                    <name>cal_resources::container_id--container::id</name>
+                    <field>
+                        <name>container_id</name>
+                    </field>
+                    <foreign>true</foreign>
+                    <reference>
+                        <table>container</table>
+                        <field>id</field>
+                    </reference>
+                </index>'));
+        }
+
+        if ($this->_backend->tableExists('cal_events')) {
+            $this->_backend->addForeignKey('cal_events', new Setup_Backend_Schema_Index_Xml('<index>
+                    <name>cal_events::container_id--container::id</name>
+                    <field>
+                        <name>container_id</name>
+                    </field>
+                    <foreign>true</foreign>
+                    <reference>
+                        <table>container</table>
+                        <field>id</field>
+                    </reference>
+                </index>'));
+        }
+
+        if ($this->_backend->tableExists('cal_attendee')) {
+            $this->_backend->addForeignKey('cal_attendee', new Setup_Backend_Schema_Index_Xml('<index>
+                    <name>cal_attendee::displaycontainer_id--container::id</name>
+                    <field>
+                        <name>displaycontainer_id</name>
+                    </field>
+                    <foreign>true</foreign>
+                    <reference>
+                        <table>container</table>
+                        <field>id</field>
+                    </reference>
+                </index>'));
+        }
+
+        if ($this->_backend->tableExists('addressbook')) {
+            $this->_backend->addForeignKey('addressbook', new Setup_Backend_Schema_Index_Xml('<index>
+                    <name>addressbook::container_id--container::id</name>
+                    <field>
+                        <name>container_id</name>
+                    </field>
+                    <foreign>true</foreign>
+                    <reference>
+                        <table>container</table>
+                        <field>id</field>
+                    </reference>
+                </index>'));
+        }
+
+        $this->setApplicationVersion('Tinebase', '10.32');
+    }
 }
index 40c5da9..262d0d0 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <application>
     <name>Tinebase</name>
-    <version>10.31</version>
+    <version>10.32</version>
     <tables>
         <table>
             <name>applications</name>
         </table>
         <table>
             <name>container</name>
-            <version>12</version>
+            <version>13</version>
             <declaration>
                 <field>
                     <name>id</name>
-                    <type>integer</type>
-                    <autoincrement>true</autoincrement>
+                    <type>text</type>
+                    <length>40</length>
+                    <notnull>true</notnull>
                 </field>
                 <field>
                     <name>name</name>
         </table>
         <table>
             <name>container_acl</name>
-            <version>3</version>
+            <version>4</version>
             <declaration>
                 <field>
                     <name>id</name>
                 </field>
                 <field>
                     <name>container_id</name>
-                    <type>integer</type>
-                    <unsigned>true</unsigned>
+                    <type>text</type>
+                    <length>40</length>
                     <notnull>true</notnull>
                 </field>
                 <field>
         </table>
         <table>
             <name>container_content</name>
-            <version>2</version>
+            <version>3</version>
             <declaration>
                 <field>
                     <name>id</name>
                 </field>
                 <field>
                     <name>container_id</name>
-                    <type>integer</type>
-                    <unsigned>true</unsigned>
+                    <type>text</type>
+                    <length>40</length>
                     <notnull>true</notnull>
                 </field>
                 <field>