}
// email column links/icon
if ($row['email']) {
- $row['email'] = '<a class="crm-hover-button crm-popup" href="' . CRM_Utils_System::url('civicrm/activity/email/add', 'reset=1&action=add&atype=3&cid=' . $row['cid']) . '&caseid=' . $caseID . '" title="' . ts('Send an Email') . '"><i class="crm-i fa-envelope" aria-hidden="true"></i></a>';
+ $row['email'] = '<a class="crm-hover-button crm-popup" href="' . CRM_Utils_System::url('civicrm/case/email/add', 'reset=1&action=add&atype=3&cid=' . $row['cid']) . '&caseid=' . $caseID . '" title="' . ts('Send an Email') . '"><i class="crm-i fa-envelope" aria-hidden="true"></i></a>';
}
// view end date if set
$activityLinks = ['' => ts('Add Activity')];
foreach ($aTypes as $type => $label) {
if ($type == $emailActivityType) {
- $url = CRM_Utils_System::url('civicrm/activity/email/add',
+ $url = CRM_Utils_System::url('civicrm/case/email/add',
"action=add&context=standalone&reset=1&caseid={$this->_caseID}&atype=$type",
FALSE, NULL, FALSE
);
* @inheritDoc
*/
public function setContactIDs() {
- // @todo Parameters shouldn't be needed and should be class member
- // variables instead, set appropriately by each subclass.
- $this->_contactIds = $this->getContactIDsFromComponent($this->_entityIds,
- 'civicrm_case_contact', 'case_id'
- );
+ $this->_contactIds = $this->getContactIDs();
}
/**
return 'case_id';
}
+ protected function getContactIDs(): array {
+ if (isset($this->_contactIds)) {
+ return $this->_contactIds;
+ }
+ $contactIDSFromUrl = CRM_Utils_Request::retrieve('cid', 'CommaSeparatedIntegers', $this);
+ if (!empty($contactIDSFromUrl)) {
+ return explode(',', $contactIDSFromUrl);
+ }
+ // @todo Parameters shouldn't be needed and should be class member
+ // variables instead, set appropriately by each subclass.
+ return $this->getContactIDsFromComponent($this->_entityIds,
+ 'civicrm_case_contact', 'case_id'
+ );
+ }
+
}
--- /dev/null
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC. All rights reserved. |
+ | |
+ | This work is published under the GNU AGPLv3 license with some |
+ | permitted exceptions and without any warranty. For full license |
+ | and copyright information, see https://civicrm.org/licensing |
+ +--------------------------------------------------------------------+
+ */
+
+/**
+ *
+ * @package CRM
+ * @copyright CiviCRM LLC https://civicrm.org/licensing
+ */
+
+/**
+ * This class provides the functionality to email a group of contacts.
+ */
+class CRM_Case_Form_Task_Email extends CRM_Case_Form_Task {
+ use CRM_Contact_Form_Task_EmailTrait;
+
+ /**
+ * Getter for isSearchContext.
+ *
+ * @return bool
+ */
+ public function isSearchContext(): bool {
+ return FALSE;
+ }
+
+ /**
+ * List available tokens for this form.
+ *
+ * @return array
+ * @throws \CRM_Core_Exception
+ */
+ public function listTokens() {
+ $tokens = CRM_Core_SelectValues::contactTokens();
+
+ if ($this->getCaseID()) {
+ // For a single case, list tokens relevant for only that case type
+ $caseTypeId = CRM_Core_DAO::getFieldValue('CRM_Case_DAO_Case', $this->getCaseID(), 'case_type_id');
+ $tokens += CRM_Core_SelectValues::caseTokens($caseTypeId);
+ }
+
+ return $tokens;
+ }
+
+ /**
+ * Get the subject for the message.
+ *
+ * The case handling should possibly be on the case form.....
+ *
+ * @param string $subject
+ *
+ * @return string
+ * @throws \CRM_Core_Exception
+ */
+ protected function getSubject(string $subject):string {
+ // CRM-5916: prepend case id hash to CiviCase-originating emails’ subjects
+ if ($this->getCaseID()) {
+ $hash = substr(sha1(CIVICRM_SITE_KEY . $this->getCaseID()), 0, 7);
+ $subject = "[case #$hash] $subject";
+ }
+ return $subject;
+ }
+
+}
<path>civicrm/ajax/get-cases</path>
<page_callback>CRM_Case_Page_AJAX::getCases</page_callback>
</item>
+ <item>
+ <path>civicrm/case/email/add</path>
+ <path_arguments>action=add,task=email</path_arguments>
+ <title>Email</title>
+ <page_callback>CRM_Case_Form_Task_Email</page_callback>
+ </item>
</menu>
* @throws \CRM_Core_Exception
*/
protected function getSubject(string $subject):string {
- // CRM-5916: prepend case id hash to CiviCase-originating emails’ subjects
- if ($this->getCaseID()) {
- $hash = substr(sha1(CIVICRM_SITE_KEY . $this->getCaseID()), 0, 7);
- $subject = "[case #$hash] $subject";
- }
return $subject;
}
{foreach from=$caseRoles.client item=client}
<tr class="crm-case-caseview-display_name">
<td class="label-left bold" style="padding: 0px; border: none;">
- <a href="{crmURL p='civicrm/contact/view' q="action=view&reset=1&cid=`$client.contact_id`"}" title="{ts}View contact record{/ts}">{$client.display_name}</a>{if $client.email}{crmAPI var='email_type_id' entity='OptionValue' action='getsingle' return="value" name="Email" option_group_id="activity_type"}<span class="crm-case-caseview-email"><a class="crm-hover-button crm-popup" href="{crmURL p='civicrm/activity/email/add' q="reset=1&action=add&atype=`$email_type_id.value`&cid=`$client.contact_id`&caseid=`$caseId`"}" title="{ts 1=$client.email|escape}Email: %1{/ts}"><i class="crm-i fa-envelope" aria-hidden="true"></i></a></span>{/if}
+ <a href="{crmURL p='civicrm/contact/view' q="action=view&reset=1&cid=`$client.contact_id`"}" title="{ts}View contact record{/ts}">{$client.display_name}</a>{if $client.email}{crmAPI var='email_type_id' entity='OptionValue' action='getsingle' return="value" name="Email" option_group_id="activity_type"}<span class="crm-case-caseview-email"><a class="crm-hover-button crm-popup" href="{crmURL p='civicrm/case/email/add' q="reset=1&action=add&atype=`$email_type_id.value`&cid=`$client.contact_id`&caseid=`$caseId`"}" title="{ts 1=$client.email|escape}Email: %1{/ts}"><i class="crm-i fa-envelope" aria-hidden="true"></i></a></span>{/if}
</td>
</tr>
{if $client.phone}
--- /dev/null
+{include file="CRM/Contact/Form/Task/Email.tpl"}
*
* @dataProvider contactIDProvider
*/
- public function testSetContactIDs($input, $selected_search_results, $expected) {
+ public function testSetContactIDs($input, $selected_search_results, $expected): void {
$this->createCaseContacts($input);
- $task = new CRM_Case_Form_Task();
+ $task = $this->getFormObject('CRM_Case_Form_Task');
// This simulates the selection from the search results list. What we're
// testing is that no matter what order the cases were created or what