Merge branch '2015.11-develop'
authorPhilipp Schüle <p.schuele@metaways.de>
Thu, 17 Mar 2016 10:39:00 +0000 (11:39 +0100)
committerPhilipp Schüle <p.schuele@metaways.de>
Thu, 17 Mar 2016 10:39:00 +0000 (11:39 +0100)
tine20/Crm/Controller/Lead.php
tine20/Sales/Controller/Contract.php
tine20/Sales/Controller/Customer.php
tine20/Sales/Controller/Invoice.php
tine20/Sales/Controller/Offer.php
tine20/Sales/Controller/OrderConfirmation.php
tine20/Sales/Controller/Product.php
tine20/Sales/Controller/PurchaseInvoice.php
tine20/Sales/Controller/Supplier.php
tine20/Tinebase/Relation/Backend/Sql.php

index 946762a..26dfb68 100644 (file)
@@ -300,6 +300,7 @@ class Crm_Controller_Lead extends Tinebase_Controller_Record_Abstract
      *
      * TODO generalize
      * TODO translate field names (modelconfig?)
+     * TODO allow non scalar values
      */
     protected function _getNotificationUpdates($lead, $oldLead)
     {
@@ -311,11 +312,14 @@ class Crm_Controller_Lead extends Tinebase_Controller_Record_Abstract
         foreach ($lead->diff($oldLead, array('seq', 'notes', 'tags', 'relations', 'last_modified_time', 'last_modified_by'))->diff
              as $key => $value)
         {
-            $result[] = array(
-                'modified_attribute' => $key,
-                'old_value' => $value,
-                'new_value' => $lead->{$key}
-            );
+            // only allow scalars atm
+            if (! is_array($value) && ! is_array($lead->{$key})) {
+                $result[] = array(
+                    'modified_attribute' => $key,
+                    'old_value' => $value,
+                    'new_value' => $lead->{$key}
+                );
+            }
         }
 
         return $result;
index a52e96a..633a851 100644 (file)
@@ -37,10 +37,13 @@ class Sales_Controller_Contract extends Sales_Controller_NumberableAbstract
      *
      * don't use the constructor. use the singleton 
      */
-    private function __construct() {
+    private function __construct()
+    {
         $this->_applicationName = 'Sales';
         $this->_backend = new Sales_Backend_Contract();
         $this->_modelName = 'Sales_Model_Contract';
+        // TODO this should be done automatically if model has customfields (hasCustomFields)
+        $this->_resolveCustomFields = true;
     }    
     
     /**
index ee94169..cc7a8a9 100644 (file)
@@ -38,11 +38,14 @@ class Sales_Controller_Customer extends Sales_Controller_NumberableAbstract
      *
      * don't use the constructor. use the singleton 
      */
-    private function __construct() {
+    private function __construct()
+    {
         $this->_applicationName = 'Sales';
         $this->_backend = new Sales_Backend_Customer();
         $this->_modelName = 'Sales_Model_Customer';
         $this->_doContainerACLChecks = FALSE;
+        // TODO this should be done automatically if model has customfields (hasCustomFields)
+        $this->_resolveCustomFields = true;
     }
     
     /**
index 099f8dc..f7fe62f 100644 (file)
@@ -108,12 +108,15 @@ class Sales_Controller_Invoice extends Sales_Controller_NumberableAbstract
      *
      * don't use the constructor. use the singleton 
      */
-    private function __construct() {
+    private function __construct()
+    {
         $this->_applicationName = 'Sales';
         $this->_backend = new Sales_Backend_Invoice();
         $this->_modelName = 'Sales_Model_Invoice';
         $this->_doContainerACLChecks = FALSE;
         $this->_cachedProducts = new Tinebase_Record_RecordSet('Sales_Model_Product');
+        // TODO this should be done automatically if model has customfields (hasCustomFields)
+        $this->_resolveCustomFields = true;
     }
     
     /**
index de1eed7..35dbbb9 100644 (file)
@@ -50,6 +50,8 @@ class Sales_Controller_Offer extends Sales_Controller_NumberableAbstract
         $this->_applicationName = 'Sales';
         $this->_backend = new Sales_Backend_Offer();
         $this->_modelName = 'Sales_Model_Offer';
+        // TODO this should be done automatically if model has customfields (hasCustomFields)
+        $this->_resolveCustomFields = true;
     }
     
     /**
index 6368fcb..3d1fcd8 100644 (file)
@@ -46,10 +46,13 @@ class Sales_Controller_OrderConfirmation extends Sales_Controller_NumberableAbst
      *
      * don't use the constructor. use the singleton 
      */
-    private function __construct() {
+    private function __construct()
+    {
         $this->_applicationName = 'Sales';
         $this->_backend = new Sales_Backend_OrderConfirmation();
         $this->_modelName = 'Sales_Model_OrderConfirmation';
+        // TODO this should be done automatically if model has customfields (hasCustomFields)
+        $this->_resolveCustomFields = true;
     }
     
     /**
index d7cfcaa..042e40d 100644 (file)
@@ -40,11 +40,14 @@ class Sales_Controller_Product extends Sales_Controller_NumberableAbstract
      *
      * don't use the constructor. use the singleton 
      */
-    private function __construct() {
+    private function __construct()
+    {
         $this->_backend = new Sales_Backend_Product();
         
         $this->_numberPrefix   = Sales_Config::getInstance()->get(Sales_Config::PRODUCT_NUMBER_PREFIX);
         $this->_numberZerofill = Sales_Config::getInstance()->get(Sales_Config::PRODUCT_NUMBER_ZEROFILL);
+        // TODO this should be done automatically if model has customfields (hasCustomFields)
+        $this->_resolveCustomFields = true;
     }
     
     /**
index db684fd..ac9a9d1 100644 (file)
@@ -27,12 +27,15 @@ class Sales_Controller_PurchaseInvoice extends Sales_Controller_NumberableAbstra
      *
      * don't use the constructor. use the singleton 
      */
-    private function __construct() {
+    private function __construct()
+    {
         $this->_backend = new Sales_Backend_PurchaseInvoice();
         $this->_duplicateCheckFields = array(
             array('number'),
             array('date', 'price_total'),
         );
+        // TODO this should be done automatically if model has customfields (hasCustomFields)
+        $this->_resolveCustomFields = true;
     }
     
     /**
index f977f6b..cb617c4 100644 (file)
@@ -42,8 +42,11 @@ class Sales_Controller_Supplier extends Sales_Controller_NumberableAbstract
      *
      * don't use the constructor. use the singleton 
      */
-    private function __construct() {
+    private function __construct()
+    {
         $this->_backend = new Sales_Backend_Supplier();
+        // TODO this should be done automatically if model has customfields (hasCustomFields)
+        $this->_resolveCustomFields = true;
     }
     
     /**
index 1831a06..adb8e80 100644 (file)
@@ -495,13 +495,18 @@ class Tinebase_Relation_Backend_Sql extends Tinebase_Backend_Sql_Abstract
     {
         $tableName = SQL_TABLE_PREFIX . 'relations';
 
-        $select = $this->_db->select()->from($tableName)->columns('rel_id')
-            ->where($this->_db->quoteIdentifier('own_model') . ' LIKE ?', $applicationName . '_%');
+        $select = $this->_db->select()->from($tableName, array('rel_id'))
+            ->where($this->_db->quoteIdentifier('own_model') . ' LIKE ?', $applicationName . '_%')
+            ->limit(10000);
 
-        $relation_ids = $this->_db->fetchCol($select);
+        do {
+            $relation_ids = $this->_db->fetchCol($select);
 
-        if (is_array($relation_ids) && count($relation_ids) > 0) {
-            $this->_db->delete($tableName, $this->_db->quoteInto($this->_db->quoteIdentifier('rel_id') . ' IN (?)', $relation_ids));
-        }
+            if (is_array($relation_ids) && count($relation_ids) > 0) {
+                $this->_db->delete($tableName, $this->_db->quoteInto($this->_db->quoteIdentifier('rel_id') . ' IN (?)', $relation_ids));
+            } else {
+                break;
+            }
+        } while(true);
     }
 }