0010016: Do not return relations the user shouldn't see on search
authorAlexander Stintzing <a.stintzing@metaways.de>
Thu, 17 Jul 2014 10:59:56 +0000 (12:59 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Wed, 30 Jul 2014 09:17:27 +0000 (11:17 +0200)
On searching in grid (e.g. tasks), the renderer tries to render the
crm lead relation even if the user doesn't have the right to use the
crm application or the crm application isn't installed anyway.

https://forge.tine20.org/mantisbt/view.php?id=10016

Change-Id: I2b50fd08f574587a5478138a230e5c48efb19bff
Reviewed-on: http://gerrit.tine20.com/customers/879
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
Tested-by: Philipp Schüle <p.schuele@metaways.de>
tine20/Tasks/js/TaskGridPanel.js

index 1d60fc8..e3e0304 100644 (file)
@@ -78,21 +78,21 @@ Tine.Tasks.TaskGridPanel = Ext.extend(Tine.widgets.grid.GridPanel, {
      * @private
      */
     getColumnModel: function(){
-        return new Ext.grid.ColumnModel({
-        defaults: {
-            sortable: true,
-            resizable: true
-        },
-        columns: [
-        {   id: 'tags', header: this.app.i18n._('Tags'), width: 40,  dataIndex: 'tags', sortable: false, renderer: Tine.Tinebase.common.tagsRenderer 
-        }, {
-            id: 'lead',
-            header: this.app.i18n._('Lead'),
-            width: 150,
-            dataIndex: 'relations',
-            renderer: Tine.widgets.grid.RendererManager.get('Tasks', 'Task', 'lead'),
-            sortable: false
-        }, {
+        
+        var columns = [{id: 'tags', header: this.app.i18n._('Tags'), width: 40,  dataIndex: 'tags', sortable: false, renderer: Tine.Tinebase.common.tagsRenderer}];
+        
+        if (Tine.hasOwnProperty('Crm') && Tine.Tinebase.common.hasRight('view', 'Crm')) {
+            columns.push({
+                id: 'lead',
+                header: this.app.i18n._('Lead'),
+                width: 150,
+                dataIndex: 'relations',
+                renderer: Tine.widgets.grid.RendererManager.get('Tasks', 'Task', 'lead'),
+                sortable: false
+            });
+        }
+        
+        columns = columns.concat([{
             id: 'summary',
             header: this.app.i18n._("Summary"),
             width: 400,
@@ -188,7 +188,15 @@ Tine.Tasks.TaskGridPanel = Ext.extend(Tine.widgets.grid.GridPanel, {
                 value: Tine.Tinebase.registry.get('currentAccount')
             })
           // TODO add customfields and modlog columns, atm they break the layout :(
-        }]/*.concat(this.getModlogColumns().concat(this.getCustomfieldColumns()))*/});
+        }]);/*.concat(this.getModlogColumns().concat(this.getCustomfieldColumns()))*/
+        
+        return new Ext.grid.ColumnModel({
+            defaults: {
+                sortable: true,
+                resizable: true
+            },
+            columns: columns
+        });
     },
 
     /**