3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
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. |
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. |
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 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2015
37 * This class generates form components for Tell A Friend
40 class CRM_Friend_Form_Event
extends CRM_Event_Form_ManageEvent
{
43 * Tell a friend id in db.
49 public function preProcess() {
54 * Set default values for the form.
59 public function setDefaultValues() {
62 if (isset($this->_id
)) {
63 $defaults['entity_table'] = 'civicrm_event';
64 $defaults['entity_id'] = $this->_id
;
65 CRM_Friend_BAO_Friend
::getValues($defaults);
66 if (!empty($defaults['id'])) {
67 $defaults['tf_id'] = CRM_Utils_Array
::value('id', $defaults);
68 $this->_friendId
= $defaults['tf_id'];
69 // lets unset the 'id' since it conflicts with eventID (or contribID)
71 unset($defaults['id']);
73 $defaults['tf_title'] = CRM_Utils_Array
::value('title', $defaults);
74 $defaults['tf_is_active'] = CRM_Utils_Array
::value('is_active', $defaults);
75 $defaults['tf_thankyou_title'] = CRM_Utils_Array
::value('thankyou_title', $defaults);
76 $defaults['tf_thankyou_text'] = CRM_Utils_Array
::value('thankyou_text', $defaults);
79 if (!$this->_friendId
) {
80 $defaults['intro'] = ts('Help us spread the word about this event. Use the space below to personalize your email message - let your friends know why you\'re attending. Then fill in the name(s) and email address(es) and click \'Send Your Message\'.');
81 $defaults['suggested_message'] = ts('Thought you might be interested in checking out this event. I\'m planning on attending.');
82 $defaults['tf_thankyou_text'] = ts('Thanks for spreading the word about this event to your friends.');
83 $defaults['tf_title'] = ts('Tell a Friend');
84 $defaults['tf_thankyou_title'] = ts('Thanks for Spreading the Word');
91 * Build the form object.
95 public function buildQuickForm() {
96 if (isset($this->_id
)) {
97 $defaults['entity_table'] = 'civicrm_event';
98 $defaults['entity_id'] = $this->_id
;
99 CRM_Friend_BAO_Friend
::getValues($defaults);
100 $this->_friendId
= CRM_Utils_Array
::value('id', $defaults);
103 CRM_Friend_BAO_Friend
::buildFriendForm($this);
104 parent
::buildQuickForm();
108 * Process the form submission.
113 public function postProcess() {
114 // get the submitted form values.
115 $formValues = $this->controller
->exportValues($this->_name
);
117 // let's unset event id
118 unset($formValues['id']);
120 $formValues['entity_table'] = 'civicrm_event';
121 $formValues['entity_id'] = $this->_id
;
122 $formValues['title'] = $formValues['tf_title'];
123 $formValues['is_active'] = CRM_Utils_Array
::value('tf_is_active', $formValues, FALSE);
124 $formValues['thankyou_title'] = CRM_Utils_Array
::value('tf_thankyou_title', $formValues);
125 $formValues['thankyou_text'] = CRM_Utils_Array
::value('tf_thankyou_text', $formValues);
127 if (($this->_action
& CRM_Core_Action
::UPDATE
) && $this->_friendId
) {
128 $formValues['id'] = $this->_friendId
;
131 CRM_Friend_BAO_Friend
::addTellAFriend($formValues);
133 // Update tab "disabled" css class
134 $this->ajaxResponse
['tabValid'] = !empty($formValues['tf_is_active']);
136 parent
::endPostProcess();
140 * Return a descriptive name for the page, used in wizard header
144 public function getTitle() {
145 return ts('Tell a Friend');