Merge pull request #18589 from eileenmcnaughton/ex_class
[civicrm-core.git] / CRM / Campaign / BAO / Petition.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
5 | |
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 +--------------------------------------------------------------------+
10 */
11
12 /**
13 *
14 * @package CRM
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
16 */
17 class CRM_Campaign_BAO_Petition extends CRM_Campaign_BAO_Survey {
18
19 /**
20 * Class constructor.
21 */
22 public function __construct() {
23 parent::__construct();
24 // expire cookie in one day
25 $this->cookieExpire = (1 * 60 * 60 * 24);
26 }
27
28 /**
29 * Get Petition Details for dashboard.
30 *
31 * @param array $params
32 * @param bool $onlyCount
33 *
34 * @return array|int
35 */
36 public static function getPetitionSummary($params = [], $onlyCount = FALSE) {
37 //build the limit and order clause.
38 $limitClause = $orderByClause = $lookupTableJoins = NULL;
39 if (!$onlyCount) {
40 $sortParams = [
41 'sort' => 'created_date',
42 'offset' => 0,
43 'rowCount' => 10,
44 'sortOrder' => 'desc',
45 ];
46 foreach ($sortParams as $name => $default) {
47 if (!empty($params[$name])) {
48 $sortParams[$name] = $params[$name];
49 }
50 }
51
52 //need to lookup tables.
53 $orderOnPetitionTable = TRUE;
54 if ($sortParams['sort'] == 'campaign') {
55 $orderOnPetitionTable = FALSE;
56 $lookupTableJoins = '
57 LEFT JOIN civicrm_campaign campaign ON ( campaign.id = petition.campaign_id )';
58 $orderByClause = "ORDER BY campaign.title {$sortParams['sortOrder']}";
59 }
60 elseif ($sortParams['sort'] == 'activity_type') {
61 $orderOnPetitionTable = FALSE;
62 $lookupTableJoins = "
63 LEFT JOIN civicrm_option_value activity_type ON ( activity_type.value = petition.activity_type_id
64 OR petition.activity_type_id IS NULL )
65 INNER JOIN civicrm_option_group grp ON ( activity_type.option_group_id = grp.id AND grp.name = 'activity_type' )";
66 $orderByClause = "ORDER BY activity_type.label {$sortParams['sortOrder']}";
67 }
68 elseif ($sortParams['sort'] == 'isActive') {
69 $sortParams['sort'] = 'is_active';
70 }
71 if ($orderOnPetitionTable) {
72 $orderByClause = "ORDER BY petition.{$sortParams['sort']} {$sortParams['sortOrder']}";
73 }
74 $limitClause = "LIMIT {$sortParams['offset']}, {$sortParams['rowCount']}";
75 }
76
77 //build the where clause.
78 $queryParams = $where = [];
79
80 //we only have activity type as a
81 //difference between survey and petition.
82 $petitionTypeID = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Petition');
83 if ($petitionTypeID) {
84 $where[] = "( petition.activity_type_id = %1 )";
85 $queryParams[1] = [$petitionTypeID, 'Positive'];
86 }
87 if (!empty($params['title'])) {
88 $where[] = "( petition.title LIKE %2 )";
89 $queryParams[2] = ['%' . trim($params['title']) . '%', 'String'];
90 }
91 if (!empty($params['campaign_id'])) {
92 $where[] = '( petition.campaign_id = %3 )';
93 $queryParams[3] = [$params['campaign_id'], 'Positive'];
94 }
95 $whereClause = NULL;
96 if (!empty($where)) {
97 $whereClause = ' WHERE ' . implode(" \nAND ", $where);
98 }
99
100 $selectClause = '
101 SELECT petition.id as id,
102 petition.title as title,
103 petition.is_active as is_active,
104 petition.result_id as result_id,
105 petition.is_default as is_default,
106 petition.campaign_id as campaign_id,
107 petition.activity_type_id as activity_type_id';
108
109 if ($onlyCount) {
110 $selectClause = 'SELECT COUNT(*)';
111 }
112 $fromClause = 'FROM civicrm_survey petition';
113
114 $query = "{$selectClause} {$fromClause} {$whereClause} {$orderByClause} {$limitClause}";
115
116 if ($onlyCount) {
117 return (int) CRM_Core_DAO::singleValueQuery($query, $queryParams);
118 }
119
120 $petitions = [];
121 $properties = [
122 'id',
123 'title',
124 'campaign_id',
125 'is_active',
126 'is_default',
127 'result_id',
128 'activity_type_id',
129 ];
130
131 $petition = CRM_Core_DAO::executeQuery($query, $queryParams);
132 while ($petition->fetch()) {
133 foreach ($properties as $property) {
134 $petitions[$petition->id][$property] = $petition->$property;
135 }
136 }
137
138 return $petitions;
139 }
140
141 /**
142 * Get the petition count.
143 *
144 */
145 public static function getPetitionCount() {
146 $whereClause = 'WHERE ( 1 )';
147 $queryParams = [];
148 $petitionTypeID = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Petition');
149 if ($petitionTypeID) {
150 $whereClause = "WHERE ( petition.activity_type_id = %1 )";
151 $queryParams[1] = [$petitionTypeID, 'Positive'];
152 }
153 $query = "SELECT COUNT(*) FROM civicrm_survey petition {$whereClause}";
154
155 return (int) CRM_Core_DAO::singleValueQuery($query, $queryParams);
156 }
157
158 /**
159 * Takes an associative array and creates a petition signature activity.
160 *
161 * @param array $params
162 * (reference ) an assoc array of name/value pairs.
163 *
164 * @return mixed
165 * CRM_Campaign_BAO_Petition or NULl or void
166 */
167 public function createSignature(&$params) {
168 if (empty($params)) {
169 return NULL;
170 }
171
172 if (!isset($params['sid'])) {
173 $statusMsg = ts('No survey sid parameter. Cannot process signature.');
174 CRM_Core_Session::setStatus($statusMsg, ts('Sorry'), 'error');
175 return;
176 }
177
178 if (isset($params['contactId'])) {
179
180 // add signature as activity with survey id as source id
181 // get the activity type id associated with this survey
182 $surveyInfo = CRM_Campaign_BAO_Petition::getSurveyInfo($params['sid']);
183
184 // create activity
185 // 1-Schedule, 2-Completed
186
187 $activityParams = [
188 'source_contact_id' => $params['contactId'],
189 'target_contact_id' => $params['contactId'],
190 'source_record_id' => $params['sid'],
191 'subject' => $surveyInfo['title'],
192 'activity_type_id' => $surveyInfo['activity_type_id'],
193 'activity_date_time' => date("YmdHis"),
194 'status_id' => $params['statusId'],
195 'activity_campaign_id' => $params['activity_campaign_id'],
196 ];
197
198 //activity creation
199 // *** check for activity using source id - if already signed
200 $activity = CRM_Activity_BAO_Activity::create($activityParams);
201
202 // save activity custom data
203 if (!empty($params['custom']) &&
204 is_array($params['custom'])
205 ) {
206 CRM_Core_BAO_CustomValueTable::store($params['custom'], 'civicrm_activity', $activity->id);
207 }
208
209 // Set browser cookie to indicate this petition was already signed.
210 $config = CRM_Core_Config::singleton();
211 $url_parts = parse_url($config->userFrameworkBaseURL);
212 setcookie('signed_' . $params['sid'], $activity->id, time() + $this->cookieExpire, $url_parts['path'], $url_parts['host'], CRM_Utils_System::isSSL());
213 }
214
215 return $activity;
216 }
217
218 /**
219 * @param int $activity_id
220 * @param int $contact_id
221 * @param int $petition_id
222 *
223 * @return bool
224 */
225 public function confirmSignature($activity_id, $contact_id, $petition_id) {
226 // change activity status to completed (status_id = 2)
227 // I wonder why do we need contact_id when we have activity_id anyway? [chastell]
228 $sql = 'UPDATE civicrm_activity SET status_id = 2 WHERE id = %1';
229 $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate');
230 $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts);
231 $params = [
232 1 => [$activity_id, 'Integer'],
233 2 => [$contact_id, 'Integer'],
234 3 => [$sourceID, 'Integer'],
235 ];
236 CRM_Core_DAO::executeQuery($sql, $params);
237
238 $sql = 'UPDATE civicrm_activity_contact SET contact_id = %2 WHERE activity_id = %1 AND record_type_id = %3';
239 CRM_Core_DAO::executeQuery($sql, $params);
240 // remove 'Unconfirmed' tag for this contact
241 $tag_name = Civi::settings()->get('tag_unconfirmed');
242
243 $sql = "
244 DELETE FROM civicrm_entity_tag
245 WHERE entity_table = 'civicrm_contact'
246 AND entity_id = %1
247 AND tag_id = ( SELECT id FROM civicrm_tag WHERE name = %2 )";
248 $params = [
249 1 => [$contact_id, 'Integer'],
250 2 => [$tag_name, 'String'],
251 ];
252 CRM_Core_DAO::executeQuery($sql, $params);
253 // validate arguments to setcookie are numeric to prevent header manipulation
254 if (isset($petition_id) && is_numeric($petition_id)
255 && isset($activity_id) && is_numeric($activity_id)) {
256 // set permanent cookie to indicate this users email address now confirmed
257 $config = CRM_Core_Config::singleton();
258 $url_parts = parse_url($config->userFrameworkBaseURL);
259 setcookie("confirmed_{$petition_id}",
260 $activity_id,
261 time() + $this->cookieExpire,
262 $url_parts['path'],
263 $url_parts['host'],
264 CRM_Utils_System::isSSL()
265 );
266 return TRUE;
267 }
268 else {
269 throw new CRM_Core_Exception(ts('Petition Id and/or Activity Id is not of the type Positive.'));
270 }
271 }
272
273 /**
274 * Get Petition Signature Total.
275 *
276 * @param int $surveyId
277 *
278 * @return array
279 */
280 public static function getPetitionSignatureTotalbyCountry($surveyId) {
281 $countries = [];
282 $sql = "
283 SELECT count(civicrm_address.country_id) as total,
284 IFNULL(country_id,'') as country_id,IFNULL(iso_code,'') as country_iso, IFNULL(civicrm_country.name,'') as country
285 FROM ( civicrm_activity a, civicrm_survey, civicrm_contact )
286 LEFT JOIN civicrm_address ON civicrm_address.contact_id = civicrm_contact.id AND civicrm_address.is_primary = 1
287 LEFT JOIN civicrm_country ON civicrm_address.country_id = civicrm_country.id
288 LEFT JOIN civicrm_activity_contact ac ON ( ac.activity_id = a.id AND ac.record_type_id = %2 )
289 WHERE
290 ac.contact_id = civicrm_contact.id AND
291 a.activity_type_id = civicrm_survey.activity_type_id AND
292 civicrm_survey.id = %1 AND
293 a.source_record_id = %1 ";
294
295 $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate');
296 $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts);
297 $params = [
298 1 => [$surveyId, 'Integer'],
299 2 => [$sourceID, 'Integer'],
300 ];
301 $sql .= " GROUP BY civicrm_address.country_id";
302 $fields = ['total', 'country_id', 'country_iso', 'country'];
303
304 $dao = CRM_Core_DAO::executeQuery($sql, $params);
305 while ($dao->fetch()) {
306 $row = [];
307 foreach ($fields as $field) {
308 $row[$field] = $dao->$field;
309 }
310 $countries[] = $row;
311 }
312 return $countries;
313 }
314
315 /**
316 * Get Petition Signature Total.
317 *
318 * @param int $surveyId
319 *
320 * @return array
321 */
322 public static function getPetitionSignatureTotal($surveyId) {
323 $surveyInfo = CRM_Campaign_BAO_Petition::getSurveyInfo((int) $surveyId);
324 //$activityTypeID = $surveyInfo['activity_type_id'];
325 $sql = "
326 SELECT
327 status_id,count(id) as total
328 FROM civicrm_activity
329 WHERE
330 source_record_id = " . (int) $surveyId . " AND activity_type_id = " . (int) $surveyInfo['activity_type_id'] . " GROUP BY status_id";
331
332 $statusTotal = [];
333 $total = 0;
334 $dao = CRM_Core_DAO::executeQuery($sql);
335 while ($dao->fetch()) {
336 $total += $dao->total;
337 $statusTotal['status'][$dao->status_id] = $dao->total;
338 }
339 $statusTotal['count'] = $total;
340 return $statusTotal;
341 }
342
343 /**
344 * @param int $surveyId
345 *
346 * @return array
347 */
348 public static function getSurveyInfo($surveyId = NULL) {
349 $surveyInfo = [];
350
351 $sql = "
352 SELECT activity_type_id,
353 campaign_id,
354 s.title,
355 ov.label AS activity_type
356 FROM civicrm_survey s, civicrm_option_value ov, civicrm_option_group og
357 WHERE s.id = " . (int) $surveyId . "
358 AND s.activity_type_id = ov.value
359 AND ov.option_group_id = og.id
360 AND og.name = 'activity_type'";
361
362 $dao = CRM_Core_DAO::executeQuery($sql);
363 while ($dao->fetch()) {
364 //$survey['campaign_id'] = $dao->campaign_id;
365 //$survey['campaign_name'] = $dao->campaign_name;
366 $surveyInfo['activity_type'] = $dao->activity_type;
367 $surveyInfo['activity_type_id'] = $dao->activity_type_id;
368 $surveyInfo['title'] = $dao->title;
369 }
370
371 return $surveyInfo;
372 }
373
374 /**
375 * Get Petition Signature Details.
376 *
377 * @param int $surveyId
378 * @param int $status_id
379 *
380 * @return array
381 */
382 public static function getPetitionSignature($surveyId, $status_id = NULL) {
383
384 // sql injection protection
385 $surveyId = (int) $surveyId;
386 $signature = [];
387
388 $sql = "
389 SELECT a.id,
390 a.source_record_id as survey_id,
391 a.activity_date_time,
392 a.status_id,
393 civicrm_contact.id as contact_id,
394 civicrm_contact.contact_type,civicrm_contact.contact_sub_type,image_URL,
395 first_name,last_name,sort_name,
396 employer_id,organization_name,
397 household_name,
398 IFNULL(gender_id,'') AS gender_id,
399 IFNULL(state_province_id,'') AS state_province_id,
400 IFNULL(country_id,'') as country_id,IFNULL(iso_code,'') as country_iso, IFNULL(civicrm_country.name,'') as country
401 FROM (civicrm_activity a, civicrm_survey, civicrm_contact )
402 LEFT JOIN civicrm_activity_contact ac ON ( ac.activity_id = a.id AND ac.record_type_id = %3 )
403 LEFT JOIN civicrm_address ON civicrm_address.contact_id = civicrm_contact.id AND civicrm_address.is_primary = 1
404 LEFT JOIN civicrm_country ON civicrm_address.country_id = civicrm_country.id
405 WHERE
406 ac.contact_id = civicrm_contact.id AND
407 a.activity_type_id = civicrm_survey.activity_type_id AND
408 civicrm_survey.id = %1 AND
409 a.source_record_id = %1 ";
410
411 $params = [1 => [$surveyId, 'Integer']];
412
413 if ($status_id) {
414 $sql .= " AND status_id = %2";
415 $params[2] = [$status_id, 'Integer'];
416 }
417 $sql .= " ORDER BY a.activity_date_time";
418
419 $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate');
420 $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts);
421 $params[3] = [$sourceID, 'Integer'];
422
423 $fields = [
424 'id',
425 'survey_id',
426 'contact_id',
427 'activity_date_time',
428 'activity_type_id',
429 'status_id',
430 'first_name',
431 'last_name',
432 'sort_name',
433 'gender_id',
434 'country_id',
435 'state_province_id',
436 'country_iso',
437 'country',
438 ];
439
440 $dao = CRM_Core_DAO::executeQuery($sql, $params);
441 while ($dao->fetch()) {
442 $row = [];
443 foreach ($fields as $field) {
444 $row[$field] = $dao->$field;
445 }
446 $signature[] = $row;
447 }
448 return $signature;
449 }
450
451 /**
452 * This function returns all entities assigned to a specific tag.
453 *
454 * @param object $tag
455 * An object of a tag.
456 *
457 * @return array
458 * array of contact ids
459 */
460 public function getEntitiesByTag($tag) {
461 $contactIds = [];
462 $entityTagDAO = new CRM_Core_DAO_EntityTag();
463 $entityTagDAO->tag_id = $tag['id'];
464 $entityTagDAO->find();
465
466 while ($entityTagDAO->fetch()) {
467 $contactIds[] = $entityTagDAO->entity_id;
468 }
469 return $contactIds;
470 }
471
472 /**
473 * Check if contact has signed this petition.
474 *
475 * @param int $surveyId
476 * @param int $contactId
477 *
478 * @return array
479 */
480 public static function checkSignature($surveyId, $contactId) {
481
482 $surveyInfo = CRM_Campaign_BAO_Petition::getSurveyInfo($surveyId);
483 $signature = [];
484 $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate');
485 $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts);
486
487 $sql = "
488 SELECT a.id AS id,
489 a.source_record_id AS source_record_id,
490 ac.contact_id AS source_contact_id,
491 a.activity_date_time AS activity_date_time,
492 a.activity_type_id AS activity_type_id,
493 a.status_id AS status_id,
494 %1 AS survey_title
495 FROM civicrm_activity a
496 INNER JOIN civicrm_activity_contact ac ON (ac.activity_id = a.id AND ac.record_type_id = %5)
497 WHERE a.source_record_id = %2
498 AND a.activity_type_id = %3
499 AND ac.contact_id = %4
500 ";
501 $params = [
502 1 => [$surveyInfo['title'], 'String'],
503 2 => [$surveyId, 'Integer'],
504 3 => [$surveyInfo['activity_type_id'], 'Integer'],
505 4 => [$contactId, 'Integer'],
506 5 => [$sourceID, 'Integer'],
507 ];
508
509 $dao = CRM_Core_DAO::executeQuery($sql, $params);
510 while ($dao->fetch()) {
511 $signature[$dao->id]['id'] = $dao->id;
512 $signature[$dao->id]['source_record_id'] = $dao->source_record_id;
513 $signature[$dao->id]['source_contact_id'] = CRM_Contact_BAO_Contact::displayName($dao->source_contact_id);
514 $signature[$dao->id]['activity_date_time'] = $dao->activity_date_time;
515 $signature[$dao->id]['activity_type_id'] = $dao->activity_type_id;
516 $signature[$dao->id]['status_id'] = $dao->status_id;
517 $signature[$dao->id]['survey_title'] = $dao->survey_title;
518 $signature[$dao->id]['contactId'] = $dao->source_contact_id;
519 }
520
521 return $signature;
522 }
523
524 /**
525 * Takes an associative array and sends a thank you or email verification email.
526 *
527 * @param array $params
528 * (reference ) an assoc array of name/value pairs.
529 *
530 * @param int $sendEmailMode
531 *
532 * @throws Exception
533 */
534 public static function sendEmail($params, $sendEmailMode) {
535
536 /* sendEmailMode
537 * CRM_Campaign_Form_Petition_Signature::EMAIL_THANK
538 * connected user via login/pwd - thank you
539 * or dedupe contact matched who doesn't have a tag CIVICRM_TAG_UNCONFIRMED - thank you
540 * or login using fb connect - thank you + click to add msg to fb wall
541 *
542 * CRM_Campaign_Form_Petition_Signature::EMAIL_CONFIRM
543 * send a confirmation request email
544 */
545
546 // check if the group defined by CIVICRM_PETITION_CONTACTS exists, else create it
547 $petitionGroupName = Civi::settings()->get('petition_contacts');
548
549 $dao = new CRM_Contact_DAO_Group();
550 $dao->title = $petitionGroupName;
551 if (!$dao->find(TRUE)) {
552 $dao->is_active = 1;
553 $dao->visibility = 'User and User Admin Only';
554 $dao->save();
555 }
556 $group_id = $dao->id;
557
558 // get petition info
559 $petitionParams['id'] = $params['sid'];
560 $petitionInfo = [];
561 CRM_Campaign_BAO_Survey::retrieve($petitionParams, $petitionInfo);
562 if (empty($petitionInfo)) {
563 throw new CRM_Core_Exception('Petition doesn\'t exist.');
564 }
565
566 //get the default domain email address.
567 list($domainEmailName, $domainEmailAddress) = CRM_Core_BAO_Domain::getNameAndEmail();
568
569 $emailDomain = CRM_Core_BAO_MailSettings::defaultDomain();
570
571 $toName = CRM_Contact_BAO_Contact::displayName($params['contactId']);
572
573 $replyTo = CRM_Core_BAO_Domain::getNoReplyEmailAddress();
574
575 // set additional general message template params (custom tokens to use in email msg templates)
576 // tokens then available in msg template as {$petition.title}, etc
577 $petitionTokens['title'] = $petitionInfo['title'];
578 $petitionTokens['petitionId'] = $params['sid'];
579 $tplParams['petition'] = $petitionTokens;
580
581 switch ($sendEmailMode) {
582 case CRM_Campaign_Form_Petition_Signature::EMAIL_THANK:
583
584 // add this contact to the CIVICRM_PETITION_CONTACTS group
585 // Cannot pass parameter 1 by reference
586 $p = [$params['contactId']];
587 CRM_Contact_BAO_GroupContact::addContactsToGroup($p, $group_id, 'API');
588
589 if ($params['email-Primary']) {
590 CRM_Core_BAO_MessageTemplate::sendTemplate(
591 [
592 'groupName' => 'msg_tpl_workflow_petition',
593 'valueName' => 'petition_sign',
594 'contactId' => $params['contactId'],
595 'tplParams' => $tplParams,
596 'from' => "\"{$domainEmailName}\" <{$domainEmailAddress}>",
597 'toName' => $toName,
598 'toEmail' => $params['email-Primary'],
599 'replyTo' => $replyTo,
600 'petitionId' => $params['sid'],
601 'petitionTitle' => $petitionInfo['title'],
602 ]
603 );
604 }
605 break;
606
607 case CRM_Campaign_Form_Petition_Signature::EMAIL_CONFIRM:
608 // create mailing event subscription record for this contact
609 // this will allow using a hash key to confirm email address by sending a url link
610 $se = CRM_Mailing_Event_BAO_Subscribe::subscribe($group_id,
611 $params['email-Primary'],
612 $params['contactId'],
613 'profile'
614 );
615
616 // require_once 'CRM/Core/BAO/Domain.php';
617 // $domain = CRM_Core_BAO_Domain::getDomain();
618 $config = CRM_Core_Config::singleton();
619 $localpart = CRM_Core_BAO_MailSettings::defaultLocalpart();
620
621 $replyTo = implode($config->verpSeparator,
622 [
623 $localpart . 'c',
624 $se->contact_id,
625 $se->id,
626 $se->hash,
627 ]
628 ) . "@$emailDomain";
629
630 $confirmUrl = CRM_Utils_System::url('civicrm/petition/confirm',
631 "reset=1&cid={$se->contact_id}&sid={$se->id}&h={$se->hash}&a={$params['activityId']}&pid={$params['sid']}",
632 TRUE
633 );
634 $confirmUrlPlainText = CRM_Utils_System::url('civicrm/petition/confirm',
635 "reset=1&cid={$se->contact_id}&sid={$se->id}&h={$se->hash}&a={$params['activityId']}&pid={$params['sid']}",
636 TRUE,
637 NULL,
638 FALSE
639 );
640
641 // set email specific message template params and assign to tplParams
642 $petitionTokens['confirmUrl'] = $confirmUrl;
643 $petitionTokens['confirmUrlPlainText'] = $confirmUrlPlainText;
644 $tplParams['petition'] = $petitionTokens;
645
646 if ($params['email-Primary']) {
647 CRM_Core_BAO_MessageTemplate::sendTemplate(
648 [
649 'groupName' => 'msg_tpl_workflow_petition',
650 'valueName' => 'petition_confirmation_needed',
651 'contactId' => $params['contactId'],
652 'tplParams' => $tplParams,
653 'from' => "\"{$domainEmailName}\" <{$domainEmailAddress}>",
654 'toName' => $toName,
655 'toEmail' => $params['email-Primary'],
656 'replyTo' => $replyTo,
657 'petitionId' => $params['sid'],
658 'petitionTitle' => $petitionInfo['title'],
659 'confirmUrl' => $confirmUrl,
660 ]
661 );
662 }
663 break;
664 }
665 }
666
667 }