BUG 0000 improving the authentication sources code

This commit is contained in:
Carlos Pacha
2011-10-28 11:50:20 -04:00
parent 93d9f365f5
commit fc9b5e7283
11 changed files with 1225 additions and 38 deletions

View File

@@ -3,7 +3,7 @@
* authSources_Ajax.php
*
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2008 Colosa Inc.23
* Copyright (C) 2004 - 2011 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
@@ -147,7 +147,36 @@ try {
echo '{success: false, error: '.$ex->getMessage().'}';
}
break;
case 'authSourcesNew':
$arr = Array();
$oDirectory = dir(PATH_RBAC . 'plugins' . PATH_SEP);
$aAuthSourceTypes = array();
while($sObject = $oDirectory->read()) {
if (($sObject != '.') && ($sObject != '..') && ($sObject != '.svn') && ($sObject != 'ldap')) {
if (is_file(PATH_RBAC . 'plugins' . PATH_SEP . $sObject)) {
$sType = trim(str_replace('class.', '', str_replace('.php', '', $sObject)));
$aAuthSourceTypes['sType'] = $sType;
$aAuthSourceTypes['sLabel'] = $sType;
$arr[] = $aAuthSourceTypes;
}
}
}
echo '{sources: '.G::json_encode($arr).'}';
break;
case 'loadauthSourceData':
global $RBAC;
$fields = $RBAC->getAuthSource($_POST['sUID']);
if (is_array($fields['AUTH_SOURCE_DATA'])) {
foreach($fields['AUTH_SOURCE_DATA'] as $field => $value) {
$fields[$field] = $value;
}
}
unset($fields['AUTH_SOURCE_DATA']);
$result->success = true;
$result->sources = $fields;
print(G::json_encode($result));
break;
}
}
catch ( Exception $e ) {

View File

@@ -48,6 +48,7 @@ $G_ID_MENU_SELECTED = 'USERS';
$G_ID_SUB_MENU_SELECTED = 'AUTH_SOURCES';
$fields = $RBAC->getAuthSource($_GET['sUID']);
if (is_array($fields['AUTH_SOURCE_DATA'])) {
foreach($fields['AUTH_SOURCE_DATA'] as $field => $value) {
$fields[$field] = $value;
@@ -65,8 +66,11 @@ if (isset($fields['AUTH_ANONYMOUS'])) {
}
$G_PUBLISH = new Publisher();
if ($fields['AUTH_SOURCE_PROVIDER'] == 'ldap') {
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'authSources/ldapEdit', '', $fields, '../authSources/authSources_Save');
if ($fields['AUTH_SOURCE_PROVIDER'] == 'ldap' ) {
$oHeadPublisher =& headPublisher::getSingleton();
$oHeadPublisher->addExtJsScript('authSources/authSourcesEdit', false);
$oHeadPublisher->assign('sUID',$_GET['sUID']);
G::RenderPage('publish', 'extJs');
}
else {
if (file_exists(PATH_PLUGINS . $fields['AUTH_SOURCE_PROVIDER'] . PATH_SEP . $fields['AUTH_SOURCE_PROVIDER'] . 'Edit.xml')) {
@@ -81,4 +85,4 @@ else {
}
}
}
G::RenderPage('publish', 'blank');
G::RenderPage('publish', 'blank');

View File

@@ -48,4 +48,4 @@ $oHeadPublisher->addContent('authSources/authSourcesList'); //adding a html file
$oHeadPublisher->assign('FORMATS',$c->getFormats());
$oHeadPublisher->assign('CONFIG', $Config);
G::RenderPage('publish', 'extJs');
?>
?>

View File

@@ -3,7 +3,7 @@
* authSources_New.php
*
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2008 Colosa Inc.23
* Copyright (C) 2004 - 2011 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
@@ -22,35 +22,33 @@
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
*
*/
global $RBAC;
if ($RBAC->userCanAccess('PM_SETUP_ADVANCE') != 1) {
G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels');
G::header('location: ../login/login');
die;
}
$G_MAIN_MENU = 'processmaker';
$G_SUB_MENU = 'users';
$G_ID_MENU_SELECTED = 'USERS';
$G_ID_SUB_MENU_SELECTED = 'AUTH_SOURCES';
$fields = array('AUTH_SOURCE_PROVIDER' => $_POST['form']['AUTH_SOURCE_PROVIDER']);
$G_PUBLISH = new Publisher();
if ($_POST['form']['AUTH_SOURCE_PROVIDER'] == 'ldap') {
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'authSources/ldapEdit', '', $fields, '../authSources/authSources_Save');
}
else {
if (file_exists(PATH_PLUGINS . $fields['AUTH_SOURCE_PROVIDER'] . PATH_SEP . $fields['AUTH_SOURCE_PROVIDER'] . 'Edit.xml')) {
$G_PUBLISH->AddContent('xmlform', 'xmlform', $fields['AUTH_SOURCE_PROVIDER'] . PATH_SEP . $fields['AUTH_SOURCE_PROVIDER'] . 'Edit.xml', '', $fields, '../authSources/authSources_Save');
global $RBAC;
if ($RBAC->userCanAccess('PM_SETUP_ADVANCE') != 1) {
G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels');
G::header('location: ../login/login');
die;
}
else {
if (file_exists(PATH_XMLFORM . 'authSources/' . $fields['AUTH_SOURCE_PROVIDER'] . 'Edit.xml')) {
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'authSources/' . $fields['AUTH_SOURCE_PROVIDER'] . 'Edit', '', $fields, '../authSources/authSources_Save');
$G_MAIN_MENU = 'processmaker';
$G_SUB_MENU = 'users';
$G_ID_MENU_SELECTED = 'USERS';
$G_ID_SUB_MENU_SELECTED = 'AUTH_SOURCES';
$fields = array('AUTH_SOURCE_PROVIDER' => $_REQUEST['AUTH_SOURCE_PROVIDER']);
$G_PUBLISH = new Publisher();
if (file_exists(PATH_PLUGINS . $fields['AUTH_SOURCE_PROVIDER'] . PATH_SEP . $fields['AUTH_SOURCE_PROVIDER'] . 'Edit.xml')) {
$G_PUBLISH->AddContent('xmlform', 'xmlform', $fields['AUTH_SOURCE_PROVIDER'] . PATH_SEP . $fields['AUTH_SOURCE_PROVIDER'] . 'Edit.xml', '', $fields, '../authSources/authSources_Save');
}
else {
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showMessage', '', array('MESSAGE' => 'File: ' . $fields['AUTH_SOURCE_PROVIDER'] . 'Edit.xml' . ' not exists.'));
if (file_exists(PATH_XMLFORM . 'authSources/' . $fields['AUTH_SOURCE_PROVIDER'] . 'Edit.xml')) {
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'authSources/' . $fields['AUTH_SOURCE_PROVIDER'] . 'Edit', '', $fields, '../authSources/authSources_Save');
}
else {
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showMessage', '', array('MESSAGE' => 'File: ' . $fields['AUTH_SOURCE_PROVIDER'] . 'Edit.xml' . ' not exists.'));
}
}
}
}
G::RenderPage('publish','blank');
G::RenderPage('publish','blank');

View File

@@ -3,7 +3,7 @@
* authSources_SelectType.php
*
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2008 Colosa Inc.23
* Copyright (C) 2004 - 2011 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
@@ -49,5 +49,7 @@ $_DBArray['authSourceTypes'] = $aAuthSourceTypes;
$_SESSION['_DBArray'] = $_DBArray;
$G_PUBLISH = new Publisher();
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'authSources/authSources_SelectType', '', '', '../authSources/authSources_New');
$oHeadPublisher =& headPublisher::getSingleton();
$oHeadPublisher->addExtJsScript('authSources/authSourcesListNew', false); //adding a javascript file .js
G::RenderPage('publish', 'extJs');
G::RenderPage('publish','blank');

View File

@@ -0,0 +1,44 @@
<?php
/**
* authSources_SelectType.php
*
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2011 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.
*
*/
global $RBAC;
if ($RBAC->userCanAccess('PM_SETUP_ADVANCE') != 1) {
G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels');
G::header('location: ../login/login');
die;
}
$G_MAIN_MENU = 'processmaker';
$G_SUB_MENU = 'users';
$G_ID_MENU_SELECTED = 'USERS';
$G_ID_SUB_MENU_SELECTED = 'AUTH_SOURCES';
$aAuthSourceTypes = array(array('sType' => 'char', 'sLabel' => 'char'));
$oDirectory = dir(PATH_RBAC . 'plugins' . PATH_SEP);
$G_PUBLISH = new Publisher();
$oHeadPublisher =& headPublisher::getSingleton();
$oHeadPublisher->addExtJsScript('authSources/authSourceskindof', true); //adding a javascript file .js
$oHeadPublisher->assign('sprovider', $_GET['sprovider']);
G::RenderPage('publish', 'extJs');
G::RenderPage('publish','blank');