3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
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 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
19 * This class generates form components for Tell A Friend
22 class CRM_Friend_Form_Contribute
extends CRM_Contribute_Form_ContributionPage
{
25 * Tell a friend id in db.
31 public function preProcess() {
33 $this->setSelectedChild('friend');
37 * Set default values for the form. Note that in edit/view mode
38 * the default values are retrieved from the database
43 public function setDefaultValues() {
46 if (isset($this->_id
)) {
47 $defaults['entity_table'] = 'civicrm_contribution_page';
48 $defaults['entity_id'] = $this->_id
;
49 CRM_Friend_BAO_Friend
::getValues($defaults);
50 $this->_friendId
= $defaults['id'] ??
NULL;
51 $defaults['tf_title'] = $defaults['title'] ??
NULL;
52 $defaults['tf_is_active'] = $defaults['is_active'] ??
NULL;
53 $defaults['tf_thankyou_title'] = $defaults['thankyou_title'] ??
NULL;
54 $defaults['tf_thankyou_text'] = $defaults['thankyou_text'] ??
NULL;
57 if (!$this->_friendId
) {
58 $defaults['intro'] = ts('Help us spread the word and leverage the power of your contribution by telling your friends. Use the space below to personalize your email message - let your friends know why you support us. Then fill in the name(s) and email address(es) and click \'Send Your Message\'.');
59 $defaults['suggested_message'] = ts('Thought you might be interested in learning about and helping this organization. I think they do important work.');
60 $defaults['tf_thankyou_text'] = ts('Thanks for telling your friends about us and supporting our efforts. Together we can make a difference.');
61 $defaults['tf_title'] = ts('Tell a Friend');
62 $defaults['tf_thankyou_title'] = ts('Thanks for Spreading the Word');
69 * Build the form object.
73 public function buildQuickForm() {
74 if (isset($this->_id
)) {
75 $defaults['entity_table'] = 'civicrm_contribution_page';
76 $defaults['entity_id'] = $this->_id
;
77 CRM_Friend_BAO_Friend
::getValues($defaults);
78 $this->_friendId
= $defaults['id'] ??
NULL;
81 CRM_Friend_BAO_Friend
::buildFriendForm($this);
82 parent
::buildQuickForm();
86 * Process the form submission.
91 public function postProcess() {
92 // get the submitted form values.
93 $formValues = $this->controller
->exportValues($this->_name
);
95 $formValues['entity_table'] = 'civicrm_contribution_page';
96 $formValues['entity_id'] = $this->_id
;
97 $formValues['title'] = $formValues['tf_title'];
98 $formValues['is_active'] = CRM_Utils_Array
::value('tf_is_active', $formValues, FALSE);
99 $formValues['thankyou_title'] = $formValues['tf_thankyou_title'] ??
NULL;
100 $formValues['thankyou_text'] = $formValues['tf_thankyou_text'] ??
NULL;
102 if (($this->_action
& CRM_Core_Action
::UPDATE
) && $this->_friendId
) {
103 $formValues['id'] = $this->_friendId
;
106 CRM_Friend_BAO_Friend
::addTellAFriend($formValues);
107 parent
::endPostProcess();
111 * Return a descriptive name for the page, used in wizard header
115 public function getTitle() {
116 return ts('Tell a Friend');