Merge remote-tracking branch 'upstream/4.5' into 4.5-master-2015-02-16-17-51-20
[civicrm-core.git] / CRM / Upgrade / Incremental / php / FourFour.php
index 6d304608c7d6dbd3d5d87b9cb25723a67e563c87..34f5085ec85480f3bde025e636b0736dc4fedac0 100644 (file)
@@ -22,7 +22,7 @@
  | GNU Affero General Public License or the licensing of CiviCRM,     |
  | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
  +--------------------------------------------------------------------+
-*/
+ */
 
 /**
  *
@@ -46,7 +46,7 @@ class CRM_Upgrade_Incremental_php_FourFour {
   }
 
   /**
-   * Compute any messages which should be displayed beforeupgrade
+   * Compute any messages which should be displayed beforeupgrade.
    *
    * Note: This function is called iteratively for each upcoming
    * revision to the database.
@@ -76,7 +76,7 @@ class CRM_Upgrade_Incremental_php_FourFour {
   }
 
   /**
-   * Compute any messages which should be displayed after upgrade
+   * Compute any messages which should be displayed after upgrade.
    *
    * @param string $postUpgradeMessage
    *   alterable.
@@ -104,7 +104,7 @@ WHERE ceft.entity_table = 'civicrm_contribution' AND cft.payment_instrument_id I
       if ($dao->N) {
         $postUpgradeMessage .= '<br /><br /><strong>' . ts('Your database contains %1 financial transaction records with no payment instrument (Paid By is empty). If you use the Accounting Batches feature this may result in unbalanced transactions. If you do not use this feature, you can ignore the condition (although you will be required to select a Paid By value for new transactions). <a href="%2" target="_blank">You can review steps to correct transactions with missing payment instruments on the wiki.</a>', array(
               1 => $dao->N,
-              2 => 'http://wiki.civicrm.org/confluence/display/CRMDOC/Fixing+Transactions+Missing+a+Payment+Instrument+-+4.4.3+Upgrades'
+              2 => 'http://wiki.civicrm.org/confluence/display/CRMDOC/Fixing+Transactions+Missing+a+Payment+Instrument+-+4.4.3+Upgrades',
             )) . '</strong>';
       }
     }
@@ -357,11 +357,11 @@ ALTER TABLE civicrm_dashboard
   }
 
   /**
-   * @param CRM_Queue_TaskContext $ctx
-   * @param int $startId
-   * @param int $endId
+   * @param $rev
+   * @param $originalVer
+   * @param $latestVer
    *
-   * @return bool
+   * @return void
    */
   public function upgrade_4_4_7($rev, $originalVer, $latestVer) {
     // For WordPress/Joomla(?), cleanup broken image_URL from 4.4.6 upgrades - https://issues.civicrm.org/jira/browse/CRM-14971
@@ -379,16 +379,29 @@ ALTER TABLE civicrm_dashboard
     $this->addTask(ts('Update saved search information'), 'changeSavedSearch');
   }
 
+  /**
+   * Upgrade image URLs.
+   *
+   * @param \CRM_Queue_TaskContext $ctx
+   * @param $startId
+   * @param $endId
+   *
+   * @return bool
+   */
   public static function upgradeImageUrls(CRM_Queue_TaskContext $ctx, $startId, $endId) {
     $dao = self::findContactImageUrls($startId, $endId);
     $failures = array();
+    $config = CRM_Core_Config::singleton();
     while ($dao->fetch()) {
       $imageURL = $dao->image_url;
       $baseurl = CIVICRM_UF_BASEURL;
+      //CRM-15897 - gross hack for joomla to remove the administrator/
+      if ($config->userFramework == 'Joomla') {
+        $baseurl = str_replace("/administrator/", "/", $baseurl);
+      }
       $baselen = strlen($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.
@@ -408,6 +421,13 @@ ALTER TABLE civicrm_dashboard
     return TRUE;
   }
 
+  /**
+   * Change saved search.
+   *
+   * @param \CRM_Queue_TaskContext $ctx
+   *
+   * @return bool
+   */
   public static function changeSavedSearch(CRM_Queue_TaskContext $ctx) {
     $membershipStatuses = array_flip(CRM_Member_PseudoConstant::membershipStatus());
 
@@ -788,9 +808,9 @@ CREATE TABLE IF NOT EXISTS `civicrm_word_replacement` (
   }
 
 
-  /***
+  /**
    * CRM-13998 missing alter statements for civicrm_report_instance
-   ***/
+   */
   public function updateReportInstanceTable() {
 
     // add civicrm_report_instance.name
@@ -832,4 +852,5 @@ CREATE TABLE IF NOT EXISTS `civicrm_word_replacement` (
     }
     return $result;
   }
+
 }