Merge pull request #15976 from eileenmcnaughton/5.20
[civicrm-core.git] / CRM / Contribute / BAO / ContributionSoft.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2019 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
9 | |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
13 | |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
18 | |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
26 */
27
28 /**
29 *
30 * @package CRM
31 * @copyright CiviCRM LLC (c) 2004-2019
32 */
33 class CRM_Contribute_BAO_ContributionSoft extends CRM_Contribute_DAO_ContributionSoft {
34
35 /**
36 * Construct method.
37 */
38 public function __construct() {
39 parent::__construct();
40 }
41
42 /**
43 * Add contribution soft credit record.
44 *
45 * @param array $params
46 * (reference ) an assoc array of name/value pairs.
47 *
48 * @return object
49 * soft contribution of object that is added
50 */
51 public static function add(&$params) {
52 $contributionSoft = new CRM_Contribute_DAO_ContributionSoft();
53 $contributionSoft->copyValues($params);
54
55 // set currency for CRM-1496
56 if (!isset($contributionSoft->currency)) {
57 $config = CRM_Core_Config::singleton();
58 $contributionSoft->currency = $config->defaultCurrency;
59 }
60 return $contributionSoft->save();
61 }
62
63 /**
64 * Process the soft contribution and/or link to personal campaign page.
65 *
66 * @param array $params
67 * @param object $contribution CRM_Contribute_DAO_Contribution
68 *
69 */
70 public static function processSoftContribution($params, $contribution) {
71 //retrieve existing soft-credit and pcp id(s) if any against $contribution
72 $softIDs = self::getSoftCreditIds($contribution->id);
73 $pcpId = self::getSoftCreditIds($contribution->id, TRUE);
74
75 if ($pcp = CRM_Utils_Array::value('pcp', $params)) {
76 $softParams = array();
77 $softParams['id'] = $pcpId ? $pcpId : NULL;
78 $softParams['contribution_id'] = $contribution->id;
79 $softParams['pcp_id'] = $pcp['pcp_made_through_id'];
80 $softParams['contact_id'] = CRM_Core_DAO::getFieldValue('CRM_PCP_DAO_PCP',
81 $pcp['pcp_made_through_id'], 'contact_id'
82 );
83 $softParams['currency'] = $contribution->currency;
84 $softParams['amount'] = $contribution->total_amount;
85 $softParams['pcp_display_in_roll'] = CRM_Utils_Array::value('pcp_display_in_roll', $pcp);
86 $softParams['pcp_roll_nickname'] = CRM_Utils_Array::value('pcp_roll_nickname', $pcp);
87 $softParams['pcp_personal_note'] = CRM_Utils_Array::value('pcp_personal_note', $pcp);
88 $softParams['soft_credit_type_id'] = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_ContributionSoft', 'soft_credit_type_id', 'pcp');
89 $contributionSoft = self::add($softParams);
90 //Send notification to owner for PCP
91 if ($contributionSoft->pcp_id && empty($pcpId)) {
92 CRM_Contribute_Form_Contribution_Confirm::pcpNotifyOwner($contribution, $contributionSoft);
93 }
94 }
95 //Delete PCP against this contribution and create new on submitted PCP information
96 elseif (array_key_exists('pcp', $params) && $pcpId) {
97 civicrm_api3('ContributionSoft', 'delete', array('id' => $pcpId));
98 }
99 if (isset($params['soft_credit'])) {
100 $softParams = $params['soft_credit'];
101 foreach ($softParams as $softParam) {
102 if (!empty($softIDs)) {
103 $key = key($softIDs);
104 $softParam['id'] = $softIDs[$key];
105 unset($softIDs[$key]);
106 }
107 $softParam['contribution_id'] = $contribution->id;
108 $softParam['currency'] = $contribution->currency;
109 //case during Contribution Import when we assign soft contribution amount as contribution's total_amount by default
110 if (empty($softParam['amount'])) {
111 $softParam['amount'] = $contribution->total_amount;
112 }
113 CRM_Contribute_BAO_ContributionSoft::add($softParam);
114 }
115
116 // delete any extra soft-credit while updating back-office contribution
117 foreach ((array) $softIDs as $softID) {
118 if (!in_array($softID, $params['soft_credit_ids'])) {
119 civicrm_api3('ContributionSoft', 'delete', array('id' => $softID));
120 }
121 }
122 }
123 }
124
125 /**
126 * Function used to save pcp / soft credit entry.
127 *
128 * This is used by contribution and also event pcps
129 *
130 * @param array $params
131 * @param object $form
132 * Form object.
133 */
134 public static function formatSoftCreditParams(&$params, &$form) {
135 $pcp = $softParams = $softIDs = array();
136 if (!empty($params['pcp_made_through_id'])) {
137 $fields = array(
138 'pcp_made_through_id',
139 'pcp_display_in_roll',
140 'pcp_roll_nickname',
141 'pcp_personal_note',
142 );
143 foreach ($fields as $f) {
144 $pcp[$f] = CRM_Utils_Array::value($f, $params);
145 }
146 }
147
148 if (!empty($form->_values['honoree_profile_id']) && !empty($params['soft_credit_type_id'])) {
149 $honorId = NULL;
150
151 // @todo fix use of deprecated function.
152 $contributionSoftParams['soft_credit_type_id'] = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_ContributionSoft', 'soft_credit_type_id', 'pcp');
153 //check if there is any duplicate contact
154 // honoree should never be the donor
155 $exceptKeys = array(
156 'contactID' => 0,
157 'onbehalf_contact_id' => 0,
158 );
159 $except = array_values(array_intersect_key($params, $exceptKeys));
160 $ids = CRM_Contact_BAO_Contact::getDuplicateContacts(
161 $params['honor'],
162 CRM_Core_BAO_UFGroup::getContactType($form->_values['honoree_profile_id']),
163 'Unsupervised',
164 $except,
165 FALSE
166 );
167 if (count($ids)) {
168 $honorId = CRM_Utils_Array::value(0, $ids);
169 }
170
171 $null = [];
172 $honorId = CRM_Contact_BAO_Contact::createProfileContact(
173 $params['honor'], $null,
174 $honorId, NULL,
175 $form->_values['honoree_profile_id']
176 );
177 $softParams[] = array(
178 'contact_id' => $honorId,
179 'soft_credit_type_id' => $params['soft_credit_type_id'],
180 );
181
182 if (CRM_Utils_Array::value('is_email_receipt', $form->_values)) {
183 $form->_values['honor'] = array(
184 'soft_credit_type' => CRM_Utils_Array::value(
185 $params['soft_credit_type_id'],
186 CRM_Core_OptionGroup::values("soft_credit_type")
187 ),
188 'honor_id' => $honorId,
189 'honor_profile_id' => $form->_values['honoree_profile_id'],
190 'honor_profile_values' => $params['honor'],
191 );
192 }
193 }
194 elseif (!empty($params['soft_credit_contact_id'])) {
195 //build soft credit params
196 foreach ($params['soft_credit_contact_id'] as $key => $val) {
197 if ($val && $params['soft_credit_amount'][$key]) {
198 $softParams[$key]['contact_id'] = $val;
199 $softParams[$key]['amount'] = CRM_Utils_Rule::cleanMoney($params['soft_credit_amount'][$key]);
200 $softParams[$key]['soft_credit_type_id'] = $params['soft_credit_type'][$key];
201 if (!empty($params['soft_credit_id'][$key])) {
202 $softIDs[] = $softParams[$key]['id'] = $params['soft_credit_id'][$key];
203 }
204 }
205 }
206 }
207
208 $params['pcp'] = !empty($pcp) ? $pcp : NULL;
209 $params['soft_credit'] = $softParams;
210 $params['soft_credit_ids'] = $softIDs;
211 }
212
213 /**
214 * Fetch object based on array of properties.
215 *
216 * @param array $params
217 * (reference ) an assoc array of name/value pairs.
218 * @param array $defaults
219 * (reference ) an assoc array to hold the flattened values.
220 *
221 * @return CRM_Contribute_BAO_ContributionSoft
222 */
223 public static function retrieve(&$params, &$defaults) {
224 $contributionSoft = new CRM_Contribute_DAO_ContributionSoft();
225 $contributionSoft->copyValues($params);
226 if ($contributionSoft->find(TRUE)) {
227 CRM_Core_DAO::storeValues($contributionSoft, $defaults);
228 return $contributionSoft;
229 }
230 return NULL;
231 }
232
233 /**
234 * @param int $contact_id
235 * @param int $isTest
236 *
237 * @return array
238 */
239 public static function getSoftContributionTotals($contact_id, $isTest = 0) {
240
241 $whereClause = "AND cc.cancel_date IS NULL";
242
243 $query = "
244 SELECT SUM(amount) as amount, AVG(total_amount) as average, cc.currency
245 FROM civicrm_contribution_soft ccs
246 LEFT JOIN civicrm_contribution cc ON ccs.contribution_id = cc.id
247 WHERE cc.is_test = %2 AND ccs.contact_id = %1 {$whereClause}
248 GROUP BY currency";
249
250 $params = array(
251 1 => array($contact_id, 'Integer'),
252 2 => array($isTest, 'Integer'),
253 );
254
255 $cs = CRM_Core_DAO::executeQuery($query, $params);
256
257 $count = $countCancelled = 0;
258 $amount = $average = $cancelAmount = array();
259
260 while ($cs->fetch()) {
261 if ($cs->amount > 0) {
262 $count++;
263 $amount[] = CRM_Utils_Money::format($cs->amount, $cs->currency);
264 $average[] = CRM_Utils_Money::format($cs->average, $cs->currency);
265 }
266 }
267
268 //to get cancel amount
269 $cancelAmountWhereClause = "AND cc.cancel_date IS NOT NULL";
270 $query = str_replace($whereClause, $cancelAmountWhereClause, $query);
271 $cancelAmountSQL = CRM_Core_DAO::executeQuery($query, $params);
272 while ($cancelAmountSQL->fetch()) {
273 if ($cancelAmountSQL->amount > 0) {
274 $countCancelled++;
275 $cancelAmount[] = CRM_Utils_Money::format($cancelAmountSQL->amount, $cancelAmountSQL->currency);
276 }
277 }
278
279 if ($count > 0 || $countCancelled > 0) {
280 return array(
281 $count,
282 $countCancelled,
283 implode(',&nbsp;', $amount),
284 implode(',&nbsp;', $average),
285 implode(',&nbsp;', $cancelAmount),
286 );
287 }
288 return array(0, 0);
289 }
290
291 /**
292 * Retrieve soft contributions for contribution record.
293 *
294 * @param int $contributionID
295 * @param bool $all
296 * Include PCP data.
297 *
298 * @return array
299 * Array of soft contribution ids, amounts, and associated contact ids
300 */
301 public static function getSoftContribution($contributionID, $all = FALSE) {
302 $softContributionFields = self::getSoftCreditContributionFields([$contributionID], $all);
303 return isset($softContributionFields[$contributionID]) ? $softContributionFields[$contributionID] : [];
304 }
305
306 /**
307 * Retrieve soft contributions for an array of contribution records.
308 *
309 * @param array $contributionIDs
310 * @param bool $all
311 * Include PCP data.
312 *
313 * @return array
314 * Array of soft contribution ids, amounts, and associated contact ids
315 */
316 public static function getSoftCreditContributionFields($contributionIDs, $all = FALSE) {
317 $pcpFields = [
318 'pcp_id',
319 'pcp_title',
320 'pcp_display_in_roll',
321 'pcp_roll_nickname',
322 'pcp_personal_note',
323 ];
324
325 $query = "
326 SELECT ccs.id, pcp_id, ccs.contribution_id as contribution_id, cpcp.title as pcp_title, pcp_display_in_roll, pcp_roll_nickname, pcp_personal_note, ccs.currency as currency, amount, ccs.contact_id as contact_id, c.display_name, ccs.soft_credit_type_id
327 FROM civicrm_contribution_soft ccs INNER JOIN civicrm_contact c on c.id = ccs.contact_id
328 LEFT JOIN civicrm_pcp cpcp ON ccs.pcp_id = cpcp.id
329 WHERE contribution_id IN (%1)
330 ";
331 $queryParams = [1 => [implode(',', $contributionIDs), 'CommaSeparatedIntegers']];
332 $dao = CRM_Core_DAO::executeQuery($query, $queryParams);
333
334 $softContribution = $indexes = [];
335 while ($dao->fetch()) {
336 if ($dao->pcp_id) {
337 if ($all) {
338 foreach ($pcpFields as $val) {
339 $softContribution[$dao->contribution_id][$val] = $dao->$val;
340 }
341 $softContribution[$dao->contribution_id]['pcp_soft_credit_to_name'] = $dao->display_name;
342 $softContribution[$dao->contribution_id]['pcp_soft_credit_to_id'] = $dao->contact_id;
343 }
344 }
345 else {
346 // Use a 1-based array because that's what this function returned before refactoring in https://github.com/civicrm/civicrm-core/pull/14747
347 $indexes[$dao->contribution_id] = isset($indexes[$dao->contribution_id]) ? $indexes[$dao->contribution_id] + 1 : 1;
348 $softContribution[$dao->contribution_id]['soft_credit'][$indexes[$dao->contribution_id]] = [
349 'contact_id' => $dao->contact_id,
350 'soft_credit_id' => $dao->id,
351 'currency' => $dao->currency,
352 'amount' => $dao->amount,
353 'contact_name' => $dao->display_name,
354 'soft_credit_type' => $dao->soft_credit_type_id,
355 'soft_credit_type_label' => CRM_Core_PseudoConstant::getLabel('CRM_Contribute_BAO_ContributionSoft', 'soft_credit_type_id', $dao->soft_credit_type_id),
356 ];
357 }
358 }
359
360 return $softContribution;
361 }
362
363 /**
364 * @param int $contributionID
365 * @param bool $isPCP
366 *
367 * @return array
368 */
369 public static function getSoftCreditIds($contributionID, $isPCP = FALSE) {
370 $query = "
371 SELECT id
372 FROM civicrm_contribution_soft
373 WHERE contribution_id = %1
374 ";
375
376 if ($isPCP) {
377 $query .= " AND pcp_id IS NOT NULL";
378 }
379 else {
380 $query .= " AND pcp_id IS NULL";
381 }
382 $params = array(1 => array($contributionID, 'Integer'));
383
384 $dao = CRM_Core_DAO::executeQuery($query, $params);
385 $id = array();
386 $type = '';
387 while ($dao->fetch()) {
388 if ($isPCP) {
389 return $dao->id;
390 }
391 $id[] = $dao->id;
392 }
393 return $id;
394 }
395
396 /**
397 * Wrapper for ajax soft contribution selector.
398 *
399 * @param array $params
400 * Associated array for params.
401 *
402 * @return array
403 * Associated array of soft contributions
404 */
405 public static function getSoftContributionSelector($params) {
406 $isTest = 0;
407 if (!empty($params['isTest'])) {
408 $isTest = $params['isTest'];
409 }
410 // Format the params.
411 $params['offset'] = ($params['page'] - 1) * $params['rp'];
412 $params['rowCount'] = $params['rp'];
413 $params['sort'] = CRM_Utils_Array::value('sortBy', $params);
414 $contactId = $params['cid'];
415
416 $filter = NULL;
417 if ($params['context'] == 'membership' && !empty($params['entityID']) && $contactId) {
418 $filter = " AND cc.id IN (SELECT contribution_id FROM civicrm_membership_payment WHERE membership_id = {$params['entityID']})";
419 }
420
421 $softCreditList = self::getSoftContributionList($contactId, $filter, $isTest, $params);
422
423 $softCreditListDT = array();
424 $softCreditListDT['data'] = array_values($softCreditList);
425 $softCreditListDT['recordsTotal'] = $params['total'];
426 $softCreditListDT['recordsFiltered'] = $params['total'];
427
428 return $softCreditListDT;
429 }
430
431 /**
432 * Function to retrieve the list of soft contributions for given contact.
433 *
434 * @param int $contact_id
435 * Contact id.
436 * @param string $filter
437 * @param int $isTest
438 * Additional filter criteria, later used in where clause.
439 * @param array $dTParams
440 *
441 * @return array
442 */
443 public static function getSoftContributionList($contact_id, $filter = NULL, $isTest = 0, &$dTParams = NULL) {
444 $config = CRM_Core_Config::singleton();
445 $links = array(
446 CRM_Core_Action::VIEW => array(
447 'name' => ts('View'),
448 'url' => 'civicrm/contact/view/contribution',
449 'qs' => 'reset=1&id=%%contributionid%%&cid=%%contactId%%&action=view&context=contribution&selectedChild=contribute',
450 'title' => ts('View related contribution'),
451 ),
452 );
453 $orderBy = 'cc.receive_date DESC';
454 if (!empty($dTParams['sort'])) {
455 $orderBy = $dTParams['sort'];
456 }
457 $limit = '';
458 if (!empty($dTParams['rowCount']) && $dTParams['rowCount'] > 0) {
459 $limit = " LIMIT {$dTParams['offset']}, {$dTParams['rowCount']} ";
460 }
461 $softOgId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', 'soft_credit_type', 'id', 'name');
462 $statusOgId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', 'contribution_status', 'id', 'name');
463
464 $query = '
465 SELECT SQL_CALC_FOUND_ROWS ccs.id, ccs.amount as amount,
466 ccs.contribution_id,
467 ccs.pcp_id,
468 ccs.pcp_display_in_roll,
469 ccs.pcp_roll_nickname,
470 ccs.pcp_personal_note,
471 ccs.soft_credit_type_id,
472 sov.label as sct_label,
473 cc.receive_date,
474 cc.contact_id as contributor_id,
475 cc.contribution_status_id as contribution_status_id,
476 cov.label as contribution_status,
477 cp.title as pcp_title,
478 cc.currency,
479 contact.display_name as contributor_name,
480 cct.name as financial_type
481 FROM civicrm_contribution_soft ccs
482 LEFT JOIN civicrm_contribution cc
483 ON ccs.contribution_id = cc.id
484 LEFT JOIN civicrm_pcp cp
485 ON ccs.pcp_id = cp.id
486 LEFT JOIN civicrm_contact contact ON
487 ccs.contribution_id = cc.id AND cc.contact_id = contact.id
488 LEFT JOIN civicrm_financial_type cct ON cc.financial_type_id = cct.id
489 LEFT JOIN civicrm_option_value sov ON sov.option_group_id = %3 AND ccs.soft_credit_type_id = sov.value
490 LEFT JOIN civicrm_option_value cov ON cov.option_group_id = %4 AND cc.contribution_status_id = cov.value
491 ';
492
493 $where = "
494 WHERE cc.is_test = %2 AND ccs.contact_id = %1";
495 if ($filter) {
496 $where .= $filter;
497 }
498
499 $query .= "{$where} ORDER BY {$orderBy} {$limit}";
500
501 $params = array(
502 1 => array($contact_id, 'Integer'),
503 2 => array($isTest, 'Integer'),
504 3 => array($softOgId, 'Integer'),
505 4 => array($statusOgId, 'Integer'),
506 );
507 $cs = CRM_Core_DAO::executeQuery($query, $params);
508
509 $dTParams['total'] = CRM_Core_DAO::singleValueQuery('SELECT FOUND_ROWS()');
510 $result = array();
511 while ($cs->fetch()) {
512 $result[$cs->id]['amount'] = CRM_Utils_Money::format($cs->amount, $cs->currency);
513 $result[$cs->id]['currency'] = $cs->currency;
514 $result[$cs->id]['contributor_id'] = $cs->contributor_id;
515 $result[$cs->id]['contribution_id'] = $cs->contribution_id;
516 $result[$cs->id]['contributor_name'] = CRM_Utils_System::href(
517 $cs->contributor_name,
518 'civicrm/contact/view',
519 "reset=1&cid={$cs->contributor_id}"
520 );
521 $result[$cs->id]['financial_type'] = $cs->financial_type;
522 $result[$cs->id]['receive_date'] = CRM_Utils_Date::customFormat($cs->receive_date, $config->dateformatDatetime);
523 $result[$cs->id]['pcp_id'] = $cs->pcp_id;
524 $result[$cs->id]['pcp_title'] = ($cs->pcp_title) ? $cs->pcp_title : 'n/a';
525 $result[$cs->id]['pcp_display_in_roll'] = $cs->pcp_display_in_roll;
526 $result[$cs->id]['pcp_roll_nickname'] = $cs->pcp_roll_nickname;
527 $result[$cs->id]['pcp_personal_note'] = $cs->pcp_personal_note;
528 $result[$cs->id]['contribution_status'] = $cs->contribution_status;
529 $result[$cs->id]['sct_label'] = $cs->sct_label;
530 $replace = array(
531 'contributionid' => $cs->contribution_id,
532 'contactId' => $cs->contributor_id,
533 );
534 $result[$cs->id]['links'] = CRM_Core_Action::formLink($links, NULL, $replace);
535
536 if ($isTest) {
537 $result[$cs->id]['contribution_status'] = CRM_Core_TestEntity::appendTestText($result[$cs->id]['contribution_status']);
538 }
539 }
540 return $result;
541 }
542
543 /**
544 * Function to assign honor profile fields to template/form, if $honorId (as soft-credit's contact_id)
545 * is passed then whole honoreeprofile fields with title/value assoc array assigned or only honoreeName
546 * is assigned
547 *
548 * @param CRM_Core_Form $form
549 * @param array $params
550 * @param int $honorId
551 */
552 public static function formatHonoreeProfileFields($form, $params, $honorId = NULL) {
553 if (empty($form->_values['honoree_profile_id'])) {
554 return;
555 }
556 $profileContactType = CRM_Core_BAO_UFGroup::getContactType($form->_values['honoree_profile_id']);
557 $profileFields = CRM_Core_BAO_UFGroup::getFields($form->_values['honoree_profile_id']);
558 $honoreeProfileFields = $values = array();
559 $honorName = NULL;
560
561 if ($honorId) {
562 CRM_Core_BAO_UFGroup::getValues($honorId, $profileFields, $values, FALSE, $params);
563 if (empty($params)) {
564 foreach ($profileFields as $name => $field) {
565 $title = $field['title'];
566 $params[$field['name']] = $values[$title];
567 }
568 }
569 }
570
571 //remove name related fields and construct name string with prefix/suffix
572 //which will be later assigned to template
573 switch ($profileContactType) {
574 case 'Individual':
575 if (array_key_exists('prefix_id', $params)) {
576 $honorName = CRM_Utils_Array::value(CRM_Utils_Array::value('prefix_id', $params),
577 CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'prefix_id')
578 );
579 unset($profileFields['prefix_id']);
580 }
581 $honorName .= ' ' . $params['first_name'] . ' ' . $params['last_name'];
582 unset($profileFields['first_name']);
583 unset($profileFields['last_name']);
584 if (array_key_exists('suffix_id', $params)) {
585 $honorName .= ' ' . CRM_Utils_Array::value(CRM_Utils_Array::value('suffix_id', $params),
586 CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'suffix_id')
587 );
588 unset($profileFields['suffix_id']);
589 }
590 break;
591
592 case 'Organization':
593 $honorName = $params['organization_name'];
594 unset($profileFields['organization_name']);
595 break;
596
597 case 'Household':
598 $honorName = $params['household_name'];
599 unset($profileFields['household_name']);
600 break;
601 }
602
603 if ($honorId) {
604 $honoreeProfileFields['Name'] = $honorName;
605 foreach ($profileFields as $name => $field) {
606 $title = $field['title'];
607 $honoreeProfileFields[$title] = $values[$title];
608 }
609 $form->assign('honoreeProfile', $honoreeProfileFields);
610 }
611 else {
612 $form->assign('honorName', $honorName);
613 }
614 }
615
616 }