From: kurund Date: Wed, 16 Jul 2014 07:38:50 +0000 (+0530) Subject: Merge remote-tracking branch 'upstream/4.4' into 4.4-master-2014-07-16-12-52-48 X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=f2a84e5c7c916f6c0d4c7fce69b844b019c17dd1;p=civicrm-core.git Merge remote-tracking branch 'upstream/4.4' into 4.4-master-2014-07-16-12-52-48 Conflicts: CRM/Contact/Form/Contact.php CRM/Profile/Form.php CRM/Upgrade/Incremental/php/FourFour.php CRM/Utils/String.php --- f2a84e5c7c916f6c0d4c7fce69b844b019c17dd1 diff --cc CRM/Contact/Form/Contact.php index 40abe4743c,204ea6fe0a..2ca53a7896 --- a/CRM/Contact/Form/Contact.php +++ b/CRM/Contact/Form/Contact.php @@@ -435,8 -442,8 +435,9 @@@ class CRM_Contact_Form_Contact extends //set address block defaults CRM_Contact_Form_Edit_Address::setDefaultValues( $defaults, $this ); - if (CRM_Utils_Array::value('image_URL', $defaults)) { ++ + if (!empty($defaults['image_URL'])) { - list($imageWidth, $imageHeight) = getimagesize($defaults['image_URL']); + list($imageWidth, $imageHeight) = getimagesize(CRM_Utils_String::unstupifyUrl($defaults['image_URL'])); list($imageThumbWidth, $imageThumbHeight) = CRM_Contact_BAO_Contact::getThumbSize($imageWidth, $imageHeight); $this->assign('imageWidth', $imageWidth); $this->assign('imageHeight', $imageHeight); diff --cc CRM/Profile/Form.php index 549024b350,33e46f5429..8f0aec6b6f --- a/CRM/Profile/Form.php +++ b/CRM/Profile/Form.php @@@ -557,8 -550,8 +557,8 @@@ class CRM_Profile_Form extends CRM_Core return; } - if (CRM_Utils_Array::value('image_URL', $this->_defaults)) { + if (!empty($this->_defaults['image_URL'])) { - list($imageWidth, $imageHeight) = getimagesize($this->_defaults['image_URL']); + list($imageWidth, $imageHeight) = getimagesize(CRM_Utils_String::unstupifyUrl($this->_defaults['image_URL'])); list($imageThumbWidth, $imageThumbHeight) = CRM_Contact_BAO_Contact::getThumbSize($imageWidth, $imageHeight); $this->assign("imageWidth", $imageWidth); $this->assign("imageHeight", $imageHeight); diff --cc CRM/Upgrade/Form.php index bd2413619d,7b93e115aa..b689907941 --- a/CRM/Upgrade/Form.php +++ b/CRM/Upgrade/Form.php @@@ -643,15 -521,12 +643,15 @@@ SET version = '$version /** * Perform an incremental version update * + * @param CRM_Queue_TaskContext $ctx * @param $rev string, the target (intermediate) revision e.g '3.2.alpha1' - * @param $currentVer string, the original revision + * @param $originalVer string, the original revision * @param $latestVer string, the target (final) revision * @param $postUpgradeMessageFile string, path of a modifiable file which lists the post-upgrade messages + * + * @return bool */ - static function doIncrementalUpgradeStep(CRM_Queue_TaskContext$ctx, $rev, $currentVer, $latestVer, $postUpgradeMessageFile) { + static function doIncrementalUpgradeStep(CRM_Queue_TaskContext$ctx, $rev, $originalVer, $latestVer, $postUpgradeMessageFile) { $upgrade = new CRM_Upgrade_Form(); $phpFunctionName = 'upgrade_' . str_replace('.', '_', $rev); diff --cc CRM/Upgrade/Incremental/php/FourFour.php index bcad6fcf03,7dcf3eba4f..af2a61d3a0 --- a/CRM/Upgrade/Incremental/php/FourFour.php +++ b/CRM/Upgrade/Incremental/php/FourFour.php @@@ -352,26 -325,24 +352,31 @@@ ALTER TABLE civicrm_dashboar } } + /** + * @param CRM_Queue_TaskContext $ctx + * @param $startId + * @param $endId + * + * @return bool + */ + 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 + $exBackendUrl = CRM_Utils_System::url('civicrm/contact/imagefile', 'photo=XXX', TRUE); // URL formula from 4.4.6 upgrade + $exFrontendUrl = CRM_Utils_System::url('civicrm/contact/imagefile', 'photo=XXX', TRUE, NULL, TRUE, TRUE); + if ($originalVer == '4.4.6' && $exBackendUrl != $exFrontendUrl) { + $minId = CRM_Core_DAO::singleValueQuery('SELECT coalesce(min(id),0) FROM civicrm_contact WHERE image_URL IS NOT NULL'); + $maxId = CRM_Core_DAO::singleValueQuery('SELECT coalesce(max(id),0) FROM civicrm_contact WHERE image_URL IS NOT NULL'); + for ($startId = $minId; $startId <= $maxId; $startId += self::BATCH_SIZE) { + $endId = $startId + self::BATCH_SIZE - 1; + $title = ts('Upgrade image_urls (%1 => %2)', array(1 => $startId, 2 => $endId)); + $this->addTask($title, 'cleanupBackendImageUrls', $startId, $endId); + } + } + $this->addTask(ts('Update saved search information'), 'changeSavedSearch'); + } + static function upgradeImageUrls(CRM_Queue_TaskContext $ctx, $startId, $endId){ - $sql = " - SELECT id, image_url - FROM civicrm_contact - WHERE 1 - AND id BETWEEN %1 AND %2 - AND image_URL IS NOT NULL - "; - $params = array( - 1 => array($startId, 'Integer'), - 2 => array($endId, 'Integer'), - ); - $dao = CRM_Core_DAO::executeQuery($sql, $params, TRUE, NULL, FALSE, FALSE); + $dao = self::findContactImageUrls($startId, $endId); $failures = array(); while ($dao->fetch()){ $imageURL = $dao->image_url; diff --cc CRM/Utils/String.php index 7e3b8f0d49,4ba11f1942..1643491496 --- a/CRM/Utils/String.php +++ b/CRM/Utils/String.php @@@ -661,61 -652,17 +661,73 @@@ class CRM_Utils_String } } + /** + * this function will mask part of the the user portion of an Email address (everything before the @) + * + * @param string $email the email address to be masked + * @param string $maskChar the character used for masking + * @param integer $percent the percentage of the user portion to be masked + * + * @return string returns the masked Email address + */ + public static function maskEmail($email, $maskChar= '*', $percent=50) { + list($user, $domain) = preg_split("/@/", $email); + $len = strlen($user); + $maskCount = floor($len * $percent /100); + $offset = floor(($len - $maskCount) / 2); + + $masked = substr($user, 0, $offset) + .str_repeat($maskChar, $maskCount) + .substr($user, $maskCount + $offset); + + return($masked.'@'.$domain); + } + + /** + * this function compares two strings + * + * @param string $strOne string one + * @param string $strTwo string two + * @param boolean $case boolean indicating whether you want the comparison to be case sensitive or not + * + * @return boolean TRUE (string are identical); FALSE (strings are not identical) + */ + public static function compareStr($strOne, $strTwo, $case) { + if ($case == TRUE) { + // Convert to lowercase and trim white spaces + if (strtolower(trim($strOne)) == strtolower(trim($strTwo))) { + // yes - they are identical + return TRUE; + } + else { + // not identical + return FALSE; + } + } + if ($case == FALSE) { + // Trim white spaces + if (trim($strOne) == trim($strTwo)) { + // yes - they are identical + return TRUE; + } + else { + // not identical + return FALSE; + } + } + } + + /** + * Many parts of the codebase have a convention of internally passing around + * HTML-encoded URLs. This effectively means that "&" is replaced by "&" + * (because most other odd characters are %-escaped in URLs; and %-escaped + * strings don't need any extra escaping in HTML). + * + * @param string $url URL with HTML entities + * @return string URL without HTML entities + */ + public static function unstupifyUrl($htmlUrl) { + return str_replace('&', '&', $htmlUrl); + } }