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 Providers
21 class CRM_SMS_Page_Provider
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_SMS_BAO_Provider';
46 * (reference) of action links
48 public function &links() {
49 if (!(self
::$_links)) {
50 self
::$_links = array(
51 CRM_Core_Action
::UPDATE
=> array(
53 'url' => 'civicrm/admin/sms/provider',
54 'qs' => 'action=update&id=%%id%%&reset=1',
55 'title' => ts('Edit Provider'),
57 CRM_Core_Action
::DELETE
=> array(
58 'name' => ts('Delete'),
59 'url' => 'civicrm/admin/sms/provider',
60 'qs' => 'action=delete&id=%%id%%',
61 'title' => ts('Delete Provider'),
63 CRM_Core_Action
::ENABLE
=> array(
64 'name' => ts('Enable'),
65 'ref' => 'crm-enable-disable',
66 'title' => ts('Enable Provider'),
68 CRM_Core_Action
::DISABLE
=> array(
69 'name' => ts('Disable'),
70 'ref' => 'crm-enable-disable',
71 'title' => ts('Disable Provider'),
81 * This method is called after the page is created. It checks for the
82 * type of action and executes that action.
83 * Finally it calls the parent's run method.
85 public function run() {
86 // set title and breadcrumb
87 CRM_Utils_System
::setTitle(ts('Settings - SMS Provider'));
90 'title' => ts('SMS Provider'),
91 'url' => CRM_Utils_System
::url('civicrm/admin/sms/provider',
96 CRM_Utils_System
::appendBreadCrumb($breadCrumb);
98 $this->_id
= CRM_Utils_Request
::retrieve('id', 'String',
101 $this->_action
= CRM_Utils_Request
::retrieve('action', 'String',
105 return parent
::run();
109 * Browse all Providers.
111 * @param array $action
113 public function browse($action = NULL) {
114 $providers = CRM_SMS_BAO_Provider
::getProviders();
116 foreach ($providers as $provider) {
117 $action = array_sum(array_keys($this->links()));
118 // update enable/disable links.
119 if ($provider['is_active']) {
120 $action -= CRM_Core_Action
::ENABLE
;
123 $action -= CRM_Core_Action
::DISABLE
;
126 $apiTypes = CRM_Core_OptionGroup
::values('sms_api_type', FALSE, FALSE, FALSE, NULL, 'label');
127 $provider['api_type'] = $apiTypes[$provider['api_type']];
129 $provider['action'] = CRM_Core_Action
::formLink(self
::links(), $action,
130 array('id' => $provider['id']),
139 $this->assign('rows', $rows);
143 * Get name of edit form.
146 * Classname of edit form.
148 public function editForm() {
149 return 'CRM_SMS_Form_Provider';
153 * Get edit form name.
158 public function editName() {
159 return 'SMS Provider';
170 public function userContext($mode = NULL) {
171 return 'civicrm/admin/sms/provider';