HOR-4601
This commit is contained in:
485
workflow/engine/src/ProcessMaker/AuditLog/AuditLog.php
Normal file
485
workflow/engine/src/ProcessMaker/AuditLog/AuditLog.php
Normal file
@@ -0,0 +1,485 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\AuditLog;
|
||||
|
||||
use Bootstrap;
|
||||
use Configurations;
|
||||
use Exception;
|
||||
use G;
|
||||
use ProcessMaker\Core\System;
|
||||
use Symfony\Component\Finder\Finder;
|
||||
|
||||
class AuditLog
|
||||
{
|
||||
private $actions = [];
|
||||
private $columns;
|
||||
private $pageSizeDefault = 20;
|
||||
private $pathGlobalLog;
|
||||
private $userFullname = "";
|
||||
private $userLogged = "";
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
$this->pathGlobalLog = PATH_DATA . 'log';
|
||||
$this->columns = ['date', 'workspace', 'ip', 'id', 'user', 'action', 'description'];
|
||||
|
||||
$this->actions = [
|
||||
"CreateUser" => G::LoadTranslation("ID_CREATE_USER"),
|
||||
"UpdateUser" => G::LoadTranslation("ID_UPDATE_USER"),
|
||||
"DeleteUser" => G::LoadTranslation("ID_DELETE_USER"),
|
||||
"EnableUser" => G::LoadTranslation("ID_ENABLE_USER"),
|
||||
"DisableUser" => G::LoadTranslation("ID_DISABLE_USER"),
|
||||
"AssignAuthenticationSource" => G::LoadTranslation("ID_ASSIGN_AUTHENTICATION_SOURCE"),
|
||||
"AssignUserToGroup" => G::LoadTranslation("ID_ASSIGN_USER_TO_GROUP"),
|
||||
"CreateAuthSource" => G::LoadTranslation("ID_CREATE_AUTH_SOURCE"),
|
||||
"UpdateAuthSource" => G::LoadTranslation("ID_UPDATE_AUTH_SOURCE"),
|
||||
"DeleteAuthSource" => G::LoadTranslation("ID_DELETE_AUTH_SOURCE"),
|
||||
"CreateRole" => G::LoadTranslation("ID_CREATE_ROLE"),
|
||||
"UpdateRole" => G::LoadTranslation("ID_UPDATE_ROLE"),
|
||||
"DeleteRole" => G::LoadTranslation("ID_DELETE_ROLE"),
|
||||
"AssignUserToRole" => G::LoadTranslation("ID_ASSIGN_USER_TO_ROLE"),
|
||||
"DeleteUserToRole" => G::LoadTranslation("ID_DELETE_USER_TO_ROLE"),
|
||||
"AddPermissionToRole" => G::LoadTranslation("ID_ADD_PERMISSION_TO_ROLE"),
|
||||
"DeletePermissionToRole" => G::LoadTranslation("ID_DELETE_PERMISSION_TO_ROLE"),
|
||||
"CreateSkin" => G::LoadTranslation("ID_CREATE_SKIN"),
|
||||
"ImportSkin" => G::LoadTranslation("ID_IMPORT_SKIN"),
|
||||
"ExportSkin" => G::LoadTranslation("ID_EXPORT_SKIN"),
|
||||
"DeleteSkin" => G::LoadTranslation("ID_DELETE_SKIN"),
|
||||
"CreateGroup" => G::LoadTranslation("ID_CREATE_GROUP"),
|
||||
"UpdateGroup" => G::LoadTranslation("ID_UPDATE_GROUP"),
|
||||
"DeleteGroup" => G::LoadTranslation("ID_DELETE_GROUP"),
|
||||
"CreateCategory" => G::LoadTranslation("ID_CREATE_CATEGORY"),
|
||||
"UpdateCategory" => G::LoadTranslation("ID_UPDATE_CATEGORY"),
|
||||
"DeleteCategory" => G::LoadTranslation("ID_DELETE_CATEGORY"),
|
||||
"BuildCache" => G::LoadTranslation("ID_BUILD_CACHE"),
|
||||
"ClearCache" => G::LoadTranslation("ID_CLEAR_CACHE"),
|
||||
"ClearCron" => G::LoadTranslation("ID_CLEAR_CRON"),
|
||||
"UpdateEnvironmentSettings" => G::LoadTranslation("ID_UPDATE_ENVIRONMENT_SETTINGS"),
|
||||
"UpdateLoginSettings" => G::LoadTranslation("ID_UPDATE_LOGIN_SETTINGS"),
|
||||
"EnableHeartBeat" => G::LoadTranslation("ID_ENABLE_HEART_BEAT"),
|
||||
"DisableHeartBeat" => G::LoadTranslation("ID_DISABLE_HEART_BEAT"),
|
||||
"CreatePmtable" => G::LoadTranslation("ID_CREATE_PMTABLE"),
|
||||
"UpdatePmtable" => G::LoadTranslation("ID_UPDATE_PMTABLE"),
|
||||
"DeletePmtable" => G::LoadTranslation("ID_DELETE_PMTABLE"),
|
||||
"AddDataPmtable" => G::LoadTranslation("ID_ADD_DATA_PMTABLE"),
|
||||
"UpdateDataPmtable" => G::LoadTranslation("ID_UPDATE_DATA_PMTABLE"),
|
||||
"DeleteDataPmtable" => G::LoadTranslation("ID_DELETE_DATA_PMTABLE"),
|
||||
"ImportTable" => G::LoadTranslation("ID_IMPORT_TABLE"),
|
||||
"ExportTable" => G::LoadTranslation("ID_EXPORT_TABLE"),
|
||||
"CreateCalendar" => G::LoadTranslation("ID_CREATE_CALENDAR"),
|
||||
"UpdateCalendar" => G::LoadTranslation("ID_UPDATE_CALENDAR"),
|
||||
"DeleteCalendar" => G::LoadTranslation("ID_DELETE_CALENDAR"),
|
||||
"CreateDashletInstance" => G::LoadTranslation("ID_CREATE_DASHLET_INSTANCE"),
|
||||
"UpdateDashletInstance" => G::LoadTranslation("ID_UPDATE_DASHLET_INSTANCE"),
|
||||
"DeleteDashletInstance" => G::LoadTranslation("ID_DELETE_DASHLET_INSTANCE"),
|
||||
"CreateDepartament" => G::LoadTranslation("ID_CREATE_DEPARTAMENT"),
|
||||
"CreateSubDepartament" => G::LoadTranslation("ID_CREATE_SUB_DEPARTAMENT"),
|
||||
"UpdateDepartament" => G::LoadTranslation("ID_UPDATE_DEPARTAMENT"),
|
||||
"UpdateSubDepartament" => G::LoadTranslation("ID_UPDATE_SUB_DEPARTAMENT"),
|
||||
"DeleteDepartament" => G::LoadTranslation("ID_DELETE_DEPARTAMENT"),
|
||||
"AssignManagerToDepartament" => G::LoadTranslation("ID_ASSIGN_MANAGER_TO_DEPARTAMENT"),
|
||||
"AssignUserToDepartament" => G::LoadTranslation("ID_ASSIGN_USER_TO_DEPARTAMENT"),
|
||||
"RemoveUsersFromDepartament" => G::LoadTranslation("ID_REMOVE_USERS_FROM_DEPARTAMENT"),
|
||||
"AssignUserToGroup" => G::LoadTranslation("ID_ASSIGN_USER_TO_GROUP"),
|
||||
"UploadLanguage" => G::LoadTranslation("ID_UPLOAD_LANGUAGE"),
|
||||
"ExportLanguage" => G::LoadTranslation("ID_EXPORT_LANGUAGE"),
|
||||
"DeleteLanguage" => G::LoadTranslation("ID_DELETE_LAGUAGE"),
|
||||
"UploadSystemSettings" => G::LoadTranslation("ID_UPLOAD_SYSTEM_SETTINGS"),
|
||||
"UpdateEmailSettings" => G::LoadTranslation("ID_UPDATE_EMAIL_SETTINGS"),
|
||||
"CreateEmailSettings" => G::LoadTranslation("ID_CREATE_EMAIL_SETTINGS"),
|
||||
"UploadLogo" => G::LoadTranslation("ID_UPLOAD_LOGO"),
|
||||
"DeleteLogo" => G::LoadTranslation("ID_DELETE_LOGO"),
|
||||
"RestoreLogo" => G::LoadTranslation("ID_RESTORE_LOGO"),
|
||||
"ReplaceLogo" => G::LoadTranslation("ID_REPLACE_LOGO"),
|
||||
"InstallPlugin" => G::LoadTranslation("ID_INSTALL_PLUGIN"),
|
||||
"EnablePlugin" => G::LoadTranslation("ID_ENABLE_PLUGIN"),
|
||||
"DisablePlugin" => G::LoadTranslation("ID_DISABLE_PLUGIN"),
|
||||
"RemovePlugin" => G::LoadTranslation("ID_REMOVE_PLUGIN"),
|
||||
"SetColumns" => G::LoadTranslation("ID_SET_COLUMNS"),
|
||||
"EnableAuditLog" => G::LoadTranslation("ID_ENABLE_AUDIT_LOG"),
|
||||
"DisableAuditLog" => G::LoadTranslation("ID_DISABLE_AUDIT_LOG"),
|
||||
"EditProcess" => G::LoadTranslation("ID_EDIT_PROCESS"),
|
||||
"ExportProcess" => G::LoadTranslation("ID_EXPORT_PROCESS"),
|
||||
"WebEntry" => G::LoadTranslation("ID_WEB_ENTRY"),
|
||||
"AssignRole" => G::LoadTranslation("ID_ASSIGN_ROLE"),
|
||||
"RemoveUser" => G::LoadTranslation("ID_REMOVE_USER"),
|
||||
"AddTask" => G::LoadTranslation("ID_ADD_TASK"),
|
||||
"AddSubProcess" => G::LoadTranslation("ID_ADD_SUB_PROCESS"),
|
||||
"SaveTaskPosition" => G::LoadTranslation("ID_SAVE_TASK_POSITION"),
|
||||
"AddHorizontalLine" => G::LoadTranslation("ID_ADD_HORIZONTAL_LINE"),
|
||||
"AddVerticalLine" => G::LoadTranslation("ID_ADD_VERTICAL_LINE"),
|
||||
"SaveGuidePosition" => G::LoadTranslation("ID_SAVE_GUIDE_POSITION"),
|
||||
"DeleteLine" => G::LoadTranslation("ID_DELETE_LINE"),
|
||||
"DeleteLines" => G::LoadTranslation("ID_DELETE_LINES"),
|
||||
"AddText" => G::LoadTranslation("ID_ADD_TEXT"),
|
||||
"UpdateText" => G::LoadTranslation("ID_UPDATE_TEXT"),
|
||||
"SaveTextPosition" => G::LoadTranslation("ID_SAVE_TEXT_POSITION"),
|
||||
"DeleteText" => G::LoadTranslation("ID_DELETE_TEXT"),
|
||||
"ProcessFileManager" => G::LoadTranslation("ID_PROCESS_FILE_MANAGER"),
|
||||
"ProcessPermissions" => G::LoadTranslation("ID_PROCESS_PERMISSIONS"),
|
||||
"DeletePermissions" => G::LoadTranslation("ID_DELETE_PERMISSIONS"),
|
||||
"AssignSupervisorDynaform" => G::LoadTranslation("ID_ASSIGN_SUPERVISOR_DYNAFORM"),
|
||||
"RemoveSupervisorDynaform" => G::LoadTranslation("ID_REMOVE_SUPERVISOR_DYNAFORM"),
|
||||
"AssignSupervisorInput" => G::LoadTranslation("ID_ASSIGN_SUPERVISOR_INPUT"),
|
||||
"RemoveSupervisorInput" => G::LoadTranslation("ID_REMOVE_SUPERVISOR_INPUT"),
|
||||
"CaseTrackers" => G::LoadTranslation("ID_CASE_TRACKERS"),
|
||||
"EditEvent" => G::LoadTranslation("ID_EDIT_EVENT"),
|
||||
"DeleteEvent" => G::LoadTranslation("ID_EVENT_DELETED"),
|
||||
"CreateDynaform" => G::LoadTranslation("ID_CREATE_DYNAFORM"),
|
||||
"UpdateDynaform" => G::LoadTranslation("ID_UPDATE_DYNAFORM"),
|
||||
"DeleteDynaform" => G::LoadTranslation("ID_DELETE_DYNAFORM"),
|
||||
"ConditionsEditorDynaform" => G::LoadTranslation("ID_CONDITIONS_EDITOR_DYNAFORM"),
|
||||
"CreateCaseScheduler" => G::LoadTranslation("ID_CREATE_CASE_SCHEDULER"),
|
||||
"UpdateCaseScheduler" => G::LoadTranslation("ID_UPDATE_CASE_SCHEDULER"),
|
||||
"DeleteCaseScheduler" => G::LoadTranslation("ID_DELETE_CASE_SCHEDULER"),
|
||||
"CreateDatabaseConnection" => G::LoadTranslation("ID_CREATE_DATABASE_CONNECTION"),
|
||||
"UpdateDatabaseConnection" => G::LoadTranslation("ID_UPDATE_DATABASE_CONNECTION"),
|
||||
"DeleteDatabaseConnection" => G::LoadTranslation("ID_DELETE_DATABASE_CONNECTION"),
|
||||
"CreateInputDocument" => G::LoadTranslation("ID_CREATE_INPUT_DOCUMENT"),
|
||||
"UpdateInputDocument" => G::LoadTranslation("ID_UPDATE_INPUT_DOCUMENT"),
|
||||
"DeleteInputDocument" => G::LoadTranslation("ID_DELETE_INPUT_DOCUMENT"),
|
||||
"CreateOutputDocument" => G::LoadTranslation("ID_CREATE_OUTPUT_DOCUMENT"),
|
||||
"UpdateOutputDocument" => G::LoadTranslation("ID_UPDATE_OUTPUT_DOCUMENT"),
|
||||
"DeleteOutputDocument" => G::LoadTranslation("ID_DELETE_OUTPUT_DOCUMENT"),
|
||||
"CreateTrigger" => G::LoadTranslation("ID_CREATE_TRIGGER"),
|
||||
"UpdateTrigger" => G::LoadTranslation("ID_UPDATE_TRIGGER"),
|
||||
"DeleteTrigger" => G::LoadTranslation("ID_DELETE_TRIGGER"),
|
||||
"DerivationRule" => G::LoadTranslation("ID_DERIVATION_RULE"),
|
||||
"DeleteTask" => G::LoadTranslation("ID_DELETE_TASK"),
|
||||
"DeleteSubProcess" => G::LoadTranslation("ID_DELETE_SUB_PROCESS"),
|
||||
"OptionsMenuTask" => G::LoadTranslation("ID_OPTIONS_MENU_TASK"),
|
||||
"SaveTaskProperties" => G::LoadTranslation("ID_SAVE_TASK_PROPERTIES"),
|
||||
"DeleteRoutes" => G::LoadTranslation("ID_DELETE_ROUTES"),
|
||||
"NewConditionFromStep" => G::LoadTranslation("ID_NEW_CONDITION_FROM_STEP"),
|
||||
"AssignTrigger" => G::LoadTranslation("ID_ASSIGN_TRIGGER"),
|
||||
"UpTrigger" => G::LoadTranslation("ID_UP_TRIGGER"),
|
||||
"DownTrigger" => G::LoadTranslation("ID_DOWN_TRIGGER"),
|
||||
"StepDelete" => G::LoadTranslation("ID_STEP_DELETE"),
|
||||
"StepUp" => G::LoadTranslation("ID_STEP_UP"),
|
||||
"StepDown" => G::LoadTranslation("ID_STEP_DOWN"),
|
||||
"SaveNewStep" => G::LoadTranslation("ID_SAVE_NEW_STEP"),
|
||||
"AssignUserTask" => G::LoadTranslation("ID_ASSIGN_USER_TASK"),
|
||||
"AssignGroupTask" => G::LoadTranslation("ID_ASSIGN_GROUP_TASK"),
|
||||
"DeleteUserTask" => G::LoadTranslation("ID_DELETE_USER_TASK"),
|
||||
"DeleteGroupTask" => G::LoadTranslation("ID_DELETE_GROUP_TASK"),
|
||||
"ImportProcess" => G::LoadTranslation("ID_IMPORT_PROCESS"),
|
||||
"DeleteProcess" => G::LoadTranslation("ID_DELETE_PROCESS")
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the identifier of the logged user.
|
||||
*
|
||||
* @param string $userLogged
|
||||
*/
|
||||
function setUserLogged($userLogged)
|
||||
{
|
||||
$this->userLogged = $userLogged;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the full name of the logged user.
|
||||
*
|
||||
* @param string $userFullname
|
||||
*/
|
||||
function setUserFullname($userFullname)
|
||||
{
|
||||
$this->userFullname = $userFullname;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the configuration for the Audit Log.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getConfig()
|
||||
{
|
||||
$configurations = new Configurations();
|
||||
$configPage = $configurations->getConfiguration("auditLogList", "pageSize", null, $this->userLogged);
|
||||
|
||||
$config = [];
|
||||
$config["pageSize"] = isset($configPage["pageSize"]) ? $configPage["pageSize"] : $this->pageSizeDefault;
|
||||
|
||||
return $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the actions for Audit Log.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getActions()
|
||||
{
|
||||
$actions = [];
|
||||
$actions[] = ["ALL", G::LoadTranslation("ID_ALL")];
|
||||
/**
|
||||
* We arrange the arrangement to create an ordered list and that the option
|
||||
* 'All' be found at the beginning.
|
||||
*/
|
||||
asort($this->actions);
|
||||
foreach ($this->actions as $key => $value) {
|
||||
$actions[] = [$key, $value];
|
||||
}
|
||||
return $actions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the data of the files registered by Audit Log.
|
||||
*
|
||||
* @param array $filter
|
||||
* @param int $limit
|
||||
* @param int $start
|
||||
* @return array
|
||||
*/
|
||||
public function getAuditLogData($filter, $limit, $start)
|
||||
{
|
||||
$result = [];
|
||||
$count = 0;
|
||||
|
||||
$files = $this->getFiles($this->pathGlobalLog, 'audit*.log');
|
||||
foreach ($files as $file) {
|
||||
$lines = file($file->getPathname());
|
||||
foreach ($lines as $line) {
|
||||
if ($start <= $count && count($result) < $limit) {
|
||||
$data = $this->lineToObject($line);
|
||||
if ($this->validate($filter, $data)) {
|
||||
$result[] = $this->lineToArray($data);
|
||||
}
|
||||
}
|
||||
$count = $count + 1;
|
||||
}
|
||||
}
|
||||
|
||||
//from workspace
|
||||
$system = System::getSystemConfiguration();
|
||||
$path = PATH_DATA . 'sites' . PATH_SEP . config('system.workspace') . PATH_SEP . 'log' . PATH_SEP;
|
||||
if (isset($system['logs_location']) && !empty($system['logs_location']) && is_dir($system['logs_location'])) {
|
||||
$path = $system['logs_location'];
|
||||
}
|
||||
$files = $this->getFiles($path, 'audit*.log');
|
||||
foreach ($files as $file) {
|
||||
$lines = file($file->getPathname());
|
||||
foreach ($lines as $line) {
|
||||
if ($start <= $count && count($result) < $limit) {
|
||||
/**
|
||||
* processmaker/gulliver/system/class.monologProvider.php
|
||||
* "<%level%> %datetime% %channel% %level_name%: %message% %context% %extra%\n"
|
||||
*/
|
||||
$data = $this->lineToObject($line, '/([A-Z][a-z][a-z]\s{1,2}\d{1,2}\s\d{2}[:]\d{2}[:]\d{2})\s([\w][\w\d\.@-]*)\s(.*)$/');
|
||||
if ($this->validate($filter, $data)) {
|
||||
$result[] = $this->lineToArray($data);
|
||||
}
|
||||
}
|
||||
$count = $count + 1;
|
||||
}
|
||||
}
|
||||
|
||||
return [$count, $result];
|
||||
}
|
||||
|
||||
/**
|
||||
* Register an action for Audit Log.
|
||||
*
|
||||
* @param string $action
|
||||
* @param string $value
|
||||
*/
|
||||
public function register($action, $value = '')
|
||||
{
|
||||
$context = Bootstrap::getDefaultContextLog();
|
||||
$context['usrUid'] = $this->userLogged;
|
||||
$context['usrName'] = $this->userFullname;
|
||||
$context['action'] = $action;
|
||||
$context['description'] = $value;
|
||||
Bootstrap::registerMonolog($action, 200, $action, $context, $context['workspace'], 'audit.log');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Audit Log files.
|
||||
*
|
||||
* @param string $path
|
||||
* @param string $pattern
|
||||
* @param string $dir
|
||||
* @return array
|
||||
*/
|
||||
private function getFiles($path, $pattern = '', $dir = 'ASC')
|
||||
{
|
||||
$finder = new Finder();
|
||||
$finder->files()
|
||||
->in($path)
|
||||
->name($pattern);
|
||||
$files = iterator_to_array($finder->getIterator());
|
||||
uasort($files, function ($a, $b) use ($dir) {
|
||||
$name1 = $a->getFilename();
|
||||
$name2 = $b->getFilename();
|
||||
if ($dir === 'ASC') {
|
||||
return strcmp($name1, $name2);
|
||||
} else {
|
||||
return strcmp($name2, $name1);
|
||||
}
|
||||
});
|
||||
return $files;
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforms a line of content from the file into an object.
|
||||
*
|
||||
* @param string $line
|
||||
* @param string $pattern
|
||||
* @return object
|
||||
*/
|
||||
private function lineToObject($line, $pattern = '|')
|
||||
{
|
||||
$result = [];
|
||||
$data = [];
|
||||
if ($pattern === '|') {
|
||||
$data = explode("|", $line);
|
||||
} else {
|
||||
$data = $this->getDataFromJson($line, $pattern);
|
||||
}
|
||||
|
||||
foreach ($this->columns as $index => $column) {
|
||||
$result[$column] = isset($data[$index]) ? trim($data[$index]) : '';
|
||||
}
|
||||
return (object) $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Json data stored from a line of contents of Audit Log files.
|
||||
*
|
||||
* @param string $line
|
||||
* @param string $pattern
|
||||
* @return array
|
||||
*/
|
||||
private function getDataFromJson($line, $pattern)
|
||||
{
|
||||
/**
|
||||
* $matches[0]: datetime
|
||||
* $matches[1]: channel
|
||||
* $matches[2]: level_name + message + context
|
||||
*/
|
||||
preg_match($pattern, $line, $matches);
|
||||
array_shift($matches);
|
||||
|
||||
if (!isset($matches[2])) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$data = $matches[2];
|
||||
$position = strpos($data, ' {');
|
||||
if ($position === false) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$data = substr($data, $position);
|
||||
$data = str_replace('} {', '}, {', $data);
|
||||
$data = '[' . $data . ']';
|
||||
try {
|
||||
$data = G::json_decode($data);
|
||||
} catch (Exception $e) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$join = [];
|
||||
foreach ($data as $value) {
|
||||
$value = (array) $value;
|
||||
$join = array_merge($join, $value);
|
||||
}
|
||||
$join = (object) $join;
|
||||
|
||||
return [
|
||||
empty($join->timeZone) ? '' : $join->timeZone,
|
||||
empty($join->workspace) ? '' : $join->workspace,
|
||||
empty($join->ip) ? '' : $join->ip,
|
||||
empty($join->usrUid) ? '' : $join->usrUid,
|
||||
empty($join->usrName) ? '' : $join->usrName,
|
||||
empty($join->action) ? '' : $join->action,
|
||||
empty($join->description) ? '' : $join->description
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply filters to an Audit Log record.
|
||||
*
|
||||
* @param array $filter
|
||||
* @param object $data
|
||||
* @return boolean
|
||||
*/
|
||||
private function validate($filter, $data)
|
||||
{
|
||||
$result = true;
|
||||
$date = !empty($data->date) ? $this->mktimeDate($data->date) : 0;
|
||||
if ($filter["workspace"] != $data->workspace) {
|
||||
$result = false;
|
||||
}
|
||||
|
||||
if ($filter["action"] != "ALL") {
|
||||
if ($data->action != $filter["action"]) {
|
||||
$result = false;
|
||||
}
|
||||
}
|
||||
|
||||
if ($filter["dateFrom"] && $date > 0) {
|
||||
if (!($this->mktimeDate($filter["dateFrom"]) <= $date)) {
|
||||
$result = false;
|
||||
}
|
||||
}
|
||||
|
||||
if ($filter["dateTo"] && $date > 0) {
|
||||
if (!($date <= $this->mktimeDate($filter["dateTo"] . " 23:59:59"))) {
|
||||
$result = false;
|
||||
}
|
||||
}
|
||||
|
||||
if ($filter["description"]) {
|
||||
$result = false;
|
||||
$string = $filter["description"];
|
||||
|
||||
if ((stristr($data->date, $string) !== false) ||
|
||||
(stristr($data->ip, $string) !== false) ||
|
||||
(stristr($data->user, $string) !== false) ||
|
||||
(stristr($data->action, $string) !== false) ||
|
||||
(stristr($data->description, $string) !== false)) {
|
||||
$result = true;
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the timestamp of the date given.
|
||||
*
|
||||
* @param string $date
|
||||
* @return int
|
||||
*/
|
||||
private function mktimeDate($date)
|
||||
{
|
||||
$array = getdate(strtotime($date));
|
||||
$mktime = mktime($array["hours"], $array["minutes"], $array["seconds"], $array["mon"], $array["mday"], $array["year"]);
|
||||
return $mktime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtain the corresponding arrangement for the columns of the Audit Log user
|
||||
* interface.
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
private function lineToArray($data)
|
||||
{
|
||||
$action = $data->action;
|
||||
$action = preg_replace('/([A-Z])/', '_$1', $data->action);
|
||||
$action = "ID" . strtoupper($action);
|
||||
$action = G::LoadTranslation($action);
|
||||
return [
|
||||
"DATE" => $data->date,
|
||||
"USER" => $data->user,
|
||||
"IP" => $data->ip,
|
||||
"ACTION" => $action,
|
||||
"DESCRIPTION" => $data->description
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -63,7 +63,8 @@ class Cases
|
||||
*
|
||||
* @param bool $flag Value that set the format
|
||||
*
|
||||
* return void
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function setFormatFieldNameInUppercase($flag)
|
||||
{
|
||||
@@ -79,7 +80,8 @@ class Cases
|
||||
*
|
||||
* @param string $fieldName Field name
|
||||
*
|
||||
* return string Return the field name according the format
|
||||
* @return string, the field name according the format
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getFieldNameByFormatFieldName($fieldName)
|
||||
{
|
||||
@@ -97,6 +99,7 @@ class Cases
|
||||
* @param string $fieldNameForException Field name for the exception
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
private function throwExceptionCaseDoesNotExist($applicationUid, $fieldNameForException)
|
||||
{
|
||||
@@ -112,7 +115,8 @@ class Cases
|
||||
* @param string $delIndex Delegation index
|
||||
* @param string $fieldNameForException Field name for the exception
|
||||
*
|
||||
* return void Throw exception if does not exist the Case in table APPLICATION
|
||||
* @return void
|
||||
* @throws Exception, Throw exception if does not exist the Case in table APPLICATION
|
||||
*/
|
||||
public function throwExceptionIfNotExistsCase($applicationUid, $delIndex, $fieldNameForException)
|
||||
{
|
||||
@@ -143,7 +147,8 @@ class Cases
|
||||
* @param bool $throwException Flag to throw the exception if the main parameters are invalid or do not exist
|
||||
* (TRUE: throw the exception; FALSE: returns FALSE)
|
||||
*
|
||||
* @return array Returns an array with Application record, ThrowTheException/FALSE otherwise
|
||||
* @return array, an array with Application record
|
||||
* @throws Exception, ThrowTheException/FALSE otherwise
|
||||
*/
|
||||
public function getApplicationRecordByPk(
|
||||
$applicationUid,
|
||||
@@ -179,7 +184,8 @@ class Cases
|
||||
* @param bool $throwException Flag to throw the exception if the main parameters are invalid or do not exist
|
||||
* (TRUE: throw the exception; FALSE: returns FALSE)
|
||||
*
|
||||
* @return array Returns an array with AppDelegation record, ThrowTheException/FALSE otherwise
|
||||
* @return array, an array with AppDelegation record
|
||||
* @throws Exception, ThrowTheException/FALSE otherwise
|
||||
*/
|
||||
public function getAppDelegationRecordByPk(
|
||||
$applicationUid,
|
||||
@@ -219,7 +225,8 @@ class Cases
|
||||
* @param string $userUid Unique id of User
|
||||
* @param array $arrayType Type lists
|
||||
*
|
||||
* @return array Return the list counters
|
||||
* @return array, the list counters
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getListCounters($userUid, array $arrayType)
|
||||
{
|
||||
@@ -348,8 +355,10 @@ class Cases
|
||||
* Search cases and get list of cases
|
||||
*
|
||||
* @access public
|
||||
* @param array $dataList , Data for list
|
||||
* @return array $response
|
||||
*
|
||||
* @param array $dataList, Data for list
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getCasesSearch($dataList = array())
|
||||
{
|
||||
@@ -413,7 +422,8 @@ class Cases
|
||||
* @param string $applicationUid Unique id of Case
|
||||
* @param string $userUid Unique id of User
|
||||
*
|
||||
* return array Return an array with data of Case Info
|
||||
* @return object
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getCaseInfo($applicationUid, $userUid)
|
||||
{
|
||||
@@ -652,7 +662,8 @@ class Cases
|
||||
* @param string $applicationUid Unique id of Case
|
||||
* @param string $userUid Unique id of User
|
||||
*
|
||||
* return array Return an array with Task Case
|
||||
* @return array, an array with Task Case
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getTaskCase($applicationUid, $userUid)
|
||||
{
|
||||
@@ -721,7 +732,8 @@ class Cases
|
||||
* @param string $userUid Unique id of Case
|
||||
* @param array $variables
|
||||
*
|
||||
* return array Return an array with Task Case
|
||||
* @return object
|
||||
* @throws Exception
|
||||
*/
|
||||
public function addCase($processUid, $taskUid, $userUid, $variables)
|
||||
{
|
||||
@@ -766,7 +778,8 @@ class Cases
|
||||
* @param string $taskUid Unique id of Case
|
||||
* @param array $variables
|
||||
*
|
||||
* return array Return an array with Task Case
|
||||
* @return object
|
||||
* @throws Exception
|
||||
*/
|
||||
public function addCaseImpersonate($processUid, $userUid, $taskUid, $variables)
|
||||
{
|
||||
@@ -819,7 +832,8 @@ class Cases
|
||||
* @param string $userUidSource Unique id of User Source
|
||||
* @param string $userUid $userUidTarget id of User Target
|
||||
*
|
||||
* return array Return an array with Task Case
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function updateReassignCase($applicationUid, $userUid, $delIndex, $userUidSource, $userUidTarget)
|
||||
{
|
||||
@@ -851,13 +865,12 @@ class Cases
|
||||
* Put cancel case
|
||||
*
|
||||
* @access public
|
||||
* @param string $app_uid , Uid for case
|
||||
* @param string $usr_uid , Uid for user
|
||||
* @param string $del_index , Index for case
|
||||
* @return array
|
||||
* @param string $app_uid, Uid for case
|
||||
* @param string $usr_uid, Uid for user
|
||||
* @param bool|string $del_index
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function putCancelCase($app_uid, $usr_uid, $del_index = false)
|
||||
{
|
||||
@@ -905,12 +918,11 @@ class Cases
|
||||
* @access public
|
||||
* @param string $app_uid , Uid for case
|
||||
* @param string $usr_uid , Uid for user
|
||||
* @param bool|string $del_index , Index for case
|
||||
* @param bool|string $del_index
|
||||
* @param null|string $unpaused_date , Date for unpaused
|
||||
* @return array
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function putPauseCase($app_uid, $usr_uid, $del_index = false, $unpaused_date = null)
|
||||
{
|
||||
@@ -972,10 +984,10 @@ class Cases
|
||||
* @access public
|
||||
* @param string $app_uid , Uid for case
|
||||
* @param string $usr_uid , Uid for user
|
||||
* @param bool|string $del_index , Index for case
|
||||
* @param bool|string $del_index
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function putUnpauseCase($app_uid, $usr_uid, $del_index = false)
|
||||
{
|
||||
@@ -1025,9 +1037,9 @@ class Cases
|
||||
* @param string $appUid , Uid for case
|
||||
* @param string $triUid , Uid for trigger
|
||||
* @param string $userUid , Uid for user
|
||||
* @param bool|string $delIndex , Index for case
|
||||
* @param bool|string $delIndex
|
||||
*
|
||||
* @return array
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function putExecuteTriggerCase($appUid, $triUid, $userUid, $delIndex = false)
|
||||
@@ -1068,12 +1080,11 @@ class Cases
|
||||
* Delete case
|
||||
*
|
||||
* @access public
|
||||
* @param string $app_uid , Uid for case
|
||||
* @param string $usr_uid , Uid user
|
||||
* @return array
|
||||
* @param string $app_uid, Uid for case
|
||||
* @param string $usr_uid, Uid user
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function deleteCase($app_uid, $usr_uid)
|
||||
{
|
||||
@@ -1108,7 +1119,8 @@ class Cases
|
||||
* @param string $delIndex
|
||||
* @param boolean $executeTriggersBeforeAssignment
|
||||
*
|
||||
* return array Return an array with Task Case
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function updateRouteCase($applicationUid, $userUid, $delIndex, $executeTriggersBeforeAssignment)
|
||||
{
|
||||
@@ -1145,7 +1157,9 @@ class Cases
|
||||
* @param string $sApplicationUID Unique id of Case
|
||||
* @param string $sTasKUID Unique id of Activity
|
||||
* @param string $sUserUID Unique id of User
|
||||
*
|
||||
* @return object
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getAllUploadedDocumentsCriteria($sProcessUID, $sApplicationUID, $sTasKUID, $sUserUID)
|
||||
{
|
||||
@@ -1439,7 +1453,7 @@ class Cases
|
||||
return $oCriteria;
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* get all generate document
|
||||
*
|
||||
* @name getAllGeneratedDocumentsCriteria
|
||||
@@ -1447,7 +1461,9 @@ class Cases
|
||||
* @param string $sApplicationUID
|
||||
* @param string $sTasKUID
|
||||
* @param string $sUserUID
|
||||
*
|
||||
* @return object
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getAllGeneratedDocumentsCriteria($sProcessUID, $sApplicationUID, $sTasKUID, $sUserUID)
|
||||
{
|
||||
@@ -1679,7 +1695,9 @@ class Cases
|
||||
* @param array $form
|
||||
* @param array $appData
|
||||
* @param array $caseVariable
|
||||
*
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
private function __getFieldsAndValuesByDynaFormAndAppData(array $form, array $appData, array $caseVariable)
|
||||
{
|
||||
@@ -1721,7 +1739,8 @@ class Cases
|
||||
*
|
||||
* @param type $field
|
||||
* @param type $value
|
||||
* @return type
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getFieldValue($field, $value)
|
||||
{
|
||||
@@ -1740,10 +1759,8 @@ class Cases
|
||||
* @param string $app_uid , Uid for case
|
||||
* @param string $usr_uid , Uid for user
|
||||
* @param string $dynaFormUid , Uid for dynaform
|
||||
* @return array
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
* @return array
|
||||
*/
|
||||
public function getCaseVariables(
|
||||
$app_uid,
|
||||
@@ -1821,8 +1838,8 @@ class Cases
|
||||
* @param string $del_index , Index for case
|
||||
* @param string $usr_uid , Uid for user
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function setCaseVariables($app_uid, $app_data, $dyn_uid = null, $usr_uid, $del_index = 0)
|
||||
{
|
||||
@@ -1909,10 +1926,9 @@ class Cases
|
||||
*
|
||||
* @access public
|
||||
* @param string $app_uid , Uid for case
|
||||
* @return array
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getCaseNotes($app_uid, $usr_uid, $data_get)
|
||||
{
|
||||
@@ -2012,8 +2028,8 @@ class Cases
|
||||
* @param string $app_uid , Uid for case
|
||||
* @param array $app_data , Data for case variables
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function saveCaseNote($app_uid, $usr_uid, $note_content, $send_mail = false)
|
||||
{
|
||||
@@ -2050,7 +2066,8 @@ class Cases
|
||||
*
|
||||
* @param array $record Record
|
||||
*
|
||||
* return array Return an array with data Task
|
||||
* @return array Return an array with data Task
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getTaskDataFromRecord(array $record)
|
||||
{
|
||||
@@ -2080,7 +2097,8 @@ class Cases
|
||||
*
|
||||
* @param string $applicationUid Unique id of Case
|
||||
*
|
||||
* return array Return an array with all Tasks of Case
|
||||
* @return array Return an array with all Tasks of Case
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getTasks($applicationUid)
|
||||
{
|
||||
@@ -2359,7 +2377,7 @@ class Cases
|
||||
* @param string $obj_type , Index for case
|
||||
* @param string $obj_uid , Index for case
|
||||
*
|
||||
* @copyright Colosa - Bolivia
|
||||
* @return void
|
||||
*/
|
||||
public function putExecuteTriggers($app_uid, $del_index, $obj_type, $obj_uid)
|
||||
{
|
||||
@@ -2381,9 +2399,8 @@ class Cases
|
||||
* @access public
|
||||
* @param string $app_uid , Uid for case
|
||||
* @param int $del_index , Index for case
|
||||
* @return array
|
||||
*
|
||||
* @copyright Colosa - Bolivia
|
||||
* @return array
|
||||
*/
|
||||
public function getSteps($app_uid, $del_index)
|
||||
{
|
||||
@@ -2402,6 +2419,14 @@ class Cases
|
||||
return $aField;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function get the status information
|
||||
*
|
||||
* @param object $rsCriteria
|
||||
*
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
private function __getStatusInfoDataByRsCriteria($rsCriteria)
|
||||
{
|
||||
try {
|
||||
@@ -2439,6 +2464,7 @@ class Cases
|
||||
* @param string $userUid Unique id of User
|
||||
*
|
||||
* @return array Return an array with status info Case, array empty otherwise
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getStatusInfo($applicationUid, $delIndex = 0, $userUid = "")
|
||||
{
|
||||
@@ -2633,7 +2659,8 @@ class Cases
|
||||
* @param string $usrUid id of user
|
||||
* @param string $typeView type of view
|
||||
*
|
||||
* return array Return an array with process list that the user can start.
|
||||
* @return array Return an array with process list that the user can start.
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getCasesListStarCase($usrUid, $typeView)
|
||||
{
|
||||
@@ -2655,7 +2682,8 @@ class Cases
|
||||
* @param string $usrUid id of user
|
||||
* @param string $typeView type of view
|
||||
*
|
||||
* return array Return an array with process list that the user can start.
|
||||
* @return array Return an array with process list that the user can start.
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getCasesListBookmarkStarCase($usrUid, $typeView)
|
||||
{
|
||||
@@ -2743,6 +2771,7 @@ class Cases
|
||||
* @param int $limit Limit
|
||||
*
|
||||
* @return array Return Users to reassign
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getUsersToReassign(
|
||||
$userUid,
|
||||
@@ -2934,7 +2963,7 @@ class Cases
|
||||
*
|
||||
* @param array $data
|
||||
*
|
||||
* return json Return an json with the result of the reassigned cases.
|
||||
* @return json Return an json with the result of the reassigned cases.
|
||||
*/
|
||||
|
||||
public function doPostReassign($data)
|
||||
@@ -2999,6 +3028,7 @@ class Cases
|
||||
* @param $value
|
||||
* @param $data
|
||||
* @param string $type
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function validateReassignData($appDelegation, $value, $data, $type = 'DELEGATION_NOT_EXISTS')
|
||||
@@ -3075,12 +3105,13 @@ class Cases
|
||||
}
|
||||
|
||||
/**
|
||||
* if case already routed
|
||||
* If case already routed
|
||||
*
|
||||
* @param type $app_uid
|
||||
* @param type $del_index
|
||||
* @param type $usr_uid
|
||||
* @throws type
|
||||
* @param string $app_uid
|
||||
* @param string $del_index
|
||||
* @param string $usr_uid
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function caseAlreadyRouted($app_uid, $del_index, $usr_uid = '')
|
||||
{
|
||||
@@ -3318,6 +3349,7 @@ class Cases
|
||||
* @param array $rolesPermissions, the roles that we need to review
|
||||
* @param array $objectPermissions, the permissions that we need to review
|
||||
* @param boolean $objectSupervisor, if we need to get all the objects supervisor
|
||||
* @param string $tasUid
|
||||
* @return array
|
||||
*/
|
||||
public function userAuthorization(
|
||||
@@ -3326,7 +3358,8 @@ class Cases
|
||||
$appUid,
|
||||
$rolesPermissions = [],
|
||||
$objectPermissions = [],
|
||||
$objectSupervisor = false
|
||||
$objectSupervisor = false,
|
||||
$tasUid = ''
|
||||
) {
|
||||
$arrayAccess = [];
|
||||
|
||||
@@ -3358,7 +3391,7 @@ class Cases
|
||||
if (count($objectPermissions) > 0) {
|
||||
$case = new ClassesCases();
|
||||
foreach ($objectPermissions as $key => $value) {
|
||||
$resPermission = $case->getAllObjectsFrom($proUid, $appUid, '', $usrUid, $value);
|
||||
$resPermission = $case->getAllObjectsFrom($proUid, $appUid, $tasUid, $usrUid, $value);
|
||||
if (isset($resPermission[$key])) {
|
||||
$arrayAccess['objectPermissions'][$key] = $resPermission[$key];
|
||||
}
|
||||
@@ -3373,8 +3406,8 @@ class Cases
|
||||
* Get Global System Variables
|
||||
* @param array $appData
|
||||
* @param array $dataVariable
|
||||
*
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function getGlobalVariables($appData = array(), $dataVariable = array())
|
||||
{
|
||||
@@ -3435,6 +3468,7 @@ class Cases
|
||||
* @param string $appUid
|
||||
* @param string $userUid
|
||||
* @param string $threadStatus
|
||||
*
|
||||
* @return integer delIndex
|
||||
*/
|
||||
public function getLastParticipatedByUser($appUid, $userUid, $threadStatus = '')
|
||||
@@ -3464,6 +3498,7 @@ class Cases
|
||||
* in parallel cases return the first thread to find
|
||||
* @param string $appUid
|
||||
* @param boolean $checkCaseIsPaused
|
||||
*
|
||||
* @return integer delIndex
|
||||
*/
|
||||
public function getOneLastThread($appUid, $checkCaseIsPaused = false)
|
||||
@@ -3500,6 +3535,7 @@ class Cases
|
||||
* @param string $search , the parameter for search in the table
|
||||
* @param string $additionalClassName , name of the className of pmtable
|
||||
* @param array $additionalColumns , columns related to the custom cases list
|
||||
*
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function getSearchCriteriaListCases(
|
||||
|
||||
@@ -102,11 +102,19 @@ class ChangeLog
|
||||
}
|
||||
if ($index < $start) {
|
||||
$index += $this->updateData(
|
||||
$data, $row, $this->hasPermission($row['DYN_UID']), false);
|
||||
$data,
|
||||
$row,
|
||||
$this->hasPermission($row['DYN_UID']),
|
||||
false
|
||||
);
|
||||
continue;
|
||||
}
|
||||
$a = $this->updateData($data, $row,
|
||||
$this->hasPermission($row['DYN_UID']), true);
|
||||
$a = $this->updateData(
|
||||
$data,
|
||||
$row,
|
||||
$this->hasPermission($row['DYN_UID']),
|
||||
true
|
||||
);
|
||||
$limit-= $a;
|
||||
$index+= $a;
|
||||
}
|
||||
@@ -154,12 +162,12 @@ class ChangeLog
|
||||
$node = new StdClass();
|
||||
$node->field = $key;
|
||||
$previousValue = !isset($this->values[$key]) ? null : $this->values[$key];
|
||||
if(!is_array($previousValue)){
|
||||
if (!is_array($previousValue)) {
|
||||
$node->previousValue = (string) $previousValue;
|
||||
} else {
|
||||
$node->previousValue = "<br />".nl2br(print_r($previousValue, true));
|
||||
}
|
||||
if(!is_array($value)){
|
||||
if (!is_array($value)) {
|
||||
$node->currentValue = (string) $value;
|
||||
} else {
|
||||
$node->currentValue = "<br />".nl2br(print_r($value, true));
|
||||
@@ -250,7 +258,7 @@ class ChangeLog
|
||||
*/
|
||||
private function hasPermission($uid)
|
||||
{
|
||||
if(array_search($uid, $this->reservedSteps)!==false) {
|
||||
if (array_search($uid, $this->reservedSteps)!==false) {
|
||||
return false;
|
||||
}
|
||||
foreach ($this->permissions as $type => $ids) {
|
||||
@@ -260,4 +268,4 @@ class ChangeLog
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,8 +81,10 @@ class OutputDocument
|
||||
$criteria2->add(\ObjectPermissionPeer::OP_OBJ_TYPE, "OUTPUT", \Criteria::EQUAL);
|
||||
$criteria2->add(
|
||||
$criteria2->getNewCriterion(\ObjectPermissionPeer::OP_OBJ_UID, $outputDocumentUid, \Criteria::EQUAL)->addOr(
|
||||
$criteria2->getNewCriterion(\ObjectPermissionPeer::OP_OBJ_UID, "0", \Criteria::EQUAL))->addOr(
|
||||
$criteria2->getNewCriterion(\ObjectPermissionPeer::OP_OBJ_UID, "", \Criteria::EQUAL))
|
||||
$criteria2->getNewCriterion(\ObjectPermissionPeer::OP_OBJ_UID, "0", \Criteria::EQUAL)
|
||||
)->addOr(
|
||||
$criteria2->getNewCriterion(\ObjectPermissionPeer::OP_OBJ_UID, "", \Criteria::EQUAL)
|
||||
)
|
||||
);
|
||||
$criteria2->add(\ObjectPermissionPeer::OP_ACTION, "DELETE", \Criteria::EQUAL);
|
||||
|
||||
@@ -203,16 +205,16 @@ class OutputDocument
|
||||
{
|
||||
try {
|
||||
$oCase = new \Cases();
|
||||
$fields = $oCase->loadCase( $applicationUid );
|
||||
$fields = $oCase->loadCase($applicationUid);
|
||||
$sProcessUID = $fields['PRO_UID'];
|
||||
$sTaskUID = '';
|
||||
$oCriteria = new \ProcessMaker\BusinessModel\Cases();
|
||||
$oCriteria->getAllGeneratedDocumentsCriteria( $sProcessUID, $applicationUid, $sTaskUID, $userUid);
|
||||
$result = array ();
|
||||
$oCriteria->getAllGeneratedDocumentsCriteria($sProcessUID, $applicationUid, $sTaskUID, $userUid);
|
||||
$result = array();
|
||||
global $_DBArray;
|
||||
foreach ($_DBArray['outputDocuments'] as $key => $row) {
|
||||
if (isset( $row['DOC_VERSION'] )) {
|
||||
$docrow = array ();
|
||||
if (isset($row['DOC_VERSION'])) {
|
||||
$docrow = array();
|
||||
$docrow['app_doc_uid'] = $row['APP_DOC_UID'];
|
||||
$docrow['app_doc_filename'] = $row['DOWNLOAD_FILE'];
|
||||
$docrow['doc_uid'] = $row['DOC_UID'];
|
||||
@@ -246,16 +248,16 @@ class OutputDocument
|
||||
$sApplicationUID = $applicationUid;
|
||||
$sUserUID = $userUid;
|
||||
$oCase = new \Cases();
|
||||
$fields = $oCase->loadCase( $sApplicationUID );
|
||||
$fields = $oCase->loadCase($sApplicationUID);
|
||||
$sProcessUID = $fields['PRO_UID'];
|
||||
$sTaskUID = '';
|
||||
$oCaseRest = new \ProcessMaker\BusinessModel\Cases();
|
||||
$oCaseRest->getAllGeneratedDocumentsCriteria( $sProcessUID, $sApplicationUID, $sTaskUID, $sUserUID );
|
||||
$result = array ();
|
||||
$oCaseRest->getAllGeneratedDocumentsCriteria($sProcessUID, $sApplicationUID, $sTaskUID, $sUserUID);
|
||||
$result = array();
|
||||
global $_DBArray;
|
||||
foreach ($_DBArray['outputDocuments'] as $key => $row) {
|
||||
if (isset( $row['DOC_VERSION'] )) {
|
||||
$docrow = array ();
|
||||
if (isset($row['DOC_VERSION'])) {
|
||||
$docrow = array();
|
||||
$docrow['app_doc_uid'] = $row['APP_DOC_UID'];
|
||||
$docrow['app_doc_filename'] = $row['DOWNLOAD_FILE'];
|
||||
$docrow['doc_uid'] = $row['DOC_UID'];
|
||||
@@ -266,8 +268,8 @@ class OutputDocument
|
||||
$docrow['app_doc_index'] = $row['APP_DOC_INDEX'];
|
||||
$docrow['app_doc_link'] = $row['DOWNLOAD_LINK'];
|
||||
if ($docrow['app_doc_uid'] == $applicationDocumentUid) {
|
||||
$oAppDocument = \AppDocumentPeer::retrieveByPK( $applicationDocumentUid, $row['DOC_VERSION'] );
|
||||
if (is_null( $oAppDocument )) {
|
||||
$oAppDocument = \AppDocumentPeer::retrieveByPK($applicationDocumentUid, $row['DOC_VERSION']);
|
||||
if (is_null($oAppDocument)) {
|
||||
throw new \Exception(\G::LoadTranslation("ID_CASES_OUTPUT_DOES_NOT_EXIST", array($applicationDocumentUid)));
|
||||
}
|
||||
$result = $docrow;
|
||||
@@ -413,12 +415,12 @@ class OutputDocument
|
||||
try {
|
||||
$oAppDocumentVersion = new \AppDocument();
|
||||
$lastDocVersion = $oAppDocumentVersion->getLastAppDocVersion($applicationDocumentUid);
|
||||
$oAppDocument = \AppDocumentPeer::retrieveByPK( $applicationDocumentUid, $lastDocVersion);
|
||||
if (is_null( $oAppDocument ) || $oAppDocument->getAppDocStatus() == 'DELETED') {
|
||||
$oAppDocument = \AppDocumentPeer::retrieveByPK($applicationDocumentUid, $lastDocVersion);
|
||||
if (is_null($oAppDocument) || $oAppDocument->getAppDocStatus() == 'DELETED') {
|
||||
throw new \Exception(\G::LoadTranslation("ID_CASES_OUTPUT_DOES_NOT_EXIST", array($applicationDocumentUid)));
|
||||
}
|
||||
$aFields = array ('APP_DOC_UID' => $applicationDocumentUid,'DOC_VERSION' => $lastDocVersion,'APP_DOC_STATUS' => 'DELETED');
|
||||
$oAppDocument->update( $aFields );
|
||||
$aFields = array('APP_DOC_UID' => $applicationDocumentUid,'DOC_VERSION' => $lastDocVersion,'APP_DOC_STATUS' => 'DELETED');
|
||||
$oAppDocument->update($aFields);
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
@@ -443,47 +445,47 @@ class OutputDocument
|
||||
$g = new \G();
|
||||
$g->sessionVarSave();
|
||||
$oCase = new \Cases();
|
||||
$oCase->thisIsTheCurrentUser( $sApplication, $index, $sUserLogged, '', 'casesListExtJs' );
|
||||
$oCase->thisIsTheCurrentUser($sApplication, $index, $sUserLogged, '', 'casesListExtJs');
|
||||
//require_once 'classes/model/OutputDocument.php';
|
||||
$oOutputDocument = new \OutputDocument();
|
||||
$aOD = $oOutputDocument->load( $outputID );
|
||||
$Fields = $oCase->loadCase( $sApplication );
|
||||
$sFilename = preg_replace( '[^A-Za-z0-9_]', '_', \G::replaceDataField( $aOD['OUT_DOC_FILENAME'], $Fields['APP_DATA'] ) );
|
||||
require_once (PATH_TRUNK . "workflow" . PATH_SEP . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "AppFolder.php");
|
||||
require_once (PATH_TRUNK . "workflow" . PATH_SEP . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "AppDocument.php");
|
||||
$aOD = $oOutputDocument->load($outputID);
|
||||
$Fields = $oCase->loadCase($sApplication);
|
||||
$sFilename = preg_replace('[^A-Za-z0-9_]', '_', \G::replaceDataField($aOD['OUT_DOC_FILENAME'], $Fields['APP_DATA']));
|
||||
require_once(PATH_TRUNK . "workflow" . PATH_SEP . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "AppFolder.php");
|
||||
require_once(PATH_TRUNK . "workflow" . PATH_SEP . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "AppDocument.php");
|
||||
//Get the Custom Folder ID (create if necessary)
|
||||
$oFolder = new \AppFolder();
|
||||
$folderId = $oFolder->createFromPath( $aOD['OUT_DOC_DESTINATION_PATH'], $sApplication );
|
||||
$folderId = $oFolder->createFromPath($aOD['OUT_DOC_DESTINATION_PATH'], $sApplication);
|
||||
//Tags
|
||||
$fileTags = $oFolder->parseTags( $aOD['OUT_DOC_TAGS'], $sApplication );
|
||||
$fileTags = $oFolder->parseTags($aOD['OUT_DOC_TAGS'], $sApplication);
|
||||
//Get last Document Version and apply versioning if is enabled
|
||||
$oAppDocument = new \AppDocument();
|
||||
$lastDocVersion = $oAppDocument->getLastDocVersion( $outputID, $sApplication );
|
||||
$oCriteria = new \Criteria( 'workflow' );
|
||||
$oCriteria->add( \AppDocumentPeer::APP_UID, $sApplication );
|
||||
$oCriteria->add( \AppDocumentPeer::DOC_UID, $outputID );
|
||||
$oCriteria->add( \AppDocumentPeer::DOC_VERSION, $lastDocVersion );
|
||||
$oCriteria->add( \AppDocumentPeer::APP_DOC_TYPE, 'OUTPUT' );
|
||||
$oDataset = \AppDocumentPeer::doSelectRS( $oCriteria );
|
||||
$oDataset->setFetchmode( \ResultSet::FETCHMODE_ASSOC );
|
||||
$lastDocVersion = $oAppDocument->getLastDocVersion($outputID, $sApplication);
|
||||
$oCriteria = new \Criteria('workflow');
|
||||
$oCriteria->add(\AppDocumentPeer::APP_UID, $sApplication);
|
||||
$oCriteria->add(\AppDocumentPeer::DOC_UID, $outputID);
|
||||
$oCriteria->add(\AppDocumentPeer::DOC_VERSION, $lastDocVersion);
|
||||
$oCriteria->add(\AppDocumentPeer::APP_DOC_TYPE, 'OUTPUT');
|
||||
$oDataset = \AppDocumentPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
if (($aOD['OUT_DOC_VERSIONING']) && ($lastDocVersion != 0)) {
|
||||
//Create new Version of current output
|
||||
$lastDocVersion ++;
|
||||
if ($aRow = $oDataset->getRow()) {
|
||||
$aFields = array ('APP_DOC_UID' => $aRow['APP_DOC_UID'],'APP_UID' => $sApplication,'DEL_INDEX' => $index,'DOC_UID' => $outputID,'DOC_VERSION' => $lastDocVersion + 1,'USR_UID' => $sUserLogged,'APP_DOC_TYPE' => 'OUTPUT','APP_DOC_CREATE_DATE' => date( 'Y-m-d H:i:s' ),'APP_DOC_FILENAME' => $sFilename,'FOLDER_UID' => $folderId,'APP_DOC_TAGS' => $fileTags);
|
||||
$aFields = array('APP_DOC_UID' => $aRow['APP_DOC_UID'],'APP_UID' => $sApplication,'DEL_INDEX' => $index,'DOC_UID' => $outputID,'DOC_VERSION' => $lastDocVersion + 1,'USR_UID' => $sUserLogged,'APP_DOC_TYPE' => 'OUTPUT','APP_DOC_CREATE_DATE' => date('Y-m-d H:i:s'),'APP_DOC_FILENAME' => $sFilename,'FOLDER_UID' => $folderId,'APP_DOC_TAGS' => $fileTags);
|
||||
$oAppDocument = new \AppDocument();
|
||||
$oAppDocument->create( $aFields );
|
||||
$oAppDocument->create($aFields);
|
||||
$sDocUID = $aRow['APP_DOC_UID'];
|
||||
}
|
||||
} else {
|
||||
////No versioning so Update a current Output or Create new if no exist
|
||||
if ($aRow = $oDataset->getRow()) {
|
||||
//Update
|
||||
$aFields = array ('APP_DOC_UID' => $aRow['APP_DOC_UID'],'APP_UID' => $sApplication,'DEL_INDEX' => $index,'DOC_UID' => $outputID,'DOC_VERSION' => $lastDocVersion,'USR_UID' => $sUserLogged,'APP_DOC_TYPE' => 'OUTPUT','APP_DOC_CREATE_DATE' => date( 'Y-m-d H:i:s' ),'APP_DOC_FILENAME' => $sFilename,'FOLDER_UID' => $folderId,'APP_DOC_TAGS' => $fileTags
|
||||
$aFields = array('APP_DOC_UID' => $aRow['APP_DOC_UID'],'APP_UID' => $sApplication,'DEL_INDEX' => $index,'DOC_UID' => $outputID,'DOC_VERSION' => $lastDocVersion,'USR_UID' => $sUserLogged,'APP_DOC_TYPE' => 'OUTPUT','APP_DOC_CREATE_DATE' => date('Y-m-d H:i:s'),'APP_DOC_FILENAME' => $sFilename,'FOLDER_UID' => $folderId,'APP_DOC_TAGS' => $fileTags
|
||||
);
|
||||
$oAppDocument = new \AppDocument();
|
||||
$oAppDocument->update( $aFields );
|
||||
$oAppDocument->update($aFields);
|
||||
$sDocUID = $aRow['APP_DOC_UID'];
|
||||
} else {
|
||||
//we are creating the appdocument row
|
||||
@@ -491,92 +493,92 @@ class OutputDocument
|
||||
if ($lastDocVersion == 0) {
|
||||
$lastDocVersion ++;
|
||||
}
|
||||
$aFields = array ('APP_UID' => $sApplication,'DEL_INDEX' => $index,'DOC_UID' => $outputID,'DOC_VERSION' => $lastDocVersion,'USR_UID' => $sUserLogged,'APP_DOC_TYPE' => 'OUTPUT','APP_DOC_CREATE_DATE' => date( 'Y-m-d H:i:s' ),'APP_DOC_FILENAME' => $sFilename,'FOLDER_UID' => $folderId,'APP_DOC_TAGS' => $fileTags
|
||||
$aFields = array('APP_UID' => $sApplication,'DEL_INDEX' => $index,'DOC_UID' => $outputID,'DOC_VERSION' => $lastDocVersion,'USR_UID' => $sUserLogged,'APP_DOC_TYPE' => 'OUTPUT','APP_DOC_CREATE_DATE' => date('Y-m-d H:i:s'),'APP_DOC_FILENAME' => $sFilename,'FOLDER_UID' => $folderId,'APP_DOC_TAGS' => $fileTags
|
||||
);
|
||||
$oAppDocument = new \AppDocument();
|
||||
$aFields['APP_DOC_UID'] = $sDocUID = $oAppDocument->create( $aFields );
|
||||
$aFields['APP_DOC_UID'] = $sDocUID = $oAppDocument->create($aFields);
|
||||
}
|
||||
}
|
||||
$sFilename = $aFields['APP_DOC_UID'] . "_" . $lastDocVersion;
|
||||
$pathOutput = PATH_DOCUMENT . \G::getPathFromUID($sApplication) . PATH_SEP . 'outdocs' . PATH_SEP; //G::pr($sFilename);die;
|
||||
\G::mk_dir( $pathOutput );
|
||||
$aProperties = array ();
|
||||
if (! isset( $aOD['OUT_DOC_MEDIA'] )) {
|
||||
\G::mk_dir($pathOutput);
|
||||
$aProperties = array();
|
||||
if (! isset($aOD['OUT_DOC_MEDIA'])) {
|
||||
$aOD['OUT_DOC_MEDIA'] = 'Letter';
|
||||
}
|
||||
if (! isset( $aOD['OUT_DOC_LEFT_MARGIN'] )) {
|
||||
if (! isset($aOD['OUT_DOC_LEFT_MARGIN'])) {
|
||||
$aOD['OUT_DOC_LEFT_MARGIN'] = '15';
|
||||
}
|
||||
if (! isset( $aOD['OUT_DOC_RIGHT_MARGIN'] )) {
|
||||
if (! isset($aOD['OUT_DOC_RIGHT_MARGIN'])) {
|
||||
$aOD['OUT_DOC_RIGHT_MARGIN'] = '15';
|
||||
}
|
||||
if (! isset( $aOD['OUT_DOC_TOP_MARGIN'] )) {
|
||||
if (! isset($aOD['OUT_DOC_TOP_MARGIN'])) {
|
||||
$aOD['OUT_DOC_TOP_MARGIN'] = '15';
|
||||
}
|
||||
if (! isset( $aOD['OUT_DOC_BOTTOM_MARGIN'] )) {
|
||||
if (! isset($aOD['OUT_DOC_BOTTOM_MARGIN'])) {
|
||||
$aOD['OUT_DOC_BOTTOM_MARGIN'] = '15';
|
||||
}
|
||||
$aProperties['media'] = $aOD['OUT_DOC_MEDIA'];
|
||||
$aProperties['margins'] = array ('left' => $aOD['OUT_DOC_LEFT_MARGIN'],'right' => $aOD['OUT_DOC_RIGHT_MARGIN'],'top' => $aOD['OUT_DOC_TOP_MARGIN'],'bottom' => $aOD['OUT_DOC_BOTTOM_MARGIN']
|
||||
$aProperties['margins'] = array('left' => $aOD['OUT_DOC_LEFT_MARGIN'],'right' => $aOD['OUT_DOC_RIGHT_MARGIN'],'top' => $aOD['OUT_DOC_TOP_MARGIN'],'bottom' => $aOD['OUT_DOC_BOTTOM_MARGIN']
|
||||
);
|
||||
if (isset($aOD['OUT_DOC_REPORT_GENERATOR'])) {
|
||||
$aProperties['report_generator'] = $aOD['OUT_DOC_REPORT_GENERATOR'];
|
||||
}
|
||||
$this->generate( $outputID, $Fields['APP_DATA'], $pathOutput, $sFilename, $aOD['OUT_DOC_TEMPLATE'], (boolean) $aOD['OUT_DOC_LANDSCAPE'], $aOD['OUT_DOC_GENERATE'], $aProperties , $applicationUid);
|
||||
$this->generate($outputID, $Fields['APP_DATA'], $pathOutput, $sFilename, $aOD['OUT_DOC_TEMPLATE'], (boolean) $aOD['OUT_DOC_LANDSCAPE'], $aOD['OUT_DOC_GENERATE'], $aProperties, $applicationUid);
|
||||
|
||||
//Plugin Hook PM_UPLOAD_DOCUMENT for upload document
|
||||
$oPluginRegistry = PluginRegistry::loadSingleton();
|
||||
if ($oPluginRegistry->existsTrigger( PM_UPLOAD_DOCUMENT ) && class_exists( 'uploadDocumentData' )) {
|
||||
$triggerDetail = $oPluginRegistry->getTriggerInfo( PM_UPLOAD_DOCUMENT );
|
||||
if ($oPluginRegistry->existsTrigger(PM_UPLOAD_DOCUMENT) && class_exists('uploadDocumentData')) {
|
||||
$triggerDetail = $oPluginRegistry->getTriggerInfo(PM_UPLOAD_DOCUMENT);
|
||||
$aFields['APP_DOC_PLUGIN'] = $triggerDetail->getNamespace();
|
||||
$oAppDocument1 = new \AppDocument();
|
||||
$oAppDocument1->update( $aFields );
|
||||
$oAppDocument1->update($aFields);
|
||||
$sPathName = PATH_DOCUMENT . \G::getPathFromUID($sApplication) . PATH_SEP;
|
||||
$oData['APP_UID'] = $sApplication;
|
||||
$oData['ATTACHMENT_FOLDER'] = true;
|
||||
switch ($aOD['OUT_DOC_GENERATE']) {
|
||||
case "BOTH":
|
||||
$documentData = new \uploadDocumentData( $sApplication, $sUserLogged, $pathOutput . $sFilename . '.pdf', $sFilename . '.pdf', $sDocUID, $oAppDocument->getDocVersion() );
|
||||
$documentData = new \uploadDocumentData($sApplication, $sUserLogged, $pathOutput . $sFilename . '.pdf', $sFilename . '.pdf', $sDocUID, $oAppDocument->getDocVersion());
|
||||
$documentData->sFileType = "PDF";
|
||||
$documentData->bUseOutputFolder = true;
|
||||
$uploadReturn = $oPluginRegistry->executeTriggers( PM_UPLOAD_DOCUMENT, $documentData );
|
||||
$uploadReturn = $oPluginRegistry->executeTriggers(PM_UPLOAD_DOCUMENT, $documentData);
|
||||
if ($uploadReturn) {
|
||||
//Only delete if the file was saved correctly
|
||||
unlink( $pathOutput . $sFilename . '.pdf' );
|
||||
unlink($pathOutput . $sFilename . '.pdf');
|
||||
}
|
||||
$documentData = new \uploadDocumentData( $sApplication, $sUserLogged, $pathOutput . $sFilename . '.doc', $sFilename . '.doc', $sDocUID, $oAppDocument->getDocVersion() );
|
||||
$documentData = new \uploadDocumentData($sApplication, $sUserLogged, $pathOutput . $sFilename . '.doc', $sFilename . '.doc', $sDocUID, $oAppDocument->getDocVersion());
|
||||
$documentData->sFileType = "DOC";
|
||||
$documentData->bUseOutputFolder = true;
|
||||
$uploadReturn = $oPluginRegistry->executeTriggers( PM_UPLOAD_DOCUMENT, $documentData );
|
||||
$uploadReturn = $oPluginRegistry->executeTriggers(PM_UPLOAD_DOCUMENT, $documentData);
|
||||
if ($uploadReturn) {
|
||||
//Only delete if the file was saved correctly
|
||||
unlink( $pathOutput . $sFilename . '.doc' );
|
||||
unlink($pathOutput . $sFilename . '.doc');
|
||||
}
|
||||
break;
|
||||
case "PDF":
|
||||
$documentData = new \uploadDocumentData( $sApplication, $sUserLogged, $pathOutput . $sFilename . '.pdf', $sFilename . '.pdf', $sDocUID, $oAppDocument->getDocVersion() );
|
||||
$documentData = new \uploadDocumentData($sApplication, $sUserLogged, $pathOutput . $sFilename . '.pdf', $sFilename . '.pdf', $sDocUID, $oAppDocument->getDocVersion());
|
||||
$documentData->sFileType = "PDF";
|
||||
$documentData->bUseOutputFolder = true;
|
||||
$uploadReturn = $oPluginRegistry->executeTriggers( PM_UPLOAD_DOCUMENT, $documentData );
|
||||
$uploadReturn = $oPluginRegistry->executeTriggers(PM_UPLOAD_DOCUMENT, $documentData);
|
||||
if ($uploadReturn) {
|
||||
//Only delete if the file was saved correctly
|
||||
unlink( $pathOutput . $sFilename . '.pdf' );
|
||||
unlink($pathOutput . $sFilename . '.pdf');
|
||||
}
|
||||
break;
|
||||
case "DOC":
|
||||
$documentData = new \uploadDocumentData( $sApplication, $sUserLogged, $pathOutput . $sFilename . '.doc', $sFilename . '.doc', $sDocUID, $oAppDocument->getDocVersion() );
|
||||
$documentData = new \uploadDocumentData($sApplication, $sUserLogged, $pathOutput . $sFilename . '.doc', $sFilename . '.doc', $sDocUID, $oAppDocument->getDocVersion());
|
||||
$documentData->sFileType = "DOC";
|
||||
$documentData->bUseOutputFolder = true;
|
||||
$uploadReturn = $oPluginRegistry->executeTriggers( PM_UPLOAD_DOCUMENT, $documentData );
|
||||
$uploadReturn = $oPluginRegistry->executeTriggers(PM_UPLOAD_DOCUMENT, $documentData);
|
||||
if ($uploadReturn) {
|
||||
//Only delete if the file was saved correctly
|
||||
unlink( $pathOutput . $sFilename . '.doc' );
|
||||
unlink($pathOutput . $sFilename . '.doc');
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
$g->sessionVarRestore();
|
||||
$oAppDocument = \AppDocumentPeer::retrieveByPK( $aFields['APP_DOC_UID'], $lastDocVersion);
|
||||
$oAppDocument = \AppDocumentPeer::retrieveByPK($aFields['APP_DOC_UID'], $lastDocVersion);
|
||||
if ($oAppDocument->getAppDocStatus() == 'DELETED') {
|
||||
$oAppDocument->setAppDocStatus('ACTIVE');
|
||||
$oAppDocument->save();
|
||||
@@ -746,7 +748,13 @@ class OutputDocument
|
||||
/* End - Create .pdf */
|
||||
} else {
|
||||
return \PEAR::raiseError(
|
||||
null, G_ERROR_USER_UID, null, null, 'You tried to call to a generate method without send the Output Document UID, fields to use and the file path!', 'G_Error', true
|
||||
null,
|
||||
G_ERROR_USER_UID,
|
||||
null,
|
||||
null,
|
||||
'You tried to call to a generate method without send the Output Document UID, fields to use and the file path!',
|
||||
'G_Error',
|
||||
true
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -764,8 +772,8 @@ class OutputDocument
|
||||
define("MAX_FREE_FRACTION", 1);
|
||||
define('PATH_OUTPUT_FILE_DIRECTORY', PATH_HTML . 'files/' . $sApplication . '/outdocs/');
|
||||
\G::verifyPath(PATH_OUTPUT_FILE_DIRECTORY, true);
|
||||
require_once (PATH_THIRDPARTY . 'html2ps_pdf/config.inc.php');
|
||||
require_once (PATH_THIRDPARTY . 'html2ps_pdf/pipeline.factory.class.php');
|
||||
require_once(PATH_THIRDPARTY . 'html2ps_pdf/config.inc.php');
|
||||
require_once(PATH_THIRDPARTY . 'html2ps_pdf/pipeline.factory.class.php');
|
||||
parse_config_file(PATH_THIRDPARTY . 'html2ps_pdf/html2ps.config');
|
||||
$GLOBALS['g_config'] = array(
|
||||
'cssmedia' => 'screen',
|
||||
@@ -803,14 +811,16 @@ class OutputDocument
|
||||
$GLOBALS['g_config']['pdfSecurity']['openPassword'] != ""
|
||||
) {
|
||||
$GLOBALS['g_config']['pdfSecurity']['openPassword'] = G::decrypt(
|
||||
$GLOBALS['g_config']['pdfSecurity']['openPassword'], $sUID
|
||||
$GLOBALS['g_config']['pdfSecurity']['openPassword'],
|
||||
$sUID
|
||||
);
|
||||
}
|
||||
if (isset($GLOBALS['g_config']['pdfSecurity']['ownerPassword']) &&
|
||||
$GLOBALS['g_config']['pdfSecurity']['ownerPassword'] != ""
|
||||
) {
|
||||
$GLOBALS['g_config']['pdfSecurity']['ownerPassword'] = G::decrypt(
|
||||
$GLOBALS['g_config']['pdfSecurity']['ownerPassword'], $sUID
|
||||
$GLOBALS['g_config']['pdfSecurity']['ownerPassword'],
|
||||
$sUID
|
||||
);
|
||||
}
|
||||
$g_media->set_security($GLOBALS['g_config']['pdfSecurity']);
|
||||
@@ -887,7 +897,7 @@ class OutputDocument
|
||||
}
|
||||
$pipeline->output_driver->set_watermark($watermark_text);
|
||||
if ($watermark_text != '') {
|
||||
$dispatcher = & $pipeline->getDispatcher();
|
||||
$dispatcher = $pipeline->getDispatcher();
|
||||
}
|
||||
if ($GLOBALS['g_config']['debugbox']) {
|
||||
$pipeline->output_driver->set_debug_boxes(true);
|
||||
@@ -964,7 +974,7 @@ class OutputDocument
|
||||
$arrayAllObjectsFrom = $case->getAllObjectsFrom($processUid, $applicationUid, null, $userUid, $action, $delIndex);
|
||||
|
||||
if (array_key_exists('OUTPUT_DOCUMENTS', $arrayAllObjectsFrom) && !empty($arrayAllObjectsFrom['OUTPUT_DOCUMENTS'])) {
|
||||
foreach($arrayAllObjectsFrom['OUTPUT_DOCUMENTS'] as $value) {
|
||||
foreach ($arrayAllObjectsFrom['OUTPUT_DOCUMENTS'] as $value) {
|
||||
if ($value == $appDocumentUid) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\BusinessModel;
|
||||
|
||||
use DynaformHandler;
|
||||
|
||||
class DynaForm
|
||||
{
|
||||
private $arrayFieldDefinition = array(
|
||||
"DYN_UID" => array("type" => "string", "required" => false, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "dynaFormUid"),
|
||||
"DYN_UID" => array("type" => "string", "required" => false, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "dynaFormUid"),
|
||||
|
||||
"DYN_TITLE" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "dynaFormTitle"),
|
||||
"DYN_DESCRIPTION" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "dynaFormDescription"),
|
||||
"DYN_TYPE" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array("xmlform", "grid"), "fieldNameAux" => "dynaFormType"),
|
||||
"DYN_CONTENT" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "dynaFormContent"),
|
||||
"DYN_VERSION" => array("type" => "int", "required" => false, "empty" => true, "defaultValues" => array(1 ,2), "fieldNameAux" => "dynaFormVersion")
|
||||
"DYN_TITLE" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "dynaFormTitle"),
|
||||
"DYN_DESCRIPTION" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "dynaFormDescription"),
|
||||
"DYN_TYPE" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array("xmlform", "grid"), "fieldNameAux" => "dynaFormType"),
|
||||
"DYN_CONTENT" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "dynaFormContent"),
|
||||
"DYN_VERSION" => array("type" => "int", "required" => false, "empty" => true, "defaultValues" => array(1, 2), "fieldNameAux" => "dynaFormVersion")
|
||||
);
|
||||
|
||||
private $formatFieldNameInUppercase = true;
|
||||
@@ -82,7 +84,7 @@ class DynaForm
|
||||
public function getFieldNameByFormatFieldName($fieldName)
|
||||
{
|
||||
try {
|
||||
return ($this->formatFieldNameInUppercase)? strtoupper($fieldName) : strtolower($fieldName);
|
||||
return ($this->formatFieldNameInUppercase) ? strtoupper($fieldName) : strtolower($fieldName);
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
@@ -91,8 +93,8 @@ class DynaForm
|
||||
/**
|
||||
* Verify if exists the title of a DynaForm
|
||||
*
|
||||
* @param string $processUid Unique id of Process
|
||||
* @param string $dynaFormTitle Title
|
||||
* @param string $processUid Unique id of Process
|
||||
* @param string $dynaFormTitle Title
|
||||
* @param string $dynaFormUidExclude Unique id of DynaForm to exclude
|
||||
*
|
||||
* return bool Return true if exists the title of a DynaForm, false otherwise
|
||||
@@ -127,18 +129,18 @@ class DynaForm
|
||||
* Verify if a DynaForm is assigned some Steps
|
||||
*
|
||||
* @param string $dynaFormUid Unique id of DynaForm
|
||||
* @param string $processUid Unique id of Process
|
||||
* @param string $processUid Unique id of Process
|
||||
*
|
||||
* return bool Return true if a DynaForm is assigned some Steps, false otherwise
|
||||
*/
|
||||
public function dynaFormDepends($dynUid, $proUid)
|
||||
{
|
||||
$oCriteria = new \Criteria();
|
||||
$oCriteria->addSelectColumn( \DynaformPeer::DYN_TYPE );
|
||||
$oCriteria->add( \DynaformPeer::DYN_UID, $dynUid );
|
||||
$oCriteria->add( \DynaformPeer::PRO_UID, $proUid );
|
||||
$oDataset = \DynaformPeer::doSelectRS( $oCriteria );
|
||||
$oDataset->setFetchmode( \ResultSet::FETCHMODE_ASSOC );
|
||||
$oCriteria->addSelectColumn(\DynaformPeer::DYN_TYPE);
|
||||
$oCriteria->add(\DynaformPeer::DYN_UID, $dynUid);
|
||||
$oCriteria->add(\DynaformPeer::PRO_UID, $proUid);
|
||||
$oDataset = \DynaformPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
$dataDyna = $oDataset->getRow();
|
||||
|
||||
@@ -146,23 +148,23 @@ class DynaForm
|
||||
$formsDepend = array();
|
||||
|
||||
|
||||
$oCriteria = new \Criteria( 'workflow' );
|
||||
$oCriteria->addSelectColumn( \DynaformPeer::DYN_UID );
|
||||
$oCriteria->addSelectColumn( \DynaformPeer::DYN_TITLE );
|
||||
$oCriteria->add( \DynaformPeer::PRO_UID, $proUid );
|
||||
$oCriteria->add( \DynaformPeer::DYN_TYPE, "xmlform" );
|
||||
$oDataset = \DynaformPeer::doSelectRS( $oCriteria );
|
||||
$oDataset->setFetchmode( \ResultSet::FETCHMODE_ASSOC );
|
||||
$oCriteria = new \Criteria('workflow');
|
||||
$oCriteria->addSelectColumn(\DynaformPeer::DYN_UID);
|
||||
$oCriteria->addSelectColumn(\DynaformPeer::DYN_TITLE);
|
||||
$oCriteria->add(\DynaformPeer::PRO_UID, $proUid);
|
||||
$oCriteria->add(\DynaformPeer::DYN_TYPE, "xmlform");
|
||||
$oDataset = \DynaformPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
while ($oDataset->next()) {
|
||||
$dataForms = $oDataset->getRow();
|
||||
$dynHandler = new DynaformHandler(PATH_DYNAFORM . $proUid . PATH_SEP . $dataForms["DYN_UID"] . ".xml");
|
||||
$dynFields = $dynHandler->getFields();
|
||||
foreach ($dynFields as $field) {
|
||||
$sType = \Step::getAttribute( $field, 'type' );
|
||||
$sType = \Step::getAttribute($field, 'type');
|
||||
if ($sType == 'grid') {
|
||||
$sxmlgrid = \Step::getAttribute( $field, 'xmlgrid' );
|
||||
$aGridInfo = explode( "/", $sxmlgrid );
|
||||
$sxmlgrid = \Step::getAttribute($field, 'xmlgrid');
|
||||
$aGridInfo = explode("/", $sxmlgrid);
|
||||
if ($aGridInfo[0] == $proUid && $aGridInfo[1] == $dynUid) {
|
||||
$formsDepend[] = $dataForms["DYN_TITLE"];
|
||||
}
|
||||
@@ -258,7 +260,7 @@ class DynaForm
|
||||
/**
|
||||
* Throw the exception "The DynaForm doesn't exist"
|
||||
*
|
||||
* @param string $dynaFormUid Unique id of DynaForm
|
||||
* @param string $dynaFormUid Unique id of DynaForm
|
||||
* @param string $fieldNameForException Field name for the exception
|
||||
*
|
||||
* @return void
|
||||
@@ -273,8 +275,8 @@ class DynaForm
|
||||
/**
|
||||
* Verify if doesn't exists the DynaForm in table DYNAFORM
|
||||
*
|
||||
* @param string $dynaFormUid Unique id of DynaForm
|
||||
* @param string $processUid Unique id of Process
|
||||
* @param string $dynaFormUid Unique id of DynaForm
|
||||
* @param string $processUid Unique id of Process
|
||||
* @param string $fieldNameForException Field name for the exception
|
||||
*
|
||||
* return void Throw exception if doesn't exists the DynaForm in table DYNAFORM
|
||||
@@ -305,10 +307,10 @@ class DynaForm
|
||||
/**
|
||||
* Verify if exists the title of a DynaForm
|
||||
*
|
||||
* @param string $processUid Unique id of Process
|
||||
* @param string $dynaFormTitle Title
|
||||
* @param string $processUid Unique id of Process
|
||||
* @param string $dynaFormTitle Title
|
||||
* @param string $fieldNameForException Field name for the exception
|
||||
* @param string $dynaFormUidExclude Unique id of DynaForm to exclude
|
||||
* @param string $dynaFormUidExclude Unique id of DynaForm to exclude
|
||||
*
|
||||
* return void Throw exception if exists the title of a DynaForm
|
||||
*/
|
||||
@@ -326,7 +328,7 @@ class DynaForm
|
||||
/**
|
||||
* Verify if is not grid DynaForm
|
||||
*
|
||||
* @param string $dynaFormUid Unique id of DynaForm
|
||||
* @param string $dynaFormUid Unique id of DynaForm
|
||||
* @param string $fieldNameForException Field name for the exception
|
||||
*
|
||||
* return void Throw exception if is not grid DynaForm
|
||||
@@ -350,9 +352,9 @@ class DynaForm
|
||||
/**
|
||||
* Get DynaForm record
|
||||
*
|
||||
* @param string $dynaFormUid Unique id of DynaForm
|
||||
* @param array $arrayVariableNameForException Variable name for exception
|
||||
* @param bool $throwException Flag to throw the exception if the main parameters are invalid or do not exist
|
||||
* @param string $dynaFormUid Unique id of DynaForm
|
||||
* @param array $arrayVariableNameForException Variable name for exception
|
||||
* @param bool $throwException Flag to throw the exception if the main parameters are invalid or do not exist
|
||||
* (TRUE: throw the exception; FALSE: returns FALSE)
|
||||
*
|
||||
* @return array Returns an array with DynaForm record, ThrowTheException/FALSE otherwise
|
||||
@@ -383,7 +385,7 @@ class DynaForm
|
||||
* Create DynaForm for a Process
|
||||
*
|
||||
* @param string $processUid Unique id of Process
|
||||
* @param array $arrayData Data
|
||||
* @param array $arrayData Data
|
||||
*
|
||||
* return array Return data of the new DynaForm created
|
||||
*/
|
||||
@@ -431,7 +433,7 @@ class DynaForm
|
||||
* Update DynaForm
|
||||
*
|
||||
* @param string $dynaFormUid Unique id of DynaForm
|
||||
* @param array $arrayData Data
|
||||
* @param array $arrayData Data
|
||||
*
|
||||
* return array Return data of the DynaForm updated
|
||||
*/
|
||||
@@ -532,7 +534,7 @@ class DynaForm
|
||||
* Copy/Import a DynaForm
|
||||
*
|
||||
* @param string $processUid Unique id of Process
|
||||
* @param array $arrayData Data
|
||||
* @param array $arrayData Data
|
||||
*
|
||||
* return array Return data of the new DynaForm created
|
||||
*/
|
||||
@@ -578,7 +580,7 @@ class DynaForm
|
||||
$this->throwExceptionIfExistsTitle($processUid, $arrayData["DYN_TITLE"], $this->arrayFieldNameForException["dynaFormTitle"]);
|
||||
|
||||
//Copy/Import Uids
|
||||
$processUidCopyImport = $arrayData["COPY_IMPORT"]["PRJ_UID"];
|
||||
$processUidCopyImport = $arrayData["COPY_IMPORT"]["PRJ_UID"];
|
||||
$dynaFormUidCopyImport = $arrayData["COPY_IMPORT"]["DYN_UID"];
|
||||
|
||||
//Verify data
|
||||
@@ -633,8 +635,8 @@ class DynaForm
|
||||
$dynaFormGrid = new \Dynaform();
|
||||
|
||||
$arrayDataAux = array(
|
||||
"PRO_UID" => $processUid,
|
||||
"DYN_TITLE" => $dynGrdTitleCopyImport . (($this->existsTitle($processUid, $dynGrdTitleCopyImport))? " (" . $arrayData["DYN_TITLE"] . ")" : ""),
|
||||
"PRO_UID" => $processUid,
|
||||
"DYN_TITLE" => $dynGrdTitleCopyImport . (($this->existsTitle($processUid, $dynGrdTitleCopyImport)) ? " (" . $arrayData["DYN_TITLE"] . ")" : ""),
|
||||
"DYN_DESCRIPTION" => $dynGrdDescriptionCopyImport,
|
||||
"DYN_TYPE" => "grid"
|
||||
);
|
||||
@@ -720,7 +722,7 @@ class DynaForm
|
||||
* Create a Dynaform based on a PMTable
|
||||
*
|
||||
* @param string $processUid Unique id of Process
|
||||
* @param array $arrayData Data
|
||||
* @param array $arrayData Data
|
||||
*
|
||||
* return array Return data of the new DynaForm created
|
||||
*/
|
||||
@@ -830,7 +832,7 @@ class DynaForm
|
||||
}
|
||||
|
||||
//Set data
|
||||
$tableUid = $arrayData["PMTABLE"]["TAB_UID"];
|
||||
$tableUid = $arrayData["PMTABLE"]["TAB_UID"];
|
||||
$arrayFields = $arrayData["PMTABLE"]["FIELDS"];
|
||||
|
||||
unset($arrayData["PMTABLE"]);
|
||||
@@ -866,7 +868,7 @@ class DynaForm
|
||||
* Defines the method for create a DynaForm
|
||||
*
|
||||
* @param string $processUid Unique id of Process
|
||||
* @param array $arrayData Data
|
||||
* @param array $arrayData Data
|
||||
*
|
||||
* return array Return data of the new DynaForm created
|
||||
*/
|
||||
@@ -883,14 +885,14 @@ class DynaForm
|
||||
|
||||
if (isset($arrayData["COPY_IMPORT"])) {
|
||||
$count = $count + 1;
|
||||
$msgMethod = $msgMethod . (($msgMethod != "")? ", " : "") . "COPY_IMPORT";
|
||||
$msgMethod = $msgMethod . (($msgMethod != "") ? ", " : "") . "COPY_IMPORT";
|
||||
|
||||
$option = "COPY_IMPORT";
|
||||
}
|
||||
|
||||
if (isset($arrayData["PMTABLE"])) {
|
||||
$count = $count + 1;
|
||||
$msgMethod = $msgMethod . (($msgMethod != "")? ", " : "") . "PMTABLE";
|
||||
$msgMethod = $msgMethod . (($msgMethod != "") ? ", " : "") . "PMTABLE";
|
||||
|
||||
$option = "PMTABLE";
|
||||
}
|
||||
@@ -953,20 +955,22 @@ class DynaForm
|
||||
public function getDynaFormDataFromRecord($record)
|
||||
{
|
||||
try {
|
||||
if ($record["DYN_VERSION"] == 0) {
|
||||
$record["DYN_VERSION"] = 1;
|
||||
if ($record['DYN_VERSION'] === 0) {
|
||||
$record['DYN_VERSION'] = 1;
|
||||
}
|
||||
|
||||
$record["DYN_CONTENT"] = preg_replace("/\\\\u([a-f0-9]{4})/e", "iconv('UCS-4LE','UTF-8',pack('V', hexdec('U$1')))", $record["DYN_CONTENT"]);
|
||||
$record['DYN_CONTENT'] = preg_replace_callback("/\\\\u([a-f0-9]{4})/", function ($m) {
|
||||
return "iconv('UCS-4LE','UTF-8',pack('V', hexdec('U$m[1]')))";
|
||||
}, $record['DYN_CONTENT']);
|
||||
|
||||
return array(
|
||||
$this->getFieldNameByFormatFieldName("DYN_UID") => $record["DYN_UID"],
|
||||
$this->getFieldNameByFormatFieldName("DYN_TITLE") => $record["DYN_TITLE"],
|
||||
$this->getFieldNameByFormatFieldName("DYN_DESCRIPTION") => $record["DYN_DESCRIPTION"] . "",
|
||||
$this->getFieldNameByFormatFieldName("DYN_TYPE") => $record["DYN_TYPE"] . "",
|
||||
$this->getFieldNameByFormatFieldName("DYN_CONTENT") => $record["DYN_CONTENT"] . "",
|
||||
$this->getFieldNameByFormatFieldName("DYN_VERSION") => (int)($record["DYN_VERSION"]),
|
||||
$this->getFieldNameByFormatFieldName("DYN_UPDATE_DATE") => $record["DYN_UPDATE_DATE"]
|
||||
$this->getFieldNameByFormatFieldName('DYN_UID') => $record['DYN_UID'],
|
||||
$this->getFieldNameByFormatFieldName('DYN_TITLE') => $record['DYN_TITLE'],
|
||||
$this->getFieldNameByFormatFieldName('DYN_DESCRIPTION') => $record['DYN_DESCRIPTION'] . '',
|
||||
$this->getFieldNameByFormatFieldName('DYN_TYPE') => $record['DYN_TYPE'] . '',
|
||||
$this->getFieldNameByFormatFieldName('DYN_CONTENT') => $record['DYN_CONTENT'] . '',
|
||||
$this->getFieldNameByFormatFieldName('DYN_VERSION') => (int)$record['DYN_VERSION'],
|
||||
$this->getFieldNameByFormatFieldName('DYN_UPDATE_DATE') => $record['DYN_UPDATE_DATE']
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
@@ -1030,20 +1034,20 @@ class DynaForm
|
||||
$rsCriteria->next();
|
||||
|
||||
$aRow = $rsCriteria->getRow();
|
||||
$contentDecode = json_decode($aRow['DYN_CONTENT'],true);
|
||||
$contentDecode = json_decode($aRow['DYN_CONTENT'], true);
|
||||
|
||||
$content = $contentDecode['items'][0]['items'];
|
||||
|
||||
foreach ($content as $key => $value) {
|
||||
|
||||
$valueType = (isset($value[0]["valueType"])) ? $value[0]["valueType"]:null;
|
||||
$maxLength = (isset($value[0]["maxLength"])) ? $value[0]["maxLength"]:null;
|
||||
$label = (isset($value[0]["label"])) ? $value[0]["label"]:null;
|
||||
$defaultValue = (isset($value[0]["defaultValue"])) ? $value[0]["defaultValue"]:null;
|
||||
$required = (isset($value[0]["required"])) ? $value[0]["required"]:null;
|
||||
$dbConnection = (isset($value[0]["dbConnection"])) ? $value[0]["dbConnection"]:null;
|
||||
$sql = (isset($value[0]["sql"])) ? $value[0]["sql"]:null;
|
||||
$options = (isset($value[0]["options"])) ? $value[0]["options"]:null;
|
||||
$valueType = (isset($value[0]["valueType"])) ? $value[0]["valueType"] : null;
|
||||
$maxLength = (isset($value[0]["maxLength"])) ? $value[0]["maxLength"] : null;
|
||||
$label = (isset($value[0]["label"])) ? $value[0]["label"] : null;
|
||||
$defaultValue = (isset($value[0]["defaultValue"])) ? $value[0]["defaultValue"] : null;
|
||||
$required = (isset($value[0]["required"])) ? $value[0]["required"] : null;
|
||||
$dbConnection = (isset($value[0]["dbConnection"])) ? $value[0]["dbConnection"] : null;
|
||||
$sql = (isset($value[0]["sql"])) ? $value[0]["sql"] : null;
|
||||
$options = (isset($value[0]["options"])) ? $value[0]["options"] : null;
|
||||
|
||||
if (isset($value[0]["variable"])) {
|
||||
$variable = $value[0]["variable"];
|
||||
@@ -1070,19 +1074,19 @@ class DynaForm
|
||||
$maxLengthMerged = ($maxLength == null && $maxLength == '') ? (int)$aRow['VAR_FIELD_SIZE'] : $maxLength;
|
||||
$labelMerged = ($label == null && $label == '') ? $aRow['VAR_LABEL'] : $label;
|
||||
$defaultValueMerged = ($defaultValue == null && $defaultValue == '') ? $aRow['VAR_DEFAULT'] : $defaultValue;
|
||||
$requiredMerged = ($required == null && $required == '') ? ($aRow['VAR_NULL']==1) ? false: true : $required;
|
||||
$requiredMerged = ($required == null && $required == '') ? ($aRow['VAR_NULL'] == 1) ? false : true : $required;
|
||||
$dbConnectionMerged = ($dbConnection == null && $dbConnection == '') ? $aRow['VAR_DBCONNECTION'] : $dbConnection;
|
||||
$sqlMerged = ($sql == null && $sql == '') ? $aRow['VAR_SQL'] : $sql;
|
||||
$optionsMerged = ($options == null && $options == '') ? $aRow['VAR_ACCEPTED_VALUES'] : $options;
|
||||
|
||||
$aVariables = array('valueType' => $valueTypeMerged,
|
||||
'maxLength' => $maxLengthMerged,
|
||||
'label' => $labelMerged,
|
||||
'defaultValue' => $defaultValueMerged,
|
||||
'required' => $requiredMerged,
|
||||
'dbConnection' => $dbConnectionMerged,
|
||||
'sql' => $sqlMerged,
|
||||
'options' => $optionsMerged);
|
||||
'maxLength' => $maxLengthMerged,
|
||||
'label' => $labelMerged,
|
||||
'defaultValue' => $defaultValueMerged,
|
||||
'required' => $requiredMerged,
|
||||
'dbConnection' => $dbConnectionMerged,
|
||||
'sql' => $sqlMerged,
|
||||
'options' => $optionsMerged);
|
||||
|
||||
//fields properties
|
||||
if (isset($value[0]["pickType"])) {
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\BusinessModel\Files;
|
||||
|
||||
abstract class Files
|
||||
{
|
||||
/**
|
||||
* @var string Path of the directory where the files are stored.
|
||||
*/
|
||||
protected $pathFiles;
|
||||
|
||||
/**
|
||||
* Files constructor.
|
||||
*
|
||||
* @param $path
|
||||
*/
|
||||
public function __construct($path)
|
||||
{
|
||||
$this->pathFiles = $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get path files
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPathFiles()
|
||||
{
|
||||
return $this->pathFiles;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This function get the list of the log files
|
||||
*
|
||||
* @param string $filter
|
||||
* @param string $sort
|
||||
* @param int $start
|
||||
* @param int $limit
|
||||
* @param string $dir related to order the column
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
abstract public function getAllFiles(
|
||||
$filter = '',
|
||||
$sort = '',
|
||||
$start = 0,
|
||||
$limit = 20,
|
||||
$dir = 'ASC'
|
||||
);
|
||||
|
||||
/**
|
||||
* Download file
|
||||
*
|
||||
* @param array files
|
||||
*/
|
||||
abstract public function download($files);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,283 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\BusinessModel\Files;
|
||||
|
||||
use Chumper\Zipper\Zipper;
|
||||
use Configurations;
|
||||
use Exception;
|
||||
use G;
|
||||
use ProcessMaker\Core\System;
|
||||
use SplFileInfo;
|
||||
use Symfony\Component\Finder\Finder;
|
||||
|
||||
class FilesLogs extends Files
|
||||
{
|
||||
/**
|
||||
* Date format in list
|
||||
* @var string
|
||||
*/
|
||||
private $dateFormat = 'Y-m-d H:i:s';
|
||||
|
||||
/**
|
||||
* Path of the directory where the files are stored.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $pathData = '';
|
||||
|
||||
/**
|
||||
* FilesLogs constructor .
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$system = System::getSystemConfiguration();
|
||||
$configuration = new Configurations();
|
||||
$generalConfig = $configuration->getConfiguration('ENVIRONMENT_SETTINGS', '');
|
||||
if (isset($generalConfig['casesListDateFormat']) && !empty($generalConfig['casesListDateFormat'])) {
|
||||
$this->setDateFormat($generalConfig['casesListDateFormat']);
|
||||
}
|
||||
$path = PATH_DATA . 'sites' . PATH_SEP . config('system.workspace') . PATH_SEP . 'log' . PATH_SEP;
|
||||
if (isset($system['logs_location']) && !empty($system['logs_location']) && is_dir($system['logs_location'])) {
|
||||
$path = $system['logs_location'];
|
||||
}
|
||||
$this->setPathDataSaveFile(PATH_DATA_PUBLIC);
|
||||
parent::__construct($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Date Format
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDateFormat()
|
||||
{
|
||||
return $this->dateFormat;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Date Format
|
||||
*
|
||||
* @param string $dateFormat
|
||||
*/
|
||||
public function setDateFormat($dateFormat)
|
||||
{
|
||||
$this->dateFormat = $dateFormat;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Path data
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPathDataSaveFile()
|
||||
{
|
||||
return $this->pathData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set path data
|
||||
*
|
||||
* @param string $pathData
|
||||
*/
|
||||
public function setPathDataSaveFile($pathData)
|
||||
{
|
||||
G::mk_dir($pathData);
|
||||
$this->pathData = $pathData;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function get the list of the log files
|
||||
*
|
||||
* @param string $filter
|
||||
* @param string $sort
|
||||
* @param int $start
|
||||
* @param int $limit
|
||||
* @param string $dir related to order the column
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getAllFiles($filter = '', $sort = 'fileCreated', $start = 0, $limit = 20, $dir = 'DESC')
|
||||
{
|
||||
if (!file_exists($this->getPathFiles())) {
|
||||
return [
|
||||
'totalRows' => 0,
|
||||
'data' => []
|
||||
];
|
||||
}
|
||||
|
||||
$finder = new Finder();
|
||||
$finder->files()
|
||||
->in($this->getPathFiles())
|
||||
->name('processmaker*.log')
|
||||
->name('audit*.log');
|
||||
|
||||
if (!empty($filter)) {
|
||||
$finder->filter(function (SplFileInfo $file) use ($filter) {
|
||||
if (stristr($file->getFilename(), $filter) === false &&
|
||||
stristr($file->getSize(), $filter) === false &&
|
||||
stristr($file->getMTime(), $filter) === false
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//get files
|
||||
$iterator = $finder->getIterator();
|
||||
$files = iterator_to_array($iterator);
|
||||
|
||||
//sort files
|
||||
switch ($sort) {
|
||||
case 'fileSize':
|
||||
uasort($files, function (SplFileInfo $a, SplFileInfo $b) use ($dir) {
|
||||
$size1 = $a->getSize();
|
||||
$size2 = $b->getSize();
|
||||
if ($dir === 'ASC') {
|
||||
return $size1 > $size2;
|
||||
} else {
|
||||
return $size1 < $size2;
|
||||
}
|
||||
});
|
||||
break;
|
||||
case 'fileCreated':
|
||||
uasort($files, function ($a, $b) use ($dir) {
|
||||
$time1 = $a->getMTime();
|
||||
$time2 = $b->getMTime();
|
||||
if ($dir === 'ASC') {
|
||||
return $time1 > $time2;
|
||||
} else {
|
||||
return $time1 < $time2;
|
||||
}
|
||||
});
|
||||
break;
|
||||
case 'fileName':
|
||||
default:
|
||||
uasort($files, function ($a, $b) use ($dir) {
|
||||
$name1 = $a->getFilename();
|
||||
$name2 = $b->getFilename();
|
||||
if ($dir === 'ASC') {
|
||||
return strcmp($name1, $name2);
|
||||
} else {
|
||||
return strcmp($name2, $name1);
|
||||
}
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
//count files
|
||||
$total = count($files);
|
||||
|
||||
//limit files
|
||||
$files = array_slice(
|
||||
$files, !empty($start) ? $start : 0, !empty($limit) ? $limit : 20
|
||||
);
|
||||
|
||||
//create out element
|
||||
$result = [];
|
||||
foreach ($files as $file) {
|
||||
$result[] = [
|
||||
'fileName' => $file->getFilename(),
|
||||
'fileSize' => $this->size($file->getSize()),
|
||||
'fileCreated' => date($this->getDateFormat(), $file->getMTime())
|
||||
];
|
||||
}
|
||||
return [
|
||||
'totalRows' => $total,
|
||||
'data' => $result
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the size of a file in bytes to its literal equivalent
|
||||
*
|
||||
* @param int $size file size in bytes
|
||||
* @param string $format
|
||||
* @return string
|
||||
*/
|
||||
private function size($size, $format = null)
|
||||
{
|
||||
$sizes = ['Bytes', 'Kbytes', 'Mbytes', 'Gbytes', 'Tbytes', 'Pbytes', 'Ebytes', 'Zbytes', 'Ybytes'];
|
||||
if ($format === null) {
|
||||
$format = ' % 01.2f % s';
|
||||
}
|
||||
$lastSizesLabel = end($sizes);
|
||||
foreach ($sizes as $sizeLabel) {
|
||||
if ($size < 1024) {
|
||||
break;
|
||||
}
|
||||
if ($sizeLabel !== $lastSizesLabel) {
|
||||
$size /= 1024;
|
||||
}
|
||||
}
|
||||
if ($sizeLabel === $sizes[0]) {
|
||||
// Format bytes
|
||||
$format = '%01d %s';
|
||||
}
|
||||
return sprintf($format, $size, $sizeLabel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create file zip
|
||||
*
|
||||
* @param array $files file name
|
||||
*
|
||||
* @return string path file
|
||||
* @throws Exception
|
||||
*/
|
||||
private function createZip($files)
|
||||
{
|
||||
try {
|
||||
$zipper = new Zipper();
|
||||
$name = str_replace('.log', '.zip', $files[0]);
|
||||
if (count($files) > 1) {
|
||||
$name = 'processmaker_logs.zip';
|
||||
}
|
||||
|
||||
$zipper->zip($this->getPathDataSaveFile() . $name);
|
||||
|
||||
$pathFileLogs = $this->getPathFiles();
|
||||
$pathSep = '/';
|
||||
if (strpos($pathFileLogs, '\\') !== false) {
|
||||
$pathSep = '\\';
|
||||
}
|
||||
if (substr($pathFileLogs, -1, strlen($pathSep)) !== $pathSep) {
|
||||
$pathFileLogs .= $pathSep;
|
||||
}
|
||||
|
||||
foreach ($files as $key => $file) {
|
||||
$info = pathinfo($file);
|
||||
if (file_exists($pathFileLogs . $info['basename'])) {
|
||||
$zipper->add($pathFileLogs . $info['basename']);
|
||||
}
|
||||
}
|
||||
$zipper->close();
|
||||
|
||||
return $this->getPathDataSaveFile() . $name;
|
||||
} catch (Exception $error) {
|
||||
throw $error;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Download log files compressed in a Zip format
|
||||
*
|
||||
* @param array $files files names
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function download($files)
|
||||
{
|
||||
try {
|
||||
$fileZip = $this->createZip($files);
|
||||
|
||||
if (file_exists($fileZip)) {
|
||||
G::streamFile($fileZip, true);
|
||||
} else {
|
||||
throw new Exception('File not exist.');
|
||||
}
|
||||
G::rm_dir($fileZip);
|
||||
} catch (Exception $error) {
|
||||
throw $error;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\BusinessModel;
|
||||
|
||||
use Exception;
|
||||
use GroupUser;
|
||||
use Groupwf;
|
||||
use ProcessMaker\BusinessModel\Process;
|
||||
|
||||
class Group
|
||||
{
|
||||
private $arrayFieldDefinition = array(
|
||||
@@ -29,7 +35,7 @@ class Group
|
||||
foreach ($this->arrayFieldDefinition as $key => $value) {
|
||||
$this->arrayFieldNameForException[$value["fieldNameAux"]] = $key;
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -47,7 +53,7 @@ class Group
|
||||
$this->formatFieldNameInUppercase = $flag;
|
||||
|
||||
$this->setArrayFieldNameForException($this->arrayFieldNameForException);
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -65,7 +71,7 @@ class Group
|
||||
foreach ($arrayData as $key => $value) {
|
||||
$this->arrayFieldNameForException[$key] = $this->getFieldNameByFormatFieldName($value);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -81,7 +87,7 @@ class Group
|
||||
{
|
||||
try {
|
||||
return ($this->formatFieldNameInUppercase)? strtoupper($fieldName) : strtolower($fieldName);
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -117,7 +123,7 @@ class Group
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -133,12 +139,12 @@ class Group
|
||||
public function throwExceptionIfNotExistsGroup($groupUid, $fieldNameForException)
|
||||
{
|
||||
try {
|
||||
$group = new \Groupwf();
|
||||
$group = new Groupwf();
|
||||
|
||||
if (!$group->GroupwfExists($groupUid)) {
|
||||
throw new \Exception(\G::LoadTranslation("ID_GROUP_DOES_NOT_EXIST", array($fieldNameForException, $groupUid)));
|
||||
throw new Exception(\G::LoadTranslation("ID_GROUP_DOES_NOT_EXIST", array($fieldNameForException, $groupUid)));
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -156,9 +162,9 @@ class Group
|
||||
{
|
||||
try {
|
||||
if ($this->existsTitle($groupTitle, $groupUidExclude)) {
|
||||
throw new \Exception(\G::LoadTranslation("ID_GROUP_TITLE_ALREADY_EXISTS", array($fieldNameForException, $groupTitle)));
|
||||
throw new Exception(\G::LoadTranslation("ID_GROUP_TITLE_ALREADY_EXISTS", array($fieldNameForException, $groupTitle)));
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -166,38 +172,39 @@ class Group
|
||||
/**
|
||||
* Create Group
|
||||
*
|
||||
* @param array $arrayData Data
|
||||
* @param array $arrayData Information of group
|
||||
*
|
||||
* return array Return data of the new Group created
|
||||
* @return array Return data of the new Group created
|
||||
* @throws Exception
|
||||
*/
|
||||
public function create($arrayData)
|
||||
{
|
||||
try {
|
||||
$arrayData = array_change_key_case($arrayData, CASE_UPPER);
|
||||
|
||||
unset($arrayData["GRP_UID"]);
|
||||
unset($arrayData['GRP_UID']);
|
||||
|
||||
//Verify data
|
||||
$process = new \ProcessMaker\BusinessModel\Process();
|
||||
$process = new Process();
|
||||
|
||||
$process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayFieldDefinition, $this->arrayFieldNameForException, true);
|
||||
|
||||
$this->throwExceptionIfExistsTitle($arrayData["GRP_TITLE"], $this->arrayFieldNameForException["groupTitle"]);
|
||||
$this->throwExceptionIfExistsTitle($arrayData['GRP_TITLE'], $this->arrayFieldNameForException['groupTitle']);
|
||||
|
||||
//Create
|
||||
$group = new \Groupwf();
|
||||
$group = new Groupwf();
|
||||
|
||||
$groupUid = $group->create($arrayData);
|
||||
|
||||
//Return
|
||||
$arrayData = array_merge(array("GRP_UID" => $groupUid), $arrayData);
|
||||
$arrayData = array_merge(['GRP_UID' => $groupUid], $arrayData);
|
||||
|
||||
if (!$this->formatFieldNameInUppercase) {
|
||||
$arrayData = array_change_key_case($arrayData, CASE_LOWER);
|
||||
}
|
||||
|
||||
return $arrayData;
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -205,10 +212,11 @@ class Group
|
||||
/**
|
||||
* Update Group
|
||||
*
|
||||
* @param string $groupUid Unique id of Group
|
||||
* @param array $arrayData Data
|
||||
* @param string $groupUid Unique id of group
|
||||
* @param array $arrayData information of group
|
||||
*
|
||||
* return array Return data of the Group updated
|
||||
* @return array Return data of the Group updated
|
||||
* @throws Exception
|
||||
*/
|
||||
public function update($groupUid, $arrayData)
|
||||
{
|
||||
@@ -216,32 +224,32 @@ class Group
|
||||
$arrayData = array_change_key_case($arrayData, CASE_UPPER);
|
||||
|
||||
//Verify data
|
||||
$process = new \ProcessMaker\BusinessModel\Process();
|
||||
$process = new Process();
|
||||
|
||||
$this->throwExceptionIfNotExistsGroup($groupUid, $this->arrayFieldNameForException["groupUid"]);
|
||||
$this->throwExceptionIfNotExistsGroup($groupUid, $this->arrayFieldNameForException['groupUid']);
|
||||
|
||||
$process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayFieldDefinition, $this->arrayFieldNameForException, false);
|
||||
|
||||
if (isset($arrayData["GRP_TITLE"])) {
|
||||
$this->throwExceptionIfExistsTitle($arrayData["GRP_TITLE"], $this->arrayFieldNameForException["groupTitle"], $groupUid);
|
||||
if (isset($arrayData['GRP_TITLE'])) {
|
||||
$this->throwExceptionIfExistsTitle($arrayData['GRP_TITLE'], $this->arrayFieldNameForException['groupTitle'], $groupUid);
|
||||
}
|
||||
|
||||
//Update
|
||||
$group = new \Groupwf();
|
||||
$group = new Groupwf();
|
||||
|
||||
$arrayData["GRP_UID"] = $groupUid;
|
||||
$arrayData['GRP_UID'] = $groupUid;
|
||||
|
||||
$result = $group->update($arrayData);
|
||||
|
||||
//Return
|
||||
unset($arrayData["GRP_UID"]);
|
||||
unset($arrayData['GRP_UID']);
|
||||
|
||||
if (!$this->formatFieldNameInUppercase) {
|
||||
$arrayData = array_change_key_case($arrayData, CASE_LOWER);
|
||||
}
|
||||
|
||||
return $arrayData;
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -262,11 +270,11 @@ class Group
|
||||
$arrayTotalTasksByGroup = $this->getTotalTasksByGroup($groupUid);
|
||||
|
||||
if (isset($arrayTotalTasksByGroup[$groupUid]) && $arrayTotalTasksByGroup[$groupUid] > 0) {
|
||||
throw new \Exception(\G::LoadTranslation("ID_GROUP_CANNOT_DELETE_WHILE_ASSIGNED_TO_TASK"));
|
||||
throw new Exception(\G::LoadTranslation("ID_GROUP_CANNOT_DELETE_WHILE_ASSIGNED_TO_TASK"));
|
||||
}
|
||||
|
||||
//Delete
|
||||
$group = new \Groupwf();
|
||||
$group = new Groupwf();
|
||||
|
||||
$result = $group->remove($groupUid);
|
||||
|
||||
@@ -291,7 +299,7 @@ class Group
|
||||
$criteria->add(\ProcessUserPeer::PU_TYPE, "GROUP_SUPERVISOR");
|
||||
|
||||
\ProcessUserPeer::doDelete($criteria);
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -312,7 +320,7 @@ class Group
|
||||
$criteria->addSelectColumn(\GroupwfPeer::GRP_LDAP_DN);
|
||||
$criteria->addSelectColumn(\GroupwfPeer::GRP_UX);
|
||||
return $criteria;
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -359,7 +367,7 @@ class Group
|
||||
|
||||
//Return
|
||||
return $arrayData;
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -406,7 +414,7 @@ class Group
|
||||
|
||||
//Return
|
||||
return $arrayData;
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -428,7 +436,7 @@ class Group
|
||||
$this->getFieldNameByFormatFieldName("GRP_USERS") => $record["GRP_USERS"],
|
||||
$this->getFieldNameByFormatFieldName("GRP_TASKS") => $record["GRP_TASKS"]
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -452,7 +460,7 @@ class Group
|
||||
$numRecTotal = 0;
|
||||
|
||||
//Verify data
|
||||
$process = new \ProcessMaker\BusinessModel\Process();
|
||||
$process = new Process();
|
||||
|
||||
$process->throwExceptionIfDataNotMetPagerVarDefinition(array("start" => $start, "limit" => $limit), $this->arrayFieldNameForException);
|
||||
|
||||
@@ -561,7 +569,7 @@ class Group
|
||||
$filterName => (!is_null($arrayFilterData) && is_array($arrayFilterData) && isset($arrayFilterData["filter"]))? $arrayFilterData["filter"] : "",
|
||||
"data" => $arrayGroup
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -600,7 +608,7 @@ class Group
|
||||
|
||||
//Return
|
||||
return $this->getGroupDataFromRecord($row);
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -656,7 +664,7 @@ class Group
|
||||
}
|
||||
|
||||
return $criteria;
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -679,7 +687,7 @@ class Group
|
||||
$this->getFieldNameByFormatFieldName("USR_EMAIL") => $record["USR_EMAIL"] . "",
|
||||
$this->getFieldNameByFormatFieldName("USR_STATUS") => $record["USR_STATUS"]
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -708,123 +716,41 @@ class Group
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all Users of a Group
|
||||
* Get all users of a group
|
||||
*
|
||||
* @param string $option Option (USERS, AVAILABLE-USERS)
|
||||
* @param string $groupUid Unique id of Group
|
||||
* @param array $arrayFilterData Data of the filters
|
||||
* @param string $sortField Field name to sort
|
||||
* @param string $sortDir Direction of sorting (ASC, DESC)
|
||||
* @param int $start Start
|
||||
* @param int $limit Limit
|
||||
* @param string $option types USERS|AVAILABLE-USERS|SUPERVISOR
|
||||
* @param string $groupUid Unique id of Group
|
||||
* @param array $arrayFilterData Data of the filters
|
||||
* @param string $sortField Field name to sort
|
||||
* @param string $sortDir Direction of sorting (ASC, DESC)
|
||||
* @param int $start start
|
||||
* @param int $limit limit
|
||||
*
|
||||
* return array Return an array with all Users of a Group
|
||||
* @return array Return an array with all Users of a Group
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getUsers($option, $groupUid, $arrayFilterData = null, $sortField = null, $sortDir = null, $start = null, $limit = null)
|
||||
public function getUsers($option, $groupUid, $arrayFilterData = [], $sortField = 'USR_USERNAME', $sortDir = 'ASC', $start = 0, $limit = null)
|
||||
{
|
||||
try {
|
||||
$arrayUser = array();
|
||||
|
||||
//Verify data
|
||||
$process = new \ProcessMaker\BusinessModel\Process();
|
||||
$process = new Process();
|
||||
|
||||
$this->throwExceptionIfNotExistsGroup($groupUid, $this->arrayFieldNameForException["groupUid"]);
|
||||
$this->throwExceptionIfNotExistsGroup($groupUid, $this->arrayFieldNameForException['groupUid']);
|
||||
$process->throwExceptionIfDataNotMetPagerVarDefinition(['start' => $start, 'limit' => $limit], $this->arrayFieldNameForException);
|
||||
|
||||
$process->throwExceptionIfDataNotMetPagerVarDefinition(array("start" => $start, "limit" => $limit), $this->arrayFieldNameForException);
|
||||
$filter = isset($arrayFilterData['filter']) ? $arrayFilterData['filter'] : '';
|
||||
|
||||
//Get data
|
||||
if (!is_null($limit) && $limit . "" == "0") {
|
||||
return $arrayUser;
|
||||
$groupUsers = new GroupUser();
|
||||
$data = $groupUsers->getUsersbyGroup($groupUid, $option, $filter, $sortField, $sortDir, $start, $limit);
|
||||
|
||||
$response = [];
|
||||
foreach ($data['data'] as $user)
|
||||
{
|
||||
$response[] = $this->getUserDataFromRecord($user);
|
||||
}
|
||||
|
||||
//SQL
|
||||
switch ($option) {
|
||||
case "SUPERVISOR":
|
||||
$flagPermission = true;
|
||||
//Criteria for Supervisor
|
||||
$criteria = $this->getUserCriteria($groupUid, $arrayFilterData);
|
||||
break;
|
||||
case "USERS":
|
||||
//Criteria
|
||||
$criteria = $this->getUserCriteria($groupUid, $arrayFilterData);
|
||||
break;
|
||||
case "AVAILABLE-USERS":
|
||||
//Get Uids
|
||||
$arrayUid = array();
|
||||
|
||||
$criteria = $this->getUserCriteria($groupUid);
|
||||
|
||||
$rsCriteria = \UsersPeer::doSelectRS($criteria);
|
||||
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
while ($rsCriteria->next()) {
|
||||
$row = $rsCriteria->getRow();
|
||||
|
||||
$arrayUid[] = $row["USR_UID"];
|
||||
}
|
||||
|
||||
//Criteria
|
||||
$criteria = $this->getUserCriteria("", $arrayFilterData, $arrayUid);
|
||||
break;
|
||||
}
|
||||
|
||||
//SQL
|
||||
if (!is_null($sortField) && trim($sortField) != "") {
|
||||
$sortField = strtoupper($sortField);
|
||||
|
||||
if (in_array($sortField, array("USR_UID", "USR_USERNAME", "USR_FIRSTNAME", "USR_LASTNAME", "USR_EMAIL", "USR_STATUS"))) {
|
||||
$sortField = \UsersPeer::TABLE_NAME . "." . $sortField;
|
||||
} else {
|
||||
$sortField = \UsersPeer::USR_USERNAME;
|
||||
}
|
||||
} else {
|
||||
$sortField = \UsersPeer::USR_USERNAME;
|
||||
}
|
||||
|
||||
if (!is_null($sortDir) && trim($sortDir) != "" && strtoupper($sortDir) == "DESC") {
|
||||
$criteria->addDescendingOrderByColumn($sortField);
|
||||
} else {
|
||||
$criteria->addAscendingOrderByColumn($sortField);
|
||||
}
|
||||
|
||||
if (!is_null($start)) {
|
||||
$criteria->setOffset((int)($start));
|
||||
}
|
||||
|
||||
if (!is_null($limit)) {
|
||||
$criteria->setLimit((int)($limit));
|
||||
}
|
||||
|
||||
$rsCriteria = \UsersPeer::doSelectRS($criteria);
|
||||
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
if (isset($flagPermission) && $flagPermission) {
|
||||
|
||||
while ($rsCriteria->next()) {
|
||||
$row = $rsCriteria->getRow();
|
||||
|
||||
$aPermissions = $this->loadUserRolePermission("PROCESSMAKER", $row['USR_UID']);
|
||||
$bInclude = false;
|
||||
|
||||
foreach ($aPermissions as $aPermission) {
|
||||
if ($aPermission['PER_CODE'] == 'PM_SUPERVISOR') {
|
||||
$bInclude = true;
|
||||
}
|
||||
}
|
||||
if ($bInclude) {
|
||||
$arrayUser[] = $this->getUserDataFromRecord($row);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
while ($rsCriteria->next()) {
|
||||
$row = $rsCriteria->getRow();
|
||||
|
||||
$arrayUser[] = $this->getUserDataFromRecord($row);
|
||||
}
|
||||
}
|
||||
//Return
|
||||
return $arrayUser;
|
||||
} catch (\Exception $e) {
|
||||
return $response;
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@ class Light
|
||||
* Method get list start case
|
||||
*
|
||||
* @param $userId User id
|
||||
*
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
@@ -106,8 +107,11 @@ class Light
|
||||
$tempTreeChild['text'] = $keyChild; //ellipsis ( $keyChild, 50 );
|
||||
$tempTreeChild['processId'] = $processInfoChild['pro_uid'];
|
||||
$tempTreeChild['taskId'] = $processInfoChild['uid'];
|
||||
list($tempTreeChild['offlineEnabled'], $tempTreeChild['autoRoot']) = $task->getColumnValues($processInfoChild['pro_uid'],
|
||||
$processInfoChild['uid'], array('TAS_OFFLINE', 'TAS_AUTO_ROOT'));
|
||||
list($tempTreeChild['offlineEnabled'], $tempTreeChild['autoRoot']) = $task->getColumnValues(
|
||||
$processInfoChild['pro_uid'],
|
||||
$processInfoChild['uid'],
|
||||
array('TAS_OFFLINE', 'TAS_AUTO_ROOT')
|
||||
);
|
||||
//Add process category
|
||||
$tempTreeChild['categoryName'] = $processInfoChild['catname'];
|
||||
$tempTreeChild['categoryId'] = $processInfoChild['cat'];
|
||||
@@ -128,8 +132,11 @@ class Light
|
||||
$newForm[$c]['stepMode'] = $form['step_mode'];
|
||||
$newForm[$c]['stepCondition'] = $form['step_condition'];
|
||||
$newForm[$c]['stepPosition'] = $form['step_position'];
|
||||
$trigger = $this->statusTriggers($step->doGetActivityStepTriggers($form["step_uid"],
|
||||
$tempTreeChild['taskId'], $tempTreeChild['processId']));
|
||||
$trigger = $this->statusTriggers($step->doGetActivityStepTriggers(
|
||||
$form["step_uid"],
|
||||
$tempTreeChild['taskId'],
|
||||
$tempTreeChild['processId']
|
||||
));
|
||||
$newForm[$c]["triggers"] = $trigger;
|
||||
$c++;
|
||||
}
|
||||
@@ -151,7 +158,9 @@ class Light
|
||||
|
||||
/**
|
||||
* Get status trigger case
|
||||
*
|
||||
* @param $triggers
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function statusTriggers($triggers)
|
||||
@@ -171,7 +180,9 @@ class Light
|
||||
|
||||
/**
|
||||
* Get counters each type of list
|
||||
*
|
||||
* @param $userId
|
||||
*
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
@@ -181,7 +192,7 @@ class Light
|
||||
$userUid = (isset($userId) && $userId != '') ? $userId : null;
|
||||
$oAppCache = new AppCacheView();
|
||||
|
||||
$aTypes = Array();
|
||||
$aTypes = array();
|
||||
$aTypes['to_do'] = 'toDo';
|
||||
$aTypes['draft'] = 'draft';
|
||||
$aTypes['cancelled'] = 'cancelled';
|
||||
@@ -192,7 +203,7 @@ class Light
|
||||
|
||||
$aCount = $oAppCache->getAllCounters(array_keys($aTypes), $userUid);
|
||||
|
||||
$response = Array();
|
||||
$response = array();
|
||||
foreach ($aCount as $type => $count) {
|
||||
$response[$aTypes[$type]] = $count;
|
||||
}
|
||||
@@ -205,6 +216,7 @@ class Light
|
||||
|
||||
/**
|
||||
* @param $sAppUid
|
||||
*
|
||||
* @return Criteria
|
||||
*/
|
||||
public function getTransferHistoryCriteria($sAppUid)
|
||||
@@ -220,7 +232,6 @@ class Light
|
||||
///-- $c->addAsColumn('USR_NAME', "CONCAT(USR_LASTNAME, ' ', USR_FIRSTNAME)");
|
||||
$sDataBase = 'database_' . strtolower(DB_ADAPTER);
|
||||
if (G::LoadSystemExist($sDataBase)) {
|
||||
|
||||
$oDataBase = new database();
|
||||
$c->addAsColumn('USR_NAME', $oDataBase->concatString("USR_LASTNAME", "' '", "USR_FIRSTNAME"));
|
||||
$c->addAsColumn(
|
||||
@@ -228,7 +239,8 @@ class Light
|
||||
$oDataBase->getCaseWhen("DEL_FINISH_DATE IS NULL", "'-'", AppDelegationPeer::DEL_FINISH_DATE)
|
||||
);
|
||||
$c->addAsColumn(
|
||||
'APP_TYPE', $oDataBase->getCaseWhen("DEL_FINISH_DATE IS NULL", "'IN_PROGRESS'", AppDelayPeer::APP_TYPE)
|
||||
'APP_TYPE',
|
||||
$oDataBase->getCaseWhen("DEL_FINISH_DATE IS NULL", "'IN_PROGRESS'", AppDelayPeer::APP_TYPE)
|
||||
);
|
||||
}
|
||||
$c->addSelectColumn(AppDelegationPeer::DEL_INIT_DATE);
|
||||
@@ -261,6 +273,7 @@ class Light
|
||||
* GET history of case
|
||||
*
|
||||
* @param $app_uid
|
||||
*
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
@@ -269,7 +282,7 @@ class Light
|
||||
|
||||
//global $G_PUBLISH;
|
||||
$c = $this->getTransferHistoryCriteria($app_uid);
|
||||
$aProcesses = Array();
|
||||
$aProcesses = array();
|
||||
|
||||
$rs = GulliverBasePeer::doSelectRs($c);
|
||||
$rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
@@ -299,6 +312,7 @@ class Light
|
||||
* @param string $userId
|
||||
* @param string $proUid
|
||||
* @param string $taskUid
|
||||
*
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
@@ -329,7 +343,8 @@ class Light
|
||||
|
||||
//Log
|
||||
Bootstrap::registerMonolog('MobileCreateCase', 200, "Create case",
|
||||
['application_uid' => $aData['APPLICATION'], 'usr_uid' => $userId], config("system.workspace"), 'processmaker.log');
|
||||
['application_uid' => $aData['APPLICATION'], 'usr_uid' => $userId], config("system.workspace"),
|
||||
'processmaker.log');
|
||||
} catch (Exception $e) {
|
||||
$response['status'] = 'failure';
|
||||
$response['message'] = $e->getMessage();
|
||||
@@ -371,7 +386,6 @@ class Light
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -405,8 +419,13 @@ class Light
|
||||
$Fields['APP_DATA'] = array_merge($Fields['APP_DATA'], G::getSystemConstants());
|
||||
$triggers = $oCase->loadTriggers($act_uid, 'DYNAFORM', $step_uid_obj, strtoupper($type));
|
||||
if ($triggers) {
|
||||
$Fields['APP_DATA'] = $oCase->ExecuteTriggers($act_uid, 'DYNAFORM', $step_uid_obj, strtoupper($type),
|
||||
$Fields['APP_DATA']);
|
||||
$Fields['APP_DATA'] = $oCase->ExecuteTriggers(
|
||||
$act_uid,
|
||||
'DYNAFORM',
|
||||
$step_uid_obj,
|
||||
strtoupper($type),
|
||||
$Fields['APP_DATA']
|
||||
);
|
||||
}
|
||||
$Fields['TAS_UID'] = $act_uid;
|
||||
$Fields['CURRENT_DYNAFORM'] = $step_uid_obj;
|
||||
@@ -439,8 +458,13 @@ class Light
|
||||
$triggers = $oCase->loadTriggers($tas_uid, 'ASSIGN_TASK', '-1', 'BEFORE');
|
||||
if (isset($triggers)) {
|
||||
$Fields['APP_DATA'] = array_merge($Fields['APP_DATA'], G::getSystemConstants());
|
||||
$Fields['APP_DATA'] = $oCase->ExecuteTriggers($tas_uid, 'DYNAFORM', '-1', 'BEFORE',
|
||||
$Fields['APP_DATA']);
|
||||
$Fields['APP_DATA'] = $oCase->ExecuteTriggers(
|
||||
$tas_uid,
|
||||
'DYNAFORM',
|
||||
'-1',
|
||||
'BEFORE',
|
||||
$Fields['APP_DATA']
|
||||
);
|
||||
$oCase->updateCase($app_uid, $Fields);
|
||||
}
|
||||
$oDerivation = new \Derivation();
|
||||
@@ -455,10 +479,16 @@ class Light
|
||||
$sPriority = ''; //set priority value
|
||||
if ($derive[$sKey]['NEXT_TASK']['TAS_PRIORITY_VARIABLE'] != '') {
|
||||
//TO DO: review this type of assignment
|
||||
if (isset($aData['APP_DATA'][str_replace('@@', '',
|
||||
$derive[$sKey]['NEXT_TASK']['TAS_PRIORITY_VARIABLE'])])) {
|
||||
$sPriority = $aData['APP_DATA'][str_replace('@@', '',
|
||||
$derive[$sKey]['NEXT_TASK']['TAS_PRIORITY_VARIABLE'])];
|
||||
if (isset($aData['APP_DATA'][str_replace(
|
||||
'@@',
|
||||
'',
|
||||
$derive[$sKey]['NEXT_TASK']['TAS_PRIORITY_VARIABLE']
|
||||
)])) {
|
||||
$sPriority = $aData['APP_DATA'][str_replace(
|
||||
'@@',
|
||||
'',
|
||||
$derive[$sKey]['NEXT_TASK']['TAS_PRIORITY_VARIABLE']
|
||||
)];
|
||||
}
|
||||
} //set priority value
|
||||
|
||||
@@ -546,10 +576,10 @@ class Light
|
||||
* Route Case
|
||||
*
|
||||
* @param string $applicationUid Unique id of Case
|
||||
* @param string $userUid Unique id of User
|
||||
* @param string $userUid Unique id of User
|
||||
* @param string $delIndex
|
||||
* @param string $tasks
|
||||
* @param boolean $executeTriggersBeforeAssignment
|
||||
* @param array $tasks
|
||||
* @param string $bExecuteTriggersBeforeAssignment
|
||||
*
|
||||
* return array Return an array with Task Case
|
||||
*/
|
||||
@@ -582,7 +612,8 @@ class Light
|
||||
|
||||
//Log
|
||||
Bootstrap::registerMonolog('MobileRouteCase', 200, 'Route case',
|
||||
['application_uid' => $applicationUid, 'usr_uid' => $userUid], config("system.workspace"), 'processmaker.log');
|
||||
['application_uid' => $applicationUid, 'usr_uid' => $userUid], config("system.workspace"),
|
||||
'processmaker.log');
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
@@ -594,7 +625,7 @@ class Light
|
||||
* Get user Data
|
||||
*
|
||||
* @param string $applicationUid Unique id of Case
|
||||
* @param string $userUid Unique id of User
|
||||
* @param string $userUid Unique id of User
|
||||
* @param string $delIndex
|
||||
* @param string $bExecuteTriggersBeforeAssignment
|
||||
*
|
||||
@@ -669,8 +700,12 @@ class Light
|
||||
case 'gif':
|
||||
case 'png':
|
||||
$arrayFiles[$key]['fileId'] = $fileData['fileId'];
|
||||
$arrayFiles[$key]['fileContent'] = base64_encode($this->imagesThumbnails($realPath, $ext,
|
||||
$width, $height));
|
||||
$arrayFiles[$key]['fileContent'] = base64_encode($this->imagesThumbnails(
|
||||
$realPath,
|
||||
$ext,
|
||||
$width,
|
||||
$height
|
||||
));
|
||||
break;
|
||||
default:
|
||||
$fileTmp = fopen($realPath, "r");
|
||||
@@ -687,8 +722,12 @@ class Light
|
||||
case 'gif':
|
||||
case 'png':
|
||||
$arrayFiles[$key]['fileId'] = $fileData['fileId'];
|
||||
$arrayFiles[$key]['fileContent'] = $this->imagesThumbnails($realPath1, $ext, $width,
|
||||
$height);
|
||||
$arrayFiles[$key]['fileContent'] = $this->imagesThumbnails(
|
||||
$realPath1,
|
||||
$ext,
|
||||
$width,
|
||||
$height
|
||||
);
|
||||
break;
|
||||
default:
|
||||
$fileTmp = fopen($realPath, "r");
|
||||
@@ -710,10 +749,11 @@ class Light
|
||||
/**
|
||||
* resize image if send width or height
|
||||
*
|
||||
* @param $path
|
||||
* @param $extensions
|
||||
* @param $path
|
||||
* @param $extensions
|
||||
* @param null $newWidth
|
||||
* @param null $newHeight
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function imagesThumbnails($path, $extensions, $newWidth = null, $newHeight = null)
|
||||
@@ -815,7 +855,8 @@ class Light
|
||||
session_start();
|
||||
session_regenerate_id();
|
||||
|
||||
setcookie("workspaceSkin", SYS_SKIN, time() + (24 * 60 * 60), "/sys" . config("system.workspace"), null, false, true);
|
||||
setcookie("workspaceSkin", SYS_SKIN, time() + (24 * 60 * 60), "/sys" . config("system.workspace"), null, false,
|
||||
true);
|
||||
|
||||
if (strlen($msg) > 0) {
|
||||
$_SESSION['G_MESSAGE'] = $msg;
|
||||
@@ -830,9 +871,11 @@ class Light
|
||||
|
||||
/*----------------------------------********---------------------------------*/
|
||||
|
||||
$licenseManager =& PmLicenseManager::getSingleton();
|
||||
if (in_array(md5($licenseManager->result),
|
||||
array('38afd7ae34bd5e3e6fc170d8b09178a3', 'ba2b45bdc11e2a4a6e86aab2ac693cbb'))) {
|
||||
$licenseManager = PmLicenseManager::getSingleton();
|
||||
if (in_array(
|
||||
md5($licenseManager->result),
|
||||
array('38afd7ae34bd5e3e6fc170d8b09178a3', 'ba2b45bdc11e2a4a6e86aab2ac693cbb')
|
||||
)) {
|
||||
$G_PUBLISH = new \Publisher();
|
||||
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/licenseExpired', '', array(), 'licenseUpdate');
|
||||
G::RenderPage('publish');
|
||||
@@ -851,7 +894,6 @@ class Light
|
||||
}
|
||||
|
||||
return $response;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -860,6 +902,7 @@ class Light
|
||||
* @param $userUid
|
||||
* @param $type
|
||||
* @param $app_uid
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getInformation($userUid, $type, $app_uid)
|
||||
@@ -895,6 +938,7 @@ class Light
|
||||
* @param $userUid
|
||||
* @param $Fields
|
||||
* @param $type
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getInfoResume($userUid, $Fields, $type)
|
||||
@@ -930,7 +974,8 @@ class Light
|
||||
*
|
||||
* @param string $userUid
|
||||
* @param string $appUid
|
||||
* @param array $requestData
|
||||
* @param array $requestData
|
||||
*
|
||||
* @return array $response
|
||||
* @throws Exception
|
||||
*/
|
||||
@@ -994,9 +1039,12 @@ class Light
|
||||
$userInfo = '***';
|
||||
if ($userUid !== '-1') {
|
||||
$arrayUserData = $user->load($userUid);
|
||||
$userInfo = $config->usersNameFormatBySetParameters($confEnvSetting["format"],
|
||||
$arrayUserData["USR_USERNAME"], $arrayUserData["USR_FIRSTNAME"],
|
||||
$arrayUserData["USR_LASTNAME"]);
|
||||
$userInfo = $config->usersNameFormatBySetParameters(
|
||||
$confEnvSetting["format"],
|
||||
$arrayUserData["USR_USERNAME"],
|
||||
$arrayUserData["USR_FIRSTNAME"],
|
||||
$arrayUserData["USR_LASTNAME"]
|
||||
);
|
||||
}
|
||||
$response[$k]['appDocCreateUser'] = $userInfo;
|
||||
}
|
||||
@@ -1012,6 +1060,7 @@ class Light
|
||||
* @param $userUid
|
||||
* @param $Fields
|
||||
* @param $type
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function documentUploadFiles($userUid, $app_uid, $app_doc_uid, $request_data)
|
||||
@@ -1137,6 +1186,7 @@ class Light
|
||||
* @param $action
|
||||
* @param $categoryUid
|
||||
* @param $userUid
|
||||
*
|
||||
* @return array
|
||||
* @throws PropelException
|
||||
*/
|
||||
@@ -1245,7 +1295,6 @@ class Light
|
||||
*/
|
||||
public function getUsersToReassign($usr_uid, $task_uid)
|
||||
{
|
||||
|
||||
$memcache = PMmemcached::getSingleton(config("system.workspace"));
|
||||
$RBAC = RBAC::getSingleton(PATH_DATA, session_id());
|
||||
$RBAC->sSystem = 'PROCESSMAKER';
|
||||
@@ -1329,6 +1378,7 @@ class Light
|
||||
|
||||
/**
|
||||
* Get configuration
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getConfiguration($params)
|
||||
@@ -1337,15 +1387,18 @@ class Light
|
||||
$multiTimeZone = false;
|
||||
//Set Time Zone
|
||||
/*----------------------------------********---------------------------------*/
|
||||
if (\PMLicensedFeatures::getSingleton()->verifyfeature
|
||||
('oq3S29xemxEZXJpZEIzN01qenJUaStSekY4cTdJVm5vbWtVM0d4S2lJSS9qUT0=')) {
|
||||
if (\PMLicensedFeatures::getSingleton()->verifyfeature('oq3S29xemxEZXJpZEIzN01qenJUaStSekY4cTdJVm5vbWtVM0d4S2lJSS9qUT0=')) {
|
||||
$multiTimeZone = (int)($sysConf['system_utc_time_zone']) == 1;
|
||||
}
|
||||
/*----------------------------------********---------------------------------*/
|
||||
$tz = isset($_SESSION['USR_TIME_ZONE']) ? $_SESSION['USR_TIME_ZONE'] : $sysConf['time_zone'];
|
||||
$offset = timezone_offset_get(new \DateTimeZone($tz), new \DateTime());
|
||||
$response['timeZone'] = sprintf("GMT%s%02d:%02d", ($offset >= 0) ? '+' : '-', abs($offset / 3600),
|
||||
abs(($offset % 3600) / 60));
|
||||
$response['timeZone'] = sprintf(
|
||||
"GMT%s%02d:%02d",
|
||||
($offset >= 0) ? '+' : '-',
|
||||
abs($offset / 3600),
|
||||
abs(($offset % 3600) / 60)
|
||||
);
|
||||
$response['multiTimeZone'] = $multiTimeZone;
|
||||
$fields = System::getSysInfo();
|
||||
$response['version'] = $fields['PM_VERSION'];
|
||||
@@ -1438,10 +1491,12 @@ class Light
|
||||
|
||||
/**
|
||||
* This function check if the $data are in the corresponding cases list
|
||||
*
|
||||
* @param string $userUid
|
||||
* @param array $data
|
||||
* @param array $data
|
||||
* @param string $listName
|
||||
* @param string $action
|
||||
*
|
||||
* @return array $response
|
||||
*/
|
||||
public function getListCheck($userUid, $data, $listName = 'inbox', $action = 'todo')
|
||||
@@ -1472,14 +1527,13 @@ class Light
|
||||
foreach ($data as $key => $val) {
|
||||
$flagRemoved = true;
|
||||
foreach ($response['data'] as $row) {
|
||||
$row = array_change_key_case($row,CASE_UPPER);
|
||||
$row = array_change_key_case($row, CASE_UPPER);
|
||||
if (isset($row['APP_UID']) && isset($row['DEL_INDEX'])) {
|
||||
if ($val['caseId'] === $row['APP_UID'] && $val['delIndex'] === $row['DEL_INDEX'] ) {
|
||||
if ($val['caseId'] === $row['APP_UID'] && $val['delIndex'] === $row['DEL_INDEX']) {
|
||||
$flagRemoved = false;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if ($flagRemoved) {
|
||||
$result[] = [
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\BusinessModel;
|
||||
|
||||
use \G;
|
||||
use \Criteria;
|
||||
use \UsersPeer;
|
||||
use \PMLicensedFeatures;
|
||||
|
||||
/**
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
class Lists {
|
||||
class Lists
|
||||
{
|
||||
|
||||
/**
|
||||
* @var array
|
||||
@@ -82,17 +86,17 @@ class Lists {
|
||||
* Get list for Cases
|
||||
*
|
||||
* @access public
|
||||
* @param array $dataList, Data for list
|
||||
* @param array $dataList , Data for list
|
||||
* @return array
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
*/
|
||||
public function getList($listName = 'inbox', $dataList = array(), $total = false)
|
||||
{
|
||||
Validator::isArray($dataList, '$dataList');
|
||||
if (!isset($dataList["userId"])) {
|
||||
throw (new \Exception(\G::LoadTranslation("ID_USER_NOT_EXIST", array('userId',''))));
|
||||
throw (new \Exception(\G::LoadTranslation("ID_USER_NOT_EXIST", array('userId', ''))));
|
||||
} else {
|
||||
Validator::usrUid($dataList["userId"], "userId");
|
||||
}
|
||||
@@ -156,7 +160,7 @@ class Lists {
|
||||
$filters["start"] = (int)$filters["start"];
|
||||
$filters["start"] = abs($filters["start"]);
|
||||
if ($filters["start"] != 0) {
|
||||
$filters["start"]+1;
|
||||
$filters["start"] + 1;
|
||||
}
|
||||
|
||||
$filters["limit"] = (int)$filters["limit"];
|
||||
@@ -205,25 +209,25 @@ class Lists {
|
||||
if (!empty($result)) {
|
||||
foreach ($result as &$value) {
|
||||
if (isset($value['DEL_PREVIOUS_USR_UID'])) {
|
||||
$value['PREVIOUS_USR_UID'] = $value['DEL_PREVIOUS_USR_UID'];
|
||||
$value['PREVIOUS_USR_USERNAME'] = $value['DEL_PREVIOUS_USR_USERNAME'];
|
||||
$value['PREVIOUS_USR_UID'] = $value['DEL_PREVIOUS_USR_UID'];
|
||||
$value['PREVIOUS_USR_USERNAME'] = $value['DEL_PREVIOUS_USR_USERNAME'];
|
||||
$value['PREVIOUS_USR_FIRSTNAME'] = $value['DEL_PREVIOUS_USR_FIRSTNAME'];
|
||||
$value['PREVIOUS_USR_LASTNAME'] = $value['DEL_PREVIOUS_USR_LASTNAME'];
|
||||
$value['PREVIOUS_USR_LASTNAME'] = $value['DEL_PREVIOUS_USR_LASTNAME'];
|
||||
}
|
||||
if (isset($value['DEL_DUE_DATE'])) {
|
||||
$value['DEL_TASK_DUE_DATE'] = $value['DEL_DUE_DATE'];
|
||||
}
|
||||
if (isset($value['APP_PAUSED_DATE'])) {
|
||||
$value['APP_UPDATE_DATE'] = $value['APP_PAUSED_DATE'];
|
||||
$value['APP_UPDATE_DATE'] = $value['APP_PAUSED_DATE'];
|
||||
}
|
||||
if (isset($value['DEL_CURRENT_USR_USERNAME'])) {
|
||||
$value['USR_USERNAME'] = $value['DEL_CURRENT_USR_USERNAME'];
|
||||
$value['USR_FIRSTNAME'] = $value['DEL_CURRENT_USR_FIRSTNAME'];
|
||||
$value['USR_LASTNAME'] = $value['DEL_CURRENT_USR_LASTNAME'];
|
||||
$value['APP_UPDATE_DATE'] = $value['DEL_DELEGATE_DATE'];
|
||||
$value['USR_USERNAME'] = $value['DEL_CURRENT_USR_USERNAME'];
|
||||
$value['USR_FIRSTNAME'] = $value['DEL_CURRENT_USR_FIRSTNAME'];
|
||||
$value['USR_LASTNAME'] = $value['DEL_CURRENT_USR_LASTNAME'];
|
||||
$value['APP_UPDATE_DATE'] = $value['DEL_DELEGATE_DATE'];
|
||||
}
|
||||
if (isset($value['APP_STATUS'])) {
|
||||
$value['APP_STATUS_LABEL'] = G::LoadTranslation( "ID_{$value['APP_STATUS']}" );
|
||||
$value['APP_STATUS_LABEL'] = G::LoadTranslation("ID_{$value['APP_STATUS']}");
|
||||
}
|
||||
|
||||
|
||||
@@ -233,19 +237,19 @@ class Lists {
|
||||
$response = array();
|
||||
if ($filters["paged"]) {
|
||||
$filtersData = array();
|
||||
$filtersData['start'] = $filters["start"];
|
||||
$filtersData['limit'] = $filters["limit"];
|
||||
$filtersData['sort'] = G::toLower($filters["sort"]);
|
||||
$filtersData['dir'] = G::toLower($filters["dir"]);
|
||||
$filtersData['cat_uid'] = $filters["category"];
|
||||
$filtersData['pro_uid'] = $filters["process"];
|
||||
$filtersData['search'] = $filters["search"];
|
||||
$filtersData['date_from'] = $filters["dateFrom"];
|
||||
$filtersData['date_to'] = $filters["dateTo"];
|
||||
$response['filters'] = $filtersData;
|
||||
$response['data'] = $result;
|
||||
$filtersData['action'] = $filters["action"];
|
||||
$response['totalCount'] = $list->getCountList($userUid, $filtersData);
|
||||
$filtersData['start'] = $filters["start"];
|
||||
$filtersData['limit'] = $filters["limit"];
|
||||
$filtersData['sort'] = G::toLower($filters["sort"]);
|
||||
$filtersData['dir'] = G::toLower($filters["dir"]);
|
||||
$filtersData['cat_uid'] = $filters["category"];
|
||||
$filtersData['pro_uid'] = $filters["process"];
|
||||
$filtersData['search'] = $filters["search"];
|
||||
$filtersData['date_from'] = $filters["dateFrom"];
|
||||
$filtersData['date_to'] = $filters["dateTo"];
|
||||
$response['filters'] = $filtersData;
|
||||
$response['data'] = $result;
|
||||
$filtersData['action'] = $filters["action"];
|
||||
$response['totalCount'] = $list->getCountList($userUid, $filtersData);
|
||||
} else {
|
||||
$response = $result;
|
||||
}
|
||||
@@ -264,12 +268,12 @@ class Lists {
|
||||
foreach ($list as $listObject => $item) {
|
||||
switch ($listObject) {
|
||||
case 'ListDraft':
|
||||
$total = $this->$listObject->getCountList($userId, array('action'=>'draft'));
|
||||
$total = $this->$listObject->getCountList($userId, array('action' => 'draft'));
|
||||
array_push($response, (array('count' => $total, 'item' => $item)));
|
||||
break;
|
||||
/*----------------------------------********---------------------------------*/
|
||||
case 'ListConsolidated':
|
||||
$licensedFeatures = &\PMLicensedFeatures::getSingleton();
|
||||
$licensedFeatures = PMLicensedFeatures::getSingleton();
|
||||
if ($licensedFeatures->verifyfeature('7TTeDBQeWRoZTZKYjh4eFpYUlRDUUEyVERPU3FxellWank=')) {
|
||||
$total = $this->$listObject->getCountList($userId);
|
||||
array_push($response, (array('count' => $total, 'item' => $item)));
|
||||
@@ -284,4 +288,4 @@ class Lists {
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ class ReportTablesMigrator implements Importable, Exportable
|
||||
if (!$replace) {
|
||||
$additionalTable = new \AdditionalTables();
|
||||
|
||||
if ($additionalTable->loadByName($arrayTable['ADD_TAB_NAME']) !== false) {
|
||||
if ($additionalTable->loadByName($arrayTable['ADD_TAB_NAME'])) {
|
||||
$arrayTablesToExclude[] = $arrayTable['ADD_TAB_NAME'];
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,11 +1,12 @@
|
||||
<?php
|
||||
namespace ProcessMaker\BusinessModel;
|
||||
|
||||
use Behat\Behat\Exception\Exception;
|
||||
use \G;
|
||||
use \Criteria;
|
||||
use \ObjectPermissionPeer;
|
||||
use \Exception as StandardException;
|
||||
use BasePeer;
|
||||
use Criteria;
|
||||
use G;
|
||||
use ObjectPermission;
|
||||
use ObjectPermissionPeer;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
@@ -13,6 +14,7 @@ use \Exception as StandardException;
|
||||
*/
|
||||
class ProcessPermissions
|
||||
{
|
||||
const DOES_NOT_APPLY = 'N/A';
|
||||
/**
|
||||
* Get list for Process Permissions
|
||||
*
|
||||
@@ -20,8 +22,6 @@ class ProcessPermissions
|
||||
* @var string $op_uid. Uid for Process Permission
|
||||
*
|
||||
* @access public
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -42,6 +42,14 @@ class ProcessPermissions
|
||||
$oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
while ($aRow = $oDataset->getRow()) {
|
||||
//Participated
|
||||
if ($aRow['OP_PARTICIPATE'] == 0) {
|
||||
$participated = G::LoadTranslation('ID_NO');
|
||||
} else {
|
||||
$participated = G::LoadTranslation('ID_YES');
|
||||
}
|
||||
//Obtain action (permission)
|
||||
$action = G::LoadTranslation('ID_' . $aRow['OP_ACTION']);
|
||||
//Obtain task target
|
||||
if (($aRow['TAS_UID'] != '') && ($aRow['TAS_UID'] != '0')) {
|
||||
try {
|
||||
@@ -87,97 +95,87 @@ class ProcessPermissions
|
||||
//Obtain object and type
|
||||
switch ($aRow['OP_OBJ_TYPE']) {
|
||||
case 'ALL':
|
||||
$sObjectType = G::LoadTranslation('ID_ALL');
|
||||
$sObject = G::LoadTranslation('ID_ALL');
|
||||
$objectType = G::LoadTranslation('ID_ALL');
|
||||
$object = G::LoadTranslation('ID_ALL');
|
||||
break;
|
||||
case 'ANY': //For backward compatibility (some process with ANY instead of ALL
|
||||
$sObjectType = G::LoadTranslation('ID_ALL');
|
||||
$sObject = G::LoadTranslation('ID_ALL');
|
||||
$objectType = G::LoadTranslation('ID_ALL');
|
||||
$object = G::LoadTranslation('ID_ALL');
|
||||
break;
|
||||
/* case 'ANY_DYNAFORM':
|
||||
$sObjectType = G::LoadTranslation('ID_ANY_DYNAFORM');
|
||||
$sObject = G::LoadTranslation('ID_ALL');
|
||||
break;
|
||||
case 'ANY_INPUT':
|
||||
$sObjectType = G::LoadTranslation('ID_ANY_INPUT');
|
||||
$sObject = G::LoadTranslation('ID_ALL');
|
||||
break;
|
||||
case 'ANY_OUTPUT':
|
||||
$sObjectType = G::LoadTranslation('ID_ANY_OUTPUT');
|
||||
$sObject = G::LoadTranslation('ID_ALL');
|
||||
break; */
|
||||
case 'DYNAFORM':
|
||||
$sObjectType = G::LoadTranslation('ID_DYNAFORM');
|
||||
$objectType = G::LoadTranslation('ID_DYNAFORM');
|
||||
if (($aRow['OP_OBJ_UID'] != '') && ($aRow['OP_OBJ_UID'] != '0')) {
|
||||
$oDynaform = new \Dynaform();
|
||||
try {
|
||||
$aFields = $oDynaform->load($aRow['OP_OBJ_UID']);
|
||||
$sObject = $aFields['DYN_TITLE'];
|
||||
$object = $aFields['DYN_TITLE'];
|
||||
} catch (\Exception $errorNotExists) {
|
||||
error_log($errorNotExists->getMessage() . ' - ' . G::LoadTranslation('ID_PROCESS_PERMISSIONS') .
|
||||
error_log($errorNotExists->getMessage() . ' - ' . G::LoadTranslation('ID_PROCESS_PERMISSIONS') .
|
||||
' - ' . $aRow['OP_OBJ_TYPE'] . ' - ' . $aRow['OP_OBJ_UID']);
|
||||
$oDataset->next();
|
||||
continue 2;
|
||||
}
|
||||
} else {
|
||||
$sObject = G::LoadTranslation('ID_ALL');
|
||||
$object = G::LoadTranslation('ID_ALL');
|
||||
}
|
||||
break;
|
||||
case 'INPUT':
|
||||
$sObjectType = G::LoadTranslation('ID_INPUT_DOCUMENT');
|
||||
$objectType = G::LoadTranslation('ID_INPUT_DOCUMENT');
|
||||
if (($aRow['OP_OBJ_UID'] != '') && ($aRow['OP_OBJ_UID'] != '0')) {
|
||||
$oInputDocument = new \InputDocument();
|
||||
try {
|
||||
$aFields = $oInputDocument->load($aRow['OP_OBJ_UID']);
|
||||
$sObject = $aFields['INP_DOC_TITLE'];
|
||||
$object = $aFields['INP_DOC_TITLE'];
|
||||
} catch (\Exception $errorNotExists) {
|
||||
error_log($errorNotExists->getMessage() . ' - ' . G::LoadTranslation('ID_PROCESS_PERMISSIONS') .
|
||||
error_log($errorNotExists->getMessage() . ' - ' . G::LoadTranslation('ID_PROCESS_PERMISSIONS') .
|
||||
' - ' . $aRow['OP_OBJ_TYPE'] . ' - ' . $aRow['OP_OBJ_UID']);
|
||||
$oDataset->next();
|
||||
continue 2;
|
||||
}
|
||||
} else {
|
||||
$sObject = G::LoadTranslation('ID_ALL');
|
||||
$object = G::LoadTranslation('ID_ALL');
|
||||
}
|
||||
break;
|
||||
case 'OUTPUT':
|
||||
$sObjectType = G::LoadTranslation('ID_OUTPUT_DOCUMENT');
|
||||
$objectType = G::LoadTranslation('ID_OUTPUT_DOCUMENT');
|
||||
if (($aRow['OP_OBJ_UID'] != '') && ($aRow['OP_OBJ_UID'] != '0')) {
|
||||
$oOutputDocument = new \OutputDocument();
|
||||
try {
|
||||
$aFields = $oOutputDocument->load($aRow['OP_OBJ_UID']);
|
||||
$sObject = $aFields['OUT_DOC_TITLE'];
|
||||
$object = $aFields['OUT_DOC_TITLE'];
|
||||
} catch (\Exception $errorNotExists) {
|
||||
error_log($errorNotExists->getMessage() . ' - ' . G::LoadTranslation('ID_PROCESS_PERMISSIONS') .
|
||||
error_log($errorNotExists->getMessage() . ' - ' . G::LoadTranslation('ID_PROCESS_PERMISSIONS') .
|
||||
' - ' . $aRow['OP_OBJ_TYPE'] . ' - ' . $aRow['OP_OBJ_UID']);
|
||||
$oDataset->next();
|
||||
continue 2;
|
||||
}
|
||||
} else {
|
||||
$sObject = G::LoadTranslation('ID_ALL');
|
||||
$object = G::LoadTranslation('ID_ALL');
|
||||
}
|
||||
break;
|
||||
case 'CASES_NOTES':
|
||||
$sObjectType = G::LoadTranslation('ID_CASES_NOTES');
|
||||
$sObject = 'N/A';
|
||||
$objectType = G::LoadTranslation('ID_CASES_NOTES');
|
||||
$object = self::DOES_NOT_APPLY;
|
||||
break;
|
||||
case 'MSGS_HISTORY':
|
||||
$sObjectType = G::LoadTranslation('MSGS_HISTORY');
|
||||
$sObject = G::LoadTranslation('ID_ALL');
|
||||
$objectType = G::LoadTranslation('MSGS_HISTORY');
|
||||
$object = G::LoadTranslation('ID_ALL');
|
||||
break;
|
||||
/*----------------------------------********---------------------------------*/
|
||||
case 'REASSIGN_MY_CASES':
|
||||
$objectType = G::LoadTranslation('ID_REASSIGN_MY_CASES');
|
||||
$object = self::DOES_NOT_APPLY;
|
||||
$aRow['OP_ACTION'] = self::DOES_NOT_APPLY;
|
||||
$participated = self::DOES_NOT_APPLY;
|
||||
break;
|
||||
/*----------------------------------********---------------------------------*/
|
||||
default:
|
||||
$sObjectType = G::LoadTranslation('ID_ALL');
|
||||
$sObject = G::LoadTranslation('ID_ALL');
|
||||
$objectType = G::LoadTranslation('ID_ALL');
|
||||
$object = G::LoadTranslation('ID_ALL');
|
||||
|
||||
break;
|
||||
}
|
||||
//Participated
|
||||
if ($aRow['OP_PARTICIPATE'] == 0) {
|
||||
$sParticipated = G::LoadTranslation('ID_NO');
|
||||
} else {
|
||||
$sParticipated = G::LoadTranslation('ID_YES');
|
||||
}
|
||||
//Obtain action (permission)
|
||||
$sAction = G::LoadTranslation('ID_' . $aRow['OP_ACTION']);
|
||||
|
||||
//Add to array
|
||||
$arrayTemp = array();
|
||||
$arrayTemp = array_merge($aRow, array(
|
||||
@@ -185,10 +183,10 @@ class ProcessPermissions
|
||||
'TASK_TARGET' => $sTaskTarget,
|
||||
'GROUP_USER' => $sUserGroup,
|
||||
'TASK_SOURCE' => $sTaskSource,
|
||||
'OBJECT_TYPE' => $sObjectType,
|
||||
'OBJECT' => $sObject,
|
||||
'PARTICIPATED' => $sParticipated,
|
||||
'ACTION' => $sAction,
|
||||
'OBJECT_TYPE' => $objectType,
|
||||
'OBJECT' => $object,
|
||||
'PARTICIPATED' => $participated,
|
||||
'ACTION' => $action,
|
||||
'OP_CASE_STATUS' => $aRow['OP_CASE_STATUS'])
|
||||
);
|
||||
$aObjectsPermissions[] = array_change_key_case($arrayTemp, CASE_LOWER);
|
||||
@@ -213,7 +211,7 @@ class ProcessPermissions
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
* @return void
|
||||
* @return void|array
|
||||
* @throws Exception
|
||||
*/
|
||||
public function saveProcessPermission($data, $opUid = '')
|
||||
@@ -226,7 +224,7 @@ class ProcessPermissions
|
||||
$opUid = $this->validateOpUid($opUid);
|
||||
}
|
||||
if (empty($data['USR_UID']) || (isset($data['USR_UID']) && $data['USR_UID'] === "null")) {
|
||||
throw (new StandardException(G::LoadTranslation("ID_SELECT_USER_OR_GROUP")));
|
||||
throw (new Exception(G::LoadTranslation("ID_SELECT_USER_OR_GROUP")));
|
||||
}
|
||||
if ($data['OP_USER_RELATION'] == "1") {
|
||||
$this->validateUsrUid($data['USR_UID']);
|
||||
@@ -244,50 +242,59 @@ class ProcessPermissions
|
||||
$data['OP_TASK_SOURCE'] = '';
|
||||
}
|
||||
|
||||
$sObjectUID = '';
|
||||
$opCaseStatus = !empty($data['OP_CASE_STATUS']) ? $data['OP_CASE_STATUS'] : '0';
|
||||
$opObjectUid = '';
|
||||
switch ($data['OP_OBJ_TYPE']) {
|
||||
case 'ANY':
|
||||
//case 'ANY_DYNAFORM':CASES_NOTES
|
||||
//case 'ANY_INPUT':
|
||||
//case 'ANY_OUTPUT':
|
||||
$sObjectUID = '';
|
||||
$opObjectUid = '';
|
||||
break;
|
||||
case 'DYNAFORM':
|
||||
$data['DYNAFORMS'] = $data['DYNAFORMS'] == 0 ? '': $data['DYNAFORMS'];
|
||||
if ($data['DYNAFORMS'] != '') {
|
||||
$this->validateDynUid($data['DYNAFORMS']);
|
||||
}
|
||||
$sObjectUID = $data['DYNAFORMS'];
|
||||
$opObjectUid = $data['DYNAFORMS'];
|
||||
break;
|
||||
case 'ATTACHED':
|
||||
$sObjectUID = '';
|
||||
$opObjectUid = '';
|
||||
break;
|
||||
case 'INPUT':
|
||||
$data['INPUTS'] = $data['INPUTS'] == 0 ? '': $data['INPUTS'];
|
||||
if ($data['INPUTS'] != '') {
|
||||
$this->validateInpUid($data['INPUTS']);
|
||||
}
|
||||
$sObjectUID = $data['INPUTS'];
|
||||
$opObjectUid = $data['INPUTS'];
|
||||
break;
|
||||
case 'OUTPUT':
|
||||
$data['OUTPUTS'] = $data['OUTPUTS'] == 0 ? '': $data['OUTPUTS'];
|
||||
if ($data['OUTPUTS'] != '') {
|
||||
$this->validateOutUid($data['OUTPUTS']);
|
||||
}
|
||||
$sObjectUID = $data['OUTPUTS'];
|
||||
$opObjectUid = $data['OUTPUTS'];
|
||||
break;
|
||||
case 'REASSIGN_MY_CASES':
|
||||
$opCaseStatus = 'TO_DO';
|
||||
$data['OP_ACTION'] = '';
|
||||
break;
|
||||
}
|
||||
$oOP = new \ObjectPermission();
|
||||
$objectPermission = new ObjectPermission();
|
||||
$permissionUid = ($opUid != '') ? $opUid : G::generateUniqueID();
|
||||
$data['OP_UID'] = $permissionUid;
|
||||
$data['OP_OBJ_UID'] = $sObjectUID;
|
||||
$opParticipate = empty($data['OP_PARTICIPATE']) ? ObjectPermission::OP_PARTICIPATE_NO : $data['OP_PARTICIPATE'];
|
||||
$data['OP_PARTICIPATE'] = $opParticipate;
|
||||
$data['OP_CASE_STATUS'] = $opCaseStatus;
|
||||
$data['OP_OBJ_UID'] = $opObjectUid;
|
||||
|
||||
if ($opUid == '') {
|
||||
$oOP->fromArray( $data, \BasePeer::TYPE_FIELDNAME );
|
||||
$oOP->save();
|
||||
$daraRes = $oOP->load($permissionUid);
|
||||
$daraRes = array_change_key_case($daraRes, CASE_LOWER);
|
||||
return $daraRes;
|
||||
if (empty($opUid)) {
|
||||
$objectPermission->fromArray($data, BasePeer::TYPE_FIELDNAME);
|
||||
$objectPermission->save();
|
||||
$newPermission = $objectPermission->load($permissionUid);
|
||||
$newPermission = array_change_key_case($newPermission, CASE_LOWER);
|
||||
|
||||
return $newPermission;
|
||||
} else {
|
||||
$data['TAS_UID'] = $data['TAS_UID'] != '' ? $data['TAS_UID'] : '0';
|
||||
$data['OP_TASK_SOURCE'] = $data['OP_TASK_SOURCE'] != '' ? $data['OP_TASK_SOURCE'] : '0';
|
||||
@@ -296,7 +303,8 @@ class ProcessPermissions
|
||||
$data['OP_OBJ_UID'] = $data['OP_OBJ_UID'] != '' ? $data['OP_OBJ_UID'] : '0';
|
||||
$data['OP_ACTION'] = $data['OP_ACTION'] != '' ? $data['OP_ACTION'] : '0';
|
||||
$data['OP_CASE_STATUS'] = $data['OP_CASE_STATUS'] != '' ? $data['OP_CASE_STATUS'] : '0';
|
||||
$oOP->update($data);
|
||||
|
||||
$objectPermission->update($data);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
|
||||
@@ -105,7 +105,7 @@ class ReportTable
|
||||
|
||||
$arrayAdditionalTableData = $additionalTable->loadByName($tableName);
|
||||
|
||||
if ($arrayAdditionalTableData !== false) {
|
||||
if ($arrayAdditionalTableData) {
|
||||
$flagIsPmTable = $arrayAdditionalTableData['PRO_UID'] == '';
|
||||
|
||||
if ($flagIsPmTable && !empty($contentData)) {
|
||||
@@ -275,7 +275,7 @@ class ReportTable
|
||||
|
||||
if ($flagFromAdmin) {
|
||||
if ($flagIsPmTable) {
|
||||
if ($arrayAdditionalTableData !== false && !$flagOverwrite) {
|
||||
if ($arrayAdditionalTableData && !$flagOverwrite) {
|
||||
$arrayError[$i]['NAME_TABLE'] = $contentSchema['ADD_TAB_NAME'];
|
||||
$arrayError[$i]['ERROR_TYPE'] = 1; //ERROR_PM_TABLES_OVERWRITE
|
||||
$arrayError[$i]['ERROR_MESS'] = \G::LoadTranslation('ID_OVERWRITE_PMTABLE', [$contentSchema['ADD_TAB_NAME']]);
|
||||
@@ -290,7 +290,7 @@ class ReportTable
|
||||
$arrayError[$i]['IS_PMTABLE'] = $flagIsPmTable;
|
||||
$arrayError[$i]['PRO_UID'] = $tableProUid;
|
||||
} else {
|
||||
if ($arrayAdditionalTableData !== false && !$flagOverwrite) {
|
||||
if ($arrayAdditionalTableData && !$flagOverwrite) {
|
||||
$arrayError[$i]['NAME_TABLE'] = $contentSchema['ADD_TAB_NAME'];
|
||||
$arrayError[$i]['ERROR_TYPE'] = 3; //ERROR_RP_TABLES_OVERWRITE
|
||||
$arrayError[$i]['ERROR_MESS'] = \G::LoadTranslation('ID_OVERWRITE_RPTABLE', [$contentSchema['ADD_TAB_NAME']]);
|
||||
@@ -307,14 +307,14 @@ class ReportTable
|
||||
$arrayError[$i]['IS_PMTABLE'] = $flagIsPmTable;
|
||||
$arrayError[$i]['PRO_UID'] = $tableProUid;
|
||||
} else {
|
||||
if ($tableProUid != $processUid) {
|
||||
if ($tableProUid !== $processUid) {
|
||||
$arrayError[$i]['NAME_TABLE'] = $contentSchema['ADD_TAB_NAME'];
|
||||
$arrayError[$i]['ERROR_TYPE'] = 5; //ERROR_OVERWRITE_RELATED_PROCESS
|
||||
$arrayError[$i]['ERROR_MESS'] = \G::LoadTranslation('ID_OVERWRITE_RELATED_PROCESS', [$contentSchema['ADD_TAB_NAME']]);
|
||||
$arrayError[$i]['IS_PMTABLE'] = $flagIsPmTable;
|
||||
$arrayError[$i]['PRO_UID'] = $tableProUid;
|
||||
} else {
|
||||
if ($arrayAdditionalTableData !== false && !$flagOverwrite) {
|
||||
if ($arrayAdditionalTableData && !$flagOverwrite) {
|
||||
$arrayError[$i]['NAME_TABLE'] = $contentSchema['ADD_TAB_NAME'];
|
||||
$arrayError[$i]['ERROR_TYPE'] = 3; //ERROR_RP_TABLES_OVERWRITE
|
||||
$arrayError[$i]['ERROR_MESS'] = \G::LoadTranslation('ID_OVERWRITE_RPTABLE', [$contentSchema['ADD_TAB_NAME']]);
|
||||
@@ -419,7 +419,7 @@ class ReportTable
|
||||
}
|
||||
|
||||
//Validations
|
||||
if (is_array($additionalTable->loadByName($arrayData['REP_TAB_NAME']))) {
|
||||
if ($additionalTable->loadByName($arrayData['REP_TAB_NAME'])) {
|
||||
throw new \Exception(\G::LoadTranslation('ID_PMTABLE_ALREADY_EXISTS', [$arrayData['REP_TAB_NAME']]));
|
||||
}
|
||||
|
||||
@@ -664,11 +664,11 @@ class ReportTable
|
||||
|
||||
//Overwrite
|
||||
if ($flagOverwrite2) {
|
||||
if ($arrayAdditionalTableData !== false) {
|
||||
if ($arrayAdditionalTableData) {
|
||||
$additionalTable->deleteAll($arrayAdditionalTableData['ADD_TAB_UID']);
|
||||
}
|
||||
} else {
|
||||
if ($arrayAdditionalTableData !== false) {
|
||||
if ($arrayAdditionalTableData) {
|
||||
//Some table exists with the same name
|
||||
//renaming...
|
||||
$tNameOld = $contentSchema['ADD_TAB_NAME'];
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\BusinessModel;
|
||||
|
||||
use \G;
|
||||
@@ -17,28 +18,28 @@ class ReportingIndicators
|
||||
*
|
||||
* return decimal value
|
||||
*/
|
||||
public function getHistoricData($indicatorUid, $initDate, $endDate, $periodicity, $language)
|
||||
public function getHistoricData($indicatorUid, $initDate, $endDate, $periodicity, $language)
|
||||
{
|
||||
$retval = "";
|
||||
$retval = "";
|
||||
$calculator = new \IndicatorsCalculator();
|
||||
$arr = $calculator->indicatorData($indicatorUid);
|
||||
$indicator = $arr[0];
|
||||
$processesId = $indicator['DAS_UID_PROCESS'];
|
||||
$indicatorType = $indicator['DAS_IND_TYPE'];
|
||||
switch ($indicatorType) {
|
||||
case \ReportingIndicatorTypeEnum::PEI:
|
||||
$retval = $calculator->peiHistoric($processesId, $initDate, $endDate, \ReportingPeriodicityEnum::fromValue($periodicity));
|
||||
break;
|
||||
case \ReportingIndicatorTypeEnum::UEI:
|
||||
$retval = $calculator->ueiHistoric($processesId, $initDate, $endDate, \ReportingPeriodicityEnum::fromValue($periodicity));
|
||||
break;
|
||||
default:
|
||||
throw new Exception("Can't retrive historic Data becasuse de indicator type " + $indicator['DAS_IND_TYPE'] + " has no operation associated.");
|
||||
break;
|
||||
}
|
||||
$processesId = $indicator['DAS_UID_PROCESS'];
|
||||
$indicatorType = $indicator['DAS_IND_TYPE'];
|
||||
switch ($indicatorType) {
|
||||
case \ReportingIndicatorTypeEnum::PEI:
|
||||
$retval = $calculator->peiHistoric($processesId, $initDate, $endDate, \ReportingPeriodicityEnum::fromValue($periodicity));
|
||||
break;
|
||||
case \ReportingIndicatorTypeEnum::UEI:
|
||||
$retval = $calculator->ueiHistoric($processesId, $initDate, $endDate, \ReportingPeriodicityEnum::fromValue($periodicity));
|
||||
break;
|
||||
default:
|
||||
throw new Exception("Can't retrive historic Data becasuse de indicator type " + $indicator['DAS_IND_TYPE'] + " has no operation associated.");
|
||||
break;
|
||||
}
|
||||
return $retval;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Lists tasks of a process and it's statistics (efficiency, average times, etc.)
|
||||
@@ -50,24 +51,30 @@ class ReportingIndicators
|
||||
*
|
||||
* return decimal value
|
||||
*/
|
||||
public function getPeiCompleteData($indicatorUid, $compareDate, $measureDate, $language)
|
||||
public function getPeiCompleteData($indicatorUid, $compareDate, $measureDate, $language)
|
||||
{
|
||||
$calculator = new \IndicatorsCalculator();
|
||||
$processes = $calculator->peiProcesses($indicatorUid, $measureDate, $measureDate, $language);
|
||||
$arr = $calculator->indicatorData($indicatorUid);
|
||||
$indicator = $arr[0];
|
||||
$processesId = $indicator['DAS_UID_PROCESS'];
|
||||
$peiValue = current(reset($calculator->peiHistoric($processesId, $measureDate, $measureDate, \ReportingPeriodicityEnum::NONE)));
|
||||
$peiCost = current(reset($calculator->peiCostHistoric($processesId, $measureDate, $measureDate, \ReportingPeriodicityEnum::NONE)));
|
||||
$peiCompare = current(reset($calculator->peiHistoric($processesId, $compareDate, $compareDate, \ReportingPeriodicityEnum::NONE)));
|
||||
$processesId = $indicator['DAS_UID_PROCESS'];
|
||||
$peiValue = $calculator->peiHistoric($processesId, $measureDate, $measureDate, \ReportingPeriodicityEnum::NONE);
|
||||
$peiValue = reset($peiValue);
|
||||
$peiValue = current($peiValue);
|
||||
$peiCost = $calculator->peiCostHistoric($processesId, $measureDate, $measureDate, \ReportingPeriodicityEnum::NONE);
|
||||
$peiCost = reset($peiCost);
|
||||
$peiCost = current($peiCost);
|
||||
$peiCompare = $calculator->peiHistoric($processesId, $compareDate, $compareDate, \ReportingPeriodicityEnum::NONE);
|
||||
$peiCompare = reset($peiCompare);
|
||||
$peiCompare = current($peiCompare);
|
||||
|
||||
$retval = array(
|
||||
"id" => $indicatorUid,
|
||||
"efficiencyIndex" => $peiValue,
|
||||
"efficiencyIndexToCompare" => $peiCompare,
|
||||
"efficiencyVariation" => ($peiValue-$peiCompare),
|
||||
"inefficiencyCost" => $peiCost,
|
||||
"data"=>$processes);
|
||||
$retval = array(
|
||||
"id" => $indicatorUid,
|
||||
"efficiencyIndex" => $peiValue,
|
||||
"efficiencyIndexToCompare" => $peiCompare,
|
||||
"efficiencyVariation" => ($peiValue - $peiCompare),
|
||||
"inefficiencyCost" => $peiCost,
|
||||
"data" => $processes);
|
||||
return $retval;
|
||||
}
|
||||
|
||||
@@ -81,25 +88,31 @@ class ReportingIndicators
|
||||
*
|
||||
* return decimal value
|
||||
*/
|
||||
public function getUeiCompleteData($indicatorUid, $compareDate, $measureDate,$language)
|
||||
public function getUeiCompleteData($indicatorUid, $compareDate, $measureDate, $language)
|
||||
{
|
||||
$calculator = new \IndicatorsCalculator();
|
||||
$groups = $calculator->ueiUserGroups($indicatorUid, $measureDate, $measureDate, $language);
|
||||
|
||||
//TODO think what if each indicators has a group or user subset assigned. Now are all
|
||||
$ueiValue = current(reset($calculator->ueiHistoric(null, $measureDate, $measureDate, \ReportingPeriodicityEnum::NONE)));
|
||||
$ueiValue = $calculator->ueiHistoric(null, $measureDate, $measureDate, \ReportingPeriodicityEnum::NONE);
|
||||
$ueiValue = reset($ueiValue);
|
||||
$ueiValue = current($ueiValue);
|
||||
$arrCost = $calculator->ueiUserGroups($indicatorUid, $measureDate, $measureDate, $language);
|
||||
|
||||
$ueiCost = current(reset($calculator->ueiCostHistoric(null, $measureDate, $measureDate, \ReportingPeriodicityEnum::NONE)));
|
||||
$ueiCompare = current(reset($calculator->ueiHistoric(null, $compareDate, $compareDate, \ReportingPeriodicityEnum::NONE)));
|
||||
$ueiCost = $calculator->ueiCostHistoric(null, $measureDate, $measureDate, \ReportingPeriodicityEnum::NONE);
|
||||
$ueiCost = reset($ueiCost);
|
||||
$ueiCost = is_array($ueiCost) ? current($ueiCost) : $ueiCost;
|
||||
$ueiCompare = $calculator->ueiHistoric(null, $compareDate, $compareDate, \ReportingPeriodicityEnum::NONE);
|
||||
$ueiCompare = reset($ueiCompare);
|
||||
$ueiCompare = current($ueiCompare);
|
||||
|
||||
$retval = array(
|
||||
"id" => $indicatorUid,
|
||||
"efficiencyIndex" => $ueiValue,
|
||||
"efficiencyVariation" => ($ueiValue-$ueiCompare),
|
||||
"inefficiencyCost" => $ueiCost,
|
||||
"efficiencyIndexToCompare" => $ueiCompare,
|
||||
"data"=>$groups);
|
||||
$retval = array(
|
||||
'id' => $indicatorUid,
|
||||
'efficiencyIndex' => $ueiValue,
|
||||
'efficiencyVariation' => $ueiValue - $ueiCompare,
|
||||
'inefficiencyCost' => $ueiCost,
|
||||
'efficiencyIndexToCompare' => $ueiCompare,
|
||||
'data' => $groups);
|
||||
return $retval;
|
||||
}
|
||||
|
||||
@@ -154,27 +167,33 @@ class ReportingIndicators
|
||||
$arr = $calculator->generalIndicatorData($indicatorId, $initDate, $endDate, \ReportingPeriodicityEnum::NONE);
|
||||
$value = $arr[0]['value'];
|
||||
$dataList1 = $calculator->
|
||||
generalIndicatorData($indicatorId,
|
||||
$initDate, $endDate,
|
||||
\ReportingPeriodicityEnum::fromValue($arr[0]['frequency1Type']));
|
||||
generalIndicatorData(
|
||||
$indicatorId,
|
||||
$initDate,
|
||||
$endDate,
|
||||
\ReportingPeriodicityEnum::fromValue($arr[0]['frequency1Type'])
|
||||
);
|
||||
|
||||
$dataList2 = $calculator->
|
||||
generalIndicatorData($indicatorId,
|
||||
$initDate, $endDate,
|
||||
\ReportingPeriodicityEnum::fromValue($arr[0]['frequency2Type']));
|
||||
generalIndicatorData(
|
||||
$indicatorId,
|
||||
$initDate,
|
||||
$endDate,
|
||||
\ReportingPeriodicityEnum::fromValue($arr[0]['frequency2Type'])
|
||||
);
|
||||
|
||||
$returnValue = array("index" => $value,
|
||||
"graph1XLabel"=>$arr[0]['graph1XLabel'],
|
||||
"graph1YLabel"=>$arr[0]['graph1YLabel'],
|
||||
"graph2XLabel"=>$arr[0]['graph2XLabel'],
|
||||
"graph2YLabel"=>$arr[0]['graph2YLabel'],
|
||||
"graph1Type"=>$arr[0]['graph1Type'],
|
||||
"graph2Type"=>$arr[0]['graph2Type'],
|
||||
"frequency1Type"=>$arr[0]['frequency1Type'],
|
||||
"frequency2Type"=>$arr[0]['frequency2Type'],
|
||||
"graph1Data"=>$dataList1,
|
||||
"graph2Data"=>$dataList2
|
||||
);
|
||||
"graph1XLabel" => $arr[0]['graph1XLabel'],
|
||||
"graph1YLabel" => $arr[0]['graph1YLabel'],
|
||||
"graph2XLabel" => $arr[0]['graph2XLabel'],
|
||||
"graph2YLabel" => $arr[0]['graph2YLabel'],
|
||||
"graph1Type" => $arr[0]['graph1Type'],
|
||||
"graph2Type" => $arr[0]['graph2Type'],
|
||||
"frequency1Type" => $arr[0]['frequency1Type'],
|
||||
"frequency2Type" => $arr[0]['frequency2Type'],
|
||||
"graph1Data" => $dataList1,
|
||||
"graph2Data" => $dataList2
|
||||
);
|
||||
return $returnValue;
|
||||
}
|
||||
|
||||
@@ -182,7 +201,7 @@ class ReportingIndicators
|
||||
* Get list status indicator
|
||||
*
|
||||
* @access public
|
||||
* @param array $options, Data for list
|
||||
* @param array $options , Data for list
|
||||
* @return array
|
||||
*
|
||||
* @author Marco Antonio Nina <marco.antonio.nina@colosa.com>
|
||||
@@ -192,11 +211,10 @@ class ReportingIndicators
|
||||
{
|
||||
Validator::isArray($options, '$options');
|
||||
|
||||
$usrUid = isset( $options["usrUid"] ) ? $options["usrUid"] : "";
|
||||
$usrUid = isset($options["usrUid"]) ? $options["usrUid"] : "";
|
||||
|
||||
$calculator = new \IndicatorsCalculator();
|
||||
$result = $calculator->statusIndicator($usrUid);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -253,7 +253,7 @@ class Table
|
||||
|
||||
// validations
|
||||
if ($createRep) {
|
||||
if (is_array( $oAdditionalTables->loadByName( $tableName ) )) {
|
||||
if ($oAdditionalTables->loadByName($tableName)) {
|
||||
throw new \Exception(G::loadTranslation('ID_PMTABLE_ALREADY_EXISTS', array($tableName)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,35 +45,197 @@ use UsersRolesPeer;
|
||||
class User
|
||||
{
|
||||
private $arrayFieldDefinition = array(
|
||||
"USR_UID" => array("type" => "string", "required" => false, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "usrUid"),
|
||||
"USR_FIRSTNAME" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "usrFirstname"),
|
||||
"USR_LASTNAME" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "usrLastname"),
|
||||
"USR_USERNAME" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "usrUsername"),
|
||||
"USR_EMAIL" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "usrEmail"),
|
||||
"USR_ADDRESS" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "usrAddress"),
|
||||
"USR_ZIP_CODE" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "usrZipCode"),
|
||||
"USR_COUNTRY" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "usrCountry"),
|
||||
"USR_CITY" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "usrCity"),
|
||||
"USR_LOCATION" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "usrLocation"),
|
||||
"USR_PHONE" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "usrPhone"),
|
||||
"USR_POSITION" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "usrPosition"),
|
||||
"USR_REPLACED_BY" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "usrReplacedBy"),
|
||||
"USR_DUE_DATE" => array("type" => "date", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "usrDueDate"),
|
||||
"USR_CALENDAR" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "usrCalendar"),
|
||||
"USR_STATUS" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array("ACTIVE", "INACTIVE", "VACATION"), "fieldNameAux" => "usrStatus"),
|
||||
"USR_ROLE" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "usrRole"),
|
||||
"USR_NEW_PASS" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "usrNewPass"),
|
||||
"USR_UX" => array("type" => "string", "required" => false, "empty" => false, "defaultValues" => array("NORMAL", "SIMPLIFIED", "SWITCHABLE", "SINGLE"), "fieldNameAux" => "usrUx"),
|
||||
"DEP_UID" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "depUid"),
|
||||
"USR_BIRTHDAY" => array("type" => "date", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "usrBirthday"),
|
||||
"USR_FAX" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "usrFax"),
|
||||
"USR_CELLULAR" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "usrCellular"),
|
||||
"USR_UID" => array(
|
||||
"type" => "string",
|
||||
"required" => false,
|
||||
"empty" => false,
|
||||
"defaultValues" => array(),
|
||||
"fieldNameAux" => "usrUid"
|
||||
),
|
||||
"USR_FIRSTNAME" => array(
|
||||
"type" => "string",
|
||||
"required" => true,
|
||||
"empty" => false,
|
||||
"defaultValues" => array(),
|
||||
"fieldNameAux" => "usrFirstname"
|
||||
),
|
||||
"USR_LASTNAME" => array(
|
||||
"type" => "string",
|
||||
"required" => true,
|
||||
"empty" => false,
|
||||
"defaultValues" => array(),
|
||||
"fieldNameAux" => "usrLastname"
|
||||
),
|
||||
"USR_USERNAME" => array(
|
||||
"type" => "string",
|
||||
"required" => true,
|
||||
"empty" => false,
|
||||
"defaultValues" => array(),
|
||||
"fieldNameAux" => "usrUsername"
|
||||
),
|
||||
"USR_EMAIL" => array(
|
||||
"type" => "string",
|
||||
"required" => true,
|
||||
"empty" => false,
|
||||
"defaultValues" => array(),
|
||||
"fieldNameAux" => "usrEmail"
|
||||
),
|
||||
"USR_ADDRESS" => array(
|
||||
"type" => "string",
|
||||
"required" => false,
|
||||
"empty" => true,
|
||||
"defaultValues" => array(),
|
||||
"fieldNameAux" => "usrAddress"
|
||||
),
|
||||
"USR_ZIP_CODE" => array(
|
||||
"type" => "string",
|
||||
"required" => false,
|
||||
"empty" => true,
|
||||
"defaultValues" => array(),
|
||||
"fieldNameAux" => "usrZipCode"
|
||||
),
|
||||
"USR_COUNTRY" => array(
|
||||
"type" => "string",
|
||||
"required" => false,
|
||||
"empty" => true,
|
||||
"defaultValues" => array(),
|
||||
"fieldNameAux" => "usrCountry"
|
||||
),
|
||||
"USR_CITY" => array(
|
||||
"type" => "string",
|
||||
"required" => false,
|
||||
"empty" => true,
|
||||
"defaultValues" => array(),
|
||||
"fieldNameAux" => "usrCity"
|
||||
),
|
||||
"USR_LOCATION" => array(
|
||||
"type" => "string",
|
||||
"required" => false,
|
||||
"empty" => true,
|
||||
"defaultValues" => array(),
|
||||
"fieldNameAux" => "usrLocation"
|
||||
),
|
||||
"USR_PHONE" => array(
|
||||
"type" => "string",
|
||||
"required" => false,
|
||||
"empty" => true,
|
||||
"defaultValues" => array(),
|
||||
"fieldNameAux" => "usrPhone"
|
||||
),
|
||||
"USR_POSITION" => array(
|
||||
"type" => "string",
|
||||
"required" => false,
|
||||
"empty" => true,
|
||||
"defaultValues" => array(),
|
||||
"fieldNameAux" => "usrPosition"
|
||||
),
|
||||
"USR_REPLACED_BY" => array(
|
||||
"type" => "string",
|
||||
"required" => false,
|
||||
"empty" => true,
|
||||
"defaultValues" => array(),
|
||||
"fieldNameAux" => "usrReplacedBy"
|
||||
),
|
||||
"USR_DUE_DATE" => array(
|
||||
"type" => "date",
|
||||
"required" => true,
|
||||
"empty" => false,
|
||||
"defaultValues" => array(),
|
||||
"fieldNameAux" => "usrDueDate"
|
||||
),
|
||||
"USR_CALENDAR" => array(
|
||||
"type" => "string",
|
||||
"required" => false,
|
||||
"empty" => true,
|
||||
"defaultValues" => array(),
|
||||
"fieldNameAux" => "usrCalendar"
|
||||
),
|
||||
"USR_STATUS" => array(
|
||||
"type" => "string",
|
||||
"required" => true,
|
||||
"empty" => false,
|
||||
"defaultValues" => array("ACTIVE", "INACTIVE", "VACATION"),
|
||||
"fieldNameAux" => "usrStatus"
|
||||
),
|
||||
"USR_ROLE" => array(
|
||||
"type" => "string",
|
||||
"required" => true,
|
||||
"empty" => false,
|
||||
"defaultValues" => array(),
|
||||
"fieldNameAux" => "usrRole"
|
||||
),
|
||||
"USR_NEW_PASS" => array(
|
||||
"type" => "string",
|
||||
"required" => true,
|
||||
"empty" => false,
|
||||
"defaultValues" => array(),
|
||||
"fieldNameAux" => "usrNewPass"
|
||||
),
|
||||
"USR_UX" => array(
|
||||
"type" => "string",
|
||||
"required" => false,
|
||||
"empty" => false,
|
||||
"defaultValues" => array("NORMAL", "SIMPLIFIED", "SWITCHABLE", "SINGLE"),
|
||||
"fieldNameAux" => "usrUx"
|
||||
),
|
||||
"DEP_UID" => array(
|
||||
"type" => "string",
|
||||
"required" => false,
|
||||
"empty" => true,
|
||||
"defaultValues" => array(),
|
||||
"fieldNameAux" => "depUid"
|
||||
),
|
||||
"USR_BIRTHDAY" => array(
|
||||
"type" => "date",
|
||||
"required" => false,
|
||||
"empty" => true,
|
||||
"defaultValues" => array(),
|
||||
"fieldNameAux" => "usrBirthday"
|
||||
),
|
||||
"USR_FAX" => array(
|
||||
"type" => "string",
|
||||
"required" => false,
|
||||
"empty" => true,
|
||||
"defaultValues" => array(),
|
||||
"fieldNameAux" => "usrFax"
|
||||
),
|
||||
"USR_CELLULAR" => array(
|
||||
"type" => "string",
|
||||
"required" => false,
|
||||
"empty" => true,
|
||||
"defaultValues" => array(),
|
||||
"fieldNameAux" => "usrCellular"
|
||||
),
|
||||
/*----------------------------------********---------------------------------*/
|
||||
"USR_COST_BY_HOUR" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "usrCostByHour"),
|
||||
"USR_UNIT_COST" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "usrUnitCost"),
|
||||
"USR_COST_BY_HOUR" => array(
|
||||
"type" => "string",
|
||||
"required" => false,
|
||||
"empty" => true,
|
||||
"defaultValues" => array(),
|
||||
"fieldNameAux" => "usrCostByHour"
|
||||
),
|
||||
"USR_UNIT_COST" => array(
|
||||
"type" => "string",
|
||||
"required" => false,
|
||||
"empty" => true,
|
||||
"defaultValues" => array(),
|
||||
"fieldNameAux" => "usrUnitCost"
|
||||
),
|
||||
/*----------------------------------********---------------------------------*/
|
||||
'USR_LOGGED_NEXT_TIME' => ['type' => 'int', 'required' => false, 'empty' => false, 'defaultValues' => [0, 1], 'fieldNameAux' => 'usrLoggedNextTime'],
|
||||
'USR_TIME_ZONE' => ['type' => 'string', 'required' => false, 'empty' => true, 'defaultValues' => [], 'fieldNameAux' => 'usrTimeZone']
|
||||
'USR_LOGGED_NEXT_TIME' => [
|
||||
'type' => 'int',
|
||||
'required' => false,
|
||||
'empty' => false,
|
||||
'defaultValues' => [0, 1],
|
||||
'fieldNameAux' => 'usrLoggedNextTime'
|
||||
],
|
||||
'USR_TIME_ZONE' => [
|
||||
'type' => 'string',
|
||||
'required' => false,
|
||||
'empty' => true,
|
||||
'defaultValues' => [],
|
||||
'fieldNameAux' => 'usrTimeZone'
|
||||
]
|
||||
);
|
||||
|
||||
private $formatFieldNameInUppercase = true;
|
||||
@@ -148,7 +310,9 @@ class User
|
||||
|
||||
/**
|
||||
* Set the format of the fields name (uppercase, lowercase)
|
||||
*
|
||||
* @param bool $flag Value that set the format
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function setFormatFieldNameInUppercase($flag)
|
||||
@@ -164,7 +328,9 @@ class User
|
||||
|
||||
/**
|
||||
* Set exception users for fields
|
||||
*
|
||||
* @param array $arrayData Data with the fields
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function setArrayFieldNameForException(array $arrayData)
|
||||
@@ -180,7 +346,9 @@ class User
|
||||
|
||||
/**
|
||||
* Get the name of the field according to the format
|
||||
*
|
||||
* @param string $fieldName Field name
|
||||
*
|
||||
* @return string Return the field name according the format
|
||||
* @throws Exception
|
||||
*/
|
||||
@@ -195,8 +363,10 @@ class User
|
||||
|
||||
/**
|
||||
* Verify if exists the Name of a User
|
||||
* @param string $userName Name
|
||||
*
|
||||
* @param string $userName Name
|
||||
* @param string $userUidToExclude Unique id of User to exclude
|
||||
*
|
||||
* @return bool Return true if exists the Name of a User, false otherwise
|
||||
* @throws Exception
|
||||
*/
|
||||
@@ -223,16 +393,19 @@ class User
|
||||
|
||||
/**
|
||||
* Verify if exists the Name of a User
|
||||
* @param string $userName Name
|
||||
*
|
||||
* @param string $userName Name
|
||||
* @param string $fieldNameForException Field name for the exception
|
||||
* @param string $userUidToExclude Unique id of User to exclude
|
||||
* @param string $userUidToExclude Unique id of User to exclude
|
||||
*
|
||||
* @throws Exception if exists the title of a User
|
||||
*/
|
||||
public function throwExceptionIfExistsName($userName, $fieldNameForException, $userUidToExclude = "")
|
||||
{
|
||||
try {
|
||||
if ($this->existsName($userName, $userUidToExclude)) {
|
||||
throw new Exception(G::LoadTranslation("ID_USER_NAME_ALREADY_EXISTS", array($fieldNameForException, $userName)));
|
||||
throw new Exception(G::LoadTranslation("ID_USER_NAME_ALREADY_EXISTS",
|
||||
array($fieldNameForException, $userName)));
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
@@ -241,8 +414,10 @@ class User
|
||||
|
||||
/**
|
||||
* Verify password
|
||||
* @param string $userPassword Password
|
||||
*
|
||||
* @param string $userPassword Password
|
||||
* @param string $fieldNameForException Field name for the exception
|
||||
*
|
||||
* @throws Exception if password is invalid
|
||||
*/
|
||||
public function throwExceptionIfPasswordIsInvalid($userPassword, $fieldNameForException)
|
||||
@@ -260,8 +435,10 @@ class User
|
||||
|
||||
/**
|
||||
* Validate the data if they are invalid (INSERT and UPDATE)
|
||||
* @param string $userUid Unique id of User
|
||||
* @param array $arrayData Data
|
||||
*
|
||||
* @param string $userUid Unique id of User
|
||||
* @param array $arrayData Data
|
||||
*
|
||||
* @throws Exception if data has an invalid value
|
||||
*/
|
||||
public function throwExceptionIfDataIsInvalid($userUid, array $arrayData)
|
||||
@@ -276,11 +453,13 @@ class User
|
||||
//Verify data - Field definition.
|
||||
$process = new Process();
|
||||
|
||||
$process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayFieldDefinition, $this->arrayFieldNameForException, $flagInsert);
|
||||
$process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayFieldDefinition,
|
||||
$this->arrayFieldNameForException, $flagInsert);
|
||||
|
||||
//Verify data
|
||||
if (isset($arrayData["USR_USERNAME"])) {
|
||||
$this->throwExceptionIfExistsName($arrayData["USR_USERNAME"], $this->arrayFieldNameForException["usrUsername"], $userUid);
|
||||
$this->throwExceptionIfExistsName($arrayData["USR_USERNAME"],
|
||||
$this->arrayFieldNameForException["usrUsername"], $userUid);
|
||||
}
|
||||
|
||||
if (isset($arrayData["USR_EMAIL"])) {
|
||||
@@ -290,14 +469,16 @@ class User
|
||||
}
|
||||
|
||||
if (isset($arrayData["USR_NEW_PASS"])) {
|
||||
$this->throwExceptionIfPasswordIsInvalid($arrayData["USR_NEW_PASS"], $this->arrayFieldNameForException["usrNewPass"]);
|
||||
$this->throwExceptionIfPasswordIsInvalid($arrayData["USR_NEW_PASS"],
|
||||
$this->arrayFieldNameForException["usrNewPass"]);
|
||||
}
|
||||
|
||||
if (isset($arrayData["USR_REPLACED_BY"]) && $arrayData["USR_REPLACED_BY"] != "") {
|
||||
$obj = UsersPeer::retrieveByPK($arrayData["USR_REPLACED_BY"]);
|
||||
|
||||
if (is_null($obj)) {
|
||||
throw new Exception(G::LoadTranslation("ID_USER_DOES_NOT_EXIST", array($this->arrayFieldNameForException["usrReplacedBy"], $arrayData["USR_REPLACED_BY"])));
|
||||
throw new Exception(G::LoadTranslation("ID_USER_DOES_NOT_EXIST",
|
||||
array($this->arrayFieldNameForException["usrReplacedBy"], $arrayData["USR_REPLACED_BY"])));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -322,7 +503,8 @@ class User
|
||||
$rsCriteria = RolesPeer::doSelectRS($criteria);
|
||||
|
||||
if (!$rsCriteria->next()) {
|
||||
throw new Exception(G::LoadTranslation("ID_INVALID_VALUE_FOR", array($this->arrayFieldNameForException["usrRole"])));
|
||||
throw new Exception(G::LoadTranslation("ID_INVALID_VALUE_FOR",
|
||||
array($this->arrayFieldNameForException["usrRole"])));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -330,31 +512,36 @@ class User
|
||||
$obj = IsoCountryPeer::retrieveByPK($arrayData["USR_COUNTRY"]);
|
||||
|
||||
if (is_null($obj)) {
|
||||
throw new Exception(G::LoadTranslation("ID_INVALID_VALUE_FOR", array($this->arrayFieldNameForException["usrCountry"])));
|
||||
throw new Exception(G::LoadTranslation("ID_INVALID_VALUE_FOR",
|
||||
array($this->arrayFieldNameForException["usrCountry"])));
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($arrayData["USR_CITY"]) && $arrayData["USR_CITY"] != "") {
|
||||
if (!isset($arrayFinalData["USR_COUNTRY"]) || $arrayFinalData["USR_COUNTRY"] == "") {
|
||||
throw new Exception(G::LoadTranslation("ID_INVALID_VALUE_FOR", array($this->arrayFieldNameForException["usrCountry"])));
|
||||
throw new Exception(G::LoadTranslation("ID_INVALID_VALUE_FOR",
|
||||
array($this->arrayFieldNameForException["usrCountry"])));
|
||||
}
|
||||
|
||||
$obj = IsoSubdivisionPeer::retrieveByPK($arrayFinalData["USR_COUNTRY"], $arrayData["USR_CITY"]);
|
||||
|
||||
if (is_null($obj)) {
|
||||
throw new Exception(G::LoadTranslation("ID_INVALID_VALUE_FOR", array($this->arrayFieldNameForException["usrCity"])));
|
||||
throw new Exception(G::LoadTranslation("ID_INVALID_VALUE_FOR",
|
||||
array($this->arrayFieldNameForException["usrCity"])));
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($arrayData["USR_LOCATION"]) && $arrayData["USR_LOCATION"] != "") {
|
||||
if (!isset($arrayFinalData["USR_COUNTRY"]) || $arrayFinalData["USR_COUNTRY"] == "") {
|
||||
throw new Exception(G::LoadTranslation("ID_INVALID_VALUE_FOR", array($this->arrayFieldNameForException["usrCountry"])));
|
||||
throw new Exception(G::LoadTranslation("ID_INVALID_VALUE_FOR",
|
||||
array($this->arrayFieldNameForException["usrCountry"])));
|
||||
}
|
||||
|
||||
$obj = IsoLocationPeer::retrieveByPK($arrayFinalData["USR_COUNTRY"], $arrayData["USR_LOCATION"]);
|
||||
|
||||
if (is_null($obj)) {
|
||||
throw new Exception(G::LoadTranslation("ID_INVALID_VALUE_FOR", array($this->arrayFieldNameForException["usrLocation"])));
|
||||
throw new Exception(G::LoadTranslation("ID_INVALID_VALUE_FOR",
|
||||
array($this->arrayFieldNameForException["usrLocation"])));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -362,7 +549,8 @@ class User
|
||||
$obj = CalendarDefinitionPeer::retrieveByPK($arrayData["USR_CALENDAR"]);
|
||||
|
||||
if (is_null($obj)) {
|
||||
throw new Exception(G::LoadTranslation("ID_CALENDAR_DOES_NOT_EXIST", array($this->arrayFieldNameForException["usrCalendar"], $arrayData["USR_CALENDAR"])));
|
||||
throw new Exception(G::LoadTranslation("ID_CALENDAR_DOES_NOT_EXIST",
|
||||
array($this->arrayFieldNameForException["usrCalendar"], $arrayData["USR_CALENDAR"])));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -370,13 +558,15 @@ class User
|
||||
$department = new Department();
|
||||
|
||||
if (!$department->existsDepartment($arrayData["DEP_UID"])) {
|
||||
throw new Exception(G::LoadTranslation("ID_DEPARTMENT_NOT_EXIST", array($this->arrayFieldNameForException["depUid"], $arrayData["DEP_UID"])));
|
||||
throw new Exception(G::LoadTranslation("ID_DEPARTMENT_NOT_EXIST",
|
||||
array($this->arrayFieldNameForException["depUid"], $arrayData["DEP_UID"])));
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($arrayData['USR_TIME_ZONE']) && $arrayData['USR_TIME_ZONE'] != '') {
|
||||
if (!in_array($arrayData['USR_TIME_ZONE'], DateTimeZone::listIdentifiers())) {
|
||||
throw new Exception(G::LoadTranslation('ID_TIME_ZONE_DOES_NOT_EXIST', [$this->arrayFieldNameForException['usrTimeZone'], $arrayData['USR_TIME_ZONE']]));
|
||||
throw new Exception(G::LoadTranslation('ID_TIME_ZONE_DOES_NOT_EXIST',
|
||||
[$this->arrayFieldNameForException['usrTimeZone'], $arrayData['USR_TIME_ZONE']]));
|
||||
}
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
@@ -386,8 +576,10 @@ class User
|
||||
|
||||
/**
|
||||
* Verify if does not exist the User in table USERS
|
||||
* @param string $userUid Unique id of Email Server
|
||||
*
|
||||
* @param string $userUid Unique id of Email Server
|
||||
* @param string $fieldNameForException Field name for the exception
|
||||
*
|
||||
* @throws Exception if does not exist the User in table USERS
|
||||
*/
|
||||
public function throwExceptionIfNotExistsUser($userUid, $fieldNameForException)
|
||||
@@ -396,7 +588,8 @@ class User
|
||||
$obj = UsersPeer::retrieveByPK($userUid);
|
||||
|
||||
if (is_null($obj) || $obj->getUsrUsername() == "") {
|
||||
throw new Exception(G::LoadTranslation("ID_USER_DOES_NOT_EXIST", array($fieldNameForException, $userUid)));
|
||||
throw new Exception(G::LoadTranslation("ID_USER_DOES_NOT_EXIST",
|
||||
array($fieldNameForException, $userUid)));
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
@@ -405,10 +598,13 @@ class User
|
||||
|
||||
/**
|
||||
* Get User record
|
||||
* @param string $userUid Unique id of User
|
||||
* @param array $arrayVariableNameForException Variable name for exception
|
||||
* @param bool $throwException Flag to throw the exception if the main parameters are invalid or do not exist
|
||||
* (TRUE: throw the exception; FALSE: returns FALSE)
|
||||
*
|
||||
* @param string $userUid Unique id of User
|
||||
* @param array $arrayVariableNameForException Variable name for exception
|
||||
* @param bool $throwException Flag to throw the exception if the main parameters are invalid or
|
||||
* do not exist
|
||||
* (TRUE: throw the exception; FALSE: returns FALSE)
|
||||
*
|
||||
* @return array|bool Returns an array with User record, ThrowTheException/FALSE otherwise
|
||||
* @throws Exception
|
||||
*/
|
||||
@@ -437,7 +633,9 @@ class User
|
||||
|
||||
/**
|
||||
* Get custom record
|
||||
*
|
||||
* @param array $record Record
|
||||
*
|
||||
* @return array Return an array with custom record
|
||||
* @throws Exception
|
||||
*/
|
||||
@@ -504,6 +702,7 @@ class User
|
||||
|
||||
/**
|
||||
* Get criteria for User
|
||||
*
|
||||
* @return object
|
||||
* @throws Exception
|
||||
*/
|
||||
@@ -553,7 +752,9 @@ class User
|
||||
|
||||
/**
|
||||
* Create User
|
||||
*
|
||||
* @param array $arrayData Data
|
||||
*
|
||||
* @return array Return data of the new User created
|
||||
* @throws Exception
|
||||
*/
|
||||
@@ -617,7 +818,8 @@ class User
|
||||
//User Properties
|
||||
$userProperty = new UsersProperties();
|
||||
|
||||
$aUserProperty = $userProperty->loadOrCreateIfNotExists($arrayData["USR_UID"], array("USR_PASSWORD_HISTORY" => serialize(array(Bootstrap::hashPassword($arrayData["USR_PASSWORD"])))));
|
||||
$aUserProperty = $userProperty->loadOrCreateIfNotExists($arrayData["USR_UID"],
|
||||
array("USR_PASSWORD_HISTORY" => serialize(array(Bootstrap::hashPassword($arrayData["USR_PASSWORD"])))));
|
||||
$aUserProperty["USR_LOGGED_NEXT_TIME"] = $arrayData["USR_LOGGED_NEXT_TIME"];
|
||||
|
||||
$userProperty->update($aUserProperty);
|
||||
@@ -644,9 +846,11 @@ class User
|
||||
|
||||
/**
|
||||
* Update User
|
||||
* @param string $userUid Unique id of User
|
||||
* @param array $arrayData Data
|
||||
*
|
||||
* @param string $userUid Unique id of User
|
||||
* @param array $arrayData Data
|
||||
* @param string $userUidLogged Unique id of User logged
|
||||
*
|
||||
* @return array data of the User updated
|
||||
* @throws Exception
|
||||
*/
|
||||
@@ -731,13 +935,13 @@ class User
|
||||
|
||||
if (isset($arrayData["USR_PASSWORD"])) {
|
||||
if ($arrayData["USR_PASSWORD"] != "") {
|
||||
//require_once 'classes/model/UsersProperties.php';
|
||||
|
||||
$userProperty = new UsersProperties();
|
||||
$aUserProperty = $userProperty->loadOrCreateIfNotExists($userUid, array("USR_PASSWORD_HISTORY" => serialize(array(Bootstrap::hashPassword($arrayData["USR_PASSWORD"])))));
|
||||
$aUserProperty = $userProperty->loadOrCreateIfNotExists($userUid,
|
||||
array("USR_PASSWORD_HISTORY" => serialize(array(Bootstrap::hashPassword($arrayData["USR_PASSWORD"])))));
|
||||
|
||||
$memKey = "rbacSession" . session_id();
|
||||
$memcache = &PMmemcached::getSingleton(!empty(config("system.workspace")) ? config("system.workspace") : "");
|
||||
$memcache = PMmemcached::getSingleton(!empty(config("system.workspace")) ? config("system.workspace") : "");
|
||||
|
||||
if (($rbac->aUserInfo = $memcache->get($memKey)) == false) {
|
||||
$rbac->loadUserRolePermission("PROCESSMAKER", $userUidLogged);
|
||||
@@ -803,7 +1007,8 @@ class User
|
||||
$oUser = new Users();
|
||||
$aUser = $oUser->load($userUid);
|
||||
$oUserProperty = new UsersProperties();
|
||||
$aUserProperty = $oUserProperty->loadOrCreateIfNotExists($userUid, array("USR_PASSWORD_HISTORY" => serialize(array($oUser->getUsrPassword()))));
|
||||
$aUserProperty = $oUserProperty->loadOrCreateIfNotExists($userUid,
|
||||
array("USR_PASSWORD_HISTORY" => serialize(array($oUser->getUsrPassword()))));
|
||||
$aUserProperty["USR_LOGGED_NEXT_TIME"] = $arrayData["USR_LOGGED_NEXT_TIME"];
|
||||
$oUserProperty->update($aUserProperty);
|
||||
}
|
||||
@@ -847,8 +1052,10 @@ class User
|
||||
|
||||
/**
|
||||
* Get data of a User
|
||||
* @param string $userUid Unique id of User
|
||||
* @param bool $flagGetRecord Value that set the getting
|
||||
*
|
||||
* @param string $userUid Unique id of User
|
||||
* @param bool $flagGetRecord Value that set the getting
|
||||
*
|
||||
* @return array Return an array with data of a User
|
||||
* @throws Exception
|
||||
*/
|
||||
@@ -881,7 +1088,9 @@ class User
|
||||
|
||||
/**
|
||||
* Create User Uid
|
||||
*
|
||||
* @param array $userData Data
|
||||
*
|
||||
* @return int
|
||||
* @throws Exception
|
||||
*/
|
||||
@@ -917,8 +1126,10 @@ class User
|
||||
* to put role an user
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
* @param string $sUserUID
|
||||
* @param string $sRolCode
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function assignRoleToUser($sUserUID = '', $sRolCode = '')
|
||||
@@ -933,7 +1144,9 @@ class User
|
||||
* to test Password
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
* @param string $sPassword
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function testPassword($sPassword = '')
|
||||
@@ -979,7 +1192,9 @@ class User
|
||||
|
||||
/**
|
||||
* change status of an user
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
* @param string $sUserUID
|
||||
* @param string $sStatus
|
||||
*/
|
||||
@@ -998,7 +1213,9 @@ class User
|
||||
* remove a role from an user
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
* @param string $sUserUID
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function removeRolesFromUser($sUserUID = '')
|
||||
@@ -1012,8 +1229,10 @@ class User
|
||||
* updated an user
|
||||
*
|
||||
* @access public
|
||||
* @param array $userData
|
||||
*
|
||||
* @param array $userData
|
||||
* @param string $sRolCode
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function updateUser($userData = array(), $sRolCode = '')
|
||||
@@ -1040,7 +1259,8 @@ class User
|
||||
* @access public
|
||||
*
|
||||
* @param string $sSystem the system
|
||||
* @param string $sUser the user
|
||||
* @param string $sUser the user
|
||||
*
|
||||
* @return $this->aUserInfo[ $sSystem ]
|
||||
*/
|
||||
public function loadUserRolePermission($sSystem, $sUser)
|
||||
@@ -1063,7 +1283,9 @@ class User
|
||||
|
||||
/**
|
||||
* Authenticate User
|
||||
*
|
||||
* @param array $arrayUserData Data
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function authenticate($arrayUserData)
|
||||
@@ -1076,7 +1298,9 @@ class User
|
||||
|
||||
/**
|
||||
* Delete User
|
||||
*
|
||||
* @param string $usrUid Unique id of User
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function delete($usrUid)
|
||||
@@ -1134,15 +1358,17 @@ class User
|
||||
|
||||
/**
|
||||
* Get all Users
|
||||
* @param array $arrayWhere Where (Condition and filters)
|
||||
* @param string $sortField Field name to sort
|
||||
* @param string $sortDir Direction of sorting (ASC, DESC)
|
||||
* @param int $start Start
|
||||
* @param int $limit Limit
|
||||
* @param bool $flagRecord Flag that set the "getting" of record
|
||||
* @param bool $throwException Flag to throw the exception (This only if the parameters are invalid)
|
||||
*
|
||||
* @param array $arrayWhere Where (Condition and filters)
|
||||
* @param string $sortField Field name to sort
|
||||
* @param string $sortDir Direction of sorting (ASC, DESC)
|
||||
* @param int $start Start
|
||||
* @param int $limit Limit
|
||||
* @param bool $flagRecord Flag that set the "getting" of record
|
||||
* @param bool $throwException Flag to throw the exception (This only if the parameters are invalid)
|
||||
* (TRUE: throw the exception; FALSE: returns FALSE)
|
||||
* @param string $status The user's status, which can be "ACTIVE", "INACTIVE" or "VACATION"
|
||||
* @param string $status The user's status, which can be "ACTIVE", "INACTIVE" or "VACATION"
|
||||
*
|
||||
* @return array Return an array with all Users, ThrowTheException/FALSE otherwise
|
||||
* @throws Exception
|
||||
*/
|
||||
@@ -1299,7 +1525,9 @@ class User
|
||||
|
||||
/**
|
||||
* Upload image User
|
||||
*
|
||||
* @param string $userUid Unique id of User
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function uploadImage($userUid)
|
||||
@@ -1313,14 +1541,17 @@ class User
|
||||
}
|
||||
|
||||
if (!isset($_FILES["USR_PHOTO"])) {
|
||||
throw new Exception(G::LoadTranslation("ID_UNDEFINED_VALUE_IS_REQUIRED", array($this->arrayFieldNameForException["usrPhoto"])));
|
||||
throw new Exception(G::LoadTranslation("ID_UNDEFINED_VALUE_IS_REQUIRED",
|
||||
array($this->arrayFieldNameForException["usrPhoto"])));
|
||||
}
|
||||
|
||||
if ($_FILES['USR_PHOTO']['error'] != 1) {
|
||||
if ($_FILES['USR_PHOTO']['tmp_name'] != '') {
|
||||
$aAux = explode('.', $_FILES['USR_PHOTO']['name']);
|
||||
G::uploadFile($_FILES['USR_PHOTO']['tmp_name'], PATH_IMAGES_ENVIRONMENT_USERS, $userUid . '.' . $aAux[1]);
|
||||
G::resizeImage(PATH_IMAGES_ENVIRONMENT_USERS . $userUid . '.' . $aAux[1], 96, 96, PATH_IMAGES_ENVIRONMENT_USERS . $userUid . '.gif');
|
||||
G::uploadFile($_FILES['USR_PHOTO']['tmp_name'], PATH_IMAGES_ENVIRONMENT_USERS,
|
||||
$userUid . '.' . $aAux[1]);
|
||||
G::resizeImage(PATH_IMAGES_ENVIRONMENT_USERS . $userUid . '.' . $aAux[1], 96, 96,
|
||||
PATH_IMAGES_ENVIRONMENT_USERS . $userUid . '.gif');
|
||||
}
|
||||
} else {
|
||||
throw new Exception(G::LoadTranslation('ID_ERROR') . ' ' . $_FILES['USR_PHOTO']['error']);
|
||||
@@ -1334,9 +1565,11 @@ class User
|
||||
* change Bookmarks of an user
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
* @param $userUID
|
||||
* @param $tasUid
|
||||
* @param $type
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function updateBookmark($userUID, $tasUid, $type)
|
||||
@@ -1356,8 +1589,9 @@ class User
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $userUid
|
||||
* @param $userUid
|
||||
* @param array $arrayPermission
|
||||
*
|
||||
* @return User
|
||||
* @throws Exception
|
||||
*/
|
||||
@@ -1378,6 +1612,7 @@ class User
|
||||
|
||||
/**
|
||||
* @param $aFields
|
||||
*
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
@@ -1395,7 +1630,8 @@ class User
|
||||
return $resultPermissionsForUser;
|
||||
} else {
|
||||
$lang = defined('SYS_LANG') ? SYS_LANG : 'en';
|
||||
throw (new Exception(G::LoadTranslation("ID_USER_UID_DOESNT_EXIST", $lang, array("USR_UID" => $aFields['USR_UID']))));
|
||||
throw (new Exception(G::LoadTranslation("ID_USER_UID_DOESNT_EXIST", $lang,
|
||||
array("USR_UID" => $aFields['USR_UID']))));
|
||||
}
|
||||
} catch (Exception $oError) {
|
||||
throw ($oError);
|
||||
@@ -1404,8 +1640,10 @@ class User
|
||||
|
||||
/**
|
||||
* Check permission
|
||||
* @param string $userUid Unique uid of User
|
||||
*
|
||||
* @param string $userUid Unique uid of User
|
||||
* @param string $permissionCode Permission code
|
||||
*
|
||||
* @return bool
|
||||
* @throws Exception
|
||||
*/
|
||||
@@ -1432,6 +1670,7 @@ class User
|
||||
|
||||
/**
|
||||
* Get User-Logged Time Zone
|
||||
*
|
||||
* @return string Return the User-Logged Time Zone; Time Zone system settings otherwise
|
||||
* @throws Exception
|
||||
*/
|
||||
@@ -1455,9 +1694,11 @@ class User
|
||||
|
||||
/**
|
||||
* Get the User's Manager
|
||||
* @param string $userUid Unique id of User
|
||||
* @param bool $throwException Flag to throw the exception if the main parameters are invalid or do not exist
|
||||
*
|
||||
* @param string $userUid Unique id of User
|
||||
* @param bool $throwException Flag to throw the exception if the main parameters are invalid or do not exist
|
||||
* (TRUE: throw the exception; FALSE: returns FALSE)
|
||||
*
|
||||
* @return string Returns an string with Unique id of User (Manager), ThrowTheException/FALSE otherwise
|
||||
* @throws Exception
|
||||
*/
|
||||
@@ -1520,25 +1761,34 @@ class User
|
||||
|
||||
/**
|
||||
* AuditLog
|
||||
* @param string $option Option
|
||||
* @param array $arrayData Data
|
||||
*
|
||||
* @param string $option Option
|
||||
* @param array $arrayData Data
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function auditLog($option, array $arrayData)
|
||||
{
|
||||
try {
|
||||
$firstName = (array_key_exists('USR_FIRSTNAME', $arrayData)) ? ' - First Name: ' . $arrayData['USR_FIRSTNAME'] : '';
|
||||
$lastName = (array_key_exists('USR_LASTNAME', $arrayData)) ? ' - Last Name: ' . $arrayData['USR_LASTNAME'] : '';
|
||||
$firstName = (array_key_exists('USR_FIRSTNAME',
|
||||
$arrayData)) ? ' - First Name: ' . $arrayData['USR_FIRSTNAME'] : '';
|
||||
$lastName = (array_key_exists('USR_LASTNAME',
|
||||
$arrayData)) ? ' - Last Name: ' . $arrayData['USR_LASTNAME'] : '';
|
||||
$email = (array_key_exists('USR_EMAIL', $arrayData)) ? ' - Email: ' . $arrayData['USR_EMAIL'] : '';
|
||||
$dueDate = (array_key_exists('USR_DUE_DATE', $arrayData)) ? ' - Due Date: ' . $arrayData['USR_DUE_DATE'] : '';
|
||||
$dueDate = (array_key_exists('USR_DUE_DATE',
|
||||
$arrayData)) ? ' - Due Date: ' . $arrayData['USR_DUE_DATE'] : '';
|
||||
$status = (array_key_exists('USR_STATUS', $arrayData)) ? ' - Status: ' . $arrayData['USR_STATUS'] : '';
|
||||
$address = (array_key_exists('USR_ADDRESS', $arrayData)) ? ' - Address: ' . $arrayData['USR_ADDRESS'] : '';
|
||||
$phone = (array_key_exists('USR_PHONE', $arrayData)) ? ' - Phone: ' . $arrayData['USR_PHONE'] : '';
|
||||
$zipCode = (array_key_exists('USR_ZIP_CODE', $arrayData)) ? ' - Zip Code: ' . $arrayData['USR_ZIP_CODE'] : '';
|
||||
$position = (array_key_exists('USR_POSITION', $arrayData)) ? ' - Position: ' . $arrayData['USR_POSITION'] : '';
|
||||
$zipCode = (array_key_exists('USR_ZIP_CODE',
|
||||
$arrayData)) ? ' - Zip Code: ' . $arrayData['USR_ZIP_CODE'] : '';
|
||||
$position = (array_key_exists('USR_POSITION',
|
||||
$arrayData)) ? ' - Position: ' . $arrayData['USR_POSITION'] : '';
|
||||
$role = (array_key_exists('USR_ROLE', $arrayData)) ? ' - Role: ' . $arrayData['USR_ROLE'] : '';
|
||||
$languageDef = (array_key_exists('USR_DEFAULT_LANG', $arrayData)) ? ' - Default Language: ' . $arrayData['USR_DEFAULT_LANG'] : '';
|
||||
$timeZone = (array_key_exists('USR_TIME_ZONE', $arrayData)) ? ' - Time Zone: ' . $arrayData['USR_TIME_ZONE'] : '';
|
||||
$languageDef = (array_key_exists('USR_DEFAULT_LANG',
|
||||
$arrayData)) ? ' - Default Language: ' . $arrayData['USR_DEFAULT_LANG'] : '';
|
||||
$timeZone = (array_key_exists('USR_TIME_ZONE',
|
||||
$arrayData)) ? ' - Time Zone: ' . $arrayData['USR_TIME_ZONE'] : '';
|
||||
|
||||
$str = 'User Name: ' . $arrayData['USR_USERNAME'] . ' - User ID: (' . $arrayData['USR_UID'] . ')' .
|
||||
$firstName . $lastName . $email . $dueDate . $status . $address . $phone . $zipCode . $position . $role . $timeZone . $languageDef;
|
||||
@@ -1551,12 +1801,14 @@ class User
|
||||
|
||||
/**
|
||||
* This function get the list of users
|
||||
*
|
||||
* @param string $authSource , authentication source
|
||||
* @param string $filter
|
||||
* @param string $sort
|
||||
* @param int $start
|
||||
* @param int $limit
|
||||
* @param string $dir related to order the column
|
||||
* @param int $start
|
||||
* @param int $limit
|
||||
* @param string $dir related to order the column
|
||||
*
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
@@ -1579,7 +1831,8 @@ class User
|
||||
$cc = $oCriteria->getNewCriterion(UsersPeer::USR_USERNAME, '%' . $filter . '%', Criteria::LIKE)
|
||||
->addOr($oCriteria->getNewCriterion(UsersPeer::USR_FIRSTNAME, '%' . $filter . '%', Criteria::LIKE)
|
||||
->addOr($oCriteria->getNewCriterion(UsersPeer::USR_LASTNAME, '%' . $filter . '%', Criteria::LIKE)
|
||||
->addOr($oCriteria->getNewCriterion(UsersPeer::USR_EMAIL, '%' . $filter . '%', Criteria::LIKE))));
|
||||
->addOr($oCriteria->getNewCriterion(UsersPeer::USR_EMAIL, '%' . $filter . '%',
|
||||
Criteria::LIKE))));
|
||||
$oCriteria->add($cc);
|
||||
}
|
||||
$oCriteria->add(UsersPeer::USR_STATUS, array('CLOSED'), Criteria::NOT_IN);
|
||||
@@ -1622,7 +1875,8 @@ class User
|
||||
$cc = $oCriteria->getNewCriterion(UsersPeer::USR_USERNAME, '%' . $filter . '%', Criteria::LIKE)
|
||||
->addOr($oCriteria->getNewCriterion(UsersPeer::USR_FIRSTNAME, '%' . $filter . '%', Criteria::LIKE)
|
||||
->addOr($oCriteria->getNewCriterion(UsersPeer::USR_LASTNAME, '%' . $filter . '%', Criteria::LIKE)
|
||||
->addOr($oCriteria->getNewCriterion(UsersPeer::USR_EMAIL, '%' . $filter . '%', Criteria::LIKE))));
|
||||
->addOr($oCriteria->getNewCriterion(UsersPeer::USR_EMAIL, '%' . $filter . '%',
|
||||
Criteria::LIKE))));
|
||||
$oCriteria->add($cc);
|
||||
}
|
||||
if (sizeof($aUsers) > 0) {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\BusinessModel;
|
||||
|
||||
use G;
|
||||
@@ -15,7 +16,7 @@ class Variable
|
||||
* Create Variable for a Process
|
||||
*
|
||||
* @param string $processUid Unique id of Process
|
||||
* @param array $arrayData Data
|
||||
* @param array $arrayData Data
|
||||
*
|
||||
* @return array, return data of the new Variable created
|
||||
* @throws Exception
|
||||
@@ -44,13 +45,13 @@ class Variable
|
||||
if (isset($arrayData["VAR_NAME"])) {
|
||||
$variable->setVarName($arrayData["VAR_NAME"]);
|
||||
} else {
|
||||
throw new Exception(G::LoadTranslation("ID_CAN_NOT_BE_NULL", array('$var_name' )));
|
||||
throw new Exception(G::LoadTranslation("ID_CAN_NOT_BE_NULL", array('$var_name')));
|
||||
}
|
||||
if (isset($arrayData["VAR_FIELD_TYPE"])) {
|
||||
$arrayData["VAR_FIELD_TYPE"] = $this->validateVarFieldType($arrayData["VAR_FIELD_TYPE"]);
|
||||
$variable->setVarFieldType($arrayData["VAR_FIELD_TYPE"]);
|
||||
} else {
|
||||
throw new Exception(G::LoadTranslation("ID_CAN_NOT_BE_NULL", array('$var_field_type' )));
|
||||
throw new Exception(G::LoadTranslation("ID_CAN_NOT_BE_NULL", array('$var_field_type')));
|
||||
}
|
||||
if (isset($arrayData["VAR_FIELD_SIZE"])) {
|
||||
$variable->setVarFieldSize($arrayData["VAR_FIELD_SIZE"]);
|
||||
@@ -58,7 +59,7 @@ class Variable
|
||||
if (isset($arrayData["VAR_LABEL"])) {
|
||||
$variable->setVarLabel($arrayData["VAR_LABEL"]);
|
||||
} else {
|
||||
throw new Exception(G::LoadTranslation("ID_CAN_NOT_BE_NULL", array('$var_label' )));
|
||||
throw new Exception(G::LoadTranslation("ID_CAN_NOT_BE_NULL", array('$var_label')));
|
||||
}
|
||||
if (isset($arrayData["VAR_DBCONNECTION"])) {
|
||||
$variable->setVarDbconnection($arrayData["VAR_DBCONNECTION"]);
|
||||
@@ -88,16 +89,14 @@ class Variable
|
||||
$variable->save();
|
||||
$cnn->commit();
|
||||
} else {
|
||||
|
||||
$msg = "";
|
||||
|
||||
foreach ($variable->getValidationFailures() as $validationFailure) {
|
||||
$msg = $msg . (($msg != "")? "\n" : "") . $validationFailure->getMessage();
|
||||
$msg = $msg . (($msg != "") ? "\n" : "") . $validationFailure->getMessage();
|
||||
}
|
||||
|
||||
throw new Exception(G::LoadTranslation("ID_RECORD_CANNOT_BE_CREATED") . "\n" . $msg);
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
$cnn->rollback();
|
||||
|
||||
@@ -108,7 +107,6 @@ class Variable
|
||||
$variable = $this->getVariable($processUid, $sPkProcessVariables);
|
||||
|
||||
return $variable;
|
||||
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
@@ -119,7 +117,7 @@ class Variable
|
||||
*
|
||||
* @param string $processUid Unique id of Process
|
||||
* @param string $variableUid Unique id of Variable
|
||||
* @param array $arrayData Data
|
||||
* @param array $arrayData Data
|
||||
*
|
||||
* @return array,return data of the Variable updated
|
||||
* @throws Exception
|
||||
@@ -199,16 +197,14 @@ class Variable
|
||||
$pmDynaform = new PmDynaform();
|
||||
$pmDynaform->synchronizeVariable($processUid, $newVariable, $oldVariable);
|
||||
} else {
|
||||
|
||||
$msg = "";
|
||||
|
||||
foreach ($variable->getValidationFailures() as $validationFailure) {
|
||||
$msg = $msg . (($msg != "")? "\n" : "") . $validationFailure->getMessage();
|
||||
$msg = $msg . (($msg != "") ? "\n" : "") . $validationFailure->getMessage();
|
||||
}
|
||||
|
||||
throw new Exception(G::LoadTranslation("ID_RECORD_CANNOT_BE_CREATED") . "\n" . $msg);
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
$cnn->rollback();
|
||||
|
||||
@@ -241,14 +237,13 @@ class Variable
|
||||
$pmDynaform = new PmDynaform();
|
||||
$isUsed = $pmDynaform->isUsed($processUid, $variable);
|
||||
if ($isUsed !== false) {
|
||||
$titleDynaform=$pmDynaform->getDynaformTitle($isUsed);
|
||||
$titleDynaform = $pmDynaform->getDynaformTitle($isUsed);
|
||||
throw new Exception(G::LoadTranslation("ID_VARIABLE_IN_USE", array($titleDynaform)));
|
||||
}
|
||||
//Delete
|
||||
$criteria = new \Criteria("workflow");
|
||||
$criteria->add(\ProcessVariablesPeer::VAR_UID, $variableUid);
|
||||
\ProcessVariablesPeer::doDelete($criteria);
|
||||
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
@@ -295,10 +290,11 @@ class Variable
|
||||
$rsCriteria->next();
|
||||
$arrayVariables = array();
|
||||
while ($aRow = $rsCriteria->getRow()) {
|
||||
|
||||
$VAR_ACCEPTED_VALUES = G::json_decode($aRow['VAR_ACCEPTED_VALUES'], true);
|
||||
if(sizeof($VAR_ACCEPTED_VALUES)) {
|
||||
$encodeAcceptedValues = preg_replace("/\\\\u([a-f0-9]{4})/e", "iconv('UCS-4LE','UTF-8',pack('V', hexdec('U$1')))", G::json_encode($VAR_ACCEPTED_VALUES));
|
||||
if (count($VAR_ACCEPTED_VALUES)) {
|
||||
$encodeAcceptedValues = preg_replace_callback("/\\\\u([a-f0-9]{4})/", function ($m) {
|
||||
return iconv('UCS-4LE', 'UTF-8', pack('V', hexdec('U' . $m[1])));
|
||||
}, G::json_encode($VAR_ACCEPTED_VALUES));
|
||||
} else {
|
||||
$encodeAcceptedValues = $aRow['VAR_ACCEPTED_VALUES'];
|
||||
}
|
||||
@@ -320,9 +316,8 @@ class Variable
|
||||
}
|
||||
//Return
|
||||
return $arrayVariables;
|
||||
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -366,10 +361,11 @@ class Variable
|
||||
$rsCriteria->next();
|
||||
$arrayVariables = array();
|
||||
while ($aRow = $rsCriteria->getRow()) {
|
||||
|
||||
$VAR_ACCEPTED_VALUES = G::json_decode($aRow['VAR_ACCEPTED_VALUES'], true);
|
||||
if(sizeof($VAR_ACCEPTED_VALUES)) {
|
||||
$encodeAcceptedValues = preg_replace("/\\\\u([a-f0-9]{4})/e", "iconv('UCS-4LE','UTF-8',pack('V', hexdec('U$1')))", G::json_encode($VAR_ACCEPTED_VALUES));
|
||||
if (count($VAR_ACCEPTED_VALUES)) {
|
||||
$encodeAcceptedValues = preg_replace_callback("/\\\\u([a-f0-9]{4})/", function ($m) {
|
||||
return iconv('UCS-4LE', 'UTF-8', pack('V', hexdec($m[1])));
|
||||
}, G::json_encode($VAR_ACCEPTED_VALUES));
|
||||
} else {
|
||||
$encodeAcceptedValues = $aRow['VAR_ACCEPTED_VALUES'];
|
||||
}
|
||||
@@ -391,7 +387,6 @@ class Variable
|
||||
}
|
||||
//Return
|
||||
return $arrayVariables;
|
||||
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
@@ -430,8 +425,8 @@ class Variable
|
||||
}
|
||||
if (isset($aData["VAR_NULL"])) {
|
||||
Validator::isInteger($aData['VAR_NULL'], '$var_null');
|
||||
if ($aData["VAR_NULL"] != 0 && $aData["VAR_NULL"] !=1 ) {
|
||||
throw new Exception(G::LoadTranslation("ID_INVALID_VALUE_ONLY_ACCEPTS_VALUES", array('$var_null','0, 1' )));
|
||||
if ($aData["VAR_NULL"] != 0 && $aData["VAR_NULL"] != 1) {
|
||||
throw new Exception(G::LoadTranslation("ID_INVALID_VALUE_ONLY_ACCEPTS_VALUES", array('$var_null', '0, 1')));
|
||||
}
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
@@ -442,8 +437,8 @@ class Variable
|
||||
/**
|
||||
* Verify if exists the name of a variable
|
||||
*
|
||||
* @param string $processUid, unique id of Process
|
||||
* @param string $variableName, name of variable
|
||||
* @param string $processUid , unique id of Process
|
||||
* @param string $variableName , name of variable
|
||||
* @param string $variableUidToExclude
|
||||
* @throws Exception
|
||||
*
|
||||
@@ -502,9 +497,9 @@ class Variable
|
||||
/**
|
||||
* Verify if some required variable in the SQL is missing in the variables
|
||||
*
|
||||
* @param string $variableName Variable name
|
||||
* @param string $variableSql SQL
|
||||
* @param array $arrayVariable The variables
|
||||
* @param string $variableName Variable name
|
||||
* @param string $variableSql SQL
|
||||
* @param array $arrayVariable The variables
|
||||
*
|
||||
* @return void Throw exception if some required variable in the SQL is missing in the variables
|
||||
* @throws Exception
|
||||
@@ -524,9 +519,9 @@ class Variable
|
||||
/**
|
||||
* Get all records by execute SQL
|
||||
*
|
||||
* @param string $processUid Unique id of Process
|
||||
* @param string $variableName Variable name
|
||||
* @param array $arrayVariable The variables
|
||||
* @param string $processUid Unique id of Process
|
||||
* @param string $variableName Variable name
|
||||
* @param array $arrayVariable The variables
|
||||
*
|
||||
* @return array, return an array with all records
|
||||
* @throws Exception
|
||||
@@ -543,7 +538,7 @@ class Variable
|
||||
/**
|
||||
* Verify if does not exist the variable in table PROCESS_VARIABLES
|
||||
*
|
||||
* @param string $variableUid Unique id of variable
|
||||
* @param string $variableUid Unique id of variable
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception, throw exception if does not exist the variable in table PROCESS_VARIABLES
|
||||
@@ -554,7 +549,7 @@ class Variable
|
||||
$obj = \ProcessVariablesPeer::retrieveByPK($variableUid);
|
||||
|
||||
if (is_null($obj)) {
|
||||
throw new Exception('var_uid: '.$variableUid. ' '.G::LoadTranslation("ID_DOES_NOT_EXIST"));
|
||||
throw new Exception('var_uid: ' . $variableUid . ' ' . G::LoadTranslation("ID_DOES_NOT_EXIST"));
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
@@ -593,8 +588,8 @@ class Variable
|
||||
/**
|
||||
* Verify if the variable is being used in a Dynaform
|
||||
*
|
||||
* @param string $processUid, Unique id of Process
|
||||
* @param string $variableUid, Unique id of Variable
|
||||
* @param string $processUid , Unique id of Process
|
||||
* @param string $variableUid , Unique id of Variable
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*
|
||||
@@ -602,7 +597,6 @@ class Variable
|
||||
public function verifyUse($processUid, $variableUid)
|
||||
{
|
||||
try {
|
||||
|
||||
$criteria = new \Criteria("workflow");
|
||||
$criteria->addSelectColumn(\DynaformPeer::DYN_CONTENT);
|
||||
$criteria->addSelectColumn(\DynaformPeer::DYN_UID);
|
||||
@@ -633,7 +627,6 @@ class Variable
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
@@ -642,9 +635,9 @@ class Variable
|
||||
/**
|
||||
* Get all records by execute SQL suggest
|
||||
*
|
||||
* @param string $processUid Unique id of Process
|
||||
* @param string $variableName Variable name
|
||||
* @param array $arrayVariable The variables
|
||||
* @param string $processUid Unique id of Process
|
||||
* @param string $variableName Variable name
|
||||
* @param array $arrayVariable The variables
|
||||
*
|
||||
* @return array, return an array with all records
|
||||
* @throws Exception
|
||||
@@ -674,7 +667,7 @@ class Variable
|
||||
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
||||
if ($rsCriteria->next()) {
|
||||
$row = $rsCriteria->getRow();
|
||||
return sizeof($row) ? $row : false;
|
||||
return count($row) ? $row : false;
|
||||
}
|
||||
return false;
|
||||
} catch (Exception $e) {
|
||||
@@ -685,10 +678,10 @@ class Variable
|
||||
/**
|
||||
* Get Variable record by name
|
||||
*
|
||||
* @param string $projectUid Unique id of Project
|
||||
* @param string $variableName Variable name
|
||||
* @param array $arrayVariableNameForException Variable name for exception
|
||||
* @param bool $throwException Flag to throw the exception if the main parameters are invalid or do not exist
|
||||
* @param string $projectUid Unique id of Project
|
||||
* @param string $variableName Variable name
|
||||
* @param array $arrayVariableNameForException Variable name for exception
|
||||
* @param bool $throwException Flag to throw the exception if the main parameters are invalid or do not exist
|
||||
* (TRUE: throw the exception; FALSE: returns FALSE)
|
||||
*
|
||||
* @return array, returns an array with Variable record
|
||||
@@ -699,7 +692,8 @@ class Variable
|
||||
$variableName,
|
||||
array $arrayVariableNameForException,
|
||||
$throwException = true
|
||||
) {
|
||||
)
|
||||
{
|
||||
try {
|
||||
$criteria = new \Criteria('workflow');
|
||||
$criteria->add(\ProcessVariablesPeer::PRJ_UID, $projectUid, \Criteria::EQUAL);
|
||||
@@ -711,7 +705,7 @@ class Variable
|
||||
} else {
|
||||
if ($throwException) {
|
||||
throw new Exception(
|
||||
$arrayVariableNameForException['$variableName'] . ': ' . $variableName. ' ' .
|
||||
$arrayVariableNameForException['$variableName'] . ': ' . $variableName . ' ' .
|
||||
G::LoadTranslation('ID_DOES_NOT_EXIST')
|
||||
);
|
||||
} else {
|
||||
@@ -729,23 +723,23 @@ class Variable
|
||||
public function validateVarFieldType($type)
|
||||
{
|
||||
$vType = strtolower($type);
|
||||
if(!in_array($vType, $this->variableTypes)) {
|
||||
if (!in_array($vType, $this->variableTypes)) {
|
||||
throw new Exception(G::LoadTranslation("ID_RECORD_CANNOT_BE_CREATED"));
|
||||
}
|
||||
return $vType;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Executes the sql string of a control and returns the data in the queryOutputData
|
||||
* property of the control. The control returned by the pmDynaform :: searchField
|
||||
* function is the php representation of the json definition, which can be
|
||||
* Executes the sql string of a control and returns the data in the queryOutputData
|
||||
* property of the control. The control returned by the pmDynaform :: searchField
|
||||
* function is the php representation of the json definition, which can be
|
||||
* supported by the pmDynaform :: jsonr function.
|
||||
* The params parameter must contain: dyn_uid, field_id and optionally
|
||||
* app_uid, del_index, filter, start, limit, and so many related control variables
|
||||
* to be sent and their corresponding value.
|
||||
* The parameters: filter, start and limit, are only necessary for the suggest
|
||||
* The params parameter must contain: dyn_uid, field_id and optionally
|
||||
* app_uid, del_index, filter, start, limit, and so many related control variables
|
||||
* to be sent and their corresponding value.
|
||||
* The parameters: filter, start and limit, are only necessary for the suggest
|
||||
* control.
|
||||
* If app_uid is not sent you can not get the appData in an environment where
|
||||
* If app_uid is not sent you can not get the appData in an environment where
|
||||
* only endPoint is used, it is always advisable to send the app_uid and _index.
|
||||
* Note: You do not get triguer execution values where only endPoint is used.
|
||||
* @param type $proUid
|
||||
@@ -756,7 +750,7 @@ class Variable
|
||||
public function executeSqlControl($proUid, array $params = array())
|
||||
{
|
||||
try {
|
||||
//Get and clear vector data that does not correspond to variables
|
||||
//Get and clear vector data that does not correspond to variables
|
||||
//related to a control.
|
||||
$dynUid = $params["dyn_uid"];
|
||||
$fieldId = $params["field_id"];
|
||||
@@ -764,7 +758,7 @@ class Variable
|
||||
$start = isset($params["start"]) ? $params["start"] : 0;
|
||||
$limit = isset($params["limit"]) ? $params["limit"] : 10;
|
||||
$appUid = empty($params["app_uid"]) ? null : $params["app_uid"];
|
||||
$delIndex = (int) isset($params["del_index"]) ? $params["del_index"] : 0;
|
||||
$delIndex = (int)isset($params["del_index"]) ? $params["del_index"] : 0;
|
||||
unset($params["dyn_uid"]);
|
||||
unset($params["field_id"]);
|
||||
unset($params["app_uid"]);
|
||||
@@ -791,7 +785,7 @@ class Variable
|
||||
$pmDynaform = new PmDynaform(array("APP_DATA" => $params));
|
||||
|
||||
//Get control from dynaform.
|
||||
//The parameters: queryFilter, queryStart, queryLimit, are only necessary
|
||||
//The parameters: queryFilter, queryStart, queryLimit, are only necessary
|
||||
//for the suggest control, the rest of the controls are ignored.
|
||||
$field = $pmDynaform->searchField($dynUid, $fieldId, $proUid);
|
||||
$field->queryField = true;
|
||||
@@ -800,8 +794,8 @@ class Variable
|
||||
$field->queryStart = $start;
|
||||
$field->queryLimit = $limit;
|
||||
//Grids only access the global variables of 'ProcessMaker', other variables are removed.
|
||||
//The property 'columnWidth' is only present in the controls of a grid,
|
||||
//in the current change there is no specific property that indicates
|
||||
//The property 'columnWidth' is only present in the controls of a grid,
|
||||
//in the current change there is no specific property that indicates
|
||||
//if the control is in the grid.
|
||||
if (isset($field->columnWidth)) {
|
||||
$pmDynaform->fields["APP_DATA"] = $globalVariables;
|
||||
@@ -821,5 +815,4 @@ class Variable
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,19 +4,26 @@ namespace ProcessMaker\Core;
|
||||
|
||||
use AppCacheView;
|
||||
use Archive_Tar;
|
||||
use Bootstrap;
|
||||
use Configuration;
|
||||
use Exception;
|
||||
use G;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use InstallerModule;
|
||||
use ProcessMaker\Util\Common;
|
||||
|
||||
class Installer
|
||||
{
|
||||
|
||||
public $options = Array();
|
||||
public $result = Array();
|
||||
public $error = Array();
|
||||
public $report = Array();
|
||||
public $options = [];
|
||||
public $result = [];
|
||||
public $error = [];
|
||||
public $report = [];
|
||||
private $connection_database;
|
||||
|
||||
const CONNECTION_INSTALL = 'install';
|
||||
const CONNECTION_TEST_INSTALL = 'testInstall';
|
||||
|
||||
/**
|
||||
* construct of insert
|
||||
*
|
||||
@@ -32,18 +39,41 @@ class Installer
|
||||
*
|
||||
* @param array $config
|
||||
* @param boolean $confirmed
|
||||
* @return void
|
||||
* @return array
|
||||
*/
|
||||
public function create_site($config = Array(), $confirmed = false)
|
||||
public function create_site($config = [], $confirmed = false)
|
||||
{
|
||||
$this->options = G::array_concat(Array('isset' => false, 'password' => G::generate_password(15), 'path_data' => @PATH_DATA, 'path_compiled' => @PATH_C, 'name' => $config['name'], 'database' => Array(), 'admin' => Array('username' => 'admin', 'password' => 'admin'
|
||||
), 'advanced' => Array('ao_db_wf' => 'wf_' . $config['name'], 'ao_db_rb' => 'rb_' . $config['name'], 'ao_db_rp' => 'rp_' . $config['name'], 'ao_db_drop' => false
|
||||
)
|
||||
), $config);
|
||||
$a = @explode(SYSTEM_HASH, G::decrypt(HASH_INSTALLATION, SYSTEM_HASH));
|
||||
$this->options['database'] = G::array_concat(Array('username' => @$a[1], 'password' => @$a[2], 'hostname' => @$a[0]
|
||||
), $this->options['database']);
|
||||
return ($confirmed === true) ? $this->make_site() : $this->create_site_test();
|
||||
$this->options = G::array_concat([
|
||||
'isset' => false,
|
||||
'password' => G::generate_password(15),
|
||||
'path_data' => @PATH_DATA,
|
||||
'path_compiled' => @PATH_C,
|
||||
'name' => $config['name'],
|
||||
'database' => [],
|
||||
'admin' => ['username' => 'admin', 'password' => 'admin'],
|
||||
'advanced' => [
|
||||
'ao_db_wf' => 'wf_' . $config['name'],
|
||||
'ao_db_rb' => 'rb_' . $config['name'],
|
||||
'ao_db_rp' => 'rp_' . $config['name'],
|
||||
'ao_db_drop' => false
|
||||
]
|
||||
], $config);
|
||||
$configuration = @explode(SYSTEM_HASH, G::decrypt(HASH_INSTALLATION, SYSTEM_HASH));
|
||||
|
||||
$host = explode(':', $configuration[0]);
|
||||
if (count($host) < 2) {
|
||||
$host[1] = 3306;
|
||||
}
|
||||
$configuration[0] = $host[0];
|
||||
|
||||
$this->options['database'] = G::array_concat([
|
||||
'username' => @$configuration[1],
|
||||
'password' => @$configuration[2],
|
||||
'hostname' => @$configuration[0],
|
||||
'port' => $host[1]
|
||||
], $this->options['database']);
|
||||
|
||||
return $confirmed ? $this->make_site() : $this->create_site_test();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -68,29 +98,44 @@ class Installer
|
||||
/**
|
||||
* create_site_test
|
||||
*
|
||||
* @return void
|
||||
* @return array
|
||||
*/
|
||||
private function create_site_test()
|
||||
{
|
||||
$name = (preg_match('/^[\w]+$/i', trim($this->options['name']))) ? true : false;
|
||||
$result = Array('path_data' => $this->is_dir_writable($this->options['path_data']), 'path_compiled' => $this->is_dir_writable($this->options['path_compiled']), 'database' => $this->check_connection(), 'access_level' => $this->cc_status, 'isset' => ($this->options['isset'] == true) ? $this->isset_site($this->options['name']) : false, 'microtime' => microtime(), 'workspace' => $this->options['name'], 'name' => array('status' => $name, 'message' => ($name) ? 'PASSED' : 'Workspace name invalid'
|
||||
), 'admin' => array('username' => (preg_match('/^[\w@\.-]+$/i', trim($this->options['admin']['username']))) ? true : false, 'password' => ((trim($this->options['admin']['password']) == '') ? false : true)
|
||||
)
|
||||
);
|
||||
$result['name']['message'] = ($result['isset']) ? 'Workspace already exist' : $result['name']['message'];
|
||||
$result['name']['status'] = ($result['isset']) ? false : $result['name']['status'];
|
||||
//print_r($result);
|
||||
return Array('created' => G::var_compare(true,
|
||||
$result['path_data'],
|
||||
$result['database']['connection'],
|
||||
$result['name']['status'],
|
||||
$result['database']['version'],
|
||||
$result['database']['ao']['ao_db_wf']['status'],
|
||||
$result['admin']['username'],
|
||||
(($result['isset']) ? false : true),
|
||||
$result['admin']['password']),
|
||||
$name = preg_match('/^[\w]+$/i', trim($this->options['name'])) ? true : false;
|
||||
$result = [
|
||||
'path_data' => $this->is_dir_writable($this->options['path_data']),
|
||||
'path_compiled' => $this->is_dir_writable($this->options['path_compiled']),
|
||||
'database' => $this->check_connection(self::CONNECTION_TEST_INSTALL),
|
||||
'access_level' => $this->cc_status,
|
||||
'isset' => $this->options['isset'] === true ? $this->isset_site($this->options['name']) : false,
|
||||
'microtime' => microtime(),
|
||||
'workspace' => $this->options['name'],
|
||||
'name' => [
|
||||
'status' => $name,
|
||||
'message' => $name ? 'PASSED' : 'Workspace name invalid'
|
||||
],
|
||||
'admin' => [
|
||||
'username' => preg_match('/^[\w@\.-]+$/i', trim($this->options['admin']['username'])) ? true : false,
|
||||
'password' => empty(trim($this->options['admin']['password'])) ? false : true
|
||||
]
|
||||
];
|
||||
$result['name']['message'] = $result['isset'] ? 'Workspace already exist' : $result['name']['message'];
|
||||
$result['name']['status'] = $result['isset'] ? false : $result['name']['status'];
|
||||
return [
|
||||
'created' => G::var_compare(
|
||||
true,
|
||||
$result['path_data'],
|
||||
$result['database']['connection'],
|
||||
$result['name']['status'],
|
||||
$result['database']['version'],
|
||||
$result['database']['ao']['ao_db_wf']['status'],
|
||||
$result['admin']['username'],
|
||||
$result['isset'] ? false : true,
|
||||
$result['admin']['password']
|
||||
),
|
||||
'result' => $result
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -102,9 +147,10 @@ class Installer
|
||||
{
|
||||
$test = $this->create_site_test();
|
||||
|
||||
if ($test["created"] == true || $this->options["advanced"]["ao_db_drop"] == true) {
|
||||
if ($test["created"] === true || $this->options["advanced"]["ao_db_drop"] === true) {
|
||||
/* Check if the hostname is local (localhost or 127.0.0.1) */
|
||||
$islocal = (strcmp(substr($this->options['database']['hostname'], 0, strlen('localhost')), 'localhost') === 0) || (strcmp(substr($this->options['database']['hostname'], 0, strlen('127.0.0.1')), '127.0.0.1') === 0);
|
||||
$islocal = (strcmp(substr($this->options['database']['hostname'], 0, strlen('localhost')), 'localhost') === 0) ||
|
||||
(strcmp(substr($this->options['database']['hostname'], 0, strlen('127.0.0.1')), '127.0.0.1') === 0);
|
||||
|
||||
$this->wf_site_name = $wf = $this->options['advanced']['ao_db_wf'];
|
||||
$this->wf_user_db = isset($this->options['advanced']['ao_user_wf']) ? $this->options['advanced']['ao_user_wf'] : uniqid('wf_');
|
||||
@@ -118,36 +164,39 @@ class Installer
|
||||
if ($this->options['advanced']['ao_db_drop'] === true) {
|
||||
//Delete workspace directory if exists
|
||||
//Drop databases
|
||||
$this->run_query("DROP DATABASE IF EXISTS " . $wf, "Drop database $wf");
|
||||
$this->run_query('DROP DATABASE IF EXISTS ' . $wf, 'Drop database $wf', self::CONNECTION_TEST_INSTALL);
|
||||
}
|
||||
|
||||
$this->run_query("CREATE DATABASE IF NOT EXISTS " . $wf . " DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci", "Create database $wf");
|
||||
$this->run_query('CREATE DATABASE IF NOT EXISTS ' . $wf . ' DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci', "Create database $wf", self::CONNECTION_TEST_INSTALL);
|
||||
|
||||
|
||||
if ($this->cc_status == 1) {
|
||||
$host = ($islocal) ? "localhost" : "%";
|
||||
$this->run_query("GRANT ALL PRIVILEGES ON `$wf`.* TO {$this->wf_user_db}@'$host' IDENTIFIED BY '{$this->options['password']}' WITH GRANT OPTION", "Grant privileges for user {$this->wf_user_db} on database $wf");
|
||||
$this->run_query("GRANT ALL PRIVILEGES ON `$wf`.* TO {$this->wf_user_db}@'$host' IDENTIFIED BY '{$this->options['password']}' WITH GRANT OPTION", "Grant privileges for user {$this->wf_user_db} on database $wf", self::CONNECTION_TEST_INSTALL);
|
||||
}
|
||||
|
||||
|
||||
/* Dump schema workflow && data */
|
||||
|
||||
$this->log("Import database schema:\n");
|
||||
$myPortA = explode(":", $this->options['database']['hostname']);
|
||||
if (count($myPortA) < 2) {
|
||||
$myPortA[1] = "3306";
|
||||
}
|
||||
$myPort = $myPortA[1];
|
||||
$this->options['database']['hostname'] = $myPortA[0];
|
||||
|
||||
mysql_select_db($wf, $this->connection_database);
|
||||
InstallerModule::setNewConnection(
|
||||
self::CONNECTION_INSTALL,
|
||||
$this->options['database']['hostname'],
|
||||
$this->options['database']['username'],
|
||||
$this->options['database']['password'],
|
||||
$this->wf_site_name,
|
||||
$this->options['database']['port']);
|
||||
|
||||
$pws = PATH_WORKFLOW_MYSQL_DATA . $schema;
|
||||
$qws = $this->query_sql_file(PATH_WORKFLOW_MYSQL_DATA . $schema, $this->connection_database);
|
||||
$qws = $this->query_sql_file(PATH_WORKFLOW_MYSQL_DATA . $schema);
|
||||
$this->log($qws, isset($qws['errors']));
|
||||
$qwv = $this->query_sql_file(PATH_WORKFLOW_MYSQL_DATA . $values, $this->connection_database);
|
||||
$qwv = $this->query_sql_file(PATH_WORKFLOW_MYSQL_DATA . $values);
|
||||
$this->log($qwv, isset($qwv['errors']));
|
||||
|
||||
$http = (G::is_https() == true) ? 'https' : 'http';
|
||||
$http = G::is_https() ? 'https' : 'http';
|
||||
$lang = defined('SYS_LANG') ? SYS_LANG : 'en';
|
||||
$host = $_SERVER['SERVER_NAME'] . ($_SERVER['SERVER_PORT'] != '80' ? ':' . $_SERVER['SERVER_PORT'] : '');
|
||||
$host = $_SERVER['SERVER_NAME'] . ($_SERVER['SERVER_PORT'] !== '80' ? ':' . $_SERVER['SERVER_PORT'] : '');
|
||||
$workspace = $this->options['name'];
|
||||
|
||||
$endpoint = sprintf(
|
||||
@@ -159,33 +208,37 @@ class Installer
|
||||
SYS_SKIN
|
||||
);
|
||||
|
||||
// inserting the outh_client
|
||||
$query = ("INSERT INTO OAUTH_CLIENTS (CLIENT_ID,CLIENT_SECRET,CLIENT_NAME,CLIENT_DESCRIPTION,CLIENT_WEBSITE,REDIRECT_URI,USR_UID ) VALUES
|
||||
('x-pm-local-client','179ad45c6ce2cb97cf1029e212046e81','PM Web Designer','ProcessMaker Web Designer App','www.processmaker.com','" . $endpoint . "','00000000000000000000000000000001' )");
|
||||
$this->run_query($query);
|
||||
DB::connection(self::CONNECTION_INSTALL)
|
||||
->table('OAUTH_CLIENTS')
|
||||
->insert([
|
||||
'CLIENT_ID' => 'x-pm-local-client',
|
||||
'CLIENT_SECRET' => '179ad45c6ce2cb97cf1029e212046e81',
|
||||
'CLIENT_NAME' => 'PM Web Designer',
|
||||
'CLIENT_DESCRIPTION' => 'ProcessMaker Web Designer App',
|
||||
'CLIENT_WEBSITE' => 'www.processmaker.com',
|
||||
'REDIRECT_URI' => $endpoint,
|
||||
'USR_UID' => '00000000000000000000000000000001'
|
||||
]);
|
||||
|
||||
/* Dump schema rbac && data */
|
||||
$pws = PATH_RBAC_MYSQL_DATA . $schema;
|
||||
mysql_select_db($rb, $this->connection_database);
|
||||
$qrs = $this->query_sql_file(PATH_RBAC_MYSQL_DATA . $schema, $this->connection_database);
|
||||
$qrs = $this->query_sql_file(PATH_RBAC_MYSQL_DATA . $schema);
|
||||
$this->log($qrs, isset($qrs['errors']));
|
||||
$qrv = $this->query_sql_file(PATH_RBAC_MYSQL_DATA . $values, $this->connection_database);
|
||||
$qrv = $this->query_sql_file(PATH_RBAC_MYSQL_DATA . $values);
|
||||
$this->log($qrv, isset($qrv['errors']));
|
||||
|
||||
mysql_select_db($wf, $this->connection_database);
|
||||
|
||||
require_once("propel/Propel.php");
|
||||
require_once('classes/model/AppCacheView.php');
|
||||
|
||||
$appCache = new AppCacheView();
|
||||
$appCache->setPathToAppCacheFiles(PATH_METHODS . 'setup/setupSchemas/');
|
||||
$triggers = $appCache->getTriggers("en");
|
||||
$triggers = $appCache->getTriggers('en');
|
||||
$this->log("Create 'cases list cache' triggers");
|
||||
foreach ($triggers as $triggerName => $trigger) {
|
||||
$this->run_query($trigger, "-> Trigger $triggerName");
|
||||
$this->runTrigger($trigger, "-> Trigger $triggerName");
|
||||
}
|
||||
|
||||
$path_site = $this->options['path_data'] . "/sites/" . $this->options['name'] . "/";
|
||||
$path_site = $this->options['path_data'] . '/sites/' . $this->options['name'] . '/';
|
||||
|
||||
@mkdir($path_site, 0777, true);
|
||||
@mkdir($path_site . "files/", 0777, true);
|
||||
@@ -195,8 +248,27 @@ class Installer
|
||||
@mkdir($path_site . "xmlForms", 0777, true);
|
||||
|
||||
//Generate the db.php file
|
||||
$hostname = $this->options['database']['hostname'] . ':' . $this->options['database']['port'];
|
||||
$username = $this->cc_status === 1 ? $this->wf_user_db : $this->options['database']['username'];
|
||||
$password = $this->cc_status === 1 ? $this->options['password'] : $this->options['database']['password'];
|
||||
$db_file = $path_site . 'db.php';
|
||||
$db_text = "<?php\n" . "// Processmaker configuration\n" . "define ('DB_ADAPTER', 'mysql' );\n" . "define ('DB_HOST', '" . $this->options['database']['hostname'] . ":" . $myPort . "' );\n" . "define ('DB_NAME', '" . $wf . "' );\n" . "define ('DB_USER', '" . (($this->cc_status == 1) ? $this->wf_user_db : $this->options['database']['username']) . "' );\n" . "define ('DB_PASS', '" . (($this->cc_status == 1) ? $this->options['password'] : $this->options['database']['password']) . "' );\n" . "define ('DB_RBAC_HOST', '" . $this->options['database']['hostname'] . ":" . $myPort . "' );\n" . "define ('DB_RBAC_NAME', '" . $rb . "' );\n" . "define ('DB_RBAC_USER', '" . (($this->cc_status == 1) ? $this->wf_user_db : $this->options['database']['username']) . "' );\n" . "define ('DB_RBAC_PASS', '" . (($this->cc_status == 1) ? $this->options['password'] : $this->options['database']['password']) . "' );\n" . "define ('DB_REPORT_HOST', '" . $this->options['database']['hostname'] . ":" . $myPort . "' );\n" . "define ('DB_REPORT_NAME', '" . $rp . "' );\n" . "define ('DB_REPORT_USER', '" . (($this->cc_status == 1) ? $this->wf_user_db : $this->options['database']['username']) . "' );\n" . "define ('DB_REPORT_PASS', '" . (($this->cc_status == 1) ? $this->options['password'] : $this->options['database']['password']) . "' );\n";
|
||||
$db_text = "<?php\n"
|
||||
. "// Processmaker configuration\n"
|
||||
. " define ('DB_ADAPTER', 'mysql' );\n"
|
||||
. " define ('DB_HOST', '" . $hostname . "' );\n"
|
||||
. " define ('DB_NAME', '" . $wf . "' );\n"
|
||||
. " define ('DB_USER', '" . $username . "' );\n"
|
||||
. " define ('DB_PASS', '" . $password . "' );\n"
|
||||
. " define ('DB_RBAC_HOST', '" . $hostname . "' );\n"
|
||||
. " define ('DB_RBAC_NAME', '" . $rb . "' );\n"
|
||||
. " define ('DB_RBAC_USER', '" . $username . "' );\n"
|
||||
. " define ('DB_RBAC_PASS', '" . $password . "' );\n"
|
||||
. " define ('DB_REPORT_HOST', '" . $hostname . "' );\n"
|
||||
. " define ('DB_REPORT_NAME', '" . $rp . "' );\n"
|
||||
. " define ('DB_REPORT_USER', '" . $username . "' );\n"
|
||||
. " define ('DB_REPORT_PASS', '" . $password . "' );\n"
|
||||
. "";
|
||||
|
||||
if (defined('PARTNER_FLAG') || isset($_REQUEST['PARTNER_FLAG'])) {
|
||||
$db_text .= "define ('PARTNER_FLAG', " . ((defined('PARTNER_FLAG') && PARTNER_FLAG != '') ? PARTNER_FLAG : ((isset($_REQUEST['PARTNER_FLAG'])) ? $_REQUEST['PARTNER_FLAG'] : 'false')) . ");\n";
|
||||
if (defined('SYSTEM_NAME')) {
|
||||
@@ -207,7 +279,7 @@ class Installer
|
||||
|
||||
$fp = @fopen($db_file, "w");
|
||||
$this->log("Create: " . $db_file . " => " . ((!$fp) ? $fp : "OK") . "\n", $fp === false);
|
||||
$ff = @fputs($fp, $db_text, strlen($db_text));
|
||||
$ff = @fwrite($fp, $db_text, strlen($db_text));
|
||||
$this->log("Write: " . $db_file . " => " . ((!$ff) ? $ff : "OK") . "\n", $ff === false);
|
||||
fclose($fp);
|
||||
|
||||
@@ -218,7 +290,7 @@ class Installer
|
||||
|
||||
$fp = @fopen($envIniFile, 'w');
|
||||
$this->log('Create: ' . $envIniFile . ' => ' . ((!$fp) ? $fp : 'OK') . "\n", $fp === false);
|
||||
$ff = @fputs($fp, $content, strlen($content));
|
||||
$ff = @fwrite($fp, $content, strlen($content));
|
||||
$this->log('Write: ' . $envIniFile . ' => ' . ((!$ff) ? $ff : 'OK') . "\n", $ff === false);
|
||||
fclose($fp);
|
||||
/*----------------------------------********---------------------------------*/
|
||||
@@ -227,9 +299,12 @@ class Installer
|
||||
$this->setPartner();
|
||||
$this->setAdmin();
|
||||
|
||||
$querySql = "INSERT INTO EMAIL_SERVER(MESS_UID, MESS_ENGINE) VALUES('" . \ProcessMaker\Util\Common::generateUID() . "', 'MAIL')";
|
||||
|
||||
$this->run_query($querySql);
|
||||
DB::connection(self::CONNECTION_INSTALL)
|
||||
->table('EMAIL_SERVER')
|
||||
->insert([
|
||||
'MESS_UID' => Common::generateUID(),
|
||||
'MESS_ENGINE' => 'MAIL'
|
||||
]);
|
||||
}
|
||||
return $test;
|
||||
}
|
||||
@@ -246,17 +321,16 @@ class Installer
|
||||
// Execute sql for partner
|
||||
$pathMysqlPartner = PATH_CORE . 'data' . PATH_SEP . 'partner' . PATH_SEP . 'mysql' . PATH_SEP;
|
||||
if (G::verifyPath($pathMysqlPartner)) {
|
||||
$res = array();
|
||||
$filesSlq = glob($pathMysqlPartner . '*.sql');
|
||||
foreach ($filesSlq as $value) {
|
||||
$this->query_sql_file($value, $this->connection_database);
|
||||
$this->query_sql_file($value);
|
||||
}
|
||||
}
|
||||
|
||||
// Execute to change of skin
|
||||
$pathSkinPartner = PATH_CORE . 'data' . PATH_SEP . 'partner' . PATH_SEP . 'skin' . PATH_SEP;
|
||||
if (G::verifyPath($pathSkinPartner)) {
|
||||
$res = array();
|
||||
$res = [];
|
||||
$fileTar = glob($pathSkinPartner . '*.tar');
|
||||
foreach ($fileTar as $value) {
|
||||
$dataFile = pathinfo($value);
|
||||
@@ -331,7 +405,7 @@ class Installer
|
||||
curl_close($ch);
|
||||
|
||||
$ch = curl_init();
|
||||
$postData = array();
|
||||
$postData = [];
|
||||
// resolv the plugin name
|
||||
$plugins = glob(PATH_CORE . "plugins/*.tar");
|
||||
if (count($plugins) > 0) {
|
||||
@@ -356,10 +430,10 @@ class Installer
|
||||
}
|
||||
}
|
||||
|
||||
function copyFile($fromDir, $toDir, $chmod = 0777)
|
||||
public function copyFile($fromDir, $toDir, $chmod = 0777)
|
||||
{
|
||||
$errors = array();
|
||||
$messages = array();
|
||||
$errors = [];
|
||||
$messages = [];
|
||||
|
||||
if (!is_writable($toDir)) {
|
||||
$errors[] = 'target ' . $toDir . ' is not writable';
|
||||
@@ -406,10 +480,10 @@ class Installer
|
||||
*/
|
||||
public function setConfiguration()
|
||||
{
|
||||
$oConf = new Configuration();
|
||||
$dataCondif = $oConf->getAll();
|
||||
if (count($dataCondif)) {
|
||||
foreach ($dataCondif as $value) {
|
||||
$configuration = new Configuration();
|
||||
$dataConfig = $configuration->getAll();
|
||||
if (count($dataConfig)) {
|
||||
foreach ($dataConfig as $value) {
|
||||
if ($value['CFG_UID'] == 'ENVIRONMENT_SETTINGS') {
|
||||
$query = 'INSERT INTO CONFIGURATION (CFG_UID, OBJ_UID, CFG_VALUE, PRO_UID, USR_UID, APP_UID) VALUES';
|
||||
$query .= "('" .
|
||||
@@ -419,7 +493,6 @@ class Installer
|
||||
$value['PRO_UID'] . "', '" .
|
||||
$value['USR_UID'] . "', '" .
|
||||
$value['APP_UID'] . "')";
|
||||
mysql_select_db($this->wf_site_name, $this->connection_database);
|
||||
$this->run_query($query, "Copy configuracion environment");
|
||||
break;
|
||||
}
|
||||
@@ -434,59 +507,92 @@ class Installer
|
||||
*/
|
||||
public function setAdmin()
|
||||
{
|
||||
mysql_select_db($this->wf_site_name, $this->connection_database);
|
||||
// The mysql_escape_string function has been DEPRECATED as of PHP 5.3.0.
|
||||
// $this->run_query('UPDATE USERS SET USR_USERNAME = \''.mysql_escape_string($this->options['admin']['username']).'\', `USR_PASSWORD` = \''.md5($this->options['admin']['password']).'\' WHERE `USR_UID` = \'00000000000000000000000000000001\' LIMIT 1',
|
||||
// "Add 'admin' user in ProcessMaker (wf)");
|
||||
$this->run_query('UPDATE USERS SET USR_USERNAME = \'' . mysql_real_escape_string($this->options['admin']['username']) . '\', ' . ' `USR_PASSWORD` = \'' . G::encryptHash($this->options['admin']['password']) . '\' ' . ' WHERE `USR_UID` = \'00000000000000000000000000000001\' LIMIT 1', "Add 'admin' user in ProcessMaker (wf)");
|
||||
mysql_select_db($this->rbac_site_name, $this->connection_database);
|
||||
// The mysql_escape_string function has been DEPRECATED as of PHP 5.3.0.
|
||||
// $this->run_query('UPDATE USERS SET USR_USERNAME = \''.mysql_escape_string($this->options['admin']['username']).'\', `USR_PASSWORD` = \''.md5($this->options['admin']['password']).'\' WHERE `USR_UID` = \'00000000000000000000000000000001\' LIMIT 1',
|
||||
// "Add 'admin' user in ProcessMaker (rb)");
|
||||
$this->run_query('UPDATE RBAC_USERS SET USR_USERNAME = \'' . mysql_real_escape_string($this->options['admin']['username']) . '\', ' . ' `USR_PASSWORD` = \'' . G::encryptHash($this->options['admin']['password']) . '\' ' . ' WHERE `USR_UID` = \'00000000000000000000000000000001\' LIMIT 1', "Add 'admin' user in ProcessMaker (rb)");
|
||||
// Change admin user
|
||||
DB::connection(self::CONNECTION_INSTALL)
|
||||
->table('USERS')
|
||||
->where('USR_UID', '00000000000000000000000000000001')
|
||||
->update([
|
||||
'USR_USERNAME' => $this->options['admin']['username'],
|
||||
'USR_PASSWORD' => G::encryptHash($this->options['admin']['password'])
|
||||
]);
|
||||
|
||||
DB::connection(self::CONNECTION_INSTALL)
|
||||
->table('RBAC_USERS')
|
||||
->where('USR_UID', '00000000000000000000000000000001')
|
||||
->update([
|
||||
'USR_USERNAME' => $this->options['admin']['username'],
|
||||
'USR_PASSWORD' => G::encryptHash($this->options['admin']['password'])
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run a mysql query on the current database and take care of logging and
|
||||
* Run a mysql script on the current database and take care of logging and
|
||||
* error handling.
|
||||
*
|
||||
* @param string $query SQL command
|
||||
* @param string $description Description to log instead of $query
|
||||
* @param string $connection default connection install
|
||||
* @throws Exception
|
||||
*/
|
||||
private function run_query($query, $description = null)
|
||||
private function runTrigger($query, $description = '', $connection = self::CONNECTION_INSTALL)
|
||||
{
|
||||
$result = @mysql_query($query, $this->connection_database);
|
||||
$error = ($result) ? false : mysql_error();
|
||||
$this->log(($description ? $description : $query) . " => " . (($error) ? $error : "OK") . "\n", $error);
|
||||
$this->run_query($query, $description, $connection, 'RAW');
|
||||
}
|
||||
|
||||
/**
|
||||
* query_sql_file
|
||||
* Run a mysql query on the current database and take care of logging and
|
||||
* error handling.
|
||||
*
|
||||
* @param string $file
|
||||
* @param string $connection
|
||||
* @return array $report
|
||||
* @param string $query SQL command
|
||||
* @param string $description Description to log instead of $query
|
||||
* @param string $connection default connection install
|
||||
* @param string $type STATEMENT|RAW
|
||||
*/
|
||||
public function query_sql_file($file, $connection)
|
||||
private function run_query($query, $description = '', $connection = self::CONNECTION_INSTALL, $type = 'STATEMENT')
|
||||
{
|
||||
try {
|
||||
$message = '';
|
||||
switch ($type) {
|
||||
case 'STATEMENT':
|
||||
DB::connection($connection)->statement($query);
|
||||
break;
|
||||
case 'RAW':
|
||||
DB::connection($connection)->raw($query);
|
||||
break;
|
||||
}
|
||||
|
||||
} catch (QueryException $exception) {
|
||||
$message = $exception->getMessage();
|
||||
}
|
||||
$this->log(!empty($description) ? $description : $query . ' => ' . (!empty($message) ? $message : 'OK') . "\n", !empty($message));
|
||||
}
|
||||
|
||||
/**
|
||||
* Query sql file
|
||||
*
|
||||
* @param $file
|
||||
* @param string $connection
|
||||
*/
|
||||
public function query_sql_file($file, $connection = self::CONNECTION_INSTALL)
|
||||
{
|
||||
$lines = file($file);
|
||||
$previous = null;
|
||||
$errors = '';
|
||||
@mysql_query("SET NAMES 'utf8';");
|
||||
DB::connection($connection)
|
||||
->statement("SET NAMES 'utf8'");
|
||||
foreach ($lines as $j => $line) {
|
||||
$line = trim($line); // Remove comments from the script
|
||||
|
||||
|
||||
if (strpos($line, "--") === 0) {
|
||||
$line = substr($line, 0, strpos($line, "--"));
|
||||
if (strpos($line, '--') === 0) {
|
||||
$line = substr($line, 0, strpos($line, '--'));
|
||||
}
|
||||
|
||||
if (empty($line)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strpos($line, "#") === 0) {
|
||||
$line = substr($line, 0, strpos($line, "#"));
|
||||
if (strpos($line, '#') === 0) {
|
||||
$line = substr($line, 0, strpos($line, '#'));
|
||||
}
|
||||
|
||||
if (empty($line)) {
|
||||
@@ -495,32 +601,23 @@ class Installer
|
||||
|
||||
// Concatenate the previous line, if any, with the current
|
||||
if ($previous) {
|
||||
$line = $previous . " " . $line;
|
||||
$line = $previous . ' ' . $line;
|
||||
}
|
||||
$previous = null;
|
||||
|
||||
// If the current line doesnt end with ; then put this line together
|
||||
// with the next one, thus supporting multi-line statements.
|
||||
if (strrpos($line, ";") != strlen($line) - 1) {
|
||||
if (strrpos($line, ';') != strlen($line) - 1) {
|
||||
$previous = $line;
|
||||
continue;
|
||||
}
|
||||
|
||||
$line = substr($line, 0, strrpos($line, ";"));
|
||||
@mysql_query($line, $connection);
|
||||
$line = substr($line, 0, strrpos($line, ';'));
|
||||
DB::connection($connection)
|
||||
->statement($line);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* check_path
|
||||
*
|
||||
* @return void
|
||||
* @todo Empty function
|
||||
*/
|
||||
private function check_path()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* function find_root_path
|
||||
*
|
||||
@@ -573,11 +670,11 @@ class Installer
|
||||
* getDirectoryFiles
|
||||
*
|
||||
* @param string $dir default value empty
|
||||
* @return string $path
|
||||
* @return array
|
||||
*/
|
||||
public function getDirectoryFiles($dir, $extension)
|
||||
{
|
||||
$filesArray = array();
|
||||
$filesArray = [];
|
||||
if (file_exists($dir)) {
|
||||
if ($handle = opendir($dir)) {
|
||||
while (false !== ($file = readdir($handle))) {
|
||||
@@ -595,131 +692,149 @@ class Installer
|
||||
/**
|
||||
* check_db_empty
|
||||
*
|
||||
* @param string $dbName
|
||||
* @param string$dbName
|
||||
* @return boolean true or false
|
||||
* @throws Exception
|
||||
*/
|
||||
public function check_db_empty($dbName)
|
||||
{
|
||||
$a = @mysql_select_db($dbName, $this->connection_database);
|
||||
if (!$a) {
|
||||
return true;
|
||||
try
|
||||
{
|
||||
$result = DB::connection(self::CONNECTION_TEST_INSTALL)->select("show databases like '$dbName'");
|
||||
if (!$result) {
|
||||
return true;
|
||||
} else {
|
||||
$result = DB::connection(self::CONNECTION_TEST_INSTALL)->select("show tables from $dbName");
|
||||
return !$result;
|
||||
}
|
||||
} catch (QueryException $exception) {
|
||||
throw new Exception('User without permissions. ' . $exception->getMessage());
|
||||
}
|
||||
$q = @mysql_query('SHOW TABLES', $this->connection_database);
|
||||
return (@mysql_num_rows($q) > 0) ? false : true;
|
||||
}
|
||||
|
||||
/**
|
||||
* check_db
|
||||
*
|
||||
* @param string $dbName
|
||||
* @return Array Array('status' => true or false,'message' => string)
|
||||
* @return array Array('status' => true or false,'message' => string)
|
||||
*/
|
||||
public function check_db($dbName)
|
||||
{
|
||||
$response = [];
|
||||
$response['status'] = false;
|
||||
$response['message'] = '';
|
||||
if (!$this->connection_database) {
|
||||
//erik: new verification if the mysql extension is enabled
|
||||
$error = class_exists('mysql_error') ? mysql_error() : 'Mysql Module for PHP is not enabled!';
|
||||
return Array('status' => false, 'message' => $error
|
||||
);
|
||||
//new verification if the mysql extension is enabled
|
||||
$response['message'] = 'Mysql Module for PHP is not enabled!';
|
||||
} else {
|
||||
if (!mysql_select_db($dbName, $this->connection_database) && $this->cc_status != 1) {
|
||||
return Array('status' => false, 'message' => mysql_error()
|
||||
);
|
||||
if ($this->cc_status != 1) {
|
||||
$result = DB::connection(self::CONNECTION_TEST_INSTALL)->select("show databases like '$dbName'");
|
||||
} else {
|
||||
/* var_dump($this->options['advanced']['ao_db_drop'],$this->cc_status,$this->check_db_empty($dbName));
|
||||
if(($this->options['advanced']['ao_db_drop']===false && $this->cc_status!=1 && !$this->check_db_empty($dbName)) )
|
||||
{
|
||||
return Array('status'=>false,'message'=>'Database is not empty');
|
||||
}
|
||||
else
|
||||
{
|
||||
return Array('status'=>true,'message'=>'OK');
|
||||
} */
|
||||
if ($this->options['advanced']['ao_db_drop'] === true || $this->check_db_empty($dbName)) {
|
||||
return Array('status' => true, 'message' => 'PASSED'
|
||||
);
|
||||
$response['status'] = true;
|
||||
$response['message'] = 'PASSED';
|
||||
} else {
|
||||
return Array('status' => false, 'message' => 'Database is not empty'
|
||||
);
|
||||
$response['message'] = 'Database is not empty';
|
||||
}
|
||||
}
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* check_connection
|
||||
*
|
||||
* @return Array $rt
|
||||
* @return array $rt
|
||||
*/
|
||||
private function check_connection()
|
||||
private function check_connection($nameConnection)
|
||||
{
|
||||
if (!function_exists("mysql_connect")) {
|
||||
$this->cc_status = 0;
|
||||
$rt = Array('connection' => false, 'grant' => 0, 'version' => false, 'message' => "ERROR: Mysql Module for PHP is not enabled, try install <b>php-mysql</b> package.", 'ao' => Array('ao_db_wf' => false, 'ao_db_rb' => false, 'ao_db_rp' => false
|
||||
)
|
||||
);
|
||||
} else {
|
||||
$this->connection_database = @mysql_connect($this->options['database']['hostname'], $this->options['database']['username'], $this->options['database']['password']);
|
||||
$rt = Array('version' => false, 'ao' => Array('ao_db_wf' => false, 'ao_db_rb' => false, 'ao_db_rp' => false
|
||||
)
|
||||
);
|
||||
if (!$this->connection_database) {
|
||||
$this->cc_status = 0;
|
||||
$rt['connection'] = false;
|
||||
$rt['grant'] = 0;
|
||||
$rt['message'] = "Mysql error: " . mysql_error();
|
||||
} else {
|
||||
preg_match('@[0-9]+\.[0-9]+\.[0-9]+@', mysql_get_server_info($this->connection_database), $version);
|
||||
$rt['version'] = version_compare(@$version[0], "4.1.0", ">=");
|
||||
$this->cc_status = 0;
|
||||
$rt = [
|
||||
'connection' => false,
|
||||
'grant' => 0,
|
||||
'version' => false,
|
||||
'message' => 'ERROR: Mysql Module for PHP is not enabled, try install <b>php-mysqli</b> package.',
|
||||
'ao' => [
|
||||
'ao_db_wf' => false,
|
||||
'ao_db_rb' => false,
|
||||
'ao_db_rp' => false
|
||||
]
|
||||
];
|
||||
|
||||
if (function_exists('mysqli_connect')) {
|
||||
try {
|
||||
InstallerModule::setNewConnection(
|
||||
$nameConnection,
|
||||
$this->options['database']['hostname'],
|
||||
$this->options['database']['username'],
|
||||
$this->options['database']['password'],
|
||||
'',
|
||||
$this->options['database']['port']);
|
||||
$rt = [
|
||||
'version' => false,
|
||||
'ao' => [
|
||||
'ao_db_wf' => false,
|
||||
'ao_db_rb' => false,
|
||||
'ao_db_rp' => false
|
||||
]
|
||||
];
|
||||
|
||||
$results = DB::connection($nameConnection)->select(DB::raw('select version()'));
|
||||
|
||||
preg_match('@[0-9]+\.[0-9]+\.[0-9]+@', $results[0]->{'version()'}, $version);
|
||||
$rt['version'] = version_compare($mysql_version = $version[0], '4.1.0', '>=');
|
||||
$rt['connection'] = true;
|
||||
|
||||
$dbNameTest = "PROCESSMAKERTESTDC";
|
||||
$db = @mysql_query("CREATE DATABASE " . $dbNameTest, $this->connection_database);
|
||||
$dbNameTest = 'PROCESSMAKERTESTDC';
|
||||
$db = DB::connection($nameConnection)->statement("CREATE DATABASE IF NOT EXISTS $dbNameTest");
|
||||
$this->connection_database = true;
|
||||
|
||||
if (!$db) {
|
||||
$this->cc_status = 3;
|
||||
$rt['grant'] = 3;
|
||||
//$rt['message'] = "Db GRANTS error: ".mysql_error();
|
||||
$rt['message'] = "Successful connection";
|
||||
$rt['message'] = 'Successful connection';
|
||||
} else {
|
||||
$usrTest = 'wfrbtest';
|
||||
$chkG = "GRANT ALL PRIVILEGES ON `" . $dbNameTest . "`.* TO " . $usrTest . "@'%' IDENTIFIED BY '!Sample123' WITH GRANT OPTION";
|
||||
$ch = DB::connection($nameConnection)
|
||||
->statement($chkG);
|
||||
|
||||
//@mysql_drop_db("processmaker_testGA");
|
||||
$usrTest = "wfrbtest";
|
||||
$chkG = "GRANT ALL PRIVILEGES ON `" . $dbNameTest . "`.* TO " . $usrTest . "@'%' IDENTIFIED BY 'sample' WITH GRANT OPTION";
|
||||
$ch = @mysql_query($chkG, $this->connection_database);
|
||||
if (!$ch) {
|
||||
$this->cc_status = 2;
|
||||
$rt['grant'] = 2;
|
||||
//$rt['message'] = "USER PRIVILEGES ERROR";
|
||||
$rt['message'] = "Successful connection";
|
||||
$rt['message'] = 'Successful connection';
|
||||
} else {
|
||||
$this->cc_status = 1;
|
||||
@mysql_query("DROP USER " . $usrTest . "@'%'", $this->connection_database);
|
||||
DB::connection($nameConnection)
|
||||
->statement("DROP USER " . $usrTest . "@'%'");
|
||||
$rt['grant'] = 1;
|
||||
$rt['message'] = "Successful connection";
|
||||
$rt['message'] = 'Successful connection';
|
||||
}
|
||||
@mysql_query("DROP DATABASE " . $dbNameTest, $this->connection_database);
|
||||
DB::connection($nameConnection)
|
||||
->statement('DROP DATABASE ' . $dbNameTest);
|
||||
}
|
||||
// var_dump($wf,$rb,$rp);
|
||||
} catch (Exception $exception) {
|
||||
$rt['connection'] = false;
|
||||
$rt['grant'] = 0;
|
||||
$rt['message'] = 'Mysql error: ' . $exception->getMessage();
|
||||
}
|
||||
}
|
||||
$rt['ao']['ao_db_wf'] = $this->check_db($this->options['advanced']['ao_db_wf']);
|
||||
//$rt['ao']['ao_db_rb'] = $this->check_db($this->options['advanced']['ao_db_rb']);
|
||||
//$rt['ao']['ao_db_rp'] = $this->check_db($this->options['advanced']['ao_db_rp']);
|
||||
return $rt;
|
||||
}
|
||||
|
||||
/**
|
||||
* log
|
||||
* Log
|
||||
*
|
||||
* @param string $text
|
||||
* @return void
|
||||
* @param boolean $failed
|
||||
* @throws Exception
|
||||
*/
|
||||
public function log($text, $failed = null)
|
||||
public function log($text, $failed = false)
|
||||
{
|
||||
array_push($this->report, $text);
|
||||
$this->report[] = $text;
|
||||
if ($failed) {
|
||||
throw new Exception(is_string($text) ? $text : var_export($text, true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\Core;
|
||||
|
||||
use Configurations;
|
||||
use DomDocument;
|
||||
use Exception;
|
||||
use Faker;
|
||||
use G;
|
||||
use GzipFile;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use InputFilter;
|
||||
use InstallerModule;
|
||||
use Net;
|
||||
use schema;
|
||||
use WorkspaceTools;
|
||||
|
||||
@@ -54,7 +60,8 @@ class System
|
||||
'load_headers_ie' => 0,
|
||||
'redirect_to_mobile' => 0,
|
||||
'disable_php_upload_execution' => 0,
|
||||
'disable_download_documents_session_validation' => 0
|
||||
'disable_download_documents_session_validation' => 0,
|
||||
'logs_max_files' => 60
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -66,7 +73,7 @@ class System
|
||||
*/
|
||||
public static function getPlugins()
|
||||
{
|
||||
$plugins = array();
|
||||
$plugins = [];
|
||||
|
||||
foreach (glob(PATH_PLUGINS . "*") as $filename) {
|
||||
$info = pathinfo($filename);
|
||||
@@ -90,7 +97,7 @@ class System
|
||||
public static function listWorkspaces()
|
||||
{
|
||||
$oDirectory = dir(PATH_DB);
|
||||
$aWorkspaces = array();
|
||||
$aWorkspaces = [];
|
||||
foreach (glob(PATH_DB . "*") as $filename) {
|
||||
if (is_dir($filename) && file_exists($filename . "/db.php")) {
|
||||
$aWorkspaces[] = new WorkspaceTools(basename($filename));
|
||||
@@ -150,7 +157,7 @@ class System
|
||||
*/
|
||||
public static function getSysInfo()
|
||||
{
|
||||
$ipe = isset($_SERVER['SSH_CONNECTION']) ? explode(" ", $_SERVER['SSH_CONNECTION']) : array();
|
||||
$ipe = isset($_SERVER['SSH_CONNECTION']) ? explode(" ", $_SERVER['SSH_CONNECTION']) : [];
|
||||
|
||||
if (getenv('HTTP_CLIENT_IP')) {
|
||||
$ip = getenv('HTTP_CLIENT_IP');
|
||||
@@ -194,7 +201,7 @@ class System
|
||||
*/
|
||||
$distro = trim($distro, "\"") . " (" . PHP_OS . ")";
|
||||
|
||||
$Fields = array();
|
||||
$Fields = [];
|
||||
$Fields['SYSTEM'] = $distro;
|
||||
$Fields['PHP'] = phpversion();
|
||||
$Fields['PM_VERSION'] = self::getVersion();
|
||||
@@ -397,9 +404,9 @@ class System
|
||||
fwrite($fp, "");
|
||||
fclose($fp);
|
||||
|
||||
$aEnvironmentsUpdated = array();
|
||||
$aEnvironmentsDiff = array();
|
||||
$aErrors = array();
|
||||
$aEnvironmentsUpdated = [];
|
||||
$aEnvironmentsDiff = [];
|
||||
$aErrors = [];
|
||||
|
||||
//now will verify each folder and file has permissions to write and add files.
|
||||
if ($this->sUpgradeFileList != '') {
|
||||
@@ -557,13 +564,13 @@ class System
|
||||
$oDirectory = dir(PATH_DB);
|
||||
|
||||
//count db.php files ( workspaces )
|
||||
$aWorkspaces = array();
|
||||
$aWorkspaces = [];
|
||||
while (($sObject = $oDirectory->read())) {
|
||||
if (is_dir(PATH_DB . $sObject) && substr($sObject, 0, 1) != '.' && file_exists(PATH_DB . $sObject . PATH_SEP . 'db.php')) {
|
||||
$aWorkspaces[] = $sObject;
|
||||
}
|
||||
}
|
||||
$aUpgradeData = array();
|
||||
$aUpgradeData = [];
|
||||
$aUpgradeData['workspaces'] = $aWorkspaces;
|
||||
$aUpgradeData['wsQuantity'] = count($aWorkspaces);
|
||||
$aUpgradeData['sPoFile'] = $sPoFile;
|
||||
@@ -732,19 +739,28 @@ class System
|
||||
public static function getSchema($sSchemaFile)
|
||||
{
|
||||
/* This is the MySQL mapping that Propel uses (from MysqlPlatform.php) */
|
||||
$mysqlTypes = array('NUMERIC' => "DECIMAL", 'LONGVARCHAR' => "MEDIUMTEXT", 'TIMESTAMP' => "DATETIME", 'BU_TIMESTAMP' => "DATETIME", 'BINARY' => "BLOB", 'VARBINARY' => "MEDIUMBLOB", 'LONGVARBINARY' => "LONGBLOB", 'BLOB' => "LONGBLOB", 'CLOB' => "LONGTEXT",
|
||||
$mysqlTypes = [
|
||||
'NUMERIC' => 'DECIMAL',
|
||||
'LONGVARCHAR' => 'MEDIUMTEXT',
|
||||
'TIMESTAMP' => 'DATETIME',
|
||||
'BU_TIMESTAMP' => 'DATETIME',
|
||||
'BINARY' => 'BLOB',
|
||||
'VARBINARY' => 'MEDIUMBLOB',
|
||||
'LONGVARBINARY' => 'LONGBLOB',
|
||||
'BLOB' => 'LONGBLOB',
|
||||
'CLOB' => 'LONGTEXT',
|
||||
/* This is not from Propel, but is required to get INT right */
|
||||
'INTEGER' => "INT"
|
||||
);
|
||||
'INTEGER' => 'INT'
|
||||
];
|
||||
|
||||
$aSchema = array();
|
||||
$aSchema = [];
|
||||
$oXml = new DomDocument();
|
||||
$oXml->load($sSchemaFile);
|
||||
$aTables = $oXml->getElementsByTagName('table');
|
||||
foreach ($aTables as $oTable) {
|
||||
$aPrimaryKeys = array();
|
||||
$aPrimaryKeys = [];
|
||||
$sTableName = $oTable->getAttribute('name');
|
||||
$aSchema[$sTableName] = array();
|
||||
$aSchema[$sTableName] = [];
|
||||
$aColumns = $oTable->getElementsByTagName('column');
|
||||
foreach ($aColumns as $oColumn) {
|
||||
$sColumName = $oColumn->getAttribute('name');
|
||||
@@ -801,7 +817,7 @@ class System
|
||||
}
|
||||
$aIndexes = $oTable->getElementsByTagName('index');
|
||||
foreach ($aIndexes as $oIndex) {
|
||||
$aIndex = array();
|
||||
$aIndex = [];
|
||||
$aIndexesColumns = $oIndex->getElementsByTagName('index-column');
|
||||
foreach ($aIndexesColumns as $oIndexColumn) {
|
||||
$aIndex[] = $oIndexColumn->getAttribute('name');
|
||||
@@ -820,7 +836,7 @@ class System
|
||||
*/
|
||||
public static function verifyRbacSchema($aOldSchema)
|
||||
{
|
||||
$aChanges = array();
|
||||
$aChanges = [];
|
||||
|
||||
foreach ($aOldSchema as $sTableName => $aColumns) {
|
||||
if (substr($sTableName, 0, 4) != 'RBAC') {
|
||||
@@ -936,13 +952,13 @@ class System
|
||||
foreach ($aNewSchema[$sTableName]['INDEXES'] as $indexName => $indexFields) {
|
||||
if (!isset($aOldSchema[$sTableName]['INDEXES'][$indexName])) {
|
||||
if (!isset($aChanges['tablesWithNewIndex'][$sTableName])) {
|
||||
$aChanges['tablesWithNewIndex'][$sTableName] = array();
|
||||
$aChanges['tablesWithNewIndex'][$sTableName] = [];
|
||||
}
|
||||
$aChanges['tablesWithNewIndex'][$sTableName][$indexName] = $indexFields;
|
||||
} else {
|
||||
if ($aOldSchema[$sTableName]['INDEXES'][$indexName] != $indexFields) {
|
||||
if (!isset($aChanges['tablesToAlterIndex'][$sTableName])) {
|
||||
$aChanges['tablesToAlterIndex'][$sTableName] = array();
|
||||
$aChanges['tablesToAlterIndex'][$sTableName] = [];
|
||||
}
|
||||
$aChanges['tablesToAlterIndex'][$sTableName][$indexName] = $indexFields;
|
||||
}
|
||||
@@ -1007,11 +1023,11 @@ class System
|
||||
}
|
||||
|
||||
//Get Skin Config files
|
||||
$skinListArray = array();
|
||||
$skinListArray = [];
|
||||
$customSkins = glob(PATH_CUSTOM_SKINS . "*/config.xml");
|
||||
|
||||
if (!is_array($customSkins)) {
|
||||
$customSkins = array();
|
||||
$customSkins = [];
|
||||
}
|
||||
|
||||
// getting al base skins
|
||||
@@ -1045,7 +1061,7 @@ class System
|
||||
|
||||
if (isset($xmlConfigurationObj->result['skinConfiguration'])) {
|
||||
$skinInformationArray = $skinFilesArray = $xmlConfigurationObj->result['skinConfiguration']['__CONTENT__']['information']['__CONTENT__'];
|
||||
$res = array();
|
||||
$res = [];
|
||||
$res['SKIN_FOLDER_ID'] = strtolower($folderId);
|
||||
|
||||
foreach ($skinInformationArray as $keyInfo => $infoValue) {
|
||||
@@ -1115,18 +1131,26 @@ class System
|
||||
}
|
||||
|
||||
if (empty($wsIniFile)) {
|
||||
|
||||
if (defined('PATH_DB')) {
|
||||
// if we're on a valid workspace env.
|
||||
if (empty($wsName)) {
|
||||
$uriParts = explode('/', getenv("REQUEST_URI"));
|
||||
|
||||
if (isset($uriParts[1])) {
|
||||
if (substr($uriParts[1], 0, 3) == 'sys') {
|
||||
$wsName = substr($uriParts[1], 3);
|
||||
try {
|
||||
if (function_exists('config')) {
|
||||
$wsName = config("system.workspace");
|
||||
}
|
||||
} catch (Exception $exception) {
|
||||
$wsName = '';
|
||||
}
|
||||
if (empty($wsName)) {
|
||||
$uriParts = explode('/', getenv("REQUEST_URI"));
|
||||
if (isset($uriParts[1])) {
|
||||
if (substr($uriParts[1], 0, 3) === 'sys') {
|
||||
$wsName = substr($uriParts[1], 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$wsIniFile = PATH_DB . $wsName . PATH_SEP . 'env.ini';
|
||||
}
|
||||
}
|
||||
@@ -1157,8 +1181,7 @@ class System
|
||||
self::$debug = $config['debug'];
|
||||
|
||||
if ($config['proxy_pass'] != '') {
|
||||
$G = new G();
|
||||
$config['proxy_pass'] = $G->decrypt($config['proxy_pass'], 'proxy_pass');
|
||||
$config['proxy_pass'] = G::decrypt($config['proxy_pass'], 'proxy_pass');
|
||||
}
|
||||
|
||||
return $config;
|
||||
@@ -1172,7 +1195,7 @@ class System
|
||||
*/
|
||||
public static function getQueryBlackList($globalIniFile = '')
|
||||
{
|
||||
$config = array();
|
||||
$config = [];
|
||||
if (empty($globalIniFile)) {
|
||||
$blackListIniFile = PATH_CONFIG . 'execute-query-blacklist.ini';
|
||||
$sysTablesIniFile = PATH_CONFIG . 'system-tables.ini';
|
||||
@@ -1195,7 +1218,7 @@ class System
|
||||
* @return string $result
|
||||
* @throws Exception
|
||||
*/
|
||||
public function updateIndexFile($conf)
|
||||
public static function updateIndexFile($conf)
|
||||
{
|
||||
if (!file_exists(PATH_HTML . 'index.html')) {
|
||||
throw new Exception('The public index file "' . PATH_HTML . 'index.html" does not exist!');
|
||||
@@ -1321,5 +1344,179 @@ class System
|
||||
|
||||
return $serverVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate user name for test
|
||||
*
|
||||
* @param int $length
|
||||
* @return string
|
||||
*/
|
||||
public static function generateUserName($length = 10)
|
||||
{
|
||||
$userName = 'PM_';
|
||||
for ($i = 0; $i < $length - 3; $i++) {
|
||||
$userName .= ($i % 3) === 0 ? '?' : '#';
|
||||
}
|
||||
$faker = Faker\Factory::create();
|
||||
return $faker->bothify($userName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check permission the user in db
|
||||
*
|
||||
* @param string $adapter
|
||||
* @param string $serverName
|
||||
* @param int $port
|
||||
* @param string $userName
|
||||
* @param string $pass
|
||||
* @param string $dbName
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function checkPermissionsDbUser($adapter = 'mysql', $serverName, $port = 3306, $userName, $pass, $dbName = '')
|
||||
{
|
||||
if (empty($port)) {
|
||||
//setting defaults ports
|
||||
switch ($adapter) {
|
||||
case 'mysql':
|
||||
$port = 3306;
|
||||
break;
|
||||
case 'pgsql':
|
||||
$port = 5432;
|
||||
break;
|
||||
case 'mssql':
|
||||
$port = 1433;
|
||||
break;
|
||||
case 'oracle':
|
||||
$port = 1521;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$filter = new InputFilter();
|
||||
$serverName = $filter->validateInput($serverName);
|
||||
$userName = $filter->validateInput($userName);
|
||||
|
||||
$serverNet = new Net($serverName);
|
||||
if ($serverNet->getErrno() !== 0) {
|
||||
return [false, $serverNet->error];
|
||||
}
|
||||
$serverNet->scannPort($port);
|
||||
if ($serverNet->getErrno() !== 0) {
|
||||
return [false, $serverNet->error];
|
||||
}
|
||||
$serverNet->loginDbServer($userName, $pass);
|
||||
$serverNet->setDataBase('', $port);
|
||||
if ($serverNet->getErrno() !== 0) {
|
||||
return [false, $serverNet->error];
|
||||
}
|
||||
|
||||
$response = $serverNet->tryConnectServer($adapter);
|
||||
if (!empty($response) && $response->status !== 'SUCCESS' && $serverNet->getErrno() !== 0) {
|
||||
return [false, $serverNet->error];
|
||||
}
|
||||
|
||||
$message = '';
|
||||
$success = false;
|
||||
|
||||
$userName = $filter->validateInput($userName, 'nosql');
|
||||
try {
|
||||
$connection = 'SYSTEM';
|
||||
InstallerModule::setNewConnection($connection, $serverName, $userName, $pass, $dbName, $port);
|
||||
|
||||
//Test Create Database
|
||||
$dbNameTest = 'PROCESSMAKERTESTDC';
|
||||
$result = DB::connection($connection)->statement("CREATE DATABASE $dbNameTest");
|
||||
if ($result) {
|
||||
//Test set permissions user
|
||||
$usrTest = self::generateUserName(strlen($userName));
|
||||
$passTest = '!Sample123_';
|
||||
$result = DB::connection($connection)->statement("GRANT ALL PRIVILEGES ON `$dbNameTest`.* TO $usrTest@'%%' IDENTIFIED BY '$passTest' WITH GRANT OPTION");
|
||||
|
||||
if ($result) {
|
||||
//Test Create user
|
||||
$userTestCreate = self::generateUserName(strlen($userName));
|
||||
$result = DB::connection($connection)->statement("CREATE USER '$userTestCreate'@'%%' IDENTIFIED BY '$passTest'");
|
||||
|
||||
if ($result) {
|
||||
$success = true;
|
||||
$message = G::LoadTranslation('ID_SUCCESSFUL_CONNECTION');
|
||||
}
|
||||
|
||||
DB::connection($connection)->statement("DROP USER '$userTestCreate'@'%%'");
|
||||
DB::connection($connection)->statement("DROP USER '$usrTest'@'%%'");
|
||||
}
|
||||
DB::connection($connection)->statement("DROP DATABASE $dbNameTest");
|
||||
}
|
||||
} catch (Exception $exception) {
|
||||
$success = false;
|
||||
$message = $exception->getMessage();
|
||||
}
|
||||
|
||||
return [$success, !empty($message) ? $message : $serverNet->error];
|
||||
}
|
||||
|
||||
/**
|
||||
* Regenerate credentials paths installed
|
||||
*
|
||||
* @param string $host
|
||||
* @param string $user
|
||||
* @param string $pass
|
||||
* @return bool
|
||||
*/
|
||||
public static function regenerateCredentiaslPathInstalled($host, $user, $pass)
|
||||
{
|
||||
$hashOld = G::encryptOld(filemtime(PATH_GULLIVER . "/class.g.php"));
|
||||
$hash = G::encrypt($host . $hashOld . $user . $hashOld . $pass . $hashOld . (1), $hashOld);
|
||||
$insertStatements = "define ( 'HASH_INSTALLATION','{$hash}' ); \ndefine ( 'SYSTEM_HASH', '{$hashOld}' ); \n";
|
||||
$content = '';
|
||||
$filename = PATH_HOME . 'engine' . PATH_SEP . 'config' . PATH_SEP . 'paths_installed.php';
|
||||
$lines = file($filename);
|
||||
|
||||
$count = 1;
|
||||
foreach ($lines as $line_num => $line) {
|
||||
$pos = strpos($line, 'define');
|
||||
if ($pos !== false && $count < 3) {
|
||||
$content .= $line;
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
$content = "<?php \n" . $content . "\n" . $insertStatements . "\n";
|
||||
return file_put_contents($filename, $content) !== false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Connection Configuration using "config" helper from "Laravel" with
|
||||
* the constants defined in file "db.php"
|
||||
*/
|
||||
public static function setConnectionConfig(
|
||||
$dbAdapter,
|
||||
$dbHost,
|
||||
$dbName,
|
||||
$dbUser,
|
||||
$dbPass,
|
||||
$dbRbacHost,
|
||||
$dbRbacName,
|
||||
$dbRbacUser,
|
||||
$dbRbacPass,
|
||||
$dbReportHost,
|
||||
$dbReportName,
|
||||
$dbReportUser,
|
||||
$dbReportPass)
|
||||
{
|
||||
config(['connections.driver' => $dbAdapter]);
|
||||
config(['connections.workflow.host' => $dbHost]);
|
||||
config(['connections.workflow.database' => $dbName]);
|
||||
config(['connections.workflow.username' => $dbUser]);
|
||||
config(['connections.workflow.password' => $dbPass]);
|
||||
config(['connections.rbac.host' => $dbRbacHost]);
|
||||
config(['connections.rbac.database' => $dbRbacName]);
|
||||
config(['connections.rbac.username' => $dbRbacUser]);
|
||||
config(['connections.rbac.password' => $dbRbacPass]);
|
||||
config(['connections.report.host' => $dbReportHost]);
|
||||
config(['connections.report.database' => $dbReportName]);
|
||||
config(['connections.report.username' => $dbReportUser]);
|
||||
config(['connections.report.password' => $dbReportPass]);
|
||||
}
|
||||
}
|
||||
// end System class
|
||||
|
||||
10
workflow/engine/src/ProcessMaker/Facades/DB.php
Normal file
10
workflow/engine/src/ProcessMaker/Facades/DB.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
/**
|
||||
* Our own DB Facade that supports loading the database for workspaces as well as
|
||||
* external database connections.
|
||||
*/
|
||||
|
||||
class DB extends \Illuminate\Support\Facades\DB
|
||||
{
|
||||
|
||||
}
|
||||
20
workflow/engine/src/ProcessMaker/Model/DbSource.php
Normal file
20
workflow/engine/src/ProcessMaker/Model/DbSource.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\Model;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Class DbSource
|
||||
* @package ProcessMaker\Model
|
||||
*
|
||||
* Represents an external database connection. Each DB Source is related to a owner process.
|
||||
*/
|
||||
class DbSource extends Model
|
||||
{
|
||||
// Set our table name
|
||||
protected $table = 'DB_SOURCE';
|
||||
// We do not store timestamps
|
||||
public $timestamps = false;
|
||||
|
||||
}
|
||||
21
workflow/engine/src/ProcessMaker/Model/Process.php
Normal file
21
workflow/engine/src/ProcessMaker/Model/Process.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\Model;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Class Process
|
||||
* @package ProcessMaker\Model
|
||||
*
|
||||
* Represents a business process object in the system.
|
||||
*/
|
||||
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
|
||||
const CREATED_AT = 'PRO_CREATE_DATE';
|
||||
const UPDATED_AT = null;
|
||||
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\Project\Adapter;
|
||||
|
||||
use ProcessMaker\Plugins\PluginRegistry;
|
||||
@@ -18,22 +19,22 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
*/
|
||||
protected $wp;
|
||||
|
||||
const BPMN_GATEWAY_COMPLEX = "COMPLEX";
|
||||
const BPMN_GATEWAY_PARALLEL = "PARALLEL";
|
||||
const BPMN_GATEWAY_INCLUSIVE = "INCLUSIVE";
|
||||
const BPMN_GATEWAY_EXCLUSIVE = "EXCLUSIVE";
|
||||
const BPMN_GATEWAY_COMPLEX = "COMPLEX";
|
||||
const BPMN_GATEWAY_PARALLEL = "PARALLEL";
|
||||
const BPMN_GATEWAY_INCLUSIVE = "INCLUSIVE";
|
||||
const BPMN_GATEWAY_EXCLUSIVE = "EXCLUSIVE";
|
||||
const BPMN_GATEWAY_EVENTBASED = "EVENTBASED";
|
||||
|
||||
private $arrayTaskAttribute = array(
|
||||
"gateway-to-gateway" => array("type" => "GATEWAYTOGATEWAY", "prefix" => "gtg-"),
|
||||
"end-message-event" => array("type" => "END-MESSAGE-EVENT", "prefix" => "eme-"),
|
||||
"start-message-event" => array("type" => "START-MESSAGE-EVENT", "prefix" => "sme-"),
|
||||
"gateway-to-gateway" => array("type" => "GATEWAYTOGATEWAY", "prefix" => "gtg-"),
|
||||
"end-message-event" => array("type" => "END-MESSAGE-EVENT", "prefix" => "eme-"),
|
||||
"start-message-event" => array("type" => "START-MESSAGE-EVENT", "prefix" => "sme-"),
|
||||
"intermediate-throw-message-event" => array("type" => "INTERMEDIATE-THROW-MESSAGE-EVENT", "prefix" => "itme-"),
|
||||
"intermediate-catch-message-event" => array("type" => "INTERMEDIATE-CATCH-MESSAGE-EVENT", "prefix" => "icme-"),
|
||||
"start-timer-event" => array("type" => "START-TIMER-EVENT", "prefix" => "ste-"),
|
||||
"intermediate-catch-timer-event" => array("type" => "INTERMEDIATE-CATCH-TIMER-EVENT", "prefix" => "icte-"),
|
||||
"end-email-event" => array("type" => "END-EMAIL-EVENT", "prefix" => "eee-"),
|
||||
"intermediate-throw-email-event" => array("type" => "INTERMEDIATE-THROW-EMAIL-EVENT", "prefix" => "itee-")
|
||||
"start-timer-event" => array("type" => "START-TIMER-EVENT", "prefix" => "ste-"),
|
||||
"intermediate-catch-timer-event" => array("type" => "INTERMEDIATE-CATCH-TIMER-EVENT", "prefix" => "icte-"),
|
||||
"end-email-event" => array("type" => "END-EMAIL-EVENT", "prefix" => "eee-"),
|
||||
"intermediate-throw-email-event" => array("type" => "INTERMEDIATE-THROW-EMAIL-EVENT", "prefix" => "itee-")
|
||||
);
|
||||
|
||||
private $arrayElementTaskRelation = array();
|
||||
@@ -44,9 +45,7 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
|
||||
public static function load($prjUid)
|
||||
{
|
||||
|
||||
$parent = parent::load($prjUid);
|
||||
//return new BpmnWorkflow();
|
||||
|
||||
$me = new BpmnWorkflow();
|
||||
|
||||
@@ -104,19 +103,17 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
|
||||
//Add Audit Log
|
||||
$ogetProcess = new \Process();
|
||||
$getprocess=$ogetProcess->load($this->getUid());
|
||||
$nameProcess=$getprocess['PRO_TITLE'];
|
||||
\G::auditLog("ImportProcess", 'PMX File Imported '.$nameProcess. ' ('.$this->getUid().')');
|
||||
|
||||
$getprocess = $ogetProcess->load($this->getUid());
|
||||
$nameProcess = $getprocess['PRO_TITLE'];
|
||||
\G::auditLog("ImportProcess", 'PMX File Imported ' . $nameProcess . ' (' . $this->getUid() . ')');
|
||||
} catch (\Exception $e) {
|
||||
$prjUid = $this->getUid();
|
||||
//$this->remove();
|
||||
$bpmnProject = Project\Bpmn::load($prjUid);
|
||||
$bpmnProject->remove();
|
||||
|
||||
throw new \RuntimeException(sprintf(
|
||||
"Can't create Bpmn Project with prj_uid: %s, workflow creation fails." . PHP_EOL . $e->getMessage()
|
||||
, $prjUid
|
||||
"Can't create Bpmn Project with prj_uid: %s, workflow creation fails." . PHP_EOL . $e->getMessage(),
|
||||
$prjUid
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -284,18 +281,18 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
|
||||
$taskData = self::__updateServiceTask($activityBefore, $activityCurrent, $taskData);
|
||||
|
||||
if($activityCurrent->getActLoopType() == "PARALLEL"){
|
||||
$task = \TaskPeer::retrieveByPK($actUid);
|
||||
if($task->getTasAssignType() == "BALANCED" || $task->getTasAssignType() == "MANUAL" || $task->getTasAssignType() == "EVALUATE" || $task->getTasAssignType() == "REPORT_TO" || $task->getTasAssignType() == "SELF_SERVICE"){
|
||||
$taskData["TAS_ASSIGN_TYPE"] = "MULTIPLE_INSTANCE";
|
||||
}
|
||||
if ($activityCurrent->getActLoopType() == "PARALLEL") {
|
||||
$task = \TaskPeer::retrieveByPK($actUid);
|
||||
if ($task->getTasAssignType() == "BALANCED" || $task->getTasAssignType() == "MANUAL" || $task->getTasAssignType() == "EVALUATE" || $task->getTasAssignType() == "REPORT_TO" || $task->getTasAssignType() == "SELF_SERVICE") {
|
||||
$taskData["TAS_ASSIGN_TYPE"] = "MULTIPLE_INSTANCE";
|
||||
}
|
||||
}
|
||||
|
||||
if($activityCurrent->getActLoopType() == "EMPTY"){
|
||||
$task = \TaskPeer::retrieveByPK($actUid);
|
||||
if($task->getTasAssignType() == "MULTIPLE_INSTANCE_VALUE_BASED" || $task->getTasAssignType() == "MULTIPLE_INSTANCE"){
|
||||
$taskData["TAS_ASSIGN_TYPE"] = "BALANCED";
|
||||
}
|
||||
if ($activityCurrent->getActLoopType() == "EMPTY") {
|
||||
$task = \TaskPeer::retrieveByPK($actUid);
|
||||
if ($task->getTasAssignType() == "MULTIPLE_INSTANCE_VALUE_BASED" || $task->getTasAssignType() == "MULTIPLE_INSTANCE") {
|
||||
$taskData["TAS_ASSIGN_TYPE"] = "BALANCED";
|
||||
}
|
||||
}
|
||||
|
||||
$this->wp->updateTask($actUid, $taskData);
|
||||
@@ -324,7 +321,7 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
* @param $taskData
|
||||
* @return mixed
|
||||
*/
|
||||
static function __updateServiceTask($activityBefore, $activityCurrent, $taskData)
|
||||
public static function __updateServiceTask($activityBefore, $activityCurrent, $taskData)
|
||||
{
|
||||
$registry = PluginRegistry::loadSingleton();
|
||||
if ($activityBefore->getActTaskType() != "SERVICETASK" && $activityCurrent->getActTaskType() == "SERVICETASK") {
|
||||
@@ -341,7 +338,7 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
if ($activityBefore->getActTaskType() == "SERVICETASK" && $activityCurrent->getActTaskType() != "SERVICETASK") {
|
||||
$taskData["TAS_TYPE"] = "NORMAL";
|
||||
$taskData["TAS_ASSIGN_TYPE"] = "BALANCED";
|
||||
if($activityCurrent->getActTaskType() == "SCRIPTTASK"){
|
||||
if ($activityCurrent->getActTaskType() == "SCRIPTTASK") {
|
||||
$taskData["TAS_TYPE"] = "SCRIPT-TASK";
|
||||
}
|
||||
//The plugin pmConnectors will be moved to the core in pm.3.3
|
||||
@@ -380,8 +377,8 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
|
||||
$arrayElementTaskRelationData = $elementTaskRelation->getElementTaskRelationWhere(
|
||||
array(
|
||||
\ElementTaskRelationPeer::PRJ_UID => $this->wp->getUid(),
|
||||
\ElementTaskRelationPeer::ELEMENT_UID => $elementUid,
|
||||
\ElementTaskRelationPeer::PRJ_UID => $this->wp->getUid(),
|
||||
\ElementTaskRelationPeer::ELEMENT_UID => $elementUid,
|
||||
\ElementTaskRelationPeer::ELEMENT_TYPE => $elementType
|
||||
),
|
||||
true
|
||||
@@ -461,7 +458,7 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
return $floUid;
|
||||
}
|
||||
|
||||
public function updateFlow($floUid, $data, $flows)
|
||||
public function updateFlow($floUid, $data, $flows = null)
|
||||
{
|
||||
$flowBefore = \BpmnFlowPeer::retrieveByPK($floUid);
|
||||
|
||||
@@ -538,7 +535,7 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
$messageEventRelation = new \ProcessMaker\BusinessModel\MessageEventRelation();
|
||||
|
||||
$messageEventRelation->deleteWhere(array(
|
||||
\MessageEventRelationPeer::PRJ_UID => $flowBefore->getPrjUid(),
|
||||
\MessageEventRelationPeer::PRJ_UID => $flowBefore->getPrjUid(),
|
||||
\MessageEventRelationPeer::EVN_UID_THROW => $flowBefore->getFloElementOrigin(),
|
||||
\MessageEventRelationPeer::EVN_UID_CATCH => $flowBefore->getFloElementDest()
|
||||
));
|
||||
@@ -563,10 +560,10 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
$flow->getFloElementDestType() == "bpmnActivity"
|
||||
) {
|
||||
$bpmnFlow = \BpmnFlow::findOneBy(array(
|
||||
\BpmnFlowPeer::FLO_ELEMENT_ORIGIN => $flow->getFloElementOrigin(),
|
||||
\BpmnFlowPeer::FLO_ELEMENT_ORIGIN => $flow->getFloElementOrigin(),
|
||||
\BpmnFlowPeer::FLO_ELEMENT_ORIGIN_TYPE => "bpmnEvent",
|
||||
\BpmnFlowPeer::FLO_ELEMENT_DEST => $flow->getFloElementDest(),
|
||||
\BpmnFlowPeer::FLO_ELEMENT_DEST_TYPE => "bpmnActivity"
|
||||
\BpmnFlowPeer::FLO_ELEMENT_DEST => $flow->getFloElementDest(),
|
||||
\BpmnFlowPeer::FLO_ELEMENT_DEST_TYPE => "bpmnActivity"
|
||||
));
|
||||
|
||||
if (is_null($bpmnFlow)) {
|
||||
@@ -617,7 +614,7 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
$messageEventRelation = new \ProcessMaker\BusinessModel\MessageEventRelation();
|
||||
|
||||
$messageEventRelation->deleteWhere(array(
|
||||
\MessageEventRelationPeer::PRJ_UID => $flow->getPrjUid(),
|
||||
\MessageEventRelationPeer::PRJ_UID => $flow->getPrjUid(),
|
||||
\MessageEventRelationPeer::EVN_UID_THROW => $flow->getFloElementOrigin(),
|
||||
\MessageEventRelationPeer::EVN_UID_CATCH => $flow->getFloElementDest()
|
||||
));
|
||||
@@ -637,8 +634,8 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
if ($bpmnEvent->getEvnType() == "START") {
|
||||
//Flows
|
||||
$arrayFlow = \BpmnFlow::findAllBy(array(
|
||||
\BpmnFlowPeer::FLO_TYPE => array("MESSAGE", \Criteria::NOT_EQUAL),
|
||||
\BpmnFlowPeer::FLO_ELEMENT_ORIGIN => $bpmnEvent->getEvnUid(),
|
||||
\BpmnFlowPeer::FLO_TYPE => array("MESSAGE", \Criteria::NOT_EQUAL),
|
||||
\BpmnFlowPeer::FLO_ELEMENT_ORIGIN => $bpmnEvent->getEvnUid(),
|
||||
\BpmnFlowPeer::FLO_ELEMENT_ORIGIN_TYPE => "bpmnEvent"
|
||||
));
|
||||
|
||||
@@ -679,7 +676,7 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
}
|
||||
|
||||
//Message-Event-Definition - Delete
|
||||
$arrayEventType = array("START", "END", "INTERMEDIATE");
|
||||
$arrayEventType = array("START", "END", "INTERMEDIATE");
|
||||
$arrayEventMarker = array("MESSAGETHROW", "MESSAGECATCH");
|
||||
|
||||
if (in_array($bpmnEvent->getEvnType(), $arrayEventType) && in_array($bpmnEvent->getEvnMarker(), $arrayEventMarker)) {
|
||||
@@ -693,7 +690,7 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
}
|
||||
|
||||
//Timer-Event - Delete
|
||||
$arrayEventType = array("START", "INTERMEDIATE");
|
||||
$arrayEventType = array("START", "INTERMEDIATE");
|
||||
$arrayEventMarker = array("TIMER");
|
||||
|
||||
if (in_array($bpmnEvent->getEvnType(), $arrayEventType) && in_array($bpmnEvent->getEvnMarker(), $arrayEventMarker)) {
|
||||
@@ -706,7 +703,7 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
}
|
||||
|
||||
//Email-Event - Delete
|
||||
$arrayEventType = array("END", "INTERMEDIATE");
|
||||
$arrayEventType = array("END", "INTERMEDIATE");
|
||||
$arrayEventMarker = array("EMAIL");
|
||||
|
||||
if (in_array($bpmnEvent->getEvnType(), $arrayEventType) && in_array($bpmnEvent->getEvnMarker(), $arrayEventMarker)) {
|
||||
@@ -728,7 +725,7 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
|
||||
public function addEvent($data)
|
||||
{
|
||||
if (! array_key_exists("EVN_TYPE", $data)) {
|
||||
if (!array_key_exists("EVN_TYPE", $data)) {
|
||||
throw new \RuntimeException("Required param \"EVN_TYPE\" is missing.");
|
||||
}
|
||||
|
||||
@@ -811,7 +808,7 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
$taskPosY = 0;
|
||||
|
||||
$flow = \BpmnFlow::findOneBy(array(
|
||||
\BpmnFlowPeer::FLO_ELEMENT_ORIGIN => $elementUid,
|
||||
\BpmnFlowPeer::FLO_ELEMENT_ORIGIN => $elementUid,
|
||||
\BpmnFlowPeer::FLO_ELEMENT_ORIGIN_TYPE => $elementType
|
||||
));
|
||||
|
||||
@@ -822,7 +819,7 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
$taskPosY = (int)($arrayFlowData["FLO_Y1"]);
|
||||
} else {
|
||||
$flow = \BpmnFlow::findOneBy(array(
|
||||
\BpmnFlowPeer::FLO_ELEMENT_DEST => $elementUid,
|
||||
\BpmnFlowPeer::FLO_ELEMENT_DEST => $elementUid,
|
||||
\BpmnFlowPeer::FLO_ELEMENT_DEST_TYPE => $elementType
|
||||
));
|
||||
|
||||
@@ -834,15 +831,15 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
}
|
||||
}
|
||||
|
||||
$prefix = $this->arrayTaskAttribute[$key]["prefix"];
|
||||
$prefix = $this->arrayTaskAttribute[$key]["prefix"];
|
||||
$taskType = $this->arrayTaskAttribute[$key]["type"];
|
||||
|
||||
$taskUid = $this->wp->addTask(array(
|
||||
"TAS_UID" => $prefix . substr(Util\Common::generateUID(), (32 - strlen($prefix)) * -1),
|
||||
"TAS_TYPE" => $taskType,
|
||||
"TAS_UID" => $prefix . substr(Util\Common::generateUID(), (32 - strlen($prefix)) * -1),
|
||||
"TAS_TYPE" => $taskType,
|
||||
"TAS_TITLE" => $taskType,
|
||||
"TAS_POSX" => $taskPosX,
|
||||
"TAS_POSY" => $taskPosY
|
||||
"TAS_POSX" => $taskPosX,
|
||||
"TAS_POSY" => $taskPosY
|
||||
));
|
||||
|
||||
//Element-Task-Relation - Create
|
||||
@@ -851,9 +848,9 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
$arrayResult = $elementTaskRelation->create(
|
||||
$this->wp->getUid(),
|
||||
[
|
||||
'ELEMENT_UID' => $elementUid,
|
||||
'ELEMENT_UID' => $elementUid,
|
||||
'ELEMENT_TYPE' => $elementType,
|
||||
'TAS_UID' => $taskUid
|
||||
'TAS_UID' => $taskUid
|
||||
]
|
||||
);
|
||||
|
||||
@@ -922,16 +919,16 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
|
||||
//Flows
|
||||
$arrayFlow = \BpmnFlow::findAllBy(array(
|
||||
\BpmnFlowPeer::FLO_TYPE => array("MESSAGE", \Criteria::NOT_EQUAL),
|
||||
\BpmnFlowPeer::FLO_ELEMENT_ORIGIN => $gatewayUid,
|
||||
\BpmnFlowPeer::FLO_TYPE => array("MESSAGE", \Criteria::NOT_EQUAL),
|
||||
\BpmnFlowPeer::FLO_ELEMENT_ORIGIN => $gatewayUid,
|
||||
\BpmnFlowPeer::FLO_ELEMENT_ORIGIN_TYPE => "bpmnGateway"
|
||||
));
|
||||
|
||||
foreach ($arrayFlow as $value) {
|
||||
$arrayFlowData = $value->toArray();
|
||||
|
||||
$routeDefault = (array_key_exists("FLO_TYPE", $arrayFlowData) && $arrayFlowData["FLO_TYPE"] == "DEFAULT")? 1 : 0;
|
||||
$routeCondition = (array_key_exists("FLO_CONDITION", $arrayFlowData))? $arrayFlowData["FLO_CONDITION"] : "";
|
||||
$routeDefault = (array_key_exists("FLO_TYPE", $arrayFlowData) && $arrayFlowData["FLO_TYPE"] == "DEFAULT") ? 1 : 0;
|
||||
$routeCondition = (array_key_exists("FLO_CONDITION", $arrayFlowData)) ? $arrayFlowData["FLO_CONDITION"] : "";
|
||||
|
||||
switch ($arrayFlowData["FLO_ELEMENT_DEST_TYPE"]) {
|
||||
case "bpmnActivity":
|
||||
@@ -1015,15 +1012,15 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
$arrayEventData = \BpmnEvent::findOneBy(\BpmnEventPeer::EVN_UID, $eventUid)->toArray();
|
||||
|
||||
if (!is_null($arrayEventData)) {
|
||||
$arrayEventType = array("INTERMEDIATE");
|
||||
$arrayEventType = array("INTERMEDIATE");
|
||||
$arrayEventMarker = array("MESSAGETHROW", "MESSAGECATCH", "TIMER", "EMAIL");
|
||||
|
||||
if (in_array($arrayEventData["EVN_TYPE"], $arrayEventType) && in_array($arrayEventData["EVN_MARKER"], $arrayEventMarker)) {
|
||||
$arrayKey = array(
|
||||
"MESSAGETHROW" => "intermediate-throw-message-event",
|
||||
"MESSAGECATCH" => "intermediate-catch-message-event",
|
||||
"TIMER" => "intermediate-catch-timer-event",
|
||||
"EMAIL" => "intermediate-throw-email-event"
|
||||
"TIMER" => "intermediate-catch-timer-event",
|
||||
"EMAIL" => "intermediate-throw-email-event"
|
||||
);
|
||||
|
||||
$taskUid = $this->__createTaskByElement(
|
||||
@@ -1042,15 +1039,15 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
// The result value returns zero if the element is already mapped as a route
|
||||
// we need to add this to fix cases of recursion if an already element has been mapped.
|
||||
// like a loop for example.
|
||||
if ($result === 0 ) {
|
||||
if ($result === 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//Flows
|
||||
$arrayFlow = \BpmnFlow::findAllBy(array(
|
||||
\BpmnFlowPeer::FLO_TYPE => array("MESSAGE", \Criteria::NOT_EQUAL),
|
||||
\BpmnFlowPeer::FLO_ELEMENT_ORIGIN => $eventUid,
|
||||
\BpmnFlowPeer::FLO_TYPE => array("MESSAGE", \Criteria::NOT_EQUAL),
|
||||
\BpmnFlowPeer::FLO_ELEMENT_ORIGIN => $eventUid,
|
||||
\BpmnFlowPeer::FLO_ELEMENT_ORIGIN_TYPE => "bpmnEvent"
|
||||
));
|
||||
|
||||
@@ -1141,8 +1138,8 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
|
||||
//Flows
|
||||
$arrayFlow = \BpmnFlow::findAllBy(array(
|
||||
\BpmnFlowPeer::FLO_TYPE => array("MESSAGE", \Criteria::NOT_EQUAL),
|
||||
\BpmnFlowPeer::FLO_ELEMENT_ORIGIN => $activity["ACT_UID"],
|
||||
\BpmnFlowPeer::FLO_TYPE => array("MESSAGE", \Criteria::NOT_EQUAL),
|
||||
\BpmnFlowPeer::FLO_ELEMENT_ORIGIN => $activity["ACT_UID"],
|
||||
\BpmnFlowPeer::FLO_ELEMENT_ORIGIN_TYPE => "bpmnActivity"
|
||||
));
|
||||
|
||||
@@ -1266,13 +1263,13 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
if (\Process::existsByProTitle($projectData["prj_name"])) {
|
||||
throw new \Exception("Project with name: {$projectData["prj_name"]}, already exists.");
|
||||
}
|
||||
$activities = isset($projectData['diagrams']['0']['activities'])?$projectData['diagrams']['0']['activities']:array();
|
||||
$activities = isset($projectData['diagrams']['0']['activities']) ? $projectData['diagrams']['0']['activities'] : array();
|
||||
foreach ($activities as $value) {
|
||||
if (empty($value['act_type'])) {
|
||||
throw new \Exception("For activity: {$value['act_uid']} `act_type` is required but missing.");
|
||||
}
|
||||
}
|
||||
$events = isset($projectData['diagrams']['0']['events'])?$projectData['diagrams']['0']['events']:array();
|
||||
$events = isset($projectData['diagrams']['0']['events']) ? $projectData['diagrams']['0']['events'] : array();
|
||||
foreach ($events as $value) {
|
||||
if (empty($value['evn_type'])) {
|
||||
throw new \Exception("For event: {$value['evn_uid']} `evn_type` is required but missing.");
|
||||
@@ -1388,7 +1385,7 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
|
||||
$configList = array("changeCaseTo" => CASE_LOWER);
|
||||
|
||||
if (! is_null($diagram)) {
|
||||
if (!is_null($diagram)) {
|
||||
$diagram = array_change_key_case($diagram, CASE_LOWER);
|
||||
$diagram["activities"] = $bwp->getActivities($configList);
|
||||
$diagram["events"] = $bwp->getEvents($configList);
|
||||
@@ -1475,20 +1472,22 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
* @return array
|
||||
*/
|
||||
public static function updateFromStruct(
|
||||
$prjUid, $projectData,
|
||||
$prjUid,
|
||||
$projectData,
|
||||
$generateUid = true,
|
||||
$forceInsert = false,
|
||||
$allData = null
|
||||
) {
|
||||
)
|
||||
{
|
||||
$diagram = isset($projectData["diagrams"]) && isset($projectData["diagrams"][0]) ? $projectData["diagrams"][0] : array();
|
||||
$diagram["activities"] = isset($diagram["activities"])? $diagram["activities"]: array();
|
||||
$diagram["artifacts"] = isset($diagram["artifacts"])? $diagram["artifacts"]: array();
|
||||
$diagram["gateways"] = isset($diagram["gateways"])? $diagram["gateways"]: array();
|
||||
$diagram["events"] = isset($diagram["events"])? $diagram["events"]: array();
|
||||
$diagram["data"] = isset($diagram["data"])? $diagram["data"]: array();
|
||||
$diagram["participants"] = isset($diagram["participants"])? $diagram["participants"]: array();
|
||||
$diagram["laneset"] = isset($diagram["laneset"])? $diagram["laneset"]: array();
|
||||
$diagram["lanes"] = isset($diagram["lanes"])? $diagram["lanes"]: array();
|
||||
$diagram["activities"] = isset($diagram["activities"]) ? $diagram["activities"] : array();
|
||||
$diagram["artifacts"] = isset($diagram["artifacts"]) ? $diagram["artifacts"] : array();
|
||||
$diagram["gateways"] = isset($diagram["gateways"]) ? $diagram["gateways"] : array();
|
||||
$diagram["events"] = isset($diagram["events"]) ? $diagram["events"] : array();
|
||||
$diagram["data"] = isset($diagram["data"]) ? $diagram["data"] : array();
|
||||
$diagram["participants"] = isset($diagram["participants"]) ? $diagram["participants"] : array();
|
||||
$diagram["laneset"] = isset($diagram["laneset"]) ? $diagram["laneset"] : array();
|
||||
$diagram["lanes"] = isset($diagram["lanes"]) ? $diagram["lanes"] : array();
|
||||
|
||||
$result = array();
|
||||
|
||||
@@ -1540,13 +1539,13 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
$diagram = self::refreshElementUid($diagram, $uidOld, $lanesetData["LNS_UID"]);
|
||||
|
||||
$result[] = array(
|
||||
"object" => "laneset",
|
||||
"object" => "laneset",
|
||||
"old_uid" => $uidOld,
|
||||
"new_uid" => $lanesetData["LNS_UID"]
|
||||
);
|
||||
}
|
||||
$bwp->addLaneset($lanesetData);
|
||||
} elseif (! $bwp->isEquals($dataObject, $lanesetData)) {
|
||||
} elseif (!$bwp->isEquals($dataObject, $lanesetData)) {
|
||||
$bwp->updateLaneset($lanesetData["LNS_UID"], $lanesetData);
|
||||
} else {
|
||||
Util\Logger::log("Update Laneset ({$lanesetData["LNS_UID"]}) Skipped - No changes required");
|
||||
@@ -1560,7 +1559,7 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
|
||||
// looking for removed elements
|
||||
foreach ($dataCollection as $lanesetData) {
|
||||
if (! in_array($lanesetData["LNS_UID"], $whiteList)) {
|
||||
if (!in_array($lanesetData["LNS_UID"], $whiteList)) {
|
||||
// If it is not in the white list, then remove them
|
||||
$bwp->removeLaneset($lanesetData["LNS_UID"]);
|
||||
}
|
||||
@@ -1585,13 +1584,13 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
$diagram = self::refreshElementUid($diagram, $uidOld, $laneData["LAN_UID"]);
|
||||
|
||||
$result[] = array(
|
||||
"object" => "lane",
|
||||
"object" => "lane",
|
||||
"old_uid" => $uidOld,
|
||||
"new_uid" => $laneData["LAN_UID"]
|
||||
);
|
||||
}
|
||||
$bwp->addLane($laneData);
|
||||
} elseif (! $bwp->isEquals($dataObject, $laneData)) {
|
||||
} elseif (!$bwp->isEquals($dataObject, $laneData)) {
|
||||
$bwp->updateLane($laneData["LAN_UID"], $laneData);
|
||||
} else {
|
||||
Util\Logger::log("Update Lane ({$laneData["LAN_UID"]}) Skipped - No changes required");
|
||||
@@ -1605,7 +1604,7 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
|
||||
// looking for removed elements
|
||||
foreach ($dataCollection as $laneData) {
|
||||
if (! in_array($laneData["LAN_UID"], $whiteList)) {
|
||||
if (!in_array($laneData["LAN_UID"], $whiteList)) {
|
||||
// If it is not in the white list, then remove them
|
||||
$bwp->removeLane($laneData["LAN_UID"]);
|
||||
}
|
||||
@@ -1630,7 +1629,7 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
$activityData["ACT_UID"] = Util\Common::generateUID();
|
||||
|
||||
$result[] = array(
|
||||
"object" => "activity",
|
||||
"object" => "activity",
|
||||
"old_uid" => $uidOld,
|
||||
"new_uid" => $activityData["ACT_UID"]
|
||||
);
|
||||
@@ -1644,7 +1643,7 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
}
|
||||
|
||||
$bwp->addActivity($activityData);
|
||||
} elseif (! $bwp->isEquals($activity, $activityData)) {
|
||||
} elseif (!$bwp->isEquals($activity, $activityData)) {
|
||||
$bwp->updateActivity($activityData["ACT_UID"], $activityData);
|
||||
} else {
|
||||
Util\Logger::log("Update Activity ({$activityData["ACT_UID"]}) Skipped - No changes required");
|
||||
@@ -1652,14 +1651,13 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
$bwp->sincronizeActivityData($activityData["ACT_UID"], $activityData);
|
||||
$diagram["activities"][$i] = $activityData;
|
||||
$whiteList[] = $activityData["ACT_UID"];
|
||||
|
||||
}
|
||||
|
||||
$activities = $bwp->getActivities();
|
||||
|
||||
// looking for removed elements
|
||||
foreach ($activities as $activityData) {
|
||||
if (! in_array($activityData["ACT_UID"], $whiteList)) {
|
||||
if (!in_array($activityData["ACT_UID"], $whiteList)) {
|
||||
$bwp->removeActivity($activityData["ACT_UID"]);
|
||||
}
|
||||
}
|
||||
@@ -1683,14 +1681,14 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
$artifactData["ART_UID"] = Util\Common::generateUID();
|
||||
|
||||
$result[] = array(
|
||||
"object" => "artifact",
|
||||
"object" => "artifact",
|
||||
"old_uid" => $uidOld,
|
||||
"new_uid" => $artifactData["ART_UID"]
|
||||
);
|
||||
}
|
||||
|
||||
$bwp->addArtifact($artifactData);
|
||||
} elseif (! $bwp->isEquals($artifact, $artifactData)) {
|
||||
} elseif (!$bwp->isEquals($artifact, $artifactData)) {
|
||||
$bwp->updateArtifact($artifactData["ART_UID"], $artifactData);
|
||||
} else {
|
||||
Util\Logger::log("Update Artifact ({$artifactData["ART_UID"]}) Skipped - No changes required");
|
||||
@@ -1703,7 +1701,7 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
$artifacts = $bwp->getArtifacts();
|
||||
// looking for removed elements
|
||||
foreach ($artifacts as $artifactData) {
|
||||
if (! in_array($artifactData["ART_UID"], $whiteList)) {
|
||||
if (!in_array($artifactData["ART_UID"], $whiteList)) {
|
||||
$bwp->removeArtifact($artifactData["ART_UID"]);
|
||||
}
|
||||
}
|
||||
@@ -1734,7 +1732,7 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
$gatewayData["GAT_UID"] = Util\Common::generateUID();
|
||||
|
||||
$result[] = array(
|
||||
"object" => "gateway",
|
||||
"object" => "gateway",
|
||||
"old_uid" => $uidOld,
|
||||
"new_uid" => $gatewayData["GAT_UID"]
|
||||
);
|
||||
@@ -1743,7 +1741,7 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
$bwp->addGateway($gatewayData);
|
||||
|
||||
$flagAddOrUpdate = true;
|
||||
} elseif (! $bwp->isEquals($gateway, $gatewayData)) {
|
||||
} elseif (!$bwp->isEquals($gateway, $gatewayData)) {
|
||||
$bwp->updateGateway($gatewayData["GAT_UID"], $gatewayData);
|
||||
|
||||
$flagAddOrUpdate = true;
|
||||
@@ -1775,7 +1773,7 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
|
||||
// looking for removed elements
|
||||
foreach ($gateways as $gatewayData) {
|
||||
if (! in_array($gatewayData["GAT_UID"], $whiteList)) {
|
||||
if (!in_array($gatewayData["GAT_UID"], $whiteList)) {
|
||||
$bwp->removeGateway($gatewayData["GAT_UID"]);
|
||||
}
|
||||
}
|
||||
@@ -1808,14 +1806,14 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
$eventData["EVN_UID"] = Util\Common::generateUID();
|
||||
|
||||
$result[] = array(
|
||||
"object" => "event",
|
||||
"object" => "event",
|
||||
"old_uid" => $uidOld,
|
||||
"new_uid" => $eventData["EVN_UID"]
|
||||
);
|
||||
}
|
||||
|
||||
$bwp->addEvent($eventData);
|
||||
} elseif (! $bwp->isEquals($event, $eventData)) {
|
||||
} elseif (!$bwp->isEquals($event, $eventData)) {
|
||||
$bwp->updateEvent($eventData["EVN_UID"], $eventData);
|
||||
} else {
|
||||
Util\Logger::log("Update Event ({$eventData["EVN_UID"]}) Skipped - No changes required");
|
||||
@@ -1829,7 +1827,7 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
|
||||
// looking for removed elements
|
||||
foreach ($events as $eventData) {
|
||||
if (! in_array($eventData["EVN_UID"], $whiteList)) {
|
||||
if (!in_array($eventData["EVN_UID"], $whiteList)) {
|
||||
// If it is not in the white list, then remove them
|
||||
$bwp->removeEvent($eventData["EVN_UID"]);
|
||||
}
|
||||
@@ -1854,14 +1852,14 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
$dataObjectData["DAT_UID"] = Util\Common::generateUID();
|
||||
|
||||
$result[] = array(
|
||||
"object" => "data",
|
||||
"object" => "data",
|
||||
"old_uid" => $uidOld,
|
||||
"new_uid" => $dataObjectData["DAT_UID"]
|
||||
);
|
||||
}
|
||||
|
||||
$bwp->addData($dataObjectData);
|
||||
} elseif (! $bwp->isEquals($dataObject, $dataObjectData)) {
|
||||
} elseif (!$bwp->isEquals($dataObject, $dataObjectData)) {
|
||||
$bwp->updateData($dataObjectData["DAT_UID"], $dataObjectData);
|
||||
} else {
|
||||
Util\Logger::log("Update Data ({$dataObjectData["DAT_UID"]}) Skipped - No changes required");
|
||||
@@ -1875,7 +1873,7 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
|
||||
// looking for removed elements
|
||||
foreach ($dataCollection as $dataObjectData) {
|
||||
if (! in_array($dataObjectData["DAT_UID"], $whiteList)) {
|
||||
if (!in_array($dataObjectData["DAT_UID"], $whiteList)) {
|
||||
// If it is not in the white list, then remove them
|
||||
$bwp->removeData($dataObjectData["DAT_UID"]);
|
||||
}
|
||||
@@ -1900,14 +1898,14 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
$participantData["PAR_UID"] = Util\Common::generateUID();
|
||||
|
||||
$result[] = array(
|
||||
"object" => "participant",
|
||||
"object" => "participant",
|
||||
"old_uid" => $uidOld,
|
||||
"new_uid" => $participantData["PAR_UID"]
|
||||
);
|
||||
}
|
||||
|
||||
$bwp->addParticipant($participantData);
|
||||
} elseif (! $bwp->isEquals($participant, $participantData)) {
|
||||
} elseif (!$bwp->isEquals($participant, $participantData)) {
|
||||
$bwp->updateParticipant($participantData["PAR_UID"], $participantData);
|
||||
} else {
|
||||
Util\Logger::log("Update Participant ({$participantData["PAR_UID"]}) Skipped - No changes required");
|
||||
@@ -1921,7 +1919,7 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
|
||||
// looking for removed elements
|
||||
foreach ($dataCollection as $participantData) {
|
||||
if (! in_array($participantData["PAR_UID"], $whiteList)) {
|
||||
if (!in_array($participantData["PAR_UID"], $whiteList)) {
|
||||
// If it is not in the white list, then remove them
|
||||
$bwp->removeParticipant($participantData["PAR_UID"]);
|
||||
}
|
||||
@@ -1934,7 +1932,7 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
|
||||
$whiteList = array();
|
||||
|
||||
$diagramFlows = isset($diagram["flows"])?$diagram["flows"]:array();
|
||||
$diagramFlows = isset($diagram["flows"]) ? $diagram["flows"] : array();
|
||||
foreach ($diagramFlows as $i => $flowData) {
|
||||
$flowData = array_change_key_case($flowData, CASE_UPPER);
|
||||
|
||||
@@ -1987,12 +1985,12 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
$whiteList[] = $flowData["FLO_UID"];
|
||||
}
|
||||
|
||||
$diagramFlows = isset($diagram["flows"])?$diagram["flows"]:array();
|
||||
$diagramFlows = isset($diagram["flows"]) ? $diagram["flows"] : array();
|
||||
foreach ($diagramFlows as $flowData) {
|
||||
$flow = $bwp->getFlow($flowData["FLO_UID"]);
|
||||
if ($forceInsert || is_null($flow)) {
|
||||
$bwp->addFlow($flowData);
|
||||
} elseif (! $bwp->isEquals($flow, $flowData)) {
|
||||
} elseif (!$bwp->isEquals($flow, $flowData)) {
|
||||
$bwp->updateFlow($flowData["FLO_UID"], $flowData, $diagram["flows"]);
|
||||
} else {
|
||||
Util\Logger::log("Update Flow ({$flowData["FLO_UID"]}) Skipped - No changes required");
|
||||
@@ -2003,7 +2001,7 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
|
||||
// looking for removed elements
|
||||
foreach ($flows as $flowData) {
|
||||
if (! in_array($flowData["FLO_UID"], $whiteList)) {
|
||||
if (!in_array($flowData["FLO_UID"], $whiteList)) {
|
||||
$bwp->removeFlow($flowData["FLO_UID"]);
|
||||
}
|
||||
}
|
||||
@@ -2014,15 +2012,15 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
|
||||
if (!is_null($arrayGatewayData)) {
|
||||
$arrayFlow = \BpmnFlow::findAllBy([
|
||||
\BpmnFlowPeer::FLO_TYPE => ['MESSAGE', \Criteria::NOT_EQUAL],
|
||||
\BpmnFlowPeer::FLO_ELEMENT_DEST => $arrayGatewayData['GAT_UID'],
|
||||
\BpmnFlowPeer::FLO_TYPE => ['MESSAGE', \Criteria::NOT_EQUAL],
|
||||
\BpmnFlowPeer::FLO_ELEMENT_DEST => $arrayGatewayData['GAT_UID'],
|
||||
\BpmnFlowPeer::FLO_ELEMENT_DEST_TYPE => 'bpmnGateway'
|
||||
]);
|
||||
|
||||
if (count($arrayFlow) > 1) {
|
||||
$arrayFlow = \BpmnFlow::findAllBy([
|
||||
\BpmnFlowPeer::FLO_TYPE => ['MESSAGE', \Criteria::NOT_EQUAL],
|
||||
\BpmnFlowPeer::FLO_ELEMENT_ORIGIN => $arrayGatewayData['GAT_UID'],
|
||||
\BpmnFlowPeer::FLO_TYPE => ['MESSAGE', \Criteria::NOT_EQUAL],
|
||||
\BpmnFlowPeer::FLO_ELEMENT_ORIGIN => $arrayGatewayData['GAT_UID'],
|
||||
\BpmnFlowPeer::FLO_ELEMENT_ORIGIN_TYPE => 'bpmnGateway'
|
||||
]);
|
||||
|
||||
@@ -2086,7 +2084,7 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
$arrayResult = $webEntryEvent->update(
|
||||
$arrayWebEntryEventData['WEE_UID'],
|
||||
$bpmnProject->getPrjAuthor(),
|
||||
(!is_null($arrayData))? $arrayData : $arrayWebEntryEventData,
|
||||
(!is_null($arrayData)) ? $arrayData : $arrayWebEntryEventData,
|
||||
false
|
||||
);
|
||||
}
|
||||
@@ -2129,10 +2127,9 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
{
|
||||
array_walk_recursive(
|
||||
$diagram,
|
||||
function (&$value, $key, $arrayData)
|
||||
{
|
||||
function (&$value, $key, $arrayData) {
|
||||
try {
|
||||
if (strcmp($arrayData['oldUid'], $value) === 0){
|
||||
if (strcmp($arrayData['oldUid'], $value) === 0) {
|
||||
$value = $arrayData['newUid'];
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
@@ -2166,7 +2163,7 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
|
||||
$criteria->addSelectColumn(\TaskPeer::TAS_UID);
|
||||
|
||||
$criteria->addAlias('RT', \RoutePeer::TABLE_NAME);
|
||||
$criteria->addAlias('RT', \RoutePeer::TABLE_NAME);
|
||||
$criteria->addAlias('RNT', \RoutePeer::TABLE_NAME);
|
||||
|
||||
$arrayCondition = [];
|
||||
@@ -2182,7 +2179,8 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
|
||||
$criteria->add(
|
||||
$criteria->getNewCriterion('RT.ROU_UID', null, \Criteria::ISNULL)->addAnd(
|
||||
$criteria->getNewCriterion('RNT.ROU_UID', null, \Criteria::ISNULL))
|
||||
$criteria->getNewCriterion('RNT.ROU_UID', null, \Criteria::ISNULL)
|
||||
)
|
||||
);
|
||||
|
||||
$rsCriteria = \TaskPeer::doSelectRS($criteria);
|
||||
@@ -2207,7 +2205,7 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
//Update Process
|
||||
$process = \ProcessPeer::retrieveByPk($this->wp->getUid());
|
||||
|
||||
$arrayActionDone = (!is_null($process->getProActionDone()) && (string)($process->getProActionDone()) != '')? unserialize($process->getProActionDone()) : [];
|
||||
$arrayActionDone = (!is_null($process->getProActionDone()) && (string)($process->getProActionDone()) != '') ? unserialize($process->getProActionDone()) : [];
|
||||
$arrayActionDone[] = $actionDone;
|
||||
|
||||
$this->wp->update(['PRO_ACTION_DONE' => serialize($arrayActionDone)]);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\Project\Adapter;
|
||||
|
||||
use ProcessMaker\Project;
|
||||
@@ -67,17 +68,16 @@ class WorkflowBpmn extends Project\Workflow
|
||||
|
||||
//Add Audit Log
|
||||
$ogetProcess = new \Process();
|
||||
$getprocess=$ogetProcess->load($this->getUid());
|
||||
$nameProcess=$getprocess['PRO_TITLE'];
|
||||
\G::auditLog("ImportProcess", 'BPMN Imported '.$nameProcess. ' ('.$this->getUid().')');
|
||||
|
||||
$getprocess = $ogetProcess->load($this->getUid());
|
||||
$nameProcess = $getprocess['PRO_TITLE'];
|
||||
\G::auditLog("ImportProcess", 'BPMN Imported ' . $nameProcess . ' (' . $this->getUid() . ')');
|
||||
} catch (\Exception $e) {
|
||||
$prjUid = $this->getUid();
|
||||
$this->remove();
|
||||
|
||||
throw new \RuntimeException(sprintf(
|
||||
"Can't create Project with prj_uid: %s, workflow creation fails." . PHP_EOL . $e->getMessage()
|
||||
, $prjUid
|
||||
"Can't create Project with prj_uid: %s, workflow creation fails." . PHP_EOL . $e->getMessage(),
|
||||
$prjUid
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -103,12 +103,13 @@ class WorkflowBpmn extends Project\Workflow
|
||||
$eventName,
|
||||
$eventType,
|
||||
$condition = ""
|
||||
) {
|
||||
)
|
||||
{
|
||||
try {
|
||||
$eventBouWidth = 35;
|
||||
$eventBouWidth = 35;
|
||||
$eventBouHeight = $eventBouWidth;
|
||||
|
||||
$eventBouWidth2 = (int)($eventBouWidth / 2);
|
||||
$eventBouWidth2 = (int)($eventBouWidth / 2);
|
||||
$eventBouHeight2 = (int)($eventBouHeight / 2);
|
||||
|
||||
$eventBouHeight12 = (int)($eventBouWidth / 12);
|
||||
@@ -125,16 +126,16 @@ class WorkflowBpmn extends Project\Workflow
|
||||
} else {
|
||||
//Activity
|
||||
$eventBouX = $objectBouX + $objectBouWidth2 - $eventBouWidth2;
|
||||
$eventBouY = ($eventType == "START")? $objectBouY - $eventBouHeight - $eventBouHeight2 : $objectBouY + $objectBouHeight + $eventBouHeight2 + $eventBouHeight12;
|
||||
$eventBouY = ($eventType == "START") ? $objectBouY - $eventBouHeight - $eventBouHeight2 : $objectBouY + $objectBouHeight + $eventBouHeight2 + $eventBouHeight12;
|
||||
}
|
||||
|
||||
$arrayData = array(
|
||||
"EVN_NAME" => $eventName,
|
||||
"EVN_TYPE" => $eventType,
|
||||
"EVN_NAME" => $eventName,
|
||||
"EVN_TYPE" => $eventType,
|
||||
"EVN_MARKER" => "EMPTY",
|
||||
"BOU_X" => $eventBouX,
|
||||
"BOU_Y" => $eventBouY,
|
||||
"BOU_WIDTH" => $eventBouWidth,
|
||||
"BOU_X" => $eventBouX,
|
||||
"BOU_Y" => $eventBouY,
|
||||
"BOU_WIDTH" => $eventBouWidth,
|
||||
"BOU_HEIGHT" => $eventBouHeight
|
||||
);
|
||||
|
||||
@@ -150,24 +151,24 @@ class WorkflowBpmn extends Project\Workflow
|
||||
} else {
|
||||
//Activity
|
||||
$flowX1 = $objectBouX + $objectBouWidth2;
|
||||
$flowY1 = ($eventType == "START")? $objectBouY - $eventBouHeight + $eventBouHeight2 : $objectBouY + $objectBouHeight;
|
||||
$flowY1 = ($eventType == "START") ? $objectBouY - $eventBouHeight + $eventBouHeight2 : $objectBouY + $objectBouHeight;
|
||||
$flowX2 = $flowX1;
|
||||
$flowY2 = ($eventType == "START")? $objectBouY : $objectBouY + $objectBouHeight + $eventBouHeight2 + $eventBouHeight12;
|
||||
$flowY2 = ($eventType == "START") ? $objectBouY : $objectBouY + $objectBouHeight + $eventBouHeight2 + $eventBouHeight12;
|
||||
}
|
||||
|
||||
$arrayData = array(
|
||||
"FLO_TYPE" => "SEQUENCE",
|
||||
"FLO_ELEMENT_ORIGIN" => ($eventType == "START")? $eventUid : $objectUid,
|
||||
"FLO_ELEMENT_ORIGIN_TYPE" => ($eventType == "START")? "bpmnEvent" : $objectBpmnType,
|
||||
"FLO_ELEMENT_DEST" => ($eventType == "START")? $objectUid : $eventUid,
|
||||
"FLO_ELEMENT_DEST_TYPE" => ($eventType == "START")? $objectBpmnType : "bpmnEvent",
|
||||
"FLO_IS_INMEDIATE" => 1,
|
||||
"FLO_CONDITION" => $condition,
|
||||
"FLO_X1" => $flowX1,
|
||||
"FLO_Y1" => $flowY1,
|
||||
"FLO_X2" => $flowX2,
|
||||
"FLO_Y2" => $flowY2,
|
||||
"FLO_STATE" => json_encode(
|
||||
"FLO_TYPE" => "SEQUENCE",
|
||||
"FLO_ELEMENT_ORIGIN" => ($eventType == "START") ? $eventUid : $objectUid,
|
||||
"FLO_ELEMENT_ORIGIN_TYPE" => ($eventType == "START") ? "bpmnEvent" : $objectBpmnType,
|
||||
"FLO_ELEMENT_DEST" => ($eventType == "START") ? $objectUid : $eventUid,
|
||||
"FLO_ELEMENT_DEST_TYPE" => ($eventType == "START") ? $objectBpmnType : "bpmnEvent",
|
||||
"FLO_IS_INMEDIATE" => 1,
|
||||
"FLO_CONDITION" => $condition,
|
||||
"FLO_X1" => $flowX1,
|
||||
"FLO_Y1" => $flowY1,
|
||||
"FLO_X2" => $flowX2,
|
||||
"FLO_Y2" => $flowY2,
|
||||
"FLO_STATE" => json_encode(
|
||||
array(
|
||||
array("x" => $flowX1, "y" => $flowY1),
|
||||
array("x" => $flowX1, "y" => $flowY2 - 5),
|
||||
@@ -195,23 +196,23 @@ class WorkflowBpmn extends Project\Workflow
|
||||
//BPMN
|
||||
//Activity
|
||||
$arrayActivityType = array(
|
||||
"NORMAL" => "TASK",
|
||||
"ADHOC" => "TASK",
|
||||
"NORMAL" => "TASK",
|
||||
"ADHOC" => "TASK",
|
||||
"SUBPROCESS" => "SUB_PROCESS"
|
||||
);
|
||||
|
||||
$activityBouX = (int)($arrayTaskData["TAS_POSX"]);
|
||||
$activityBouY = (int)($arrayTaskData["TAS_POSY"]);
|
||||
$activityBouWidth = (int)($arrayTaskData["TAS_WIDTH"]);
|
||||
$activityBouWidth = (int)($arrayTaskData["TAS_WIDTH"]);
|
||||
$activityBouHeight = (int)($arrayTaskData["TAS_HEIGHT"]);
|
||||
|
||||
$arrayData = array(
|
||||
"ACT_UID" => $taskUid,
|
||||
"ACT_NAME" => $arrayTaskData["TAS_TITLE"],
|
||||
"ACT_TYPE" => $arrayActivityType[$arrayTaskData["TAS_TYPE"]],
|
||||
"BOU_X" => $activityBouX,
|
||||
"BOU_Y" => $activityBouY,
|
||||
"BOU_WIDTH" => $activityBouWidth,
|
||||
"ACT_UID" => $taskUid,
|
||||
"ACT_NAME" => $arrayTaskData["TAS_TITLE"],
|
||||
"ACT_TYPE" => $arrayActivityType[$arrayTaskData["TAS_TYPE"]],
|
||||
"BOU_X" => $activityBouX,
|
||||
"BOU_Y" => $activityBouY,
|
||||
"BOU_WIDTH" => $activityBouWidth,
|
||||
"BOU_HEIGHT" => $activityBouHeight
|
||||
);
|
||||
|
||||
@@ -247,12 +248,13 @@ class WorkflowBpmn extends Project\Workflow
|
||||
$gatewayName,
|
||||
$gatewayType,
|
||||
$gatewayDirection
|
||||
) {
|
||||
)
|
||||
{
|
||||
try {
|
||||
$gatewayBouWidth = 45;
|
||||
$gatewayBouWidth = 45;
|
||||
$gatewayBouHeight = $gatewayBouWidth;
|
||||
|
||||
$gatewayBouWidth2 = (int)($gatewayBouWidth / 2);
|
||||
$gatewayBouWidth2 = (int)($gatewayBouWidth / 2);
|
||||
$gatewayBouHeight2 = (int)($gatewayBouHeight / 2);
|
||||
|
||||
//
|
||||
@@ -261,17 +263,17 @@ class WorkflowBpmn extends Project\Workflow
|
||||
|
||||
//Gateway
|
||||
$gatewayBouX = $objectBouX + $objectBouWidth2 - $gatewayBouWidth2;
|
||||
$gatewayBouY = ($gatewayDirection == "DIVERGING")? $objectBouY + $objectBouHeight + $gatewayBouHeight2 : $objectBouY - $gatewayBouHeight - $gatewayBouHeight2;
|
||||
$gatewayBouY = ($gatewayDirection == "DIVERGING") ? $objectBouY + $objectBouHeight + $gatewayBouHeight2 : $objectBouY - $gatewayBouHeight - $gatewayBouHeight2;
|
||||
|
||||
$arrayData = array(
|
||||
"GAT_NAME" => $gatewayName,
|
||||
"GAT_TYPE" => $gatewayType,
|
||||
"GAT_DIRECTION" => $gatewayDirection,
|
||||
"GAT_NAME" => $gatewayName,
|
||||
"GAT_TYPE" => $gatewayType,
|
||||
"GAT_DIRECTION" => $gatewayDirection,
|
||||
"GAT_DEFAULT_FLOW" => "0",
|
||||
"BOU_X" => $gatewayBouX,
|
||||
"BOU_Y" => $gatewayBouY,
|
||||
"BOU_WIDTH" => $gatewayBouWidth,
|
||||
"BOU_HEIGHT" => $gatewayBouHeight
|
||||
"BOU_X" => $gatewayBouX,
|
||||
"BOU_Y" => $gatewayBouY,
|
||||
"BOU_WIDTH" => $gatewayBouWidth,
|
||||
"BOU_HEIGHT" => $gatewayBouHeight
|
||||
);
|
||||
|
||||
$gatewayUid = $this->bp->addGateway($arrayData);
|
||||
@@ -290,18 +292,18 @@ class WorkflowBpmn extends Project\Workflow
|
||||
}
|
||||
|
||||
$arrayData = array(
|
||||
"FLO_TYPE" => "SEQUENCE",
|
||||
"FLO_ELEMENT_ORIGIN" => ($gatewayDirection == "DIVERGING")? $objectUid : $gatewayUid,
|
||||
"FLO_ELEMENT_ORIGIN_TYPE" => ($gatewayDirection == "DIVERGING")? $objectBpmnType : "bpmnGateway",
|
||||
"FLO_ELEMENT_DEST" => ($gatewayDirection == "DIVERGING")? $gatewayUid : $objectUid,
|
||||
"FLO_ELEMENT_DEST_TYPE" => ($gatewayDirection == "DIVERGING")? "bpmnGateway" : $objectBpmnType,
|
||||
"FLO_IS_INMEDIATE" => 1,
|
||||
"FLO_CONDITION" => "",
|
||||
"FLO_X1" => $flowX1,
|
||||
"FLO_Y1" => $flowY1,
|
||||
"FLO_X2" => $flowX2,
|
||||
"FLO_Y2" => $flowY2,
|
||||
"FLO_STATE" => json_encode(
|
||||
"FLO_TYPE" => "SEQUENCE",
|
||||
"FLO_ELEMENT_ORIGIN" => ($gatewayDirection == "DIVERGING") ? $objectUid : $gatewayUid,
|
||||
"FLO_ELEMENT_ORIGIN_TYPE" => ($gatewayDirection == "DIVERGING") ? $objectBpmnType : "bpmnGateway",
|
||||
"FLO_ELEMENT_DEST" => ($gatewayDirection == "DIVERGING") ? $gatewayUid : $objectUid,
|
||||
"FLO_ELEMENT_DEST_TYPE" => ($gatewayDirection == "DIVERGING") ? "bpmnGateway" : $objectBpmnType,
|
||||
"FLO_IS_INMEDIATE" => 1,
|
||||
"FLO_CONDITION" => "",
|
||||
"FLO_X1" => $flowX1,
|
||||
"FLO_Y1" => $flowY1,
|
||||
"FLO_X2" => $flowX2,
|
||||
"FLO_Y2" => $flowY2,
|
||||
"FLO_STATE" => json_encode(
|
||||
array(
|
||||
array("x" => $flowX1, "y" => $flowY1),
|
||||
array("x" => $flowX1, "y" => $flowY2 - 5),
|
||||
@@ -334,10 +336,11 @@ class WorkflowBpmn extends Project\Workflow
|
||||
$objectDestBouWidth,
|
||||
$objectDestBouHeight,
|
||||
$condition = ""
|
||||
) {
|
||||
)
|
||||
{
|
||||
try {
|
||||
$objectOriginBouWidth2 = (int)($objectOriginBouWidth / 2);
|
||||
$objectDestBouWidth2 = (int)($objectDestBouWidth / 2);
|
||||
$objectOriginBouWidth2 = (int)($objectOriginBouWidth / 2);
|
||||
$objectDestBouWidth2 = (int)($objectDestBouWidth / 2);
|
||||
|
||||
$flowX1 = $objectOriginBouX + $objectOriginBouWidth2;
|
||||
$flowY1 = $objectOriginBouY + $objectOriginBouHeight;
|
||||
@@ -346,18 +349,18 @@ class WorkflowBpmn extends Project\Workflow
|
||||
|
||||
//Flow
|
||||
$arrayData = array(
|
||||
"FLO_TYPE" => "SEQUENCE",
|
||||
"FLO_ELEMENT_ORIGIN" => $objectOriginUid,
|
||||
"FLO_TYPE" => "SEQUENCE",
|
||||
"FLO_ELEMENT_ORIGIN" => $objectOriginUid,
|
||||
"FLO_ELEMENT_ORIGIN_TYPE" => $objectOriginBpmnType,
|
||||
"FLO_ELEMENT_DEST" => $objectDestUid,
|
||||
"FLO_ELEMENT_DEST_TYPE" => $objectDestBpmnType,
|
||||
"FLO_IS_INMEDIATE" => 1,
|
||||
"FLO_CONDITION" => $condition,
|
||||
"FLO_X1" => $flowX1,
|
||||
"FLO_Y1" => $flowY1,
|
||||
"FLO_X2" => $flowX2,
|
||||
"FLO_Y2" => $flowY2,
|
||||
"FLO_STATE" => json_encode(array())
|
||||
"FLO_ELEMENT_DEST" => $objectDestUid,
|
||||
"FLO_ELEMENT_DEST_TYPE" => $objectDestBpmnType,
|
||||
"FLO_IS_INMEDIATE" => 1,
|
||||
"FLO_CONDITION" => $condition,
|
||||
"FLO_X1" => $flowX1,
|
||||
"FLO_Y1" => $flowY1,
|
||||
"FLO_X2" => $flowX2,
|
||||
"FLO_Y2" => $flowY2,
|
||||
"FLO_STATE" => json_encode(array())
|
||||
);
|
||||
|
||||
$flowUid = $this->bp->addFlow($arrayData);
|
||||
@@ -381,7 +384,7 @@ class WorkflowBpmn extends Project\Workflow
|
||||
$activityUid = $arrayTaskData["TAS_UID"];
|
||||
$activityBouX = (int)($arrayTaskData["TAS_POSX"]);
|
||||
$activityBouY = (int)($arrayTaskData["TAS_POSY"]);
|
||||
$activityBouWidth = (int)($arrayTaskData["TAS_WIDTH"]);
|
||||
$activityBouWidth = (int)($arrayTaskData["TAS_WIDTH"]);
|
||||
$activityBouHeight = (int)($arrayTaskData["TAS_HEIGHT"]);
|
||||
|
||||
$arrayTaskData = $this->getTask($nextTaskUid);
|
||||
@@ -389,7 +392,7 @@ class WorkflowBpmn extends Project\Workflow
|
||||
$nextActivityUid = $arrayTaskData["TAS_UID"];
|
||||
$nextActivityBouX = (int)($arrayTaskData["TAS_POSX"]);
|
||||
$nextActivityBouY = (int)($arrayTaskData["TAS_POSY"]);
|
||||
$nextActivityBouWidth = (int)($arrayTaskData["TAS_WIDTH"]);
|
||||
$nextActivityBouWidth = (int)($arrayTaskData["TAS_WIDTH"]);
|
||||
$nextActivityBouHeight = (int)($arrayTaskData["TAS_HEIGHT"]);
|
||||
|
||||
$result = $this->bp->getGatewayByDirectionActivityAndFlow("CONVERGING", $nextActivityUid);
|
||||
@@ -439,11 +442,11 @@ class WorkflowBpmn extends Project\Workflow
|
||||
$arrayGatewayData = $result;
|
||||
}
|
||||
|
||||
$gatewayUid = $arrayGatewayData["GAT_UID"];
|
||||
$gatewayUid = $arrayGatewayData["GAT_UID"];
|
||||
$gatewayType = $arrayGatewayData["GAT_TYPE"];
|
||||
$gatewayBouX = $arrayGatewayData["BOU_X"];
|
||||
$gatewayBouY = $arrayGatewayData["BOU_Y"];
|
||||
$gatewayBouWidth = $arrayGatewayData["BOU_WIDTH"];
|
||||
$gatewayBouWidth = $arrayGatewayData["BOU_WIDTH"];
|
||||
$gatewayBouHeight = $arrayGatewayData["BOU_HEIGHT"];
|
||||
|
||||
$flowUid = $this->routeToBpmnFlow(
|
||||
@@ -470,7 +473,7 @@ class WorkflowBpmn extends Project\Workflow
|
||||
}
|
||||
}
|
||||
|
||||
public function addRoute($taskUid, $nextTaskUid, $type, $condition = "")
|
||||
public function addRoute($taskUid, $nextTaskUid, $type, $condition = "", $default = 0)
|
||||
{
|
||||
try {
|
||||
//Verify data
|
||||
@@ -483,9 +486,9 @@ class WorkflowBpmn extends Project\Workflow
|
||||
|
||||
//BPMN
|
||||
$arrayBpmnGatewayType = array(
|
||||
"EVALUATE" => "EXCLUSIVE",
|
||||
"SELECT" => "COMPLEX",
|
||||
"PARALLEL" => "PARALLEL",
|
||||
"EVALUATE" => "EXCLUSIVE",
|
||||
"SELECT" => "COMPLEX",
|
||||
"PARALLEL" => "PARALLEL",
|
||||
"PARALLEL-BY-EVALUATION" => "INCLUSIVE"
|
||||
);
|
||||
|
||||
@@ -494,7 +497,7 @@ class WorkflowBpmn extends Project\Workflow
|
||||
$activityUid = $arrayTaskData["TAS_UID"];
|
||||
$activityBouX = (int)($arrayTaskData["TAS_POSX"]);
|
||||
$activityBouY = (int)($arrayTaskData["TAS_POSY"]);
|
||||
$activityBouWidth = (int)($arrayTaskData["TAS_WIDTH"]);
|
||||
$activityBouWidth = (int)($arrayTaskData["TAS_WIDTH"]);
|
||||
$activityBouHeight = (int)($arrayTaskData["TAS_HEIGHT"]);
|
||||
|
||||
switch ($type) {
|
||||
@@ -522,11 +525,11 @@ class WorkflowBpmn extends Project\Workflow
|
||||
$arrayGatewayData = $result;
|
||||
}
|
||||
|
||||
$gatewayUid = $arrayGatewayData["GAT_UID"];
|
||||
$gatewayUid = $arrayGatewayData["GAT_UID"];
|
||||
$gatewayType = $arrayGatewayData["GAT_TYPE"];
|
||||
$gatewayBouX = $arrayGatewayData["BOU_X"];
|
||||
$gatewayBouY = $arrayGatewayData["BOU_Y"];
|
||||
$gatewayBouWidth = $arrayGatewayData["BOU_WIDTH"];
|
||||
$gatewayBouWidth = $arrayGatewayData["BOU_WIDTH"];
|
||||
$gatewayBouHeight = $arrayGatewayData["BOU_HEIGHT"];
|
||||
|
||||
if ($nextTaskUid != "-1") {
|
||||
@@ -610,12 +613,12 @@ class WorkflowBpmn extends Project\Workflow
|
||||
//BPMN
|
||||
//Artifact
|
||||
$arrayData = array(
|
||||
"ART_UID" => $swiUid,
|
||||
"ART_TYPE" => ($direction == "HORIZONTAL")? "HORIZONTAL_LINE" : "VERTICAL_LINE",
|
||||
"ART_NAME" => "",
|
||||
"BOU_X" => ($direction == "HORIZONTAL")? -6666 : $position,
|
||||
"BOU_Y" => ($direction == "HORIZONTAL")? $position : -6666,
|
||||
"BOU_WIDTH" => 0,
|
||||
"ART_UID" => $swiUid,
|
||||
"ART_TYPE" => ($direction == "HORIZONTAL") ? "HORIZONTAL_LINE" : "VERTICAL_LINE",
|
||||
"ART_NAME" => "",
|
||||
"BOU_X" => ($direction == "HORIZONTAL") ? -6666 : $position,
|
||||
"BOU_Y" => ($direction == "HORIZONTAL") ? $position : -6666,
|
||||
"BOU_WIDTH" => 0,
|
||||
"BOU_HEIGHT" => 0
|
||||
);
|
||||
|
||||
@@ -637,12 +640,12 @@ class WorkflowBpmn extends Project\Workflow
|
||||
//BPMN
|
||||
//Artifact
|
||||
$arrayData = array(
|
||||
"ART_UID" => $swiUid,
|
||||
"ART_TYPE" => "TEXT_ANNOTATION",
|
||||
"ART_NAME" => $text,
|
||||
"BOU_X" => $x,
|
||||
"BOU_Y" => $y,
|
||||
"BOU_WIDTH" => 100,
|
||||
"ART_UID" => $swiUid,
|
||||
"ART_TYPE" => "TEXT_ANNOTATION",
|
||||
"ART_NAME" => $text,
|
||||
"BOU_X" => $x,
|
||||
"BOU_Y" => $y,
|
||||
"BOU_WIDTH" => 100,
|
||||
"BOU_HEIGHT" => 30
|
||||
);
|
||||
|
||||
@@ -689,7 +692,7 @@ class WorkflowBpmn extends Project\Workflow
|
||||
$arrayWorkflowData["groupwfs"] = array();
|
||||
|
||||
//Create WorkflowBpmn
|
||||
$arrayUid = array();
|
||||
$arrayUid = array();
|
||||
$arrayUid2 = array();
|
||||
|
||||
//Process
|
||||
@@ -701,8 +704,8 @@ class WorkflowBpmn extends Project\Workflow
|
||||
);
|
||||
|
||||
$arrayProcessData["PRO_PARENT"] = $processUidBk;
|
||||
$arrayProcessData["PRO_TITLE"] = $arrayProcessData["PRO_TITLE"] . " - New version - " . date("M d, H:i:s");
|
||||
$arrayProcessData["PRO_CREATE_USER"] = ($userUid != "")? $userUid : "00000000000000000000000000000001";
|
||||
$arrayProcessData["PRO_TITLE"] = $arrayProcessData["PRO_TITLE"] . " - New version - " . date("M d, H:i:s");
|
||||
$arrayProcessData["PRO_CREATE_USER"] = ($userUid != "") ? $userUid : "00000000000000000000000000000001";
|
||||
|
||||
$this->create($arrayProcessData);
|
||||
|
||||
@@ -739,7 +742,7 @@ class WorkflowBpmn extends Project\Workflow
|
||||
$arrayRouteData = $value;
|
||||
|
||||
$arrayRouteData["TAS_UID"] = $arrayUid["task"][$arrayRouteData["TAS_UID"]];
|
||||
$arrayRouteData["ROU_NEXT_TASK"] = ($arrayRouteData["ROU_NEXT_TASK"] != "-1")? $arrayUid["task"][$arrayRouteData["ROU_NEXT_TASK"]] : $arrayRouteData["ROU_NEXT_TASK"];
|
||||
$arrayRouteData["ROU_NEXT_TASK"] = ($arrayRouteData["ROU_NEXT_TASK"] != "-1") ? $arrayUid["task"][$arrayRouteData["ROU_NEXT_TASK"]] : $arrayRouteData["ROU_NEXT_TASK"];
|
||||
|
||||
if ($arrayRouteData["ROU_TYPE"] != "SEC-JOIN") {
|
||||
//Add
|
||||
@@ -770,9 +773,9 @@ class WorkflowBpmn extends Project\Workflow
|
||||
$swiUid = $this->addText($arrayLaneData["SWI_TEXT"], $swiX, $swiY);
|
||||
break;
|
||||
case "LINE":
|
||||
$direction = (($swiX == 0)? "HORIZONTAL" : "VERTICAL");
|
||||
$direction = (($swiX == 0) ? "HORIZONTAL" : "VERTICAL");
|
||||
|
||||
$swiUid = $this->addLine(($direction == "HORIZONTAL")? $swiY : $swiX, $direction);
|
||||
$swiUid = $this->addLine(($direction == "HORIZONTAL") ? $swiY : $swiX, $direction);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -808,4 +811,3 @@ class WorkflowBpmn extends Project\Workflow
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -225,7 +225,7 @@ class Bpmn extends Handler
|
||||
$response = array();
|
||||
foreach ($data as $key => $val) {
|
||||
//Review if the type is "prj_uid"
|
||||
if (isset($val['prj_uid']) && !empty($val['prj_uid']) ) {
|
||||
if (isset($val['prj_uid']) && !empty($val['prj_uid'])) {
|
||||
//The project exist?
|
||||
if (!Bpmn::exists($val['prj_uid'])) {
|
||||
$response[] = array(
|
||||
@@ -514,7 +514,8 @@ class Bpmn extends Handler
|
||||
}
|
||||
|
||||
// setting defaults
|
||||
$data['PRO_UID'] = array_key_exists('PRO_UID', $data) ? $data['PRO_UID'] : Common::generateUID();;
|
||||
$data['PRO_UID'] = array_key_exists('PRO_UID', $data) ? $data['PRO_UID'] : Common::generateUID();
|
||||
;
|
||||
$data['PRO_NAME'] = array_key_exists('PRO_NAME', $data) ? $data['PRO_NAME'] : $this->diagram->getDiaName();
|
||||
|
||||
$this->process = new Process();
|
||||
@@ -696,7 +697,7 @@ class Bpmn extends Handler
|
||||
);
|
||||
}
|
||||
|
||||
public function updateEvent($evnUid, $data)
|
||||
public function updateEvent($evnUid, array $data)
|
||||
{
|
||||
/*if (array_key_exists("EVN_CANCEL_ACTIVITY", $data)) {
|
||||
$data["EVN_CANCEL_ACTIVITY"] = $data["EVN_CANCEL_ACTIVITY"] ? 1 : 0;
|
||||
@@ -913,15 +914,22 @@ class Bpmn extends Handler
|
||||
case "bpmnLaneset": $class = "BpmnLaneset"; break;
|
||||
case "bpmnLane": $class = "BpmnLane"; break;
|
||||
default:
|
||||
throw new \RuntimeException(sprintf("Invalid Object type, accepted types: [%s|%s|%s|%s], given %s.",
|
||||
"BpmnActivity", "BpmnBpmnGateway", "BpmnEvent", "bpmnArtifact", $data["FLO_ELEMENT_ORIGIN_TYPE"]
|
||||
throw new \RuntimeException(sprintf(
|
||||
"Invalid Object type, accepted types: [%s|%s|%s|%s], given %s.",
|
||||
"BpmnActivity",
|
||||
"BpmnBpmnGateway",
|
||||
"BpmnEvent",
|
||||
"bpmnArtifact",
|
||||
$data["FLO_ELEMENT_ORIGIN_TYPE"]
|
||||
));
|
||||
}
|
||||
|
||||
// Validate origin object exists
|
||||
if (! $class::exists($data["FLO_ELEMENT_ORIGIN"])) {
|
||||
throw new \RuntimeException(sprintf("Reference not found, the %s with UID: %s, does not exist!",
|
||||
ucfirst($data["FLO_ELEMENT_ORIGIN_TYPE"]), $data["FLO_ELEMENT_ORIGIN"]
|
||||
throw new \RuntimeException(sprintf(
|
||||
"Reference not found, the %s with UID: %s, does not exist!",
|
||||
ucfirst($data["FLO_ELEMENT_ORIGIN_TYPE"]),
|
||||
$data["FLO_ELEMENT_ORIGIN"]
|
||||
));
|
||||
}
|
||||
|
||||
@@ -935,15 +943,22 @@ class Bpmn extends Handler
|
||||
case "bpmnLaneset": $class = "BpmnLaneset"; break;
|
||||
case "bpmnLane": $class = "BpmnLane"; break;
|
||||
default:
|
||||
throw new \RuntimeException(sprintf("Invalid Object type, accepted types: [%s|%s|%s|%s], given %s.",
|
||||
"BpmnActivity", "BpmnBpmnGateway", "BpmnEvent", "bpmnArtifact", $data["FLO_ELEMENT_DEST_TYPE"]
|
||||
throw new \RuntimeException(sprintf(
|
||||
"Invalid Object type, accepted types: [%s|%s|%s|%s], given %s.",
|
||||
"BpmnActivity",
|
||||
"BpmnBpmnGateway",
|
||||
"BpmnEvent",
|
||||
"bpmnArtifact",
|
||||
$data["FLO_ELEMENT_DEST_TYPE"]
|
||||
));
|
||||
}
|
||||
|
||||
// Validate origin object exists
|
||||
if (! $class::exists($data["FLO_ELEMENT_DEST"])) {
|
||||
throw new \RuntimeException(sprintf("Reference not found, the %s with UID: %s, does not exist!",
|
||||
ucfirst($data["FLO_ELEMENT_DEST_TYPE"]), $data["FLO_ELEMENT_DEST"]
|
||||
throw new \RuntimeException(sprintf(
|
||||
"Reference not found, the %s with UID: %s, does not exist!",
|
||||
ucfirst($data["FLO_ELEMENT_DEST_TYPE"]),
|
||||
$data["FLO_ELEMENT_DEST"]
|
||||
));
|
||||
}
|
||||
|
||||
@@ -1536,12 +1551,11 @@ class Bpmn extends Handler
|
||||
}
|
||||
}
|
||||
|
||||
public function getFlowNextPosition ($sFloUid, $sFloType, $sFloElementOrigin)
|
||||
public function getFlowNextPosition($sFloUid, $sFloType, $sFloElementOrigin)
|
||||
{
|
||||
try {
|
||||
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->addSelectColumn( '(COUNT(*) + 1) AS FLOW_POS' );
|
||||
$oCriteria->addSelectColumn('(COUNT(*) + 1) AS FLOW_POS');
|
||||
$oCriteria->add(\BpmnFlowPeer::PRJ_UID, $this->getUid());
|
||||
$oCriteria->add(\BpmnFlowPeer::DIA_UID, $this->getDiagram("object")->getDiaUid());
|
||||
$oCriteria->add(\BpmnFlowPeer::FLO_UID, $sFloUid, \Criteria::NOT_EQUAL);
|
||||
@@ -1552,26 +1566,25 @@ class Bpmn extends Handler
|
||||
$oDataset->next();
|
||||
$aRow = $oDataset->getRow();
|
||||
return (int)($aRow["FLOW_POS"]);
|
||||
|
||||
} catch (Exception $oException) {
|
||||
throw $oException;
|
||||
}
|
||||
}
|
||||
|
||||
public function reOrderFlowPosition ($sFloOrigin, $iPosition)
|
||||
public function reOrderFlowPosition($sFloOrigin, $iPosition)
|
||||
{
|
||||
try {
|
||||
$con = \Propel::getConnection('workflow');
|
||||
$oCriteria = new Criteria( 'workflow' );
|
||||
$oCriteria->add( \BpmnFlowPeer::FLO_ELEMENT_ORIGIN, $sFloOrigin );
|
||||
$oCriteria->add( \BpmnFlowPeer::FLO_POSITION, $iPosition, '>' );
|
||||
$oDataset = \BpmnFlowPeer::doSelectRS( $oCriteria );
|
||||
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->add(\BpmnFlowPeer::FLO_ELEMENT_ORIGIN, $sFloOrigin);
|
||||
$oCriteria->add(\BpmnFlowPeer::FLO_POSITION, $iPosition, '>');
|
||||
$oDataset = \BpmnFlowPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
while ($oDataset->next()) {
|
||||
$aRow = $oDataset->getRow();
|
||||
$newPosition = ((int)$aRow['FLO_POSITION'])-1;
|
||||
$oCriteriaTemp = new Criteria( 'workflow' );
|
||||
$oCriteriaTemp->add( \BpmnFlowPeer::FLO_UID, $aRow['FLO_UID'] );
|
||||
$oCriteriaTemp = new Criteria('workflow');
|
||||
$oCriteriaTemp->add(\BpmnFlowPeer::FLO_UID, $aRow['FLO_UID']);
|
||||
$oCriteria2 = new Criteria('workflow');
|
||||
$oCriteria2->add(\BpmnFlowPeer::FLO_POSITION, $newPosition);
|
||||
BasePeer::doUpdate($oCriteriaTemp, $oCriteria2, $con);
|
||||
@@ -1680,8 +1693,7 @@ class Bpmn extends Handler
|
||||
$level,
|
||||
$message,
|
||||
$context = array()
|
||||
)
|
||||
{
|
||||
) {
|
||||
try {
|
||||
Bootstrap::registerMonolog($channel, $level, $message, $context, $context['workspace'], 'processmaker.log');
|
||||
} catch (Exception $e) {
|
||||
@@ -1689,4 +1701,3 @@ class Bpmn extends Handler
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ use ProcessMaker\Util\Common;
|
||||
use ProcessMaker\Exception;
|
||||
use ProcessMaker\Util;
|
||||
use ReportTables;
|
||||
|
||||
/**
|
||||
* Class Workflow
|
||||
*
|
||||
@@ -68,7 +69,7 @@ class Workflow extends Handler
|
||||
|
||||
$testTitle = htmlspecialchars($data['PRO_TITLE']);
|
||||
|
||||
if($testTitle != $data['PRO_TITLE']) {
|
||||
if ($testTitle != $data['PRO_TITLE']) {
|
||||
$data['PRO_TITLE'] = $testTitle;
|
||||
}
|
||||
|
||||
@@ -174,7 +175,7 @@ class Workflow extends Handler
|
||||
* Projects elements handlers
|
||||
*/
|
||||
|
||||
public function addTask($taskData)
|
||||
public function addTask(array $taskData)
|
||||
{
|
||||
// Setting defaults
|
||||
$taskData['TAS_UID'] = array_key_exists('TAS_UID', $taskData) ? $taskData['TAS_UID'] : Common::generateUID();
|
||||
@@ -190,7 +191,6 @@ class Workflow extends Handler
|
||||
if ($task->getTasType() == "SUBPROCESS") {
|
||||
$this->addSubProcess($this->proUid, $tasUid);
|
||||
}
|
||||
|
||||
} catch (\Exception $e) {
|
||||
self::log("Exception: ", $e->getMessage(), "Trace: ", $e->getTraceAsString());
|
||||
throw $e;
|
||||
@@ -242,7 +242,6 @@ class Workflow extends Handler
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (\Exception $e) {
|
||||
self::log("Exception: ", $e->getMessage(), "Trace: ", $e->getTraceAsString());
|
||||
throw $e;
|
||||
@@ -254,7 +253,7 @@ class Workflow extends Handler
|
||||
try {
|
||||
$task = new ClassesTask();
|
||||
$taskData = $task->load($tasUid);
|
||||
} catch (\Exception $e){
|
||||
} catch (\Exception $e) {
|
||||
$taskData = null;
|
||||
}
|
||||
|
||||
@@ -320,7 +319,6 @@ class Workflow extends Handler
|
||||
|
||||
public function updateSubProcess()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -398,8 +396,8 @@ class Workflow extends Handler
|
||||
}
|
||||
|
||||
//if ($type == 'SEQUENTIAL' || $type == 'SEC-JOIN' || $type == 'DISCRIMINATOR') {
|
||||
//$oTasks = new Tasks();
|
||||
//$oTasks->deleteAllRoutesOfTask($this->proUid, $fromTasUid);
|
||||
//$oTasks = new Tasks();
|
||||
//$oTasks->deleteAllRoutesOfTask($this->proUid, $fromTasUid);
|
||||
//}
|
||||
|
||||
$route = \Route::findOneBy([
|
||||
@@ -547,7 +545,7 @@ class Workflow extends Handler
|
||||
$aFields["ROU_TYPE"] = $sType;
|
||||
$aFields["ROU_DEFAULT"] = $default;
|
||||
|
||||
if(! empty($condition)) {
|
||||
if (! empty($condition)) {
|
||||
$aFields['ROU_CONDITION'] = $condition;
|
||||
}
|
||||
|
||||
@@ -894,7 +892,7 @@ class Workflow extends Handler
|
||||
|
||||
while ($rsCriteria->next()) {
|
||||
$row = $rsCriteria->getRow();
|
||||
$emailEvent->delete($sProcessUID,$row["EMAIL_EVENT_UID"],false);
|
||||
$emailEvent->delete($sProcessUID, $row["EMAIL_EVENT_UID"], false);
|
||||
}
|
||||
|
||||
if (!$onlyDiagram) {
|
||||
@@ -945,7 +943,7 @@ class Workflow extends Handler
|
||||
'PRO_UID'=>$this->proUid,
|
||||
'TAS_UID'=>'',
|
||||
'SCH_TIME_NEXT_RUN'=>date('Y-m-d H:i:s'),
|
||||
'SCH_LAST_RUN_TIME'=>NULL,
|
||||
'SCH_LAST_RUN_TIME'=>null,
|
||||
'SCH_STATE'=>'',
|
||||
'SCH_LAST_STATE'=>'',
|
||||
'USR_UID'=>'',
|
||||
@@ -953,7 +951,7 @@ class Workflow extends Handler
|
||||
'SCH_START_TIME'=>date('Y-m-d H:i:s'),
|
||||
'SCH_START_DATE'=>date('Y-m-d H:i:s'),
|
||||
'SCH_DAYS_PERFORM_TASK'=>'',
|
||||
'SCH_EVERY_DAYS'=>NULL,
|
||||
'SCH_EVERY_DAYS'=>null,
|
||||
'SCH_WEEK_DAYS'=>'',
|
||||
'SCH_START_DAY'=>'',
|
||||
'SCH_START_DAY_OPT_1'=>'',
|
||||
@@ -962,7 +960,7 @@ class Workflow extends Handler
|
||||
'SCH_END_DATE'=>date('Y-m-d H:i:s'),
|
||||
'SCH_REPEAT_EVERY'=>'',
|
||||
'SCH_REPEAT_STOP_IF_RUNNING'=>'',
|
||||
'CASE_SH_PLUGIN_UID'=>NULL,
|
||||
'CASE_SH_PLUGIN_UID'=>null,
|
||||
'SCH_DEL_USER_PASS'=>'',
|
||||
'SCH_UID'=>$schUid,
|
||||
'SCH_REPEAT_UNTIL'=>''
|
||||
@@ -1047,7 +1045,6 @@ class Workflow extends Handler
|
||||
self::log("Exception: ", $e->getMessage(), "Trace: ", $e->getTraceAsString());
|
||||
throw $e;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function addLine($position, $direction = "HORIZONTAL")
|
||||
@@ -1323,8 +1320,8 @@ class Workflow extends Handler
|
||||
isset($arrayWorkflowData["uid"][$value["CTO_TYPE_OBJ"]]) &&
|
||||
isset($arrayWorkflowData["uid"][$value["CTO_TYPE_OBJ"]][$value["CTO_UID_OBJ"]])) {
|
||||
$arrayWorkflowData["caseTrackerObject"][$key]["CTO_UID_OBJ"] = $arrayWorkflowData["uid"][$value["CTO_TYPE_OBJ"]][$value["CTO_UID_OBJ"]];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Synchronize variables with process variables.
|
||||
foreach ($arrayWorkflowData["processVariables"] as $key => $value) {
|
||||
@@ -1378,4 +1375,3 @@ class Workflow extends Handler
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
73
workflow/engine/src/ProcessMaker/Services/Api/FileLogs.php
Normal file
73
workflow/engine/src/ProcessMaker/Services/Api/FileLogs.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\Services\Api;
|
||||
|
||||
use Exception;
|
||||
use G;
|
||||
use ProcessMaker\BusinessModel\Files\FilesLogs;
|
||||
use \ProcessMaker\Services\Api;
|
||||
use \Luracast\Restler\RestException;
|
||||
|
||||
/**
|
||||
* Log Files Api Controller
|
||||
*
|
||||
* @protected
|
||||
*/
|
||||
class FileLogs extends Api
|
||||
{
|
||||
/**
|
||||
* Get the list of the log files
|
||||
*
|
||||
* @url GET /list
|
||||
*
|
||||
* @param int $start {@from path}
|
||||
* @param int $limit {@from path}
|
||||
* @param string $sort {@from path}
|
||||
* @param string $dir {@from path}
|
||||
* @param string $filter {@from path}
|
||||
*
|
||||
* @return array
|
||||
* @throws RestException
|
||||
*
|
||||
* @access protected
|
||||
* @class AccessControl {@permission PM_SETUP_LOG_FILES}
|
||||
*/
|
||||
public function doGetListFileLogs(
|
||||
$start = 0,
|
||||
$limit = 0,
|
||||
$sort = 'fileCreated',
|
||||
$dir = 'DESC',
|
||||
$filter = ''
|
||||
)
|
||||
{
|
||||
try {
|
||||
$file = new FilesLogs();
|
||||
return $file->getAllFiles($filter, $sort, $start, $limit, $dir);
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Download file.
|
||||
*
|
||||
* @url POST /download
|
||||
*
|
||||
* @param array $request_data name of the files
|
||||
*
|
||||
* @throws RestException
|
||||
*
|
||||
* @access protected
|
||||
* @class AccessControl {@permission PM_SETUP_LOG_FILES}
|
||||
*/
|
||||
public function doPostDownload($request_data)
|
||||
{
|
||||
try {
|
||||
$file = new FilesLogs();
|
||||
$file->download(G::json_decode($request_data['files']));
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
<?php
|
||||
namespace ProcessMaker\Services\Api\Project;
|
||||
|
||||
use \ProcessMaker\Services\Api;
|
||||
use \Luracast\Restler\RestException;
|
||||
use Exception;
|
||||
use Luracast\Restler\RestException;
|
||||
use ProcessMaker\BusinessModel\ProcessPermissions as BmProcessPermissions;
|
||||
use ProcessMaker\Services\Api;
|
||||
|
||||
/**
|
||||
* Project\ProcessPermissions Api Controller
|
||||
@@ -17,20 +19,18 @@ class ProcessPermissions extends Api
|
||||
/**
|
||||
* @param string $prj_uid {@min 1} {@max 32}
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*
|
||||
* @return array
|
||||
* @throws RestException
|
||||
*
|
||||
* @url GET /:prj_uid/process-permissions
|
||||
*/
|
||||
public function doGetProcessPermissions($prj_uid)
|
||||
{
|
||||
try {
|
||||
$processPermissions = new \ProcessMaker\BusinessModel\ProcessPermissions();
|
||||
$processPermissions = new BmProcessPermissions();
|
||||
$response = $processPermissions->getProcessPermissions($prj_uid);
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
@@ -39,20 +39,18 @@ class ProcessPermissions extends Api
|
||||
* @param string $prj_uid {@min 1} {@max 32}
|
||||
* @param string $ob_uid {@min 1} {@max 32}
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*
|
||||
* @return array
|
||||
* @throws RestException
|
||||
*
|
||||
* @url GET /:prj_uid/process-permission/:ob_uid
|
||||
*/
|
||||
public function doGetProcessPermission($prj_uid, $ob_uid)
|
||||
{
|
||||
try {
|
||||
$processPermissions = new \ProcessMaker\BusinessModel\ProcessPermissions();
|
||||
$processPermissions = new BmProcessPermissions();
|
||||
$response = $processPermissions->getProcessPermissions($prj_uid, $ob_uid);
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
@@ -75,11 +73,11 @@ class ProcessPermissions extends Api
|
||||
public function doPostProcessPermission($prj_uid, $request_data)
|
||||
{
|
||||
try {
|
||||
$hiddenFields = array('task_target', 'group_user', 'task_source',
|
||||
$hiddenFields = ['task_target', 'group_user', 'task_source',
|
||||
'object_type', 'object', 'participated', 'action'
|
||||
);
|
||||
];
|
||||
$request_data['pro_uid'] = $prj_uid;
|
||||
$processPermissions = new \ProcessMaker\BusinessModel\ProcessPermissions();
|
||||
$processPermissions = new BmProcessPermissions();
|
||||
$response = $processPermissions->saveProcessPermission($request_data);
|
||||
foreach ($response as $key => $eventData) {
|
||||
if (in_array($key, $hiddenFields)) {
|
||||
@@ -87,13 +85,13 @@ class ProcessPermissions extends Api
|
||||
}
|
||||
}
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update process permisson.
|
||||
* Update process permission.
|
||||
*
|
||||
* @url PUT /:prj_uid/process-permission/:ob_uid
|
||||
*
|
||||
@@ -104,7 +102,7 @@ class ProcessPermissions extends Api
|
||||
* @param string $op_user_relation {@from body} {@choice 1,2}
|
||||
* @param string $op_case_status {@from body} {@choice ALL,DRAFT,TO_DO,PAUSED,COMPLETED}
|
||||
* @param string $op_participate {@from body} {@choice 0,1}
|
||||
* @param string $op_obj_type {@from body} {@choice ANY,DYNAFORM,ATTACHMENT,INPUT,OUTPUT,CASES_NOTES,MSGS_HISTORY,SUMMARY_FORM}
|
||||
* @param string $op_obj_type {@from body} {@choice ANY,DYNAFORM,ATTACHMENT,INPUT,OUTPUT,CASES_NOTES,MSGS_HISTORY,SUMMARY_FORM,REASSIGN_MY_CASES}
|
||||
* @param string $op_action {@from body} {@choice VIEW,BLOCK,DELETE,RESEND}
|
||||
* @param string $tas_uid {@from body}
|
||||
* @param string $op_task_source {@from body}
|
||||
@@ -124,10 +122,10 @@ class ProcessPermissions extends Api
|
||||
$request_data,
|
||||
$usr_uid,
|
||||
$op_user_relation,
|
||||
$op_case_status,
|
||||
$op_participate,
|
||||
$op_case_status = 'ALL',
|
||||
$op_participate = '0',
|
||||
$op_obj_type,
|
||||
$op_action,
|
||||
$op_action = 'VIEW',
|
||||
$tas_uid = '',
|
||||
$op_task_source = '',
|
||||
$dynaforms = '',
|
||||
@@ -136,10 +134,11 @@ class ProcessPermissions extends Api
|
||||
) {
|
||||
try {
|
||||
$request_data['pro_uid'] = $prj_uid;
|
||||
$processPermissions = new \ProcessMaker\BusinessModel\ProcessPermissions();
|
||||
$request_data['op_action'] = $op_action;
|
||||
$processPermissions = new BmProcessPermissions();
|
||||
$response = $processPermissions->saveProcessPermission($request_data, $ob_uid);
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
@@ -153,14 +152,14 @@ class ProcessPermissions extends Api
|
||||
* @param string $ob_uid {@min 1} {@max 32}
|
||||
*
|
||||
* @return void
|
||||
* @throws RestException
|
||||
*/
|
||||
public function doDeleteProcessPermission($prj_uid, $ob_uid)
|
||||
{
|
||||
try {
|
||||
$processPermissions = new \ProcessMaker\BusinessModel\ProcessPermissions();
|
||||
$response = $processPermissions->deleteProcessPermission($ob_uid, $prj_uid);
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
$processPermissions = new BmProcessPermissions();
|
||||
$processPermissions->deleteProcessPermission($ob_uid, $prj_uid);
|
||||
} catch (Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,27 +2,29 @@
|
||||
|
||||
namespace ProcessMaker\Services\OAuth2;
|
||||
|
||||
use PDO;
|
||||
|
||||
/**
|
||||
* Simple PmPDO storage for all storage types
|
||||
* based on \OAuth2\Storage\Pdo
|
||||
*
|
||||
* @author Erik Amaru Ortiz <aortiz.erik at gmail dot com>
|
||||
*/
|
||||
class PmPdo implements \OAuth2\Storage\AuthorizationCodeInterface,
|
||||
class PmPdo implements
|
||||
\OAuth2\Storage\AuthorizationCodeInterface,
|
||||
\OAuth2\Storage\AccessTokenInterface,
|
||||
\OAuth2\Storage\ClientCredentialsInterface,
|
||||
\OAuth2\Storage\UserCredentialsInterface,
|
||||
\OAuth2\Storage\RefreshTokenInterface,
|
||||
\OAuth2\Storage\JwtBearerInterface
|
||||
{
|
||||
|
||||
protected $db;
|
||||
protected $dbRBAC;
|
||||
protected $config;
|
||||
|
||||
public function __construct($connection, $config = array(), $connectionRBAC = null)
|
||||
{
|
||||
if (!$connection instanceof \PDO) {
|
||||
if (!$connection instanceof PDO) {
|
||||
if (!is_array($connection)) {
|
||||
throw new \InvalidArgumentException('First argument to OAuth2\Storage\Pdo must be an instance of PDO or a configuration array');
|
||||
}
|
||||
@@ -34,12 +36,12 @@ class PmPdo implements \OAuth2\Storage\AuthorizationCodeInterface,
|
||||
'username' => null,
|
||||
'password' => null,
|
||||
), $connection);
|
||||
$connection = new \PDO($connection['dsn'], $connection['username'], $connection['password']);
|
||||
$connection = new PDO($connection['dsn'], $connection['username'], $connection['password']);
|
||||
}
|
||||
$this->db = $connection;
|
||||
|
||||
// it's for Pm < 3
|
||||
if (!is_null($connectionRBAC) &&(!$connectionRBAC instanceof \PDO)) {
|
||||
if (!is_null($connectionRBAC) &&(!$connectionRBAC instanceof PDO)) {
|
||||
if (!is_array($connectionRBAC)) {
|
||||
throw new \InvalidArgumentException('First argument to OAuth2\Storage\Pdo must be an instance of PDO or a configuration array');
|
||||
}
|
||||
@@ -51,12 +53,12 @@ class PmPdo implements \OAuth2\Storage\AuthorizationCodeInterface,
|
||||
'username' => null,
|
||||
'password' => null,
|
||||
), $connectionRBAC);
|
||||
$connectionRBAC = new \PDO($connectionRBAC['dsn'], $connectionRBAC['username'], $connectionRBAC['password']);
|
||||
$connectionRBAC = new PDO($connectionRBAC['dsn'], $connectionRBAC['username'], $connectionRBAC['password']);
|
||||
}
|
||||
$this->dbRBAC = $connectionRBAC;
|
||||
|
||||
// debugging
|
||||
$connection->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
|
||||
$connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
|
||||
$this->config = array_merge(array(
|
||||
'client_table' => 'OAUTH_CLIENTS',
|
||||
@@ -173,7 +175,7 @@ class PmPdo implements \OAuth2\Storage\AuthorizationCodeInterface,
|
||||
{
|
||||
$access_token = new \OauthAccessTokens();
|
||||
$access_token->load($token);
|
||||
$stmt = $this->db->prepare(sprintf('UPDATE %s SET EXPIRES=%s WHERE ACCESS_TOKEN=:token', $this->config['access_token_table'], "'".Date('Y-m-d H:i:s',strtotime("-1 minute"))."'"));
|
||||
$stmt = $this->db->prepare(sprintf('UPDATE %s SET EXPIRES=%s WHERE ACCESS_TOKEN=:token', $this->config['access_token_table'], "'".Date('Y-m-d H:i:s', strtotime("-1 minute"))."'"));
|
||||
return $stmt->execute(compact('token'));
|
||||
}
|
||||
|
||||
@@ -192,12 +194,12 @@ class PmPdo implements \OAuth2\Storage\AuthorizationCodeInterface,
|
||||
{
|
||||
$RBAC = \RBAC::getSingleton();
|
||||
$RBAC->initRBAC();
|
||||
$uid = $RBAC->VerifyLogin($username , $password);
|
||||
if($uid < 0){
|
||||
return false;
|
||||
$uid = $RBAC->VerifyLogin($username, $password);
|
||||
if ($uid < 0) {
|
||||
return false;
|
||||
}
|
||||
if($uid != ''){
|
||||
return true;
|
||||
if ($uid != '') {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -295,6 +297,4 @@ class PmPdo implements \OAuth2\Storage\AuthorizationCodeInterface,
|
||||
|
||||
return array_merge($a, array_change_key_case($a, $case));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -121,8 +121,11 @@ debug = 1
|
||||
authentication = "ProcessMaker\Services\Api\Google\Authentication"
|
||||
|
||||
[alias: gmailIntegration]
|
||||
gmailIntegration = "ProcessMaker\Services\Api\GmailIntegration"
|
||||
token = "ProcessMaker\Services\Api\GmailToken"
|
||||
gmailIntegration = "ProcessMaker\Services\Api\GmailIntegration"
|
||||
token = "ProcessMaker\Services\Api\GmailToken"
|
||||
|
||||
[alias: reportingIndicators]
|
||||
reportingIndicators = "ProcessMaker\Services\Api\ReportingIndicators"
|
||||
reportingIndicators = "ProcessMaker\Services\Api\ReportingIndicators"
|
||||
|
||||
[alias: logs]
|
||||
log = "ProcessMaker\Services\Api\FileLogs"
|
||||
Reference in New Issue
Block a user