UAM - SAM Custom Script for User Add and Edit
From All n One's bxp software Wixi
Overview
For UAM it's possible to control what options are ticked and are not ticked. The following JavaScript script gives a working example of four different user types and how to control the options that are ticked for each of the different types.
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The function that checks and unchecks based on the button pressed
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
function fn_UAM_Selection(strFunctionalGroup){
fn_SetUnChecked();
if ( strFunctionalGroup == 'User'){
//Modules
if (document.getElementById('09')) { document.getElementById('09').checked=true; }
//Sections
if (document.getElementById('0910')) { document.getElementById('0910').checked=true; }
}
else if ( strFunctionalGroup == 'TeamLead'){
//Modules
if (document.getElementById('09')) { document.getElementById('09').checked=true; }
//Sections
if (document.getElementById('0910')) { document.getElementById('0910').checked=true; }
if (document.getElementById('0910')) { document.getElementById('0920').checked=true; }
if (document.getElementById('0910')) { document.getElementById('0930').checked=true; }
if (document.getElementById('0910')) { document.getElementById('0940').checked=true; }
if (document.getElementById('0910')) { document.getElementById('0950').checked=true; }
}
else if ( strFunctionalGroup == 'Reporter'){
//Modules
if (document.getElementById('61')) { document.getElementById('61').checked=true; }
//Sections
if (document.getElementById('6120')) { document.getElementById('6150').checked=true; }
if (document.getElementById('6170')) { document.getElementById('6170').checked=true; }
if (document.getElementById('6192')) { document.getElementById('6192').checked=true; }
if (document.getElementById('6194')) { document.getElementById('6194').checked=true; }
if (document.getElementById('6180')) { document.getElementById('6180').checked=true; }
if (document.getElementById('6190')) { document.getElementById('6190').checked=true; }
if (document.getElementById('6152')) { document.getElementById('6152').checked=true; }
if (document.getElementById('6110')) { document.getElementById('6110').checked=true; }
if (document.getElementById('6160')) { document.getElementById('6160').checked=true; }
if (document.getElementById('6150')) { document.getElementById('6160').checked=true; }
if (document.getElementById('6140')) { document.getElementById('6140').checked=true; }
if (document.getElementById('6196')) { document.getElementById('6196').checked=true; }
if (document.getElementById('6130')) { document.getElementById('6130').checked=true; }
}
else if ( strFunctionalGroup == 'Admin'){
fn_SetChecked();
}
//Feedback for the user to let them know they clicked something
alert ( strFunctionalGroup + ' set' );
}
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The row of buttons with the options set up
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
function fn_UAM_Controls(){
var strHTMLControls = '';
strHTMLControls += '<div id="divUAM_Controls">\n';
strHTMLControls += ' <input type="button" name="btnUAM_Group1" id="btnUAM_Group1" class="cssMaster_Button" style="width:15%;" value="User" onclick="fn_UAM_Selection(\'User\');" />\n';
strHTMLControls += ' <input type="button" name="btnUAM_Group2" id="btnUAM_Group2" class="cssMaster_Button" style="width:15%;" value="TeamLead" onclick="fn_UAM_Selection(\'TeamLead\');" />\n';
strHTMLControls += ' <input type="button" name="btnUAM_Group3" id="btnUAM_Group3" class="cssMaster_Button" style="width:15%;" value="Reporter" onclick="fn_UAM_Selection(\'Reporter\');" />\n';
strHTMLControls += ' <input type="button" name="btnUAM_Group4" id="btnUAM_Group4" class="cssMaster_Button" style="width:15%;" value="Admin" onclick="fn_UAM_Selection(\'Admin\');" />\n';
strHTMLControls += '</div>\n';
if ( document.getElementById('divUAM_Controls') ) {
document.getElementById('divUAM_Controls').innerHTML = strHTMLControls;
}
}
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The primary control function which is kicked off when the page loads.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
function fn_UAM_Main(){
//Initial default position is that a user has no permissions
fn_SetUnChecked();
//We add in the bar to allow permissions to be selected
fn_UAM_Controls();
//We hide all the checkboxes
if (document.getElementById('tableOptions')){
document.getElementById('tableOptions').style.display = 'none';
document.getElementById('tableSelectOptions').style.display = 'none';
}
}
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//Fire it all off as soon as the Add or Edit page loads
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
fn_UAM_Main();