TASK-229 Validate all Endpoints for delete Old Ajax files
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
|
||||
use ProcessMaker\Model\RbacAuthenticationSource;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
@@ -15,6 +15,8 @@ use ProcessMaker\Model\Groupwf;
|
||||
class LdapSource
|
||||
{
|
||||
public $authSourceUid;
|
||||
public $ldapcnn = null;
|
||||
public $terminatedOu;
|
||||
|
||||
private $arrayObjectClassFilter = [
|
||||
"user" => "|(objectclass=inetorgperson)(objectclass=organizationalperson)(objectclass=person)(objectclass=user)",
|
||||
@@ -76,6 +78,225 @@ class LdapSource
|
||||
return ['connection' =>$ldapcnn, 'startTLS' => $resultLDAPStartTLS];
|
||||
}
|
||||
|
||||
public function searchGroups() {
|
||||
try {
|
||||
$arrayGroup = [];
|
||||
|
||||
$rbac = RBAC::getSingleton();
|
||||
|
||||
if (is_null($rbac->authSourcesObj)) {
|
||||
$rbac->authSourcesObj = new AuthenticationSource();
|
||||
}
|
||||
|
||||
$arrayAuthenticationSourceData = $rbac->authSourcesObj->load($this->authSourceUid);
|
||||
|
||||
if (is_null($this->ldapcnn)) {
|
||||
$ldapcnn = $this->ldapConnection($arrayAuthenticationSourceData);
|
||||
$this->ldapcnn = $ldapcnn['connection'];
|
||||
}
|
||||
|
||||
$ldapcnn = $this->ldapcnn;
|
||||
// Get Groups
|
||||
$limit = $this->getPageSizeLimitByData($arrayAuthenticationSourceData);
|
||||
$flagError = false;
|
||||
$filter = '(' . $this->arrayObjectClassFilter['group'] . ')';
|
||||
$this->log($ldapcnn, 'search groups with Filter: ' . $filter);
|
||||
|
||||
$cookie = '';
|
||||
do {
|
||||
$searchResult = @ldap_search(
|
||||
$ldapcnn,
|
||||
$arrayAuthenticationSourceData['AUTH_SOURCE_BASE_DN'],
|
||||
$filter,
|
||||
['dn', 'cn'],
|
||||
0,
|
||||
-1,
|
||||
-1,
|
||||
LDAP_DEREF_NEVER,
|
||||
[['oid' => LDAP_CONTROL_PAGEDRESULTS, 'value' => ['size' => $limit, 'cookie' => $cookie]]]
|
||||
);
|
||||
ldap_parse_result($ldapcnn, $searchResult, $errcode, $matcheddn, $errmsg, $referrals, $controls);
|
||||
$this->stdLog($ldapcnn, "ldap_search", ["filter" => $filter, "attributes" => ['dn', 'cn']]);
|
||||
|
||||
$context = [
|
||||
"baseDN" => $arrayAuthenticationSourceData['AUTH_SOURCE_BASE_DN'],
|
||||
"filter" => $filter,
|
||||
"attributes" => ['dn', 'cn']
|
||||
];
|
||||
$this->stdLog($ldapcnn, "ldap_search", $context);
|
||||
|
||||
if ($error = ldap_errno($ldapcnn)) {
|
||||
$this->log($ldapcnn, 'Error in Search');
|
||||
|
||||
$flagError = true;
|
||||
} else {
|
||||
if ($searchResult) {
|
||||
//Get groups from the ldap entries
|
||||
$countEntries = ldap_count_entries($ldapcnn, $searchResult);
|
||||
$this->stdLog($ldapcnn, "ldap_count_entries");
|
||||
|
||||
if ($countEntries > 0) {
|
||||
$entry = ldap_first_entry($ldapcnn, $searchResult);
|
||||
$this->stdLog($ldapcnn, "ldap_first_entry");
|
||||
|
||||
do {
|
||||
$arrayEntryData = $this->ldapGetAttributes($ldapcnn, $entry);
|
||||
|
||||
if (isset($arrayEntryData['cn']) && !is_array($arrayEntryData['cn'])) {
|
||||
$arrayGroup[] = [
|
||||
'dn' => $arrayEntryData['dn'],
|
||||
'cn' => trim($arrayEntryData['cn']),
|
||||
'users' => 0,
|
||||
];
|
||||
}
|
||||
} while ($entry = ldap_next_entry($ldapcnn, $entry));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$flagError) {
|
||||
if (isset($controls[LDAP_CONTROL_PAGEDRESULTS]['value']['cookie'])) {
|
||||
// You need to pass the cookie from the last call to the next one
|
||||
$cookie = $controls[LDAP_CONTROL_PAGEDRESULTS]['value']['cookie'];
|
||||
} else {
|
||||
$cookie = '';
|
||||
}
|
||||
}
|
||||
// Empty cookie means last page
|
||||
} while (!empty($cookie) && !$flagError);
|
||||
|
||||
$str = '';
|
||||
|
||||
foreach ($arrayGroup as $group) {
|
||||
$str .= ' ' . $group['cn'];
|
||||
}
|
||||
|
||||
$this->log($ldapcnn, 'found ' . count($arrayGroup) . ' groups: ' . $str);
|
||||
|
||||
return $arrayGroup;
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
public function searchDepartments() {
|
||||
try {
|
||||
$arrayDepartment = [];
|
||||
|
||||
$filters = ['conditions' => ['AUTH_SOURCE_UID'=> $this->authSourceUid]];
|
||||
$rbacAuthenticationSource = new RbacAuthenticationSource();
|
||||
$authSourceReturn = $rbacAuthenticationSource->show($filters);
|
||||
$authenticationSourceData = $authSourceReturn['data'][0];
|
||||
|
||||
if (is_null($this->ldapcnn)) {
|
||||
$ldapcnn = $this->ldapConnection($authenticationSourceData);
|
||||
$this->ldapcnn = $ldapcnn['connection'];
|
||||
}
|
||||
$this->terminatedOu = $attributes['AUTH_SOURCE_RETIRED_OU'] ?? '';
|
||||
$ldapcnn = $this->ldapcnn;
|
||||
|
||||
//Get Departments
|
||||
$limit = $this->getPageSizeLimitByData($authenticationSourceData);
|
||||
$flagError = false;
|
||||
$filter = '(' . $this->arrayObjectClassFilter['department'] . ')';
|
||||
$this->log($ldapcnn, 'search Departments with Filter: ' . $filter);
|
||||
$unitsBase = $this->custom_ldap_explode_dn($authenticationSourceData['AUTH_SOURCE_BASE_DN']);
|
||||
|
||||
$cookie = '';
|
||||
do {
|
||||
$searchResult = @ldap_search(
|
||||
$ldapcnn,
|
||||
$authenticationSourceData['AUTH_SOURCE_BASE_DN'],
|
||||
$filter,
|
||||
['dn', 'ou'],
|
||||
0,
|
||||
-1,
|
||||
-1,
|
||||
LDAP_DEREF_NEVER,
|
||||
[['oid' => LDAP_CONTROL_PAGEDRESULTS, 'value' => ['size' => $limit, 'cookie' => $cookie]]]
|
||||
);
|
||||
ldap_parse_result($ldapcnn, $searchResult, $errcode, $matcheddn, $errmsg, $referrals, $controls);
|
||||
$this->stdLog($ldapcnn, "ldap_search", ["filter" => $filter, "attributes" => ['dn', 'ou']]);
|
||||
|
||||
$context = [
|
||||
"baseDN" => $authenticationSourceData['AUTH_SOURCE_BASE_DN'],
|
||||
"filter" => $filter,
|
||||
"attributes" => ['dn', 'ou']
|
||||
];
|
||||
$this->stdLog($ldapcnn, "ldap_search", $context);
|
||||
|
||||
if ($error = ldap_errno($ldapcnn)) {
|
||||
$this->log($ldapcnn, 'Error in Search');
|
||||
|
||||
$flagError = true;
|
||||
} else {
|
||||
if ($searchResult) {
|
||||
//The first node is root
|
||||
if (empty($arrayDepartment)) {
|
||||
$arrayDepartment[] = [
|
||||
'dn' => $authenticationSourceData['AUTH_SOURCE_BASE_DN'],
|
||||
'parent' => '',
|
||||
'ou' => 'ROOT',
|
||||
'users' => 0
|
||||
];
|
||||
}
|
||||
|
||||
//Get departments from the ldap entries
|
||||
if (ldap_count_entries($ldapcnn, $searchResult) > 0) {
|
||||
$this->stdLog($ldapcnn, "ldap_count_entries");
|
||||
$entry = ldap_first_entry($ldapcnn, $searchResult);
|
||||
$this->stdLog($ldapcnn, "ldap_first_entry", $context);
|
||||
|
||||
do {
|
||||
$arrayEntryData = $this->ldapGetAttributes($ldapcnn, $entry);
|
||||
$unitsEqual = $this->custom_ldap_explode_dn($arrayEntryData['dn']);
|
||||
|
||||
if (count($unitsEqual) == 1 && $unitsEqual[0] == '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (count($unitsEqual) > count($unitsBase)) {
|
||||
unset($unitsEqual[0]);
|
||||
}
|
||||
|
||||
if (isset($arrayEntryData['ou']) && !is_array($arrayEntryData['ou'])) {
|
||||
$arrayDepartment[] = [
|
||||
'dn' => $arrayEntryData['dn'],
|
||||
'parent' => (isset($unitsEqual[1])) ? implode(',', $unitsEqual) : '',
|
||||
'ou' => trim($arrayEntryData['ou']),
|
||||
'users' => 0
|
||||
];
|
||||
}
|
||||
} while ($entry = ldap_next_entry($ldapcnn, $entry));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$flagError) {
|
||||
if (isset($controls[LDAP_CONTROL_PAGEDRESULTS]['value']['cookie'])) {
|
||||
// You need to pass the cookie from the last call to the next one
|
||||
$cookie = $controls[LDAP_CONTROL_PAGEDRESULTS]['value']['cookie'];
|
||||
} else {
|
||||
$cookie = '';
|
||||
}
|
||||
}
|
||||
// Empty cookie means last page
|
||||
} while (!empty($cookie) && !$flagError);
|
||||
|
||||
$str = '';
|
||||
|
||||
foreach ($arrayDepartment as $dep) {
|
||||
$str .= ' ' . $dep['ou'];
|
||||
}
|
||||
|
||||
$this->log($ldapcnn, 'found ' . count($arrayDepartment) . ' departments: ' . $str);
|
||||
|
||||
return $arrayDepartment;
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
public function getPageSizeLimit($ldapcnn, $baseDn = '')
|
||||
{
|
||||
try {
|
||||
@@ -231,13 +452,14 @@ class LdapSource
|
||||
|
||||
$paged = !is_null($start) && !is_null($limit);
|
||||
|
||||
$rbac = RBAC::getSingleton();
|
||||
$filters = [
|
||||
'conditions' => ['AUTH_SOURCE_UID' => $this->authSourceUid],
|
||||
];
|
||||
$rbacAuthenticationSource = new RbacAuthenticationSource();
|
||||
$authSourceReturn = $rbacAuthenticationSource->show($filters);
|
||||
$arrayAuthenticationSourceData = $authSourceReturn['data'][0];
|
||||
$arrayAuthenticationSourceData['AUTH_SOURCE_DATA'] = json_decode($arrayAuthenticationSourceData['AUTH_SOURCE_DATA'], true);
|
||||
|
||||
if (is_null($rbac->authSourcesObj)) {
|
||||
$rbac->authSourcesObj = new AuthenticationSource();
|
||||
}
|
||||
|
||||
$arrayAuthenticationSourceData = $rbac->authSourcesObj->load($this->authSourceUid);
|
||||
$attributeUserSet = [];
|
||||
$attributeSetAdd = [];
|
||||
|
||||
@@ -400,6 +622,15 @@ class LdapSource
|
||||
}
|
||||
}
|
||||
|
||||
private function getPageSizeLimitByData(array $arrayAuthSourceData)
|
||||
{
|
||||
if (isset($arrayAuthSourceData['AUTH_SOURCE_DATA']['LDAP_PAGE_SIZE_LIMIT'])) {
|
||||
return $arrayAuthSourceData['AUTH_SOURCE_DATA']['LDAP_PAGE_SIZE_LIMIT'];
|
||||
} else {
|
||||
return $this->getPageSizeLimit(false);
|
||||
}
|
||||
}
|
||||
|
||||
private function ldapGetAttributes($ldapcnn, $entry)
|
||||
{
|
||||
try {
|
||||
@@ -438,4 +669,23 @@ class LdapSource
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
public function custom_ldap_explode_dn($dn)
|
||||
{
|
||||
$dn = trim($dn, ',');
|
||||
$result = ldap_explode_dn($dn, 0);
|
||||
$this->stdLog(null, "ldap_explode_dn", ["dn" => $dn]);
|
||||
|
||||
if (is_array($result)) {
|
||||
unset($result['count']);
|
||||
|
||||
foreach ($result as $key => $value) {
|
||||
$result[$key] = addcslashes(preg_replace_callback("/\\\([0-9A-Fa-f]{2})/", function ($m) {
|
||||
return chr(hexdec($m[1]));
|
||||
}, $value), '<>,"');
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
<?php
|
||||
|
||||
require_once 'classes/AuthSources.php';
|
||||
|
||||
try {
|
||||
if (isset($_REQUEST['action']) === false) {
|
||||
throw new Exception('No action was sent');
|
||||
@@ -18,7 +16,7 @@ try {
|
||||
switch ($action) {
|
||||
case 'authSourcesList':
|
||||
$start = $_REQUEST['start'] ?? 0;
|
||||
$limit = $_REQUEST['limit'] ?? $limit_size;
|
||||
$limit = $_REQUEST['limit'] ?? 25;
|
||||
$filter = $_REQUEST['textFilter'] ?? '';
|
||||
$orderBy = $_REQUEST['orderBy'] ?? '';
|
||||
$ascending = $_REQUEST['ascending'] ?? 'asc';
|
||||
@@ -112,7 +110,7 @@ try {
|
||||
$authSourceUid = $_POST['sUID'];
|
||||
$filters = [
|
||||
'start'=> $_POST['start'] ?? 0,
|
||||
'limit'=> $_POST['limit'] ?? ($_POST["pageSize"] ?? 10),
|
||||
'limit'=> $_POST['limit'] ?? ($_POST['pageSize'] ?? 10),
|
||||
'text'=> $_POST['sKeyword'] ?? ''
|
||||
];
|
||||
|
||||
@@ -136,16 +134,34 @@ try {
|
||||
$responseProxy = $authSources->importUsers($authSourceUid, $usersImport);
|
||||
break;
|
||||
case 'authSourcesImportLoadDepartment':
|
||||
$responseProxy['success'] = true;
|
||||
if (!isset($_REQUEST['authUid'])) {
|
||||
throw new Exception('No auth source UID was sent');
|
||||
}
|
||||
|
||||
$authSourceUid = $_REQUEST['authUid'];
|
||||
$authSources = new AuthSources();
|
||||
$responseProxy = $authSources->searchDepartaments($authSourceUid);
|
||||
break;
|
||||
case 'authSourcesImportSaveDepartment':
|
||||
$responseProxy['success'] = true;
|
||||
$authSources = new AuthSources();
|
||||
$departmentsDN = $_REQUEST['departmentsDN'];
|
||||
$authSourceUid = $_REQUEST['authUid'];
|
||||
$responseProxy = $authSources->saveDepartments($departmentsDN, $authSourceUid);
|
||||
break;
|
||||
case 'authSourcesImportLoadGroup':
|
||||
$responseProxy['success'] = true;
|
||||
if (!isset($_REQUEST['authUid'])) {
|
||||
throw new Exception('No auth source UID was sent');
|
||||
}
|
||||
|
||||
$authSourceUid = $_REQUEST['authUid'];
|
||||
$authSources = new AuthSources();
|
||||
$responseProxy = $authSources->searchGroups($authSourceUid);
|
||||
break;
|
||||
case 'authSourcesImportSaveGroup':
|
||||
$responseProxy['success'] = true;
|
||||
$authSources = new AuthSources();
|
||||
$groupsDN = $_REQUEST['groupsDN'];
|
||||
$authSourceUid = $_REQUEST['authUid'];
|
||||
$responseProxy = $authSources->saveGroups($groupsDN, $authSourceUid);
|
||||
break;
|
||||
default:
|
||||
throw new Exception('The action "' . $action . '" is not allowed');
|
||||
@@ -156,7 +172,7 @@ try {
|
||||
echo json_encode($responseProxy, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
|
||||
} catch (Exception $exception) {
|
||||
$responseProxy['success'] = false;
|
||||
$responseProxy['message'] = $exception->getMessage();
|
||||
$responseProxy['message'] = htmlentities($exception->getMessage(), ENT_QUOTES, 'UTF-8');
|
||||
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode($responseProxy, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
|
||||
|
||||
@@ -306,7 +306,7 @@
|
||||
gridText: "[]",
|
||||
signInPolicyForLDAP: "1",
|
||||
inactiveUsers: "",
|
||||
role: "PROCESSMAKER_OPERATOR",
|
||||
role: "LURANA_OPERATOR",
|
||||
groupIdentifier: "member",
|
||||
userClassIdentifier: "",
|
||||
groupClassIdentifier: "(objectclass=posixgroup)(objectclass=group)(objectclass=groupofuniquenames)",
|
||||
@@ -356,7 +356,7 @@
|
||||
gridText: "[]",
|
||||
signInPolicyForLDAP: "1",
|
||||
inactiveUsers: "",
|
||||
role: "PROCESSMAKER_OPERATOR",
|
||||
role: "LURANA_OPERATOR",
|
||||
groupIdentifier: "member",
|
||||
userClassIdentifier: "",
|
||||
groupClassIdentifier: "(objectclass=posixgroup)(objectclass=group)(objectclass=groupofuniquenames)",
|
||||
@@ -381,7 +381,7 @@
|
||||
let formDataForName = new FormData();
|
||||
formDataForName.append("AUTH_SOURCE_NAME", form.name);
|
||||
//axios.post(this.$root.baseUrl() + "authSources/ldapAdvancedProxy.php?functionAccion=ldapVerifyName", formDataForName)
|
||||
axios.post(this.$root.baseUrl() + "authSources/authSourcesProxy.php?action=authSourcesVerifyName", formDataForName)
|
||||
axios.post(this.$root.baseUrl() + "authSources/authSourcesProxy?action=authSourcesVerifyName", formDataForName)
|
||||
.then(response => {
|
||||
//the name is valid
|
||||
if (response.data.row === false || (this.form.uid !== "" && typeof this.form.uid === "string")) {
|
||||
|
||||
@@ -142,7 +142,7 @@
|
||||
let formData = new FormData();
|
||||
formData.append("AUTH_SOURCE_NAME", this.fileContent.AUTH_SOURCE_NAME);
|
||||
//axios.post(this.$root.baseUrl() + "authSources/ldapAdvancedProxy.php?functionAccion=ldapVerifyName", formData)
|
||||
axios.post(this.$root.baseUrl() + "authSources/authSourcesProxy.php?action=authSourcesVerifyName", formData)
|
||||
axios.post(this.$root.baseUrl() + "authSources/authSourcesProxy?action=authSourcesVerifyName", formData)
|
||||
.then(response => {
|
||||
this.newName = response.data.row === false;
|
||||
this.validationResult = response.data;
|
||||
|
||||
@@ -4,6 +4,8 @@ namespace ProcessMaker\Model;
|
||||
|
||||
use App\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use \Exception;
|
||||
use \G;
|
||||
|
||||
/**
|
||||
* Class Department
|
||||
@@ -15,6 +17,100 @@ class Department extends Model
|
||||
|
||||
// Set our table name
|
||||
protected $table = 'DEPARTMENT';
|
||||
// We do not store timestamps
|
||||
protected $fillable = [
|
||||
'DEP_UID',
|
||||
'DEP_TITLE',
|
||||
'DEP_PARENT',
|
||||
'DEP_MANAGER',
|
||||
'DEP_LOCATION',
|
||||
'DEP_STATUS',
|
||||
'DEP_REF_CODE',
|
||||
'DEP_LDAP_DN'
|
||||
];
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
public function show($filters = array())
|
||||
{
|
||||
try {
|
||||
$query = static::query();
|
||||
|
||||
if (is_array($filters['fields'])) {
|
||||
$query->select($filters['fields']);
|
||||
}
|
||||
|
||||
if (is_array($filters['conditions'])) {
|
||||
if (!empty($filters['conditions']['text'])) {
|
||||
$query->where('DEP_TITLE', 'like', '%' . $filters['conditions']['text'] . '%');
|
||||
unset($filters['conditions']['text']);
|
||||
}
|
||||
$query->where($filters['conditions']);
|
||||
}
|
||||
|
||||
$total = $query->count();
|
||||
|
||||
if (is_array($filters['start']) || is_array($filters['limit'])) {
|
||||
$start = $filters['start'] ?? 0;
|
||||
$limit = $filters['limit'] ?? 25;
|
||||
$query->offset($start)->limit($limit);
|
||||
}
|
||||
|
||||
if (is_array($filters['orderBy'])) {
|
||||
$query->orderBy($filters['orderBy'][0], $filters['orderBy'][1] ?? 'asc');
|
||||
}
|
||||
|
||||
$data = $query->get()->toArray();
|
||||
$result = [
|
||||
'total' => $total,
|
||||
'data' => $data
|
||||
];
|
||||
return $result;
|
||||
} catch (Exception $exception) {
|
||||
return $exception->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
public static function saveData($departmentData)
|
||||
{
|
||||
try {
|
||||
if (empty($departmentData['DEP_UID'])) {
|
||||
$departmentData['DEP_UID'] = G::generateUniqueID();
|
||||
$responseSave = self::create($departmentData);
|
||||
} else {
|
||||
$responseSave = self::where('DEP_UID', $departmentData['DEP_UID'])
|
||||
->update($departmentData);
|
||||
}
|
||||
return $responseSave;
|
||||
} catch (Exception $exception) {
|
||||
return $exception->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
public static function getDepUidIfExistsDN($currentDN)
|
||||
{
|
||||
$query = Department::select(['DEP_UID'])
|
||||
->where('DEP_STATUS', '=', 'ACTIVE')
|
||||
->where('DEP_LDAP_DN', $currentDN);
|
||||
|
||||
$data =$query->get()->toArray();
|
||||
$result = [
|
||||
'total' => count($data),
|
||||
'data' => $data
|
||||
];
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function getDepartmentsWithDN()
|
||||
{
|
||||
$query = Department::select(['DEP_LDAP_DN'])
|
||||
->where('DEP_LDAP_DN', '!=', '')
|
||||
->whereNotNull('DEP_LDAP_DN');
|
||||
|
||||
$data =$query->get()->toArray();
|
||||
$result = [
|
||||
'total' => count($data),
|
||||
'data' => $data
|
||||
];
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ use G;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use ProcessMaker\Model\Groupwf;
|
||||
use ProcessMaker\Model\RbacUsers;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class GroupUser extends Model
|
||||
{
|
||||
@@ -117,4 +118,19 @@ class GroupUser extends Model
|
||||
throw new Exception("Error: {$e->getMessage()}.");
|
||||
}
|
||||
}
|
||||
|
||||
public static function getNumberOfUsersByGroups()
|
||||
{
|
||||
$query = GroupUser::select(['GROUP_USER.GRP_UID', DB::raw('COUNT(GROUP_USER.GRP_UID) AS NUM_REC')])
|
||||
->leftJoin('USERS','USERS.USR_UID','=','GROUP_USER.USR_UID')
|
||||
->where('USERS.USR_STATUS', '!=', 'CLOSED')
|
||||
->groupBy('GROUP_USER.GRP_UID');
|
||||
|
||||
$data =$query->get()->toArray();
|
||||
$result = [
|
||||
'total' => count($data),
|
||||
'data' => $data
|
||||
];
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@ namespace ProcessMaker\Model;
|
||||
|
||||
use App\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use \Exception;
|
||||
use \G;
|
||||
|
||||
class Groupwf extends Model
|
||||
{
|
||||
@@ -11,9 +13,74 @@ class Groupwf extends Model
|
||||
|
||||
protected $table = 'GROUPWF';
|
||||
protected $primaryKey = 'GRP_ID';
|
||||
protected $fillable = [
|
||||
'GRP_UID',
|
||||
'GRP_ID',
|
||||
'GRP_TITLE',
|
||||
'GRP_STATUS',
|
||||
'GRP_STATUS_ID',
|
||||
'GRP_LDAP_DN',
|
||||
'GRP_UX'
|
||||
];
|
||||
// We do not have create/update timestamps for this table
|
||||
public $timestamps = false;
|
||||
|
||||
public function show($filters = array())
|
||||
{
|
||||
try {
|
||||
$query = static::query();
|
||||
|
||||
if (is_array($filters['fields'])) {
|
||||
$query->select($filters['fields']);
|
||||
}
|
||||
|
||||
if (is_array($filters['conditions'])) {
|
||||
if (!empty($filters['conditions']['text'])) {
|
||||
$query->where('GRP_TITLE', 'like', '%' . $filters['conditions']['text'] . '%');
|
||||
unset($filters['conditions']['text']);
|
||||
}
|
||||
$query->where($filters['conditions']);
|
||||
}
|
||||
|
||||
$total = $query->count();
|
||||
|
||||
if (is_array($filters['start']) || is_array($filters['limit'])) {
|
||||
$start = $filters['start'] ?? 0;
|
||||
$limit = $filters['limit'] ?? 25;
|
||||
$query->offset($start)->limit($limit);
|
||||
}
|
||||
|
||||
if (is_array($filters['orderBy'])) {
|
||||
$query->orderBy($filters['orderBy'][0], $filters['orderBy'][1] ?? 'asc');
|
||||
}
|
||||
|
||||
$data =$query->get()->toArray();
|
||||
$result = [
|
||||
'total' => $total,
|
||||
'data' => $data
|
||||
];
|
||||
return $result;
|
||||
} catch (Exception $exception) {
|
||||
return $exception->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
public static function saveData($groupwfData)
|
||||
{
|
||||
try {
|
||||
if (empty($groupwfData['GRP_UID'])) {
|
||||
$groupwfData['GRP_UID'] = G::generateUniqueID();
|
||||
$responseSave = self::create($groupwfData);
|
||||
} else {
|
||||
$responseSave = self::where('GRP_UID', $groupwfData['GRP_UID'])
|
||||
->update($groupwfData);
|
||||
}
|
||||
return $responseSave;
|
||||
} catch (Exception $exception) {
|
||||
return $exception->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to active groups
|
||||
*
|
||||
@@ -72,4 +139,17 @@ class Groupwf extends Model
|
||||
$query = Groupwf::select('GRP_ID')->where('GRP_UID', $grpUid);
|
||||
return $query->first()->toArray();
|
||||
}
|
||||
|
||||
public static function getGroupWithDN($dn)
|
||||
{
|
||||
try {
|
||||
$query = Groupwf::select('GRP_UID')
|
||||
->where('GRP_STATUS', 'ACTIVE')
|
||||
->where('GRP_LDAP_DN', $dn);
|
||||
$response = $query->get()->toArray();
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace ProcessMaker\Model;
|
||||
use App\Factories\HasFactory;
|
||||
use Configurations;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Exception;
|
||||
use RBAC;
|
||||
|
||||
@@ -300,4 +301,20 @@ class User extends Model
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function getNumberOfUsersByDepartments()
|
||||
{
|
||||
$query = User::select(['DEP_UID', DB::raw('COUNT(DEP_UID) AS NUM_REC')])
|
||||
->where('USR_STATUS', '!=', 'CLOSED')
|
||||
->where('DEP_UID', '!=', '')
|
||||
->whereNotNull('DEP_UID')
|
||||
->groupBy('DEP_UID');
|
||||
|
||||
$data =$query->get()->toArray();
|
||||
$result = [
|
||||
'total' => count($data),
|
||||
'data' => $data
|
||||
];
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ Ext.onReady(function() {
|
||||
nodeType: 'async'
|
||||
},
|
||||
maskDisabled: false,
|
||||
dataUrl: 'authSourcesSynchronizeAjax?m=loadDepartments&authUid=' + AUTHENTICATION_SOURCE.AUTH_SOURCE_UID,
|
||||
dataUrl: 'authSourcesProxy?action=authSourcesImportLoadDepartment&authUid=' + AUTHENTICATION_SOURCE.AUTH_SOURCE_UID,
|
||||
requestMethod: 'POST',
|
||||
buttons: [{
|
||||
text: 'Save Changes',
|
||||
@@ -75,8 +75,8 @@ Ext.onReady(function() {
|
||||
departments.push(node.id);
|
||||
});
|
||||
Ext.Ajax.request({
|
||||
url: 'authSourcesSynchronizeAjax',
|
||||
params: {m: 'saveDepartments', authUid: AUTHENTICATION_SOURCE.AUTH_SOURCE_UID, departmentsDN: departments.join('|')},
|
||||
url: 'authSourcesProxy',
|
||||
params: {action: 'authSourcesImportSaveDepartment', authUid: AUTHENTICATION_SOURCE.AUTH_SOURCE_UID, departmentsDN: departments.join('|')},
|
||||
success: function(r) {
|
||||
var response = Ext.util.JSON.decode(r.responseText);
|
||||
if (response.status == 'OK') {
|
||||
@@ -123,7 +123,7 @@ Ext.onReady(function() {
|
||||
root: {
|
||||
nodeType: 'async'
|
||||
},
|
||||
dataUrl: 'authSourcesSynchronizeAjax?m=loadGroups&authUid=' + AUTHENTICATION_SOURCE.AUTH_SOURCE_UID,
|
||||
dataUrl: "authSourcesProxy?action=authSourcesImportLoadGroup&authUid=" + AUTHENTICATION_SOURCE.AUTH_SOURCE_UID,
|
||||
requestMethod: 'POST',
|
||||
buttons: [{
|
||||
text: 'Save Changes',
|
||||
@@ -137,8 +137,8 @@ Ext.onReady(function() {
|
||||
Groups.push(node.id);
|
||||
});
|
||||
Ext.Ajax.request({
|
||||
url: 'authSourcesSynchronizeAjax',
|
||||
params: {m: 'saveGroups', authUid: AUTHENTICATION_SOURCE.AUTH_SOURCE_UID, groupsDN: Groups.join('|')},
|
||||
url: 'authSourcesProxy',
|
||||
params: {action: 'authSourcesImportSaveGroup', authUid: AUTHENTICATION_SOURCE.AUTH_SOURCE_UID, groupsDN: Groups.join('|')},
|
||||
success: function(r) {
|
||||
var response = Ext.util.JSON.decode(r.responseText);
|
||||
if (response.status == 'OK') {
|
||||
|
||||
@@ -1 +1 @@
|
||||
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="/lib/authenticationSources/favicon.ico"><title>authenticationSources</title><script src="/js/ext/translation.en.js"></script><script>var pageSize=10;</script><link href="/lib/authenticationSources/css/app.a1f82e8b.css" rel="preload" as="style"><link href="/lib/authenticationSources/css/chunk-vendors.26dc108e.css" rel="preload" as="style"><link href="/lib/authenticationSources/js/app.4050fbb5.js" rel="preload" as="script"><link href="/lib/authenticationSources/js/chunk-vendors.9b74053c.js" rel="preload" as="script"><link href="/lib/authenticationSources/css/chunk-vendors.26dc108e.css" rel="stylesheet"><link href="/lib/authenticationSources/css/app.a1f82e8b.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but authenticationSources doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div><script src="/lib/authenticationSources/js/chunk-vendors.9b74053c.js"></script><script src="/lib/authenticationSources/js/app.4050fbb5.js"></script></body></html>
|
||||
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="/lib/authenticationSources/favicon.ico"><title>authenticationSources</title><script src="/js/ext/translation.en.js"></script><script>var pageSize=10;</script><link href="/lib/authenticationSources/css/app.a1f82e8b.css" rel="preload" as="style"><link href="/lib/authenticationSources/css/chunk-vendors.26dc108e.css" rel="preload" as="style"><link href="/lib/authenticationSources/js/app.09d204f4.js" rel="preload" as="script"><link href="/lib/authenticationSources/js/chunk-vendors.9b74053c.js" rel="preload" as="script"><link href="/lib/authenticationSources/css/chunk-vendors.26dc108e.css" rel="stylesheet"><link href="/lib/authenticationSources/css/app.a1f82e8b.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but authenticationSources doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div><script src="/lib/authenticationSources/js/chunk-vendors.9b74053c.js"></script><script src="/lib/authenticationSources/js/app.09d204f4.js"></script></body></html>
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user