From 6eee0915194e1ed8a6e0d0b8b3e37d8b8729f0c7 Mon Sep 17 00:00:00 2001 From: "deb.monish" Date: Thu, 8 Feb 2018 12:19:46 +0530 Subject: [PATCH] CRM-21751: Move SMS provider ID to 'Select Recipients' page from 'SMS content' --- CRM/SMS/BAO/Provider.php | 2 +- CRM/SMS/Form/Group.php | 15 +++++++++++++++ CRM/SMS/Form/Upload.php | 28 ---------------------------- templates/CRM/SMS/Form/Group.hlp | 13 +++++++++++++ templates/CRM/SMS/Form/Group.tpl | 1 + templates/CRM/SMS/Form/Upload.hlp | 13 ------------- templates/CRM/SMS/Form/Upload.tpl | 4 ---- 7 files changed, 30 insertions(+), 46 deletions(-) diff --git a/CRM/SMS/BAO/Provider.php b/CRM/SMS/BAO/Provider.php index 21c55629c6..f58f511ad6 100644 --- a/CRM/SMS/BAO/Provider.php +++ b/CRM/SMS/BAO/Provider.php @@ -83,7 +83,7 @@ class CRM_SMS_BAO_Provider extends CRM_SMS_DAO_Provider { $dao->find(); while ($dao->fetch()) { CRM_Core_DAO::storeValues($dao, $temp); - $providers[] = $temp; + $providers[$dao->id] = $temp; } return $providers; } diff --git a/CRM/SMS/Form/Group.php b/CRM/SMS/Form/Group.php index 8c4bd8a63c..9aabab1004 100644 --- a/CRM/SMS/Form/Group.php +++ b/CRM/SMS/Form/Group.php @@ -46,6 +46,10 @@ class CRM_SMS_Form_Group extends CRM_Contact_Form_Task { $session = CRM_Core_Session::singleton(); $session->replaceUserContext(CRM_Utils_System::url('civicrm/mailing/browse', 'reset=1&sms=1')); + + if (CRM_Core_Permission::check('administer CiviCRM')) { + $this->assign('isAdmin', 1); + } } /** @@ -107,6 +111,12 @@ class CRM_SMS_Form_Group extends CRM_Contact_Form_Task { TRUE ); + $this->add('select', 'sms_provider_id', + ts('Select SMS Provider'), + CRM_Utils_Array::collect('title', CRM_SMS_BAO_Provider::getProviders()), + TRUE + ); + // Get the mailing groups. $groups = CRM_Core_PseudoConstant::nestedGroup('Mailing'); @@ -183,9 +193,14 @@ class CRM_SMS_Form_Group extends CRM_Contact_Form_Task { 'name', 'group_id', 'is_sms', + 'sms_provider_id', ) as $n) { if (!empty($values[$n])) { $params[$n] = $values[$n]; + if ($n == 'sms_provider_id') { + // Get the from Name. + $params['from_name'] = CRM_Core_DAO::getFieldValue('CRM_SMS_DAO_Provider', $params['sms_provider_id'], 'username'); + } } } diff --git a/CRM/SMS/Form/Upload.php b/CRM/SMS/Form/Upload.php index 0be17ca10c..4a52c4052b 100644 --- a/CRM/SMS/Form/Upload.php +++ b/CRM/SMS/Form/Upload.php @@ -39,9 +39,6 @@ class CRM_SMS_Form_Upload extends CRM_Core_Form { public function preProcess() { $this->_mailingID = $this->get('mailing_id'); - if (CRM_Core_Permission::check('administer CiviCRM')) { - $this->assign('isAdmin', 1); - } } /** @@ -128,25 +125,6 @@ class CRM_SMS_Form_Upload extends CRM_Core_Form { "CRM_SMS_Controller_Send_{$this->controller->_key}" ); - $providers = CRM_SMS_BAO_Provider::getProviders(array('id', 'title')); - - if (empty($providers)) { - //redirect user to configure sms provider. - $url = CRM_Utils_System::url('civicrm/admin/sms/provider', 'action=add&reset=1'); - $status = ts("There is no SMS Provider Configured. You can add here Add SMS Provider", array(1 => $url)); - $session->setStatus($status); - } - else { - $providerSelect[''] = '- select -'; - foreach ($providers as $provider) { - $providerSelect[$provider['id']] = $provider['title']; - } - } - - $this->add('select', 'sms_provider_id', - ts('SMS Provider'), $providerSelect, TRUE - ); - $attributes = array('onclick' => "showHideUpload();"); $options = array(ts('Upload Content'), ts('Compose On-screen')); @@ -272,12 +250,6 @@ class CRM_SMS_Form_Upload extends CRM_Core_Form { $ids['mailing_id'] = $this->_mailingID; - // Get the from email address. - $params['sms_provider_id'] = $formValues['sms_provider_id']; - - // Get the from Name. - $params['from_name'] = CRM_Core_DAO::getFieldValue('CRM_SMS_DAO_Provider', $params['sms_provider_id'], 'username'); - // Build SMS in mailing table. CRM_Mailing_BAO_Mailing::create($params, $ids); } diff --git a/templates/CRM/SMS/Form/Group.hlp b/templates/CRM/SMS/Form/Group.hlp index c2c50d5beb..9cd389c837 100644 --- a/templates/CRM/SMS/Form/Group.hlp +++ b/templates/CRM/SMS/Form/Group.hlp @@ -62,3 +62,16 @@ {htxt id="exclude-mailings"}

{ts}If you have sent other Mass SMS - you can additionally Include (or Exclude) contacts who received those Mass SMS. CiviCRM will eliminate any duplications so that contacts who are in an Included Group AND were recipients of an Included Mailing will only be sent one copy of this SMS.{/ts}

{/htxt} + +{htxt id ="id-sms_provider-title"} + {ts}SMS Provider{/ts} +{/htxt} +{htxt id ="id-sms_provider"} +

{ts}Select the SMS provider for this mass message from the dropdown list.{/ts}

+{if $params.isAdmin} + {capture assign="fromConfig"}{crmURL p="civicrm/admin/sms/provider" q="reset=1"}{/capture} +

{ts 1=$fromConfig}Go to Administer CiviCRM » System Settings » SMS Providers to add or edit SMS Provider.{/ts}

+{else} + {ts}Contact your site administrator if you need to use a SMS Provider which is not in the dropdown list.{/ts} +{/if} +{/htxt} diff --git a/templates/CRM/SMS/Form/Group.tpl b/templates/CRM/SMS/Form/Group.tpl index d434e5077a..378dddf5a4 100644 --- a/templates/CRM/SMS/Form/Group.tpl +++ b/templates/CRM/SMS/Form/Group.tpl @@ -34,6 +34,7 @@ +
{$form.name.label}{$form.name.html} {help id="sms-name"}
{$form.sms_provider_id.label}{$form.sms_provider_id.html} {help id ="id-sms_provider" isAdmin=$isAdmin}
diff --git a/templates/CRM/SMS/Form/Upload.hlp b/templates/CRM/SMS/Form/Upload.hlp index 240aff41d1..33cfb42b8c 100644 --- a/templates/CRM/SMS/Form/Upload.hlp +++ b/templates/CRM/SMS/Form/Upload.hlp @@ -23,19 +23,6 @@ | see the CiviCRM license FAQ at http://civicrm.org/licensing | +--------------------------------------------------------------------+ *} -{htxt id ="id-sms_provider-title"} - {ts}SMS Provider{/ts} -{/htxt} -{htxt id ="id-sms_provider"} -

{ts}Select the SMS provider for this mass message from the dropdown list.{/ts}

-{if $params.isAdmin} - {capture assign="fromConfig"}{crmURL p="civicrm/admin/sms/provider" q="reset=1"}{/capture} -

{ts 1=$fromConfig}Go to Administer CiviCRM » System Settings » SMS Providers to add or edit SMS Provider.{/ts}

-{else} - {ts}Contact your site administrator if you need to use a SMS Provider which is not in the dropdown list.{/ts} -{/if} -{/htxt} - {htxt id="content-intro-title"} {ts}Message Formats{/ts} {/htxt} diff --git a/templates/CRM/SMS/Form/Upload.tpl b/templates/CRM/SMS/Form/Upload.tpl index 178a27fbc9..e998e2024d 100644 --- a/templates/CRM/SMS/Form/Upload.tpl +++ b/templates/CRM/SMS/Form/Upload.tpl @@ -33,10 +33,6 @@ {include file="CRM/Mailing/Form/Count.tpl"} - - - - -- 2.25.1
{$form.sms_provider_id.label}{$form.sms_provider_id.html} {help id ="id-sms_provider" isAdmin=$isAdmin}
{$form.SMStemplate.label} {$form.SMStemplate.html}