Merge pull request #12790 from alifrumin/core362
[civicrm-core.git] / CRM / Admin / Page / MailSettings.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
fee14197 4 | CiviCRM version 5 |
6a488035 5 +--------------------------------------------------------------------+
8c9251b3 6 | Copyright CiviCRM LLC (c) 2004-2018 |
6a488035
TO
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
9 | |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
13 | |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
18 | |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
d25dd0ee 26 */
6a488035
TO
27
28/**
29 *
30 * @package CRM
8c9251b3 31 * @copyright CiviCRM LLC (c) 2004-2018
6a488035
TO
32 */
33
34/**
ce064e4f 35 * Page for displaying list of Mail account settings.
6a488035
TO
36 */
37class CRM_Admin_Page_MailSettings extends CRM_Core_Page_Basic {
38
96f50de2 39 public $useLivePageJS = TRUE;
da6b46f4 40
6a488035 41 /**
eceb18cc 42 * The action links that we need to display for the browse screen.
6a488035
TO
43 *
44 * @var array
6a488035
TO
45 */
46 static $_links = NULL;
47
48 /**
eceb18cc 49 * Get BAO Name.
6a488035 50 *
a6c01b45
CW
51 * @return string
52 * Classname of BAO.
6a488035 53 */
00be9182 54 public function getBAOName() {
6a488035
TO
55 return 'CRM_Core_BAO_MailSettings';
56 }
57
58 /**
eceb18cc 59 * Get action Links.
6a488035 60 *
a6c01b45
CW
61 * @return array
62 * (reference) of action links
6a488035 63 */
00be9182 64 public function &links() {
6a488035
TO
65 if (!(self::$_links)) {
66 // helper variable for nicer formatting
67 self::$_links = array(
68 CRM_Core_Action::UPDATE => array(
69 'name' => ts('Edit'),
70 'url' => 'civicrm/admin/mailSettings',
71 'qs' => 'action=update&id=%%id%%&reset=1',
72 'title' => ts('Edit Mail Settings'),
73 ),
74 CRM_Core_Action::DELETE => array(
75 'name' => ts('Delete'),
76 'url' => 'civicrm/admin/mailSettings',
77 'qs' => 'action=delete&id=%%id%%',
78 'title' => ts('Delete Mail Settings'),
79 ),
80 );
81 }
82
83 return self::$_links;
84 }
85
86 /**
87 * Browse all mail settings.
6a488035 88 */
00be9182 89 public function browse() {
6a488035
TO
90 //get all mail settings.
91 $allMailSettings = array();
92 $mailSetting = new CRM_Core_DAO_MailSettings();
93
cbf48754 94 $allProtocols = CRM_Core_PseudoConstant::get('CRM_Core_DAO_MailSettings', 'protocol');
6a488035
TO
95
96 //multi-domain support for mail settings. CRM-5244
97 $mailSetting->domain_id = CRM_Core_Config::domainID();
98
99 //find all mail settings.
100 $mailSetting->find();
101 while ($mailSetting->fetch()) {
102 //replace protocol value with name
103 $mailSetting->protocol = CRM_Utils_Array::value($mailSetting->protocol, $allProtocols);
104 CRM_Core_DAO::storeValues($mailSetting, $allMailSettings[$mailSetting->id]);
105
106 //form all action links
107 $action = array_sum(array_keys($this->links()));
108
109 // disallow the DELETE action for the default set of settings
110 if ($mailSetting->is_default) {
111 $action &= ~CRM_Core_Action::DELETE;
112 }
113
114 //add action links.
115 $allMailSettings[$mailSetting->id]['action'] = CRM_Core_Action::formLink(self::links(), $action,
87dab4a4
AH
116 array('id' => $mailSetting->id),
117 ts('more'),
118 FALSE,
119 'mailSetting.manage.action',
120 'MailSetting',
121 $mailSetting->id
6a488035
TO
122 );
123 }
124
125 $this->assign('rows', $allMailSettings);
126 }
127
128 /**
eceb18cc 129 * Get name of edit form.
6a488035 130 *
a6c01b45
CW
131 * @return string
132 * Classname of edit form.
6a488035 133 */
00be9182 134 public function editForm() {
6a488035
TO
135 return 'CRM_Admin_Form_MailSettings';
136 }
137
138 /**
eceb18cc 139 * Get edit form name.
6a488035 140 *
a6c01b45
CW
141 * @return string
142 * name of this page.
6a488035 143 */
00be9182 144 public function editName() {
6a488035
TO
145 return 'Mail Settings';
146 }
147
148 /**
149 * Get user context.
150 *
da6b46f4
EM
151 * @param null $mode
152 *
a6c01b45
CW
153 * @return string
154 * user context.
6a488035 155 */
00be9182 156 public function userContext($mode = NULL) {
6a488035
TO
157 return 'civicrm/admin/mailSettings';
158 }
96025800 159
6a488035 160}