Merge next into suite 8

This commit is contained in:
Jack Anderson 2023-01-24 10:56:09 +00:00
commit 10efe5a340
51 changed files with 3318 additions and 2228 deletions

View file

@ -50,11 +50,41 @@ class OutboundEmailAccounts extends OutboundEmailAccounts_sugar
*/
public $mail_smtppass;

/**
* @var string
*/
public $smtp_from_addr;

/**
* @var string
*/
public $smtp_from_name;

/**
* @var string
*/
public $mail_smtpuser;

/**
* @var string
*/
public $type;

/**
* @var string
*/
public $signature;

/**
* @var string
*/
public $reply_to_addr;

/**
* @var string
*/
public $reply_to_name;

public function __construct()
{
parent::__construct();
@ -86,7 +116,7 @@ class OutboundEmailAccounts extends OutboundEmailAccounts_sugar
$this->smtp_from_addr = trim($this->smtp_from_addr);
$this->mail_smtpserver = trim($this->mail_smtpserver);
$this->mail_smtpuser = trim($this->mail_smtpuser);

$results = parent::save($check_notify);
return $results;
}
@ -107,6 +137,22 @@ class OutboundEmailAccounts extends OutboundEmailAccounts_sugar
return $results;
}

/**
* @return array
*/
public function getUserOutboundAccounts(): array {
global $current_user, $db;

$where = '';
if (is_admin($current_user)) {
$currentUserId = $db->quote($current_user->id);
$tableName = $db->quote($this->table_name);
$where = "(($tableName.type IS NULL) OR ($tableName.type != 'user' ) OR ($tableName.type = 'user' AND $tableName.user_id = '$currentUserId'))";
}

return $this->get_list('', $where)['list'] ?? [];
}

/**
* @inheritDoc
*/
@ -247,6 +293,48 @@ class OutboundEmailAccounts extends OutboundEmailAccounts_sugar
return parent::ACLAccess($view, $is_owner, $in_group);
}

/**
* Get from address
* @return string
*/
public function getFromAddress(): string {
$fromAddress = $this->smtp_from_addr ?? '';
if (empty($fromAddress) || isValidEmailAddress($this->mail_smtpuser, '', false, '')) {
$fromAddress = $this->mail_smtpuser;
}

return $fromAddress;
}

/**
* Get from name
* @return string
*/
public function getFromName(): string {
return $this->smtp_from_name ?? '';
}

/**
* Get reply to address
* @return string
*/
public function getReplyToAddress(): string {
$address = $this->reply_to_addr ?? '';
if (empty($address) && isValidEmailAddress($this->reply_to_addr, '', false, '')) {
return $this->getFromAddress();
}

return $address;
}

/**
* Get reply to name
* @return string
*/
public function getReplyToName(): string {
return $this->reply_to_name ?? '';
}

/**
* @return void
*/

View file

@ -0,0 +1,76 @@
/**
*
* SugarCRM Community Edition is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
*
* SuiteCRM is an extension to SugarCRM Community Edition developed by SalesAgility Ltd.
* Copyright (C) 2011 - 2022 SalesAgility Ltd.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo and "Supercharged by SuiteCRM" logo. If the display of the logos is not
* reasonably feasible for technical reasons, the Appropriate Legal Notices must
* display the words "Powered by SugarCRM" and "Supercharged by SuiteCRM".
*/

function togglePanels(type) {

var panelsPerType = {
'personal': {
'DEFAULT': true,
'LBL_CONNECTION_CONFIGURATION': true,
'LBL_OUTBOUND_CONFIGURATION': true,
},
'group': {
'DEFAULT': true,
'LBL_CONNECTION_CONFIGURATION': true,
'LBL_OUTBOUND_CONFIGURATION': true,
},
'system-override': {
'DEFAULT': true,
'LBL_CONNECTION_CONFIGURATION': false,
'LBL_OUTBOUND_CONFIGURATION': true,
}
};

var panelDisplay = panelsPerType[type] || panelsPerType.personal;

Object.keys(panelDisplay).forEach(function (panelKey) {
var display = panelDisplay[panelKey];
var method = 'show';
if(!display) {
method = 'hide';
}
$('[data-id="' + panelKey + '"]').closest('.panel')[method]();
});
}


$(document).ready(function () {
var type = outboundEmailFields.getValue('type');
togglePanels(type);
});

View file

@ -110,6 +110,8 @@ $mod_strings = array(
'LBL_MAIL_SMTPSSL' => 'Mail SMTP/SSL',
'LBL_SMTP_FROM_NAME' => '"From" name',
'LBL_SMTP_FROM_ADDR' => '"From" address',
'LBL_REPLY_TO_NAME' => '"Reply-to" name',
'LBL_REPLY_TO_ADDR' => '"Reply-to" address',

'LBL_SECURITYGROUPS_SUBPANEL_TITLE' => 'Security Groups',


View file

@ -36,6 +36,7 @@ $viewdefs ['OutboundEmailAccounts'] = [
{suite_combinescripts
files="modules/OutboundEmailAccounts/js/fields.js,
modules/OutboundEmailAccounts/js/owner_toggle.js,
modules/OutboundEmailAccounts/js/panel_toggle.js,
modules/OutboundEmailAccounts/js/smtp_auth_toggle.js"}
</script>
',
@ -71,10 +72,16 @@ $viewdefs ['OutboundEmailAccounts'] = [
'lbl_outbound_configuration' => [
[
'smtp_from_name',
'reply_to_name'
],
[
'smtp_from_addr',
'reply_to_addr'
],
[
'signature',
''
]
],
],
],

View file

@ -38,6 +38,7 @@ $viewdefs ['OutboundEmailAccounts'] = [
{suite_combinescripts
files="modules/OutboundEmailAccounts/js/fields.js,
modules/OutboundEmailAccounts/js/ssl_port_set.js,
modules/OutboundEmailAccounts/js/panel_toggle.js,
modules/OutboundEmailAccounts/js/owner_toggle.js,
modules/OutboundEmailAccounts/js/smtp_auth_toggle.js"}
</script>
@ -80,10 +81,16 @@ $viewdefs ['OutboundEmailAccounts'] = [
'lbl_outbound_configuration' => [
[
'smtp_from_name',
'reply_to_name'
],
[
'smtp_from_addr',
'reply_to_addr'
],
[
'signature',
''
]
],
],
],

View file

@ -167,6 +167,40 @@ $dictionary["OutboundEmailAccounts"] = [
'exportable' => false,
'unified_search' => false,
],
'reply_to_name' => [
'name' => 'reply_to_name',
'vname' => 'LBL_REPLY_TO_NAME',
'type' => 'varchar',
'reportable' => false,
'massupdate' => false,
'inline_edit' => false,
'importable' => false,
'exportable' => false,
'unified_search' => false,
],
'reply_to_addr' => [
'name' => 'reply_to_addr',
'vname' => 'LBL_REPLY_TO_ADDR',
'type' => 'varchar',
'reportable' => false,
'massupdate' => false,
'inline_edit' => false,
'importable' => false,
'exportable' => false,
'unified_search' => false,
],
'signature' => [
'name' => 'signature',
'vname' => 'LBL_SIGNATURE',
'type' => 'wysiwyg',
'dbType' => 'text',
'reportable' => false,
'massupdate' => false,
'inline_edit' => false,
'importable' => false,
'exportable' => false,
'unified_search' => false,
],
'mail_sendtype' => [
'name' => 'mail_sendtype',
'vname' => 'LBL_MAIL_SENDTYPE',