diff --git a/rbac/engine/classes/model/AuthenticationSource.php b/rbac/engine/classes/model/AuthenticationSource.php index be7f8d3f6..e1d923f1e 100644 --- a/rbac/engine/classes/model/AuthenticationSource.php +++ b/rbac/engine/classes/model/AuthenticationSource.php @@ -33,6 +33,11 @@ class AuthenticationSource extends BaseAuthenticationSource { $oAuthenticationSource = AuthenticationSourcePeer::retrieveByPK($sUID); if (!is_null($oAuthenticationSource)) { $aFields = $oAuthenticationSource->toArray(BasePeer::TYPE_FIELDNAME); + //fixing the problem where the BaseDN has spaces. we are removing the spaces. + $baseDn = explode(',', $aFields['AUTH_SOURCE_BASE_DN']); + foreach ($baseDn as $key => $val ) $baseDn[$key] = trim($val); + $aFields['AUTH_SOURCE_BASE_DN'] = implode (',', $baseDn); + $this->fromArray($aFields, BasePeer::TYPE_FIELDNAME); $aFields['AUTH_SOURCE_DATA'] = ($aFields['AUTH_SOURCE_DATA'] != '' ? unserialize($aFields['AUTH_SOURCE_DATA']) : array()); return $aFields; diff --git a/workflow/engine/methods/authSources/authSources_Edit.php b/workflow/engine/methods/authSources/authSources_Edit.php index 3d0a26d47..ada70cd37 100644 --- a/workflow/engine/methods/authSources/authSources_Edit.php +++ b/workflow/engine/methods/authSources/authSources_Edit.php @@ -22,48 +22,56 @@ * 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; -} -if (!isset($_GET['sUID'])) { - G::SendTemporalMessage('ID_ERROR_OBJECT_NOT_EXISTS', 'error', 'labels'); - G::header('location: authSources_List'); - die; -} - -if ($_GET['sUID'] == '') { - G::SendTemporalMessage('ID_ERROR_OBJECT_NOT_EXISTS', 'error', 'labels'); - G::header('location: authSources_List'); - die; -} - -$G_MAIN_MENU = 'processmaker'; -$G_SUB_MENU = 'users'; -$G_ID_MENU_SELECTED = 'USERS'; -$G_ID_SUB_MENU_SELECTED = 'AUTH_SOURCES'; - -$aFields = $RBAC->getAuthSource($_GET['sUID']); -if (is_array($aFields['AUTH_SOURCE_DATA'])) { - foreach($aFields['AUTH_SOURCE_DATA'] as $sField => $sValue) { - $aFields[$sField] = $sValue; + global $RBAC; + if ($RBAC->userCanAccess('PM_SETUP_ADVANCE') != 1) { + G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels'); + G::header('location: ../login/login'); + die; } -} -unset($aFields['AUTH_SOURCE_DATA']); - -$G_PUBLISH = new Publisher(); -if ($aFields['AUTH_SOURCE_PROVIDER'] == 'ldap') { - $G_PUBLISH->AddContent('xmlform', 'xmlform', 'authSources/ldapEdit', '', $aFields, '../authSources/authSources_Save'); -} -else { - if (file_exists(PATH_XMLFORM . 'authSources/' . $aFields['AUTH_SOURCE_PROVIDER'] . 'Edit.xml')) { - $G_PUBLISH->AddContent('xmlform', 'xmlform', 'authSources/' . $aFields['AUTH_SOURCE_PROVIDER'] . 'Edit', '', $aFields, '../authSources/authSources_Save'); + + if (!isset($_GET['sUID'])) { + G::SendTemporalMessage('ID_ERROR_OBJECT_NOT_EXISTS', 'error', 'labels'); + G::header('location: authSources_List'); + die; + } + + if ($_GET['sUID'] == '') { + G::SendTemporalMessage('ID_ERROR_OBJECT_NOT_EXISTS', 'error', 'labels'); + G::header('location: authSources_List'); + die; + } + + $G_MAIN_MENU = 'processmaker'; + $G_SUB_MENU = 'users'; + $G_ID_MENU_SELECTED = 'USERS'; + $G_ID_SUB_MENU_SELECTED = 'AUTH_SOURCES'; + + $aFields = $RBAC->getAuthSource($_GET['sUID']); + if (is_array($aFields['AUTH_SOURCE_DATA'])) { + foreach($aFields['AUTH_SOURCE_DATA'] as $sField => $sValue) { + $aFields[$sField] = $sValue; + } + } + unset($aFields['AUTH_SOURCE_DATA']); + + //fixing a problem with dropdown with int values, + //the problem : the value was integer, but the dropdown was expecting a string value, and they returns always the first item of dropdown + if ( isset($aFields['AUTH_SOURCE_ENABLED_TLS'])) + $aFields['AUTH_SOURCE_ENABLED_TLS'] = sprintf('%d', $aFields['AUTH_SOURCE_ENABLED_TLS'] ); + if ( isset($aFields['AUTH_ANONYMOUS'])) + $aFields['AUTH_ANONYMOUS'] = sprintf('%d', $aFields['AUTH_ANONYMOUS'] ); + + $G_PUBLISH = new Publisher(); + if ($aFields['AUTH_SOURCE_PROVIDER'] == 'ldap') { + $G_PUBLISH->AddContent('xmlform', 'xmlform', 'authSources/ldapEdit', '', $aFields, '../authSources/authSources_Save'); } else { - $G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showMessage', '', array('MESSAGE' => 'File: ' . $aFields['AUTH_SOURCE_PROVIDER'] . 'Edit.xml' . ' not exists.')); + if (file_exists(PATH_XMLFORM . 'authSources/' . $aFields['AUTH_SOURCE_PROVIDER'] . 'Edit.xml')) { + $G_PUBLISH->AddContent('xmlform', 'xmlform', 'authSources/' . $aFields['AUTH_SOURCE_PROVIDER'] . 'Edit', '', $aFields, '../authSources/authSources_Save'); + } + else { + $G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showMessage', '', array('MESSAGE' => 'File: ' . $aFields['AUTH_SOURCE_PROVIDER'] . 'Edit.xml' . ' not exists.')); + } } -} -G::RenderPage('publish','blank'); \ No newline at end of file + G::RenderPage('publish','blank'); \ No newline at end of file diff --git a/workflow/engine/methods/authSources/authSources_Save.php b/workflow/engine/methods/authSources/authSources_Save.php index f34574146..f8c2a0f72 100644 --- a/workflow/engine/methods/authSources/authSources_Save.php +++ b/workflow/engine/methods/authSources/authSources_Save.php @@ -3,7 +3,7 @@ * authSources_Save.php * * ProcessMaker Open Source Edition - * Copyright (C) 2004 - 2008 Colosa Inc.23 + * Copyright (C) 2004 - 2008 Colosa Inc. * * 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,44 +22,46 @@ * 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; -} -unset($_POST['form']['btnSave']); + global $RBAC; + if ($RBAC->userCanAccess('PM_SETUP_ADVANCE') != 1) { + G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels'); + G::header('location: ../login/login'); + die; + } -$aCommonFields = array('AUTH_SOURCE_UID', - 'AUTH_SOURCE_NAME', - 'AUTH_SOURCE_PROVIDER', - 'AUTH_SOURCE_SERVER_NAME', - 'AUTH_SOURCE_PORT', - 'AUTH_SOURCE_ENABLED_TLS', - 'AUTH_ANONYMOUS', - 'AUTH_SOURCE_SEARCH_USER', - 'AUTH_SOURCE_PASSWORD', - 'AUTH_SOURCE_VERSION', - 'AUTH_SOURCE_BASE_DN', - 'AUTH_SOURCE_OBJECT_CLASSES', - 'AUTH_SOURCE_ATTRIBUTES'); -$aFields = $aData = array(); -foreach ($_POST['form'] as $sField => $sValue) { - if (in_array($sField, $aCommonFields)) { - $aFields[$sField] = $sValue; + unset($_POST['form']['btnSave']); + + $aCommonFields = array('AUTH_SOURCE_UID', + 'AUTH_SOURCE_NAME', + 'AUTH_SOURCE_PROVIDER', + 'AUTH_SOURCE_SERVER_NAME', + 'AUTH_SOURCE_PORT', + 'AUTH_SOURCE_ENABLED_TLS', + 'AUTH_ANONYMOUS', + 'AUTH_SOURCE_SEARCH_USER', + 'AUTH_SOURCE_PASSWORD', + 'AUTH_SOURCE_VERSION', + 'AUTH_SOURCE_BASE_DN', + 'AUTH_SOURCE_OBJECT_CLASSES', + 'AUTH_SOURCE_ATTRIBUTES'); + + $aFields = $aData = array(); + foreach ($_POST['form'] as $sField => $sValue) { + if (in_array($sField, $aCommonFields)) { + $aFields[$sField] = $sValue; + } + else { + $aData[$sField] = $sValue; + } + } + $aFields['AUTH_SOURCE_DATA'] = $aData; + + if ($aFields['AUTH_SOURCE_UID'] == '') { + $RBAC->createAuthSource($aFields); } else { - $aData[$sField] = $sValue; + $RBAC->updateAuthSource($aFields); } -} -$aFields['AUTH_SOURCE_DATA'] = $aData; - -if ($aFields['AUTH_SOURCE_UID'] == '') { - $RBAC->createAuthSource($aFields); -} -else { - $RBAC->updateAuthSource($aFields); -} - -G::header('location: authSources_List'); \ No newline at end of file + + G::header('location: authSources_List'); \ No newline at end of file