Merge pull request #4360 from christianwach/wordpress-hooks
[civicrm-core.git] / CRM / Friend / Form / Event.php
index 24874c3a5bbdb1fe9df694f6d31280de74ee4365..d7da13322fbe23a844d8400cd953737911885ff8 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.4                                                |
+ | CiviCRM version 4.5                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013                                |
+ | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -28,7 +28,7 @@
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2013
+ * @copyright CiviCRM LLC (c) 2004-2014
  * $Id$
  *
  */
@@ -40,7 +40,7 @@
 class CRM_Friend_Form_Event extends CRM_Event_Form_ManageEvent {
 
   /**
-   * tell a friend id in db
+   * Tell a friend id in db
    *
    * @var int
    */
@@ -51,11 +51,11 @@ class CRM_Friend_Form_Event extends CRM_Event_Form_ManageEvent {
   }
 
   /**
-   * This function sets the default values for the form.
+   * Set default values for the form.
    *
    * @access public
    *
-   * @return None
+   * @return void
    */
   public function setDefaultValues() {
     $defaults = array();
@@ -64,7 +64,7 @@ class CRM_Friend_Form_Event extends CRM_Event_Form_ManageEvent {
       $defaults['entity_table'] = 'civicrm_event';
       $defaults['entity_id'] = $this->_id;
       CRM_Friend_BAO_Friend::getValues($defaults);
-      if (CRM_Utils_Array::value('id', $defaults)) {
+      if (!empty($defaults['id'])) {
         $defaults['tf_id'] = CRM_Utils_Array::value('id', $defaults);
         $this->_friendId = $defaults['tf_id'];
         // lets unset the 'id' since it conflicts with eventID (or contribID)
@@ -89,9 +89,9 @@ class CRM_Friend_Form_Event extends CRM_Event_Form_ManageEvent {
   }
 
   /**
-   * Function to build the form
+   * Build the form object
    *
-   * @return None
+   * @return void
    * @access public
    */
   public function buildQuickForm() {
@@ -107,11 +107,11 @@ class CRM_Friend_Form_Event extends CRM_Event_Form_ManageEvent {
   }
 
   /**
-   * Function to process the form
+   * Process the form submission
    *
    * @access public
    *
-   * @return None
+   * @return void
    */
   public function postProcess() {
     // get the submitted form values.
@@ -133,6 +133,9 @@ class CRM_Friend_Form_Event extends CRM_Event_Form_ManageEvent {
 
     CRM_Friend_BAO_Friend::addTellAFriend($formValues);
 
+    // Update tab "disabled" css class
+    $this->ajaxResponse['tabValid'] = !empty($formValues['tf_is_active']);
+
     parent::endPostProcess();
   }