Merge pull request #514 from adamwight/cache_acl_entityTable
[civicrm-core.git] / CRM / Contribute / Form / SoftCredit.php
index 7b51243095c3d097419839205d4c5964fa144eb1..ea22b5e93f4e53ad21a6649d5a65589348ddee30 100644 (file)
@@ -72,6 +72,21 @@ class CRM_Contribute_Form_SoftCredit {
       }
     }
 
+    // CRM-7368 allow user to set or edit PCP link for contributions
+    $siteHasPCPs = CRM_Contribute_PseudoConstant::pcPage();
+    if (!CRM_Utils_Array::crmIsEmptyArray($siteHasPCPs)) {
+      $form->assign('siteHasPCPs', 1);
+      $pcpDataUrl = CRM_Utils_System::url('civicrm/ajax/rest',
+        'className=CRM_Contact_Page_AJAX&fnName=getPCPList&json=1&context=contact&reset=1',
+        FALSE, NULL, FALSE
+      );
+      $form->assign('pcpDataUrl', $pcpDataUrl);
+      $form->addElement('text', 'pcp_made_through', ts('Credit to a Personal Campaign Page'));
+      $form->addElement('hidden', 'pcp_made_through_id', '', array('id' => 'pcp_made_through_id'));
+      $form->addElement('checkbox', 'pcp_display_in_roll', ts('Display in Honor Roll?'), NULL);
+      $form->addElement('text', 'pcp_roll_nickname', ts('Name (for Honor Roll)'));
+      $form->addElement('textarea', 'pcp_personal_note', ts('Personal Note (for Honor Roll)'));
+    }
     $form->assign('showSoftCreditRow', $showSoftCreditRow);
     $form->assign('rowCount', $item_count);
     $form->assign('showCreateNew', $showCreateNew);
@@ -93,7 +108,7 @@ class CRM_Contribute_Form_SoftCredit {
       }
     }
 
-    if (CRM_Utils_Array::value('pcp_id', $form->_softCreditInfo)) {
+    elseif (CRM_Utils_Array::value('pcp_id', $form->_softCreditInfo)) {
       $pcpInfo = $form->_softCreditInfo;
       $pcpId = CRM_Utils_Array::value('pcp_id', $pcpInfo);
       $pcpTitle = CRM_Core_DAO::getFieldValue('CRM_PCP_DAO_PCP', $pcpId, 'title');