Merge branch '2014.11-develop' into 2014.09
authorPhilipp Schüle <p.schuele@metaways.de>
Wed, 29 Apr 2015 15:38:15 +0000 (17:38 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Wed, 29 Apr 2015 15:38:15 +0000 (17:38 +0200)
tine20/Crm/Controller/Lead.php
tine20/Setup/Frontend/Cli.php
tine20/Tinebase/Controller/Record/Abstract.php
tine20/Tinebase/Import/Abstract.php
tine20/Tinebase/js/tineInit.js
tine20/Tinebase/js/ux/PopupWindow.js

index a0f1c30..1c1a3ed 100644 (file)
@@ -41,8 +41,14 @@ class Crm_Controller_Lead extends Tinebase_Controller_Record_Abstract
         $this->_resolveCustomFields     = TRUE;
 
         $this->_duplicateCheckFields = Crm_Config::getInstance()->get(Crm_Config::LEAD_DUP_FIELDS, array(
-            array('CUSTOMER' => 'relations')
+            array('relations')
         ));
+        $this->_duplicateCheckConfig = array(
+            'relations' => array(
+                'type'          => 'CUSTOMER',
+                'filterField'   => 'contact'
+            )
+        );
 
         $this->_backend                 = new Crm_Backend_Lead();
     }
index 120d728..685361b 100644 (file)
@@ -351,9 +351,14 @@ class Setup_Frontend_Cli
                 }
             }
         }
-        
         echo "Successfully cleand up containers.\n";
         
+        //remove state
+        $db = Tinebase_Core::getDb();
+        $statement = "TRUNCATE TABLE " . $db->quoteIdentifier(SQL_TABLE_PREFIX . 'state');
+        $db->query($statement);
+        echo "Successfully truncated state table.\n";
+        
         //Get Demodata
         $cli->createAllDemoData();
         
index ed8e909..643584d 100644 (file)
@@ -138,6 +138,8 @@ abstract class Tinebase_Controller_Record_Abstract
      */
     protected $_duplicateCheckFields = NULL;
 
+    protected $_duplicateCheckConfig = array();
+    
     /**
      * holds new relation on update multiple
      * @var array
@@ -709,10 +711,10 @@ abstract class Tinebase_Controller_Record_Abstract
             if (! is_array($group)) {
                 $group = array($group);
             }
-            foreach ($group as $key => $field) {
+            foreach ($group as $field) {
                 if (! empty($_record->{$field})) {
                     if ($field === 'relations') {
-                        $relationFilter = $this->_getRelationDuplicateFilter($_record, $key, $field);
+                        $relationFilter = $this->_getRelationDuplicateFilter($_record);
                         if ($relationFilter) {
                             $addFilter[] = $relationFilter;
                         }
@@ -756,12 +758,12 @@ abstract class Tinebase_Controller_Record_Abstract
         return $filter;
     }
     
-    protected function _getRelationDuplicateFilter($record, $key, $field)
+    protected function _getRelationDuplicateFilter($record)
     {
         $filter = null;
-        $relations = $record->{$field};
+        $relations = $record->relations;
         
-        if (count($relations) === 0) {
+        if (count($relations) === 0 || ! isset($this->_duplicateCheckConfig['relations']['filterField'])) {
             return $filter;
         }
         
@@ -770,16 +772,15 @@ abstract class Tinebase_Controller_Record_Abstract
         }
         
         // check for relation and add relation filter
-        $type = is_string($key) ? $key : '';
+        $type = isset($this->_duplicateCheckConfig['relations']['type']) ? $this->_duplicateCheckConfig['relations']['type'] : '';
         $relations = $relations->filter('type', $type);
         if (count($relations) > 0) {
             $duplicateRelation = $relations->getFirstRecord();
             if ($duplicateRelation->related_id) {
-                // TODO get field name from definition / relation
                 $filter = array(
-                    'field' => 'contact',
+                    'field' => $this->_duplicateCheckConfig['relations']['filterField'],
                     'operator' => 'AND',
-                    'value' => array('field' => ':id', 'operator' => 'equals', 'value' => $duplicateRelation->related_id)
+                    'value' => array(array('field' => ':id', 'operator' => 'equals', 'value' => $duplicateRelation->related_id))
                 );
             }
         }
index 73fcac1..64dca6d 100644 (file)
@@ -586,16 +586,17 @@ abstract class Tinebase_Import_Abstract implements Tinebase_Import_Interface
                 'related_record' => $record
             );
             
-            // TODO add some more relation definition info?
-
             $relations[] = $relation;
         }
 
         if (isset($field['targetField'])&& isset($field['targetFieldData'])) {
-            $targetField = $field['targetFieldData'];
+            $unreplaced = $targetField = $field['targetFieldData'];
             foreach ($record as $key => $value) {
                 $targetField = preg_replace('/' . preg_quote($key) . '/', $value, $targetField);
+                $unreplaced = preg_replace('/^[, ]*' . preg_quote($key) . '/', '', $unreplaced);
             }
+            // remove unreplaced stuff
+            $targetField = str_replace($unreplaced, '', $targetField);
             $data[$field['targetField']] = $targetField;
         }
         
index 056a8b8..14ee9bc 100644 (file)
@@ -215,8 +215,9 @@ Tine.Tinebase.tineInit = {
         // check if user is already logged in
         if (! Tine.Tinebase.registry.get('currentAccount')) {
             Tine.Tinebase.tineInit.showLoginBox(function(response){
-                // fetch users registry
+                Tine.log.info('tineInit::renderWindow -fetch users registry');
                 Tine.Tinebase.tineInit.initRegistry(true, function() {
+                    Tine.log.info('tineInit::renderWindow - registry fetched, render main window');
                     Ext.MessageBox.hide();
                     Tine.Tinebase.tineInit.initWindowMgr();
                     Tine.Tinebase.tineInit.renderWindow();
index d91cc93..2f29f51 100644 (file)
@@ -233,17 +233,19 @@ Ext.ux.PopupWindow.close = function(win) {
     win = win || window;
     win.close();
     // defer messagebox as it should not be displayed too early
-    window.setTimeout(function(){
-        if (! win) {
-            return;
-        }
-
-        win.Ext.MessageBox.alert(
-            _('Window can be closed'),
-            String.format(_('This Window can be closed now. To avoid this message please deactivate your browsers popup blocker for {0}'), Tine.title),
-            function() {
-                win.close();
+    if (! Ext.isNewIE && ! Ext.isIE) { // FIXME should not be needed, there is somthing very fishy here ...
+        window.setTimeout(function(){
+            if (! win) {
+                return;
             }
-        );
-    }, 500);
+    
+            win.Ext.MessageBox.alert(
+                _('Window can be closed'),
+                String.format(_('This Window can be closed now. To avoid this message please deactivate your browsers popup blocker for {0}'), Tine.title),
+                function() {
+                    win.close();
+                }
+            );
+        }, 500);
+    }
 };