diff --git a/CRM/SMS/BAO/Provider.php b/CRM/SMS/BAO/Provider.php index 21c55629c63d..f58f511ad6fa 100644 --- a/CRM/SMS/BAO/Provider.php +++ b/CRM/SMS/BAO/Provider.php @@ -83,7 +83,7 @@ public static function getProviders($selectArr = NULL, $filter = NULL, $getActiv $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 8c4bd8a63c45..9aabab100401 100644 --- a/CRM/SMS/Form/Group.php +++ b/CRM/SMS/Form/Group.php @@ -46,6 +46,10 @@ public function preProcess() { $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 @@ public function buildQuickForm() { 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 @@ public function postProcess() { '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 0be17ca10ce5..4a52c4052ba9 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 @@ public function buildQuickForm() { "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 @@ public function postProcess() { $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 c2c50d5beb7b..9cd389c83788 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 d434e5077a68..378dddf5a442 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 240aff41d10e..33cfb42b8c32 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 178a27fbc976..e998e2024d9d 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"} - - - -
{$form.sms_provider_id.label}{$form.sms_provider_id.html} {help id ="id-sms_provider" isAdmin=$isAdmin}
{$form.SMStemplate.label} {$form.SMStemplate.html}