Merge pull request #2762 from amitajgaonkar/WebtestIssues
[civicrm-core.git] / CRM / Friend / BAO / Friend.php
index 9393d3ff0e1accffefec17b949dcf0c73b70ca6a..7d7389ea1a1bb3a653007bd68ac5868e06306e19 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.3                                                |
+ | 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$
  *
  */
@@ -191,7 +191,7 @@ class CRM_Friend_BAO_Friend extends CRM_Friend_DAO_Friend {
       );
       //if is_email_receipt is set then take receipt_from_email
       //as from_email
-      if (CRM_Utils_Array::value('is_email_receipt', $default) && CRM_Utils_Array::value('receipt_from_email', $default)) {
+      if (!empty($default['is_email_receipt']) && !empty($default['receipt_from_email'])) {
         $mailParams['email_from'] = $default['receipt_from_email'];
       }
 
@@ -211,7 +211,7 @@ class CRM_Friend_BAO_Friend extends CRM_Friend_DAO_Friend {
 
       //if is_email_confirm is set then take confirm_from_email
       //as from_email
-      if (CRM_Utils_Array::value('is_email_confirm', $default) && CRM_Utils_Array::value('confirm_from_email', $default)) {
+      if (!empty($default['is_email_confirm']) && !empty($default['confirm_from_email'])) {
         $mailParams['email_from'] = $default['confirm_from_email'];
       }
 
@@ -237,7 +237,7 @@ class CRM_Friend_BAO_Friend extends CRM_Friend_DAO_Friend {
    *
    * @param object $form form object
    *
-   * @return None
+   * @return void
    * @access public
    */
   static function buildFriendForm($form) {
@@ -257,6 +257,11 @@ class CRM_Friend_BAO_Friend extends CRM_Friend_DAO_Friend {
     $form->add('text', 'tf_thankyou_title', ts('Thank-you Title'), CRM_Core_DAO::getAttribute('CRM_Friend_DAO_Friend', 'thankyou_title'), TRUE);
 
     $form->addWysiwyg('tf_thankyou_text', ts('Thank-you Message'), CRM_Core_DAO::getAttribute('CRM_Friend_DAO_Friend', 'thankyou_text'), TRUE);
+
+    if ($form->_friendId) {
+      // CRM-14200 the i18n dialogs need this for translation
+      $form->assign('friendId', $form->_friendId);
+    }
   }
 
   /**
@@ -294,14 +299,14 @@ class CRM_Friend_BAO_Friend extends CRM_Friend_DAO_Friend {
     }
 
     // use contact email, CRM-4963
-    if (!CRM_Utils_Array::value('email_from', $values)) {
+    if (empty($values['email_from'])) {
       $values['email_from'] = $email;
     }
 
     foreach ($values['email'] as $displayName => $emailTo) {
       if ($emailTo) {
         // FIXME: factor the below out of the foreach loop
-        CRM_Core_BAO_MessageTemplates::sendTemplate(
+        CRM_Core_BAO_MessageTemplate::sendTemplate(
           array(
             'groupName' => 'msg_tpl_workflow_friend',
             'valueName' => 'friend',