Merged in develop (pull request #8497)

Updating feature branch with last changes in release/3.7.6 merged to develop
This commit is contained in:
Julio Cesar Laura Avendaño
2022-07-12 14:35:57 +00:00
12 changed files with 136 additions and 37 deletions

View File

@@ -6137,6 +6137,12 @@ msgstr "Delegation Date"
msgid "Delete"
msgstr "Delete"
# TRANSLATION
# LABEL/ID_DELETE_EMAIL_SETTINGS
#: LABEL/ID_DELETE_EMAIL_SETTINGS
msgid "Delete Email Settings"
msgstr "Delete Email Settings"
# TRANSLATION
# LABEL/ID_DELETED
#: LABEL/ID_DELETED

View File

@@ -57850,6 +57850,7 @@ INSERT INTO TRANSLATION (TRN_CATEGORY,TRN_ID,TRN_LANG,TRN_VALUE,TRN_UPDATE_DATE
( 'LABEL','ID_DELEGATE_USER','en','Delegated User','2014-01-15') ,
( 'LABEL','ID_DELEGATION_DATE','en','Delegation Date','2014-01-15') ,
( 'LABEL','ID_DELETE','en','Delete','2014-01-15') ,
( 'LABEL','ID_DELETE_EMAIL_SETTINGS','en','Delete Email Settings','2022-06-29') ,
( 'LABEL','ID_DELETED','en','Deleted','2014-01-15') ,
( 'LABEL','ID_DELETED_SUCCESSFULLY','en','Deleted Successfully','2014-01-15') ,
( 'LABEL','ID_DELETE_ACTION','en','Delete case','2020-01-15') ,

View File

@@ -1,5 +1,6 @@
<?php
use ProcessMaker\BusinessModel\EmailServer;
use ProcessMaker\Core\System;
use ProcessMaker\GmailOAuth\GmailOAuth;
use ProcessMaker\Office365OAuth\Office365OAuth;
@@ -11,7 +12,6 @@ $RBAC->allows(basename(__FILE__), $option);
switch ($option) {
case "INS":
$arrayData = [];
$server = "";
$port = "";
$incomingServer = "";
@@ -19,7 +19,6 @@ switch ($option) {
$reqAuthentication = 0;
$password = "";
$smtpSecure = "";
$cboEmailEngine = $_POST["cboEmailEngine"];
$accountFrom = (isset($_POST["accountFrom"])) ? $_POST["accountFrom"] : "";
$fromName = $_POST["fromName"];
@@ -45,7 +44,7 @@ switch ($option) {
}
try {
$arrayData = array(
$arrayData = [
"MESS_ENGINE" => $cboEmailEngine,
"MESS_SERVER" => $server,
"MESS_PORT" => $port,
@@ -60,11 +59,22 @@ switch ($option) {
"MESS_TRY_SEND_INMEDIATLY" => $sendTestMail,
"MAIL_TO" => $mailTo,
"MESS_DEFAULT" => $emailServerDefault
);
$emailSever = new \ProcessMaker\BusinessModel\EmailServer();
];
$emailSever = new EmailServer();
$arrayEmailServerData = $emailSever->create($arrayData);
// Register the log
G::auditLog(
"CreateEmailSettings",
"SetDefaultConfiguration-> " . $emailServerDefault .
", EmailEngine-> " . $cboEmailEngine .
", Server-> " . $server .
", Port-> " . $port .
", RequireAuthentication-> " . $reqAuthentication .
", FromMail-> " . $fromMail .
", FromName-> " . $fromName .
", UseSecureConnection-> " . $smtpSecure
);
$response["status"] = "OK";
$response["data"] = $arrayEmailServerData;
@@ -75,9 +85,7 @@ switch ($option) {
break;
case "UPD":
$arrayData = [];
$emailServerUid = $_POST["emailServerUid"];
$server = "";
$port = "";
$incomingServer = "";
@@ -85,7 +93,6 @@ switch ($option) {
$reqAuthentication = 0;
$password = "";
$smtpSecure = "";
$cboEmailEngine = $_POST["cboEmailEngine"];
$accountFrom = (isset($_POST["accountFrom"])) ? $_POST["accountFrom"] : "";
$fromName = $_POST["fromName"];
@@ -111,7 +118,7 @@ switch ($option) {
}
try {
$arrayData = array(
$arrayData = [
"MESS_ENGINE" => $cboEmailEngine,
"MESS_SERVER" => $server,
"MESS_PORT" => $port,
@@ -126,11 +133,23 @@ switch ($option) {
"MESS_TRY_SEND_INMEDIATLY" => $sendTestMail,
"MAIL_TO" => $mailTo,
"MESS_DEFAULT" => $emailServerDefault
);
$emailSever = new \ProcessMaker\BusinessModel\EmailServer();
];
$emailSever = new EmailServer();
$arrayEmailServerData = $emailSever->update($emailServerUid, $arrayData);
// Register the log
G::auditLog(
"UpdateEmailSettings",
"EmailServer-> " . $emailServerUid .
", SetDefaultConfiguration-> " . $emailServerDefault .
", EmailEngine-> " . $cboEmailEngine .
", Server-> " . $server .
", Port-> " . $port .
", RequireAuthentication-> " . $reqAuthentication .
", FromMail-> " . $fromMail .
", FromName-> " . $fromName .
", UseSecureConnection-> " . $smtpSecure
);
$response["status"] = "OK";
$response["data"] = $arrayEmailServerData;
@@ -144,9 +163,13 @@ switch ($option) {
$emailServerUid = $_POST["emailServerUid"];
try {
$emailSever = new \ProcessMaker\BusinessModel\EmailServer();
$emailSever = new EmailServer();
$result = $emailSever->delete($emailServerUid);
// Register the log
G::auditLog(
"DeleteEmailSettings",
"EmailServer-> " . $emailServerUid
);
$response["status"] = "OK";
} catch (Exception $e) {
@@ -157,16 +180,14 @@ switch ($option) {
case "LST":
$pageSize = $_POST["pageSize"];
$search = $_POST["search"];
$sortField = (isset($_POST["sort"])) ? $_POST["sort"] : "";
$sortDir = (isset($_POST["dir"])) ? $_POST["dir"] : "";
$start = (isset($_POST["start"])) ? $_POST["start"] : 0;
$limit = (isset($_POST["limit"])) ? $_POST["limit"] : $pageSize;
try {
$emailSever = new \ProcessMaker\BusinessModel\EmailServer();
$result = $emailSever->getEmailServers(array("filter" => $search), $sortField, $sortDir, $start, $limit);
$emailSever = new EmailServer();
$result = $emailSever->getEmailServers(["filter" => $search], $sortField, $sortDir, $start, $limit);
$response["status"] = "OK";
$response["success"] = true;
@@ -205,7 +226,7 @@ switch ($option) {
}
try {
$arrayData = array(
$arrayData = [
"MESS_ENGINE" => $cboEmailEngine,
"MESS_SERVER" => $server,
"MESS_PORT" => $port,
@@ -218,10 +239,9 @@ switch ($option) {
"MESS_TRY_SEND_INMEDIATLY" => $sendTestMail,
"MAIL_TO" => $mailTo,
"MESS_DEFAULT" => $emailServerDefault
);
$emailSever = new \ProcessMaker\BusinessModel\EmailServer();
];
$emailSever = new EmailServer();
$arrayEmailServerData = $emailSever->testConnection($arrayData);
$response["data"] = $arrayEmailServerData;
@@ -245,10 +265,27 @@ switch ($option) {
$gmailOAuth->setSendTestMail((int) $_POST['sendTestMail']);
$gmailOAuth->setMailTo($_POST['mailTo']);
$gmailOAuth->setSetDefaultConfiguration((int) $_POST['setDefaultConfiguration']);
// Audit log parameters
$action = "CreateEmailSettings";
$content = "SetDefaultConfiguration-> " . $_POST['setDefaultConfiguration'];
if (!empty($_POST['emailServerUid'])) {
$gmailOAuth->setEmailServerUid($_POST['emailServerUid']);
// Audit log parameters
$action = "UpdateEmailSettings";
$content = "EmailServer-> " . $_POST['emailServerUid'] .
", SetDefaultConfiguration-> " . $_POST['setDefaultConfiguration'];
}
$client = $gmailOAuth->getGoogleClient();
// Register the log
G::auditLog(
$action,
$content .
", EmailEngine-> " . $_POST['emailEngine'] .
", Server-> " . $_POST['server'] .
", Port-> " . $_POST['port'] .
", FromMail-> " . $_POST['senderEmail'] .
", FromName-> " . $_POST['senderName']
);
$response = [
"status" => 200,
"data" => $client->createAuthUrl()
@@ -276,11 +313,27 @@ switch ($option) {
$office365OAuth->setSendTestMail((int) $_POST['sendTestMail']);
$office365OAuth->setMailTo($_POST['mailTo']);
$office365OAuth->setSetDefaultConfiguration((int) $_POST['setDefaultConfiguration']);
// Audit log parameters
$action = "CreateEmailSettings";
$content = "SetDefaultConfiguration-> " . $_POST['setDefaultConfiguration'];
if (!empty($_POST['emailServerUid'])) {
$office365OAuth->setEmailServerUid($_POST['emailServerUid']);
// Audit log parameters
$action = "UpdateEmailSettings";
$content = "EmailServer-> " . $_POST['emailServerUid'] .
", SetDefaultConfiguration-> " . $_POST['setDefaultConfiguration'];
}
$client = $office365OAuth->getOffice365Client();
// Register the log
G::auditLog(
$action,
$content .
", EmailEngine-> " . $_POST['emailEngine'] .
", Server-> " . $_POST['server'] .
", Port-> " . $_POST['port'] .
", FromMail-> " . $_POST['senderEmail'] .
", FromName-> " . $_POST['senderName']
);
$response = [
"status" => 200,
"data" => $client->getAuthorizationUrl($office365OAuth->getOptions())

View File

@@ -2551,7 +2551,7 @@ class Cases
// Filter specific case
$query->case($caseNumber);
// Filter specific index
if (is_int($index)) {
if ($index > 0) {
$query->index($index);
}
$results = $query->get();

View File

@@ -250,7 +250,7 @@ class Unassigned extends AbstractCases
{
$caseList = CaseList::getCaseList($id, $type);
$query = Delegation::query()->select();
$query->selfService($this->getUserId());
$query->selfService($this->getUserUid());
$name = '';
$description = '';

View File

@@ -104,9 +104,10 @@ class AuditLog
"ExportLanguage" => G::LoadTranslation("ID_EXPORT_LANGUAGE"),
"DeleteLanguage" => G::LoadTranslation("ID_DELETE_LAGUAGE"),
// Settings
"UploadSystemSettings" => G::LoadTranslation("ID_UPLOAD_SYSTEM_SETTINGS"),
"UpdateEmailSettings" => G::LoadTranslation("ID_UPDATE_EMAIL_SETTINGS"),
"CreateEmailSettings" => G::LoadTranslation("ID_CREATE_EMAIL_SETTINGS"),
"DeleteEmailSettings" => G::LoadTranslation("ID_DELETE_EMAIL_SETTINGS"),
"UpdateEmailSettings" => G::LoadTranslation("ID_UPDATE_EMAIL_SETTINGS"),
"UploadSystemSettings" => G::LoadTranslation("ID_UPLOAD_SYSTEM_SETTINGS"),
// Logo
"UploadLogo" => G::LoadTranslation("ID_UPLOAD_LOGO"),
"DeleteLogo" => G::LoadTranslation("ID_DELETE_LOGO"),

View File

@@ -791,18 +791,18 @@ class Delegation extends Model
* Scope a self service cases
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param string $user
* @param string $usrUid
*
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeSelfService($query, $user)
public function scopeSelfService($query, string $usrUid)
{
// Add Join with task filtering only the type self-service
$query->taskAssignType('SELF_SERVICE');
// Filtering the open threads and without users
$query->threadOpen()->withoutUserId();
// Filtering the cases unassigned that the user can view
$this->casesUnassigned($query, $user);
$this->casesUnassigned($query, $usrUid);
return $query;
}
@@ -1135,7 +1135,7 @@ class Delegation extends Model
*
* @return \Illuminate\Database\Eloquent\Builder
*/
public function casesUnassigned(&$query, $usrUid)
public function casesUnassigned(&$query, string $usrUid)
{
// Get the task self services related to the user
$taskSelfService = TaskUser::getSelfServicePerUser($usrUid);

View File

@@ -62,7 +62,7 @@ class TaskUser extends Model
*
* @return array
*/
public static function getSelfServicePerUser($usrUid)
public static function getSelfServicePerUser(string $usrUid)
{
//Get the groups related to the user
$groups = GroupUser::getGroups($usrUid, 'GRP_UID');