Fix an issue with empty perms being serialized to arrays, while non-empty
authorJan Schneider <jan@horde.org>
Mon, 15 Mar 2010 21:40:15 +0000 (22:40 +0100)
committerJan Schneider <jan@horde.org>
Mon, 15 Mar 2010 21:40:15 +0000 (22:40 +0100)
perms are being serialized to hashes.

kronolith/js/kronolith.js

index 8ae1541..bf401a2 100644 (file)
@@ -2406,27 +2406,31 @@ KronolithCore = {
                 }
                 break;
             case 'groups':
-                $H(perm.value).each(function(group) {
-                    this.insertGroupOrUser(type, 'group', group.key);
-                    groupPerms = group.value;
-                    groupId = group.key;
-                }, this);
-                if (Object.isUndefined(basic) &&
-                    $H(perm.value).size() == 1 &&
-                    (groupPerms == (Kronolith.conf.perms.show | Kronolith.conf.perms.read) ||
-                     groupPerms == (Kronolith.conf.perms.show | Kronolith.conf.perms.read | Kronolith.conf.perms.edit))) {
-                    basic = groupPerms == (Kronolith.conf.perms.show | Kronolith.conf.perms.read) ? 'group_read' : 'group_edit';
-                } else {
-                    advanced = true;
+                if (perm.value.size()) {
+                    $H(perm.value).each(function(group) {
+                        this.insertGroupOrUser(type, 'group', group.key);
+                        groupPerms = group.value;
+                        groupId = group.key;
+                    }, this);
+                    if (Object.isUndefined(basic) &&
+                        $H(perm.value).size() == 1 &&
+                        (groupPerms == (Kronolith.conf.perms.show | Kronolith.conf.perms.read) ||
+                         groupPerms == (Kronolith.conf.perms.show | Kronolith.conf.perms.read | Kronolith.conf.perms.edit))) {
+                        basic = groupPerms == (Kronolith.conf.perms.show | Kronolith.conf.perms.read) ? 'group_read' : 'group_edit';
+                    } else {
+                        advanced = true;
+                    }
                 }
                 break;
             case 'users':
-                $H(perm.value).each(function(user) {
-                    if (user.key != Kronolith.conf.user) {
-                        this.insertGroupOrUser(type, 'user', user.key);
-                        advanced = true;
-                    }
-                }, this);
+                if (perm.value.size()) {
+                    $H(perm.value).each(function(user) {
+                        if (user.key != Kronolith.conf.user) {
+                            this.insertGroupOrUser(type, 'user', user.key);
+                            advanced = true;
+                        }
+                    }, this);
+                }
                 break;
             }