PMCORE-561

This commit is contained in:
Andrea Adamczyk
2020-09-08 16:20:28 -04:00
parent d60dbe1e37
commit fe49792fc0
11 changed files with 355 additions and 13 deletions

View File

@@ -323,6 +323,9 @@ class Process extends BaseProcess
if (isset($aData['PRO_DESCRIPTION'])) {
$oPro->setProDescriptionContent($aData['PRO_DESCRIPTION']);
}
if (isset($aData['PRO_PROCESS_OWNER'])) {
$oPro->setProCreateUser($aData['PRO_PROCESS_OWNER']);
}
$res = $oPro->save();
$con->commit();

View File

@@ -19253,6 +19253,12 @@ msgstr "Do you want to delete this user ?"
msgid "The user can not be deleted while assigned as a supervisor. Do you want to delete it anyway?"
msgstr "The user can not be deleted while assigned as a supervisor. Do you want to delete it anyway?"
# TRANSLATION
# LABEL/ID_MSG_CONFIRM_DELETE_USER_PRIVATE_PROCESSES
#: LABEL/ID_MSG_CONFIRM_DELETE_USER_PRIVATE_PROCESSES
msgid "This user has private processes, if you continue all the user's private processes will become public processes. Do you want to continue?"
msgstr "This user has private processes, if you continue all the user's private processes will become public processes. Do you want to continue?"
# TRANSLATION
# LABEL/ID_MSG_CONFIRM_DELETE_WEBBOT
#: LABEL/ID_MSG_CONFIRM_DELETE_WEBBOT

View File

@@ -60092,6 +60092,7 @@ INSERT INTO TRANSLATION (TRN_CATEGORY,TRN_ID,TRN_LANG,TRN_VALUE,TRN_UPDATE_DATE
( 'LABEL','ID_MSG_CONFIRM_DELETE_TRIGGER','en','Do you want to delete this trigger?','2014-01-15') ,
( 'LABEL','ID_MSG_CONFIRM_DELETE_USER','en','Do you want to delete this user ?','2014-01-15') ,
( 'LABEL','ID_MSG_CONFIRM_DELETE_USER_ASSINGED_SUPERVISOR','en','The user can not be deleted while assigned as a supervisor. Do you want to delete it anyway?','2014-10-21') ,
( 'LABEL','ID_MSG_CONFIRM_DELETE_USER_PRIVATE_PROCESSES','en',"This user has private processes, if you continue all the user's private processes will become public processes. Do you want to continue?",'2020-09-02') ,
( 'LABEL','ID_MSG_CONFIRM_DELETE_WEBBOT','en','Are you sure you want to delete this webbot?','2014-01-15') ,
( 'LABEL','ID_MSG_CONFIRM_REMOVE_LANGUAGE','en','Are you sure you want to remove this language?','2014-01-15') ,
( 'LABEL','ID_MSG_CONFIRM_REMOVE_TRIGGER','en','Are you sure you want to remove this trigger?','2014-01-15') ,

View File

@@ -1,5 +1,7 @@
<?php
use ProcessMaker\Model\Process;
try {
global $RBAC;
switch ($RBAC->userCanAccess('PM_LOGIN')) {
@@ -107,7 +109,15 @@ try {
$response .= '}';
echo $response;
break;
case 'privateProcesses':
$usrUid = $_POST['USR_UID'];
//Check if the user has private processes
$r = Process::getProcessPrivateListByUser($usrUid);
$response = json_encode(['success'=>true, 'publicProcesses'=>$r]);
echo $response;
break;
case 'deleteUser':
Process::convertPrivateProcessesToPublic(json_decode($_POST['private_processes']));
$usrUid = $_POST['USR_UID'];
//Check if the user was defined in a process permissions
$oObjectPermission = new ObjectPermission();

View File

@@ -3,6 +3,8 @@
namespace ProcessMaker\Model;
use Illuminate\Database\Eloquent\Model;
use RbacUsers;
use RBAC;
/**
* Class Process
@@ -57,4 +59,35 @@ class Process extends Model
return ($query->get()->values()->toArray());
}
/**
* Obtains the list of private processes assigned to the user
*
* @param string $userUid
* @return array
*/
public static function getProcessPrivateListByUser($userUid)
{
$query = Process::query()
->select()
->where('PRO_CREATE_USER', $userUid)
->where('PRO_TYPE_PROCESS', 'PRIVATE');
return ($query->get()->values()->toArray());
}
/**
* Converts the private processes to public
*
* @param array $privateProcesses
* @return void
*/
public static function convertPrivateProcessesToPublic($privateProcesses)
{
$admin = RBAC::ADMIN_USER_UID;
$processes = array_column($privateProcesses, 'PRO_ID');
Process::whereIn('PRO_ID', $processes)
->update(['PRO_TYPE_PROCESS' => 'PUBLIC', 'PRO_CREATE_USER' => $admin]);
}
}

View File

@@ -1,19 +1,19 @@
<?php
namespace ProcessMaker\Services\Api;
use Exception;
use Luracast\Restler\RestException;
use ProcessMaker\Project\Bpmn;
use ProcessMaker\Services\Api;
use \ProcessMaker\Project\Adapter;
use \ProcessMaker\Util;
use \ProcessMaker\Util\DateTime;
use \ProcessMaker\BusinessModel\Validator;
use \ProcessMaker\BusinessModel\Migrator\GranularExporter;
use \ProcessMaker\BusinessModel\Migrator\ExportObjects;
use \ProcessMaker\Util\IO\HttpStream;
use \ProcessMaker\Util\Common;
use \ProcessMaker\BusinessModel\Validator;
use \ProcessMaker\Project\Adapter;
use ProcessMaker\Project\Adapter\BpmnWorkflow;
use Exception;
use ProcessMaker\Project\Bpmn;
use ProcessMaker\Services\Api;
use \ProcessMaker\Util\Common;
use \ProcessMaker\Util\DateTime;
use \ProcessMaker\Util\IO\HttpStream;
use RbacUsers;
/**
* @package Services\Api\ProcessMaker
@@ -296,6 +296,14 @@ class Project extends Api
$response = $process->getProcess($prj_uid);
$rbacUser = new RbacUsers();
$res = $rbacUser->load($response['pro_create_user']);
if (!empty($res)) {
$response['pro_create_username'] = $res['USR_USERNAME'];
$response['pro_create_firstname'] = $res['USR_FIRSTNAME'];
$response['pro_create_lastname'] = $res['USR_LASTNAME'];
}
return DateTime::convertUtcToIso8601($response, $this->arrayFieldIso8601);
} catch (Exception $e) {

View File

@@ -525,7 +525,7 @@ DeleteUserAction = function(){
if (response.hashistory){
Ext.Msg.confirm(_('ID_CONFIRM'), _('ID_USERS_DELETE_WITH_HISTORY'),
function(btn){
if (btn=='yes') DeleteUser(uid.data.USR_UID);
if (btn=='yes') hasPrivateProcesses(uid.data.USR_UID);
}
);
}else{
@@ -533,7 +533,7 @@ DeleteUserAction = function(){
Ext.Msg.confirm(_('ID_CONFIRM'), msgConfirm,
function(btn){
if (btn=='yes') DeleteUser(uid.data.USR_UID);
if (btn=='yes') hasPrivateProcesses(uid.data.USR_UID);
}
);
}
@@ -631,10 +631,10 @@ DoSearch = function(){
};
//Delete User Function
DeleteUser = function(uid){
DeleteUser = function(uid, privateProcesses){
Ext.Ajax.request({
url: 'users_Ajax',
params: {'function': 'deleteUser', USR_UID: uid},
params: {'function': 'deleteUser', USR_UID: uid, private_processes: privateProcesses},
success: function(res, opt){
var response = Ext.util.JSON.decode(res.responseText);
if (response.status === 'ERROR') {
@@ -648,6 +648,31 @@ DeleteUser = function(uid){
});
};
/**
* Show a message in case the user to be deleted has private processes
*
* @param {string} uid
*/
hasPrivateProcesses = function (uid) {
Ext.Ajax.request({
url: 'users_Ajax',
params: { 'function': 'privateProcesses', USR_UID: uid },
success: function (res, opt) {
var response = Ext.util.JSON.decode(res.responseText);
if (!(response.publicProcesses === undefined || response.publicProcesses.length == 0)) {
Ext.Msg.confirm(_('ID_CONFIRM'), _("ID_MSG_CONFIRM_DELETE_USER_PRIVATE_PROCESSES"),
function(btn){
if (btn == 'yes') DeleteUser(uid, Ext.util.JSON.encode(response.publicProcesses));
}
);
} else {
DeleteUser(uid, Ext.util.JSON.encode(response.publicProcesses));
}
},
failure: DoNothing
});
};
//Update Page Size Configuration
UpdatePageConfig = function(pageSize){
Ext.Ajax.request({