Pman.js
authorAlan Knowles <alan@roojs.com>
Thu, 6 Oct 2011 05:19:41 +0000 (13:19 +0800)
committerAlan Knowles <alan@roojs.com>
Thu, 6 Oct 2011 05:19:41 +0000 (13:19 +0800)
Pman.js

diff --git a/Pman.js b/Pman.js
index 7d9552c..4f822cf 100644 (file)
--- a/Pman.js
+++ b/Pman.js
@@ -464,7 +464,9 @@ Pman = new Roo.Document(
     
     /**
      * eg. has Pman.hasPerm('Admin.Admin_Tab', 'S') == showlist..
-     * 
+     * @param {String} name the [Module].[permission] to check for
+     * @param {Char} lvl  - which type of permission to use (eg. S=show...)
+     * @returns {Boolean} tue indicates permission allowed
      */
     hasPerm: function(name, lvl) {
         if (
@@ -480,8 +482,24 @@ Pman = new Roo.Document(
         return Pman.Login.authUser.perms[name].indexOf(lvl) > -1;
         
     },
-    
-    
+    /**
+     * eg. has Pman.hasPerm('Admin.Admin_Tab', 'S') == showlist..
+     * @param {String} name the [Module].[permission] to check for
+     * @param {Char} lvl  - which type of permission to use (eg. S=show...)
+     * @returns {Boolean} tue indicates permission exists.
+     */
+    hasPermExists: function(name) {
+        if (
+            (typeof(Pman.Login.authUser) != 'object')
+            ||
+            (typeof(Pman.Login.authUser.perms) != 'object')
+            ||
+            (typeof(Pman.Login.authUser.perms[name]) != 'string')
+            ) {
+                return false;
+        }
+        return true;
+    },