PM-1060: Firt migration ldapAdvanced

This commit is contained in:
Paula V. Quispe
2015-06-09 16:14:01 -04:00
parent 7b8f7b3792
commit 4d011b4174
13 changed files with 5100 additions and 26 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -158,17 +158,15 @@ try {
if (($sObject != '.') && ($sObject != '..') && ($sObject != '.svn') && ($sObject != 'ldap')) {
if (is_file( PATH_RBAC . 'plugins' . PATH_SEP . $sObject )) {
$sType = trim(str_replace(array("class.", ".php"), "", $sObject));
$statusPlugin = $pluginRegistry->getStatusPlugin($sType);
$flagAdd = false;
if (preg_match("/^(?:enabled|disabled)$/", $statusPlugin)) {
if ($statusPlugin == "enabled") {
$flagAdd = true;
}
} else {
/*----------------------------------********---------------------------------*/
if (PMLicensedFeatures
::getSingleton()
->verifyfeature('zLhSk5TeEQrNFI2RXFEVktyUGpnczV1WEJNWVp6cjYxbTU3R29mVXVZNWhZQT0=')) {
$flagAdd = true;
}
/*----------------------------------********---------------------------------*/
if ($flagAdd) {
$arr[] = array("sType" => $sType, "sLabel" => $sType);

View File

@@ -37,19 +37,8 @@ $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' )) {
$pluginEnabled = 0;
if (file_exists(PATH_PLUGINS . $fields["AUTH_SOURCE_PROVIDER"] . ".php")) {
$pluginRegistry = &PMPluginRegistry::getSingleton();
$pluginDetail = $pluginRegistry->getPluginDetails($fields["AUTH_SOURCE_PROVIDER"] . ".php");
if ($pluginDetail && $pluginDetail->enabled) {
if (file_exists( PATH_XMLFORM . 'ldapAdvanced/' . $fields['AUTH_SOURCE_PROVIDER'] . 'Edit.xml' )) {
$pluginEnabled = 1;
}
}
if ($pluginEnabled == 1) {
//The attributes the users
G::LoadClass("pmFunctions");
@@ -64,17 +53,17 @@ if (file_exists( PATH_PLUGINS . $fields['AUTH_SOURCE_PROVIDER'] . PATH_SEP . $fi
}
}
$fields["AUTH_SOURCE_ATTRIBUTE_IDS"] = $attributes;
if (file_exists(PATH_PLUGINS . $fields["AUTH_SOURCE_PROVIDER"] . PATH_SEP . $fields["AUTH_SOURCE_PROVIDER"] . 'Flag')) {
if (file_exists(PATH_XMLFORM . 'ldapAdvanced/' . $fields['AUTH_SOURCE_PROVIDER'] . 'Flag')) {
$oHeadPublisher = & headPublisher::getSingleton ();
$oHeadPublisher->assign("Fields", $fields);
$oHeadPublisher->addExtJsScript (PATH_PLUGINS . $fields["AUTH_SOURCE_PROVIDER"] . PATH_SEP . 'js' . PATH_SEP . 'library', false, true );
$oHeadPublisher->addExtJsScript (PATH_PLUGINS . $fields["AUTH_SOURCE_PROVIDER"] . PATH_SEP . 'js' . PATH_SEP . 'ldapAdvancedForm', false, true );
$oHeadPublisher->addExtJsScript (PATH_PLUGINS . $fields["AUTH_SOURCE_PROVIDER"] . PATH_SEP . 'js' . PATH_SEP . 'ldapAdvancedList', false, true );
$oHeadPublisher->addExtJsScript (PATH_TPL. 'ldapAdvanced/library.js', false, true );
$oHeadPublisher->addExtJsScript (PATH_TPL. 'ldapAdvanced/ldapAdvancedForm', false, true );
$oHeadPublisher->addExtJsScript (PATH_TPL. 'ldapAdvanced/ldapAdvancedList', false, true );
G::RenderPage ('publish', 'extJs');
die();
}
$G_PUBLISH->AddContent("xmlform", "xmlform", $fields["AUTH_SOURCE_PROVIDER"] . PATH_SEP . $fields["AUTH_SOURCE_PROVIDER"] . "Edit", "", $fields, "../authSources/authSources_Save");
$G_PUBLISH->AddContent("xmlform", "xmlform", 'ldapAdvanced/' . $fields['AUTH_SOURCE_PROVIDER'] . 'Edit', '', $fields, '../authSources/authSources_Save');
} else {
$G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'login/showMessage', '', array ('MESSAGE' => G::LoadTranslation( 'ID_AUTH_SOURCE_MISSING' )) );
}

View File

@@ -0,0 +1,651 @@
<?php
class ldapadvancedClassCron
{
public $deletedRemoved = 0; //Users in the removed OU
public $deletedRemovedUsers = "";
public $dAlready = 0; //Count for already existing users
public $dMoved = 0; //Users moved from a Department to another Department
public $dImpossible = 0; //Users already created using another Authentication source
public $dCreated = 0; //Users created
public $dRemoved = 0; //Users removed
public $dAlreadyUsers = "";
public $dMovedUsers = "";
public $dImpossibleUsers = "";
public $dCreatedUsers = "";
public $dRemovedUsers = "";
public $gAlready = 0;
public $gMoved = 0;
public $gImpossible = 0;
public $gCreated = 0;
public $gRemoved = 0;
public $gAlreadyUsers = "";
public $gMovedUsers = "";
public $gImpossibleUsers = "";
public $gCreatedUsers = "";
public $gRemovedUsers = "";
public $managersHierarchy = array();
public $oldManagersHierarchy = array();
public $managersToClear = array();
public $deletedManager = 0;
public function __construct()
{
}
/**
function executed by the cron
this function will synchronize users from ldap/active directory to PM users tables
@return void
*/
public function executeCron($debug)
{
$rbac = &RBAC::getSingleton();
if (is_null($rbac->authSourcesObj)) {
$rbac->authSourcesObj = new AuthenticationSource();
}
$plugin = new ldapAdvanced();
$plugin->sSystem = $rbac->sSystem;
$plugin->setFrontEnd(true);
$plugin->setDebug($debug);
//Get all authsource for this plugin ( ldapAdvanced plugin, because other authsources are not needed )
$arrayAuthenticationSource = $plugin->getAuthSources();
$aDepartments = $plugin->getDepartments("");
$aGroups = $plugin->getGroups();
//$arrayDepartmentUserAd = array(); //(D) Update Users
//$arrayGroupUserAd = array(); //(G) Update Users
//echo "\n";
$plugin->frontEndShow("START");
$plugin->debugLog("START");
foreach ($arrayAuthenticationSource as $value) {
$arrayAuthenticationSourceData = $value;
$plugin->debugLog("ldapadvanced.php > function executeCron() > foreach > \$arrayAuthenticationSourceData ---->\n" . print_r($arrayAuthenticationSourceData, true));
$plugin->sAuthSource = $arrayAuthenticationSourceData["AUTH_SOURCE_UID"];
$plugin->ldapcnn = null;
$plugin->setArrayDepartmentUserSynchronizedChecked(array());
$plugin->setArrayUserUpdateChecked(array());
//Get all User (USR_UID, USR_USERNAME, USR_AUTH_USER_DN) registered in RBAC with this Authentication Source
$plugin->setArrayAuthenticationSourceUsers($arrayAuthenticationSourceData["AUTH_SOURCE_UID"]); //INITIALIZE DATA
$plugin->frontEndShow("TEXT", "Authentication Source: " . $arrayAuthenticationSourceData["AUTH_SOURCE_NAME"]);
$plugin->log(null, "Executing cron for Authentication Source: " . $arrayAuthenticationSourceData["AUTH_SOURCE_NAME"]);
//Get all departments from Ldap/ActiveDirectory and build a hierarchy using dn (ou->ou parent)
$aLdapDepts = $plugin->searchDepartments();
//Obtain all departments from PM with a valid department in LDAP/ActiveDirectory
$aRegisteredDepts = $plugin->getRegisteredDepartments($aLdapDepts, $aDepartments);
$plugin->debugLog("ldapadvanced.php > function executeCron() > foreach > \$aRegisteredDepts ---->\n" . print_r($aRegisteredDepts, true));
//Get all group from Ldap/ActiveDirectory
$aLdapGroups = $plugin->searchGroups();
//Obtain all groups from PM with a valid group in LDAP/ActiveDirectory
$aRegisteredGroups = $plugin->getRegisteredGroups($aLdapGroups, $aGroups);
$plugin->debugLog("ldapadvanced.php > function executeCron() > foreach > \$aRegisteredGroups ---->\n" . print_r($aRegisteredGroups, true));
//Get all users from Removed OU
$this->usersRemovedOu = $plugin->getUsersFromRemovedOu($arrayAuthenticationSourceData);
$plugin->deactiveArrayOfUsers($this->usersRemovedOu);
//Variables
$this->deletedRemoved = count($this->usersRemovedOu);
$this->deletedRemovedUsers = "";
$this->dAlready = 0;
$this->dMoved = 0;
$this->dImpossible = 0;
$this->dCreated = 0;
$this->dRemoved = 0;
$this->dAlreadyUsers = "";
$this->dMovedUsers = "";
$this->dImpossibleUsers = "";
$this->dCreatedUsers = "";
$this->dRemovedUsers = "";
$this->gAlready = 0;
$this->gMoved = 0;
$this->gImpossible = 0;
$this->gCreated = 0;
$this->gRemoved = 0;
$this->gAlreadyUsers = "";
$this->gMovedUsers = "";
$this->gImpossibleUsers = "";
$this->gCreatedUsers = "";
$this->gRemovedUsers = "";
//Department - Synchronize Users
$numDepartments = count($aRegisteredDepts);
$count = 0;
$plugin->debugLog("ldapadvanced.php > function executeCron() > foreach > \$numDepartments ----> $numDepartments");
foreach ($aRegisteredDepts as $registeredDept) {
$count++;
//(D) Update Users
//if (!isset($arrayDepartmentUserAd[$registeredDept["DEP_UID"]])) {
// $arrayDepartmentUserAd[$registeredDept["DEP_UID"]] = array(); //Current users in department based in Active Directory
//}
//
//$arrayAux = $this->departmentSynchronizeUsers($plugin, $numDepartments, $count, $registeredDept);
//$arrayAux = array_merge($arrayDepartmentUserAd[$registeredDept["DEP_UID"]], $arrayAux);
//
//$arrayDepartmentUserAd[$registeredDept["DEP_UID"]] = array_unique($arrayAux);
$arrayAux = $this->departmentSynchronizeUsers($plugin, $numDepartments, $count, $registeredDept);
}
//Department - Print log
$logResults = sprintf(
"- Departments -> Existing users: %d, moved: %d, impossible: %d, created: %d, removed: %d",
$this->dAlready,
$this->dMoved,
$this->dImpossible,
$this->dCreated,
$this->dRemoved
);
$plugin->frontEndShow("TEXT", $logResults);
$plugin->log(null, $logResults);
//Group - Synchronize Users
$numGroups = count($aRegisteredGroups);
$count = 0;
$plugin->debugLog("ldapadvanced.php > function executeCron() > foreach > \$numGroups ----> $numGroups");
foreach ($aRegisteredGroups as $registeredGroup) {
$count++;
//(G) Update Users
//if (!isset($arrayGroupUserAd[$registeredGroup["GRP_UID"]])) {
// $arrayGroupUserAd[$registeredGroup["GRP_UID"]] = array(); //Current users in group based in Active Directory
//}
//
//$arrayAux = $this->groupSynchronizeUsers($plugin, $numGroups, $count, $registeredGroup);
//$arrayAux = array_merge($arrayGroupUserAd[$registeredGroup["GRP_UID"]], $arrayAux);
//
//$arrayGroupUserAd[$registeredGroup["GRP_UID"]] = array_unique($arrayAux);
$arrayAux = $this->groupSynchronizeUsers($plugin, $numGroups, $count, $registeredGroup);
}
//Group - Print log
$logResults = sprintf(
"- Groups -> Existing users: %d, moved: %d, impossible: %d, created: %d, removed: %d",
$this->gAlready,
$this->gMoved,
$this->gImpossible,
$this->gCreated,
$this->gRemoved
);
$plugin->frontEndShow("TEXT", $logResults);
$plugin->log(null, $logResults);
//Manager
$plugin->clearManager($this->managersToClear);
if (isset($arrayAuthenticationSourceData["AUTH_SOURCE_DATA"]["DEPARTMENTS_TO_UNASSIGN"])) {
if (is_array($arrayAuthenticationSourceData["AUTH_SOURCE_DATA"]["DEPARTMENTS_TO_UNASSIGN"])) {
foreach ($arrayAuthenticationSourceData["AUTH_SOURCE_DATA"]["DEPARTMENTS_TO_UNASSIGN"] as $departmentUID) {
// Delete manager assignments
$criteriaSet = new Criteria("workflow");
$criteriaSet->add(UsersPeer::USR_REPORTS_TO, "");
$criteriaWhere = new Criteria("workflow");
$criteriaWhere->add(UsersPeer::DEP_UID, $departmentUID);
$criteriaWhere->add(UsersPeer::USR_REPORTS_TO, "", Criteria::NOT_EQUAL);
$this->deletedManager = BasePeer::doUpdate($criteriaWhere, $criteriaSet, Propel::getConnection("workflow"));
// Delete department assignments
$criteriaSet = new Criteria("workflow");
$criteriaSet->add(UsersPeer::DEP_UID, "");
$criteriaWhere = new Criteria("workflow");
$criteriaWhere->add(UsersPeer::DEP_UID, $departmentUID);
$this->dMoved += UsersPeer::doCount($criteriaWhere);
BasePeer::doUpdate($criteriaWhere, $criteriaSet, Propel::getConnection("workflow"));
}
}
unset($arrayAuthenticationSourceData["AUTH_SOURCE_DATA"]["DEPARTMENTS_TO_UNASSIGN"]);
$rbac = &RBAC::getSingleton();
$rbac->authSourcesObj->update($arrayAuthenticationSourceData);
}
if (isset($arrayAuthenticationSourceData["AUTH_SOURCE_DATA"]["GROUPS_TO_UNASSIGN"])) {
if (is_array($arrayAuthenticationSourceData["AUTH_SOURCE_DATA"]["GROUPS_TO_UNASSIGN"])) {
foreach ($arrayAuthenticationSourceData["AUTH_SOURCE_DATA"]["GROUPS_TO_UNASSIGN"] as $groupUID) {
// Delete manager assignments
$groupsInstance = new Groups();
$criteria = $groupsInstance->getUsersGroupCriteria($groupUID);
$dataset = UsersPeer::doSelectRS($criteria);
$dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$dataset->next();
$users = array();
while ($row = $dataset->getRow()) {
$users[] = $row["USR_UID"];
$dataset->next();
}
$criteriaSet = new Criteria("workflow");
$criteriaSet->add(UsersPeer::USR_REPORTS_TO, "");
$criteriaWhere = new Criteria("workflow");
$criteriaWhere->add(UsersPeer::USR_UID, $users, Criteria::IN);
$criteriaWhere->add(UsersPeer::USR_REPORTS_TO, "", Criteria::NOT_EQUAL);
$this->deletedManager = BasePeer::doUpdate($criteriaWhere, $criteriaSet, Propel::getConnection("workflow"));
// Delete group assignments
$criteria = new Criteria("workflow");
$criteria->add(GroupUserPeer::GRP_UID, $groupUID);
$this->gMoved += GroupUserPeer::doCount($criteria);
BasePeer::doDelete($criteria, Propel::getConnection("workflow"));
}
}
unset($arrayAuthenticationSourceData["AUTH_SOURCE_DATA"]["GROUPS_TO_UNASSIGN"]);
$rbac = &RBAC::getSingleton();
$rbac->authSourcesObj->update($arrayAuthenticationSourceData);
}
// Delete the managers that not exists in PM
$criteria = new Criteria("rbac");
$criteria->addSelectColumn(RbacUsersPeer::USR_AUTH_USER_DN);
$criteria->add(RbacUsersPeer::USR_AUTH_USER_DN, "", Criteria::NOT_EQUAL);
$dataset = RbacUsersPeer::doSelectRS($criteria);
$dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$dataset->next();
$existingUsers = array();
while ($row = $dataset->getRow()) {
$existingUsers[] = $row["USR_AUTH_USER_DN"];
$dataset->next();
}
foreach ($this->managersHierarchy as $managerDN => $subordinates) {
if (!in_array($managerDN, $existingUsers)) {
unset($this->managersHierarchy[$managerDN]);
}
}
// Get the managers assigments counters
$plugin->synchronizeManagers($this->managersHierarchy);
$deletedManagersAssignments = self::array_diff_assoc_recursive($this->oldManagersHierarchy, $this->managersHierarchy);
$newManagersAssignments = self::array_diff_assoc_recursive($this->managersHierarchy, $this->oldManagersHierarchy);
$deletedManagers = array();
$newManagers = array();
$movedManagers = array();
if (is_array($deletedManagersAssignments)) {
foreach ($deletedManagersAssignments as $dn1 => $subordinates1) {
foreach ($subordinates1 as $subordinate) {
if (!in_array($subordinate, $deletedManagers)) {
$deletedManagers[] = $subordinate;
}
foreach ($newManagersAssignments as $dn2 => $subordinates2) {
if (isset($subordinates2[$subordinate])) {
$movedManagers[] = $subordinate;
}
}
}
}
}
if (is_array($newManagersAssignments)) {
foreach ($newManagersAssignments as $dn1 => $subordinates1) {
foreach ($subordinates1 as $subordinate) {
if (!in_array($subordinate, $newManagers)) {
$newManagers[] = $subordinate;
}
foreach ($deletedManagersAssignments as $dn2 => $subordinates2) {
if (isset($subordinates2[$subordinate])) {
if (!in_array($subordinate, $movedManagers)) {
$movedManagers[] = $subordinate;
}
}
}
}
}
}
//Print and log the users's information
//Deleted/Removed Users
$logResults = sprintf("- Deleted/Removed Users: %d", $this->deletedRemoved);
$plugin->frontEndShow("TEXT", $logResults);
$plugin->log(null, $logResults);
if ($this->deletedRemoved > 0) {
$plugin->log(null, "Deleted/Removed Users: ");
$plugin->log(null, $this->deletedRemovedUsers);
}
if ($this->dAlready + $this->gAlready > 0) {
$plugin->log(null, "Existing Users: ");
$plugin->log(null, $this->dAlreadyUsers . " " . $this->gAlreadyUsers);
}
if ($this->dMoved + $this->gMoved > 0) {
$plugin->log(null, "Moved Users: ");
$plugin->log(null, $this->dMovedUsers . " " . $this->gMovedUsers);
}
if ($this->dImpossible + $this->gImpossible > 0) {
$plugin->log(null, "Impossible Users: ");
$plugin->log(null, $this->dImpossibleUsers . " " . $this->gImpossibleUsers);
}
if ($this->dCreated + $this->gCreated > 0) {
$plugin->log(null, "Created Users: ");
$plugin->log(null, $this->dCreatedUsers . " " . $this->gCreatedUsers);
}
if ($this->dRemoved + $this->gRemoved > 0) {
$plugin->log(null, "Removed Users: ");
$plugin->log(null, $this->dRemovedUsers . " " . $this->gRemovedUsers);
}
//Print and log the managers assignments"s information
$logResults = sprintf(
"- Managers assignments: created %d, moved %d, removed %d",
count($newManagers) - count($movedManagers),
count($movedManagers),
count($deletedManagers) - count($movedManagers) + $this->deletedManager
);
$plugin->frontEndShow("TEXT", $logResults);
$plugin->log(null, $logResults);
//Update Users data based on the LDAP Server
$plugin->usersUpdateData($arrayAuthenticationSourceData["AUTH_SOURCE_UID"]);
}
$plugin->frontEndShow("END");
//(D) Update Users
////Department //Upgrade users in departments
//foreach ($arrayDepartmentUserAd as $departmentUid => $arrayUserAd) {
// $plugin->setArrayDepartmentUsers($departmentUid); //INITIALIZE DATA
//
// $arrayAux = array_diff(array_keys($plugin->arrayDepartmentUsersByUid), $arrayUserAd);
//
// $this->departmentRemoveUsers($departmentUid, $arrayAux);
//}
//(G) Update Users
////Group //Upgrade users in groups
//foreach ($arrayGroupUserAd as $groupUid => $arrayUserAd) {
// $plugin->setArrayGroupUsers($groupUid); //INITIALIZE DATA
//
// $arrayAux = array_diff(array_keys($plugin->arrayGroupUsersByUid), $arrayUserAd);
//
// $this->groupRemoveUsers($groupUid, $arrayAux);
//}
//// Developed by Gary and Ronald
//$usersInfo = $plugin->ASUpdateInfo('');
//if (isset($usersInfo) && $usersInfo > 0) {
// $this->dMoved = $usersInfo;
//}
//// End Developed by Gary and Ronald
$plugin->debugLog("END");
}
public function array_diff_assoc_recursive($array1, $array2)
{
foreach ($array1 as $key => $value) {
if (is_array($value)) {
if (!isset($array2[$key])) {
$difference[$key] = $value;
} else {
if (!is_array($array2[$key])) {
$difference[$key] = $value;
} else {
$new_diff = self::array_diff_assoc_recursive($value, $array2[$key]);
if ($new_diff != false) {
$difference[$key] = $new_diff;
}
}
}
} else {
if (!isset($array2[$key]) || $array2[$key] != $value) {
$difference[$key] = $value;
}
}
}
return (!isset($difference))? array() : $difference;
}
public function departmentRemoveUsers($departmentUid, array $arrayUserUid)
{
try {
$department = new Department();
$department->Load($departmentUid);
$departmentManagerUid = $department->getDepManager();
foreach ($arrayUserUid as $value) {
$userUid = $value;
$department->removeUserFromDepartment($departmentUid, $userUid);
if ($userUid == $departmentManagerUid) {
$department->update(array("DEP_UID" => $departmentUid, "DEP_MANAGER" => ""));
$department->updateDepartmentManager($departmentUid);
}
}
} catch (Exception $e) {
throw $e;
}
}
public function groupRemoveUsers($groupUid, array $arrayUserUid)
{
try {
$group = new Groups();
foreach ($arrayUserUid as $value) {
$userUid = $value;
$group->removeUserOfGroup($groupUid, $userUid);
}
} catch (Exception $e) {
throw $e;
}
}
public function departmentSynchronizeUsers($ldapAdvanced, $numDepartments, $count, array $arrayDepartmentData)
{
try {
$ldapAdvanced->debugLog("ldapadvanced.php > function departmentSynchronizeUsers() > START");
$ldapAdvanced->debugLog("ldapadvanced.php > function departmentSynchronizeUsers() > \$arrayDepartmentData ---->\n" . print_r($arrayDepartmentData, true));
//Get users from ProcessMaker tables (for this Department)
$ldapAdvanced->setArrayDepartmentUsers($arrayDepartmentData["DEP_UID"]); //INITIALIZE DATA
//Clear the manager assignments
$arrayUserUid = array();
foreach ($ldapAdvanced->arrayDepartmentUsersByUid as $key => $user) {
$arrayUserUid[] = $user["USR_UID"];
if (isset($user["USR_REPORTS_TO"]) && $user["USR_REPORTS_TO"] != "") {
$dn = (isset($ldapAdvanced->arrayAuthenticationSourceUsersByUid[$user["USR_REPORTS_TO"]]["USR_AUTH_USER_DN"]))? $ldapAdvanced->arrayAuthenticationSourceUsersByUid[$user["USR_REPORTS_TO"]]["USR_AUTH_USER_DN"] : "";
if ($dn != "") {
if (!isset($this->oldManagersHierarchy[$dn])) {
$this->oldManagersHierarchy[$dn] = array();
}
$this->oldManagersHierarchy[$dn][$user["USR_UID"]] = $user["USR_UID"];
}
}
}
$this->managersToClear = $arrayUserUid;
//Synchronize Users from Department
//Now we need to go over ldapusers and check if the user exists in ldap but not in PM, then we need to create it
$arrayData = array(
"already" => $this->dAlready,
"moved" => $this->dMoved,
"impossible" => $this->dImpossible,
"created" => $this->dCreated,
"alreadyUsers" => $this->dAlreadyUsers,
"movedUsers" => $this->dMovedUsers,
"impossibleUsers" => $this->dImpossibleUsers,
"createdUsers" => $this->dCreatedUsers,
"managersHierarchy" => $this->managersHierarchy,
"arrayUserUid" => array(),
"n" => $numDepartments,
"i" => $count
);
//Get Users from LDAP (for this Department)
$arrayData = $ldapAdvanced->ldapGetUsersFromDepartment("SYNCHRONIZE", $arrayDepartmentData["DEP_LDAP_DN"], $arrayData);
$this->dAlready = $arrayData["already"];
$this->dMoved = $arrayData["moved"];
$this->dImpossible = $arrayData["impossible"];
$this->dCreated = $arrayData["created"];
$this->dAlreadyUsers = $arrayData["alreadyUsers"];
$this->dMovedUsers = $arrayData["movedUsers"];
$this->dImpossibleUsers = $arrayData["impossibleUsers"];
$this->dCreatedUsers = $arrayData["createdUsers"];
$this->managersHierarchy = $arrayData["managersHierarchy"];
$arrayUserUid = $arrayData["arrayUserUid"];
//(D) Update Users
$arrayAux = array_diff(array_keys($ldapAdvanced->arrayDepartmentUsersByUid), $arrayUserUid);
$this->departmentRemoveUsers($arrayDepartmentData["DEP_UID"], $arrayAux);
$this->dRemoved += count($arrayAux);
$this->dRemovedUsers = "";
$ldapAdvanced->debugLog("ldapadvanced.php > function departmentSynchronizeUsers() > END");
//Return all UID of Users synchronized in the Department (Return all UID of Users of this Department)
return $arrayUserUid;
} catch (Exception $e) {
throw $e;
}
}
public function groupSynchronizeUsers($ldapAdvanced, $numGroups, $count, array $arrayGroupData)
{
try {
$ldapAdvanced->debugLog("ldapadvanced.php > function groupSynchronizeUsers() > START");
$ldapAdvanced->debugLog("ldapadvanced.php > function groupSynchronizeUsers() > \$arrayGroupData ---->\n" . print_r($arrayGroupData, true));
//Get users from ProcessMaker tables (for this Group)
$ldapAdvanced->setArrayGroupUsers($arrayGroupData["GRP_UID"]); //INITIALIZE DATA
//Clear the manager assignments
$arrayUserUid = array();
foreach ($ldapAdvanced->arrayGroupUsersByUid as $key => $user) {
$arrayUserUid[] = $user["USR_UID"];
if (isset($user["USR_REPORTS_TO"]) && $user["USR_REPORTS_TO"] != "") {
$dn = (isset($ldapAdvanced->arrayAuthenticationSourceUsersByUid[$user["USR_REPORTS_TO"]]["USR_AUTH_USER_DN"]))? $ldapAdvanced->arrayAuthenticationSourceUsersByUid[$user["USR_REPORTS_TO"]]["USR_AUTH_USER_DN"] : "";
if ($dn != "") {
if (!isset($this->oldManagersHierarchy[$dn])) {
$this->oldManagersHierarchy[$dn] = array();
}
$this->oldManagersHierarchy[$dn][$user["USR_UID"]] = $user["USR_UID"];
}
}
}
$this->managersToClear = array_merge($this->managersToClear, $arrayUserUid);
//Synchronize Users from Group
//Now we need to go over ldapusers and check if the user exists in ldap but not in PM, then we need to create it
$arrayData = array(
"already" => $this->gAlready,
"moved" => $this->gMoved,
"impossible" => $this->gImpossible,
"created" => $this->gCreated,
"alreadyUsers" => $this->gAlreadyUsers,
"movedUsers" => $this->gMovedUsers,
"impossibleUsers" => $this->gImpossibleUsers,
"createdUsers" => $this->gCreatedUsers,
"managersHierarchy" => $this->managersHierarchy,
"arrayUserUid" => array(),
"n" => $numGroups,
"i" => $count
);
//Get Users from LDAP (for this Group)
$arrayData = $ldapAdvanced->ldapGetUsersFromGroup("SYNCHRONIZE", $arrayGroupData, $arrayData);
$this->gAlready = $arrayData["already"];
$this->gMoved = $arrayData["moved"];
$this->gImpossible = $arrayData["impossible"];
$this->gCreated = $arrayData["created"];
$this->gAlreadyUsers = $arrayData["alreadyUsers"];
$this->gMovedUsers = $arrayData["movedUsers"];
$this->gImpossibleUsers = $arrayData["impossibleUsers"];
$this->gCreatedUsers = $arrayData["createdUsers"];
$this->managersHierarchy = $arrayData["managersHierarchy"];
$arrayUserUid = $arrayData["arrayUserUid"];
//(G) Update Users
$arrayAux = array_diff(array_keys($ldapAdvanced->arrayGroupUsersByUid), $arrayUserUid);
$this->groupRemoveUsers($arrayGroupData["GRP_UID"], $arrayAux);
$this->gRemoved += count($arrayAux);
$this->gRemovedUsers = "";
$ldapAdvanced->debugLog("ldapadvanced.php > function groupSynchronizeUsers() > END");
//Return all UID of Users synchronized in the Group (Return all UID of Users of this Group)
return $arrayUserUid;
} catch (Exception $e) {
throw $e;
}
}
}

View File

@@ -0,0 +1,237 @@
var ldapFormAnonymousOnChange = function (combo, arrayObject)
{
var flagAnonymous = (combo.getValue() == "1")? true : false;
arrayObject["ldapFormSearchUser"].allowBlank = flagAnonymous;
arrayObject["ldapFormPassword"].allowBlank = flagAnonymous;
arrayObject["ldapFormSearchUser"].setVisible(!flagAnonymous);
arrayObject["ldapFormPassword"].setVisible(!flagAnonymous);
};
var ldapFormId = new Ext.form.Hidden({
name: 'AUTH_SOURCE_UID',
id: 'AUTH_SOURCE_UID'
});
var ldapFormName = new Ext.form.TextField({
fieldLabel: '<span style="color: red">*</span>' + _('ID_NAME'),
name: 'AUTH_SOURCE_NAME',
id: 'AUTH_SOURCE_NAME',
autoCreate: {tag: 'input', type: 'text', maxlength: '50'},
allowBlank: false,
width: 210
});
var ldapFormProvider = new Ext.form.Hidden({
name: 'AUTH_SOURCE_PROVIDER',
id: 'AUTH_SOURCE_PROVIDER'
});
var ldapFormType = new Ext.form.ComboBox({
valueField: 'ID',
displayField: 'VALUE',
value: 'ldap',
fieldLabel: '<span style="color: red">*</span>' + _('ID_TYPE'),
typeAhead: true,
forceSelection: true,
triggerAction: 'all',
editable: true,
name: 'LDAP_TYPE',
id: 'LDAP_TYPE',
width: 130,
allowBlank: false,
store: [["ldap", "OpenLDAP"], ["ad", "Active Directory"], ["ds", "389 DS"]],
listeners:{
select: function(combo, record) {
ldapFormIdentifier.setValue((combo.getValue() == "ad")? "samaccountname" : "uid");
}
}
});
var ldapFormAutoRegister = new Ext.form.ComboBox({
valueField: 'ID',
displayField: 'VALUE',
value: '0',
fieldLabel: '<span style="color: red">*</span>' + "Enable automatic register",
typeAhead: true,
forceSelection: true,
triggerAction: 'all',
editable: true,
name: 'AUTH_SOURCE_AUTO_REGISTER',
id: 'AUTH_SOURCE_AUTO_REGISTER',
width: 130,
allowBlank: false,
store: [['0',_('ID_NO')],['1',_('ID_YES')]]
});
var ldapFormServerName = new Ext.form.TextField({
fieldLabel: '<span style="color: red">*</span>' + "Server Address",
name: 'AUTH_SOURCE_SERVER_NAME',
id: 'AUTH_SOURCE_SERVER_NAME',
autoCreate: {tag: 'input', type: 'text', maxlength: '50'},
allowBlank: false,
width: 210
});
var ldapFormPort = new Ext.form.NumberField({
fieldLabel: '<span style="color: red">*</span>' + _('ID_PORT'),
name: 'AUTH_SOURCE_PORT',
id: 'AUTH_SOURCE_PORT',
allowBlank: true,
width: 130,
value: '389',
autoCreate: {tag: 'input', type: 'text', maxlength: '5'}
});
var ldapFormTls = new Ext.form.ComboBox({
valueField: 'ID',
displayField: 'VALUE',
fieldLabel: '<span style="color: red">*</span>' + _('ID_ENABLED_TLS'),
typeAhead: true,
forceSelection: true,
triggerAction: 'all',
editable: true,
name: 'AUTH_SOURCE_ENABLED_TLS',
id: 'AUTH_SOURCE_ENABLED_TLS',
width: 130,
allowBlank: false,
value: '0',
store: [['0',_('ID_NO')],['1',_('ID_YES')]]
});
var ldapFormBaseDN = new Ext.form.TextField({
fieldLabel: '<span style="color: red">*</span>' + _('ID_BASE_DN'),
name: 'AUTH_SOURCE_BASE_DN',
id: 'AUTH_SOURCE_BASE_DN',
autoCreate: {tag: 'input', type: 'text', maxlength: '128'},
allowBlank: false,
width: 210
});
var ldapFormAnonymous = new Ext.form.ComboBox({
valueField: 'ID',
displayField: 'VALUE',
fieldLabel: '<span style="color: red">*</span>' + _('ID_ANONYMOUS'),
typeAhead: true,
forceSelection: true,
triggerAction: 'all',
editable: true,
name: 'AUTH_ANONYMOUS',
id: 'AUTH_ANONYMOUS',
width: 130,
allowBlank: false,
value: '0',
store: [['0',_('ID_NO')],['1',_('ID_YES')]],
listeners:{
select: function(combo, record) {
var arrayObject = [];
arrayObject["ldapFormSearchUser"] = ldapFormSearchUser;
arrayObject["ldapFormPassword"] = ldapFormPassword;
ldapFormAnonymousOnChange(combo, arrayObject);
}
}
});
var ldapFormSearchUser = new Ext.form.TextField({
fieldLabel: '<span style="color: red">*</span>' + _('ID_USERNAME'),
name: 'AUTH_SOURCE_SEARCH_USER',
id: 'AUTH_SOURCE_SEARCH_USER',
autoCreate: {tag: 'input', type: 'text', maxlength: '128'},
allowBlank: false,
width: 210
});
var ldapFormPassword = new Ext.form.TextField({
fieldLabel: '<span style="color: red">*</span>' + _('ID_PASSWORD'),
inputType: 'password',
name: 'AUTH_SOURCE_PASSWORD',
id: 'AUTH_SOURCE_PASSWORD',
autoCreate: {tag: 'input', type: 'text', maxlength: '32'},
allowBlank: false,
width: 210
});
var ldapFormIdentifier = new Ext.form.TextField({
fieldLabel: '<span style="color: red">*</span>' + "User Identifier",
name: 'AUTH_SOURCE_IDENTIFIER_FOR_USER',
id: 'AUTH_SOURCE_IDENTIFIER_FOR_USER',
autoCreate: {tag: 'input', type: 'text', maxlength: '20'},
allowBlank: false,
width: 210,
value: 'uid'
});
var ldapFormUsersFilter = new Ext.form.TextField({
fieldLabel: "Filter to search users",
name: 'AUTH_SOURCE_USERS_FILTER',
id: 'AUTH_SOURCE_USERS_FILTER',
autoCreate: {tag: 'input', type: 'text', maxlength: '200'},
allowBlank: true,
width: 210
});
var ldapFormRetiredEmployees = new Ext.form.TextField({
fieldLabel: "OU for Retired Employees OU",
name: 'AUTH_SOURCE_RETIRED_OU',
id: 'AUTH_SOURCE_RETIRED_OU',
autoCreate: {tag: 'input', type: 'text', maxlength: '128'},
allowBlank: true,
width: 210
});
var ldapFormAttrinuteIds = new Ext.form.Hidden({
name: 'AUTH_SOURCE_ATTRIBUTE_IDS',
id: 'AUTH_SOURCE_ATTRIBUTE_IDS'
});
var ldapFormShowGrid = new Ext.form.Hidden({
name: 'AUTH_SOURCE_SHOWGRID',
id: 'AUTH_SOURCE_SHOWGRID'
});
var ldapFormGridText = new Ext.form.Hidden({
name: 'AUTH_SOURCE_GRID_TEXT',
id: 'AUTH_SOURCE_GRID_TEXT'
});
///////////////////////////////////////////////////////////////////////////////////////
var ldapFormData = new Ext.form.FieldSet({
style: {
border: "0px"
},
labelWidth : 170,
items :[
ldapFormId, ldapFormName, ldapFormProvider, ldapFormType, ldapFormAutoRegister, ldapFormServerName,
ldapFormPort, ldapFormTls, ldapFormBaseDN, ldapFormAnonymous, ldapFormSearchUser, ldapFormPassword,
ldapFormIdentifier, ldapFormUsersFilter, ldapFormRetiredEmployees,
{
xtype: 'label',
fieldLabel: ' ',
id:'passwordReview',
width: 300,
style: 'font: 9px tahoma,arial,helvetica,sans-serif;',
text: "(Default set to (&(!(objectClass=organizationalUnit))))",
labelSeparator: ''
}, ldapFormAttrinuteIds, ldapFormShowGrid, ldapFormGridText
]
});
var pnlData = new Ext.Panel({
height: 425,
bodyStyle: "border-top: 0px; padding-top: 10px;",
title: "<div style=\"height: 20px;\">" + _("ID_INFORMATION") + "</div>",
items: [ldapFormData]
});

View File

@@ -0,0 +1,486 @@
Ext.onReady(function() {
//Head - Add style
var nhead = document.getElementsByTagName("head")[0];
var nstyle = document.createElement("style");
var strCss = "\
.ext-mb-ok {\
background: transparent url(/images/dialog-ok-apply.png) no-repeat top left;\
}";
nstyle.setAttribute("type", "text/css");
nhead.appendChild(nstyle);
if (nstyle.styleSheet) {
//IE
nstyle.styleSheet.cssText = strCss;
} else {
//Others browsers
nstyle.appendChild(document.createTextNode(strCss));
}
//Init
Ext.QuickTips.init();
Ext.form.Field.prototype.msgTarget = 'side';
var ldapGridProxy = new Ext.data.HttpProxy({
method: 'POST',
api: {
read : '../controllers/ldapAdvancedProxy.php?functionAccion=ldapGrid&tipo=read',
create : '../controllers/ldapAdvancedProxy.php?functionAccion=ldapGrid&tipo=create',
save : '../controllers/ldapAdvancedProxy.php?functionAccion=ldapGrid&tipo=save',
destroy : '../controllers/ldapAdvancedProxy.php?functionAccion=ldapGrid&tipo=destroy',
update : '../controllers/ldapAdvancedProxy.php?functionAccion=ldapGrid&tipo=update'
}
});
var ldapGridReader = new Ext.data.JsonReader({
totalProperty: 'total',
successProperty: 'success',
messageProperty: 'message',
idProperty: 'ID',
root: 'data',
fields: [
{name: 'ID'},
{name: 'ATTRIBUTE_LDAP'},
{name: 'ATTRIBUTE_USER'}
]
});
var ldapGridWriter = new Ext.data.JsonWriter({
encode: true,
writeAllFields: true,
listful: true
});
var ldapGridStore = new Ext.data.Store({
proxy: ldapGridProxy,
reader: ldapGridReader,
writer: ldapGridWriter,
autoSave: true,
listeners:{
load: function() {
//
}
}
});
Ext.data.DataProxy.addListener('beforewrite', function(proxy, action) {
/*
if(action != 'create')
{
Ext.MessageBox.show({
msg: 'Guardando su información, espere un momento por favor',
progressText: 'Saving...',
width:300,
wait:true,
waitConfig: {interval:200},
animEl: 'mb7'
});
}
*/
});
Ext.data.DataProxy.addListener('write', function(proxy, action, result, res, rs) {
//
});
Ext.data.DataProxy.addListener('exception', function(proxy, type, action, options, res) {
/*
Ext.MessageBox.show({
title: 'Error de almacenamiento',
msg: 'Error al almacenar datos',
buttons: Ext.MessageBox.OK,
animEl: 'mb9',
icon: Ext.MessageBox.ERROR
});
*/
});
var ldapGridFieldLdap = new Ext.form.TextField({
name: 'DELETE1',
id: 'DELETE1',
autoCreate: {tag: 'input', type: 'text', maxlength: '50'}
});
var values = Fields.AUTH_SOURCE_ATTRIBUTE_IDS;
values = values.trim();
var allValues = new Array();
var comboValues = new Array();
allValues = values.split('|');
for (var i = 0; i < allValues.length; i++) {
if (allValues[i] != '') {
comboValues.push([allValues[i],allValues[i]]);
}
}
var ldapGridFieldUser = new Ext.form.ComboBox({
valueField: 'ID',
displayField: 'VALUE',
value: '0',
typeAhead: true,
forceSelection: true,
triggerAction: 'all',
name: 'DELETE2',
id: 'DELETE2',
editable: true,
width: 130,
store: comboValues
});
var ldapGridCol = [
{
id: 'ID',
dataIndex: 'ID',
sortable: true,
hidden: true,
hideable:false
},{
id: 'ATTRIBUTE_LDAP',
header: "LDAP Field",
dataIndex: 'ATTRIBUTE_LDAP',
width: 10,
sortable: true,
editor: ldapGridFieldLdap
},
{
id: 'ATTRIBUTE_USER',
header: "User Field",
dataIndex: 'ATTRIBUTE_USER',
width: 10,
sortable: true,
editor: ldapGridFieldUser
}
];
var ldapGridEditor = new Ext.ux.grid.RowEditor({
saveText: _('ID_SAVE'),
listeners: {
canceledit: function(grid,obj){
//
},
afteredit: function(grid,obj,record){
//
}
}
});
var ldapGrid = new Ext.grid.GridPanel({
store: ldapGridStore,
loadMask : true,
plugins: [ldapGridEditor],
frame: true,
height: 365,
columns : ldapGridCol,
autoShow: true,
autoFill:true,
nocache: true,
autoWidth: true,
stripeRows: true,
stateful: true,
animCollapse: true,
enableColumnResize: true,
enableHdMenu: true,
columnLines: true,
tbar: [{
text: _('ID_ADD'),
iconCls: ' x-btn-text button_menu_ext ss_sprite ss_add',
handler: onAdd
}, '-', {
text: _('ID_REMOVE'),
iconCls: ' x-btn-text button_menu_ext ss_sprite ss_delete',
handler: onDelete
}],
viewConfig: {
forceFit: true
}
});
function onAdd(btn, ev) {
var row = new ldapGrid.store.recordType({
ID: 'NUEVO',
ATTRIBUTE_LDAP: '',
ATTRIBUTE_USER: ''
});
var length = ldapGrid.getStore().data.length;
ldapGridEditor.stopEditing();
ldapGridStore.insert(length, row);
ldapGrid.getView().refresh();
ldapGrid.getSelectionModel().selectRow(length);
ldapGridEditor.startEditing(length);
}
function onDelete() {
var rec = ldapGrid.getSelectionModel().getSelected();
if (!rec) {
return false;
}
ldapGrid.store.remove(rec);
}
///////////////////////////////////////////////////////////////////////////////////////
var pnlAttribute = new Ext.Panel({
height: 425,
bodyStyle: "border-top: 0px; padding: 10px;",
title: "<div id=\"containerChkAttribute\" style=\"height: 20px;\"></div>",
items: [ldapGrid],
listeners: {
afterrender: function (panel)
{
var chk = new Ext.form.Checkbox({
id: "AUTH_SOURCE_SHOWGRID-checkbox",
name: "AUTH_SOURCE_SHOWGRID-checkbox",
boxLabel: "Match attributes to sync",
renderTo: "containerChkAttribute",
listeners: {
check: function (chk, checked)
{
ldapGrid.setVisible(checked);
}
}
});
}
}
});
///////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////
var ldapFormSubmit = function ()
{
var itemsLdapGrid = ldapGrid.store.data.items;
var arrayDetail = [];
for (var i = 0; i <= itemsLdapGrid.length - 1; i++) {
var newItem = {
attributeLdap: itemsLdapGrid[i].data.ATTRIBUTE_LDAP,
attributeUser: itemsLdapGrid[i].data.ATTRIBUTE_USER
};
arrayDetail[i] = newItem;
}
Ext.get("LDAP_TYPE").dom.value = ldapFormType.getValue();
Ext.get("AUTH_SOURCE_AUTO_REGISTER").dom.value = ldapFormAutoRegister.getValue();
Ext.get("AUTH_SOURCE_ENABLED_TLS").dom.value = ldapFormTls.getValue();
Ext.get("AUTH_ANONYMOUS").dom.value = ldapFormAnonymous.getValue();
Ext.get("AUTH_SOURCE_GRID_TEXT").dom.value = Ext.util.JSON.encode(arrayDetail);
ldapForm.getForm().submit({
method: "POST",
waitTitle: "Connecting...",
waitMsg: _("ID_SAVING"),
success: function (form, action)
{
redirectPage("../authSources/authSources_List?" + randomNum(1, 9999999));
},
failure: function (form, action)
{
//
}
});
};
var ldapForm = new Ext.FormPanel({
url : '../controllers/ldapAdvancedProxy.php?functionAccion=ldapSave',
frame : true,
title : "Authentication Source Information",
border : false,
autoScroll: true,
monitorValid : true,
items:[
{
layout:'column',
autoScroll:true,
bodyStyle: "border: 0px;",
items:[{
columnWidth: 0.5,
bodyStyle: "border: 0px;",
items: [pnlData]
},{
columnWidth: 0.5,
bodyStyle: "border: 0px; padding-left: 10px;",
items: [pnlAttribute]
}]
},
{
layout: "column",
autoScroll: true,
bodyStyle: "margin-top: 0.5em; border: 0px;",
items: [
{
columnWidth: 1,
bodyStyle: "border: 0px;",
html: "Minimum data required to run the \"Test Connection\": \"Server Address, " + _("ID_PORT") + ", " + _("ID_ENABLED_TLS") + ", " + _("ID_ANONYMOUS") + ", " + _("ID_USERNAME") + ", " + _("ID_PASSWORD") + "\""
}
]
}
],
buttons: [
{
text: _("ID_SAVE"),
formBind: true,
handler: function ()
{
if (typeof(Fields.AUTH_SOURCE_UID) != "undefined" && typeof(Fields.AUTH_SOURCE_BASE_DN) != "undefined" && ldapFormBaseDN.getValue() != Fields.AUTH_SOURCE_BASE_DN) {
Ext.Ajax.request({
url: "../controllers/ldapAdvancedProxy.php",
method: "POST",
params: {
functionAccion: "ldapVerifyIfExistsRecordsInDb",
authenticationSourceUid: Fields.AUTH_SOURCE_UID
},
success: function (response, opts)
{
var dataResponse = Ext.util.JSON.decode(response.responseText);
if (dataResponse.status) {
if (dataResponse.status == "OK" && dataResponse.existsRecords + "" == "1") {
Ext.MessageBox.confirm(
_("ID_CONFIRM"),
"System has detected that there are synchronized elements with the \"Authentication Source \" you are editing, if you change the \"Base DN\" those synchronized elements could have problems. Are you sure you want to change the \"Base DN\"?",
function (btn)
{
if (btn == "yes") {
ldapFormSubmit();
}
}
);
} else {
ldapFormSubmit();
}
} else {
ldapFormSubmit();
}
},
failure: function (response, opts)
{
//
}
});
} else {
ldapFormSubmit();
}
}
},
{
text: "Test connection",
formBind: true,
handler: function ()
{
var loadMaskAux = new Ext.LoadMask(Ext.getBody(), {msg: "Testing connection..."});
loadMaskAux.show();
Ext.Ajax.request({
url: "../controllers/ldapAdvancedProxy.php",
method: "POST",
params: {
functionAccion: "ldapTestConnection",
AUTH_SOURCE_SERVER_NAME: Ext.getCmp("AUTH_SOURCE_SERVER_NAME").getValue(),
AUTH_SOURCE_PORT: Ext.getCmp("AUTH_SOURCE_PORT").getValue(),
AUTH_SOURCE_ENABLED_TLS: Ext.getCmp("AUTH_SOURCE_ENABLED_TLS").getValue(),
AUTH_ANONYMOUS: Ext.getCmp("AUTH_ANONYMOUS").getValue(),
AUTH_SOURCE_SEARCH_USER: Ext.getCmp("AUTH_SOURCE_SEARCH_USER").getValue(),
AUTH_SOURCE_PASSWORD: Ext.getCmp("AUTH_SOURCE_PASSWORD").getValue(),
AUTH_SOURCE_VERSION: 3
},
success: function (response, opts)
{
var dataResponse = Ext.util.JSON.decode(response.responseText);
if (dataResponse.status) {
Ext.MessageBox.show({
title: "Test connection",
msg: (dataResponse.status == "OK")? "Successfully connected" : dataResponse.message,
icon: (dataResponse.status == "OK")? "ext-mb-ok" : Ext.MessageBox.ERROR,
buttons: {ok: _("ID_ACCEPT")}
});
}
loadMaskAux.hide();
},
failure: function (response, opts)
{
loadMaskAux.hide();
}
});
}
},
{
text: _("ID_CANCEL"),
handler: function ()
{
redirectPage("../authSources/authSources_List?" + randomNum(1, 9999999));
}
}
]
});
var gridAttribute = '';
if (typeof(Fields.AUTH_SOURCE_UID) == 'undefined' || Fields.AUTH_SOURCE_UID == '') {
ldapFormProvider.setValue(Fields.AUTH_SOURCE_PROVIDER);
ldapFormAttrinuteIds.setValue(Fields.AUTH_SOURCE_ATTRIBUTE_IDS);
gridAttribute = '';
} else {
ldapFormId.setValue(Fields.AUTH_SOURCE_UID);
ldapFormName.setValue(Fields.AUTH_SOURCE_NAME);
ldapFormProvider.setValue(Fields.AUTH_SOURCE_PROVIDER);
ldapFormType.setValue(Fields.LDAP_TYPE);
ldapFormAutoRegister.setValue(Fields.AUTH_SOURCE_AUTO_REGISTER);
ldapFormServerName.setValue(Fields.AUTH_SOURCE_SERVER_NAME);
ldapFormPort.setValue(Fields.AUTH_SOURCE_PORT);
ldapFormTls.setValue(Fields.AUTH_SOURCE_ENABLED_TLS);
ldapFormBaseDN.setValue(Fields.AUTH_SOURCE_BASE_DN);
ldapFormAnonymous.setValue(Fields.AUTH_ANONYMOUS);
ldapFormSearchUser.setValue(Fields.AUTH_SOURCE_SEARCH_USER);
ldapFormPassword.setValue(Fields.AUTH_SOURCE_PASSWORD);
ldapFormIdentifier.setValue(Fields.AUTH_SOURCE_IDENTIFIER_FOR_USER);
ldapFormUsersFilter.setValue(Fields.AUTH_SOURCE_USERS_FILTER);
ldapFormRetiredEmployees.setValue(Fields.AUTH_SOURCE_RETIRED_OU);
if (typeof(Fields.AUTH_SOURCE_GRID_ATTRIBUTE) != 'undefined') {
gridAttribute = Ext.util.JSON.encode(Fields.AUTH_SOURCE_GRID_ATTRIBUTE);
}
}
ldapGridStore.load({
params:{'data': gridAttribute}
});
var arrayObject = [];
arrayObject["ldapFormSearchUser"] = ldapFormSearchUser;
arrayObject["ldapFormPassword"] = ldapFormPassword;
ldapFormAnonymousOnChange(ldapFormAnonymous, arrayObject);
new Ext.Viewport({
layout:'fit',
border: false,
items: [ldapForm]
});
ldapFormProvider.setValue(Fields.AUTH_SOURCE_PROVIDER);
ldapFormAttrinuteIds.setValue(Fields.AUTH_SOURCE_ATTRIBUTE_IDS);
Ext.getCmp("AUTH_SOURCE_SHOWGRID-checkbox").setValue(typeof(Fields.AUTH_SOURCE_GRID_ATTRIBUTE) != "undefined");
ldapGrid.setVisible(typeof(Fields.AUTH_SOURCE_GRID_ATTRIBUTE) != "undefined");
});

View File

@@ -0,0 +1,317 @@
Ext.onReady(function() {
Ext.QuickTips.init();
Ext.form.Field.prototype.msgTarget = 'side';
/////////////////////////////////
///// PANEL SEARCH USERS
/////////////////////////////////
//Variables
var pageSize = parseInt(CONFIG.pageSize);
//Components
var searchUsersText = new Ext.form.TextField({
width: 280,
allowBlank: true,
listeners:{
specialkey:function(f,o){
if(o.getKey()==13){
storeGridSearch.load({ params: {sKeyword: searchUsersText.getValue()} });
}
}
}
});
var compSearchUsers = new Ext.form.CompositeField({
fieldLabel: 'Keyword',
labelStyle: 'width:100px; padding: 3px 3px 3px 15px;',
items: [
searchUsersText,
{
xtype: 'button',
iconCls: 'button_menu_ext ss_sprite ss_magnifier',
text: 'Search',
width : 40,
handler: function(){
storeGridSearch.load({ params: {sKeyword: searchUsersText.getValue()} });
}
}
]
});
var panelSearch = new Ext.Panel({
region: 'north',
height: 65,
margins: '0 0 0 0',
frame: true,
labelAlign: 'left',
align: 'center',
labelStyle: 'font-weight:bold; padding: 3px 3px 3px 15px;',
title: "<div><div style=\"float: left;\">" + "Search for user" + "</div><div id=\"divBack\" style=\"float: right;\"></div><div style=\"clear: both; height: 0; line-height:0; font-size: 0;\"></div></div>",
items: [
new Ext.FormPanel({
labelWidth : 120,
labelStyle: 'padding: 3px 3px 3px 15px;',
autoScroll: false,
monitorValid : true,
bodyStyle: "border: 0px;",
items:[
compSearchUsers
]
})
],
listeners: {
afterrender: function (panel)
{
var btn = new Ext.Button({
text: _("ID_BACK"),
iconCls: "button_menu_ext ss_sprite ss_arrow_left",
renderTo: "divBack",
handler: function ()
{
redirectPage("authSources_List");
}
});
}
}
});
/////////////////////////////////
///// GRID SEARCH USERS
/////////////////////////////////
var storeGridSearch = new Ext.data.JsonStore({
proxy: new Ext.data.HttpProxy({
method: 'POST',
url: '../controllers/ldapAdvancedProxy.php',
timeout: 240000
}),
autoDestroy: true,
remoteSort: false,
totalProperty: "resultTotal",
root: "resultRoot",
fields: [
'sUsername',
'sFullname',
'sFirstname',
'sLastname',
'sEmail',
'sCategory',
'sDN',
'sManagerDN',
'STATUS',
'IMPORT'
],
listeners: {
beforeload: function (store, opt)
{
this.baseParams = {
functionAccion: "searchUsers",
sUID: Fields.AUTH_SOURCE_UID,
sKeyword: searchUsersText.getValue(),
pageSize: pageSize
};
},
load: function (store, record, opt)
{
Ext.getCmp('BUTTON_IMPORT').disable();
}
}
});
storeGridSearch.setDefaultSort('sUsername', 'asc');
var tbarSearch = [
{
id: 'BUTTON_IMPORT',
text: 'Import',
iconCls: 'button_menu_ext ss_sprite ss_group_go ',
disabled: true,
handler: function () {
rowSelected = gridSearch.getSelectionModel().getSelected();
var auxUsersSelect = gridSearch.getSelectionModel().selections.items;
var countSelect = auxUsersSelect.length;
if (countSelect != 0) {
var con = 0;
var usersSelect = new Array();
var numberCases = '';
while (con < countSelect) {
if (auxUsersSelect[con].data.IMPORT == 1) {
var newArray = {
sUsername : auxUsersSelect[con].data.sUsername,
sFullname : auxUsersSelect[con].data.sFullname,
sFirstname : auxUsersSelect[con].data.sFirstname,
sLastname : auxUsersSelect[con].data.sLastname,
sEmail : auxUsersSelect[con].data.sEmail,
sCategory : auxUsersSelect[con].data.sCategory,
sDN : auxUsersSelect[con].data.sDN,
sManagerDN : auxUsersSelect[con].data.sManagerDN
};
usersSelect.push(newArray);
}
con++;
}
var countImport = usersSelect.length;
if (countImport != 0) {
Ext.MessageBox.confirm('Confirm', 'Are you sure you want to import the selected users?', function (val) {
if (val == 'yes') {
Ext.MessageBox.show({
msg: 'Importing Users...',
progressText: 'Saving...',
width:300,
wait:true,
waitConfig: {interval:200},
animEl: 'mb7'
});
Ext.Ajax.request({
params: {
'UsersImport': Ext.encode(usersSelect),
'functionAccion': 'importUsers',
'AUTH_SOURCE_UID': Fields.AUTH_SOURCE_UID
},
url : '../controllers/ldapAdvancedProxy.php',
success: function (returnData) {
var resp = Ext.decode(returnData.responseText);
Ext.MessageBox.hide();
if (resp.success) {
Ext.MessageBox.show({
title: 'Import Users',
msg: 'Imported Successfully',
buttons: Ext.MessageBox.OK,
animEl: 'mb9',
icon: Ext.MessageBox.INFO
});
redirectPage('../users/users_List');
}
},
failure: function () {
Ext.MessageBox.alert('ERROR', 'Error in server');
}
});
}
});
} else {
PMExt.notify('WARNING', 'You do not select any user to import');
}
} else {
PMExt.notify('WARNING', 'You do not select any user to import');
}
}
}
];
//var pageSize = parseInt(CONFIG.pageSize);
//
//var storePageSize = new Ext.data.SimpleStore({
// autoLoad: true,
// fields: ['size'],
// data:[['20'],['30'],['40'],['50'],['100']]
//});
//
//var comboPageSize = new Ext.form.ComboBox({
// typeAhead : false,
// mode : 'local',
// triggerAction : 'all',
// store: storePageSize,
// valueField: 'size',
// displayField: 'size',
// width: 50,
// editable: false,
// listeners:{
// select: function(c,d,i){
// pagingSearchList.pageSize = parseInt(d.data['size']);
// pagingSearchList.moveFirst();
// }
// }
//});
//
//comboPageSize.setValue(pageSize);
//
//var pagingSearchList = new Ext.PagingToolbar({
// pageSize : 1000,
// store : storeGridSearch,
// displayInfo : true,
// autoHeight : true,
// displayMsg : 'Ldap Users' + ' {0} - {1} ' + 'of' + ' {2}',
// emptyMsg : ' There are no LDAP Users '//,
// //items: [
// //comboPageSize
// //]
//});
var pagingSearchList = new Ext.PagingToolbar({
pageSize: pageSize,
store: storeGridSearch,
displayInfo: true,
displayMsg: "LDAP Users" + " {0} - {1} " + "of" + " {2}",
emptyMsg: "There are no LDAP Users"
});
var selectModelList = new Ext.grid.CheckboxSelectionModel({
listeners: {
selectionchange: function() {
if (selectModelList.getCount() > 0) {
Ext.getCmp('BUTTON_IMPORT').enable();
} else {
Ext.getCmp('BUTTON_IMPORT').disable();
}
}
}
});
var gridSearch = new Ext.grid.GridPanel({
store : storeGridSearch,
tbar : tbarSearch,
bbar : pagingSearchList,
region: 'center',
margins: '0 0 0 0',
loadMask : true,
sm: selectModelList,
cm: new Ext.grid.ColumnModel({
defaults: {
sortable: true
},
columns: [
selectModelList,
{header: 'Username', width: 15, dataIndex: 'sUsername', sortable: true},
{header: 'First Name', width: 15, dataIndex: 'sFirstname', sortable: true},
{header: 'Last Name', width: 15, dataIndex: 'sLastname', sortable: true},
{header: 'Email', width: 15, dataIndex: 'sEmail', sortable: true},
{header: 'Distinguished Name', width: 35, dataIndex: 'sDN'},
{dataIndex: "STATUS", header: _("ID_STATUS"), width: 10, css: "background: #D4D4D4; font-weight: bold;", align: "center", renderer: renderStatus}
]
}),
border: false,
autoShow: true,
autoFill:true,
nocache: true,
autoWidth: true,
stripeRows: true,
stateful: true,
animCollapse: true,
enableColumnResize: true,
enableHdMenu: true,
columnLines: true,
viewConfig: {
forceFit:true,
emptyText: '<div align="center"><b> ' + ' There are no LDAP Users ' + ' </b></div>'
}
});
new Ext.Viewport({
layout:'border',
border: false,
items: [panelSearch, gridSearch]
});
});

View File

@@ -0,0 +1,15 @@
function redirectPage(page){
window.location = page;
}
function randomNum(inf, sup){
numPos = sup - inf;
aleat = Math.random() * numPos;
aleat = Math.round(aleat);
return parseInt(inf) + aleat;
}
function renderStatus (data, metadata, record, rowIndex, columnIndex, store) {
return "<span style=\"color: " + ((record.data.IMPORT == 1)? "#005E20" : "#FF0000") + ";\">" + record.data.STATUS.toUpperCase() + "</span>";
}

View File

@@ -0,0 +1,180 @@
var caseData = '';
var appTitle = new Ext.form.Label({
fieldLabel: "Case Title",
labelStyle: 'font-weight:bold;padding-right:30px;'
});
var process = new Ext.form.Label({
fieldLabel: "Process Uid",
labelStyle: 'font-weight:bold;padding-right:35px;'
});
var processTitle = new Ext.form.Label({
fieldLabel: "Process",
labelStyle: 'font-weight:bold;padding-right:35px;'
});
var appUid = new Ext.form.Label({
fieldLabel: "App Uid",
labelStyle: 'font-weight:bold;padding-right:35px;'
});
var caseNumber = new Ext.form.Label({
fieldLabel: "Case number",
labelStyle: 'font-weight:bold;padding-right:35px;'
});
var initUser = new Ext.form.Label({
fieldLabel: "Init user",
labelStyle: 'font-weight:bold;padding-right:35px;'
});
var finishUser = new Ext.form.Label({
fieldLabel: "Finish user",
labelStyle: 'font-weight:bold;padding-right:35px;'
});
var createDate = new Ext.form.Label({
fieldLabel: "Create date",
labelStyle: 'font-weight:bold;padding-right:35px;'
});
var finishDate = new Ext.form.Label({
fieldLabel: "Finish date",
labelStyle: 'font-weight:bold;padding-right:35px;'
});
var fileName = new Ext.form.Label({
fieldLabel: "File Name",
labelStyle: 'font-weight:bold;padding-right:35px;'
});
var statusCaseWin = new Ext.form.Label({
fieldLabel: "Status",
labelStyle: 'font-weight:bold;padding-right:35px;'
});
var formCase = new Ext.FormPanel({
labelWidth : 120,
labelAlign : 'right',
autoScroll: true,
frame: true,
bodyStyle : 'padding-top:20px;padding-left:20px;',
items:[
appTitle,
caseNumber,
processTitle,
initUser,
finishUser,
createDate,
finishDate,
fileName,
statusCaseWin
],
buttons:[{
text : "Restore case",
id: 'BUTTON_UNARCHIVE_CASE',
iconCls: 'button_menu_ext ss_sprite ss_folder_go',
formBind : true,
handler : function(){
if (caseData!='') {
Ext.MessageBox.confirm("Confirm", "Are you sure you want to restore the case?", function (val) {
if (val == 'yes') {
dataCase = caseData;
Ext.MessageBox.show({
msg: "Restoring case" + ' ' + dataCase.CASE_NUMBER + ' ...',
progressText: 'Saving...',
width:300,
wait:true,
waitConfig: {interval:200},
animEl: 'mb7'
});
Ext.Ajax.request({
params: {
'APP_UID': dataCase.APP_UID,
'FILENAME_TAR': dataCase.FILENAME_TAR,
'functionExecute': 'unarchiveCase'
},
url : 'controllers/searchListProxy.php',
success: function (returnData) {
Ext.MessageBox.hide();
var resp = Ext.decode(returnData.responseText);
if (resp.success) {
Ext.MessageBox.show({
title: 'Case Unarhive',
msg: "Case" + ' ' + dataCase.CASE_NUMBER + ' ' + "Restored sucessfully",
buttons: Ext.MessageBox.OK,
animEl: 'mb9',
icon: Ext.MessageBox.INFO
});
} else {
Ext.MessageBox.show({
title: "Error",
msg: resp.message,
buttons: Ext.MessageBox.OK,
animEl: 'mb9',
icon: Ext.MessageBox.ERROR
});
}
storeGridSearch.load();
},
failure: function () {
Ext.MessageBox.alert("Error", "Error in server");
}
});
}
});
}
}
},
{
text : _('ID_CLOSE'),
iconCls: 'button_menu_ext ss_sprite ss_folder_delete',
formBind : true,
handler : function(){
summaryWindow.hide();
}
}]
});
var summaryWindow = new Ext.Window({
title: "Detail Case",
layout: 'fit',
width: 500,
height: 320,
resizable: true,
closable: true,
closeAction : 'hide',
modal: true,
autoScroll:true,
constrain: true,
items: [formCase]
});
function showCaseSummary(dataCase) {
if (dataCase) {
caseData = dataCase;
if(dataCase.STATUS == 'RESTORED'){
Ext.getCmp('BUTTON_UNARCHIVE_CASE').disable();
} else {
Ext.getCmp('BUTTON_UNARCHIVE_CASE').enable();
}
appTitle.setText(dataCase.APP_TITLE, false);
process.setText(dataCase.PRO_UID, false);
processTitle.setText(dataCase.PRO_TITLE, false);
appUid.setText(dataCase.APP_UID, false);
caseNumber.setText(dataCase.CASE_NUMBER, false);
initUser.setText(dataCase.INIT_USER_NAME, false);
finishUser.setText(dataCase.FINISH_USER_NAME, false);
createDate.setText(renderDate(dataCase.CREATE_DATE, false));
finishDate.setText(renderDate(dataCase.FINISH_DATE, false));
fileName.setText(dataCase.FILENAME_TAR+'.tar', false);
statusCaseWin.setText(dataCase.STATUS, false);
summaryWindow.show();
}
}

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<dynaForm type="grid" name="ldapAdvanced/gridAttribute" enabletemplate="0" mode="">
<attributeLdap type="text" maxlength="64" validate="Any" required="0" readonly="0" size="15" mode="edit" btn_cancel="Cancel">
<en><![CDATA[LDAP Field]]></en>
<pt-BR><![CDATA[Campo LDAP]]></pt-BR>
</attributeLdap>
<attributeUser type="dropdown" required="0" readonly="0" mode="edit" options="Array" btn_cancel="Cancel">
<en><![CDATA[User Field]]></en>
<pt-BR><![CDATA[Campo de Usuário]]></pt-BR>
</attributeUser>
</dynaForm>

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<dynaForm name="Ldap Setup Form" type="xmlform" width="550">
<TITLE type="title" group="1">
<en><![CDATA[Ldap Advance Plugin]]></en>
<pt-BR><![CDATA[Ldap Plugin Adiantamento]]></pt-BR>
</TITLE>
<HelpText type="subtitle" maxlength="100" size="60">
<en><![CDATA[Please check the User Section in order to Synchronize or Import users from an authentication source using this plugin. There is no further configuration needed.]]></en>
<pt-BR><![CDATA[Por favor verifique a seção do usuário, a fim de sincronizar ou importar usuários a partir de uma fonte de autenticação usando este plugin. Não há nenhuma configuração adicional necessário.]]></pt-BR>
</HelpText>
</dynaForm>

View File

@@ -0,0 +1,215 @@
<?xml version="1.0" encoding="UTF-8"?>
<dynaForm name="authSources/ldap_Edit" type="xmlform" width="650" enabletemplate="0" mode="">
<title type="title">
<en><![CDATA[Authentication Source Information]]></en>
<pt-BR><![CDATA[Informações de fonte de autenticação]]></pt-BR>
</title>
<AUTH_SOURCE_UID type="hidden"/>
<AUTH_SOURCE_NAME type="text" size="50" maxlength="50" required="1">
<en><![CDATA[Name]]></en>
<pt-BR><![CDATA[Nome]]></pt-BR>
</AUTH_SOURCE_NAME>
<AUTH_SOURCE_PROVIDER type="hidden" defaultValue="ldap"/>
<LDAP_TYPE type="dropdown" required="0">
<en><![CDATA[Type]]><option name="ldap"><![CDATA[OpenLDAP]]></option><option name="ad"><![CDATA[Active Directory]]></option><option name="ds"><![CDATA[389 DS]]></option></en>
<pt-BR><![CDATA[Tipo]]><option name="ldap"><![CDATA[OpenLDAP]]></option><option name="ad"><![CDATA[Active Directory]]></option><option name="ds"><![CDATA[389 DS]]></option></pt-BR>
</LDAP_TYPE>
<AUTH_SOURCE_AUTO_REGISTER type="dropdown">
<en><![CDATA[Enable automatic register]]><option name="0"><![CDATA[No]]></option><option name="1"><![CDATA[Yes]]></option></en>
<pt-BR><![CDATA[Ativado automatic registrar]]><option name="0"><![CDATA[Não]]></option><option name="1"><![CDATA[Sim]]></option></pt-BR>
</AUTH_SOURCE_AUTO_REGISTER>
<AUTH_SOURCE_SERVER_NAME type="text" size="50" maxlength="50" required="1">
<en><![CDATA[Server Address]]></en>
<pt-BR><![CDATA[Endereço do Servidor]]></pt-BR>
</AUTH_SOURCE_SERVER_NAME>
<AUTH_SOURCE_PORT type="text" size="5" maxlength="5" required="1" defaultValue="389" validate="Int">
<en><![CDATA[Port]]></en>
<pt-BR><![CDATA[Porto]]></pt-BR>
</AUTH_SOURCE_PORT>
<AUTH_SOURCE_ENABLED_TLS type="dropdown">
<en><![CDATA[Enabled TLS]]><option name="0"><![CDATA[No]]></option><option name="1"><![CDATA[Yes]]></option></en>
<pt-BR><![CDATA[Ativado TLS]]><option name="0"><![CDATA[Não]]></option><option name="1"><![CDATA[Sim]]></option></pt-BR>
</AUTH_SOURCE_ENABLED_TLS>
<AUTH_SOURCE_BASE_DN type="text" size="50" maxlength="128" required="1">
<en><![CDATA[Base DN]]></en>
<pt-BR><![CDATA[Base DN]]></pt-BR>
</AUTH_SOURCE_BASE_DN>
<AUTH_ANONYMOUS type="dropdown">
<en><![CDATA[Anonymous]]><option name="0"><![CDATA[No]]></option><option name="1"><![CDATA[Yes]]></option></en>
<pt-BR><![CDATA[anônimo]]><option name="0"><![CDATA[Não]]></option><option name="1"><![CDATA[Sim]]></option></pt-BR>
</AUTH_ANONYMOUS>
<AUTH_SOURCE_SEARCH_USER type="text" size="50" maxlength="128" required="0">
<en><![CDATA[Username]]></en>
<pt-BR><![CDATA[Usuário]]></pt-BR>
</AUTH_SOURCE_SEARCH_USER>
<AUTH_SOURCE_PASSWORD type="password" size="20" maxlength="32" required="0">
<en><![CDATA[Password]]></en>
<pt-BR><![CDATA[Senha]]></pt-BR>
</AUTH_SOURCE_PASSWORD>
<AUTH_SOURCE_IDENTIFIER_FOR_USER type="text" size="20" maxlength="20" required="1" defaultValue="uid">
<en><![CDATA[User Identifier]]></en>
<pt-BR><![CDATA[Identificador de usuário]]></pt-BR>
</AUTH_SOURCE_IDENTIFIER_FOR_USER>
<AUTH_SOURCE_USERS_FILTER type="text" size="50" maxlength="200" required="0" defaultValue="">
<en><![CDATA[Filter to search users (Default set to (&(!(objectClass=organizationalUnit))))]]></en>
<pt-BR><![CDATA[Filtro para os usuários de busca (Default set to (&(!(objectClass=organizationalUnit))))]]></pt-BR>
</AUTH_SOURCE_USERS_FILTER>
<AUTH_SOURCE_RETIRED_OU type="text" size="50" maxlength="128" required="0">
<en><![CDATA[OU for Retired Employees OU]]></en>
<pt-BR><![CDATA[OU ao Aposentado UO]]></pt-BR>
</AUTH_SOURCE_RETIRED_OU>
<AUTH_SOURCE_ATTRIBUTE_IDS type="hidden"/>
<AUTH_SOURCE_SHOWGRID_FLAG type="hidden"/>
<AUTH_SOURCE_GRID_TEXT type="hidden"/>
<AUTH_SOURCE_ATTRIBUTE_SUBTITLE type="subtitle" enablehtml="1" btn_cancel="Cancel" required="0" readonly="0" savelabel="0">
<en><![CDATA[<input type="checkbox" name="form[AUTH_SOURCE_SHOWGRID]" id="form[AUTH_SOURCE_SHOWGRID]"> Match attributes to sync]]></en>
<pt-BR><![CDATA[<input type="checkbox" name="form[AUTH_SOURCE_SHOWGRID]" id="form[AUTH_SOURCE_SHOWGRID]"> Combinar atributos para sincronizar]]></pt-BR>
</AUTH_SOURCE_ATTRIBUTE_SUBTITLE>
<AUTH_SOURCE_GRID_ATTRIBUTE type="grid" xmlgrid="ldapAdvanced/gridAttribute" addrow="1" deleterow="1" btn_cancel="Cancel"/>
<SUBTITLETESTCONNECTION type="subtitle">
<en><![CDATA[Minimum data required to run the "Test Connection": "Server Address, Port, Enabled TLS, Anonymous, Username, Password"]]></en>
<pt-BR><![CDATA[Dados mínimos necessários para executar o "Test Connection": "Server Address, Port, TLS Habilitado, Anonymous, Nome de usuário, Senha"]]></pt-BR>
</SUBTITLETESTCONNECTION>
<btnSave type="submit">
<en><![CDATA[Save]]></en>
<pt-BR><![CDATA[Salvar]]></pt-BR>
</btnSave>
<BTNTESTCONNECTION type="button" onclick="testConnection();">
<en><![CDATA[Test connection]]></en>
<pt-BR><![CDATA[Teste de conexão]]></pt-BR>
</BTNTESTCONNECTION>
<btnCancel type="button" onclick="history.go(-1);">
<en><![CDATA[Cancel]]></en>
<pt-BR><![CDATA[Cancel]]></pt-BR>
</btnCancel>
<JS type="javascript"><![CDATA[
var dynaformOnload = function() {
getField('AUTH_SOURCE_SHOWGRID').checked = (getField('AUTH_SOURCE_SHOWGRID_FLAG').value == 1) ? true : false;
var fieldGridTd = getField('AUTH_SOURCE_GRID_ATTRIBUTE').parentNode.parentNode.parentNode;
fieldGridTd.style.display = 'none';
leimnud.event.add(getField('AUTH_ANONYMOUS'), 'change', hideShowSearchUser);
leimnud.event.add(getField('LDAP_TYPE'), 'change', hideShowSuggest);
leimnud.event.add(getField('AUTH_SOURCE_SHOWGRID'), 'click', showGrid);
hideShowSearchUser();
hideShowSuggest();
showGrid();
var valuesDrop = getField('AUTH_SOURCE_ATTRIBUTE_IDS').value;
valuesDropArray = valuesDrop.split('|');
for (var i = 0 ; i < valuesDropArray.length ; i++) {
if (valuesDropArray[i] != '') {
var iRows = Number_Rows_Grid('AUTH_SOURCE_GRID_ATTRIBUTE','attributeLdap');
for (cont=1 ; cont<=iRows ; cont=cont+1) {
eval(" var newOption = document.createElement('option'); newOption.text = valuesDropArray[i]; newOption.value = valuesDropArray[i]; try { getField('AUTH_SOURCE_GRID_ATTRIBUTE][" + cont + "][attributeUser').add(newOption, null);} catch(ex) { getField('AUTH_SOURCE_GRID_ATTRIBUTE][" + cont + "][attributeUser').add(newOption);}");
}
}
}
var valuesGrid = getField('AUTH_SOURCE_GRID_TEXT').value;
valuesGridArray = valuesGrid.split('|');
var fil = 1;
for (var i = 0 ; i < valuesGridArray.length ; i++) {
if(valuesGridArray[i] != '')
{
var valuesFielddGrid = valuesGridArray[i].split("/");
getField('AUTH_SOURCE_GRID_ATTRIBUTE][' + fil + '][attributeUser').value = valuesFielddGrid['1'];
fil++;
}
}
function showGrid() {
if (getField('AUTH_SOURCE_SHOWGRID').checked == true) {
fieldGridTd.style.display = 'block';
fieldGridTd.removeAttribute("style",0);
} else {
fieldGridTd.style.display = 'none';
}
}
};
var hideShowSearchUser = function() {
if (getField('AUTH_ANONYMOUS').value == '1') {
hideRowById('AUTH_SOURCE_SEARCH_USER');
hideRowById('AUTH_SOURCE_PASSWORD');
}
else {
showRowById('AUTH_SOURCE_SEARCH_USER');
showRowById('AUTH_SOURCE_PASSWORD');
}
};
var hideShowSuggest = function ()
{
getField("AUTH_SOURCE_IDENTIFIER_FOR_USER").value = (getField("LDAP_TYPE").value == "ad")? "samaccountname" : "uid";
};
var testConnection = function ()
{
var strArgs = "functionAccion=ldapTestConnection&";
strArgs += "AUTH_SOURCE_SERVER_NAME=" + getField("AUTH_SOURCE_SERVER_NAME").value + "&";
strArgs += "AUTH_SOURCE_PORT=" + getField("AUTH_SOURCE_PORT").value + "&";
strArgs += "AUTH_SOURCE_ENABLED_TLS=" + getField("AUTH_SOURCE_ENABLED_TLS").value + "&";
strArgs += "AUTH_ANONYMOUS=" + getField("AUTH_ANONYMOUS").value + "&";
strArgs += "AUTH_SOURCE_SEARCH_USER=" + getField("AUTH_SOURCE_SEARCH_USER").value + "&";
strArgs += "AUTH_SOURCE_PASSWORD=" + getField("AUTH_SOURCE_PASSWORD").value + "&";
strArgs += "AUTH_SOURCE_VERSION=3";
var rpcAjax = new leimnud.module.rpc.xmlhttp({
url: "../ldapAdvanced/controllers/ldapAdvancedProxy.php",
method: "POST",
args: strArgs
});
rpcAjax.callback = function (rpc)
{
var dataResponse = rpc.xmlhttp.responseText.parseJSON();
if (dataResponse.status) {
var panel = new leimnud.module.panel();
panel.options = {
statusBarButtons: [{value: _("ID_ACCEPT")}],
position: {center: true},
size: {
w: 400,
h: 125
},
control: {
close: true,
resize: false
},
fx: {modal: true}
};
panel.setStyle = {
content:{
padding: 10,
paddingLeft: 50,
textAlign: "left",
background: "url(/images/" + ((dataResponse.status == "OK")? "dialog-ok-apply" : "error") + ".png)",
backgroundRepeat: "no-repeat",
backgroundPosition: "2% 10%",
backgroundColor: "transparent",
borderWidth: 0
}
};
panel.make();
panel.addContent((dataResponse.status == "OK")? "Successfully connected" : dataResponse.message);
panel.fixContent();
panel.elements.statusBarButtons[0].onmouseup = function ()
{
panel.remove();
return false;
}.extend(this);
}
}.extend(this);
rpcAjax.make();
};
]]></JS>
</dynaForm>

View File

@@ -0,0 +1 @@
Bandera para habilitar nueva interfaz extjs