0012218: manage_timeaccounts should always allow export timesheets
authorPhilipp Schüle <p.schuele@metaways.de>
Wed, 21 Sep 2016 08:51:53 +0000 (10:51 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Tue, 27 Sep 2016 12:41:30 +0000 (14:41 +0200)
https://forge.tine20.org/view.php?id=12218

Change-Id: I04c514ca9c493d9806cf2f6f6185f56f288dd788
Reviewed-on: http://gerrit.tine20.com/customers/3596
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
Tested-by: Philipp Schüle <p.schuele@metaways.de>
tine20/Timetracker/js/TimesheetGridPanel.js

index 0f0c365..8c3e9fa 100644 (file)
@@ -266,17 +266,28 @@ Tine.Timetracker.TimesheetGridPanel = Ext.extend(Tine.widgets.grid.GridPanel, {
         Tine.Timetracker.TimesheetGridPanel.superclass.initActions.call(this);
     },
 
+    /**
+     * check user exportGrant for timeaccounts
+     * NOTE: manage_timeaccounts ALWAYS allows to export
+     *
+     * @param action
+     * @param grants
+     * @param records
+     * @returns {boolean}
+     */
     updateExportAction: function(action, grants, records) {
         var exportGrant = true;
-        Ext.each(records, function(record) {
-            var c = record.get('timeaccount_id').container_id;
-            if (c.hasOwnProperty('account_grants')) {
-                if (! c.account_grants.exportGrant) {
-                    exportGrant = false;
-                    return false;
+        if (! Tine.Tinebase.common.hasRight('manage', 'Timetracker', 'timeaccounts')) {
+            Ext.each(records, function (record) {
+                var c = record.get('timeaccount_id').container_id;
+                if (c.hasOwnProperty('account_grants')) {
+                    if (!c.account_grants.exportGrant) {
+                        exportGrant = false;
+                        return false;
+                    }
                 }
-            }
-        });
+            });
+        }
 
         var disable = ! exportGrant;
         action.setDisabled(disable);