includes/clientside/static/acl.js
changeset 1058 c4b057708436
parent 1056 f21d6e75b469
child 1227 bdac73ed481e
equal deleted inserted replaced
1057:183111d8c46a 1058:c4b057708436
     4 var aclPermList = false;
     4 var aclPermList = false;
     5 var aclDataCache = false;
     5 var aclDataCache = false;
     6 
     6 
     7 function ajaxOpenACLManager(page_id, namespace)
     7 function ajaxOpenACLManager(page_id, namespace)
     8 {
     8 {
     9   if(IE)
     9   // touch these to make them available to child functions
    10     return true;
       
    11   
       
    12   void(page_id);
    10   void(page_id);
    13   void(namespace);
    11   void(namespace);
    14   
    12   
    15   // require re-auth
    13   // require re-auth
    16   if ( auth_level <= USER_LEVEL_MEMBER )
    14   if ( auth_level <= USER_LEVEL_MEMBER )
   481             
   479             
   482             a_dismiss.setAttribute('onclick', 'var parent = this.parentNode.parentNode; parent.removeChild(this.parentNode); return false;');
   480             a_dismiss.setAttribute('onclick', 'var parent = this.parentNode.parentNode; parent.removeChild(this.parentNode); return false;');
   483             a_close.setAttribute('onclick', 'killACLManager(); return false;');
   481             a_close.setAttribute('onclick', 'killACLManager(); return false;');
   484             
   482             
   485             if ( !document.getElementById(aclManagerID+'_deletelnk') )
   483             if ( !document.getElementById(aclManagerID+'_deletelnk') )
   486               document.getElementById(aclManagerID + '_main').innerHTML += '<p id="'+aclManagerID+'_deletelnk" style="text-align: right;"><a href="#delete_acl_rule" onclick="if(confirm(\'' + $lang.get('acl_msg_deleterule_confirm') + '\')) __aclDeleteRule(); return false;" style="color: red;">' + $lang.get('acl_lbl_deleterule') + '</a></p>';
   484             {
       
   485               var p = document.createElement('p');
       
   486               p.innerHTML = '<a href="#delete_acl_rule" onclick="if(confirm(\'' + $lang.get('acl_msg_deleterule_confirm') + '\')) __aclDeleteRule(); return false;" style="color: red;">' + $lang.get('acl_lbl_deleterule') + '</a>';
       
   487               p.id = aclManagerID + '_deletelnk';
       
   488               p.style.textAlign = 'right';
       
   489               
       
   490               document.getElementById(aclManagerID + '_main').appendChild(p);
       
   491             }
   487             
   492             
   488             document.getElementById(aclManagerID+'_main').scrollTop = 0;
   493             document.getElementById(aclManagerID+'_main').scrollTop = 0;
   489             document.getElementById(aclManagerID+'_main').style.backgroundImage = 'none';
   494             document.getElementById(aclManagerID+'_main').style.backgroundImage = 'none';
   490                         
   495                         
   491             aclDataCache.mode = 'save_edit';
   496             aclDataCache.mode = 'save_edit';
   700 }
   705 }
   701 
   706 
   702 function __aclBuildWizardWindow()
   707 function __aclBuildWizardWindow()
   703 {
   708 {
   704   darken(aclDisableTransitionFX, 70, 'acldarkener');
   709   darken(aclDisableTransitionFX, 70, 'acldarkener');
   705   box = document.createElement('div');
   710   var box = document.createElement('div');
   706   box.style.width = '640px'
   711   box.style.width = '640px'
   707   box.style.height = '440px';
   712   box.style.height = IE ? '500px' : '440px';
   708   box.style.position = 'fixed';
   713   box.style.position = 'fixed';
   709   width = getWidth();
   714   width = getWidth();
   710   height = getHeight();
   715   height = getHeight();
   711   box.style.left = ( width / 2 - 320 ) + 'px';
   716   box.style.left = ( width / 2 - 320 ) + 'px';
   712   box.style.top = ( height / 2 - 250 ) + 'px';
   717   box.style.top = ( height / 2 - 250 ) + 'px';
   715   box.id = aclManagerID;
   720   box.id = aclManagerID;
   716   box.style.opacity = '0';
   721   box.style.opacity = '0';
   717   box.style.filter = 'alpha(opacity=0)';
   722   box.style.filter = 'alpha(opacity=0)';
   718   box.style.display = 'none';
   723   box.style.display = 'none';
   719   
   724   
   720   mainwin = document.createElement('div');
   725   var mainwin = document.createElement('div');
   721   mainwin.id = aclManagerID + '_main';
   726   mainwin.id = aclManagerID + '_main';
   722   mainwin.style.clip = 'rect(0px,640px,440px,0px)';
   727   mainwin.style.clip = 'rect(0px,640px,440px,0px)';
   723   mainwin.style.overflow = 'auto';
   728   mainwin.style.overflow = 'auto';
   724   mainwin.style.width = '620px';
   729   mainwin.style.width = '620px';
   725   mainwin.style.height = '420px';
   730   mainwin.style.height = '420px';
   726   
   731   
   727   panel = document.createElement('div');
   732   var panel = document.createElement('div');
   728   panel.style.width = '620px';
   733   panel.style.width = '620px';
   729   panel.style.padding = '10px';
   734   panel.style.padding = '10px';
   730   panel.style.lineHeight = '40px';
   735   panel.style.lineHeight = '40px';
   731   panel.style.textAlign = 'right';
   736   panel.style.textAlign = 'right';
   732   panel.style.position = 'fixed';
   737   panel.style.position = 'fixed';
   733   panel.style.left = ( width / 2 - 320 ) + 'px';
   738   if ( IE )
   734   panel.style.top = ( height / 2 + 190 ) + 'px';
   739   {
       
   740     panel.style.left = '0px';
       
   741     panel.style.top = '440px';
       
   742   }
       
   743   else
       
   744   {
       
   745     panel.style.left = ( width / 2 - 320 ) + 'px';
       
   746     panel.style.top = ( height / 2 + 190 ) + 'px';
       
   747   }
   735   panel.style.backgroundColor = '#D0D0D0';
   748   panel.style.backgroundColor = '#D0D0D0';
   736   panel.style.opacity = '0';
   749   panel.style.opacity = '0';
   737   panel.style.filter = 'alpha(opacity=0)';
   750   panel.style.filter = 'alpha(opacity=0)';
   738   panel.id = aclManagerID + '_panel';
   751   panel.id = aclManagerID + '_panel';
   739   
   752   
   740   form = document.createElement('form');
   753   var form = document.createElement('form');
   741   form.method = 'post';
   754   form.method = 'post';
   742   form.action = 'javascript:void(0)';
   755   form.action = 'javascript:void(0)';
   743   form.onsubmit = function() { if(this.username && !submitAuthorized) return false; __aclSubmitManager(this); return false; };
   756   form.onsubmit = function() { if(this.username && !submitAuthorized) return false; __aclSubmitManager(this); return false; };
   744   form.name = aclManagerID + '_formobj';
   757   form.name = aclManagerID + '_formobj';
   745   form.id   = aclManagerID + '_formobj_id';
   758   form.id   = aclManagerID + '_formobj_id';
   746   
   759   
   747   back = document.createElement('input');
   760   var back = document.createElement('input');
   748   back.type = 'button';
   761   back.type = 'button';
   749   back.value = $lang.get('etc_wizard_back');
   762   back.value = $lang.get('etc_wizard_back');
   750   back.style.fontWeight = 'normal';
   763   back.style.fontWeight = 'normal';
   751   back.onclick = function() { ajaxACLSwitchToSelector(); return false; };
   764   back.onclick = function() { ajaxACLSwitchToSelector(); return false; };
   752   back.style.display = 'none';
   765   back.style.display = 'none';
   753   back.id = aclManagerID + '_back';
   766   back.id = aclManagerID + '_back';
   754   
   767   
   755   saver = document.createElement('input');
   768   var saver = document.createElement('input');
   756   saver.type = 'submit';
   769   saver.type = 'submit';
   757   saver.value = $lang.get('etc_wizard_next');
   770   saver.value = $lang.get('etc_wizard_next');
   758   saver.style.fontWeight = 'bold';
   771   saver.style.fontWeight = 'bold';
   759   saver.id = aclManagerID + '_next';
   772   saver.id = aclManagerID + '_next';
   760   
   773   
   761   closer = document.createElement('input');
   774   var closer = document.createElement('input');
   762   closer.type = 'button';
   775   closer.type = 'button';
   763   closer.value = $lang.get('etc_cancel_changes');
   776   closer.value = $lang.get('etc_cancel_changes');
   764   closer.onclick = function()
   777   closer.onclick = function()
   765   {
   778   {
   766     miniPromptMessage({
   779     miniPromptMessage({
   789       ]
   802       ]
   790     });
   803     });
   791     return false;
   804     return false;
   792   }
   805   }
   793   
   806   
   794   spacer1 = document.createTextNode('  ');
   807   var spacer1 = document.createTextNode('  ');
   795   spacer2 = document.createTextNode('  ');
   808   var spacer2 = document.createTextNode('  ');
   796   
   809   
   797   panel.appendChild(back);
   810   panel.appendChild(back);
   798   panel.appendChild(spacer1);
   811   panel.appendChild(spacer1);
   799   panel.appendChild(saver);
   812   panel.appendChild(saver);
   800   panel.appendChild(spacer2);
   813   panel.appendChild(spacer2);
   801   panel.appendChild(closer);
   814   panel.appendChild(closer);
   802   form.appendChild(mainwin);
   815   form.appendChild(mainwin);
   803   form.appendChild(panel);
   816   form.appendChild(panel);
   804   box.appendChild(form);
   817   box.appendChild(form);
   805   
   818   
   806   body = document.getElementsByTagName('body')[0];
   819   var body = document.getElementsByTagName('body')[0];
   807   body.appendChild(box);
   820   body.appendChild(box);
   808   if ( aclDisableTransitionFX )
   821   if ( aclDisableTransitionFX )
   809   {
   822   {
   810     document.getElementById(aclManagerID).style.display = 'block';
   823     document.getElementById(aclManagerID).style.display = 'block';
   811     changeOpac(100, aclManagerID);
   824     changeOpac(100, aclManagerID);
   813   }
   826   }
   814   else
   827   else
   815   {
   828   {
   816     setTimeout("document.getElementById('"+aclManagerID+"').style.display = 'block'; opacity('"+aclManagerID+"', 0, 100, 250); opacity('"+aclManagerID + '_panel'+"', 0, 100, 250);", 500);
   829     setTimeout("document.getElementById('"+aclManagerID+"').style.display = 'block'; opacity('"+aclManagerID+"', 0, 100, 250); opacity('"+aclManagerID + '_panel'+"', 0, 100, 250);", 500);
   817   }
   830   }
       
   831   
       
   832   console.debug(panel);
   818 }
   833 }
   819 
   834 
   820 function killACLManager()
   835 function killACLManager()
   821 {
   836 {
   822   el = document.getElementById(aclManagerID);
   837   el = document.getElementById(aclManagerID);
   835   }
   850   }
   836 }
   851 }
   837 
   852 
   838 function __aclSubmitManager(form)
   853 function __aclSubmitManager(form)
   839 {
   854 {
   840   var thefrm = document.forms[form.name];
   855   console.debug(form);
       
   856   var thefrm = form;
       
   857   // var thefrm = document.forms[form.name];
   841   var modeobj = form_fetch_field(thefrm, 'mode');
   858   var modeobj = form_fetch_field(thefrm, 'mode');
   842   if ( typeof(modeobj) == 'object' )
   859   if ( typeof(modeobj) == 'object' )
   843   {
   860   {
   844     var mode = (thefrm.mode.value) ? thefrm.mode.value : 'cant_get';
   861     var mode = (thefrm.mode.value) ? thefrm.mode.value : 'cant_get';
   845   }
   862   }
  1131   // selection window for viewing effective permissions
  1148   // selection window for viewing effective permissions
  1132   var main = document.getElementById(aclManagerID + '_main');
  1149   var main = document.getElementById(aclManagerID + '_main');
  1133   main.innerHTML = '';
  1150   main.innerHTML = '';
  1134  
  1151  
  1135   // set the submission handler to trace
  1152   // set the submission handler to trace
  1136   var thefrm = document.forms[form.name];
  1153   var thefrm = document.forms[aclManagerID + '_formobj'];
  1137   var modeobj = form_fetch_field(thefrm, 'mode');
  1154   var modeobj = form_fetch_field(thefrm, 'mode');
  1138   modeobj.value = 'trace';
  1155   modeobj.value = 'trace';
  1139   
  1156   
  1140   // show the back button
  1157   // show the back button
  1141   document.getElementById(aclManagerID + '_back').style.display = 'inline';
  1158   document.getElementById(aclManagerID + '_back').style.display = 'inline';