changeset 359:8bc067b5f9c5

Added helper function to get authorisation information for the current item.
author Torsten Irländer <torsten.irlaender@intevation.de>
date Thu, 15 Aug 2013 14:03:47 +0200
parents 2b4ba307dae1
children 302db31ac50a
files app/model/Base.js
diffstat 1 files changed, 20 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/app/model/Base.js	Tue Aug 13 16:22:00 2013 +0200
+++ b/app/model/Base.js	Thu Aug 15 14:03:47 2013 +0200
@@ -12,5 +12,25 @@
      */
     getEidi: function() {
         return "/" + idProperty;
+    },
+    /**
+     * Helper function to make a AJAX request against the authinfo interface
+     * of the server
+     * @param callback function(model, readonly, isowner)
+     * @private
+     */
+    getAuthInfo: function(cb) {
+        Ext.Ajax.request({
+            scope: this,
+            url: 'server/rest/authinfo/' + this.data.probeId,
+            success: function(response, opts) {
+                var obj = Ext.decode(Ext.decode(response.responseText).data);
+                cb(this, obj.readonly, obj.isOwner);
+            },
+            failure: function(response, opts) {
+                console.log('server-side failure with status code ' + response.status);
+                cb(this, true, false);
+            }
+        });
     }
 });

http://lada.wald.intevation.org