Skip to content

Commit

Permalink
Merge pull request #11656 from JMAConsulting/CRM-21751
Browse files Browse the repository at this point in the history
CRM-21751: Move SMS provider ID to 'Select Recipients' page from 'SMS content'
  • Loading branch information
eileenmcnaughton authored Feb 8, 2018
2 parents adfb80c + 6eee091 commit 0a714e2
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 46 deletions.
2 changes: 1 addition & 1 deletion CRM/SMS/BAO/Provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
15 changes: 15 additions & 0 deletions CRM/SMS/Form/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

/**
Expand Down Expand Up @@ -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');

Expand Down Expand Up @@ -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');
}
}
}

Expand Down
28 changes: 0 additions & 28 deletions CRM/SMS/Form/Upload.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

/**
Expand Down Expand Up @@ -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 <a href='%1'>Add SMS Provider</a>", 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'));

Expand Down Expand Up @@ -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);
}
Expand Down
13 changes: 13 additions & 0 deletions templates/CRM/SMS/Form/Group.hlp
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,16 @@
{htxt id="exclude-mailings"}
<p>{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}</p>
{/htxt}

{htxt id ="id-sms_provider-title"}
{ts}SMS Provider{/ts}
{/htxt}
{htxt id ="id-sms_provider"}
<p>{ts}Select the SMS provider for this mass message from the dropdown list.{/ts}</p>
{if $params.isAdmin}
{capture assign="fromConfig"}{crmURL p="civicrm/admin/sms/provider" q="reset=1"}{/capture}
<p>{ts 1=$fromConfig}Go to <a href='%1'>Administer CiviCRM &raquo; System Settings &raquo; SMS Providers</a> to add or edit SMS Provider.{/ts}</p>
{else}
{ts}Contact your site administrator if you need to use a SMS Provider which is not in the dropdown list.{/ts}
{/if}
{/htxt}
1 change: 1 addition & 0 deletions templates/CRM/SMS/Form/Group.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

<table class="form-layout">
<tr class="crm-mailing-group-form-block-name"><td class="label">{$form.name.label}</td><td>{$form.name.html} {help id="sms-name"}</td></tr>
<tr class="crm-mailing-upload-form-block-sms_provider_id"><td class="label">{$form.sms_provider_id.label}</td><td>{$form.sms_provider_id.html} {help id ="id-sms_provider" isAdmin=$isAdmin}</td></tr>
</table>


Expand Down
13 changes: 0 additions & 13 deletions templates/CRM/SMS/Form/Upload.hlp
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
<p>{ts}Select the SMS provider for this mass message from the dropdown list.{/ts}</p>
{if $params.isAdmin}
{capture assign="fromConfig"}{crmURL p="civicrm/admin/sms/provider" q="reset=1"}{/capture}
<p>{ts 1=$fromConfig}Go to <a href='%1'>Administer CiviCRM &raquo; System Settings &raquo; SMS Providers</a> to add or edit SMS Provider.{/ts}</p>
{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}
Expand Down
4 changes: 0 additions & 4 deletions templates/CRM/SMS/Form/Upload.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@
{include file="CRM/Mailing/Form/Count.tpl"}

<table class="form-layout-compressed">
<tr class="crm-mailing-upload-form-block-sms_provider_id"><td class="label">{$form.sms_provider_id.label}</td>
<td>{$form.sms_provider_id.html} {help id ="id-sms_provider" isAdmin=$isAdmin}</td>
</tr>

<tr class="crm-mailing-upload-form-block-template">
<td class="label">{$form.SMStemplate.label}</td>
<td>{$form.SMStemplate.html}</td>
Expand Down

0 comments on commit 0a714e2

Please sign in to comment.