Merge remote-tracking branch 'upstream/4.5' into 4.5-master-2015-02-16-17-51-20
authorkurund <kurund@civicrm.org>
Mon, 16 Feb 2015 12:46:40 +0000 (18:16 +0530)
committerkurund <kurund@civicrm.org>
Mon, 16 Feb 2015 12:46:40 +0000 (18:16 +0530)
Conflicts:
CRM/Upgrade/Incremental/php/FourFour.php

1  2 
CRM/Upgrade/Incremental/php/FourFour.php

index 54bc8157bbf80330391780edc0a9512971e4cb5c,0a887b1258789ee0297f28e9553bf9a06d02a5c3..34f5085ec85480f3bde025e636b0736dc4fedac0
@@@ -379,40 -375,35 +379,44 @@@ ALTER TABLE civicrm_dashboar
      $this->addTask(ts('Update saved search information'), 'changeSavedSearch');
    }
  
 -  static function upgradeImageUrls(CRM_Queue_TaskContext $ctx, $startId, $endId){
 +  /**
 +   * 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();
 -    while ($dao->fetch()){
+     $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){
 +      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,
 -              CRM_Utils_System::url('civicrm/contact/imagefile', 'photo='.$photo, TRUE, NULL, TRUE, TRUE));
 -          }
 -          else{
 -            $failures[$dao->id] = $dao->image_url;
 -          }
 +        $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,
 +            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;
          }
        }
 +      else {
 +        $failures[$dao->id] = $dao->image_url;
 +      }
 +    }
      CRM_Core_Error::debug_var('imageUrlsNotUpgraded', $failures);
      return TRUE;
    }