INFRA-132 - CRM/Upgrade - phpcbf (plus fixup)
authorTim Otten <totten@civicrm.org>
Tue, 6 Jan 2015 21:21:24 +0000 (13:21 -0800)
committerTim Otten <totten@civicrm.org>
Tue, 6 Jan 2015 23:07:45 +0000 (15:07 -0800)
14 files changed:
CRM/Upgrade/Form.php
CRM/Upgrade/Headless.php
CRM/Upgrade/Incremental/php/FourFive.php
CRM/Upgrade/Incremental/php/FourFour.php
CRM/Upgrade/Incremental/php/FourOne.php
CRM/Upgrade/Incremental/php/FourSix.php
CRM/Upgrade/Incremental/php/FourTwo.php
CRM/Upgrade/Incremental/php/ThreeFour.php
CRM/Upgrade/Incremental/php/ThreeThree.php
CRM/Upgrade/Page/Cleanup.php
CRM/Upgrade/Snapshot/V4p2/Price/BAO/Field.php
CRM/Upgrade/Snapshot/V4p2/Price/BAO/FieldValue.php
CRM/Upgrade/Snapshot/V4p2/Price/BAO/LineItem.php
CRM/Upgrade/Snapshot/V4p2/Price/BAO/Set.php

index 05f578c7d8018a7bcbf523e3fb6d7dee680db14c..406fc40e9895809e287019b1c05a58658d0522c7 100644 (file)
@@ -102,7 +102,7 @@ class CRM_Upgrade_Form extends CRM_Core_Form {
   function __construct($state = NULL,
     $action = CRM_Core_Action::NONE,
     $method = 'post',
-    $name   = NULL
+    $name = NULL
   ) {
     $this->_config = CRM_Core_Config::singleton();
 
@@ -364,7 +364,6 @@ SET    version = '$version'
 
     /*                          '2.2.alpha3', '2.2.0', '2.2.2', '2.1.alpha1', '2.1.3'); */
 
-
     usort($revList, 'version_compare');
     return $revList;
   }
@@ -441,7 +440,7 @@ SET    version = '$version'
    */
   public function getUpgradeVersions() {
     $latestVer = CRM_Utils_System::version();
-    $currentVer = CRM_Core_BAO_Domain::version(true);
+    $currentVer = CRM_Core_BAO_Domain::version(TRUE);
     if (!$currentVer) {
       CRM_Core_Error::fatal(ts('Version information missing in civicrm database.'));
     }
@@ -511,7 +510,7 @@ SET    version = '$version'
                array(1 => $latestVer));
     }
 
-    if (CRM_Core_DAO::getGlobalSetting('thread_stack', 0) < (1024*self::MINIMUM_THREAD_STACK)) {
+    if (CRM_Core_DAO::getGlobalSetting('thread_stack', 0) < (1024 * self::MINIMUM_THREAD_STACK)) {
       $error = ts('CiviCRM %1 requires MySQL thread stack >= %2k', array(
         1 => $latestVer,
         2 => self::MINIMUM_THREAD_STACK
@@ -646,7 +645,7 @@ SET    version = '$version'
    *
    * @return bool
    */
-  public static function doIncrementalUpgradeStep(CRM_Queue_TaskContext$ctx, $rev, $originalVer, $latestVer, $postUpgradeMessageFile) {
+  public static function doIncrementalUpgradeStep(CRM_Queue_TaskContext $ctx, $rev, $originalVer, $latestVer, $postUpgradeMessageFile) {
     $upgrade = new CRM_Upgrade_Form();
 
     $phpFunctionName = 'upgrade_' . str_replace('.', '_', $rev);
@@ -767,10 +766,10 @@ SET    version = '$version'
         version_compare($rev, '3.2.alpha1') > 0
       ) {
         $versionObject = $this->incrementalPhpObject($rev);
-         if (is_callable(array(
+        if (is_callable(array(
           $versionObject, 'setPreUpgradeMessage'))) {
-           $versionObject->setPreUpgradeMessage($preUpgradeMessage, $rev, $currentVer);
-         }
+          $versionObject->setPreUpgradeMessage($preUpgradeMessage, $rev, $currentVer);
+        }
       }
     }
   }
index e5815d5705edb566ddfb98a5fefd9f04297a92d4..a56de4a8beef769162d0d7d6530b9999e798e10f 100644 (file)
@@ -70,8 +70,8 @@ class CRM_Upgrade_Headless {
       $errorMessage = CRM_Core_Error::formatTextException($queueResult['exception']);
       CRM_Core_Error::debug_log_message($errorMessage);
       if ($enablePrint) {
-        print($errorMessage);
-    }
+        print ($errorMessage);
+      }
       throw $queueResult['exception']; // FIXME test
     }
 
index c184955ffa7cc2ee2ec49cbbddacefa13192b14f..3ef5a1ac8e348703bdc7a5f134f62c21c0f8004a 100644 (file)
@@ -255,7 +255,7 @@ DROP KEY `{$dao->CONSTRAINT_NAME}`";
   public static function migrateHonoreeInfo(CRM_Queue_TaskContext $ctx) {
     $query = "ALTER TABLE `civicrm_uf_join`
     ADD COLUMN `module_data` longtext COMMENT 'Json serialized array of data used by the ufjoin.module'";
-      CRM_Core_DAO::executeQuery($query);
+    CRM_Core_DAO::executeQuery($query);
 
     $honorTypes = array_keys(CRM_Core_OptionGroup::values('honor_type'));
     $ufGroupDAO = new CRM_Core_DAO_UFGroup();
@@ -273,8 +273,8 @@ DROP KEY `{$dao->CONSTRAINT_NAME}`";
         if ($domain->locales) {
           $locales = explode(CRM_Core_DAO::VALUE_SEPARATOR, $domain->locales);
           foreach ($locales as $locale) {
-            $honor_block_title =  "honor_block_title_{$locale}";
-            $honor_block_text =  "honor_block_text_{$locale}";
+            $honor_block_title = "honor_block_title_{$locale}";
+            $honor_block_text = "honor_block_text_{$locale}";
             $honorParams['soft_credit'] += array(
               $locale => array(
                 'honor_block_title' => $dao->$honor_block_title,
index 18e7a6800ead37098566c09ac72d8d45991cfe62..4bd43d2ef0c4060d2c9bb8e78198f67de783c712 100644 (file)
@@ -106,7 +106,7 @@ WHERE ceft.entity_table = 'civicrm_contribution' AND cft.payment_instrument_id I
       }
     }
     if ($rev == '4.4.6'){
-     $postUpgradeMessage .= '<br /><br /><strong>'. ts('Your contact image urls have been upgraded. If your contact image urls did not follow the standard format for image Urls they have not been upgraded. Please check the log to see image urls that were not upgraded.');
+      $postUpgradeMessage .= '<br /><br /><strong>'. ts('Your contact image urls have been upgraded. If your contact image urls did not follow the standard format for image Urls they have not been upgraded. Please check the log to see image urls that were not upgraded.');
     }
   }
 
@@ -234,12 +234,12 @@ WHERE ceft.entity_table = 'civicrm_contribution' AND cft.payment_instrument_id I
 
       $p[1] = array($acOptionGroupID, 'Integer');
       if ($avinc) {
-        $p[2] = array($avinc+$maxVal, 'Integer');
-        $p[3] = array($avinc+$maxWeight, 'Integer');
+        $p[2] = array($avinc + $maxVal, 'Integer');
+        $p[3] = array($avinc + $maxWeight, 'Integer');
       }
       if ($nsinc) {
-        $p[4] = array($nsinc+$maxVal, 'Integer');
-        $p[5] = array($nsinc+$maxWeight, 'Integer');
+        $p[4] = array($nsinc + $maxVal, 'Integer');
+        $p[5] = array($nsinc + $maxWeight, 'Integer');
       }
       $insertStatus = implode(',', $insertStatus);
 
@@ -275,13 +275,13 @@ VALUES {$insertStatus}";
 {$fkConstraint}
 ";
       // CRM-14036 : delete entries of un-mapped contacts
-        CRM_Core_DAO::executeQuery("DELETE ac FROM civicrm_activity_contact ac
+      CRM_Core_DAO::executeQuery("DELETE ac FROM civicrm_activity_contact ac
 LEFT JOIN civicrm_contact c
 ON c.id = ac.contact_id
 WHERE c.id IS NULL;
 ");
-        // delete entries of un-mapped activities
-        CRM_Core_DAO::executeQuery("DELETE ac FROM civicrm_activity_contact ac
+      // delete entries of un-mapped activities
+      CRM_Core_DAO::executeQuery("DELETE ac FROM civicrm_activity_contact ac
 LEFT JOIN civicrm_activity a
 ON a.id = ac.activity_id
 WHERE a.id IS NULL;
@@ -329,7 +329,6 @@ ALTER TABLE civicrm_dashboard
     // CRM-13998 : missing alter statements for civicrm_report_instance
     $this->addTask(ts('Confirm civicrm_report_instance sql table for upgrades'), 'updateReportInstanceTable');
 
-
     return TRUE;
   }
 
@@ -384,24 +383,24 @@ ALTER TABLE civicrm_dashboard
       $imageURL = $dao->image_url;
       $baseurl = CIVICRM_UF_BASEURL;
       $baselen = strlen($baseurl);
-      if (substr($imageURL, 0, $baselen)==$baseurl){
+      if (substr($imageURL, 0, $baselen) == $baseurl){
         $photo = basename($dao->image_url);
         $config = CRM_Core_Config::singleton();
         $fullpath = $config->customFileUploadDir.$photo;
-          if (file_exists($fullpath)){
-            // For anyone who upgraded 4.4.6 release (eg 4.4.0=>4.4.6), the $newImageUrl incorrectly used backend URLs.
-            // For anyone who skipped 4.4.6 (eg 4.4.0=>4.4.7), the $newImageUrl correctly uses frontend URLs
-            self::setContactImageUrl($dao->id,
+        if (file_exists($fullpath)){
+          // For anyone who upgraded 4.4.6 release (eg 4.4.0=>4.4.6), the $newImageUrl incorrectly used backend URLs.
+          // For anyone who skipped 4.4.6 (eg 4.4.0=>4.4.7), the $newImageUrl correctly uses frontend URLs
+          self::setContactImageUrl($dao->id,
               CRM_Utils_System::url('civicrm/contact/imagefile', 'photo='.$photo, TRUE, NULL, TRUE, TRUE));
-          }
-          else{
-            $failures[$dao->id] = $dao->image_url;
-          }
         }
         else{
-            $failures[$dao->id] = $dao->image_url;
+          $failures[$dao->id] = $dao->image_url;
         }
       }
+      else{
+        $failures[$dao->id] = $dao->image_url;
+      }
+    }
     CRM_Core_Error::debug_var('imageUrlsNotUpgraded', $failures);
     return TRUE;
   }
@@ -552,7 +551,7 @@ WHERE  option_group_id = {$optionGroupID} AND value IN ($ovValues)";
     }
 
     if (!$assigneeID || !$sourceID || !$targetID ) {
-      $insert =  "
+      $insert = "
 INSERT INTO civicrm_option_value
 (option_group_id, label, value, name, weight, is_reserved, is_active)
 VALUES
@@ -582,7 +581,6 @@ CREATE TABLE IF NOT EXISTS civicrm_activity_contact (
 
     $dao = CRM_Core_DAO::executeQuery($query);
 
-
     $query = "
 INSERT INTO civicrm_activity_contact (activity_id, contact_id, record_type_id)
 SELECT      activity_id, target_contact_id, {$targetID} as record_type_id
@@ -604,21 +602,21 @@ WHERE       source_contact_id IS NOT NULL";
 
     $dao = CRM_Core_DAO::executeQuery($query);
 
-   $query = "DROP TABLE civicrm_activity_target";
-   $dao = CRM_Core_DAO::executeQuery($query);
+    $query = "DROP TABLE civicrm_activity_target";
+    $dao = CRM_Core_DAO::executeQuery($query);
 
-   $query = "DROP TABLE civicrm_activity_assignment";
-   $dao = CRM_Core_DAO::executeQuery($query);
+    $query = "DROP TABLE civicrm_activity_assignment";
+    $dao = CRM_Core_DAO::executeQuery($query);
 
-   $query = "ALTER  TABLE civicrm_activity
+    $query = "ALTER  TABLE civicrm_activity
      DROP FOREIGN KEY FK_civicrm_activity_source_contact_id";
 
-   $dao = CRM_Core_DAO::executeQuery($query);
+    $dao = CRM_Core_DAO::executeQuery($query);
 
-   $query = "ALTER  TABLE civicrm_activity DROP COLUMN source_contact_id";
-   $dao = CRM_Core_DAO::executeQuery($query);
+    $query = "ALTER  TABLE civicrm_activity DROP COLUMN source_contact_id";
+    $dao = CRM_Core_DAO::executeQuery($query);
 
-   return TRUE;
+    return TRUE;
   }
 
   /**
@@ -745,7 +743,7 @@ CREATE TABLE IF NOT EXISTS `civicrm_word_replacement` (
           foreach ($localeCustomArray as $localCustomData) {
             // Traverse status array "enabled" "disabled"
             foreach ($localCustomData as $status => $matchTypes) {
-              $params["is_active"] = ($status == "enabled")?TRUE:FALSE;
+              $params["is_active"] = ($status == "enabled") ? TRUE : FALSE;
               // Traverse Match Type array "wildcardMatch" "exactMatch"
               foreach ($matchTypes as $matchType => $words) {
                 $params["match_type"] = $matchType;
index d6fb34a6b28cbc0672960fcb2831a8d7359b2f8f..f11c4d2652f1e28bb786e12de6109397036f400c 100644 (file)
@@ -105,7 +105,6 @@ class CRM_Upgrade_Incremental_php_FourOne {
     $upgrade = new CRM_Upgrade_Form();
     $upgrade->processSQL($rev);
 
-
     $this->transferPreferencesToSettings();
     $this->createNewSettings();
 
@@ -144,7 +143,6 @@ class CRM_Upgrade_Incremental_php_FourOne {
       ),
     );
 
-
     $userColumnNames = array(
       self::NAVIGATION_NAME => array(
         'navigation',
index 1b28b7e31c0397d488469df595a0fed93713c1c4..084aadd7df1b2f3bcfad512b4fae3d82e5f72d82 100644 (file)
@@ -69,9 +69,9 @@ class CRM_Upgrade_Incremental_php_FourSix {
    * @return void
    */
   public function setPostUpgradeMessage(&$postUpgradeMessage, $rev) {
-   if ($rev == '4.6.alpha1') {
+    if ($rev == '4.6.alpha1') {
       $postUpgradeMessage .= '<br /><br />' . ts('Default versions of the following System Workflow Message Templates have been modified to handle new functionality: <ul><li>Events - Registration Confirmation and Receipt (on-line)</li><li>Events - Registration Confirmation and Receipt (off-line)</li><li>Contributions - Receipt (on-line)</li><li>Contributions - Receipt (off-line)</li><li>Memberships - Receipt (on-line)</li><li>Memberships - Signup and Renewal Receipts (off-line)</li></ul> If you have modified these templates, please review the new default versions and implement updates as needed to your copies (Administer > Communications > Message Templates > System Workflow Messages).');
-    }
+   }
   }
 
 
index d4725328ff13a12964dcec4a02016d506d321ea0..c03f54d178fe571a9b3a054f8896fac353382b47 100644 (file)
@@ -61,7 +61,7 @@ class CRM_Upgrade_Incremental_php_FourTwo {
    */
   public function setPreUpgradeMessage(&$preUpgradeMessage, $rev, $currentVer = NULL) {
     if ($rev == '4.2.alpha1') {
-      $tables = array('civicrm_contribution_page','civicrm_event','civicrm_group','civicrm_contact');
+      $tables = array('civicrm_contribution_page', 'civicrm_event', 'civicrm_group', 'civicrm_contact');
       if (!CRM_Core_DAO::schemaRequiresRebuilding($tables)){
         $errors = ts("The upgrade has identified some schema integrity issues in the database. It seems some of your constraints are missing. You will have to rebuild your schema before re-trying the upgrade. Please refer to %1.", array(1 => CRM_Utils_System::docURL2("Ensuring Schema Integrity on Upgrades", FALSE, "Ensuring Schema Integrity on Upgrades", NULL, NULL, "wiki")));
         CRM_Core_Error::fatal($errors);
@@ -97,12 +97,12 @@ ORDER BY mp.contribution_id, mp.membership_id";
           $invalidDataMessage .= "<td>{$invalidData->end_date}</td>";
           $invalidDataMessage .= "<td>" . CRM_Utils_Array::value($invalidData->status_id, $membershipStatus) . "</td>";
           $invalidDataMessage .= "</tr>";
-          }
+        }
         $invalidDataMessage .= "</table><p>" . ts('If you have reviewed the cleanup script documentation on the wiki and you are ready to run the cleanup now - <a href="%1">click here</a>.', array(1 => CRM_Utils_System::url('civicrm/upgrade/cleanup425', 'reset=1'))) . "</p>";
         CRM_Core_Error::fatal($invalidDataMessage);
         return FALSE;
-        }
       }
+    }
 
     if ($rev == '4.2.beta2') {
       // note: error conditions are also checked in upgrade_4_2_beta2()
@@ -140,7 +140,7 @@ INNER JOIN civicrm_price_set cps ON cps.id = cpf.price_set_id AND cps.name <>'de
         $errors = ts("We found unexpected data values from an older version of CiviCRM in your database. The upgrade can not be run until this condition is corrected.<br /><br />Details: One or more rows are present in the civicrm_option_group with name like 'civicrm_price_field.amount.%'. <a href='%1'>Check here for information on diagnosing and correcting this problem.</a>", array(1 => 'http://forum.civicrm.org/index.php/topic,27744.msg118748.html#msg118748'));
         CRM_Core_Error::fatal($errors);
         return FALSE;
-  }
+      }
     }
   }
 
@@ -160,11 +160,11 @@ INNER JOIN civicrm_price_set cps ON cps.id = cpf.price_set_id AND cps.name <>'de
         $postUpgradeMessage .= '<br />' . ts('Please <a href="%1" target="_blank">configure the Extension Resource URL</a>.', array(
           1 => CRM_Utils_System::url('civicrm/admin/setting/url', 'reset=1')
         ));
-  }
+      }
     }
     if ($rev == '4.2.7') {
       $postUpgradeMessage .= '<br />' . ts('If you have configured a report instance to allow anonymous access, you will need to reset the permission to Everyone for that instance (under the Report Settings pane).');
-  }
+    }
   }
 
   /**
@@ -174,12 +174,13 @@ INNER JOIN civicrm_price_set cps ON cps.id = cpf.price_set_id AND cps.name <>'de
     //checking whether the foreign key exists before dropping it
     //drop foreign key queries of CRM-9850
     $params = array();
-    $tables = array('civicrm_contribution_page' =>'FK_civicrm_contribution_page_payment_processor_id',
+    $tables = array(
+    'civicrm_contribution_page' => 'FK_civicrm_contribution_page_payment_processor_id',
                     'civicrm_event' => 'FK_civicrm_event_payment_processor_id',
                     'civicrm_group' => 'FK_civicrm_group_saved_search_id',
                     );
     foreach($tables as $tableName => $fKey){
-      $foreignKeyExists = CRM_Core_DAO::checkConstraintExists($tableName,$fKey);
+      $foreignKeyExists = CRM_Core_DAO::checkConstraintExists($tableName, $fKey);
       if ($foreignKeyExists){
         CRM_Core_DAO::executeQuery("ALTER TABLE {$tableName} DROP FOREIGN KEY {$fKey}", $params, TRUE, NULL, FALSE, FALSE);
         CRM_Core_DAO::executeQuery("ALTER TABLE {$tableName} DROP INDEX {$fKey}", $params, TRUE, NULL, FALSE, FALSE);
@@ -411,7 +412,7 @@ WHERE  name LIKE '%.amount.%' ";
     while ($dao->fetch()) {
       $addTo = explode('.', $dao->name);
       if (!empty($addTo[2])) {
-        $options = array ('optionGroup' => $dao->name);
+        $options = array('optionGroup' => $dao->name);
         self::createPriceSet($daoName, $addTo, $options);
       }
       CRM_Core_OptionGroup::deleteAssoc($dao->name);
@@ -428,7 +429,8 @@ WHERE     cpse.price_set_id IS NULL";
     $addTo = array('civicrm_contribution_page');
     while ($dao->fetch()) {
       $addTo[2] = $dao->contribution_page_id;
-      $options = array ('otherAmount' =>$dao->is_allow_other_amount,
+      $options = array(
+      'otherAmount' => $dao->is_allow_other_amount,
                       'membership' => $dao->membership_block_id );
       self::createPriceSet($daoName, $addTo, $options);
     }
@@ -440,21 +442,21 @@ WHERE     cpse.price_set_id IS NULL";
    * (Queue Task Callback)
    */
   public static function task_4_2_x_runSql(CRM_Queue_TaskContext $ctx, $rev) {
-      $upgrade = new CRM_Upgrade_Form();
-      $upgrade->processSQL($rev);
+    $upgrade = new CRM_Upgrade_Form();
+    $upgrade->processSQL($rev);
 
-      // now rebuild all the triggers
-      // CRM-9716
-      // FIXME // CRM_Core_DAO::triggerRebuild();
+    // now rebuild all the triggers
+    // CRM-9716
+    // FIXME // CRM_Core_DAO::triggerRebuild();
 
-      return TRUE;
+    return TRUE;
   }
 
   /**
    *
    * create price sets
    */
-  public static function createPriceSet($daoName, $addTo,  $options = array()) {
+  public static function createPriceSet($daoName, $addTo, $options = array()) {
     $query = "SELECT title FROM {$addTo[0]} where id =%1";
     $setParams['title']  = CRM_Core_DAO::singleValueQuery($query,
       array(1 => array($addTo[2], 'Integer'))
@@ -471,8 +473,9 @@ WHERE     cpse.price_set_id IS NULL";
     $optionValue = array();
     if (!empty($options['optionGroup'])) {
       CRM_Core_OptionGroup::getAssoc($options['optionGroup'], $optionValue);
-      if (empty($optionValue))
+      if (empty($optionValue)) {
         return;
+      }
     }
     elseif (empty($options['otherAmount']) && empty($options['membership'])) {
       //CRM-12273
@@ -480,11 +483,11 @@ WHERE     cpse.price_set_id IS NULL";
       return;
     }
 
-    if (! CRM_Core_DAO::getFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_BAO_Set', $pageTitle, 'id', 'name', true)) {
+    if (! CRM_Core_DAO::getFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_BAO_Set', $pageTitle, 'id', 'name', TRUE)) {
       $setParams['name'] = $pageTitle;
     }
     else {
-      $timeSec = explode(".", microtime(true));
+      $timeSec = explode(".", microtime(TRUE));
       $setParams['name'] = $pageTitle . '_' . date('is', $timeSec[0]) . $timeSec[1];
     }
     $setParams['extends'] = $daoName[$addTo[0]][1];
@@ -950,7 +953,7 @@ VALUES
         $contribStatus  = CRM_Utils_Array::value($dao->contribution_status_id, $contributionStatus);
         $processedRecords[] = array($dao->contact_id, $dao->contribution_id, $contribStatus, $dao->membership_id,
                                     $memType, $dao->start_date, $dao->end_date, $memStatus, $status);
-}
+      }
     }
 
     if ( !empty($processedRecords) ) {
index 29db710fbfbeeb7c31afffe0ebbbb9f9a16c2ebf..9afb3c7f3ced156e9b351d077f424049ed5258e9 100644 (file)
@@ -313,7 +313,8 @@ FROM   civicrm_option_value v,
 WHERE  v.option_group_id = g.id
   AND  g.name      = %1
   AND  g.is_active = 1
-  AND  v.name      = %2", array(1 => array('activity_type', 'String'),
+  AND  v.name      = %2", array(
+    1 => array('activity_type', 'String'),
         2 => array('Bulk Email', 'String'),
       ));
 
@@ -352,7 +353,8 @@ INSERT INTO civicrm_uf_join
 VALUES
     (1, 'OnBehalf', 'civicrm_contribution_page', %1, 1, %2)";
 
-      $params = array(1 => array($pages->id, 'Integer'),
+      $params = array(
+      1 => array($pages->id, 'Integer'),
         2 => array($onBehalfProfileId, 'Integer'),
       );
       CRM_Core_DAO::executeQuery($query, $params);
index f7a56beb17cb83fe2550d2c2d6a18ae735bf98fc..654bda1c13082d0116d8836abbbeef29142622f7 100644 (file)
@@ -67,7 +67,8 @@ class CRM_Upgrade_Incremental_php_ThreeThree {
     while ($customField->fetch()) {
       $name = CRM_Utils_String::munge($customField->label, '_', 64);
       $fldCnt = CRM_Core_DAO::singleValueQuery($customFldCntQuery,
-        array(1 => array($name, 'String'),
+        array(
+      1 => array($name, 'String'),
           2 => array($customField->id, 'Integer'),
         ), TRUE, FALSE
       );
@@ -79,7 +80,8 @@ Update `civicrm_custom_field`
 SET `name` = %1
 WHERE id = %2
 ";
-      $customFieldParams = array(1 => array($name, 'String'),
+      $customFieldParams = array(
+      1 => array($name, 'String'),
         2 => array($customField->id, 'Integer'),
       );
       CRM_Core_DAO::executeQuery($customFieldQuery, $customFieldParams, TRUE, NULL, FALSE, FALSE);
@@ -94,7 +96,8 @@ WHERE id = %2
     while ($customGroup->fetch()) {
       $name = CRM_Utils_String::munge($customGroup->title, '_', 64);
       $grpCnt = CRM_Core_DAO::singleValueQuery($customGrpCntQuery,
-        array(1 => array($name, 'String'),
+        array(
+      1 => array($name, 'String'),
           2 => array($customGroup->id, 'Integer'),
         )
       );
@@ -113,7 +116,8 @@ WHERE id = %2
     while ($ufGroup->fetch()) {
       $name = CRM_Utils_String::munge($ufGroup->title, '_', 64);
       $ufGrpCnt = CRM_Core_DAO::singleValueQuery($ufGrpCntQuery,
-        array(1 => array($name, 'String'),
+        array(
+      1 => array($name, 'String'),
           2 => array($ufGroup->id, 'Integer'),
         )
       );
@@ -148,7 +152,6 @@ WHERE id = %2
     $updateLineItem1 = "ALTER TABLE civicrm_line_item ADD COLUMN price_field_value_id int(10) unsigned default NULL;";
     CRM_Core_DAO::executeQuery($updateLineItem1);
 
-
     $priceFieldDAO = new CRM_Price_DAO_PriceField();
     $priceFieldDAO->find();
     $ids = array();
@@ -217,7 +220,8 @@ WHERE id = %2
         // update civicrm_line_item for price_field_value_id.
         // Used query to avoid line by line update.
         if ($labelFound || $priceFound) {
-          $lineItemParams = array(1 => array($fieldValueDAO->id, 'Integer'),
+          $lineItemParams = array(
+          1 => array($fieldValueDAO->id, 'Integer'),
             2 => array($opValueDAO->label, 'String'),
           );
           $updateLineItems = "UPDATE civicrm_line_item SET price_field_value_id = %1 WHERE label = %2";
@@ -262,7 +266,8 @@ WHERE id = %2
     $mainLineItem->find(TRUE);
     while ($mainLineItem->fetch()) {
       $dupeLineItem = new CRM_Price_BAO_LineItem();
-      foreach ($fields as $fld) $dupeLineItem->$fld = $mainLineItem->$fld;
+      foreach ($fields as $fld) { $dupeLineItem->$fld = $mainLineItem->$fld;
+      }
       $dupeLineItem->find(TRUE);
       $dupeLineItem->addWhere("id != $mainLineItem->id");
       while ($dupeLineItem->fetch()) {
index 094c8cf36983425fc1bf0ca59cd7d95cc4d22246..8325c3f6331c30012f232d478973d432fcea8165 100644 (file)
@@ -41,8 +41,9 @@ class CRM_Upgrade_Page_Cleanup  extends CRM_Core_Page {
     $preMessage = !empty($rows) ? ts('The following records have been processed. Membership records with action = Un-linked have been disconnected from the listed contribution record:') : ts('Could not find any records to process.');
     $template->assign('preMessage', $preMessage);
 
-    $postMessage =  ts('You can <a href="%1">click here</a> to try running the 4.2 upgrade script again. <a href="%2" target="_blank">(Review upgrade documentation)</a>',
-                    array(1 => CRM_Utils_System::url('civicrm/upgrade', 'reset=1'),
+    $postMessage = ts('You can <a href="%1">click here</a> to try running the 4.2 upgrade script again. <a href="%2" target="_blank">(Review upgrade documentation)</a>',
+                    array(
+    1 => CRM_Utils_System::url('civicrm/upgrade', 'reset=1'),
                           2 => 'http://wiki.civicrm.org/confluence/display/CRMDOC/Installation+and+Upgrades'));
     $template->assign('postMessage', $postMessage);
 
index 21108dc984c0f3694cf750602776d2d3d8bcedd2..bb1e2f8fded890e7515ea759a0e976e081012bbb 100644 (file)
@@ -143,7 +143,8 @@ class CRM_Upgrade_Snapshot_V4p2_Price_BAO_Field extends CRM_Upgrade_Snapshot_V4p
           if ($opId = CRM_Utils_Array::value($index, $opIds)) {
             $optionsIds['id'] = $opId;
           }
-          else $optionsIds['id'] = NULL;
+          else { $optionsIds['id'] = NULL;
+          }
         }
         CRM_Upgrade_Snapshot_V4p2_Price_BAO_FieldValue::create($options, $optionsIds);
       }
@@ -222,8 +223,8 @@ class CRM_Upgrade_Snapshot_V4p2_Price_BAO_Field extends CRM_Upgrade_Snapshot_V4p
     $elementName,
     $fieldId,
     $inactiveNeeded,
-    $useRequired  = TRUE,
-    $label        = NULL,
+    $useRequired = TRUE,
+    $label = NULL,
     $fieldOptions = NULL,
     $freezeOptions = array()
   ) {
@@ -243,11 +244,11 @@ class CRM_Upgrade_Snapshot_V4p2_Price_BAO_Field extends CRM_Upgrade_Snapshot_V4p
     $currencyName = $config->defaultCurrency;
 
     if (!isset($label)) {
-      $label = (property_exists($qf,'_membershipBlock') && !empty($qf->_membershipBlock['is_separate_payment']) && $field->name == 'contribution_amount' && empty($otherAmount['is_allow_other_amount'])) ? ts('Additional Contribution') : $field->label;
+      $label = (property_exists($qf, '_membershipBlock') && !empty($qf->_membershipBlock['is_separate_payment']) && $field->name == 'contribution_amount' && empty($otherAmount['is_allow_other_amount'])) ? ts('Additional Contribution') : $field->label;
     }
 
     if ($field->name == 'contribution_amount') {
-        $qf->_contributionAmount = 1;
+      $qf->_contributionAmount = 1;
     }
 
     if (isset($qf->_online) && $qf->_online) {
@@ -270,17 +271,17 @@ class CRM_Upgrade_Snapshot_V4p2_Price_BAO_Field extends CRM_Upgrade_Snapshot_V4p
         $priceVal  = implode($seperator, array($customOption[$optionKey][$valueFieldName], $count, $max_value));
 
         $extra = array();
-        if (property_exists($qf,'_quickConfig') && $qf->_quickConfig && property_exists($qf,'_contributionAmount') && $qf->_contributionAmount) {
+        if (property_exists($qf, '_quickConfig') && $qf->_quickConfig && property_exists($qf, '_contributionAmount') && $qf->_contributionAmount) {
           $qf->assign('priceset', $elementName);
           $extra = array('onclick' => 'useAmountOther();');
         }
 
         // if seperate membership payment is used with quick config priceset then change the other amount label
-        if (property_exists($qf,'_membershipBlock') && !empty($qf->_membershipBlock['is_separate_payment']) && $qf->_quickConfig && $field->name == 'other_amount' && !property_exists($qf,'_contributionAmount')) {
-            $label = ts('Additional Contribution');
-            $useRequired = 0;
+        if (property_exists($qf, '_membershipBlock') && !empty($qf->_membershipBlock['is_separate_payment']) && $qf->_quickConfig && $field->name == 'other_amount' && !property_exists($qf, '_contributionAmount')) {
+          $label = ts('Additional Contribution');
+          $useRequired = 0;
         } elseif (!empty($fieldOptions[$optionKey]['label'])) {      //check for label.
-            $label = $fieldOptions[$optionKey]['label'];
+          $label = $fieldOptions[$optionKey]['label'];
         }
 
         if ($field->is_display_amounts) {
@@ -290,7 +291,8 @@ class CRM_Upgrade_Snapshot_V4p2_Price_BAO_Field extends CRM_Upgrade_Snapshot_V4p
 
         $element = &$qf->add('text', $elementName, $label,
           array_merge($extra,
-            array('price' => json_encode(array($optionKey, $priceVal)),
+            array(
+        'price' => json_encode(array($optionKey, $priceVal)),
               'size' => '4',
             )
           ),
@@ -317,7 +319,7 @@ class CRM_Upgrade_Snapshot_V4p2_Price_BAO_Field extends CRM_Upgrade_Snapshot_V4p
       case 'Radio':
         $choice = array();
 
-        if (property_exists($qf, '_quickConfig') && $qf->_quickConfig && property_exists($qf,'_contributionAmount') && $qf->_contributionAmount) {
+        if (property_exists($qf, '_quickConfig') && $qf->_quickConfig && property_exists($qf, '_contributionAmount') && $qf->_contributionAmount) {
           $qf->assign('contriPriceset', $elementName);
         }
 
@@ -329,17 +331,19 @@ class CRM_Upgrade_Snapshot_V4p2_Price_BAO_Field extends CRM_Upgrade_Snapshot_V4p
           $count     = CRM_Utils_Array::value('count', $opt, '');
           $max_value = CRM_Utils_Array::value('max_value', $opt, '');
           $priceVal  = implode($seperator, array($opt[$valueFieldName], $count, $max_value));
-          $extra = array('price' => json_encode(array($elementName, $priceVal)),
+          $extra = array(
+          'price' => json_encode(array($elementName, $priceVal)),
                          'data-amount' => $opt[$valueFieldName],
                          'data-currency' => $currencyName,
                          );
           if (property_exists($qf, '_quickConfig') && $qf->_quickConfig && $field->name == 'contribution_amount') {
             $extra += array('onclick' => 'clearAmountOther();');
           } elseif (property_exists($qf, '_quickConfig') && $qf->_quickConfig && $field->name == 'membership_amount') {
-            $extra += array('onclick' => "return showHideAutoRenew({$opt['membership_type_id']});",
+            $extra += array(
+            'onclick' => "return showHideAutoRenew({$opt['membership_type_id']});",
                             'membership-type' => $opt['membership_type_id'],
                             );
-            $qf->assign('membershipFieldID',$field->id);
+            $qf->assign('membershipFieldID', $field->id);
           }
           $choice[$opId] = $qf->createElement('radio', NULL, '', $opt['label'], $opt['id'], $extra);
 
@@ -429,7 +433,8 @@ class CRM_Upgrade_Snapshot_V4p2_Price_BAO_Field extends CRM_Upgrade_Snapshot_V4p
             $opt['label'] .= CRM_Utils_Money::format($opt[$valueFieldName]);
           }
           $check[$opId] = &$qf->createElement('checkbox', $opt['id'], NULL, $opt['label'],
-            array('price' => json_encode(array($opt['id'], $priceVal)),
+            array(
+          'price' => json_encode(array($opt['id'], $priceVal)),
               'data-amount' => $opt[$valueFieldName],
               'data-currency' => $currencyName,
             )
index 2346c90a1697806f6a215ef24e2a41e68a64405f..9eee0fe704c6ac2dca4eade350ce56f647fc60ad 100644 (file)
@@ -86,7 +86,8 @@ class CRM_Upgrade_Snapshot_V4p2_Price_BAO_FieldValue extends CRM_Upgrade_Snapsho
     }
 
     if ($id = CRM_Utils_Array::value('id', $ids)) {
-      if (isset($params['name']))unset($params['name']);
+      if (isset($params['name'])) { unset($params['name']);
+      }
 
       $oldWeight = NULL;
       if ($id) {
index 1f485c7be9fd30ee4d5a25297f1516cf693f13dd..5c6b5808493e576c11d5b26267489c596a1449a7 100644 (file)
@@ -182,7 +182,7 @@ WHERE     %2.id = %1";
    *                          to the price set used for particular event
    * @param array $values
    *   Reference to the values array(.
-     this is
+  this is
    *                          lineItem array)
    *
    * @return void
@@ -266,8 +266,9 @@ WHERE     %2.id = %1";
    * @param array $otherParams
    */
   public static function syncLineItems($entityId, $entityTable = 'civicrm_contribution', $amount, $otherParams = NULL) {
-    if (!$entityId || CRM_Utils_System::isNull($amount))
+    if (!$entityId || CRM_Utils_System::isNull($amount)) {
       return;
+    }
 
     $from = " civicrm_line_item li
 LEFT JOIN   civicrm_price_field pf ON pf.id = li.price_field_id
@@ -296,7 +297,7 @@ LEFT JOIN civicrm_price_field_value cpfv ON cpfv.price_field_id = pf.id and cpfv
       $set .= " ,li.label = %4,
                 li.price_field_value_id = cpfv.id ";
       $where .= " AND cpse.entity_table = 'civicrm_event' AND cpse.entity_id = %5 ";
-      $amount = empty($amount) ? 0: $amount;
+      $amount = empty($amount) ? 0 : $amount;
       $params += array(
         4 => array($otherParams['fee_label'], 'String'),
         5 => array($otherParams['event_id'], 'String'),
index d124af498a64b4283338cdbb004ca4329df54f2a..c9b9f16c0aed992121995f03fdeaeb87f11188a6 100644 (file)
@@ -124,13 +124,12 @@ WHERE       ps.name = '{$entityName}'
     $dao = CRM_Core_DAO::executeQuery($sql);
     $defaultPriceSet = array();
     while ($dao->fetch()) {
-        $defaultPriceSet[$dao->priceFieldValueID]['setID'] = $dao->setID;
-        $defaultPriceSet[$dao->priceFieldValueID]['priceFieldID'] = $dao->priceFieldID;
-        $defaultPriceSet[$dao->priceFieldValueID]['name'] = $dao->name;
-        $defaultPriceSet[$dao->priceFieldValueID]['label'] = $dao->label;
+      $defaultPriceSet[$dao->priceFieldValueID]['setID'] = $dao->setID;
+      $defaultPriceSet[$dao->priceFieldValueID]['priceFieldID'] = $dao->priceFieldID;
+      $defaultPriceSet[$dao->priceFieldValueID]['name'] = $dao->name;
+      $defaultPriceSet[$dao->priceFieldValueID]['label'] = $dao->label;
     }
 
-
     return $defaultPriceSet;
   }
 
@@ -176,7 +175,7 @@ WHERE    price_set_id = %1";
       return $tables;
     }
     if (empty($forms)) {
-    $queryString = "
+      $queryString = "
 SELECT    cli.entity_table, cli.entity_id
 FROM      civicrm_line_item cli
 LEFT JOIN civicrm_price_field cpf ON cli.price_field_id = cpf.id
@@ -360,7 +359,8 @@ WHERE     ct.id = cp.contribution_type_id AND
     if ($isQuickConfig) {
       $sql .= " AND ps.is_quick_config = 0 ";
     }
-    $params = array(1 => array($entityTable, 'String'),
+    $params = array(
+    1 => array($entityTable, 'String'),
       2 => array($entityId, 'Integer'),
     );
     if ($usedFor) {
@@ -681,22 +681,22 @@ WHERE  id = %1";
           if ($params["price_{$id}"] <= 0) {
             continue;
           }
-        $params["price_{$id}"] = array($params["price_{$id}"] => 1);
-        $optionValueId = CRM_Utils_Array::key(1, $params["price_{$id}"]);
-        $optionLabel = CRM_Utils_Array::value('label', $field['options'][$optionValueId]);
-        $params['amount_priceset_level_radio'] = array();
-        $params['amount_priceset_level_radio'][$optionValueId] = $optionLabel;
-        if (isset($radioLevel)) {
-          $radioLevel = array_merge($radioLevel,
+          $params["price_{$id}"] = array($params["price_{$id}"] => 1);
+          $optionValueId = CRM_Utils_Array::key(1, $params["price_{$id}"]);
+          $optionLabel = CRM_Utils_Array::value('label', $field['options'][$optionValueId]);
+          $params['amount_priceset_level_radio'] = array();
+          $params['amount_priceset_level_radio'][$optionValueId] = $optionLabel;
+          if (isset($radioLevel)) {
+            $radioLevel = array_merge($radioLevel,
             array_keys($params['amount_priceset_level_radio'])
-          );
-        }
-        else {
-          $radioLevel = array_keys($params['amount_priceset_level_radio']);
-        }
-        CRM_Upgrade_Snapshot_V4p2_Price_BAO_LineItem::format($id, $params, $field, $lineItem);
-        $totalPrice += $lineItem[$optionValueId]['line_total'];
-        break;
+            );
+          }
+          else {
+            $radioLevel = array_keys($params['amount_priceset_level_radio']);
+          }
+          CRM_Upgrade_Snapshot_V4p2_Price_BAO_LineItem::format($id, $params, $field, $lineItem);
+          $totalPrice += $lineItem[$optionValueId]['line_total'];
+          break;
 
         case 'Select':
           $params["price_{$id}"] = array($params["price_{$id}"] => 1);
@@ -705,36 +705,37 @@ WHERE  id = %1";
           $params['amount_priceset_level_select'] = array();
           $params['amount_priceset_level_select'][CRM_Utils_Array::key(1, $params["price_{$id}"])] = $optionLabel;
           if (isset($selectLevel)) {
-          $selectLevel = array_merge($selectLevel, array_keys($params['amount_priceset_level_select']));
-        }
-        else {
-        $selectLevel = array_keys($params['amount_priceset_level_select']);
-      }
-      CRM_Upgrade_Snapshot_V4p2_Price_BAO_LineItem::format($id, $params, $field, $lineItem);
-      $totalPrice += $lineItem[$optionValueId]['line_total'];
-      break;
-    case 'CheckBox':
-      $params['amount_priceset_level_checkbox'] = $optionIds = array();
-      foreach ($params["price_{$id}"] as $optionId => $option) {
-        $optionIds[] = $optionId;
-        $optionLabel = $field['options'][$optionId]['label'];
-        $params['amount_priceset_level_checkbox']["{$field['options'][$optionId]['id']}"] = $optionLabel;
-        if (isset($checkboxLevel)) {
-          $checkboxLevel = array_unique(array_merge(
-            $checkboxLevel,
-            array_keys($params['amount_priceset_level_checkbox'])
-          )
-        );
-        }
-        else {
-          $checkboxLevel = array_keys($params['amount_priceset_level_checkbox']);
-        }
-      }
-      CRM_Upgrade_Snapshot_V4p2_Price_BAO_LineItem::format($id, $params, $field, $lineItem);
-      foreach ($optionIds as $optionId) {
-        $totalPrice += $lineItem[$optionId]['line_total'];
-      }
-      break;
+            $selectLevel = array_merge($selectLevel, array_keys($params['amount_priceset_level_select']));
+          }
+          else {
+            $selectLevel = array_keys($params['amount_priceset_level_select']);
+          }
+          CRM_Upgrade_Snapshot_V4p2_Price_BAO_LineItem::format($id, $params, $field, $lineItem);
+          $totalPrice += $lineItem[$optionValueId]['line_total'];
+          break;
+
+        case 'CheckBox':
+          $params['amount_priceset_level_checkbox'] = $optionIds = array();
+          foreach ($params["price_{$id}"] as $optionId => $option) {
+            $optionIds[] = $optionId;
+            $optionLabel = $field['options'][$optionId]['label'];
+            $params['amount_priceset_level_checkbox']["{$field['options'][$optionId]['id']}"] = $optionLabel;
+            if (isset($checkboxLevel)) {
+              $checkboxLevel = array_unique(array_merge(
+              $checkboxLevel,
+              array_keys($params['amount_priceset_level_checkbox'])
+              )
+              );
+            }
+            else {
+              $checkboxLevel = array_keys($params['amount_priceset_level_checkbox']);
+            }
+          }
+          CRM_Upgrade_Snapshot_V4p2_Price_BAO_LineItem::format($id, $params, $field, $lineItem);
+          foreach ($optionIds as $optionId) {
+            $totalPrice += $lineItem[$optionId]['line_total'];
+          }
+          break;
       }
     }
 
@@ -767,106 +768,106 @@ WHERE  id = %1";
    *
    * @return void
    */
-static function buildPriceSet(&$form) {
-$priceSetId = $form->get('priceSetId');
-$userid = $form->getVar('_userID');
-if (!$priceSetId) {
-  return;
-}
+  static function buildPriceSet(&$form) {
+    $priceSetId = $form->get('priceSetId');
+    $userid = $form->getVar('_userID');
+    if (!$priceSetId) {
+      return;
+    }
 
-$validFieldsOnly = TRUE;
-$className = CRM_Utils_System::getClassName($form);
-if (in_array($className, array(
+    $validFieldsOnly = TRUE;
+    $className = CRM_Utils_System::getClassName($form);
+    if (in_array($className, array(
   'CRM_Contribute_Form_Contribution', 'CRM_Member_Form_Membership'))) {
-$validFieldsOnly = FALSE;
-}
+      $validFieldsOnly = FALSE;
+    }
 
-$priceSet           = self::getSetDetail($priceSetId, TRUE, $validFieldsOnly);
-$form->_priceSet    = CRM_Utils_Array::value($priceSetId, $priceSet);
-$form->_quickConfig = $quickConfig = 0;
-if (CRM_Core_DAO::getFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_DAO_Set', $priceSetId, 'is_quick_config')) {
-  $quickConfig = 1;
-}
+    $priceSet           = self::getSetDetail($priceSetId, TRUE, $validFieldsOnly);
+    $form->_priceSet    = CRM_Utils_Array::value($priceSetId, $priceSet);
+    $form->_quickConfig = $quickConfig = 0;
+    if (CRM_Core_DAO::getFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_DAO_Set', $priceSetId, 'is_quick_config')) {
+      $quickConfig = 1;
+    }
 
-$form->assign('quickConfig', $quickConfig);
-if ($className == "CRM_Contribute_Form_Contribution_Main") {
-$form->_quickConfig = $quickConfig;
-}
-$form->assign('priceSet', $form->_priceSet);
+    $form->assign('quickConfig', $quickConfig);
+    if ($className == "CRM_Contribute_Form_Contribution_Main") {
+      $form->_quickConfig = $quickConfig;
+    }
+    $form->assign('priceSet', $form->_priceSet);
 
-$component = 'contribution';
-if ($className == 'CRM_Member_Form_Membership') {
-$component = 'membership';
-}
+    $component = 'contribution';
+    if ($className == 'CRM_Member_Form_Membership') {
+      $component = 'membership';
+    }
 
-if ($className == 'CRM_Contribute_Form_Contribution_Main') {
-$feeBlock = &$form->_values['fee'];
-if (!empty($form->_useForMember)) {
-$component = 'membership';
-}
-}
-else {
-$feeBlock = &$form->_priceSet['fields'];
-}
+    if ($className == 'CRM_Contribute_Form_Contribution_Main') {
+      $feeBlock = &$form->_values['fee'];
+      if (!empty($form->_useForMember)) {
+        $component = 'membership';
+      }
+    }
+    else {
+      $feeBlock = &$form->_priceSet['fields'];
+    }
 
-// call the hook.
-CRM_Utils_Hook::buildAmount($component, $form, $feeBlock);
+    // call the hook.
+    CRM_Utils_Hook::buildAmount($component, $form, $feeBlock);
 
-foreach ($feeBlock as $field) {
-if (CRM_Utils_Array::value('visibility', $field) == 'public' ||
+    foreach ($feeBlock as $field) {
+      if (CRM_Utils_Array::value('visibility', $field) == 'public' ||
 !$validFieldsOnly
 ) {
-$options = CRM_Utils_Array::value('options', $field);
-if ($className == 'CRM_Contribute_Form_Contribution_Main' && $component = 'membership') {
-$checklifetime = self::checkCurrentMembership($options, $userid);
-if ($checklifetime) {
-$form->assign('ispricelifetime', TRUE);
-}
-}
-if (!is_array($options)) {
-  continue;
-}
-CRM_Upgrade_Snapshot_V4p2_Price_BAO_Field::addQuickFormElement($form,
-'price_' . $field['id'],
-$field['id'],
-FALSE,
-CRM_Utils_Array::value('is_required', $field, FALSE),
-NULL,
-$options
-);
-}
-}
-}
+        $options = CRM_Utils_Array::value('options', $field);
+        if ($className == 'CRM_Contribute_Form_Contribution_Main' && $component = 'membership') {
+          $checklifetime = self::checkCurrentMembership($options, $userid);
+          if ($checklifetime) {
+            $form->assign('ispricelifetime', TRUE);
+          }
+        }
+        if (!is_array($options)) {
+          continue;
+        }
+        CRM_Upgrade_Snapshot_V4p2_Price_BAO_Field::addQuickFormElement($form,
+        'price_' . $field['id'],
+        $field['id'],
+        FALSE,
+        CRM_Utils_Array::value('is_required', $field, FALSE),
+        NULL,
+        $options
+        );
+      }
+    }
+  }
 
-/**
- * check the current Membership
- * having end date null.
- */
-static function checkCurrentMembership(&$options, $userid) {
-if (!$userid || empty($options)) {
-return;
-}
-static $_contact_memberships = array();
-$checklifetime = FALSE;
-foreach ($options as $key => $value) {
-if (!empty($value['membership_type_id'])) {
-if (!isset($_contact_memberships[$userid][$value['membership_type_id']])) {
-$_contact_memberships[$userid][$value['membership_type_id']] = CRM_Member_BAO_Membership::getContactMembership($userid, $value['membership_type_id'], FALSE);
-}
-$currentMembership = $_contact_memberships[$userid][$value['membership_type_id']];
-if (!empty($currentMembership) && empty($currentMembership['end_date'])) {
-unset($options[$key]);
-$checklifetime = TRUE;
-}
-}
-}
-if ($checklifetime) {
-return TRUE;
-}
-else {
-return FALSE;
-}
-}
+  /**
  * check the current Membership
  * having end date null.
  */
+  static function checkCurrentMembership(&$options, $userid) {
+    if (!$userid || empty($options)) {
+      return;
+    }
+    static $_contact_memberships = array();
+    $checklifetime = FALSE;
+    foreach ($options as $key => $value) {
+      if (!empty($value['membership_type_id'])) {
+        if (!isset($_contact_memberships[$userid][$value['membership_type_id']])) {
+          $_contact_memberships[$userid][$value['membership_type_id']] = CRM_Member_BAO_Membership::getContactMembership($userid, $value['membership_type_id'], FALSE);
+        }
+        $currentMembership = $_contact_memberships[$userid][$value['membership_type_id']];
+        if (!empty($currentMembership) && empty($currentMembership['end_date'])) {
+          unset($options[$key]);
+          $checklifetime = TRUE;
+        }
+      }
+    }
+    if ($checklifetime) {
+      return TRUE;
+    }
+    else {
+      return FALSE;
+    }
+  }
 
   /**
    * Set daefult the price set fields.
@@ -876,92 +877,93 @@ return FALSE;
    *
    * @return array $defaults
    */
-static function setDefaultPriceSet(&$form, &$defaults) {
-if (!isset($form->_priceSet) || empty($form->_priceSet['fields'])) {
-return $defaults;
-}
+  static function setDefaultPriceSet(&$form, &$defaults) {
+    if (!isset($form->_priceSet) || empty($form->_priceSet['fields'])) {
+      return $defaults;
+    }
 
-foreach ($form->_priceSet['fields'] as $key => $val) {
-foreach ($val['options'] as $keys => $values) {
-if ($values['is_default']) {
-if ($val['html_type'] == 'CheckBox') {
-$defaults["price_{$key}"][$keys] = 1;
-}
-else {
-$defaults["price_{$key}"] = $keys;
-}
-}
-}
-}
-return $defaults;
-}
+    foreach ($form->_priceSet['fields'] as $key => $val) {
+      foreach ($val['options'] as $keys => $values) {
+        if ($values['is_default']) {
+          if ($val['html_type'] == 'CheckBox') {
+            $defaults["price_{$key}"][$keys] = 1;
+          }
+          else {
+            $defaults["price_{$key}"] = $keys;
+          }
+        }
+      }
+    }
+    return $defaults;
+  }
 
-/**
- * Get field ids of a price set
- *
- * @param int id Price Set id
- *
- * @return array of the field ids
- *
- * @static
- */
-public static function getFieldIds($id) {
-$priceField = new CRM_Upgrade_Snapshot_V4p2_Price_DAO_Field();
-$priceField->price_set_id = $id;
-$priceField->find();
-while ($priceField->fetch()) {
-$var[] = $priceField->id;
-}
-return $var;
-}
+  /**
  * Get field ids of a price set
  *
  * @param int id Price Set id
  *
  * @return array of the field ids
  *
  * @static
  */
+  public static function getFieldIds($id) {
+    $priceField = new CRM_Upgrade_Snapshot_V4p2_Price_DAO_Field();
+    $priceField->price_set_id = $id;
+    $priceField->find();
+    while ($priceField->fetch()) {
+      $var[] = $priceField->id;
+    }
+    return $var;
+  }
 
-/**
- * This function is to make a copy of a price set, including
- * all the fields
- *
- * @param int $id
- *   The price set id to copy.
- *
- * @return the copy object
- * @static
- */
-static function copy($id) {
-$maxId = CRM_Core_DAO::singleValueQuery("SELECT max(id) FROM civicrm_price_set");
-
-$title = ts('[Copy id %1]', array(1 => $maxId + 1));
-$fieldsFix = array(
-  'suffix' => array('title' => ' ' . $title,
-'name' => '__Copy_id_' . ($maxId + 1) . '_',
-),
-);
-
-$copy = &CRM_Core_DAO::copyGeneric('CRM_Upgrade_Snapshot_V4p2_Price_DAO_Set',
-array('id' => $id),
-NULL,
-$fieldsFix
-);
-
-//copying all the blocks pertaining to the price set
-$copyPriceField = &CRM_Core_DAO::copyGeneric('CRM_Upgrade_Snapshot_V4p2_Price_DAO_Field',
-array('price_set_id' => $id),
-array('price_set_id' => $copy->id)
-);
-if (!empty($copyPriceField)) {
-$price = array_combine(self::getFieldIds($id), self::getFieldIds($copy->id));
-
-//copy option group and values
-foreach ($price as $originalId => $copyId) {
-CRM_Core_DAO::copyGeneric('CRM_Upgrade_Snapshot_V4p2_Price_DAO_FieldValue',
-array('price_field_id' => $originalId),
-array('price_field_id' => $copyId)
-);
-}
-}
-$copy->save();
+  /**
+   * This function is to make a copy of a price set, including
+   * all the fields
+   *
+   * @param int $id
+   *   The price set id to copy.
+   *
+   * @return the copy object
+   * @static
+   */
+  static function copy($id) {
+    $maxId = CRM_Core_DAO::singleValueQuery("SELECT max(id) FROM civicrm_price_set");
+
+    $title = ts('[Copy id %1]', array(1 => $maxId + 1));
+    $fieldsFix = array(
+    'suffix' => array(
+    'title' => ' ' . $title,
+    'name' => '__Copy_id_' . ($maxId + 1) . '_',
+    ),
+    );
 
-CRM_Utils_Hook::copy('Set', $copy);
-return $copy;
-}
+    $copy = &CRM_Core_DAO::copyGeneric('CRM_Upgrade_Snapshot_V4p2_Price_DAO_Set',
+    array('id' => $id),
+    NULL,
+    $fieldsFix
+    );
+
+    //copying all the blocks pertaining to the price set
+    $copyPriceField = &CRM_Core_DAO::copyGeneric('CRM_Upgrade_Snapshot_V4p2_Price_DAO_Field',
+    array('price_set_id' => $id),
+    array('price_set_id' => $copy->id)
+    );
+    if (!empty($copyPriceField)) {
+      $price = array_combine(self::getFieldIds($id), self::getFieldIds($copy->id));
+
+      //copy option group and values
+      foreach ($price as $originalId => $copyId) {
+        CRM_Core_DAO::copyGeneric('CRM_Upgrade_Snapshot_V4p2_Price_DAO_FieldValue',
+        array('price_field_id' => $originalId),
+        array('price_field_id' => $copyId)
+        );
+      }
+    }
+    $copy->save();
+
+    CRM_Utils_Hook::copy('Set', $copy);
+    return $copy;
+  }
 
   /**
    * This function is to check price set permission
@@ -971,17 +973,17 @@ return $copy;
    *
    * @return bool
    */
-function checkPermission($sid) {
-if ($sid &&
+  function checkPermission($sid) {
+    if ($sid &&
 self::eventPriceSetDomainID()
 ) {
-$domain_id = CRM_Core_DAO::getFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_DAO_Set', $sid, 'domain_id', 'id');
-if (CRM_Core_Config::domainID() != $domain_id) {
-CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
-}
-}
-return TRUE;
-}
+      $domain_id = CRM_Core_DAO::getFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_DAO_Set', $sid, 'domain_id', 'id');
+      if (CRM_Core_Config::domainID() != $domain_id) {
+        CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
+      }
+    }
+    return TRUE;
+  }
 
   /**
    * Get the sum of participant count
@@ -995,20 +997,20 @@ return TRUE;
    * @return int|null|string
    * @static
    */
-public static function getPricesetCount($sid, $onlyActive = TRUE) {
-$count = 0;
-if (!$sid) {
-  return $count;
-}
+  public static function getPricesetCount($sid, $onlyActive = TRUE) {
+    $count = 0;
+    if (!$sid) {
+      return $count;
+    }
 
-$where = NULL;
-if ($onlyActive) {
-  $where = 'AND  value.is_active = 1 AND field.is_active = 1';
-}
+    $where = NULL;
+    if ($onlyActive) {
+      $where = 'AND  value.is_active = 1 AND field.is_active = 1';
+    }
 
-static $pricesetFieldCount;
-if (!isset($pricesetFieldCount[$sid])) {
-$sql = "
+    static $pricesetFieldCount;
+    if (!isset($pricesetFieldCount[$sid])) {
+      $sql = "
     SELECT  sum(value.count) as totalCount
       FROM  civicrm_price_field_value  value
 INNER JOIN  civicrm_price_field field ON ( field.id = value.price_field_id )
@@ -1016,12 +1018,12 @@ INNER JOIN  civicrm_price_set pset    ON ( pset.id = field.price_set_id )
      WHERE  pset.id = %1
             $where";
 
-$count = CRM_Core_DAO::singleValueQuery($sql, array(1 => array($sid, 'Positive')));
-$pricesetFieldCount[$sid] = ($count) ? $count : 0;
-}
+      $count = CRM_Core_DAO::singleValueQuery($sql, array(1 => array($sid, 'Positive')));
+      $pricesetFieldCount[$sid] = ($count) ? $count : 0;
+    }
 
-return $pricesetFieldCount[$sid];
-}
+    return $pricesetFieldCount[$sid];
+  }
 
   /**
    * @param $ids
@@ -1029,38 +1031,38 @@ return $pricesetFieldCount[$sid];
    * @return array
    */
   public static function getMembershipCount($ids) {
-$queryString = "
+    $queryString = "
 SELECT       count( pfv.id ) AS count, pfv.id AS id
 FROM         civicrm_price_field_value pfv
 INNER JOIN    civicrm_membership_type mt ON mt.id = pfv.membership_type_id
 WHERE        pfv.id IN ( $ids )
 GROUP BY     mt.member_of_contact_id";
 
-$crmDAO = CRM_Core_DAO::executeQuery($queryString);
-$count = array();
+    $crmDAO = CRM_Core_DAO::executeQuery($queryString);
+    $count = array();
 
-while ($crmDAO->fetch()) {
-$count[$crmDAO->id] = $crmDAO->count;
-}
+    while ($crmDAO->fetch()) {
+      $count[$crmDAO->id] = $crmDAO->count;
+    }
 
-return $count;
-}
+    return $count;
+  }
 
-/**
- * Function to check if auto renew option should be shown
- *
- * @param int $priceSetId
- *   Price set id.
- *
- * @return int $autoRenewOption ( 0:hide, 1:optional 2:required )
- */
-public static function checkAutoRenewForPriceSet($priceSetId) {
-// auto-renew option should be visible if membership types associated with all the fields has
-// been set for auto-renew option
-// Auto renew checkbox should be frozen if for all the membership type auto renew is required
+  /**
  * Function to check if auto renew option should be shown
  *
  * @param int $priceSetId
  *   Price set id.
  *
  * @return int $autoRenewOption ( 0:hide, 1:optional 2:required )
  */
+  public static function checkAutoRenewForPriceSet($priceSetId) {
+    // auto-renew option should be visible if membership types associated with all the fields has
+    // been set for auto-renew option
+    // Auto renew checkbox should be frozen if for all the membership type auto renew is required
 
-// get the membership type auto renew option and check if required or optional
-$query = 'SELECT mt.auto_renew, mt.duration_interval, mt.duration_unit
+    // get the membership type auto renew option and check if required or optional
+    $query = 'SELECT mt.auto_renew, mt.duration_interval, mt.duration_unit
             FROM civicrm_price_field_value pfv
             INNER JOIN civicrm_membership_type mt ON pfv.membership_type_id = mt.id
             INNER JOIN civicrm_price_field pf ON pfv.price_field_id = pf.id
@@ -1068,31 +1070,31 @@ $query = 'SELECT mt.auto_renew, mt.duration_interval, mt.duration_unit
             AND   pf.is_active = 1
             AND   pfv.is_active = 1';
 
-$params = array(1 => array($priceSetId, 'Integer'));
+    $params = array(1 => array($priceSetId, 'Integer'));
 
-$dao             = CRM_Core_DAO::executeQuery($query, $params);
-$autoRenewOption = 2;
-$interval        = $unit = array();
-while ($dao->fetch()) {
-if (!$dao->auto_renew) {
-$autoRenewOption = 0;
-break;
-}
-if ($dao->auto_renew == 1) {
-$autoRenewOption = 1;
-}
+    $dao             = CRM_Core_DAO::executeQuery($query, $params);
+    $autoRenewOption = 2;
+    $interval        = $unit = array();
+    while ($dao->fetch()) {
+      if (!$dao->auto_renew) {
+        $autoRenewOption = 0;
+        break;
+      }
+      if ($dao->auto_renew == 1) {
+        $autoRenewOption = 1;
+      }
 
-$interval[$dao->duration_interval] = $dao->duration_interval;
-$unit[$dao->duration_unit] = $dao->duration_unit;
-}
+      $interval[$dao->duration_interval] = $dao->duration_interval;
+      $unit[$dao->duration_unit] = $dao->duration_unit;
+    }
 
-if (count($interval) == 1 && count($unit) == 1 && $autoRenewOption > 0) {
-return $autoRenewOption;
-}
-else {
-return 0;
-}
-}
+    if (count($interval) == 1 && count($unit) == 1 && $autoRenewOption > 0) {
+      return $autoRenewOption;
+    }
+    else {
+      return 0;
+    }
+  }
 
   /**
    * Retrieve auto renew frequency and interval
@@ -1103,18 +1105,18 @@ return 0;
    * @return array associate array of frequency interval and unit
    * @static
    */
-   public static function getRecurDetails($priceSetId) {
-     $query = 'SELECT mt.duration_interval, mt.duration_unit
+  public static function getRecurDetails($priceSetId) {
+    $query = 'SELECT mt.duration_interval, mt.duration_unit
             FROM civicrm_price_field_value pfv
             INNER JOIN civicrm_membership_type mt ON pfv.membership_type_id = mt.id
             INNER JOIN civicrm_price_field pf ON pfv.price_field_id = pf.id
             WHERE pf.price_set_id = %1 LIMIT 1';
 
-     $params = array(1 => array($priceSetId, 'Integer'));
-     $dao = CRM_Core_DAO::executeQuery($query, $params);
-     $dao->fetch();
-     return array($dao->duration_interval, $dao->duration_unit);
-   }
+    $params = array(1 => array($priceSetId, 'Integer'));
+    $dao = CRM_Core_DAO::executeQuery($query, $params);
+    $dao->fetch();
+    return array($dao->duration_interval, $dao->duration_unit);
+  }
 
   /**
    * @return object
@@ -1131,7 +1133,7 @@ return 0;
    *
    * @param int $id
    *   Id of the database record.
-   * @param boolean $isQuickConfig
+   * @param bool $isQuickConfigValue we want to set the is_quick_config field.
    *   Value we want to set the is_quick_config field.
    *
    * @return Object                   DAO object on sucess, null otherwise