Merged in bugfix/PMCORE-2487 (pull request #7573)

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

Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
This commit is contained in:
Roly Rudy Gutierrez Pinto
2021-01-25 14:07:32 +00:00
committed by Julio Cesar Laura Avendaño
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
@@ -2498,6 +2500,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
*