[2010-12-08 14:01:47] Rev:652 | 3 files Added | 4 files Modified
carlos: improve assignation of users to roles -------------------------------------------------------------------------------- 1. A /trunk/workflow/engine/xmlform/roles/roles_userSearch.xml 2. A /trunk/workflow/engine/methods/roles/roles_AddUser.php 3. A /trunk/workflow/engine/xmlform/roles/roles_ListUsers.xml 4. M /trunk/workflow/engine/classes/model/Users.php 5. M /trunk/workflow/engine/methods/roles/roles_Ajax.php 6. M /trunk/workflow/engine/xmlform/roles/roles_Options.xml 7. M /trunk/workflow/engine/templates/roles/roles_Tree.php
This commit is contained in:
@@ -224,6 +224,22 @@ class Users extends BaseUsers {
|
||||
throw $oException;
|
||||
}
|
||||
}
|
||||
function getAvailableUsersCriteria($sGroupUID = '')
|
||||
{
|
||||
try {
|
||||
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->addSelectColumn(UsersPeer::USR_UID);
|
||||
$oCriteria->addSelectColumn(UsersPeer::USR_FIRSTNAME);
|
||||
$oCriteria->addSelectColumn(UsersPeer::USR_LASTNAME);
|
||||
$oCriteria->add(UsersPeer::USR_STATUS, 'ACTIVE');
|
||||
|
||||
return $oCriteria;
|
||||
}
|
||||
catch (exception $oError) {
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
} // Users
|
||||
|
||||
?>
|
||||
|
||||
34
workflow/engine/methods/roles/roles_AddUser.php
Executable file
34
workflow/engine/methods/roles/roles_AddUser.php
Executable file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/**
|
||||
* roles_AddUser.php
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*
|
||||
*/
|
||||
|
||||
$G_PUBLISH = new Publisher;
|
||||
|
||||
require_once 'classes/model/Users.php';
|
||||
$oUser = new Users();
|
||||
$aData = Array('ROL_UID'=>$_GET['ROL_UID']);
|
||||
$G_PUBLISH->AddContent('propeltable', 'roles/paged-table', 'roles/roles_ListUsers', $oUser->getAvailableUsersCriteria($_GET['ROL_UID']),$aData);
|
||||
|
||||
G::RenderPage('publish', 'raw');
|
||||
die;
|
||||
@@ -156,16 +156,20 @@ switch ($REQUEST) {
|
||||
break;
|
||||
|
||||
case 'assignUserToRole':
|
||||
$USR_UID = $_POST['USR_UID'];
|
||||
$ROL_UID = $_POST['ROL_UID'];
|
||||
$sData['USR_UID'] = $USR_UID;
|
||||
$sData['ROL_UID'] = $ROL_UID;
|
||||
$RBAC->assignUserToRole($sData);
|
||||
|
||||
$ROL_UID = $_POST['ROL_UID'];
|
||||
|
||||
$aUserIuds = explode(",",$_POST['aUsers']);
|
||||
foreach($aUserIuds as $key=>$val){
|
||||
$sData['USR_UID'] = $val;
|
||||
$sData['ROL_UID'] = $ROL_UID;
|
||||
$RBAC->assignUserToRole($sData);
|
||||
}
|
||||
|
||||
$_GET['ROL_UID'] = $ROL_UID;
|
||||
$G_PUBLISH = new Publisher;
|
||||
$G_PUBLISH->AddContent('view', 'roles/roles_Tree' );
|
||||
G::RenderPage('publish', 'raw');
|
||||
$G_PUBLISH = new Publisher;
|
||||
$G_PUBLISH->AddContent('view', 'roles/roles_Tree' );
|
||||
G::RenderPage('publish', 'raw');
|
||||
break;
|
||||
|
||||
case 'assignPermissionToRole':
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
</table>
|
||||
</div>
|
||||
<div class="boxBottomBlue"><div class="a"></div><div class="b"></div><div class="c"></div></div>
|
||||
<div class="userGroupLink"><a href="#" onclick="showUsers(\''.$_GET['ROL_UID'].'\');return false;">'.G::LoadTranslation('ID_ASSIGN_ROLE').'</a></div>';
|
||||
<div class="userGroupLink"><a href="#" onclick="showUsersLoad(\''.$_GET['ROL_UID'].'\');return false;">'.G::LoadTranslation('ID_ASSIGN_ROLE').'</a></div>';
|
||||
|
||||
$tree->showSign = false;
|
||||
|
||||
|
||||
27
workflow/engine/xmlform/roles/roles_ListUsers.xml
Executable file
27
workflow/engine/xmlform/roles/roles_ListUsers.xml
Executable file
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<dynaForm width="100%" rowsPerPage="11" menu="roles/roles_userSearch" searchBy="USR_FIRSTNAME | USR_LASTNAME">
|
||||
|
||||
<ROL_UID type="hidden" colWidth="150" titleAlign="left" align="left" enableHtml="1"/>
|
||||
|
||||
<USR_UID type="CheckboxTable" colWidth="3" titleAlign="left" align="left" value="@#USR_UID">
|
||||
<en/>
|
||||
</USR_UID>
|
||||
|
||||
<USR_FIRSTNAME type="text" colWidth="150" titleAlign="left" align="left" enableHtml="1">
|
||||
<en>Firstname</en>
|
||||
</USR_FIRSTNAME>
|
||||
|
||||
<USR_LASTNAME type="text" colWidth="150" titleAlign="left" align="left" enableHtml="1">
|
||||
<en>Lastname</en>
|
||||
</USR_LASTNAME>
|
||||
|
||||
|
||||
<PAGED_TABLE_ID type="private" showInTable="0"/>
|
||||
|
||||
<JSFILTER type="javascript" replaceTags="1" showInTable="0">
|
||||
function pagedTableFilter( form ) {
|
||||
@#PAGED_TABLE_ID.doFilter( form );
|
||||
}
|
||||
</JSFILTER>
|
||||
|
||||
</dynaForm>
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
|
||||
PROCESS_REQUEST_FILE = '../roles/roles_Ajax';
|
||||
PROCESS_REQUEST_FILE_USER = '../roles/roles_AddUser';
|
||||
|
||||
function newRol() {
|
||||
popupWindow('', '../roles/roles_Ajax?request=newRole', 350, 225);
|
||||
@@ -182,10 +183,11 @@ function deleteRole(ROL_UID) {
|
||||
ajax.send(uri);
|
||||
};
|
||||
|
||||
|
||||
function usersIntoRole(ROL_UID)
|
||||
{
|
||||
var uri = 'request=usersIntoRole&ROL_UID='+ROL_UID;
|
||||
popupWindow('', '../roles/roles_Ajax?'+uri, 500, 450);
|
||||
myRoleWindow = popupWindow('', '../roles/roles_Ajax?'+uri, 500, 450);
|
||||
}
|
||||
|
||||
function deleteUserRole(ROL_UID, USR_UID){
|
||||
@@ -208,8 +210,29 @@ function deleteUserRole(ROL_UID, USR_UID){
|
||||
|
||||
function showUsers(ROL_UID)
|
||||
{
|
||||
oPanel = new leimnud.module.panel();
|
||||
oPanel.options = {
|
||||
size :{w:400,h:512},
|
||||
position:{x:0,y:0,center:true},
|
||||
title : 'Roles',
|
||||
theme :"processmaker",
|
||||
statusBar:false,
|
||||
control :{resize:false,roll:false,drag:true},
|
||||
fx :{modal:true,opacity:true,blinkToFront:false,fadeIn:false,drag:true}
|
||||
};
|
||||
oPanel.events = {
|
||||
remove: function() {
|
||||
delete(oPanel);
|
||||
resetChecks();
|
||||
}.extend(this)
|
||||
};
|
||||
oPanel.make();
|
||||
oPanel.loader.show();
|
||||
currentPopupWindow = oPanel;
|
||||
|
||||
|
||||
var oRPC = new leimnud.module.rpc.xmlhttp({
|
||||
url : PROCESS_REQUEST_FILE,
|
||||
url : PROCESS_REQUEST_FILE_USER,
|
||||
async : false,
|
||||
method: 'POST',
|
||||
args : 'request=showUsers&ROL_UID=' + ROL_UID
|
||||
@@ -218,11 +241,63 @@ function showUsers(ROL_UID)
|
||||
currentPopupWindow.clearContent();
|
||||
currentPopupWindow.addContent(oRPC.xmlhttp.responseText);
|
||||
}
|
||||
var checks_selected_Rolid = new Array();
|
||||
function showUsersLoad( ROL_UID ){
|
||||
currentPopupWindow.remove();
|
||||
oPanel = new leimnud.module.panel();
|
||||
oPanel.options = {
|
||||
size :{w:500,h:512},
|
||||
position:{x:0,y:0,center:true},
|
||||
title : 'Roles',
|
||||
theme :"processmaker",
|
||||
statusBar:false,
|
||||
control :{resize:false,roll:false,drag:true},
|
||||
fx :{modal:true,opacity:true,blinkToFront:false,fadeIn:false,drag:true}
|
||||
};
|
||||
oPanel.events = {
|
||||
remove: function() {
|
||||
delete(oPanel);
|
||||
resetChecks();
|
||||
}.extend(this)
|
||||
};
|
||||
oPanel.make();
|
||||
oPanel.loader.show();
|
||||
currentPopupWindow = oPanel;
|
||||
var oRPC = new leimnud.module.rpc.xmlhttp({
|
||||
url : '../roles/roles_AddUser?ROL_UID='+ROL_UID,
|
||||
args: ''
|
||||
});
|
||||
|
||||
//currentPopupWindow.clearContent();
|
||||
//currentPopupWindow.addContent(oRPC.xmlhttp.responseText);
|
||||
checks_selected_Rolid.push(ROL_UID);
|
||||
oRPC.callback = function(rpc) {
|
||||
oPanel.loader.hide();
|
||||
var scs=rpc.xmlhttp.responseText.extractScript();
|
||||
oPanel.addContent(rpc.xmlhttp.responseText);
|
||||
scs.evalScript();
|
||||
var inputs = document.getElementsByTagName("input");
|
||||
for(i=0; i<inputs.length; i++){
|
||||
if( inputs[i].type == "checkbox" ){
|
||||
try{
|
||||
inputs[i].onclick = function(){
|
||||
if(this.checked){
|
||||
checks_selected_ids.push(this.value);
|
||||
} else {
|
||||
checks_selected_ids.deleteByValue(this.value);
|
||||
}
|
||||
};
|
||||
}catch(e){alert(e)}
|
||||
}
|
||||
}
|
||||
}.extend(this);
|
||||
oRPC.make();
|
||||
|
||||
|
||||
}
|
||||
function assignUserToRole(ROL_UID, USR_UID)
|
||||
{
|
||||
|
||||
var oRPC = new leimnud.module.rpc.xmlhttp({
|
||||
var oRPC = new leimnud.module.rpc.xmlhttp({
|
||||
url : PROCESS_REQUEST_FILE,
|
||||
async : false,
|
||||
method: 'POST',
|
||||
@@ -339,7 +414,34 @@ String.prototype.trim = function()
|
||||
function $(id){
|
||||
return document.getElementById(id);
|
||||
}
|
||||
function saveUsers(){
|
||||
|
||||
if(checks_selected_Rolid.length>1){
|
||||
rolUid = checks_selected_Rolid[1];
|
||||
}else{
|
||||
rolUid = checks_selected_Rolid;
|
||||
}
|
||||
|
||||
if( checks_selected_ids.length == 0 ){
|
||||
new leimnud.module.app.alert().make({label: G_STRINGS.ID_MSG_GROUPS_ADDCONFIRM});
|
||||
return 0;
|
||||
}
|
||||
var oRPC = new leimnud.module.rpc.xmlhttp({
|
||||
url : PROCESS_REQUEST_FILE,
|
||||
async : false,
|
||||
method: 'POST',
|
||||
args : 'request=assignUserToRole&ROL_UID=' + rolUid + '&aUsers=' + checks_selected_ids
|
||||
});
|
||||
resetChecks();
|
||||
oRPC.make();
|
||||
currentPopupWindow.remove();
|
||||
|
||||
usersIntoRole(rolUid);
|
||||
}
|
||||
|
||||
function resetChecks(){
|
||||
checks_selected_ids.length = 0;
|
||||
}
|
||||
]]></JS>
|
||||
|
||||
</dynaForm>
|
||||
</dynaForm>
|
||||
|
||||
9
workflow/engine/xmlform/roles/roles_userSearch.xml
Executable file
9
workflow/engine/xmlform/roles/roles_userSearch.xml
Executable file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0"?>
|
||||
<dynaForm
|
||||
type="xmlmenu"
|
||||
>
|
||||
|
||||
<PAGED_TABLE_ID type="private"/>
|
||||
<PAGED_TABLE_FAST_SEARCH type="FastSearch" label="@G::LoadTranslation(ID_SEARCH)"/>
|
||||
|
||||
</dynaForm>
|
||||
Reference in New Issue
Block a user