3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
19 * Page for displaying list of Mail account settings.
21 class CRM_Admin_Page_MailSettings
extends CRM_Core_Page_Basic
{
23 public $useLivePageJS = TRUE;
26 * The action links that we need to display for the browse screen.
30 public static $_links = NULL;
38 public function getBAOName() {
39 return 'CRM_Core_BAO_MailSettings';
46 * (reference) of action links
48 public function &links() {
49 if (!(self
::$_links)) {
50 // helper variable for nicer formatting
52 CRM_Core_Action
::UPDATE
=> [
54 'url' => 'civicrm/admin/mailSettings',
55 'qs' => 'action=update&id=%%id%%&reset=1',
56 'title' => ts('Edit Mail Settings'),
58 CRM_Core_Action
::DELETE
=> [
59 'name' => ts('Delete'),
60 'url' => 'civicrm/admin/mailSettings',
61 'qs' => 'action=delete&id=%%id%%',
62 'title' => ts('Delete Mail Settings'),
71 * Browse all mail settings.
73 public function browse() {
74 //get all mail settings.
75 $allMailSettings = [];
76 $mailSetting = new CRM_Core_DAO_MailSettings();
78 $allProtocols = CRM_Core_PseudoConstant
::get('CRM_Core_DAO_MailSettings', 'protocol');
80 //multi-domain support for mail settings. CRM-5244
81 $mailSetting->domain_id
= CRM_Core_Config
::domainID();
83 //find all mail settings.
85 while ($mailSetting->fetch()) {
86 //replace protocol value with name
87 $mailSetting->protocol
= $allProtocols[$mailSetting->protocol
] ??
NULL;
88 CRM_Core_DAO
::storeValues($mailSetting, $allMailSettings[$mailSetting->id
]);
90 //form all action links
91 $action = array_sum(array_keys($this->links()));
93 // disallow the DELETE action for the default set of settings
94 if ($mailSetting->is_default
) {
95 $action &= ~CRM_Core_Action
::DELETE
;
99 $allMailSettings[$mailSetting->id
]['action'] = CRM_Core_Action
::formLink(self
::links(), $action,
100 ['id' => $mailSetting->id
],
103 'mailSetting.manage.action',
109 $this->assign('rows', $allMailSettings);
111 $setupActions = CRM_Core_BAO_MailSettings
::getSetupActions();
112 if (count($setupActions) > 1 ||
!isset($setupActions['standard'])) {
113 $this->assign('setupActions', $setupActions);
118 * Get name of edit form.
121 * Classname of edit form.
123 public function editForm() {
124 return 'CRM_Admin_Form_MailSettings';
128 * Get edit form name.
133 public function editName() {
134 return 'Mail Settings';
145 public function userContext($mode = NULL) {
146 return 'civicrm/admin/mailSettings';