Merged in bugfix/PMC-763 (pull request #6878)

PMC-763
This commit is contained in:
Paula Quispe
2019-05-03 20:30:19 +00:00
committed by Julio Cesar Laura Avendaño
21 changed files with 2078 additions and 18 deletions

View File

@@ -47,7 +47,9 @@
"ralouphie/getallheaders": "^2.0",
"smarty/smarty": "2.6.30",
"pdepend/pdepend": "@stable",
"chumper/zipper": "^1.0"
"chumper/zipper": "^1.0",
"nikic/php-parser": "3.1.5",
"laravel/tinker": "^1.0"
},
"require-dev": {
"fzaninotto/faker": "^1.7",

315
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -21,7 +21,7 @@ return [
Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
Illuminate\Queue\QueueServiceProvider::class,
Illuminate\Translation\TranslationServiceProvider::class,
Laravel\Tinker\TinkerServiceProvider::class,
],
'aliases' => [

View File

@@ -0,0 +1,26 @@
<?php
use Faker\Generator as Faker;
use ProcessMaker\BusinessModel\Cases as BmCases;
$factory->define(\ProcessMaker\Model\Application::class, function(Faker $faker) {
$process = \ProcessMaker\Model\Process::all()->random();
$statuses = ['DRAFT', 'TO_DO'];
$status = $faker->randomElement($statuses);
$statusId = array_search($status, $statuses) + 1;
return [
'APP_UID' => G::generateUniqueID(),
'APP_TITLE' => G::generateUniqueID(),
'APP_NUMBER' => $faker->unique()->numberBetween(1000),
'APP_STATUS' => $status,
'APP_STATUS_ID' => $statusId,
'PRO_UID' => $process->PRO_UID,
'APP_PARALLEL' => 'N',
'APP_INIT_USER' => \ProcessMaker\Model\User::all()->random()->USR_UID,
'APP_CUR_USER' => \ProcessMaker\Model\User::all()->random()->USR_UID,
'APP_PIN' => G::generateUniqueID(),
'APP_CREATE_DATE' => $faker->dateTime(),
'APP_UPDATE_DATE' => $faker->dateTime(),
'APP_INIT_DATE' => $faker->dateTime(),
'APP_DATA' => serialize(['APP_NUMBER' => 12])
];
});

View File

@@ -0,0 +1,38 @@
<?php
use Faker\Generator as Faker;
use ProcessMaker\BusinessModel\Cases as BmCases;
$factory->define(\ProcessMaker\Model\Delegation::class, function(Faker $faker) {
$app = factory(\ProcessMaker\Model\Application::class)->create();
$process = \ProcessMaker\Model\Process::where('PRO_UID', $app->PRO_UID)->first();
$task = $process->tasks->first();
// Grab a user if random
$users = \ProcessMaker\Model\User::all();
if(!count($users)) {
$user = factory(\ProcessMaker\Model\User::class)->create();
} else{
$user = $users->random();
}
return [
'APP_UID' => $app->APP_UID,
'DEL_INDEX' => 1,
'APP_NUMBER' => $app->APP_NUMBER,
'DEL_PREVIOUS' => 0,
'PRO_UID' => $app->PRO_UID,
'TAS_UID' => $task->TAS_UID,
'USR_UID' => $user->USR_UID,
'DEL_TYPE' => 'NORMAL',
'DEL_THREAD' => 1,
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_PRIORITY' => 3,
'DEL_DELEGATE_DATE' => $faker->dateTime(),
'DEL_INIT_DATE' => $faker->dateTime(),
'DEL_TASK_DUE_DATE' => $faker->dateTime(),
'DEL_RISK_DATE' => $faker->dateTime(),
'USR_ID' => $user->USR_ID,
'PRO_ID' => $process->PRO_ID,
'TAS_ID' => $task->TAS_ID,
'DEL_DATA' => ''
];
});

View File

@@ -0,0 +1,14 @@
<?php
/**
* Model factory for a process category
*/
use Faker\Generator as Faker;
$factory->define(\ProcessMaker\Model\ProcessCategory::class, function (Faker $faker) {
return [
'CATEGORY_UID' => G::generateUniqueID(),
'CATEGORY_PARENT' => '',
'CATEGORY_NAME' => $faker->sentence(5),
'CATEGORY_ICON' => '',
];
});

View File

@@ -5,13 +5,56 @@
use Faker\Generator as Faker;
$factory->define(\ProcessMaker\Model\Process::class, function(Faker $faker) {
/**
* @todo Determine if we need more base columns populated
*/
return [
$process = [
'PRO_UID' => G::generateUniqueID(),
'PRO_TITLE' => $faker->sentence(3),
'PRO_DESCRIPTION' => $faker->paragraph(3)
'PRO_DESCRIPTION' => $faker->paragraph(3),
'PRO_CREATE_USER' => '00000000000000000000000000000001',
'PRO_DYNAFORMS' => '',
'PRO_ITEE' => 1,
];
$task1 = factory(\ProcessMaker\Model\Task::class)
->create([
'PRO_UID' => $process['PRO_UID'],
'TAS_START'=>'TRUE'
]);
$task2 = factory(\ProcessMaker\Model\Task::class)
->create([
'PRO_UID' => $process['PRO_UID'],
]);
//routes
factory(\ProcessMaker\Model\Route::class)
->create([
'PRO_UID' => $process['PRO_UID'],
'TAS_UID' => $task2['TAS_UID'],
'ROU_NEXT_TASK' => '-1',
]);
factory(\ProcessMaker\Model\Route::class)
->create([
'PRO_UID' => $process['PRO_UID'],
'TAS_UID' => $task1['TAS_UID'],
'ROU_NEXT_TASK' => $task2['TAS_UID']
]);
//User assignments
factory(\ProcessMaker\Model\TaskUser::class)
->create([
'TAS_UID' => $task1['TAS_UID'],
'USR_UID' => \ProcessMaker\Model\User::all()->random()->USR_UID
]);
factory(\ProcessMaker\Model\TaskUser::class)
->create([
'TAS_UID' => $task2['TAS_UID'],
'USR_UID' => \ProcessMaker\Model\User::all()->random()->USR_UID
]);
return $process;
});

View File

@@ -0,0 +1,22 @@
<?php
/**
* Model factory for a process
*/
use Faker\Generator as Faker;
$factory->define(\ProcessMaker\Model\Route::class, function(Faker $faker) {
return [
'PRO_UID' => function() {
$process = factory(\ProcessMaker\Model\Process::class)->create();
return $process->PRO_UID;
},
'TAS_UID' => function() {
$task = factory(\ProcessMaker\Model\Task::class)->create();
return $task->TAS_UID;
},
'ROU_UID' => G::generateUniqueID(),
'ROU_PARENT' => 0,
'ROU_CASE' => 1,
'ROU_TYPE' => 'SEQUENTIAL'
];
});

View File

@@ -0,0 +1,33 @@
<?php
/**
* Model factory for a process
*/
use Faker\Generator as Faker;
$factory->define(\ProcessMaker\Model\Task::class, function(Faker $faker) {
return [
'PRO_UID' => function() {
$process = factory(\ProcessMaker\Model\Process::class)->create();
return $process->PRO_UID;
},
'TAS_UID' => G::generateUniqueID(),
'TAS_TITLE' => $faker->sentence(2),
'TAS_TYPE' => 'NORMAL',
'TAS_TYPE_DAY' => 1,
'TAS_DURATION' => 1,
'TAS_ASSIGN_TYPE' => 'BALANCED',
'TAS_ASSIGN_VARIABLE' => '@@SYS_NEXT_USER_TO_BE_ASSIGNED',
'TAS_MI_INSTANCE_VARIABLE' => '@@SYS_VAR_TOTAL_INSTANCE',
'TAS_MI_COMPLETE_VARIABLE' => '@@SYS_VAR_TOTAL_INSTANCES_COMPLETE',
'TAS_ASSIGN_LOCATION' => 'FALSE',
'TAS_ASSIGN_LOCATION_ADHOC' => 'FALSE',
'TAS_TRANSFER_FLY' => 'FALSE',
'TAS_LAST_ASSIGNED' => 0,
'TAS_USER' => 0,
'TAS_CAN_UPLOAD' => 'FALSE',
'TAS_CAN_CANCEL' => 'FALSE',
'TAS_OWNER_APP' => 'FALSE',
'TAS_CAN_SEND_MESSAGE' => 'FALSE',
'TAS_SEND_LAST_EMAIL' => 'FALSE',
];
});

View File

@@ -0,0 +1,16 @@
<?php
/**
* Model factory for a process
*/
use Faker\Generator as Faker;
$factory->define(\ProcessMaker\Model\TaskUser::class, function(Faker $faker) {
return [
'TAS_UID' => function() {
$task = factory(\ProcessMaker\Model\Task::class)->create();
return $task->TAS_UID;
},
'TU_TYPE' => 1,
'TU_RELATION' => 1
];
});

View File

@@ -0,0 +1,19 @@
<?php
use Faker\Generator as Faker;
$factory->define(\ProcessMaker\Model\User::class, function(Faker $faker) {
return [
'USR_UID' => G::generateUniqueID(),
'USR_USERNAME' => $faker->unique()->userName,
'USR_PASSWORD' => $faker->password,
'USR_FIRSTNAME' => $faker->firstName,
'USR_LASTNAME' => $faker->lastName,
'USR_EMAIL' => $faker->unique()->email,
'USR_DUE_DATE' => new \Carbon\Carbon(2030,1,1),
'USR_STATUS' => 'ACTIVE',
'USR_ROLE' => $faker->randomElement(['PROCESSMAKER_ADMIN', 'PROCESSMAKER_OPERATOR']),
'USR_UX' => 'NORMAL',
'USR_TIME_ZONE' => 'America/Anguilla',
'USR_DEFAULT_LANG' => 'en',
];
});

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,9 @@
<?php
use ProcessMaker\Model\Delegation;
/**
* Authentication check for session. If not logged in, return json error
*/
if (!isset($_SESSION['USER_LOGGED'])) {
$responseObject = new stdclass();
$responseObject->error = G::LoadTranslation('ID_LOGIN_AGAIN');
@@ -9,31 +14,59 @@ if (!isset($_SESSION['USER_LOGGED'])) {
}
/**
* Do input filtering, although filtering should be done on the frontend rendering, not here
*/
$filter = new InputFilter();
$_GET = $filter->xssFilterHard($_GET);
$_REQUEST = $filter->xssFilterHard($_REQUEST);
$_SESSION['USER_LOGGED'] = $filter->xssFilterHard($_SESSION['USER_LOGGED']);
//Getting the extJs parameters
// Callback in the UI to utilize
$callback = isset($_REQUEST["callback"]) ? $_REQUEST["callback"] : "stcCallback1001";
//This default value was defined in casesList.js
$dir = isset($_REQUEST["dir"]) ? $_REQUEST["dir"] : "DESC";
//This default value was defined in casesList.js
// Sort column
$sort = isset($_REQUEST["sort"]) ? $_REQUEST["sort"] : "APP_NUMBER";
// Sort direction
$dir = isset($_REQUEST["dir"]) ? $_REQUEST["dir"] : "DESC";
// Pagination control
$start = !empty($_REQUEST["start"]) ? $_REQUEST["start"] : 0;
$limit = !empty($_REQUEST["limit"]) ? $_REQUEST["limit"] : 25;
// Our search filter
$filter = isset($_REQUEST["filter"]) ? $_REQUEST["filter"] : "";
// What process
$process = isset($_REQUEST["process"]) ? $_REQUEST["process"] : "";
// What category
$category = isset($_REQUEST["category"]) ? $_REQUEST["category"] : "";
// What status
$status = isset($_REQUEST["status"]) ? strtoupper($_REQUEST["status"]) : "";
$filterStatus = isset($_REQUEST["filterStatus"]) ? strtoupper($_REQUEST["filterStatus"]) : "";
// What user
$user = isset($_REQUEST["user"]) ? $_REQUEST["user"] : "";
// What keywords to search
$search = isset($_REQUEST["search"]) ? $_REQUEST["search"] : "";
// What kind of action
$action = isset($_GET["action"]) ? $_GET["action"] : (isset($_REQUEST["action"]) ? $_REQUEST["action"] : "todo");
// What kind of search
$type = isset($_GET["type"]) ? $_GET["type"] : (isset($_REQUEST["type"]) ? $_REQUEST["type"] : "extjs");
// Date ranges
$dateFrom = isset($_REQUEST["dateFrom"]) ? substr($_REQUEST["dateFrom"], 0, 10) : "";
$dateTo = isset($_REQUEST["dateTo"]) ? substr($_REQUEST["dateTo"], 0, 10) : "";
// First? No idea
$first = isset($_REQUEST["first"]) ? true : false;
$openApplicationUid = (isset($_REQUEST['openApplicationUid']) && $_REQUEST['openApplicationUid'] != '') ?
$_REQUEST['openApplicationUid'] : null;
$search = (!is_null($openApplicationUid)) ? $openApplicationUid : $search;
@@ -67,10 +100,8 @@ try {
break;
}
$apps = new Applications();
if ($action == 'search') {
$data = $apps->searchAll(
$data = Delegation::search(
$userUid,
$start,
$limit,
@@ -85,7 +116,7 @@ try {
$columnSearch
);
} else {
$data = $apps->getAll(
$data = Delegation::search(
$userUid,
$start,
$limit,

View File

@@ -0,0 +1,27 @@
<?php
namespace ProcessMaker\Model;
use Illuminate\Database\Eloquent\Model;
class Application extends Model
{
protected $table = "APPLICATION";
// No timestamps
public $timestamps = false;
public function delegations()
{
return $this->hasMany(Delegation::class, 'APP_UID', 'APP_UID');
}
public function parent()
{
return $this->hasOne(Application::class, 'APP_PARENT', 'APP_UID');
}
public function currentUser()
{
return $this->hasOne(User::class, 'APP_CUR_USER', 'USR_UID');
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -14,8 +14,29 @@ class Process extends Model
{
// Set our table name
protected $table = 'PROCESS';
// We do have a created at, but we don't store an updated at
// Our custom timestamp columns
const CREATED_AT = 'PRO_CREATE_DATE';
const UPDATED_AT = null;
const UPDATED_AT = 'PRO_UPDATE_DATE';
/**
* Retrieve all applications that belong to this process
*/
public function applications()
{
return $this->hasMany(Application::class, 'PRO_ID', 'PRO_ID');
}
}
public function tasks()
{
return $this->hasMany(Task::class, 'PRO_UID', 'PRO_UID');
}
public function creator()
{
return $this->hasOne(User::class, 'PRO_CREATE_USER', 'USR_UID');
}
public function category()
{
return $this->hasOne(ProcessCategory::class, 'PRO_CATEGORY', 'CATEGORY_UID');
}
}

View File

@@ -0,0 +1,19 @@
<?php
namespace ProcessMaker\Model;
use Illuminate\Database\Eloquent\Model;
/**
* Class ProcessCategory
* @package ProcessMaker\Model
*
* Represents a process category object in the system.
*/
class ProcessCategory extends Model
{
// Set our table name
protected $table = 'PROCESS_CATEGORY';
public $timestamps = false;
}

View File

@@ -0,0 +1,19 @@
<?php
namespace ProcessMaker\Model;
use Illuminate\Database\Eloquent\Model;
/**
* Class Process
* @package ProcessMaker\Model
*
* Represents a business process object in the system.
*/
class Route extends Model
{
// Set our table name
protected $table = 'ROUTE';
public $timestamps = false;
}

View File

@@ -0,0 +1,22 @@
<?php
namespace ProcessMaker\Model;
use Illuminate\Database\Eloquent\Model;
class Task extends Model
{
protected $table = 'TASK';
// We do not have create/update timestamps for this table
public $timestamps = false;
public function process()
{
return $this->belongsTo(Process::class, 'PRO_UID', 'PRO_UID');
}
public function delegations()
{
return $this->hasMany(Delegation::class, 'TAS_ID', 'TAS_ID');
}
}

View File

@@ -0,0 +1,12 @@
<?php
namespace ProcessMaker\Model;
use Illuminate\Database\Eloquent\Model;
class TaskUser extends Model
{
protected $table = 'TASK_USER';
public $timestamps = false;
}

View File

@@ -0,0 +1,21 @@
<?php
namespace ProcessMaker\Model;
use Illuminate\Database\Eloquent\Model;
class User extends Model
{
protected $table = "USERS";
// Our custom timestamp columns
const CREATED_AT = 'USR_CREATE_DATE';
const UPDATED_AT = 'USR_UPDATE_DATE';
/**
* Returns the delegations this user has (all of them)
*/
public function delegations()
{
return $this->hasMany(Delegation::class, 'USR_ID', 'USR_ID');
}
}