PMCORE-2487 Multiple groups are created with the same name when setting up ldap group synchronization

This commit is contained in:
Roly Rudy Gutierrez Pinto
2021-01-11 11:08:50 -04:00
parent 20b29ff148
commit a083cec1dd
5 changed files with 97 additions and 40 deletions

View File

@@ -1,8 +1,10 @@
<?php
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use ProcessMaker\BusinessModel\User;
use ProcessMaker\Model\Groupwf;
/**
* class.ldapAdvanced.php
@@ -2401,6 +2403,47 @@ class LdapAdvanced
}
}
/**
* Get group Uid by title.
* @param string $title
* @return string
*/
public function getGroupUidByTitle(string $title): string
{
try {
$groupWf = Groupwf::query()
->where('GRP_STATUS', '=', 'ACTIVE')
->where('GRP_TITLE', '=', $title)
->orderBy('GRP_ID', 'ASC')
->get()
->first();
if (!empty($groupWf)) {
return $groupWf->GRP_UID;
}
} catch (Exception $e) {
$message = $e->getMessage();
Log::channel(':ldapSynchronizeGroups')->error($message, Bootstrap::context());
}
return "";
}
/**
* Check duplicate titles in GROUPWF table.
* @return bool
*/
public function checkDuplicateTitles(): bool
{
$sql = ""
. "select GRP_TITLE,count(GRP_TITLE) "
. "from GROUPWF "
. "group by GRP_TITLE having count(GRP_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
*