Merged in bugfix/PMCORE-4061 (pull request #8643)

PMCORE-4061

Approved-by: Julio Cesar Laura Avendaño
This commit is contained in:
Roly Gutierrez
2023-01-19 14:55:20 +00:00
committed by Julio Cesar Laura Avendaño
4 changed files with 83 additions and 64 deletions

View File

@@ -4,6 +4,7 @@ use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use ProcessMaker\BusinessModel\User;
use ProcessMaker\Model\Department;
use ProcessMaker\Model\Groupwf;
/**
@@ -2593,6 +2594,45 @@ class LdapAdvanced
return true;
}
/**
* Get department Uid by title.
* @param string $title
* @return string
*/
public function getDepartmentUidByTitle(string $title): string
{
try {
$department = Department::query()
->where('DEP_STATUS', '=', 'ACTIVE')
->where('DEP_TITLE', '=', $title)
->first();
if (!empty($department)) {
return $department->DEP_UID;
}
} catch (Exception $e) {
$message = $e->getMessage();
Log::channel(':ldapSynchronizeGroups')->error($message, Bootstrap::context());
}
return "";
}
/**
* Check duplicate titles in DEPARTMENT table.
* @return bool
*/
public function checkDuplicateDepartmentTitles(): bool
{
$sql = ""
. "select DEP_TITLE,count(DEP_TITLE) "
. "from DEPARTMENT "
. "group by DEP_TITLE having count(DEP_TITLE)>1";
$results = DB::select(DB::raw($sql));
if (empty($results)) {
return false;
}
return true;
}
/**
* Get number of Users in each Group from the Database
*