migrating to profileContact and optimization
authormonishdeb <monish.deb@webaccessglobal.com>
Mon, 20 Jul 2015 19:25:24 +0000 (00:55 +0530)
committermonishdeb <monish.deb@webaccessglobal.com>
Thu, 10 Sep 2015 08:24:30 +0000 (13:54 +0530)
Conflicts:
CRM/Contribute/Form/Contribution/Confirm.php

CRM/Contact/Form/ProfileContact.php
CRM/Contribute/BAO/ContributionPage.php
CRM/Contribute/Form/Contribution/Confirm.php
CRM/Contribute/Form/Contribution/OnBehalfOf.php [deleted file]
CRM/Contribute/Form/Contribution/ThankYou.php
CRM/Contribute/Form/ContributionBase.php
CRM/Contribute/Form/ContributionPage/Settings.php
CRM/Contribute/Form/SoftCredit.php
templates/CRM/Contribute/Form/Contribution/Main.tpl
templates/CRM/Contribute/Form/Contribution/OnBehalfOf.tpl
templates/CRM/UF/Form/Block.tpl

index 61f3ed48b0b98cb1294a736958834d76c156111e..59b9d279fdcc1c76dbaf3817999c6636a868b376 100644 (file)
@@ -58,6 +58,7 @@ class CRM_Contact_Form_ProfileContact {
 
       if ($module == 'soft_credit') {
         $form->_honoreeProfileId = $ufJoin->uf_group_id;
+        $form->_honor_block_is_active = $ufJoin->is_active;
 
         if (!$form->_honoreeProfileId ||
           !CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $form->_honoreeProfileId, 'is_active')
@@ -78,7 +79,8 @@ class CRM_Contact_Form_ProfileContact {
       }
       else {
         $form->_onbehalf = FALSE;
-        $params = CRM_Contribute_BAO_ContributionPage::formatMultilingualOnBehalfParams($ufJoin->module_data, TRUE);
+        $params = CRM_Contribute_BAO_ContributionPage::formatModuleData($ufJoin->module_data, TRUE, 'on_behalf');
+        $form->_values = array_merge($params, $form->_values);
         if (CRM_Utils_Array::value('is_for_organization', $params)) {
           if ($params['is_for_organization'] == 2) {
             $form->_onBehalfRequired = TRUE;
@@ -92,16 +94,16 @@ class CRM_Contact_Form_ProfileContact {
             !empty($_POST['is_for_organization'])
           ) {
             $form->_onbehalf = TRUE;
-            $form->_profileId = $ufJoin->uf_group_id;
+            $form->_onBehalfProfileId = $ufJoin->uf_group_id;
 
-            if (!$form->_profileId ||
-              !CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $form->_profileId, 'is_active')
+            if (!$form->_onBehalfProfileId ||
+              !CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $form->_onBehalfProfileId, 'is_active')
             ) {
               CRM_Core_Error::fatal(ts('This contribution page has been configured for contribution on behalf of an organization and the selected onbehalf profile is either disabled or not found.'));
             }
 
             $requiredProfileFields = array('organization_name', 'email');
-            $validProfile = CRM_Core_BAO_UFGroup::checkValidProfile($form->_profileId, $requiredProfileFields);
+            $validProfile = CRM_Core_BAO_UFGroup::checkValidProfile($form->_onBehalfProfileId, $requiredProfileFields);
             if (!$validProfile) {
               CRM_Core_Error::fatal(ts('This contribution page has been configured for contribution on behalf of an organization and the required fields of the selected onbehalf profile are disabled.'));
             }
@@ -110,7 +112,7 @@ class CRM_Contact_Form_ProfileContact {
             $member = CRM_Member_BAO_Membership::getMembershipBlock($form->_id);
             if (empty($member['is_active'])) {
               $msg = ts('Mixed profile not allowed for on behalf of registration/sign up.');
-              $onBehalfProfile = CRM_Core_BAO_UFGroup::profileGroups($form->_profileId);
+              $onBehalfProfile = CRM_Core_BAO_UFGroup::profileGroups($form->_onBehalfProfileId);
               foreach (array(
                   'Individual',
                   'Organization',
@@ -143,7 +145,7 @@ class CRM_Contact_Form_ProfileContact {
               }
             }
 
-            $form->assign('profileId', $form->_profileId);
+            $form->assign('profileId', $form->_onBehalfProfileId);
             $form->assign('mode', $form->_mode);
 
             if ($contactID) {
@@ -260,8 +262,8 @@ class CRM_Contact_Form_ProfileContact {
   }
 
   public static function buildOnBehalfBlock(&$form) {
-    $form->assign('fieldSetTitle', ts('Organization Details'));
     $form->assign('buildOnBehalfForm', TRUE);
+    $form->assign('fieldSetTitle', ts('Organization Details'));
 
     $contactID = $form->_contactID;
 
@@ -296,7 +298,7 @@ class CRM_Contact_Form_ProfileContact {
     }
 
     $prefix = 'onbehalf';
-    $profileFields = CRM_Core_BAO_UFGroup::getFields($form->_profileId, FALSE, CRM_Core_Action::VIEW, NULL,
+    $profileFields = CRM_Core_BAO_UFGroup::getFields($form->_onBehalfProfileId, FALSE, CRM_Core_Action::VIEW, NULL,
       NULL, FALSE, NULL, FALSE, NULL,
       CRM_Core_Permission::CREATE, NULL
     );
@@ -323,6 +325,6 @@ class CRM_Contact_Form_ProfileContact {
     }
 
     $form->assign('onBehalfOfFields', $profileFields);
-    $form->addElement('hidden', 'hidden_onbehalf_profile', 1);
+    $form->addElement('hidden', 'onbehalf_profile_id', $form->_onBehalfProfileId);
   }
 }
index 46f7aa088c38e1d878cb290258afd808076f27ac..f45d0ae761df8396ad029ce0d9f8207171883d93 100644 (file)
@@ -770,145 +770,100 @@ LEFT JOIN  civicrm_premiums            ON ( civicrm_premiums.entity_id = civicrm
   }
 
   /**
-   * Get or Set multilingually affected honor params for processing module_data or setting default values.
+   * Get or Set honor/on_behalf params for processing module_data or setting default values.
    *
-   * @param string $params :
+   * @param array $params :
    * @param bool $setDefault : If yes then returns array to used for setting default value afterward
+   * @param string $module : processing module_data for which module? e.g. soft_credit, on_behalf
    *
    * @return array|string
    */
-  public static function formatMultilingualHonorParams($params, $setDefault = FALSE) {
+  public static function formatModuleData($params, $setDefault = FALSE, $module) {
     $config = CRM_Core_Config::singleton();
-    $sctJson = $sctJsonDecode = NULL;
+    $json = $jsonDecode = NULL;
     $domain = new CRM_Core_DAO_Domain();
     $domain->find(TRUE);
 
+    $moduleDataFormat = array(
+      'soft_credit' => array(
+        'soft_credit_types',
+        'multilingual' => array(
+          'honor_block_title',
+          'honor_block_text'
+        ),
+      ),
+      'on_behalf' => array(
+        'is_for_organization',
+        'multilingual' => array(
+          'for_organization'
+        ),
+      ),
+    );
+
     //When we are fetching the honor params respecting both multi and mono lingual state
     //and setting it to default param of Contribution Page's Main and Setting form
     if ($setDefault) {
-      $sctJsonDecode = json_decode($params);
-      $sctJsonDecode = (array) $sctJsonDecode->soft_credit;
-      if (!$domain->locales && !empty($sctJsonDecode['default'])) {
+      $jsonDecode = json_decode($params);
+      $jsonDecode = (array) $jsonDecode->$module;
+      if (!$domain->locales && !empty($jsonDecode['default'])) {
         //monolingual state
-        $sctJsonDecode += (array) $sctJsonDecode['default'];
+        $jsonDecode += (array) $jsonDecode['default'];
+        unset($jsonDecode['default']);
       }
-      elseif (!empty($sctJsonDecode[$config->lcMessages])) {
+      elseif (!empty($jsonDecode[$config->lcMessages])) {
         //multilingual state
-        foreach ($sctJsonDecode[$config->lcMessages] as $column => $value) {
-          $sctJsonDecode[$column] = $value;
+        foreach ($jsonDecode[$config->lcMessages] as $column => $value) {
+          $jsonDecode[$column] = $value;
         }
-        unset($sctJsonDecode[$config->lcMessages]);
+        unset($jsonDecode[$config->lcMessages]);
       }
-      return $sctJsonDecode;
+      return $jsonDecode;
     }
 
     //check and handle multilingual honoree params
     if (!$domain->locales) {
       //if in singlelingual state simply return the array format
-      $sctJson = json_encode(
-        array(
-          'soft_credit' => array(
-            'soft_credit_types' => $params['soft_credit_types'],
-            'default' => array(
-              'honor_block_title' => $params['honor_block_title'],
-              'honor_block_text' => $params['honor_block_text'],
-            ),
-          ),
-        )
-      );
+      $json = array($module => NULL);
+      foreach ($moduleDataFormat[$module] as $key => $attribute) {
+        if ($key === 'multilingual') {
+          $json[$module]['default'] = array();
+          foreach ($attribute as $attr) {
+            $json[$module]['default'][$attr] = $params[$attr];
+          }
+        }
+        else {
+          $json[$module][$attribute] = $params[$attribute];
+        }
+      }
+      $json = json_encode($json);
     }
     else {
       //if in multilingual state then retrieve the module_data against this contribution and
       //merge with earlier module_data json data to current so not to lose earlier multilingual module_data information
-      $sctJson = array(
-        'soft_credit' => array(
-          'soft_credit_types' => $params['soft_credit_types'],
-          $config->lcMessages => array(
-            'honor_block_title' => $params['honor_block_title'],
-            'honor_block_text' => $params['honor_block_text'],
-          ),
-        ),
-      );
-
-      $ufJoinDAO = new CRM_Core_DAO_UFJoin();
-      $ufJoinDAO->module = 'soft_credit';
-      $ufJoinDAO->entity_id = $params['id'];
-      $ufJoinDAO->find(TRUE);
-      $jsonData = json_decode($ufJoinDAO->module_data);
-      if ($jsonData) {
-        $sctJson['soft_credit'] = array_merge((array) $jsonData->soft_credit, $sctJson['soft_credit']);
-      }
-      $sctJson = json_encode($sctJson);
-    }
-    return $sctJson;
-  }
-
-  /**
-   * Get or Set multilingually affected on behalf params for processing module_data or setting default values.
-   *
-   * @param string $params :
-   * @param bool $setDefault : If yes then returns array to used for setting default value afterward
-   *
-   * @return array|string
-   */
-  public static function formatMultilingualOnBehalfParams($params, $setDefault = FALSE) {
-    $config = CRM_Core_Config::singleton();
-    $onBehalfJson = $onBehalfJsonDecode = NULL;
-    $domain = new CRM_Core_DAO_Domain();
-    $domain->find(TRUE);
-
-    if ($setDefault) {
-      $onBehalfJsonDecode = json_decode($params);
-      $onBehalfJsonDecode = (array) $onBehalfJsonDecode->on_behalf;
-      if (!$domain->locales && !empty($onBehalfJsonDecode['default'])) {
-        //monolingual state
-        $onBehalfJsonDecode += (array) $onBehalfJsonDecode['default'];
-      }
-      elseif (!empty($onBehalfJsonDecode[$config->lcMessages])) {
-        //multilingual state
-        foreach ($sctJsonDecode[$config->lcMessages] as $column => $value) {
-          $onBehalfJsonDecode[$column] = $value;
+      $json = array($module => NULL);
+      foreach ($moduleDataFormat[$module] as $key => $attribute) {
+        if ($key === 'multilingual') {
+          $json[$module][$config->lcMessages] = array();
+          foreach ($attribute as $attr) {
+            $json[$module][$config->lcMessages][$attr] = $params[$attr];
+          }
+        }
+        else {
+          $json[$module][$attribute] = $params[$attribute];
         }
-        unset($onBehalfJsonDecode[$config->lcMessages]);
       }
-      return $onBehalfJsonDecode;
-    }
-
-    //check and handle multilingual honoree params
-    if (!$domain->locales) {
-      //if in singlelingual state simply return the array format
-      $onBehalfJson = json_encode(
-        array(
-          'on_behalf' => array(
-            'is_for_organization' => $params['is_for_organization'],
-            'default' => array(
-              'for_organization' => $params['for_organization'],
-            ),
-          ),
-        )
-      );
-    }
-    else {
-      $onBehalfJson = array(
-        'on_behalf' => array(
-          'is_for_organization' => $params['is_for_organization'],
-          $config->lcMessages => array(
-            'for_organization' => $params['for_organization'],
-          ),
-        ),
-      );
 
       $ufJoinDAO = new CRM_Core_DAO_UFJoin();
-      $ufJoinDAO->module = 'on_behalf';
+      $ufJoinDAO->module = $module;
       $ufJoinDAO->entity_id = $params['id'];
       $ufJoinDAO->find(TRUE);
       $jsonData = json_decode($ufJoinDAO->module_data);
       if ($jsonData) {
-        $onBehalfJson['on_behalf'] = array_merge((array) $jsonData->on_behalf, $onBehalfJson['on_behalf']);
+        $json[$module] = array_merge((array) $jsonData->$module, $json[$module]);
       }
-      $onBehalfJson = json_encode($onBehalfJson);
+      $json = json_encode($json);
     }
-    return $onBehalfJson;
+    return $json;
   }
 
   /**
index 4d727c42ac60d5bd57a5c02f7fc725a266c3da5f..a148a96e6d64d292bcff8ec6f9b82179ee0e1ea7 100644 (file)
@@ -228,7 +228,7 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
       $this->assign('pay_later_receipt', $this->_values['pay_later_receipt']);
     }
     // if onbehalf-of-organization
-    if (!empty($this->_params['hidden_onbehalf_profile'])) {
+    if (!empty($this->_params['onbehalf_profile_id'])) {
       // CRM-15182
       if (empty($this->_params['org_option']) && empty($this->_params['organization_id'])) {
         if (!empty($this->_params['onbehalfof_id'])) {
@@ -467,15 +467,9 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
     }
     $this->buildCustom($this->_values['custom_pre_id'], 'customPre', TRUE);
     $this->buildCustom($this->_values['custom_post_id'], 'customPost', TRUE);
+      CRM_Core_Error::debug( '$params', $params );
 
-    if (!empty($params['hidden_onbehalf_profile'])) {
-      $ufJoinParams = array(
-        'module' => 'onBehalf',
-        'entity_table' => 'civicrm_contribution_page',
-        'entity_id' => $this->_id,
-      );
-      $OnBehalfProfile = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
-      $profileId = $OnBehalfProfile[0];
+    if (!empty($params['onbehalf_profile_id'])) {
 
       $fieldTypes = array('Contact', 'Organization');
       $contactSubType = CRM_Contact_BAO_ContactType::subTypes('Organization');
@@ -487,7 +481,7 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
         $fieldTypes = array_merge($fieldTypes, array('Contribution'));
       }
 
-      $this->buildCustom($profileId, 'onbehalfProfile', TRUE, 'onbehalf', $fieldTypes);
+      $this->buildCustom($params['onbehalf_profile_id'], 'onbehalfProfile', TRUE, 'onbehalf', $fieldTypes);
     }
 
     $this->_separateMembershipPayment = $this->get('separateMembershipPayment');
diff --git a/CRM/Contribute/Form/Contribution/OnBehalfOf.php b/CRM/Contribute/Form/Contribution/OnBehalfOf.php
deleted file mode 100644 (file)
index 7a87c60..0000000
+++ /dev/null
@@ -1,178 +0,0 @@
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 4.7                                                |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2015                                |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM.                                    |
- |                                                                    |
- | CiviCRM is free software; you can copy, modify, and distribute it  |
- | under the terms of the GNU Affero General Public License           |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |
- |                                                                    |
- | CiviCRM is distributed in the hope that it will be useful, but     |
- | WITHOUT ANY WARRANTY; without even the implied warranty of         |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
- | See the GNU Affero General Public License for more details.        |
- |                                                                    |
- | You should have received a copy of the GNU Affero General Public   |
- | License and the CiviCRM Licensing Exception along                  |
- | with this program; if not, contact CiviCRM LLC                     |
- | at info[AT]civicrm[DOT]org. If you have questions about the        |
- | GNU Affero General Public License or the licensing of CiviCRM,     |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
- +--------------------------------------------------------------------+
- */
-
-/**
- *
- * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2015
- */
-class CRM_Contribute_Form_Contribution_OnBehalfOf {
-
-  /**
-   * Set variables up before form is built.
-   *
-   * @param CRM_Core_Form $form
-   */
-  public static function preProcess(&$form) {
-    $session = CRM_Core_Session::singleton();
-    $contactID = $form->_contactID;
-
-    $ufJoinParams = array(
-      'module' => 'onBehalf',
-      'entity_table' => 'civicrm_contribution_page',
-      'entity_id' => $form->_id,
-    );
-    $profileId = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
-    $form->_profileId = $profileId[0];
-
-    if (!$form->_profileId ||
-      !CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $form->_profileId, 'is_active')
-    ) {
-      CRM_Core_Error::fatal(ts('This contribution page has been configured for contribution on behalf of an organization and the selected onbehalf profile is either disabled or not found.'));
-    }
-
-    $requiredProfileFields = array('organization_name', 'email');
-    $validProfile = CRM_Core_BAO_UFGroup::checkValidProfile($form->_profileId, $requiredProfileFields);
-    if (!$validProfile) {
-      CRM_Core_Error::fatal(ts('This contribution page has been configured for contribution on behalf of an organization and the required fields of the selected onbehalf profile are disabled.'));
-    }
-
-    $form->assign('profileId', $form->_profileId);
-    $form->assign('mode', $form->_mode);
-
-    if ($contactID) {
-      $form->_employers = CRM_Contact_BAO_Relationship::getPermissionedEmployer($contactID);
-
-      if (!empty($form->_membershipContactID) && $contactID != $form->_membershipContactID) {
-        // renewal case - membership being renewed may or may not be for organization
-        if (!empty($form->_employers) && array_key_exists($form->_membershipContactID, $form->_employers)) {
-          // if _membershipContactID belongs to employers list, we can say:
-          $form->_relatedOrganizationFound = TRUE;
-        }
-      }
-      elseif (!empty($form->_employers)) {
-        // not a renewal case and _employers list is not empty
-        $form->_relatedOrganizationFound = TRUE;
-      }
-
-      if ($form->_relatedOrganizationFound) {
-        // Related org url - pass checksum if needed
-        $args = array('cid' => '');
-        if (!empty($_GET['cs'])) {
-          $args = array(
-            'uid' => $form->_contactID,
-            'cs' => $_GET['cs'],
-            'cid' => '',
-          );
-        }
-        $locDataURL = CRM_Utils_System::url('civicrm/ajax/permlocation', $args, FALSE, NULL, FALSE);
-        $form->assign('locDataURL', $locDataURL);
-
-        if (!empty($form->_submitValues['onbehalf'])) {
-          if (!empty($form->_submitValues['onbehalfof_id'])) {
-            $form->assign('submittedOnBehalf', $form->_submitValues['onbehalfof_id']);
-          }
-          $form->assign('submittedOnBehalfInfo', json_encode($form->_submitValues['onbehalf']));
-        }
-      }
-
-      if ($form->_values['is_for_organization'] != 2) {
-        $form->assign('relatedOrganizationFound', $form->_relatedOrganizationFound);
-      }
-      else {
-        $form->assign('onBehalfRequired', $form->_onBehalfRequired);
-      }
-
-      if (count($form->_employers) == 1) {
-        foreach ($form->_employers as $id => $value) {
-          $form->_organizationName = $value['name'];
-          $orgId = $id;
-        }
-        $form->assign('orgId', $orgId);
-        $form->assign('organizationName', $form->_organizationName);
-      }
-    }
-  }
-
-  /**
-   * Build form for related contacts / on behalf of organization.
-   *
-   * @param CRM_Core_Form $form
-   *
-   */
-  public static function buildQuickForm(&$form) {
-    $form->assign('fieldSetTitle', ts('Organization Details'));
-    $form->assign('buildOnBehalfForm', TRUE);
-
-    $contactID = $form->_contactID;
-
-    if ($contactID && count($form->_employers) >= 1) {
-      $form->add('text', 'organization_id', ts('Select an existing related Organization OR enter a new one'));
-
-      $form->add('select', 'onbehalfof_id', '', CRM_Utils_Array::collect('name', $form->_employers));
-
-      $orgOptions = array(
-        0 => ts('Select an existing organization'),
-        1 => ts('Enter a new organization'),
-      );
-
-      $form->addRadio('org_option', ts('options'), $orgOptions);
-      $form->setDefaults(array('org_option' => 0));
-      $form->add('checkbox', 'mode', '');
-    }
-
-    $profileFields = CRM_Core_BAO_UFGroup::getFields($form->_profileId, FALSE, CRM_Core_Action::VIEW, NULL,
-      NULL, FALSE, NULL, FALSE, NULL,
-      CRM_Core_Permission::CREATE, NULL
-    );
-    $fieldTypes = array('Contact', 'Organization');
-    $contactSubType = CRM_Contact_BAO_ContactType::subTypes('Organization');
-    $fieldTypes = array_merge($fieldTypes, $contactSubType);
-
-    if (is_array($form->_membershipBlock) && !empty($form->_membershipBlock)) {
-      $fieldTypes = array_merge($fieldTypes, array('Membership'));
-    }
-    else {
-      $fieldTypes = array_merge($fieldTypes, array('Contribution'));
-    }
-
-    foreach ($profileFields as $name => $field) {
-      if (in_array($field['field_type'], $fieldTypes)) {
-        list($prefixName, $index) = CRM_Utils_System::explode('-', $name, 2);
-        if (in_array($prefixName, array('organization_name', 'email')) && empty($field['is_required'])) {
-          $field['is_required'] = 1;
-        }
-
-        CRM_Core_BAO_UFGroup::buildProfile($form, $field, NULL, NULL, FALSE, 'onbehalf');
-      }
-    }
-
-    $form->assign('onBehalfOfFields', $profileFields);
-    $form->addElement('hidden', 'hidden_onbehalf_profile', 1);
-  }
-
-}
index abe880aef8b53e3fb7c196afc3735561de9e7594..ff71a7bdaa36351404885c7720a9e6b35b01e1bb 100644 (file)
@@ -186,15 +186,7 @@ class CRM_Contribute_Form_Contribution_ThankYou extends CRM_Contribute_Form_Cont
 
     $this->buildCustom($this->_values['custom_pre_id'], 'customPre', TRUE);
     $this->buildCustom($this->_values['custom_post_id'], 'customPost', TRUE);
-    if (!empty($params['hidden_onbehalf_profile'])) {
-      $ufJoinParams = array(
-        'module' => 'onBehalf',
-        'entity_table' => 'civicrm_contribution_page',
-        'entity_id' => $this->_id,
-      );
-      $OnBehalfProfile = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
-      $profileId = $OnBehalfProfile[0];
-
+    if (!empty($params['onbehalf_profile_id'])) {
       $fieldTypes = array('Contact', 'Organization');
       $contactSubType = CRM_Contact_BAO_ContactType::subTypes('Organization');
       $fieldTypes = array_merge($fieldTypes, $contactSubType);
@@ -205,7 +197,7 @@ class CRM_Contribute_Form_Contribution_ThankYou extends CRM_Contribute_Form_Cont
         $fieldTypes = array_merge($fieldTypes, array('Contribution'));
       }
 
-      $this->buildCustom($profileId, 'onbehalfProfile', TRUE, 'onbehalf', $fieldTypes);
+      $this->buildCustom($params['onbehalf_profile_id'], 'onbehalfProfile', TRUE, 'onbehalf', $fieldTypes);
     }
 
     $this->assign('trxn_id',
index 7be232c3c0853ac4370dcac3b5b96a3c4be0bf1d..e4db6f63fc5a587a734239275f67f8b1d8e7e503 100644 (file)
@@ -539,7 +539,7 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form {
 
     $this->assign('address', CRM_Utils_Address::format($addressFields));
 
-    if (!empty($this->_params['hidden_onbehalf_profile'])) {
+    if (!empty($this->_params['onbehalf_profile_id'])) {
       $this->assign('onBehalfName', $this->_params['organization_name']);
       $locTypeId = array_keys($this->_params['onbehalf_location']['email']);
       $this->assign('onBehalfEmail', $this->_params['onbehalf_location']['email'][$locTypeId[0]]['email']);
index eec20aa160ac576c14b19c859e843500af1fead0..cfd555270166e0e63212115bbc2e9818282d93ab 100644 (file)
@@ -58,15 +58,14 @@ class CRM_Contribute_Form_ContributionPage_Settings extends CRM_Contribute_Form_
         $ufJoinDAO->module = $module;
         $ufJoinDAO->entity_id = $this->_id;
         if ($ufJoinDAO->find(TRUE)) {
+          $jsonData = CRM_Contribute_BAO_ContributionPage::formatModuleData($ufJoinDAO->module_data, TRUE, $module);
           if ($module == 'soft_credit') {
             $defaults['honoree_profile'] = $ufJoinDAO->uf_group_id;
-            $jsonData = CRM_Contribute_BAO_ContributionPage::formatMultilingualHonorParams($ufJoinDAO->module_data, TRUE);
             $defaults = array_merge($defaults, $jsonData);
             $defaults['honor_block_is_active'] = $ufJoinDAO->is_active;
           }
           else {
             $defaults['onbehalf_profile_id'] = $ufJoinDAO->uf_group_id;
-            $jsonData = CRM_Contribute_BAO_ContributionPage::formatMultilingualOnBehalfParams($ufJoinDAO->module_data, TRUE);
             $defaults = array_merge($defaults, $jsonData);
             $defaults['is_organization'] = $ufJoinDAO->is_active;
           }
@@ -362,11 +361,11 @@ class CRM_Contribute_Form_ContributionPage_Settings extends CRM_Contribute_Form_
         $ufJoinParam['is_active'] = 1;
         if ($index == 'honor_block_is_active') {
           $ufJoinParam['uf_group_id'] = $params['honoree_profile'];
-          $ufJoinParam['module_data'] = CRM_Contribute_BAO_ContributionPage::formatMultilingualHonorParams($params);
+          $ufJoinParam['module_data'] = CRM_Contribute_BAO_ContributionPage::formatModuleData($params, FALSE, 'soft_credit');
         }
         else {
           $ufJoinParam['uf_group_id'] = $params['onbehalf_profile_id'];
-          $ufJoinParam['module_data'] = CRM_Contribute_BAO_ContributionPage::formatMultilingualOnBehalfParams($params);
+          $ufJoinParam['module_data'] = CRM_Contribute_BAO_ContributionPage::formatModuleData($params, FALSE, 'on_behalf');
         }
         CRM_Core_BAO_UFJoin::create($ufJoinParam);
       }
index 7561df91bba7629d385466736b63ed0689600fe8..a24a5dc343c5cf9a94073087bcd01374960e9b43 100644 (file)
@@ -74,7 +74,7 @@ class CRM_Contribute_Form_SoftCredit {
       $ufJoinDAO->module = 'soft_credit';
       $ufJoinDAO->entity_id = $form->_id;
       if ($ufJoinDAO->find(TRUE)) {
-        $jsonData = CRM_Contribute_BAO_ContributionPage::formatMultilingualHonorParams($ufJoinDAO->module_data, TRUE);
+        $jsonData = CRM_Contribute_BAO_ContributionPage::formatModuleData($ufJoinDAO->module_data, TRUE, 'soft_credit');
         if ($jsonData) {
           foreach (array('honor_block_title', 'honor_block_text') as $name) {
             $form->assign($name, $jsonData[$name]);
index 8fb97b9582bd7499d08c606df05abe715bebcfb0..cb6642f865be2866f54c3753c10272d127478943 100644 (file)
@@ -25,7 +25,7 @@
 *}
 {* Callback snippet: On-behalf profile *}
 {if $snippet and !empty($isOnBehalfCallback)}
-  {* include file="CRM/Contribute/Form/Contribution/OnBehalfOf.tpl" context="front-end" *}
+  {include file="CRM/Contribute/Form/Contribution/OnBehalfOf.tpl" context="front-end"}
 
 {else}
   {literal}
   {/if}
 
   {if $is_for_organization}
-  <div id='onBehalfOfOrg' class="crm-section">
-    {include file="CRM/UF/Form/Block.tpl" fields=$onBehalfOfFields mode=8 prefix='onbehalf'}
-  </div>
+    {include file="CRM/Contribute/Form/Contribution/OnBehalfOf.tpl"}
   {/if}
 
   {* User account registration option. Displays if enabled for one of the profiles on this page. *}
index c12da8f42123b9ca0614b9cf213881a9ffe92b8d..e58bb75ac37b64c39412302f04677247292aa37f 100644 (file)
  *}
 
 {if $buildOnBehalfForm or $onBehalfRequired}
-<fieldset id="for_organization" class="for_organization-group">
-<legend>{$fieldSetTitle}</legend>
-  {if ( $relatedOrganizationFound or $onBehalfRequired ) and !$organizationName}
-    <div id='orgOptions' class="section crm-section">
-      <div class="content">
-        {$form.org_option.html}
+  {if !empty($context)}
+    <fieldset id="for_organization" class="for_organization-group">
+    <legend>{$fieldSetTitle}</legend>
+    {if ( $relatedOrganizationFound or $onBehalfRequired ) and !$organizationName and $form.org_option.html}
+      <div id='orgOptions' class="section crm-section">
+        <div class="content">
+          {$form.org_option.html}
+        </div>
       </div>
-    </div>
-  {/if}
-
-<div id="select_org" class="crm-section">
-  {foreach from=$onBehalfOfFields item=onBehaldField key=fieldName}
-    {if $onBehalfOfFields.$fieldName.skipDisplay}
-      {continue}
-    {/if}
-    {if $onBehalfOfFields.$fieldName.field_type eq "Formatting"}
-      {$onBehalfOfFields.$fieldName.help_pre}
-      {continue}
     {/if}
-    <div class="crm-section {$onBehalfOfFields.$fieldName.name}-section">
-      {if $onBehalfOfFields.$fieldName.help_pre}
-        &nbsp;&nbsp;<span class='description'>{$onBehalfOfFields.$fieldName.help_pre}</span>
-      {/if}
+  {/if}
+  <div id='onBehalfOfOrg' class="crm-section">
+    {include file="CRM/UF/Form/Block.tpl" fields=$onBehalfOfFields mode=8 prefix='onbehalf'}
+  </div>
 
-      {if ( $fieldName eq 'organization_name' ) and $organizationName}
-        <div id='org_name' class="label">{$form.onbehalf.$fieldName.label}</div>
-        <div class="content">
-          {$form.onbehalf.$fieldName.html|crmAddClass:big}
-          <span>
-              ( <a id='createNewOrg' href="#" onclick="createNew( ); return false;">{ts}Enter a new organization{/ts}</a> )
-          </span>
-          <div id="id-onbehalf-orgname-enter-help" class="description">
-            {ts}Organization details have been prefilled for you. If this is not the organization you want to use, click "Enter a new organization" above.{/ts}
-          </div>
-          {if $onBehalfOfFields.$fieldName.help_post}
-            <span class='description'>{$onBehalfOfFields.$fieldName.help_post}</span>
-          {/if}
-        </div>
-      {else}
-        {if $onBehalfOfFields.$fieldName.options_per_line}
-          <div class="label option-label">{$form.onbehalf.$fieldName.label}</div>
-          <div class="content">
-            {assign var="count" value="1"}
-            {strip}
-              <table class="form-layout-compressed">
-              <tr>
-              {* sort by fails for option per line. Added a variable to iterate through the element array*}
-                {assign var="index" value="1"}
-                {foreach name=outer key=key item=item from=$form.onbehalf.$fieldName}
-                  {if $index < 10}
-                    {assign var="index" value=`$index+1`}
-                  {else}
-                    <td class="labels font-light">{$form.onbehalf.$fieldName.$key.html}</td>
-                    {if $count == $onBehalfOfFields.$fieldName.options_per_line}
-                      </tr>
-                      <tr>
-                      {assign var="count" value="1"}
-                    {else}
-                      {assign var="count" value=`$count+1`}
-                    {/if}
-                  {/if}
-                {/foreach}
-              </tr>
-              </table>
-            {/strip}
-            {if $onBehalfOfFields.$fieldName.help_post}
-              <span class='description'>{$onBehalfOfFields.$fieldName.help_post}</span>
-            {/if}
-          </div>
-        {else}
-          <div class="label">{$form.onbehalf.$fieldName.label}</div>
-          <div class="content">
-            {if $fieldName eq 'organization_name' and !empty($form.onbehalfof_id)}
-              {$form.onbehalfof_id.html}
-            {/if}
-            {$form.onbehalf.$fieldName.html}
-            {if !empty($onBehalfOfFields.$fieldName.html_type)  && $onBehalfOfFields.$fieldName.html_type eq 'Autocomplete-Select'}
-              {assign var=elementName value=onbehalf[$fieldName]}
-              {if $onBehalfOfFields.$fieldName.data_type eq 'ContactReference'}
-                {include file="CRM/Custom/Form/ContactReference.tpl" element_name = $elementName}
-              {/if}
-            {/if}
-            {if $onBehalfOfFields.$fieldName.name|substr:0:5 eq 'phone'}
-              {assign var="phone_ext_field" value=$onBehalfOfFields.$fieldName.name|replace:'phone':'phone_ext'}
-              {if $form.onbehalf.$phone_ext_field.html}
-                &nbsp;{$form.onbehalf.$phone_ext_field.html}
-              {/if}
-            {/if}
-            {if $onBehalfOfFields.$fieldName.data_type eq 'Date'}
-              {assign var=elementName value=onbehalf[$fieldName]}
-              {include file="CRM/common/jcalendar.tpl" elementName=$elementName elementId=onbehalf_$fieldName}
-            {/if}
-            {if $onBehalfOfFields.$fieldName.help_post}
-              <br /><span class='description'>{$onBehalfOfFields.$fieldName.help_post}</span>
-            {/if}
-          </div>
-        {/if}
-      {/if}
-      <div class="clear"></div>
-    </div>
-  {/foreach}
-</div>
-<div>{$form.mode.html}</div>
-</fieldset>
+  <div>{$form.mode.html}</div>
+  {if !empty($context)}
+    </fieldset>
+  {/if}
 {/if}
-{if empty($snippet)}
 {literal}
 <script type="text/javascript">
 
@@ -315,4 +229,3 @@ function selectCreateOrg( orgOption, reset ) {
 {/if}
 
 </script>
-{/if}
index fc2f1ace08281752086c45e239d8bcfbd55d7631..86083919658c9cd0560c2e17ac0b9a226dad7b15 100644 (file)
                   &nbsp;{$form.$phone_ext_field.html}
                 {/if}
               {else}
-                {if $prefix}{$form.$prefix.$n.html}{else}{$form.$n.html}{/if}
+                {if $prefix}
+                  {if $n eq 'organization_name'}
+                    {if !empty($form.onbehalfof_id)}
+                      {$form.onbehalfof_id.html}
+                    {/if}
+                    {if $organizationName}
+                      <span>
+                        ( <a id='createNewOrg' href="#" onclick="createNew( ); return false;">{ts}Enter a new organization{/ts}</a> )
+                      </span>
+                    {/if}
+                  {/if}
+                  {$form.$prefix.$n.html}
+               {else}
+                 {$form.$n.html}
+               {/if}
               {/if}
 
             {*CRM-4564*}