implemented the fabled group-groups
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 2 Aug 2006 20:35:00 +0000 (20:35 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 2 Aug 2006 20:35:00 +0000 (20:35 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@5231 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/xul/staff_client/server/patron/ue.js
Open-ILS/xul/staff_client/server/patron/ue.xhtml
Open-ILS/xul/staff_client/server/patron/ue_config.js
Open-ILS/xul/staff_client/server/patron/ue_ui.js

index 862399c..2b40112 100644 (file)
@@ -83,16 +83,15 @@ function uEditBuild() {
                );
 
        if(patron.isnew()) {
-               if(clone) 
-                       uEditClone(clone);
-               else 
-                       uEditCreateNewAddr();
-       }
+               if(clone) uEditClone(clone);
+               else uEditCreateNewAddr();
+
+       } else {
 
-       if(!patron.isnew()) {
                $('ue_barcode').disabled = true;
                unHideMe($('ue_mark_card_lost'));
                unHideMe($('ue_reset_pw'));
+               uEditCheckEditPerm();
        }
 
        if(PERMS['BAR_PATRON'] == -1) 
@@ -100,6 +99,39 @@ function uEditBuild() {
 }
 
 
+/* if this user does not have permission to put users into
+       the edited users group, they do not have permission to 
+       edit this user */
+function uEditCheckEditPerm() {
+
+       var perm = uEditFindGroupPerm(groupsCache[patron.profile()]);   
+       _debug("editing user with group app perm "+patron.profile()+' : '+
+               groupsCache[patron.profile()].name() +', and perm = ' + perm);
+
+       if(PERMS[perm] != -1) return;
+
+       /* we can edit our own account, but not others in our group */
+       if( patron.id() != USER.id() ){
+               _debug("we are not allowed to edit this user");
+       
+               $('ue_save').disabled = true;
+               $('ue_save_clone').disabled = true;
+       
+               uEditIterateFields(
+                       function(f) {
+                               if( f && f.widget && f.widget.node )
+                                       f.widget.node.disabled = true;
+                       }       
+               );      
+
+       }
+
+       var node = $('ue_profile').parentNode;
+       node.removeChild($('ue_profile'));
+       node.appendChild(elem('span',null,groupsCache[patron.profile()].name()));
+}
+
+
 /* creates a new patron object with card attached */
 var uEditCardVirtId = -1;
 function uEditNewPatron() {
index 6a5330b..53cd7e6 100644 (file)
@@ -84,7 +84,7 @@
                </style>
        </head>
 
-       <body onload='try{uEditInit();}catch(e){alert(js2JSON(e));}'>
+       <body onload='uEditInit();'>
 
        <center>
 
index cf63122..0cf31d8 100644 (file)
@@ -21,12 +21,19 @@ const GUARDIAN_NOTE         = 'SYSTEM: Parent/Guardian';
 
 /* if they don't have these perms, they shouldn't be here */
 var myPerms = [ 
-       /*
-       'CREATE_USER', 
-       'UPDATE_USER', 
-       'CREATE_PATRON_STAT_CAT_ENTRY_MAP',
-       */
        'BAR_PATRON',
+       'group_application.user',
+       'group_application.user.patron',
+       'group_application.user.staff',
+       'group_application.user.staff.circ',
+       'group_application.user.staff.cat',
+       'group_application.user.staff.admin.global_admin',
+       'group_application.user.staff.admin.local_admin',
+       'group_application.user.staff.admin.lib_manager',
+       'group_application.user.staff.cat.cat1',
+       'group_application.user.staff.supercat',
+       'group_application.user.sip_client',
+       'group_application.user.vendor'
        ];
 
 var dataFields;
@@ -340,6 +347,7 @@ function uEditDefineData(patron) {
                                regex           : numRegex,
                                onpostchange : function(field, value) {
                                        var type                        = groupsCache[value];
+                                       if(!type) return;
                                        var interval    = type.perm_interval();
 
                                        /* interval_to_seconds expects 'M' for months, 'm' for minutes */
index ec62dfc..3b2e462 100644 (file)
@@ -122,12 +122,27 @@ function uEditDrawGroups(tree, depth, selector) {
                depth = 0;
        }
        groupsCache[tree.id()] = tree;
-       insertSelectorVal( selector, -1, tree.name(), tree.id(), null, depth++ );       
+
+       /* if the staff does not have perms to access this group, 
+               remove it from the tree and don't add it's children */
+       var perm = uEditFindGroupPerm(tree);
+       var org = PERMS[perm];
+       if( org == -1 ) return;
+
+       var opt = insertSelectorVal( selector, -1, tree.name(), tree.id(), null, depth++ );     
+
        for( var c in tree.children() ) 
                uEditDrawGroups( tree.children()[c], depth, selector );
 }
 
 
+function uEditFindGroupPerm(group) {
+       if( group.application_perm() ) 
+               return group.application_perm();
+       return uEditFindGroupPerm(groupsCache[group.parent()]);
+}
+
+
 /* user identification types */
 function uEditDrawIDTypes(types) {
        var pri_sel = $('ue_primary_ident_type');
@@ -439,3 +454,5 @@ function uEditDrawNetLevels(netLevels) {
 }
 
 
+
+