Merge pull request #16004 from civicrm/5.20
[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 CRM_Core_Error::fatal(ts('Petition Id and/or Activity Id is not of the type Positive.'));
270 return FALSE;
271 }
272 }
273
274 /**
275 * Get Petition Signature Total.
276 *
277 * @param int $surveyId
278 *
279 * @return array
280 */
281 public static function getPetitionSignatureTotalbyCountry($surveyId) {
282 $countries = [];
283 $sql = "
284 SELECT count(civicrm_address.country_id) as total,
285 IFNULL(country_id,'') as country_id,IFNULL(iso_code,'') as country_iso, IFNULL(civicrm_country.name,'') as country
286 FROM ( civicrm_activity a, civicrm_survey, civicrm_contact )
287 LEFT JOIN civicrm_address ON civicrm_address.contact_id = civicrm_contact.id AND civicrm_address.is_primary = 1
288 LEFT JOIN civicrm_country ON civicrm_address.country_id = civicrm_country.id
289 LEFT JOIN civicrm_activity_contact ac ON ( ac.activity_id = a.id AND ac.record_type_id = %2 )
290 WHERE
291 ac.contact_id = civicrm_contact.id AND
292 a.activity_type_id = civicrm_survey.activity_type_id AND
293 civicrm_survey.id = %1 AND
294 a.source_record_id = %1 ";
295
296 $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate');
297 $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts);
298 $params = [
299 1 => [$surveyId, 'Integer'],
300 2 => [$sourceID, 'Integer'],
301 ];
302 $sql .= " GROUP BY civicrm_address.country_id";
303 $fields = ['total', 'country_id', 'country_iso', 'country'];
304
305 $dao = CRM_Core_DAO::executeQuery($sql, $params);
306 while ($dao->fetch()) {
307 $row = [];
308 foreach ($fields as $field) {
309 $row[$field] = $dao->$field;
310 }
311 $countries[] = $row;
312 }
313 return $countries;
314 }
315
316 /**
317 * Get Petition Signature Total.
318 *
319 * @param int $surveyId
320 *
321 * @return array
322 */
323 public static function getPetitionSignatureTotal($surveyId) {
324 $surveyInfo = CRM_Campaign_BAO_Petition::getSurveyInfo((int) $surveyId);
325 //$activityTypeID = $surveyInfo['activity_type_id'];
326 $sql = "
327 SELECT
328 status_id,count(id) as total
329 FROM civicrm_activity
330 WHERE
331 source_record_id = " . (int) $surveyId . " AND activity_type_id = " . (int) $surveyInfo['activity_type_id'] . " GROUP BY status_id";
332
333 $statusTotal = [];
334 $total = 0;
335 $dao = CRM_Core_DAO::executeQuery($sql);
336 while ($dao->fetch()) {
337 $total += $dao->total;
338 $statusTotal['status'][$dao->status_id] = $dao->total;
339 }
340 $statusTotal['count'] = $total;
341 return $statusTotal;
342 }
343
344 /**
345 * @param int $surveyId
346 *
347 * @return array
348 */
349 public static function getSurveyInfo($surveyId = NULL) {
350 $surveyInfo = [];
351
352 $sql = "
353 SELECT activity_type_id,
354 campaign_id,
355 s.title,
356 ov.label AS activity_type
357 FROM civicrm_survey s, civicrm_option_value ov, civicrm_option_group og
358 WHERE s.id = " . (int) $surveyId . "
359 AND s.activity_type_id = ov.value
360 AND ov.option_group_id = og.id
361 AND og.name = 'activity_type'";
362
363 $dao = CRM_Core_DAO::executeQuery($sql);
364 while ($dao->fetch()) {
365 //$survey['campaign_id'] = $dao->campaign_id;
366 //$survey['campaign_name'] = $dao->campaign_name;
367 $surveyInfo['activity_type'] = $dao->activity_type;
368 $surveyInfo['activity_type_id'] = $dao->activity_type_id;
369 $surveyInfo['title'] = $dao->title;
370 }
371
372 return $surveyInfo;
373 }
374
375 /**
376 * Get Petition Signature Details.
377 *
378 * @param int $surveyId
379 * @param int $status_id
380 *
381 * @return array
382 */
383 public static function getPetitionSignature($surveyId, $status_id = NULL) {
384
385 // sql injection protection
386 $surveyId = (int) $surveyId;
387 $signature = [];
388
389 $sql = "
390 SELECT a.id,
391 a.source_record_id as survey_id,
392 a.activity_date_time,
393 a.status_id,
394 civicrm_contact.id as contact_id,
395 civicrm_contact.contact_type,civicrm_contact.contact_sub_type,image_URL,
396 first_name,last_name,sort_name,
397 employer_id,organization_name,
398 household_name,
399 IFNULL(gender_id,'') AS gender_id,
400 IFNULL(state_province_id,'') AS state_province_id,
401 IFNULL(country_id,'') as country_id,IFNULL(iso_code,'') as country_iso, IFNULL(civicrm_country.name,'') as country
402 FROM (civicrm_activity a, civicrm_survey, civicrm_contact )
403 LEFT JOIN civicrm_activity_contact ac ON ( ac.activity_id = a.id AND ac.record_type_id = %3 )
404 LEFT JOIN civicrm_address ON civicrm_address.contact_id = civicrm_contact.id AND civicrm_address.is_primary = 1
405 LEFT JOIN civicrm_country ON civicrm_address.country_id = civicrm_country.id
406 WHERE
407 ac.contact_id = civicrm_contact.id AND
408 a.activity_type_id = civicrm_survey.activity_type_id AND
409 civicrm_survey.id = %1 AND
410 a.source_record_id = %1 ";
411
412 $params = [1 => [$surveyId, 'Integer']];
413
414 if ($status_id) {
415 $sql .= " AND status_id = %2";
416 $params[2] = [$status_id, 'Integer'];
417 }
418 $sql .= " ORDER BY a.activity_date_time";
419
420 $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate');
421 $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts);
422 $params[3] = [$sourceID, 'Integer'];
423
424 $fields = [
425 'id',
426 'survey_id',
427 'contact_id',
428 'activity_date_time',
429 'activity_type_id',
430 'status_id',
431 'first_name',
432 'last_name',
433 'sort_name',
434 'gender_id',
435 'country_id',
436 'state_province_id',
437 'country_iso',
438 'country',
439 ];
440
441 $dao = CRM_Core_DAO::executeQuery($sql, $params);
442 while ($dao->fetch()) {
443 $row = [];
444 foreach ($fields as $field) {
445 $row[$field] = $dao->$field;
446 }
447 $signature[] = $row;
448 }
449 return $signature;
450 }
451
452 /**
453 * This function returns all entities assigned to a specific tag.
454 *
455 * @param object $tag
456 * An object of a tag.
457 *
458 * @return array
459 * array of contact ids
460 */
461 public function getEntitiesByTag($tag) {
462 $contactIds = [];
463 $entityTagDAO = new CRM_Core_DAO_EntityTag();
464 $entityTagDAO->tag_id = $tag['id'];
465 $entityTagDAO->find();
466
467 while ($entityTagDAO->fetch()) {
468 $contactIds[] = $entityTagDAO->entity_id;
469 }
470 return $contactIds;
471 }
472
473 /**
474 * Check if contact has signed this petition.
475 *
476 * @param int $surveyId
477 * @param int $contactId
478 *
479 * @return array
480 */
481 public static function checkSignature($surveyId, $contactId) {
482
483 $surveyInfo = CRM_Campaign_BAO_Petition::getSurveyInfo($surveyId);
484 $signature = [];
485 $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate');
486 $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts);
487
488 $sql = "
489 SELECT a.id AS id,
490 a.source_record_id AS source_record_id,
491 ac.contact_id AS source_contact_id,
492 a.activity_date_time AS activity_date_time,
493 a.activity_type_id AS activity_type_id,
494 a.status_id AS status_id,
495 %1 AS survey_title
496 FROM civicrm_activity a
497 INNER JOIN civicrm_activity_contact ac ON (ac.activity_id = a.id AND ac.record_type_id = %5)
498 WHERE a.source_record_id = %2
499 AND a.activity_type_id = %3
500 AND ac.contact_id = %4
501 ";
502 $params = [
503 1 => [$surveyInfo['title'], 'String'],
504 2 => [$surveyId, 'Integer'],
505 3 => [$surveyInfo['activity_type_id'], 'Integer'],
506 4 => [$contactId, 'Integer'],
507 5 => [$sourceID, 'Integer'],
508 ];
509
510 $dao = CRM_Core_DAO::executeQuery($sql, $params);
511 while ($dao->fetch()) {
512 $signature[$dao->id]['id'] = $dao->id;
513 $signature[$dao->id]['source_record_id'] = $dao->source_record_id;
514 $signature[$dao->id]['source_contact_id'] = CRM_Contact_BAO_Contact::displayName($dao->source_contact_id);
515 $signature[$dao->id]['activity_date_time'] = $dao->activity_date_time;
516 $signature[$dao->id]['activity_type_id'] = $dao->activity_type_id;
517 $signature[$dao->id]['status_id'] = $dao->status_id;
518 $signature[$dao->id]['survey_title'] = $dao->survey_title;
519 $signature[$dao->id]['contactId'] = $dao->source_contact_id;
520 }
521
522 return $signature;
523 }
524
525 /**
526 * Takes an associative array and sends a thank you or email verification email.
527 *
528 * @param array $params
529 * (reference ) an assoc array of name/value pairs.
530 *
531 * @param int $sendEmailMode
532 *
533 * @throws Exception
534 */
535 public static function sendEmail($params, $sendEmailMode) {
536
537 /* sendEmailMode
538 * CRM_Campaign_Form_Petition_Signature::EMAIL_THANK
539 * connected user via login/pwd - thank you
540 * or dedupe contact matched who doesn't have a tag CIVICRM_TAG_UNCONFIRMED - thank you
541 * or login using fb connect - thank you + click to add msg to fb wall
542 *
543 * CRM_Campaign_Form_Petition_Signature::EMAIL_CONFIRM
544 * send a confirmation request email
545 */
546
547 // check if the group defined by CIVICRM_PETITION_CONTACTS exists, else create it
548 $petitionGroupName = Civi::settings()->get('petition_contacts');
549
550 $dao = new CRM_Contact_DAO_Group();
551 $dao->title = $petitionGroupName;
552 if (!$dao->find(TRUE)) {
553 $dao->is_active = 1;
554 $dao->visibility = 'User and User Admin Only';
555 $dao->save();
556 }
557 $group_id = $dao->id;
558
559 // get petition info
560 $petitionParams['id'] = $params['sid'];
561 $petitionInfo = [];
562 CRM_Campaign_BAO_Survey::retrieve($petitionParams, $petitionInfo);
563 if (empty($petitionInfo)) {
564 CRM_Core_Error::fatal('Petition doesn\'t exist.');
565 }
566
567 //get the default domain email address.
568 list($domainEmailName, $domainEmailAddress) = CRM_Core_BAO_Domain::getNameAndEmail();
569
570 $emailDomain = CRM_Core_BAO_MailSettings::defaultDomain();
571
572 $toName = CRM_Contact_BAO_Contact::displayName($params['contactId']);
573
574 $replyTo = CRM_Core_BAO_Domain::getNoReplyEmailAddress();
575
576 // set additional general message template params (custom tokens to use in email msg templates)
577 // tokens then available in msg template as {$petition.title}, etc
578 $petitionTokens['title'] = $petitionInfo['title'];
579 $petitionTokens['petitionId'] = $params['sid'];
580 $tplParams['petition'] = $petitionTokens;
581
582 switch ($sendEmailMode) {
583 case CRM_Campaign_Form_Petition_Signature::EMAIL_THANK:
584
585 // add this contact to the CIVICRM_PETITION_CONTACTS group
586 // Cannot pass parameter 1 by reference
587 $p = [$params['contactId']];
588 CRM_Contact_BAO_GroupContact::addContactsToGroup($p, $group_id, 'API');
589
590 if ($params['email-Primary']) {
591 CRM_Core_BAO_MessageTemplate::sendTemplate(
592 [
593 'groupName' => 'msg_tpl_workflow_petition',
594 'valueName' => 'petition_sign',
595 'contactId' => $params['contactId'],
596 'tplParams' => $tplParams,
597 'from' => "\"{$domainEmailName}\" <{$domainEmailAddress}>",
598 'toName' => $toName,
599 'toEmail' => $params['email-Primary'],
600 'replyTo' => $replyTo,
601 'petitionId' => $params['sid'],
602 'petitionTitle' => $petitionInfo['title'],
603 ]
604 );
605 }
606 break;
607
608 case CRM_Campaign_Form_Petition_Signature::EMAIL_CONFIRM:
609 // create mailing event subscription record for this contact
610 // this will allow using a hash key to confirm email address by sending a url link
611 $se = CRM_Mailing_Event_BAO_Subscribe::subscribe($group_id,
612 $params['email-Primary'],
613 $params['contactId'],
614 'profile'
615 );
616
617 // require_once 'CRM/Core/BAO/Domain.php';
618 // $domain = CRM_Core_BAO_Domain::getDomain();
619 $config = CRM_Core_Config::singleton();
620 $localpart = CRM_Core_BAO_MailSettings::defaultLocalpart();
621
622 $replyTo = implode($config->verpSeparator,
623 [
624 $localpart . 'c',
625 $se->contact_id,
626 $se->id,
627 $se->hash,
628 ]
629 ) . "@$emailDomain";
630
631 $confirmUrl = CRM_Utils_System::url('civicrm/petition/confirm',
632 "reset=1&cid={$se->contact_id}&sid={$se->id}&h={$se->hash}&a={$params['activityId']}&pid={$params['sid']}",
633 TRUE
634 );
635 $confirmUrlPlainText = CRM_Utils_System::url('civicrm/petition/confirm',
636 "reset=1&cid={$se->contact_id}&sid={$se->id}&h={$se->hash}&a={$params['activityId']}&pid={$params['sid']}",
637 TRUE,
638 NULL,
639 FALSE
640 );
641
642 // set email specific message template params and assign to tplParams
643 $petitionTokens['confirmUrl'] = $confirmUrl;
644 $petitionTokens['confirmUrlPlainText'] = $confirmUrlPlainText;
645 $tplParams['petition'] = $petitionTokens;
646
647 if ($params['email-Primary']) {
648 CRM_Core_BAO_MessageTemplate::sendTemplate(
649 [
650 'groupName' => 'msg_tpl_workflow_petition',
651 'valueName' => 'petition_confirmation_needed',
652 'contactId' => $params['contactId'],
653 'tplParams' => $tplParams,
654 'from' => "\"{$domainEmailName}\" <{$domainEmailAddress}>",
655 'toName' => $toName,
656 'toEmail' => $params['email-Primary'],
657 'replyTo' => $replyTo,
658 'petitionId' => $params['sid'],
659 'petitionTitle' => $petitionInfo['title'],
660 'confirmUrl' => $confirmUrl,
661 ]
662 );
663 }
664 break;
665 }
666 }
667
668 }