Authentication Sources Manager Ext JS Migration Complete

This commit is contained in:
Enrique Ponce de Leon
2011-02-14 19:29:28 +00:00
parent 3a851208da
commit 8f5603cb6d
7 changed files with 534 additions and 4 deletions

View File

@@ -91,7 +91,7 @@ class RBAC
function initRBAC () {
if ( is_null($this->userObj ) ) {
require_once ( "classes/model/RbacUsers.php" );
$this->userObj = new RbacUsers;
$this->userObj = new RbacUsers();
}
if ( is_null($this->systemObj ) ) {
@@ -857,6 +857,22 @@ class RBAC
function getAllAuthSources() {
return $this->authSourcesObj->getAllAuthSources();
}
/**
* this function gets all authentication source
* Authentication Sources based at parameters
*
* @access public
* @author Enrique Ponce de Leon <enrique@colosa.com>
* @param int $start offset value to paging grid
* @param int $limit limit value to paging grid
* @param string $filter value to search or filter select
* @return $this->authSourcesObj->getAuthenticationSources()
*/
function getAuthenticationSources($start,$limit,$filter='') {
return $this->authSourcesObj->getAuthenticationSources($start,$limit,$filter);
}
/**
* this function gets all authentication source
@@ -910,6 +926,19 @@ class RBAC
function removeAuthSource($sUID) {
$this->authSourcesObj->remove($sUID);
}
/**
* this function gets all users by authentication source
*
* @access public
* @param void
* @return $this->userObj->getAllUsersByAuthSource()
*/
function getAllUsersByAuthSource(){
return $this->userObj->getAllUsersByAuthSource();
}
/**
* this function searchs users

View File

@@ -136,4 +136,29 @@ class AuthenticationSource extends BaseAuthenticationSource {
throw($oError);
}
}
//Added By Enrique Ponce de Leon <enrique@colosa.com>
//Gets Criteria to fill grid of authentication source
function getAuthenticationSources($start,$limit,$filter=''){
$oCriteria = new Criteria('rbac');
$oCriteria->addSelectColumn('COUNT(*) AS CNT');
$oCriteria->add(AuthenticationSourcePeer::AUTH_SOURCE_UID,'',Criteria::NOT_EQUAL);
if ($filter!=''){
$oCriteria->add(AuthenticationSourcePeer::AUTH_SOURCE_NAME,'%'.$filter.'%',Criteria::LIKE);
}
$oCriteria2 = new Criteria('rbac');
$oCriteria2->addSelectColumn('*');
$oCriteria2->add(AuthenticationSourcePeer::AUTH_SOURCE_UID,'',Criteria::NOT_EQUAL);
if ($filter!=''){
$oCriteria2->add(AuthenticationSourcePeer::AUTH_SOURCE_NAME,'%'.$filter.'%',Criteria::LIKE);
}
$oCriteria2->setLimit($limit);
$oCriteria2->setOffset($start);
$result = array();
$result['COUNTER'] = $oCriteria;
$result['LIST'] = $oCriteria2;
return $result;
}
} // AuthenticationSource

View File

@@ -209,5 +209,24 @@ class RbacUsers extends BaseRbacUsers {
$this->setUsrUid($sUserUID);
$this->delete();
}
//Added by Qennix at Feb 14th, 2011
//Gets an associative array with total users by authentication sources
function getAllUsersByAuthSource(){
$oCriteria = new Criteria('rbac');
$oCriteria->addSelectColumn(RbacUsersPeer::UID_AUTH_SOURCE);
$oCriteria->addSelectColumn('COUNT(*) AS CNT');
$oCriteria->add(RbacUsersPeer::USR_STATUS,'CLOSED',Criteria::NOT_EQUAL);
$oCriteria->addGroupByColumn(RbacUsersPeer::UID_AUTH_SOURCE);
$oDataset = RbacUsersPeer::doSelectRS($oCriteria);
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$aAuth = Array();
while ($oDataset->next()){
$row = $oDataset->getRow();
$aAuth[$row['UID_AUTH_SOURCE']] = $row['CNT'];
}
return $aAuth;
}
} // Users

View File

@@ -30,7 +30,7 @@ try {
die;
}
switch ($_POST['action']) {
switch ($_REQUEST['action']) {
case 'searchUsers':
G::LoadThirdParty('pear/json','class.json');
require_once 'classes/model/Users.php';
@@ -91,6 +91,63 @@ try {
}
G::RenderPage('publish', 'raw');
break;
case 'authSourcesList':
require_once PATH_RBAC.'model/AuthenticationSource.php';
global $RBAC;
G::LoadClass('configuration');
$co = new Configurations();
$config = $co->getConfiguration('authSourcesList', 'pageSize','',$_SESSION['USER_LOGGED']);
$limit_size = isset($config['pageSize']) ? $config['pageSize'] : 20;
$start = isset($_REQUEST['start']) ? $_REQUEST['start'] : 0;
$limit = isset($_REQUEST['limit']) ? $_REQUEST['limit'] : $limit_size;
$filter = isset($_REQUEST['textFilter']) ? $_REQUEST['textFilter'] : '';
$Criterias = $RBAC->getAuthenticationSources($start, $limit, $filter);
$Dat = AuthenticationSourcePeer::doSelectRS($Criterias['COUNTER']);
$Dat->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$Dat->next();
$row = $Dat->getRow();
$total_sources = $row['CNT'];
$oDataset = AuthenticationSourcePeer::doSelectRS($Criterias['LIST']);
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
global $RBAC;
$auth = $RBAC->getAllUsersByAuthSource();
$aSources = Array();
while ($oDataset->next()){
$aSources[] = $oDataset->getRow();
$index = sizeof($aSources)-1;
$aSources[$index]['CURRENT_USERS'] = isset($auth[$aSources[$index]['AUTH_SOURCE_UID']]) ? $auth[$aSources[$index]['AUTH_SOURCE_UID']] : 0;
}
echo '{sources: '.G::json_encode($aSources).', total_sources: '.$total_sources.'}';
break;
case 'canDeleteAuthSource':
//echo 'llego';
//require_once PATH_RBAC.'model/RbacUsers.php';
try{
$authUID = $_POST['auth_uid'];
global $RBAC;
$aAuth = $RBAC->getAllUsersByAuthSource();
$response = isset($aAuth[$authUID]) ? 'false' : 'true';
echo '{success: '.$response.'}';
}catch(Exception $ex){
echo '{success: false, error: '.$ex->getMessage().'}';
}
break;
case 'deleteAuthSource':
try{
global $RBAC;
$RBAC->removeAuthSource($_POST['auth_uid']);
echo '{success: true}';
}catch(Exception $ex){
echo '{success: false, error: '.$ex->getMessage().'}';
}
break;
}
}
catch ( Exception $e ) {

View File

@@ -30,11 +30,22 @@ if ($RBAC->userCanAccess('PM_SETUP_ADVANCE') != 1) {
die;
}
G::LoadClass('configuration');
$c = new Configurations();
$configPage = $c->getConfiguration('authSourcesList', 'pageSize','',$_SESSION['USER_LOGGED']);
$Config['pageSize'] = isset($configPage['pageSize']) ? $configPage['pageSize'] : 20;
$G_MAIN_MENU = 'processmaker';
$G_SUB_MENU = 'users';
$G_ID_MENU_SELECTED = 'USERS';
$G_ID_SUB_MENU_SELECTED = 'AUTH_SOURCES';
$G_PUBLISH = new Publisher;
$G_PUBLISH->AddContent('propeltable', 'paged-table', 'authSources/authSources_List', $RBAC->getAllAuthSources(), '', '');
G::RenderPage('publish','blank');
$oHeadPublisher =& headPublisher::getSingleton();
$oHeadPublisher->addExtJsScript('authSources/authSourcesList', false); //adding a javascript file .js
$oHeadPublisher->addContent('authSources/authSourcesList'); //adding a html file .html.
$oHeadPublisher->assign('FORMATS',$c->getFormats());
$oHeadPublisher->assign('CONFIG', $Config);
G::RenderPage('publish', 'extJs');
?>

View File

@@ -0,0 +1,3 @@
<div style="padding: 15px">
<div id="list-panel"></div>
</div>

File diff suppressed because it is too large Load Diff