2020-04-02 08:40:44 -04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace ProcessMaker\Model;
|
|
|
|
|
|
2022-07-21 00:04:21 -04:00
|
|
|
use App\Factories\HasFactory;
|
2020-04-02 08:40:44 -04:00
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
use Illuminate\Support\Facades\DB;
|
2025-09-16 16:03:55 +00:00
|
|
|
use \Exception;
|
|
|
|
|
use \G;
|
2020-04-02 08:40:44 -04:00
|
|
|
|
|
|
|
|
class RbacAuthenticationSource extends Model
|
|
|
|
|
{
|
2025-09-16 16:03:55 +00:00
|
|
|
protected $table = 'RBAC_AUTHENTICATION_SOURCE';
|
|
|
|
|
protected $fillable = [
|
|
|
|
|
'AUTH_SOURCE_UID',
|
|
|
|
|
'AUTH_SOURCE_NAME',
|
|
|
|
|
'AUTH_SOURCE_PROVIDER',
|
|
|
|
|
'AUTH_SOURCE_SERVER_NAME',
|
|
|
|
|
'AUTH_SOURCE_PORT',
|
|
|
|
|
'AUTH_SOURCE_ENABLED_TLS',
|
|
|
|
|
'AUTH_SOURCE_VERSION',
|
|
|
|
|
'AUTH_SOURCE_BASE_DN',
|
|
|
|
|
'AUTH_ANONYMOUS',
|
|
|
|
|
'AUTH_SOURCE_SEARCH_USER',
|
|
|
|
|
'AUTH_SOURCE_PASSWORD',
|
|
|
|
|
'AUTH_SOURCE_ATTRIBUTES',
|
|
|
|
|
'AUTH_SOURCE_OBJECT_CLASSES',
|
|
|
|
|
'AUTH_SOURCE_DATA'
|
|
|
|
|
];
|
2020-04-02 08:40:44 -04:00
|
|
|
public $timestamps = false;
|
|
|
|
|
|
2025-09-16 16:03:55 +00:00
|
|
|
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('AUTH_SOURCE_NAME', '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 remove($conditions)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$query = static::query();
|
|
|
|
|
$query->where($conditions);
|
|
|
|
|
$deleteRows = $query->delete();
|
|
|
|
|
return ['deleteRows' => $deleteRows];
|
|
|
|
|
} catch (Exception $exception) {
|
|
|
|
|
return $exception->getMessage();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static function saveData($authSourceData)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
if (empty($authSourceData['AUTH_SOURCE_UID'])) {
|
|
|
|
|
$authSourceData['AUTH_SOURCE_UID'] = G::generateUniqueID();
|
|
|
|
|
$responseSave = self::create($authSourceData);
|
|
|
|
|
} else {
|
|
|
|
|
$responseSave = self::where('AUTH_SOURCE_UID', $authSourceData['AUTH_SOURCE_UID'])
|
|
|
|
|
->update($authSourceData);
|
|
|
|
|
}
|
|
|
|
|
return $responseSave;
|
|
|
|
|
} catch (Exception $exception) {
|
|
|
|
|
return $exception->getMessage();
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-04-02 08:40:44 -04:00
|
|
|
}
|