BUG 11461 "User not in alfabetical order in Advance Search" SOLVED

- User not in alfabetical order in Advance Search
- Sorting problem in the dropdown "User", in Advanced Search, this are
  ordering by USERS.USR_LASTNAME field, which is incorrect
- Solved problem the ordering, has taken into account the settings
  made in ADMIN>Settings>Environment>UserNameDisplayFormat
- The ordering is in ascending
- The "All Users" and "Current User" wildcards will always be the first
- We have defined a new method in the "class.configuration.php" class which
  returns the field you should place your order to the users, this according
  to the settings made ..in ADMIN>Settings>Environment>UserNameDisplayFormat

* Available from version ProcessMaker-2.5.1-testing.3
This commit is contained in:
Victor Saisa Lopez
2013-06-18 16:25:05 -04:00
parent a2b850f272
commit 480e6b7711
3 changed files with 79 additions and 42 deletions

View File

@@ -413,27 +413,7 @@ class Applications
if (($action == "sent" || $action == "search" || $action == "simple_search" || $action == "to_revise" || $action == "to_reassign") && ($status != "TO_DO")) {
switch ($sort) {
case "APP_CACHE_VIEW.APP_CURRENT_USER":
$sort = "USRCR_USR_LASTNAME";
$confEnvSetting = $conf->getConfiguration("ENVIRONMENT_SETTINGS", "");
if (is_array($confEnvSetting)) {
$arrayAux = explode(" ", str_replace(array("(", ")", ","), array(null, null, null), $confEnvSetting["format"]));
if (isset($arrayAux[0])) {
switch (trim($arrayAux[0])) {
case "@userName":
$sort = "USRCR_USR_USERNAME";
break;
case "@firstName":
$sort = "USRCR_USR_FIRSTNAME";
break;
case "@lastName":
$sort = "USRCR_USR_LASTNAME";
break;
}
}
}
$sort = "USRCR_" . $conf->userNameFormatGetFirstFieldByUsersTable();
break;
case "APP_CACHE_VIEW.APP_TAS_TITLE":
$sort = "APPCVCR_APP_TAS_TITLE";

View File

@@ -315,7 +315,6 @@ class Configurations // extends Configuration
}
}
public function userNameFormat($username, $fullname)
{
@@ -338,6 +337,48 @@ class Configurations // extends Configuration
}
}
public function usersNameFormatBySetParameters($formatUserName, $userName, $firstName, $lastName)
{
$usersNameFormat = (!empty($formatUserName))? str_replace(array("@userName", "@firstName", "@lastName"), array($userName, $firstName, $lastName), $formatUserName) : null;
$usersNameFormat = trim($usersNameFormat);
return $usersNameFormat;
}
/**
* Gets the first field of the UserName format
*
* Returns the field, based on the field name in the USERS table
*
* @return string Return the field
*/
public function userNameFormatGetFirstFieldByUsersTable()
{
$field = "USR_LASTNAME";
$confEnvSetting = $this->getConfiguration("ENVIRONMENT_SETTINGS", "");
if (is_array($confEnvSetting) && isset($confEnvSetting["format"])) {
$arrayAux = explode(" ", str_replace(array("(", ")", ","), array(null, null, null), $confEnvSetting["format"]));
if (isset($arrayAux[0])) {
switch (trim($arrayAux[0])) {
case "@userName":
$field = "USR_USERNAME";
break;
case "@firstName":
$field = "USR_FIRSTNAME";
break;
case "@lastName":
$field = "USR_LASTNAME";
break;
}
}
}
return $field;
}
/**
* getFormats
*

View File

@@ -54,19 +54,35 @@ if ($actionAjax == "userValues") {
switch ($action) {
case 'search_simple':
case 'search':
G::LoadClass("configuration");
$conf = new Configurations();
$confEnvSetting = $conf->getConfiguration("ENVIRONMENT_SETTINGS", "");
$formatUserName = null;
if (is_array($confEnvSetting) && isset($confEnvSetting["format"])) {
$formatUserName = $confEnvSetting["format"];
}
$cUsers = new Criteria( 'workflow' );
$cUsers->clearSelectColumns();
$cUsers->addSelectColumn( UsersPeer::USR_UID );
$cUsers->addSelectColumn( UsersPeer::USR_FIRSTNAME );
$cUsers->addSelectColumn( UsersPeer::USR_LASTNAME );
$cUsers->addSelectColumn(UsersPeer::USR_UID);
$cUsers->addSelectColumn(UsersPeer::USR_USERNAME);
$cUsers->addSelectColumn(UsersPeer::USR_FIRSTNAME);
$cUsers->addSelectColumn(UsersPeer::USR_LASTNAME);
$cUsers->add( UsersPeer::USR_STATUS, 'CLOSED', Criteria::NOT_EQUAL );
$cUsers->addAscendingOrderByColumn( UsersPeer::USR_LASTNAME );
$cUsers->addAscendingOrderByColumn(UsersPeer::TABLE_NAME . "." . $conf->userNameFormatGetFirstFieldByUsersTable());
$oDataset = UsersPeer::doSelectRS( $cUsers );
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$oDataset->next();
while ($aRow = $oDataset->getRow()) {
$users[] = array ("USR_UID" => $aRow['USR_UID'],"USR_FULLNAME" => $aRow['USR_LASTNAME'] . ' ' . $aRow['USR_FIRSTNAME']);
$oDataset->next();
while ($oDataset->next()) {
$row = $oDataset->getRow();
$usrFullName = $conf->usersNameFormatBySetParameters($formatUserName, $row["USR_USERNAME"], $row["USR_FIRSTNAME"], $row["USR_LASTNAME"]);
$usrFullName = (!empty($usrFullName))? $usrFullName : $row["USR_LASTNAME"] . " " . $row["USR_FIRSTNAME"];
$users[] = array("USR_UID" => $row["USR_UID"], "USR_FULLNAME" => $usrFullName);
}
break;
default: