Merge pull request #4360 from christianwach/wordpress-hooks
[civicrm-core.git] / CRM / Friend / Form / Event.php
index 9971cfb9e9f7beeeb7f6875356fdfa051fba8de8..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$
  *
  */
 class CRM_Friend_Form_Event extends CRM_Event_Form_ManageEvent {
 
   /**
-   * tell a friend id in db
+   * Tell a friend id in db
    *
    * @var int
    */
-  private $_friendId;
+  public $_friendId;
 
   public function preProcess() {
     parent::preProcess();
   }
 
   /**
-   * This function sets the default values for the form.
+   * Set default values for the form.
    *
    * @access public
    *
@@ -89,18 +89,25 @@ class CRM_Friend_Form_Event extends CRM_Event_Form_ManageEvent {
   }
 
   /**
-   * Function to build the form
+   * Build the form object
    *
    * @return void
    * @access public
    */
   public function buildQuickForm() {
+    if (isset($this->_id)) {
+      $defaults['entity_table'] = 'civicrm_event';
+      $defaults['entity_id'] = $this->_id;
+      CRM_Friend_BAO_Friend::getValues($defaults);
+      $this->_friendId = CRM_Utils_Array::value('id', $defaults);
+    }
+
     CRM_Friend_BAO_Friend::buildFriendForm($this);
     parent::buildQuickForm();
   }
 
   /**
-   * Function to process the form
+   * Process the form submission
    *
    * @access public
    *