TASK-290 Add new new command for Auth Sources Cron
This commit is contained in:
11
processmaker
11
processmaker
@@ -9,10 +9,9 @@ require_once __DIR__ . '/bootstrap/app.php';
|
||||
|
||||
$scriptDir = dirname(__FILE__).'/';
|
||||
|
||||
define("PROCESSMAKER_PATH", $scriptDir);
|
||||
define("WORKFLOW_PATH", $scriptDir . 'workflow/');
|
||||
define("WORKFLOW_BIN_PATH", $scriptDir . 'workflow/engine/bin/');
|
||||
error_reporting(error_reporting() & ~E_DEPRECATED & ~E_STRICT);
|
||||
|
||||
include WORKFLOW_BIN_PATH . '/cli.php';
|
||||
define("PROCESSMAKER_PATH", $scriptDir);
|
||||
define("WORKFLOW_PATH", $scriptDir . 'workflow/');
|
||||
define("WORKFLOW_BIN_PATH", $scriptDir . 'workflow/engine/bin/');
|
||||
error_reporting(error_reporting() & ~E_DEPRECATED & ~E_STRICT);
|
||||
|
||||
include WORKFLOW_BIN_PATH . '/cli.php';
|
||||
|
||||
881
workflow/engine/bin/tasks/cliAuthSources.php
Normal file
881
workflow/engine/bin/tasks/cliAuthSources.php
Normal file
File diff suppressed because it is too large
Load Diff
@@ -103,6 +103,7 @@ class CLI
|
||||
public static function help ($args, $opts = null)
|
||||
{
|
||||
global $argv;
|
||||
|
||||
$scriptName = $argv[0];
|
||||
if (is_array($args) && count($args) > 0 ) {
|
||||
$taskName = $args[0];
|
||||
@@ -202,10 +203,12 @@ EOT;
|
||||
CLI::taskName( "help" );
|
||||
CLI::taskRun( array ('self','help'
|
||||
) );
|
||||
|
||||
global $argv;
|
||||
$args = $argv;
|
||||
$cliname = array_shift( $args );
|
||||
$taskName = array_shift( $args );
|
||||
|
||||
if (isset($taskName[0])) {
|
||||
while ($taskName[0] == '-') {
|
||||
$taskName = array_shift( $args );
|
||||
@@ -345,7 +348,7 @@ EOT;
|
||||
* @param string $message the message to display
|
||||
* @param string $filename the log file to write messages
|
||||
*/
|
||||
public static function logging ($message, $filename = null)
|
||||
public static function logging($message, $filename = null, $color = null)
|
||||
{
|
||||
static $log_file = null;
|
||||
if (isset( $filename )) {
|
||||
@@ -355,7 +358,7 @@ EOT;
|
||||
if (isset( $log_file )) {
|
||||
fwrite( $log_file, $message );
|
||||
}
|
||||
echo $message;
|
||||
eprintln($message, $color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -35,11 +35,11 @@ class Department extends Model
|
||||
try {
|
||||
$query = static::query();
|
||||
|
||||
if (is_array($filters['fields'])) {
|
||||
if (!empty($filters['fields']) && is_array($filters['fields'])) {
|
||||
$query->select($filters['fields']);
|
||||
}
|
||||
|
||||
if (is_array($filters['conditions'])) {
|
||||
if (!empty($filters['conditions']) && is_array($filters['conditions'])) {
|
||||
if (!empty($filters['conditions']['text'])) {
|
||||
$query->where('DEP_TITLE', 'like', '%' . $filters['conditions']['text'] . '%');
|
||||
unset($filters['conditions']['text']);
|
||||
@@ -49,13 +49,13 @@ class Department extends Model
|
||||
|
||||
$total = $query->count();
|
||||
|
||||
if (is_array($filters['start']) || is_array($filters['limit'])) {
|
||||
if ((!empty($filters['start']) && is_array($filters['start'])) || (!empty($filters['limit']) && is_array($filters['limit']))) {
|
||||
$start = $filters['start'] ?? 0;
|
||||
$limit = $filters['limit'] ?? 25;
|
||||
$query->offset($start)->limit($limit);
|
||||
}
|
||||
|
||||
if (is_array($filters['orderBy'])) {
|
||||
if (!empty($filters['orderBy']) && is_array($filters['orderBy'])) {
|
||||
$query->orderBy($filters['orderBy'][0], $filters['orderBy'][1] ?? 'asc');
|
||||
}
|
||||
|
||||
|
||||
@@ -133,4 +133,83 @@ class GroupUser extends Model
|
||||
];
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function show($filters = array())
|
||||
{
|
||||
try {
|
||||
$query = static::query();
|
||||
|
||||
if (!empty($filters['fields']) && is_array($filters['fields'])) {
|
||||
$query->select($filters['fields']);
|
||||
}
|
||||
|
||||
if (!empty($filters['conditions']) && is_array($filters['conditions'])) {
|
||||
$query->where($filters['conditions']);
|
||||
}
|
||||
|
||||
$total = $query->count();
|
||||
|
||||
if ((!empty($filters['start']) && is_array($filters['start'])) || (!empty($filters['limit']) && is_array($filters['limit']))) {
|
||||
$start = $filters['start'] ?? 0;
|
||||
$limit = $filters['limit'] ?? 25;
|
||||
$query->offset($start)->limit($limit);
|
||||
}
|
||||
|
||||
if (!empty($filters['orderBy']) && 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 getUsersByGroupId($groupUid, $filters = [])
|
||||
{
|
||||
$query = static::query();
|
||||
|
||||
if (!empty($filters['fields']) && is_array($filters['fields'])) {
|
||||
$query->select($filters['fields']);
|
||||
}
|
||||
|
||||
$query->where('GROUP_USER.GRP_UID', $groupUid);
|
||||
$query->innerJoin('GROUP_USER.USR_UID', '=', 'USERS.USR_UID');
|
||||
|
||||
$total = $query->count();
|
||||
|
||||
if ((!empty($filters['start']) && is_array($filters['start'])) || (!empty($filters['limit']) && is_array($filters['limit']))) {
|
||||
$start = $filters['start'] ?? 0;
|
||||
$limit = $filters['limit'] ?? 25;
|
||||
$query->offset($start)->limit($limit);
|
||||
}
|
||||
|
||||
if (!empty($filters['orderBy']) && is_array($filters['orderBy'])) {
|
||||
$query->orderBy($filters['orderBy'][0], $filters['orderBy'][1] ?? 'asc');
|
||||
}
|
||||
|
||||
$data =$query->get()->toArray();
|
||||
$result = [
|
||||
'total' => $total,
|
||||
'data' => $data
|
||||
];
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function removeGroupUser($conditions)
|
||||
{
|
||||
try {
|
||||
$responseSave = GroupUser::where($conditions)
|
||||
->delete();
|
||||
|
||||
return $responseSave;
|
||||
} catch (Exception $exception) {
|
||||
return $exception->getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,11 +30,11 @@ class Groupwf extends Model
|
||||
try {
|
||||
$query = static::query();
|
||||
|
||||
if (is_array($filters['fields'])) {
|
||||
if (!empty($filters['fields']) && is_array($filters['fields'])) {
|
||||
$query->select($filters['fields']);
|
||||
}
|
||||
|
||||
if (is_array($filters['conditions'])) {
|
||||
if (!empty($filters['conditions']) && is_array($filters['conditions'])) {
|
||||
if (!empty($filters['conditions']['text'])) {
|
||||
$query->where('GRP_TITLE', 'like', '%' . $filters['conditions']['text'] . '%');
|
||||
unset($filters['conditions']['text']);
|
||||
@@ -44,13 +44,13 @@ class Groupwf extends Model
|
||||
|
||||
$total = $query->count();
|
||||
|
||||
if (is_array($filters['start']) || is_array($filters['limit'])) {
|
||||
if ((!empty($filters['start']) && is_array($filters['start'])) || (!empty($filters['limit']) && is_array($filters['limit']))) {
|
||||
$start = $filters['start'] ?? 0;
|
||||
$limit = $filters['limit'] ?? 25;
|
||||
$query->offset($start)->limit($limit);
|
||||
}
|
||||
|
||||
if (is_array($filters['orderBy'])) {
|
||||
if (!empty($filters['orderBy']) && is_array($filters['orderBy'])) {
|
||||
$query->orderBy($filters['orderBy'][0], $filters['orderBy'][1] ?? 'asc');
|
||||
}
|
||||
|
||||
|
||||
@@ -34,11 +34,11 @@ class RbacAuthenticationSource extends Model
|
||||
try {
|
||||
$query = static::query();
|
||||
|
||||
if (is_array($filters['fields'])) {
|
||||
if (!empty($filters['fields']) && is_array($filters['fields'])) {
|
||||
$query->select($filters['fields']);
|
||||
}
|
||||
|
||||
if (is_array($filters['conditions'])) {
|
||||
if (!empty($filters['conditions']) && is_array($filters['conditions'])) {
|
||||
if (!empty($filters['conditions']['text'])) {
|
||||
$query->where('AUTH_SOURCE_NAME', 'like', '%' . $filters['conditions']['text'] . '%');
|
||||
unset($filters['conditions']['text']);
|
||||
@@ -48,13 +48,13 @@ class RbacAuthenticationSource extends Model
|
||||
|
||||
$total = $query->count();
|
||||
|
||||
if (is_array($filters['start']) || is_array($filters['limit'])) {
|
||||
if ((!empty($filters['start']) && is_array($filters['start'])) || (!empty($filters['limit']) && is_array($filters['limit']))) {
|
||||
$start = $filters['start'] ?? 0;
|
||||
$limit = $filters['limit'] ?? 25;
|
||||
$query->offset($start)->limit($limit);
|
||||
}
|
||||
|
||||
if (is_array($filters['orderBy'])) {
|
||||
if (!empty($filters['orderBy']) && is_array($filters['orderBy'])) {
|
||||
$query->orderBy($filters['orderBy'][0], $filters['orderBy'][1] ?? 'asc');
|
||||
}
|
||||
|
||||
|
||||
@@ -20,23 +20,23 @@ class RbacUsers extends Model
|
||||
try {
|
||||
$query = static::query();
|
||||
|
||||
if (is_array($filters['fields'])) {
|
||||
if (!empty($filters['fields']) && is_array($filters['fields'])) {
|
||||
$query->select($filters['fields']);
|
||||
}
|
||||
|
||||
if (is_array($filters['conditions'])) {
|
||||
if (!empty($filters['conditions']) && is_array($filters['conditions'])) {
|
||||
$query->where($filters['conditions']);
|
||||
}
|
||||
|
||||
$total = $query->count();
|
||||
|
||||
if (is_array($filters['start']) || is_array($filters['limit'])) {
|
||||
if ((!empty($filters['start']) && is_array($filters['start'])) || (!empty($filters['limit']) && is_array($filters['limit']))) {
|
||||
$start = $filters['start'] ?? 0;
|
||||
$limit = $filters['limit'] ?? 25;
|
||||
$query->offset($start)->limit($limit);
|
||||
}
|
||||
|
||||
if (is_array($filters['orderBy'])) {
|
||||
if (!empty($filters['orderBy']) && is_array($filters['orderBy'])) {
|
||||
$query->orderBy($filters['orderBy'][0], $filters['orderBy'][1] ?? 'asc');
|
||||
}
|
||||
|
||||
@@ -96,6 +96,17 @@ class RbacUsers extends Model
|
||||
}
|
||||
}
|
||||
|
||||
public static function updateDataFromListUsersUids($userData, $usersUids = [])
|
||||
{
|
||||
try {
|
||||
$responseSave = self::whereIn('USR_UID', $usersUids)
|
||||
->update($userData);
|
||||
return $responseSave;
|
||||
} catch (Exception $exception) {
|
||||
return $exception->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify if username exists
|
||||
*
|
||||
|
||||
@@ -18,6 +18,79 @@ class User extends Model
|
||||
// Our custom timestamp columns
|
||||
const CREATED_AT = 'USR_CREATE_DATE';
|
||||
const UPDATED_AT = 'USR_UPDATE_DATE';
|
||||
public function show($filters = array())
|
||||
{
|
||||
try {
|
||||
$query = static::query();
|
||||
|
||||
if (!empty($filters['fields']) && is_array($filters['fields'])) {
|
||||
$query->select($filters['fields']);
|
||||
}
|
||||
|
||||
if (!empty($filters['conditions']) && is_array($filters['conditions'])) {
|
||||
$query->where($filters['conditions']);
|
||||
}
|
||||
|
||||
$total = $query->count();
|
||||
|
||||
if ((!empty($filters['start']) && is_array($filters['start'])) || (!empty($filters['limit']) && is_array($filters['limit']))) {
|
||||
$start = $filters['start'] ?? 0;
|
||||
$limit = $filters['limit'] ?? 25;
|
||||
$query->offset($start)->limit($limit);
|
||||
}
|
||||
|
||||
if (!empty($filters['orderBy']) && 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 function getByListUids($listUids, $filters = array())
|
||||
{
|
||||
try {
|
||||
$query = static::query();
|
||||
|
||||
if (!empty($filters['fields']) && is_array($filters['fields'])) {
|
||||
$query->select($filters['fields']);
|
||||
}
|
||||
|
||||
if (!empty($filters['conditions']) && is_array($filters['conditions'])) {
|
||||
$query->where($filters['conditions']);
|
||||
}
|
||||
|
||||
$query->whereIn('USR_UID', $listUids);
|
||||
|
||||
$total = $query->count();
|
||||
|
||||
if ((!empty($filters['start']) && is_array($filters['start'])) || (!empty($filters['limit']) && is_array($filters['limit']))) {
|
||||
$start = $filters['start'] ?? 0;
|
||||
$limit = $filters['limit'] ?? 25;
|
||||
$query->offset($start)->limit($limit);
|
||||
}
|
||||
|
||||
if (!empty($filters['orderBy']) && 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();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the delegations this user has (all of them)
|
||||
@@ -317,4 +390,31 @@ class User extends Model
|
||||
];
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function updateData($userData, $conditions = [])
|
||||
{
|
||||
try {
|
||||
$responseSave = self::where($conditions)
|
||||
->update($userData);
|
||||
return $responseSave;
|
||||
} catch (Exception $exception) {
|
||||
return $exception->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
public static function updateDataFromListUsersUids($userData, $usersUids = [], $extraConditions = [])
|
||||
{
|
||||
try {
|
||||
$query = self::whereIn('USR_UID', $usersUids);
|
||||
|
||||
if (!empty($extraConditions) && is_array($extraConditions)) {
|
||||
$query->where($extraConditions);
|
||||
}
|
||||
|
||||
$responseSave = $query->update($userData);
|
||||
return $responseSave;
|
||||
} catch (Exception $exception) {
|
||||
return $exception->getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user