From: Tim Otten Date: Tue, 6 Jan 2015 21:21:24 +0000 (-0800) Subject: INFRA-132 - CRM/Utils - phpcbf X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=e72924229165e83a3c39896c2e3d22ca1dbd7300;p=civicrm-core.git INFRA-132 - CRM/Utils - phpcbf --- diff --git a/CRM/Utils/API/HTMLInputCoder.php b/CRM/Utils/API/HTMLInputCoder.php index 744f231150..7cdc82031f 100644 --- a/CRM/Utils/API/HTMLInputCoder.php +++ b/CRM/Utils/API/HTMLInputCoder.php @@ -98,7 +98,7 @@ class CRM_Utils_API_HTMLInputCoder extends CRM_Utils_API_AbstractFieldCoder { 'pay_later_text', 'pay_later_receipt', 'label', // This is needed for FROM Email Address configuration. dgg - 'url', // This is needed for navigation items urls + 'url', // This is needed for navigation items urls 'details', 'msg_text', // message templates’ text versions 'text_message', // (send an) email to contact’s and CiviMail’s text version diff --git a/CRM/Utils/API/MatchOption.php b/CRM/Utils/API/MatchOption.php index 2f48bd8ff4..faf4152a45 100644 --- a/CRM/Utils/API/MatchOption.php +++ b/CRM/Utils/API/MatchOption.php @@ -104,6 +104,7 @@ class CRM_Utils_API_MatchOption implements API_Wrapper { $apiRequest['params'] = $this->match($apiRequest['entity'], $apiRequest['params'], $keys, $isMandatory); } break; + case 'replace': // In addition to matching on the listed keys, also match on the set-definition keys. // For example, if the $apiRequest is to "replace the set of civicrm_emails for contact_id=123 while @@ -122,6 +123,7 @@ class CRM_Utils_API_MatchOption implements API_Wrapper { $apiRequest['params']['values'][$offset] = $createParams; } break; + default: // be forgiveful of sloppily api calls } diff --git a/CRM/Utils/Address.php b/CRM/Utils/Address.php index af5e691cbb..e9e954817e 100644 --- a/CRM/Utils/Address.php +++ b/CRM/Utils/Address.php @@ -57,11 +57,11 @@ class CRM_Utils_Address { */ static function format( $fields, - $format = NULL, - $microformat = FALSE, - $mailing = FALSE, + $format = NULL, + $microformat = FALSE, + $mailing = FALSE, $individualFormat = FALSE, - $tokenFields = NULL + $tokenFields = NULL ) { static $config = NULL; @@ -110,7 +110,7 @@ class CRM_Utils_Address { } if (!$microformat) { - // replacements in case of Individual Name Format + // replacements in case of Individual Name Format $replacements = array( 'contact.display_name' => CRM_Utils_Array::value('display_name', $fields), 'contact.individual_prefix' => CRM_Utils_Array::value('individual_prefix', $fields), diff --git a/CRM/Utils/Address/BatchUpdate.php b/CRM/Utils/Address/BatchUpdate.php index e05552b101..fa36f8a666 100644 --- a/CRM/Utils/Address/BatchUpdate.php +++ b/CRM/Utils/Address/BatchUpdate.php @@ -164,10 +164,9 @@ class CRM_Utils_Address_BatchUpdate { $dao = CRM_Core_DAO::executeQuery($query, $params); if ($processGeocode) { - require_once (str_replace('_', DIRECTORY_SEPARATOR, $config->geocodeMethod) . '.php'); + require_once str_replace('_', DIRECTORY_SEPARATOR, $config->geocodeMethod) . '.php'; } - $unparseableContactAddress = array(); while ($dao->fetch()) { $totalAddresses++; @@ -194,7 +193,7 @@ class CRM_Utils_Address_BatchUpdate { } $className = $config->geocodeMethod; - $className::format( $params, true ); + $className::format( $params, TRUE ); // see if we got a geocode error, in this case we'll trigger a fatal // CRM-13760 diff --git a/CRM/Utils/Address/USPS.php b/CRM/Utils/Address/USPS.php index cb6ab9d17d..3e13d2ede6 100644 --- a/CRM/Utils/Address/USPS.php +++ b/CRM/Utils/Address/USPS.php @@ -53,7 +53,6 @@ class CRM_Utils_Address_USPS { return FALSE; } - $userID = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::ADDRESS_STANDARDIZATION_PREFERENCES_NAME, 'address_standardization_userid' ); @@ -110,14 +109,14 @@ class CRM_Utils_Address_USPS { return FALSE; } - $values['street_address'] = (string)$xml->Address->Address2; - $values['city'] = (string)$xml->Address->City; - $values['state_province'] = (string)$xml->Address->State; - $values['postal_code'] = (string)$xml->Address->Zip5; - $values['postal_code_suffix'] = (string)$xml->Address->Zip4; + $values['street_address'] = (string) $xml->Address->Address2; + $values['city'] = (string) $xml->Address->City; + $values['state_province'] = (string) $xml->Address->State; + $values['postal_code'] = (string) $xml->Address->Zip5; + $values['postal_code_suffix'] = (string) $xml->Address->Zip4; if (array_key_exists('Address1', $xml->Address)) { - $values['supplemental_address_1'] = (string)$xml->Address->Address1; + $values['supplemental_address_1'] = (string) $xml->Address->Address1; } return TRUE; diff --git a/CRM/Utils/Array.php b/CRM/Utils/Array.php index ccd61ba889..1213096080 100644 --- a/CRM/Utils/Array.php +++ b/CRM/Utils/Array.php @@ -537,19 +537,19 @@ class CRM_Utils_Array { * When passed an array of strings, unsets $items[$k] for each string $k * in the array. */ - public static function remove(&$items) { - foreach (func_get_args() as $n => $key) { - // Skip argument 0 ($items) by testing $n for truth. - if ($n && is_array($key)) { - foreach($key as $k) { - unset($items[$k]); - } - } - elseif ($n) { - unset($items[$key]); - } - } - } + public static function remove(&$items) { + foreach (func_get_args() as $n => $key) { + // Skip argument 0 ($items) by testing $n for truth. + if ($n && is_array($key)) { + foreach($key as $k) { + unset($items[$k]); + } + } + elseif ($n) { + unset($items[$key]); + } + } + } /** * Builds an array-tree which indexes the records in an array. @@ -579,9 +579,9 @@ class CRM_Utils_Array { $node = &$node[$keyvalue]; } if (is_array($record)) { - $node[ $record[$final_key] ] = $record; + $node[$record[$final_key]] = $record; } else { - $node[ $record->{$final_key} ] = $record; + $node[$record->{$final_key}] = $record; } } return $result; diff --git a/CRM/Utils/Cache.php b/CRM/Utils/Cache.php index 5c909e56b2..72def00daa 100644 --- a/CRM/Utils/Cache.php +++ b/CRM/Utils/Cache.php @@ -86,7 +86,7 @@ class CRM_Utils_Cache { // a generic method for utilizing any of the available db caches. $dbCacheClass = 'CRM_Utils_Cache_' . $className; - require_once(str_replace('_', DIRECTORY_SEPARATOR, $dbCacheClass) . '.php'); + require_once str_replace('_', DIRECTORY_SEPARATOR, $dbCacheClass) . '.php'; $settings = self::getCacheSettings($className); self::$_singleton = new $dbCacheClass($settings); } diff --git a/CRM/Utils/Cache/APCcache.php b/CRM/Utils/Cache/APCcache.php index 28b4e28445..16e6b34139 100644 --- a/CRM/Utils/Cache/APCcache.php +++ b/CRM/Utils/Cache/APCcache.php @@ -110,7 +110,7 @@ class CRM_Utils_Cache_APCcache { foreach ($keys as $key) { $name = $key['info']; - if ($prefix == substr($name,0,$lp)) { // Ours? + if ($prefix == substr($name, 0, $lp)) { // Ours? apc_delete($this->_prefix . $name); } } diff --git a/CRM/Utils/Cache/SerializeCache.php b/CRM/Utils/Cache/SerializeCache.php index b60738297f..086c9e7f02 100644 --- a/CRM/Utils/Cache/SerializeCache.php +++ b/CRM/Utils/Cache/SerializeCache.php @@ -53,8 +53,9 @@ class CRM_Utils_Cache_SerializeCache implements CRM_Utils_Cache_Interface { * @return string */ public function fileName ($key) { - if (strlen($key) > 50) + if (strlen($key) > 50) { return CIVICRM_TEMPLATE_COMPILEDIR ."CRM_".md5($key).".php"; + } return CIVICRM_TEMPLATE_COMPILEDIR .$key.".php"; } @@ -64,13 +65,14 @@ class CRM_Utils_Cache_SerializeCache implements CRM_Utils_Cache_Interface { * @return mixed */ public function get ($key) { - if (array_key_exists($key,$this->_cache)) + if (array_key_exists($key, $this->_cache)) { return $this->_cache[$key]; + } - if (!file_exists($this->fileName ($key))) { + if (!file_exists($this->fileName($key))) { return; } - $this->_cache[$key] = unserialize (substr (file_get_contents ($this->fileName ($key)),8)); + $this->_cache[$key] = unserialize(substr(file_get_contents($this->fileName($key)), 8)); return $this->_cache[$key]; } @@ -79,19 +81,19 @@ class CRM_Utils_Cache_SerializeCache implements CRM_Utils_Cache_Interface { * @param mixed $value */ public function set($key, &$value) { - if (file_exists($this->fileName ($key))) { + if (file_exists($this->fileName($key))) { return; } $this->_cache[$key] = $value; - file_put_contents ($this->fileName ($key),"fileName($key), "fileName ($key))) { - unlink ($this->fileName ($key)); + if (file_exists($this->fileName($key))) { + unlink($this->fileName($key)); } unset($this->_cache[$key]); } @@ -99,14 +101,14 @@ class CRM_Utils_Cache_SerializeCache implements CRM_Utils_Cache_Interface { /** * @param null $key */ - public function flush($key =null) { + public function flush($key = NULL) { $prefix = "CRM_"; if (!$handle = opendir(CIVICRM_TEMPLATE_COMPILEDIR)) { return; // die? Error? } - while (false !== ($entry = readdir($handle))) { - if (substr ($entry,0,4) == $prefix) { - unlink (CIVICRM_TEMPLATE_COMPILEDIR.$entry); + while (FALSE !== ($entry = readdir($handle))) { + if (substr($entry, 0, 4) == $prefix) { + unlink(CIVICRM_TEMPLATE_COMPILEDIR.$entry); } } closedir($handle); diff --git a/CRM/Utils/Check.php b/CRM/Utils/Check.php index f559360c52..84030a707a 100644 --- a/CRM/Utils/Check.php +++ b/CRM/Utils/Check.php @@ -129,6 +129,7 @@ class CRM_Utils_Check { case 'CiviCase': $checks[] = new CRM_Utils_Check_Case(CRM_Case_XMLRepository::singleton(), CRM_Case_PseudoConstant::caseType('name')); break; + default: } } diff --git a/CRM/Utils/Check/Env.php b/CRM/Utils/Check/Env.php index 9def24f2b5..c12ca3e41d 100644 --- a/CRM/Utils/Check/Env.php +++ b/CRM/Utils/Check/Env.php @@ -108,7 +108,6 @@ class CRM_Utils_Check_Env { 'checkOutboundMail', ts('Warning: Outbound email is disabled in system settings. Proper settings should be enabled on production servers.', array(1 => CRM_Utils_System::url('civicrm/admin/setting/smtp', 'reset=1'))), - ts('Outbound Email Settings') ); } diff --git a/CRM/Utils/Check/Security.php b/CRM/Utils/Check/Security.php index a2ef3d8baf..14015d53f3 100644 --- a/CRM/Utils/Check/Security.php +++ b/CRM/Utils/Check/Security.php @@ -45,6 +45,7 @@ class CRM_Utils_Check_Security { switch ($config->userFramework) { case 'Joomla': return '/media/'; + default: return '/files/'; } diff --git a/CRM/Utils/Date.php b/CRM/Utils/Date.php index 6352552c93..7cbc0beefc 100644 --- a/CRM/Utils/Date.php +++ b/CRM/Utils/Date.php @@ -496,7 +496,7 @@ class CRM_Utils_Date { * @static */ public static function convertToDefaultDate(&$params, $dateType, $dateParam) { - $now = getDate(); + $now = getdate(); $cen = substr($now['year'], 0, 2); $prevCen = $cen - 1; @@ -559,7 +559,6 @@ class CRM_Utils_Date { } } - if ($dateType == 2 || $dateType == 4) { $formattedDate = explode("/", $value); if (count($formattedDate) != 3) { @@ -718,10 +717,10 @@ class CRM_Utils_Date { * actuall today pass 'dayParams' as null. or else pass the day, * month, year values as array values * Example: $dayParams = array( - 'day' => '25', 'month' => '10', + 'day' => '25', 'month' => '10', * 'year' => '2007' ); * - * @param Array $dayParams + * @param array $dayParamsArray of the day, month, year. * Array of the day, month, year. * values. * @param string $format @@ -970,7 +969,7 @@ class CRM_Utils_Date { * @static */ public static function relativeToAbsolute($relativeTerm, $unit) { - $now = getDate(); + $now = getdate(); $from = $to = $dateRange = array(); $from['H'] = $from['i'] = $from['s'] = 0; @@ -1438,8 +1437,8 @@ class CRM_Utils_Date { $from['Y'] = $now['year']; $from['H'] = 00; $from['i'] = $to['s'] = 00; - $to = self::intervalAdd('month', +1, $from); - $to = self::intervalAdd('second',-1, $to); + $to = self::intervalAdd('month', + 1, $from); + $to = self::intervalAdd('second', -1, $to); break; } break; @@ -1538,7 +1537,7 @@ class CRM_Utils_Date { $from['M'] = $now['mon']; $from['Y'] = $now['year']; $from = self::intervalAdd('day', -1 * ($now['wday']) + 7, $from); - $to = self::intervalAdd('day', +6, $from); + $to = self::intervalAdd('day', + 6, $from); break; case 'starting': @@ -1547,7 +1546,7 @@ class CRM_Utils_Date { $from['Y'] = $now['year']; $from['H'] = 00; $from['i'] = $to['s'] = 00; - $to = self::intervalAdd('day', +7, $from); + $to = self::intervalAdd('day', + 7, $from); $to = self::intervalAdd('second', -1, $to); break; } @@ -1607,7 +1606,7 @@ class CRM_Utils_Date { $to['d'] = $now['mday']; $to['M'] = $now['mon']; $to['Y'] = $now['year']; - $to = self::intervalAdd('day', +1, $to); + $to = self::intervalAdd('day', + 1, $to); $from['d'] = $to['d']; $from['M'] = $to['M']; $from['Y'] = $to['Y']; @@ -1735,7 +1734,6 @@ class CRM_Utils_Date { $dateFormat = CRM_Utils_Array::value( $format, $actualPHPFormats ); */ - $dateFormat = 'm/d/Y'; $date = date($dateFormat, strtotime($mysqlDate)); diff --git a/CRM/Utils/DeprecatedUtils.php b/CRM/Utils/DeprecatedUtils.php index bf6255ac2c..1041f29715 100644 --- a/CRM/Utils/DeprecatedUtils.php +++ b/CRM/Utils/DeprecatedUtils.php @@ -222,7 +222,7 @@ function _civicrm_api3_deprecated_participant_formatted_param($params, &$values, * * @return array|CRM_Error */ -function _civicrm_api3_deprecated_formatted_param($params, &$values, $create = FALSE, $onDuplicate = Null) { +function _civicrm_api3_deprecated_formatted_param($params, &$values, $create = FALSE, $onDuplicate = NULL) { // copy all the contribution fields as is $fields = CRM_Contribute_DAO_Contribution::fields(); @@ -450,15 +450,15 @@ function _civicrm_api3_deprecated_formatted_param($params, &$values, $create = F return civicrm_api3_create_error("Invalid email address(duplicate) $email for Soft Credit. Row was skipped"); } elseif (count($matchingContactIds) == 1) { - $contactId = $matchingContactIds[0]; + $contactId = $matchingContactIds[0]; unset($softParam['email']); $values[$key][$softKey] = $softParam + array('contact_id' => $contactId); } } } } - } - break; + } + break; case 'pledge_payment': case 'pledge_id': @@ -614,7 +614,7 @@ function _civicrm_api3_deprecated_check_contact_dedupe($params) { $defaultLocation = CRM_Core_BAO_LocationType::getDefault(); //set the value to default location id else set to 1 - if (!$defaultLocationId = (int)$defaultLocation->id) { + if (!$defaultLocationId = (int) $defaultLocation->id) { $defaultLocationId = 1; } } @@ -984,7 +984,7 @@ function _civicrm_api3_deprecated_add_formatted_location_blocks(&$values, &$para } foreach (array( - 'Phone', 'Email', 'IM', 'OpenID','Phone_Ext') as $block) { + 'Phone', 'Email', 'IM', 'OpenID', 'Phone_Ext') as $block) { $name = strtolower($block); if (!array_key_exists($name, $values)) { continue; @@ -1058,31 +1058,31 @@ function _civicrm_api3_deprecated_add_formatted_location_blocks(&$values, &$para $customFieldID = CRM_Core_BAO_CustomField::getKeyID($key); if ($customFieldID && array_key_exists($customFieldID, $customFields)) { // mark an entry in fields array since we want the value of custom field to be copied - $fields['Address'][$key] = null; + $fields['Address'][$key] = NULL; $htmlType = CRM_Utils_Array::value( 'html_type', $customFields[$customFieldID] ); switch ( $htmlType ) { - case 'CheckBox': - case 'AdvMulti-Select': - case 'Multi-Select': - if ( $val ) { - $mulValues = explode( ',', $val ); - $customOption = CRM_Core_BAO_CustomOption::getCustomOption( $customFieldID, true ); - $newValues[$key] = array( ); - foreach ( $mulValues as $v1 ) { - foreach ( $customOption as $v2 ) { - if ( ( strtolower( $v2['label'] ) == strtolower( trim( $v1 ) ) ) || + case 'CheckBox': + case 'AdvMulti-Select': + case 'Multi-Select': + if ( $val ) { + $mulValues = explode( ',', $val ); + $customOption = CRM_Core_BAO_CustomOption::getCustomOption( $customFieldID, TRUE ); + $newValues[$key] = array(); + foreach ( $mulValues as $v1 ) { + foreach ( $customOption as $v2 ) { + if ( ( strtolower( $v2['label'] ) == strtolower( trim( $v1 ) ) ) || ( strtolower( $v2['value'] ) == strtolower( trim( $v1 ) ) ) ) { - if ( $htmlType == 'CheckBox' ) { - $newValues[$key][$v2['value']] = 1; - } else { - $newValues[$key][] = $v2['value']; + if ( $htmlType == 'CheckBox' ) { + $newValues[$key][$v2['value']] = 1; + } else { + $newValues[$key][] = $v2['value']; + } } } } } - } - break; + break; } } } @@ -1324,7 +1324,7 @@ function _civicrm_api3_deprecated_contact_check_custom_params($params, $csType = $errorMsg = "Invalid Custom Field Contact Type: {$params['contact_type']}"; if (!empty($csType)) { - $errorMsg .= " or Mismatched SubType: " . implode(', ', (array)$csType); + $errorMsg .= " or Mismatched SubType: " . implode(', ', (array) $csType); } return civicrm_api3_create_error($errorMsg); } @@ -1367,7 +1367,6 @@ function _civicrm_api3_deprecated_contact_check_params( ), ); - // contact_type has a limited number of valid values if(empty($params['contact_type'])) { return civicrm_api3_create_error("No Contact Type"); @@ -1379,7 +1378,7 @@ function _civicrm_api3_deprecated_contact_check_params( if ($csType = CRM_Utils_Array::value('contact_sub_type', $params)) { if (!(CRM_Contact_BAO_ContactType::isExtendsContactType($csType, $params['contact_type']))) { - return civicrm_api3_create_error("Invalid or Mismatched Contact Subtype: " . implode(', ', (array)$csType)); + return civicrm_api3_create_error("Invalid or Mismatched Contact Subtype: " . implode(', ', (array) $csType)); } } diff --git a/CRM/Utils/File.php b/CRM/Utils/File.php index f74afbe09a..c9bed292ae 100644 --- a/CRM/Utils/File.php +++ b/CRM/Utils/File.php @@ -156,10 +156,10 @@ class CRM_Utils_File { elseif (is_file($object)) { if (!unlink($object)) { CRM_Core_Session::setStatus(ts('Unable to remove file %1', array(1 => $object)), ts('Warning'), 'error'); + } } } } - } closedir($sourcedir); if ($rmdir) { @@ -168,11 +168,11 @@ class CRM_Utils_File { CRM_Core_Session::setStatus(ts('Removed directory %1', array(1 => $target)), '', 'success'); } return TRUE; - } + } else { CRM_Core_Session::setStatus(ts('Unable to remove directory %1', array(1 => $target)), ts('Warning'), 'error'); - } - } + } + } } } @@ -691,7 +691,7 @@ HTACCESS; CRM_Utils_File::copyDir($fromDir, $toDir); if (!CRM_Utils_File::cleanDir($fromDir, TRUE, FALSE)) { - CRM_Core_Session::setStatus(ts('Failed to clean temp dir: %1', array(1 => $fromDir)), '', 'alert'); + CRM_Core_Session::setStatus(ts('Failed to clean temp dir: %1', array(1 => $fromDir)), '', 'alert'); return FALSE; } return TRUE; diff --git a/CRM/Utils/Geocode/Google.php b/CRM/Utils/Geocode/Google.php index 5a20a9f16c..066905dc1f 100644 --- a/CRM/Utils/Geocode/Google.php +++ b/CRM/Utils/Geocode/Google.php @@ -142,8 +142,8 @@ class CRM_Utils_Geocode_Google { ) { $ret = $xml->result->geometry->location->children(); if ($ret->lat && $ret->lng) { - $values['geo_code_1'] = (float)$ret->lat; - $values['geo_code_2'] = (float)$ret->lng; + $values['geo_code_1'] = (float) $ret->lat; + $values['geo_code_2'] = (float) $ret->lng; return TRUE; } } diff --git a/CRM/Utils/Hook.php b/CRM/Utils/Hook.php index edb706fa8d..a8cf536cda 100644 --- a/CRM/Utils/Hook.php +++ b/CRM/Utils/Hook.php @@ -83,14 +83,14 @@ abstract class CRM_Utils_Hook { if (self::$_singleton == NULL || $fresh) { $config = CRM_Core_Config::singleton(); $class = $config->userHookClass; - require_once (str_replace('_', DIRECTORY_SEPARATOR, $config->userHookClass) . '.php'); + require_once str_replace('_', DIRECTORY_SEPARATOR, $config->userHookClass) . '.php'; self::$_singleton = new $class(); } return self::$_singleton; } /** - *Invoke hooks + * Invoke hooks * * @param int $numParams * Number of parameters to pass to the hook. @@ -155,7 +155,7 @@ abstract class CRM_Utils_Hook { if (!empty($config->customPHPPathDir) && file_exists("{$config->customPHPPathDir}/civicrmHooks.php") ) { - @include_once ("civicrmHooks.php"); + @include_once "civicrmHooks.php"; } if (!empty($fnPrefix)) { @@ -253,8 +253,8 @@ abstract class CRM_Utils_Hook { } include_once $civiModule['filePath']; $moduleList[$civiModule['prefix']] = $civiModule['prefix']; - } } + } /** * This hook is called before a db write on some core objects. @@ -656,8 +656,8 @@ abstract class CRM_Utils_Hook { */ static function tokenValues(&$details, $contactIDs, - $jobID = NULL, - $tokens = array(), + $jobID = NULL, + $tokens = array(), $className = NULL ) { return self::singleton()->invoke(5, $details, $contactIDs, $jobID, $tokens, $className, self::$_nullObject, 'civicrm_tokenValues'); @@ -1583,7 +1583,7 @@ abstract class CRM_Utils_Hook { * Reserved for future use. */ static function unhandledException($exception, $request = NULL) { - self::singleton()->invoke(2, $exception, $request, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,'civicrm_unhandled_exception'); + self::singleton()->invoke(2, $exception, $request, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_unhandled_exception'); // == 4.4 == //$event = new stdClass(); //$event->exception = $exception; @@ -1698,7 +1698,7 @@ abstract class CRM_Utils_Hook { * * @return mixed */ - public static function alterBarcode( &$data, $type = 'barcode', $context = 'name_badge' ) { + public static function alterBarcode(&$data, $type = 'barcode', $context = 'name_badge') { return self::singleton()->invoke(3, $data, $type, $context, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_alterBarcode'); } diff --git a/CRM/Utils/Hook/Joomla.php b/CRM/Utils/Hook/Joomla.php index 68ba2936d0..976ab038c8 100644 --- a/CRM/Utils/Hook/Joomla.php +++ b/CRM/Utils/Hook/Joomla.php @@ -35,7 +35,7 @@ */ class CRM_Utils_Hook_Joomla extends CRM_Utils_Hook { /** - *Invoke hooks + * Invoke hooks * * @param int $numParams * Number of parameters to pass to the hook. diff --git a/CRM/Utils/Hook/Soap.php b/CRM/Utils/Hook/Soap.php index eae8e5e0e7..fc33752894 100644 --- a/CRM/Utils/Hook/Soap.php +++ b/CRM/Utils/Hook/Soap.php @@ -35,7 +35,7 @@ */ class CRM_Utils_Hook_Soap extends CRM_Utils_Hook { /** - *Invoke hooks + * Invoke hooks * * @param int $numParams * Number of parameters to pass to the hook. diff --git a/CRM/Utils/Hook/UnitTests.php b/CRM/Utils/Hook/UnitTests.php index a4cf2f61fb..cb26c88097 100644 --- a/CRM/Utils/Hook/UnitTests.php +++ b/CRM/Utils/Hook/UnitTests.php @@ -73,7 +73,7 @@ class CRM_Utils_Hook_UnitTests extends CRM_Utils_Hook { } /** - *Invoke hooks + * Invoke hooks * * @param int $numParams * Number of parameters to pass to the hook. diff --git a/CRM/Utils/Hook/WordPress.php b/CRM/Utils/Hook/WordPress.php index 34dca47e55..e63d817a95 100644 --- a/CRM/Utils/Hook/WordPress.php +++ b/CRM/Utils/Hook/WordPress.php @@ -64,7 +64,7 @@ class CRM_Utils_Hook_WordPress extends CRM_Utils_Hook { ); /** - *Invoke hooks + * Invoke hooks * * @param int $numParams * Number of parameters to pass to the hook. @@ -90,122 +90,120 @@ class CRM_Utils_Hook_WordPress extends CRM_Utils_Hook { &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6, $fnSuffix ) { - + /** - * do_action_ref_array is the default way of calling WordPress hooks - * because for the most part no return value is wanted. However, this is - * only generally true, so using do_action_ref_array() is only called for those + * do_action_ref_array is the default way of calling WordPress hooks + * because for the most part no return value is wanted. However, this is + * only generally true, so using do_action_ref_array() is only called for those * hooks which do not require a return value. We exclude the following, which * are incompatible with the WordPress Plugin API: - * + * * civicrm_upgrade * http://wiki.civicrm.org/confluence/display/CRMDOC43/hook_civicrm_upgrade - * + * * civicrm_caseSummary * http://wiki.civicrm.org/confluence/display/CRMDOC43/hook_civicrm_caseSummary - * + * * civicrm_dashboard * http://wiki.civicrm.org/confluence/display/CRMDOC43/hook_civicrm_dashboard */ - + // distinguish between types of hook if ( ! in_array( $fnSuffix, $this->hooksThatReturn ) ) { - + // only pass the arguments that have values - $args = array_slice( - array( &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6 ), - 0, + $args = array_slice( + array( &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6 ), + 0, $numParams ); - + /** * Use WordPress Plugins API to modify $args * - * Because $args are passed as references to the WordPress callbacks, + * Because $args are passed as references to the WordPress callbacks, * runHooks subsequently receives appropriately modified parameters. */ - + // protect from REST calls if (function_exists('do_action_ref_array')) { do_action_ref_array( $fnSuffix, $args ); } - + } - - - + /** - * The following is based on the logic of the Joomla hook file by allowing + * The following is based on the logic of the Joomla hook file by allowing * WordPress callbacks to do their stuff before runHooks gets called. - * - * It also follows the logic of the Drupal hook file by building the "module" + * + * It also follows the logic of the Drupal hook file by building the "module" * (read "plugin") list and then calling runHooks directly. This should avoid * the need for the post-processing that the Joomla hook file does. - * - * Note that hooks which require a return value are incompatible with the - * signature of apply_filters_ref_array and must therefore be called in - * global scope, like in Drupal. It's not ideal, but plugins can always route + * + * Note that hooks which require a return value are incompatible with the + * signature of apply_filters_ref_array and must therefore be called in + * global scope, like in Drupal. It's not ideal, but plugins can always route * these calls to methods in their classes. - * + * * At some point, those hooks could be pre-processed and called via the WordPress * Plugin API, but it would change their signature and require the CiviCRM docs * to be rewritten for those calls in WordPress. So it's been done this way for - * now. Ideally these hooks will be deprecated in favour of hooks that do not + * now. Ideally these hooks will be deprecated in favour of hooks that do not * require return values. */ - + // build list of registered plugin codes $this->buildModuleList(); - + // Call runHooks the same way Drupal does $moduleResult = $this->runHooks( - $this->allModules, + $this->allModules, $fnSuffix, - $numParams, + $numParams, $arg1, $arg2, $arg3, $arg4, $arg5, $arg6 ); - + // finally, return return empty($moduleResult) ? TRUE : $moduleResult; - + } - + /** * Build the list of plugins ("modules" in CiviCRM terminology) to be processed for hooks. * We need to do this to preserve the CiviCRM hook signatures for hooks that require * a return value, since the WordPress Plugin API seems to be incompatible with them. - * + * * Copied and adapted from: CRM/Utils/Hook/Drupal6.php */ public function buildModuleList() { if ($this->isBuilt === FALSE) { - + if ($this->wordpressModules === NULL) { - + // include custom PHP file - copied from parent->commonBuildModuleList() $config = CRM_Core_Config::singleton(); if (!empty($config->customPHPPathDir) && file_exists("{$config->customPHPPathDir}/civicrmHooks.php") ) { - @include_once ('civicrmHooks.php'); + @include_once 'civicrmHooks.php'; } // initialise with the pre-existing 'wordpress' prefix $this->wordpressModules = array('wordpress'); - + /** * Use WordPress Plugin API to build list * a plugin simply needs to declare its "unique_plugin_code" thus: * add_filter('civicrm_wp_plugin_codes', 'function_that_returns_my_unique_plugin_code'); */ - + // protect from REST calls if (function_exists('apply_filters')) { $this->wordpressModules = apply_filters('civicrm_wp_plugin_codes', $this->wordpressModules); } - + } if ($this->civiModules === NULL) { @@ -213,12 +211,12 @@ class CRM_Utils_Hook_WordPress extends CRM_Utils_Hook { $this->requireCiviModules($this->civiModules); } - $this->allModules = array_merge((array)$this->wordpressModules, (array)$this->civiModules); + $this->allModules = array_merge((array) $this->wordpressModules, (array) $this->civiModules); if ($this->wordpressModules !== NULL && $this->civiModules !== NULL) { // both CRM and CMS have bootstrapped, so this is the final list $this->isBuilt = TRUE; } - + } } diff --git a/CRM/Utils/HttpClient.php b/CRM/Utils/HttpClient.php index 9d82079e3f..0e084fda3c 100644 --- a/CRM/Utils/HttpClient.php +++ b/CRM/Utils/HttpClient.php @@ -174,9 +174,9 @@ class CRM_Utils_HttpClient { } curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($ch, CURLOPT_POST, true); - curl_setopt($ch, CURLOPT_POST,count($params)); - curl_setopt($ch, CURLOPT_POSTFIELDS,$params); + curl_setopt($ch, CURLOPT_POST, TRUE); + curl_setopt($ch, CURLOPT_POST, count($params)); + curl_setopt($ch, CURLOPT_POSTFIELDS, $params); $data = curl_exec($ch); if (curl_errno($ch)) { return array(self::STATUS_DL_ERROR, $data); diff --git a/CRM/Utils/Mail.php b/CRM/Utils/Mail.php index da0e512a25..365e7dcd03 100644 --- a/CRM/Utils/Mail.php +++ b/CRM/Utils/Mail.php @@ -160,20 +160,20 @@ class CRM_Utils_Mail { $headers = &$msg->headers($headers); $to = array($params['toEmail']); - $result = null; + $result = NULL; $mailer =& CRM_Core_Config::getMailer( ); // Mail_smtp and Mail_sendmail mailers require Bcc anc Cc emails // be included in both $to and $headers['Cc', 'Bcc'] if (get_class($mailer) != "Mail_mail") { - //get emails from headers, since these are - //combination of name and email addresses. - if (!empty($headers['Cc'])) { - $to[] = CRM_Utils_Array::value( 'Cc', $headers ); - } - if (!empty($headers['Bcc'])) { - $to[] = CRM_Utils_Array::value( 'Bcc', $headers ); - } + //get emails from headers, since these are + //combination of name and email addresses. + if (!empty($headers['Cc'])) { + $to[] = CRM_Utils_Array::value( 'Cc', $headers ); + } + if (!empty($headers['Bcc'])) { + $to[] = CRM_Utils_Array::value( 'Bcc', $headers ); + } } if (is_object($mailer)) { $errorScope = CRM_Core_TemporaryErrorScope::ignoreException(); diff --git a/CRM/Utils/Mail/EmailProcessor.php b/CRM/Utils/Mail/EmailProcessor.php index 47be237421..3b324dcf63 100644 --- a/CRM/Utils/Mail/EmailProcessor.php +++ b/CRM/Utils/Mail/EmailProcessor.php @@ -143,9 +143,7 @@ class CRM_Utils_Mail_EmailProcessor { $usedfor = $dao->is_default; $emailActivityTypeId = - (defined('EMAIL_ACTIVITY_TYPE_ID') && EMAIL_ACTIVITY_TYPE_ID) ? - EMAIL_ACTIVITY_TYPE_ID : - CRM_Core_OptionGroup::getValue( + (defined('EMAIL_ACTIVITY_TYPE_ID') && EMAIL_ACTIVITY_TYPE_ID) ? EMAIL_ACTIVITY_TYPE_ID : CRM_Core_OptionGroup::getValue( 'activity_type', 'Inbound Email', 'name' @@ -185,7 +183,6 @@ class CRM_Utils_Mail_EmailProcessor { CRM_Core_Error::fatal($message); } - // process fifty at a time, CRM-4002 while ($mails = $store->fetchNext(MAIL_BATCH_SIZE)) { foreach ($mails as $key => $mail) { diff --git a/CRM/Utils/Mail/Incoming.php b/CRM/Utils/Mail/Incoming.php index 8cfe6f90ef..ac8f7eeaad 100644 --- a/CRM/Utils/Mail/Incoming.php +++ b/CRM/Utils/Mail/Incoming.php @@ -383,7 +383,6 @@ class CRM_Utils_Mail_Incoming { $subParam['email'] = $address->email; $subParam['name'] = $address->name; - $contactID = self::getContactID($subParam['email'], $subParam['name'], TRUE, diff --git a/CRM/Utils/Migrate/Export.php b/CRM/Utils/Migrate/Export.php index 62a09696b5..a1886d3a5e 100644 --- a/CRM/Utils/Migrate/Export.php +++ b/CRM/Utils/Migrate/Export.php @@ -391,7 +391,7 @@ class CRM_Utils_Migrate_Export { $result = array(); foreach (array_keys($this->_xml) as $key) { if (!empty($this->_xml[$key]['data'])) { - $result[ $this->_xml[$key]['name'] ] = array_values($this->_xml[$key]['data']); + $result[$this->_xml[$key]['name']] = array_values($this->_xml[$key]['data']); } } return $result; diff --git a/CRM/Utils/Migrate/ExportJSON.php b/CRM/Utils/Migrate/ExportJSON.php index 539f8a311e..a481c7f31e 100644 --- a/CRM/Utils/Migrate/ExportJSON.php +++ b/CRM/Utils/Migrate/ExportJSON.php @@ -526,7 +526,7 @@ WHERE ac.contact_id IN ( $ids ) DIRECTORY_SEPARATOR, $daoName ) . '.php'; - include_once ($daoFile); + include_once $daoFile; $daoFields = & $daoName::fields(); @@ -615,7 +615,6 @@ WHERE date >= $lastExportTime "; } - $dao = & CRM_Core_DAO::executeQuery($sql); $contactIDs = array(); diff --git a/CRM/Utils/OpenFlashChart.php b/CRM/Utils/OpenFlashChart.php index b98f02a193..8f953fea4f 100644 --- a/CRM/Utils/OpenFlashChart.php +++ b/CRM/Utils/OpenFlashChart.php @@ -109,7 +109,7 @@ class CRM_Utils_OpenFlashChart { } if ($barKey = CRM_Utils_Array::value($barCount, CRM_Utils_Array::value('barKeys', $params))) { - $bars[$barCount]->key($barKey,12); + $bars[$barCount]->key($barKey, 12); } // call user define function to handle on click event. @@ -127,8 +127,8 @@ class CRM_Utils_OpenFlashChart { // set_labels function requires xValues array of string or x_axis_label // so type casting array values to string values array_walk($xValues, function(&$value, $index) { - $value = (string)$value; - }); + $value = (string) $value; + }); $xLabels->set_labels($xValues); // set angle for labels. @@ -203,7 +203,7 @@ class CRM_Utils_OpenFlashChart { // get the required data. $values = array(); foreach ($allValues as $label => $value) { - $values[] = new pie_value((double)$value, $label); + $values[] = new pie_value((double) $value, $label); } $graphTitle = !empty($params['legend']) ? $params['legend'] : ts('Pie Chart'); @@ -276,10 +276,10 @@ class CRM_Utils_OpenFlashChart { continue; } - $xValueLabels[] = (string)$xVal; + $xValueLabels[] = (string) $xVal; foreach ($criterias as $criteria) { - $xReferences[$criteria][$xVal] = (double)CRM_Utils_Array::value($criteria, $yVal, 0); - $yValues[] = (double)CRM_Utils_Array::value($criteria, $yVal, 0); + $xReferences[$criteria][$xVal] = (double) CRM_Utils_Array::value($criteria, $yVal, 0); + $yValues[] = (double) CRM_Utils_Array::value($criteria, $yVal, 0); } } @@ -309,7 +309,7 @@ class CRM_Utils_OpenFlashChart { // set colour pattel $xValues[$count]->set_colour(self::$_colours[$count]); // define colur pattel with bar criterias - $xValues[$count]->key((string)$criteria, 12); + $xValues[$count]->key((string) $criteria, 12); // define bar chart values $xValues[$count]->set_values(array_values($values)); diff --git a/CRM/Utils/PDF/Label.php b/CRM/Utils/PDF/Label.php index 9deee255d6..8893b2a29d 100644 --- a/CRM/Utils/PDF/Label.php +++ b/CRM/Utils/PDF/Label.php @@ -271,7 +271,6 @@ class CRM_Utils_PDF_Label extends TCPDF { 'dejavusans' => ts('Deja Vu Sans (UTF-8)'), ); - // Check to see if we have any additional fonts to add. You can specify more fonts in // civicrm.settings.php via: $config['CiviCRM Preferences']['additional_fonts'] // CRM-13307 diff --git a/CRM/Utils/PDF/Utils.php b/CRM/Utils/PDF/Utils.php index 773c537f10..db9779fdab 100644 --- a/CRM/Utils/PDF/Utils.php +++ b/CRM/Utils/PDF/Utils.php @@ -79,7 +79,7 @@ class CRM_Utils_PDF_Utils { $stationery_path = $doc_root . "/" . $stationery_path_partial; } - $margins = array($metric,$t,$r,$b,$l); + $margins = array($metric, $t, $r, $b, $l); $config = CRM_Core_Config::singleton(); $html = " @@ -129,7 +129,7 @@ class CRM_Utils_PDF_Utils { // This function also uses the FPDI library documented at: http://www.setasign.com/products/fpdi/about/ // Syntax borrowed from https://github.com/jake-mw/CDNTaxReceipts/blob/master/cdntaxreceipts.functions.inc require_once 'tcpdf/tcpdf.php'; - require_once('FPDI/fpdi.php'); // This library is only in the 'packages' area as of version 4.5 + require_once 'FPDI/fpdi.php'; // This library is only in the 'packages' area as of version 4.5 $paper_size_arr = array( $paper_size[2], $paper_size[3]); @@ -142,19 +142,19 @@ class CRM_Utils_PDF_Utils { $pdf->SetAuthor(''); $pdf->SetKeywords('CiviCRM.org'); - $pdf->setPageUnit( $margins[0] ) ; - $pdf->SetMargins($margins[4], $margins[1], $margins[2], true); + $pdf->setPageUnit( $margins[0] ); + $pdf->SetMargins($margins[4], $margins[1], $margins[2], TRUE); $pdf->setJPEGQuality('100'); - $pdf->SetAutoPageBreak(true, $margins[3]); + $pdf->SetAutoPageBreak(TRUE, $margins[3]); $pdf->AddPage(); - $ln = true ; - $fill = false ; - $reset_parm = false; - $cell = false; - $align = '' ; + $ln = TRUE; + $fill = FALSE; + $reset_parm = FALSE; + $cell = FALSE; + $align = ''; // output the HTML content $pdf->writeHTML($html, $ln, $fill, $reset_parm, $cell, $align); @@ -164,7 +164,7 @@ class CRM_Utils_PDF_Utils { // close and output the PDF $pdf->Close(); - $pdf_file = 'CiviLetter'.'.pdf'; + $pdf_file = 'CiviLetter'.'.pdf'; $pdf->Output($pdf_file, 'D'); CRM_Utils_System::civiExit(1); } @@ -306,11 +306,11 @@ class CRM_Utils_PDF_Utils { $searchPath, &$values, $numPages = 1, - $echo = TRUE, - $output = 'College_Match_App', - $creator = 'CiviCRM', - $author = 'http://www.civicrm.org/', - $title = '2006 College Match Scholarship Application' + $echo = TRUE, + $output = 'College_Match_App', + $creator = 'CiviCRM', + $author = 'http://www.civicrm.org/', + $title = '2006 College Match Scholarship Application' ) { try { $pdf = new PDFlib(); @@ -355,7 +355,6 @@ class CRM_Utils_PDF_Utils { $pdf->fit_pdi_page($page, 0, 0, 'adjustpage'); - $status = array(); /* Fill all text blocks with dynamic data */ diff --git a/CRM/Utils/Pager.php b/CRM/Utils/Pager.php index a83b1dee57..6a469c5c09 100644 --- a/CRM/Utils/Pager.php +++ b/CRM/Utils/Pager.php @@ -165,7 +165,6 @@ class CRM_Utils_Pager extends Pager_Sliding { $params['prevImg'] = ' ' . ts('< Previous'); $params['nextImg'] = ts('Next >') . ' '; - // set first and last text fragments $params['firstPagePre'] = ''; $params['firstPageText'] = ' ' . ts('<< First'); @@ -203,20 +202,20 @@ class CRM_Utils_Pager extends Pager_Sliding { $currentPage = $defaultPageId; if (!empty($_POST)) { if (isset($_POST[CRM_Utils_Array::value('buttonTop', $params)]) && isset($_POST[self::PAGE_ID])) { - $currentPage = max((int )@$_POST[self::PAGE_ID], 1); + $currentPage = max((int ) @$_POST[self::PAGE_ID], 1); } elseif (isset($_POST[$params['buttonBottom']]) && isset($_POST[self::PAGE_ID_BOTTOM])) { - $currentPage = max((int )@$_POST[self::PAGE_ID_BOTTOM], 1); + $currentPage = max((int ) @$_POST[self::PAGE_ID_BOTTOM], 1); } elseif (isset($_POST[self::PAGE_ID])) { - $currentPage = max((int )@$_POST[self::PAGE_ID], 1); + $currentPage = max((int ) @$_POST[self::PAGE_ID], 1); } elseif (isset($_POST[self::PAGE_ID_BOTTOM])) { - $currentPage = max((int )@$_POST[self::PAGE_ID_BOTTOM]); + $currentPage = max((int ) @$_POST[self::PAGE_ID_BOTTOM]); } } elseif (isset($_GET[self::PAGE_ID])) { - $currentPage = max((int )@$_GET[self::PAGE_ID], 1); + $currentPage = max((int ) @$_GET[self::PAGE_ID], 1); } return $currentPage; } @@ -233,10 +232,10 @@ class CRM_Utils_Pager extends Pager_Sliding { public function getPageRowCount($defaultPageRowCount = self::ROWCOUNT) { // POST has higher priority than GET vars if (isset($_POST[self::PAGE_ROWCOUNT])) { - $rowCount = max((int )@$_POST[self::PAGE_ROWCOUNT], 1); + $rowCount = max((int ) @$_POST[self::PAGE_ROWCOUNT], 1); } elseif (isset($_GET[self::PAGE_ROWCOUNT])) { - $rowCount = max((int )@$_GET[self::PAGE_ROWCOUNT], 1); + $rowCount = max((int ) @$_GET[self::PAGE_ROWCOUNT], 1); } else { $rowCount = $defaultPageRowCount; diff --git a/CRM/Utils/PagerAToZ.php b/CRM/Utils/PagerAToZ.php index 40d169db83..f67e5c9036 100644 --- a/CRM/Utils/PagerAToZ.php +++ b/CRM/Utils/PagerAToZ.php @@ -123,7 +123,7 @@ class CRM_Utils_PagerAToZ { //get the current path $path = CRM_Utils_System::currentPath(); - $qfKey = null; + $qfKey = NULL; if (isset($query->_formValues)) { $qfKey = CRM_Utils_Array::value('qfKey', $query->_formValues); } diff --git a/CRM/Utils/QueryFormatter.php b/CRM/Utils/QueryFormatter.php index 6dde078dbd..1404ede2ea 100644 --- a/CRM/Utils/QueryFormatter.php +++ b/CRM/Utils/QueryFormatter.php @@ -125,12 +125,15 @@ class CRM_Utils_QueryFormatter { case self::LANG_SQL_FTS: $text = $this->_formatFts($text, $this->mode); break; + case self::LANG_SQL_FTSBOOL: $text = $this->_formatFtsBool($text, $this->mode); break; + case self::LANG_SQL_LIKE: $text = $this->_formatLike($text, $this->mode); break; + default: $text = NULL; } diff --git a/CRM/Utils/REST.php b/CRM/Utils/REST.php index 6b6116bccd..1811dc5640 100644 --- a/CRM/Utils/REST.php +++ b/CRM/Utils/REST.php @@ -155,11 +155,11 @@ class CRM_Utils_REST { return $json; } - if (isset($result['count'])) { $count = ' count="' . $result['count'] . '" '; } - else $count = ""; + else { $count = ""; + } $xml = " "; @@ -227,7 +227,8 @@ class CRM_Utils_REST { if ($inquote || $inarray) { $result .= $char; } - else $result .= $char . $newline . str_repeat($tab, $tabcount); + else { $result .= $char . $newline . str_repeat($tab, $tabcount); + } break; case '"': @@ -300,7 +301,6 @@ class CRM_Utils_REST { $args[2] = CRM_Utils_array::value('action', $requestParams); } - // Everyone should be required to provide the server key, so the whole // interface can be disabled in more change to the configuration file. // first check for civicrm site key @@ -313,7 +313,6 @@ class CRM_Utils_REST { return self::error("FATAL: 'key' is incorrect. More info at: " . $docLink); } - // At this point we know we are not calling ping which does not require authentication. // Therefore, at this point we need to make sure we're working with a trusted user. // Valid users are those who provide a valid server key and API key @@ -375,7 +374,7 @@ class CRM_Utils_REST { return $result; } - if ($_SERVER['REQUEST_METHOD'] == 'GET' && strtolower(substr( $args[2],0,3)) != 'get') { + if ($_SERVER['REQUEST_METHOD'] == 'GET' && strtolower(substr( $args[2], 0, 3)) != 'get') { // get only valid for non destructive methods require_once 'api/v3/utils.php'; return civicrm_api3_create_error("SECURITY: All requests that modify the database must be http POST, not GET.", @@ -427,7 +426,8 @@ class CRM_Utils_REST { } } if (array_key_exists('return', $requestParams) && is_array($requestParams['return'])) { - foreach ($requestParams['return'] as $key => $v) $params['return.' . $key] = 1; + foreach ($requestParams['return'] as $key => $v) { $params['return.' . $key] = 1; + } } return $params; } @@ -468,52 +468,52 @@ class CRM_Utils_REST { /** used to load a template "inline", eg. for ajax, without having to build a menu for each template */ static function loadTemplate () { $request = CRM_Utils_Request::retrieve( 'q', 'String'); - if (false !== strpos($request, '..')) { + if (FALSE !== strpos($request, '..')) { die ("SECURITY FATAL: the url can't contain '..'. Please report the issue on the forum at civicrm.org"); } - $request = split ('/',$request); + $request = split('/', $request); $entity = _civicrm_api_get_camel_name($request[2]); - $tplfile=_civicrm_api_get_camel_name($request[3]); + $tplfile = _civicrm_api_get_camel_name($request[3]); $tpl = 'CRM/'.$entity.'/Page/Inline/'.$tplfile.'.tpl'; - $smarty= CRM_Core_Smarty::singleton( ); + $smarty = CRM_Core_Smarty::singleton( ); CRM_Utils_System::setTitle( "$entity::$tplfile inline $tpl" ); if( !$smarty->template_exists($tpl) ){ header("Status: 404 Not Found"); die ("Can't find the requested template file templates/$tpl"); } - if (array_key_exists('id',$_GET)) {// special treatmenent, because it's often used - $smarty->assign ('id',(int)$_GET['id']);// an id is always positive + if (array_key_exists('id', $_GET)) {// special treatmenent, because it's often used + $smarty->assign('id', (int) $_GET['id']);// an id is always positive } - $pos = strpos (implode (array_keys ($_GET)),'<') ; + $pos = strpos(implode(array_keys($_GET)), '<'); - if ($pos !== false) { + if ($pos !== FALSE) { die ("SECURITY FATAL: one of the param names contains <"); } - $param = array_map( 'htmlentities' , $_GET); + $param = array_map( 'htmlentities', $_GET); unset($param['q']); $smarty->assign_by_ref("request", $param); - if ( ! array_key_exists ( 'HTTP_X_REQUESTED_WITH', $_SERVER ) || + if ( ! array_key_exists( 'HTTP_X_REQUESTED_WITH', $_SERVER ) || $_SERVER['HTTP_X_REQUESTED_WITH'] != "XMLHttpRequest" ) { - $smarty->assign( 'tplFile', $tpl ); - $config = CRM_Core_Config::singleton(); - $content = $smarty->fetch( 'CRM/common/'. strtolower($config->userFramework) .'.tpl' ); + $smarty->assign( 'tplFile', $tpl ); + $config = CRM_Core_Config::singleton(); + $content = $smarty->fetch( 'CRM/common/'. strtolower($config->userFramework) .'.tpl' ); - if (!defined('CIVICRM_UF_HEAD') && $region = CRM_Core_Region::instance('html-header', FALSE)) { - CRM_Utils_System::addHTMLHead($region->render('')); - } - CRM_Utils_System::appendTPLFile( $tpl, $content ); + if (!defined('CIVICRM_UF_HEAD') && $region = CRM_Core_Region::instance('html-header', FALSE)) { + CRM_Utils_System::addHTMLHead($region->render('')); + } + CRM_Utils_System::appendTPLFile( $tpl, $content ); - return CRM_Utils_System::theme($content); + return CRM_Utils_System::theme($content); - } else { - $content = "\n"; - CRM_Utils_System::appendTPLFile( $tpl, $content ); - echo $content . $smarty->fetch ($tpl); - CRM_Utils_System::civiExit( ); + } else { + $content = "\n"; + CRM_Utils_System::appendTPLFile( $tpl, $content ); + echo $content . $smarty->fetch($tpl); + CRM_Utils_System::civiExit( ); } } diff --git a/CRM/Utils/ReCAPTCHA.php b/CRM/Utils/ReCAPTCHA.php index 95d3031812..3b1be1a1c0 100644 --- a/CRM/Utils/ReCAPTCHA.php +++ b/CRM/Utils/ReCAPTCHA.php @@ -70,7 +70,8 @@ class CRM_Utils_ReCAPTCHA { /** * */ - public function __construct() {} + public function __construct() { + } /** * Add element to form diff --git a/CRM/Utils/Rule.php b/CRM/Utils/Rule.php index d1dc1d0b62..b17809a550 100644 --- a/CRM/Utils/Rule.php +++ b/CRM/Utils/Rule.php @@ -423,14 +423,14 @@ class CRM_Utils_Rule { $config = CRM_Core_Config::singleton(); - //CRM-14868 + //CRM-14868 $currencySymbols = CRM_Core_PseudoConstant::get( 'CRM_Contribute_DAO_Contribution', 'currency', array( 'keyColumn' => 'name', 'labelColumn' => 'symbol' )); - $value = str_replace($currencySymbols,'',$value); + $value = str_replace($currencySymbols, '', $value); if ($config->monetaryThousandSeparator) { $mon_thousands_sep = $config->monetaryThousandSeparator; diff --git a/CRM/Utils/Signer.php b/CRM/Utils/Signer.php index fb0d9a6876..53eef4721b 100644 --- a/CRM/Utils/Signer.php +++ b/CRM/Utils/Signer.php @@ -89,7 +89,7 @@ class CRM_Utils_Signer { if (empty($salt)) { $message['salt'] = $this->createSalt(); } else { - $message['salt'] = $salt; + $message['salt'] = $salt; } // recall: paramNames is pre-sorted for stability foreach ($this->paramNames as $paramName) { @@ -100,8 +100,8 @@ class CRM_Utils_Signer { } else { // $paramName is not included or ===NULL $params[$paramName] = ''; } - $message['payload'][$paramName] = $params[$paramName]; - } + $message['payload'][$paramName] = $params[$paramName]; + } $token = $message['salt'] . $this->signDelim . md5(serialize($message)); return $token; } diff --git a/CRM/Utils/SoapServer.php b/CRM/Utils/SoapServer.php index c10f13ba9c..1dca58014c 100644 --- a/CRM/Utils/SoapServer.php +++ b/CRM/Utils/SoapServer.php @@ -101,7 +101,6 @@ class CRM_Utils_SoapServer { throw new SoapFault('Client', 'Invalid key'); } - if (self::$soap_timeout && $t > ($session->get('soap_time') + self::$soap_timeout) ) { @@ -128,10 +127,10 @@ class CRM_Utils_SoapServer { * @static */ public function authenticate($name, $pass, $loadCMSBootstrap = FALSE) { - require_once (str_replace('_', DIRECTORY_SEPARATOR, $this->ufClass) . '.php'); + require_once str_replace('_', DIRECTORY_SEPARATOR, $this->ufClass) . '.php'; if ($this->ufClass == 'CRM_Utils_System_Joomla'){ - $loadCMSBootstrap = true; + $loadCMSBootstrap = TRUE; } $className = $this->ufClass; diff --git a/CRM/Utils/String.php b/CRM/Utils/String.php index 035bf4d8cd..e0df196d12 100644 --- a/CRM/Utils/String.php +++ b/CRM/Utils/String.php @@ -597,7 +597,6 @@ class CRM_Utils_String { $_replaceChar = '_'; } - if ($search == NULL) { $search = $_searchChars; } @@ -622,13 +621,13 @@ class CRM_Utils_String { * @static */ public static function purifyHTML($string) { - static $_filter = null; + static $_filter = NULL; if (!$_filter) { $config = HTMLPurifier_Config::createDefault(); $config->set('Core.Encoding', 'UTF-8'); // Disable the cache entirely - $config->set('Cache.DefinitionImpl', null); + $config->set('Cache.DefinitionImpl', NULL); $_filter = new HTMLPurifier($config); } @@ -650,7 +649,7 @@ class CRM_Utils_String { return $string; } else { - return substr($string, 0, $maxLen-3) . '...'; + return substr($string, 0, $maxLen - 3) . '...'; } } @@ -688,7 +687,7 @@ class CRM_Utils_String { return array($defaultPrefix, $string); } else { - return array(substr($string, 0, $pos), substr($string, 1+$pos)); + return array(substr($string, 0, $pos), substr($string, 1 + $pos)); } } @@ -704,17 +703,17 @@ class CRM_Utils_String { * * @return string returns the masked Email address */ - public static function maskEmail($email, $maskChar= '*', $percent=50) { + public static function maskEmail($email, $maskChar = '*', $percent = 50) { list($user, $domain) = preg_split("/@/", $email); $len = strlen($user); - $maskCount = floor($len * $percent /100); + $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); + return ($masked.'@'.$domain); } /** diff --git a/CRM/Utils/System.php b/CRM/Utils/System.php index f2cf53c4c1..4291abb693 100644 --- a/CRM/Utils/System.php +++ b/CRM/Utils/System.php @@ -186,7 +186,7 @@ class CRM_Utils_System { */ static function theme( &$content, - $print = FALSE, + $print = FALSE, $maintenance = FALSE ) { $config = &CRM_Core_Config::singleton(); @@ -232,10 +232,10 @@ class CRM_Utils_System { */ static function url( $path = NULL, - $query = NULL, + $query = NULL, $absolute = FALSE, $fragment = NULL, - $htmlize = TRUE, + $htmlize = TRUE, $frontend = FALSE, $forceBackend = FALSE ) { @@ -429,8 +429,8 @@ class CRM_Utils_System { * */ static function jsRedirect( - $url = NULL, - $title = NULL, + $url = NULL, + $title = NULL, $message = NULL ) { if (!$url) { @@ -751,7 +751,7 @@ class CRM_Utils_System { if (preg_match('/

([^<]+)<\/h2>/', $vTmp[$i], $vMat)) { $vName = trim($vMat[1]); $vTmp2 = explode("\n", $vTmp[$i + 1]); - foreach ($vTmp2 AS $vOne) { + foreach ($vTmp2 as $vOne) { $vPat = '([^<]+)<\/info>'; $vPat3 = "/$vPat\s*$vPat\s*$vPat/"; $vPat2 = "/$vPat\s*$vPat/"; @@ -847,7 +847,7 @@ class CRM_Utils_System { * (optional) Whether to log the memory usage information. */ public static function xMemory($title = NULL, $log = FALSE) { - $mem = (float ) xdebug_memory_usage() / (float )(1024); + $mem = (float ) xdebug_memory_usage() / (float ) (1024); $mem = number_format($mem, 5) . ", " . time(); if ($log) { echo "

$title: $mem

"; @@ -901,7 +901,7 @@ class CRM_Utils_System { list($className, $methodName) = explode('::', $callback); $fileName = str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php'; // ignore errors if any - @include_once ($fileName); + @include_once $fileName; if (!class_exists($className)) { self::$_callbacks[$callback] = FALSE; } @@ -1063,7 +1063,7 @@ class CRM_Utils_System { array(dirname(__FILE__), '..', '..', 'civicrm-version.php') ); if (file_exists($verFile)) { - require_once ($verFile); + require_once $verFile; if (function_exists('civicrmVersion')) { $info = civicrmVersion(); $version = $info['version']; @@ -1144,7 +1144,7 @@ class CRM_Utils_System { * Note that we inline this function in install/civicrm.php, so if you change * this function, please go and change the code in the install script as well. */ - public static function isSSL( ) { + public static function isSSL() { return (isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) && @@ -1167,7 +1167,7 @@ class CRM_Utils_System { CRM_Core_Error::fatal('HTTPS is not set up on this machine'); } else { - CRM_Core_Session::setStatus(ts('HTTPS is not set up on this machine'), ts('Warning'), 'alert'); + CRM_Core_Session::setStatus(ts('HTTPS is not set up on this machine'), ts('Warning'), 'alert'); // admin should be the only one following this // since we dont want the user stuck in a bad place return; @@ -1202,7 +1202,7 @@ class CRM_Utils_System { if ($config->userSystem->is_drupal && function_exists('ip_address')) { //drupal function handles the server being behind a proxy securely. We still have legacy ipn methods // that reach this point without bootstrapping hence the check that the fn exists - $address = ip_address(); + $address = ip_address(); } // hack for safari @@ -1281,7 +1281,7 @@ class CRM_Utils_System { // return just the URL, no matter what other parameters are defined if (!function_exists('ts')) { if ($resource == 'wiki') { - $docBaseURL = self::getWikiBaseURL(); + $docBaseURL = self::getWikiBaseURL(); } else { $docBaseURL = self::getDocBaseURL(); } @@ -1456,7 +1456,7 @@ class CRM_Utils_System { /** * Reset the various system caches and some important static variables. */ - public static function flushCache( ) { + public static function flushCache() { // flush out all cache entries so we can reload new data // a bit aggressive, but livable for now $cache = CRM_Utils_Cache::singleton(); diff --git a/CRM/Utils/System/Base.php b/CRM/Utils/System/Base.php index 22f9c7f6ec..2a5806ea68 100644 --- a/CRM/Utils/System/Base.php +++ b/CRM/Utils/System/Base.php @@ -102,7 +102,7 @@ abstract class CRM_Utils_System_Base { throw new \Exception('Constant "ABSPATH" is not defined, even though WordPress is the user framework.'); } if (is_admin()) { - require_once (ABSPATH . 'wp-admin/admin-header.php'); + require_once ABSPATH . 'wp-admin/admin-header.php'; } else { // FIXME: we need to figure out to replace civicrm content on the frontend pages @@ -269,7 +269,7 @@ abstract class CRM_Utils_System_Base { return FALSE; } - $timeZoneOffset = sprintf("%02d:%02d", $tz / 3600, abs(($tz/60)%60)); + $timeZoneOffset = sprintf("%02d:%02d", $tz / 3600, abs(($tz / 60) % 60)); if ($timeZoneOffset > 0) { $timeZoneOffset = '+' . $timeZoneOffset; @@ -296,7 +296,8 @@ abstract class CRM_Utils_System_Base { * @return mixed $uniqueIdentifer Unique identifier from the user Framework system * */ - public function getUniqueIdentifierFromUserObject($user) {} + public function getUniqueIdentifierFromUserObject($user) { + } /** * Get User ID from UserFramework system (CMS) @@ -305,21 +306,24 @@ abstract class CRM_Utils_System_Base { * @return mixed * */ - public function getUserIDFromUserObject($user) {} + public function getUserIDFromUserObject($user) { + } /** * Get currently logged in user uf id. * * @return int $userID logged in user uf id. */ - public function getLoggedInUfID() {} + public function getLoggedInUfID() { + } /** * Get currently logged in user unique identifier - this tends to be the email address or user name. * * @return string $userID logged in user unique identifier */ - public function getLoggedInUniqueIdentifier() {} + public function getLoggedInUniqueIdentifier() { + } /** * Return a UFID (user account ID from the UserFramework / CMS system being based on the user object @@ -391,5 +395,6 @@ abstract class CRM_Utils_System_Base { /** * Append to coreResourcesList */ - public function appendCoreResources(&$list) {} + public function appendCoreResources(&$list) { + } } diff --git a/CRM/Utils/System/Drupal.php b/CRM/Utils/System/Drupal.php index b79de49d79..7833c465a0 100644 --- a/CRM/Utils/System/Drupal.php +++ b/CRM/Utils/System/Drupal.php @@ -61,7 +61,7 @@ class CRM_Utils_System_Drupal extends CRM_Utils_System_DrupalBase { $admin = user_access('administer users'); if (!variable_get('user_email_verification', TRUE) || $admin) { - $form_state['input']['pass'] = array('pass1'=>$params['cms_pass'],'pass2'=>$params['cms_pass']); + $form_state['input']['pass'] = array('pass1' => $params['cms_pass'], 'pass2' => $params['cms_pass']); } if(!empty($params['notify'])){ @@ -337,6 +337,7 @@ class CRM_Utils_System_Drupal extends CRM_Utils_System_DrupalBase { case 'page-footer': $params['scope'] = substr($region, 5); break; + default: return FALSE; } @@ -365,6 +366,7 @@ class CRM_Utils_System_Drupal extends CRM_Utils_System_DrupalBase { case 'page-footer': $params['scope'] = substr($region, 5); break; + default: return FALSE; } @@ -460,7 +462,7 @@ class CRM_Utils_System_Drupal extends CRM_Utils_System_DrupalBase { * array( * contactID, ufID, unique string ) if success */ - public static function authenticate($name, $password, $loadCMSBootstrap = FALSE, $realPath = NULL) { + public static function authenticate($name, $password, $loadCMSBootstrap = FALSE, $realPath = NULL) { require_once 'DB.php'; $config = CRM_Core_Config::singleton(); @@ -493,8 +495,8 @@ class CRM_Utils_System_Drupal extends CRM_Utils_System_DrupalBase { // Contact CiviSMTP folks if we run into issues with this :) $cmsPath = $config->userSystem->cmsRootPath($realPath); - require_once ("$cmsPath/includes/bootstrap.inc"); - require_once ("$cmsPath/includes/password.inc"); + require_once "$cmsPath/includes/bootstrap.inc"; + require_once "$cmsPath/includes/password.inc"; $strtolower = function_exists('mb_strtolower') ? 'mb_strtolower' : 'strtolower'; $name = $dbDrupal->escapeSimple($strtolower($name)); @@ -759,7 +761,7 @@ AND u.status = 1 // which means that define(CIVICRM_CLEANURL) was correctly set. // So we correct it $config = CRM_Core_Config::singleton(); - $config->cleanURL = (int)variable_get('clean_url', '0'); + $config->cleanURL = (int) variable_get('clean_url', '0'); // CRM-8655: Drupal wasn't available during bootstrap, so hook_civicrm_config never executes CRM_Utils_Hook::config($config); @@ -1006,7 +1008,7 @@ AND u.status = 1 if (variable_get('configurable_timezones', 1) && $user->uid && strlen($user->timezone)) { $timezone = $user->timezone; } else { - $timezone = variable_get('date_default_timezone', null); + $timezone = variable_get('date_default_timezone', NULL); } if (!$timezone) { $timezone = parent::getTimeZoneString(); diff --git a/CRM/Utils/System/Drupal6.php b/CRM/Utils/System/Drupal6.php index a088395f11..5a6238eb96 100644 --- a/CRM/Utils/System/Drupal6.php +++ b/CRM/Utils/System/Drupal6.php @@ -443,13 +443,13 @@ class CRM_Utils_System_Drupal6 extends CRM_Utils_System_DrupalBase { * contactID, ufID, unique string ) if success */ public function authenticate($name, $password, $loadCMSBootstrap = FALSE, $realPath = NULL) { - //@todo this 'PEAR-y' stuff is only required when bookstrap is not being loaded which is rare - // if ever now. - // probably if bootstrap is loaded this call - // CRM_Utils_System::loadBootStrap($bootStrapParams, TRUE, TRUE, $realPath); would be - // sufficient to do what this fn does. It does exist as opposed to return which might need some hanky-panky to make - // safe in the unknown situation where authenticate might be called & it is important that - // false is returned + //@todo this 'PEAR-y' stuff is only required when bookstrap is not being loaded which is rare + // if ever now. + // probably if bootstrap is loaded this call + // CRM_Utils_System::loadBootStrap($bootStrapParams, TRUE, TRUE, $realPath); would be + // sufficient to do what this fn does. It does exist as opposed to return which might need some hanky-panky to make + // safe in the unknown situation where authenticate might be called & it is important that + // false is returned require_once 'DB.php'; $config = CRM_Core_Config::singleton(); @@ -705,7 +705,7 @@ class CRM_Utils_System_Drupal6 extends CRM_Utils_System_DrupalBase { // which means that define(CIVICRM_CLEANURL) was correctly set. // So we correct it $config = CRM_Core_Config::singleton(); - $config->cleanURL = (int)variable_get('clean_url', '0'); + $config->cleanURL = (int) variable_get('clean_url', '0'); // CRM-8655: Drupal wasn't available during bootstrap, so hook_civicrm_config never executes CRM_Utils_Hook::config($config); @@ -946,7 +946,7 @@ class CRM_Utils_System_Drupal6 extends CRM_Utils_System_DrupalBase { * Drupal User ID. */ public function og_membership_delete($ogID, $drupalID) { - og_delete_subscription( $ogID, $drupalID ); + og_delete_subscription( $ogID, $drupalID ); } /** @@ -958,7 +958,7 @@ class CRM_Utils_System_Drupal6 extends CRM_Utils_System_DrupalBase { if (variable_get('configurable_timezones', 1) && $user->uid && strlen($user->timezone)) { $timezone = $user->timezone; } else { - $timezone = variable_get('date_default_timezone', null); + $timezone = variable_get('date_default_timezone', NULL); } if (!$timezone) { $timezone = parent::getTimeZoneString(); diff --git a/CRM/Utils/System/Drupal8.php b/CRM/Utils/System/Drupal8.php index 7aa8abd0ca..f1de352bf6 100644 --- a/CRM/Utils/System/Drupal8.php +++ b/CRM/Utils/System/Drupal8.php @@ -101,9 +101,11 @@ class CRM_Utils_System_Drupal8 extends CRM_Utils_System_DrupalBase { case $user_register_conf == 'admin_only' || $user->isAuthenticated(): _user_mail_notify('register_admin_created', $account); break; + case $user_register_conf == 'visitors': _user_mail_notify('register_no_approval_required', $account); break; + case 'visitors_admin_approval': _user_mail_notify('register_pending_approval', $account); break; @@ -155,7 +157,8 @@ class CRM_Utils_System_Drupal8 extends CRM_Utils_System_DrupalBase { // This checks for both username uniqueness and validity. $violations = iterator_to_array($user->validate()); // We only care about violations on the username field; discard the rest. - $violations = array_filter($violations, function ($v) { return $v->getPropertyPath() == 'name.0.value'; }); + $violations = array_filter($violations, function ($v) { return $v->getPropertyPath() == 'name.0.value'; + }); if (count($violations) > 0) { $errors['cms_name'] = $violations[0]->getMessage(); } @@ -171,7 +174,8 @@ class CRM_Utils_System_Drupal8 extends CRM_Utils_System_DrupalBase { // This checks for both email uniqueness. $violations = iterator_to_array($user->validate()); // We only care about violations on the email field; discard the rest. - $violations = array_filter($violations, function ($v) { return $v->getPropertyPath() == 'mail.0.value'; }); + $violations = array_filter($violations, function ($v) { return $v->getPropertyPath() == 'mail.0.value'; + }); if (count($violations) > 0) { $errors[$emailName] = $violations[0]->getMessage(); } @@ -305,6 +309,7 @@ class CRM_Utils_System_Drupal8 extends CRM_Utils_System_DrupalBase { case 'page-footer': $options['scope'] = substr($region, 5); break; + default: return FALSE; } @@ -333,6 +338,7 @@ class CRM_Utils_System_Drupal8 extends CRM_Utils_System_DrupalBase { case 'page-footer': $options['scope'] = substr($region, 5); break; + default: return FALSE; } @@ -557,7 +563,9 @@ class CRM_Utils_System_Drupal8 extends CRM_Utils_System_DrupalBase { */ public function loadBootStrap($params = array(), $loadUser = TRUE, $throwError = TRUE, $realPath = NULL) { static $run_once = FALSE; - if ($run_once) return TRUE; else $run_once = TRUE; + if ($run_once) { return TRUE; + } else { $run_once = TRUE; + } if (!($root = $this->cmsRootPath())) { return FALSE; diff --git a/CRM/Utils/System/Joomla.php b/CRM/Utils/System/Joomla.php index dcd175a4f8..0fb75eaab3 100644 --- a/CRM/Utils/System/Joomla.php +++ b/CRM/Utils/System/Joomla.php @@ -104,8 +104,8 @@ class CRM_Utils_System_Joomla extends CRM_Utils_System_Base { /** * Change user name in host CMS * - * @param integer $ufID User ID in CMS - * @param string $ufName User name + * @param int $ufID + * @param string $ufName User name */ public function updateCMSName($ufID, $ufName) { $ufID = CRM_Utils_Type::escape($ufID, 'Integer'); @@ -145,7 +145,6 @@ class CRM_Utils_System_Joomla extends CRM_Utils_System_Base { $errors['cms_name'] = ts('Your username contains invalid characters or is too short'); } - $JUserTable = &JTable::getInstance('User', 'JTable'); $db = $JUserTable->getDbo(); @@ -472,7 +471,7 @@ class CRM_Utils_System_Joomla extends CRM_Utils_System_Base { * * @return mixed false if no auth * array( - contactID, ufID, unique string ) if success + contactID, ufID, unique string ) if success */ public function authenticate($name, $password, $loadCMSBootstrap = FALSE) { require_once 'DB.php'; @@ -540,7 +539,8 @@ class CRM_Utils_System_Joomla extends CRM_Utils_System_Base { } } else { - if (!JUserHelper::verifyPassword($password, $dbPassword, $dbId)) return FALSE; + if (!JUserHelper::verifyPassword($password, $dbPassword, $dbId)) { return FALSE; + } //include additional files required by Joomla 3.2.1+ if ( version_compare(JVERSION, '3.2.1', 'ge') ) { @@ -751,7 +751,7 @@ class CRM_Utils_System_Joomla extends CRM_Utils_System_Base { $result = array(); $db = JFactory::getDbo(); - $query = $db->getQuery(true); + $query = $db->getQuery(TRUE); $query->select('type, folder, element, enabled') ->from('#__extensions') ->where('type =' . $db->Quote('plugin')); @@ -892,7 +892,7 @@ class CRM_Utils_System_Joomla extends CRM_Utils_System_Base { parent::outputError($content); } } - + /** * Append to coreResourcesList */ diff --git a/CRM/Utils/System/Soap.php b/CRM/Utils/System/Soap.php index 0b782b367c..760c651e3d 100644 --- a/CRM/Utils/System/Soap.php +++ b/CRM/Utils/System/Soap.php @@ -143,7 +143,8 @@ class CRM_Utils_System_Soap extends CRM_Utils_System_Base { * * @return void */ - public function setEmail(&$user) {} + public function setEmail(&$user) { + } /** * Authenticate a user against the real UF diff --git a/CRM/Utils/System/UnitTests.php b/CRM/Utils/System/UnitTests.php index 434edfd071..f540600252 100644 --- a/CRM/Utils/System/UnitTests.php +++ b/CRM/Utils/System/UnitTests.php @@ -42,7 +42,7 @@ class CRM_Utils_System_UnitTests extends CRM_Utils_System_Drupal { */ public function __construct() { $this->is_drupal = FALSE; - $this->supports_form_extensions = False; + $this->supports_form_extensions = FALSE; } /** diff --git a/CRM/Utils/System/WordPress.php b/CRM/Utils/System/WordPress.php index 03365f2ece..31a003e2ab 100644 --- a/CRM/Utils/System/WordPress.php +++ b/CRM/Utils/System/WordPress.php @@ -443,8 +443,8 @@ class CRM_Utils_System_WordPress extends CRM_Utils_System_Base { * * @return bool */ - public function loadUser( $user ) { - return true; + public function loadUser($user) { + return TRUE; } public function permissionDenied() { @@ -460,7 +460,8 @@ class CRM_Utils_System_WordPress extends CRM_Utils_System_Base { wp_redirect(wp_login_url()); } - public function updateCategories() {} + public function updateCategories() { + } /** * Get the locale set in the hosting CMS @@ -500,13 +501,13 @@ class CRM_Utils_System_WordPress extends CRM_Utils_System_Base { CRM_Core_Error::fatal("Could not find the install directory for WordPress"); } - require_once ($cmsRootPath . DIRECTORY_SEPARATOR . 'wp-load.php'); + require_once $cmsRootPath . DIRECTORY_SEPARATOR . 'wp-load.php'; $wpUserTimezone = get_option('timezone_string'); if ($wpUserTimezone) { date_default_timezone_set($wpUserTimezone); CRM_Core_Config::singleton()->userSystem->setMySQLTimeZone(); } - require_once ($cmsRootPath . DIRECTORY_SEPARATOR . 'wp-includes/pluggable.php'); + require_once $cmsRootPath . DIRECTORY_SEPARATOR . 'wp-includes/pluggable.php'; $uid = CRM_Utils_Array::value('uid', $name); if ($uid) { $account = wp_set_current_user($uid); @@ -516,7 +517,7 @@ class CRM_Utils_System_WordPress extends CRM_Utils_System_Base { return TRUE; } } - return true; + return TRUE; } /** @@ -624,9 +625,9 @@ class CRM_Utils_System_WordPress extends CRM_Utils_System_Base { $ufID = CRM_Utils_Type::escape($ufID, 'Integer'); $ufName = CRM_Utils_Type::escape($ufName, 'String'); - $values = array ('ID' => $ufID, 'user_email' => $ufName); + $values = array('ID' => $ufID, 'user_email' => $ufName); if( $ufID ) { - wp_update_user( $values ) ; + wp_update_user( $values ); } } } diff --git a/CRM/Utils/Token.php b/CRM/Utils/Token.php index f914c45090..937c2a7d7c 100644 --- a/CRM/Utils/Token.php +++ b/CRM/Utils/Token.php @@ -214,7 +214,7 @@ class CRM_Utils_Token { return preg_replace(array('/{/', '/(? array()); - // also call a hook and get token details - CRM_Utils_Hook::tokenValues($details[0], + // also call a hook and get token details + CRM_Utils_Hook::tokenValues($details[0], $contactIDs, $jobID, $tokens, @@ -1326,9 +1326,9 @@ class CRM_Utils_Token { */ static function getContributionTokenDetails($contributionIDs, $returnProperties = NULL, - $extraParams = NULL, - $tokens = array(), - $className = NULL + $extraParams = NULL, + $tokens = array(), + $className = NULL ) { //@todo - this function basically replications calling civicrm_api3('contribution', 'get', array('id' => array('IN' => array()) if (empty($contributionIDs)) { @@ -1508,7 +1508,7 @@ class CRM_Utils_Token { $str = preg_replace_callback( self::tokenRegex($key), function ($matches) use($escapeSmarty) { - return CRM_Utils_Token::getUserTokenReplacement($matches[1], $escapeSmarty); + return CRM_Utils_Token::getUserTokenReplacement($matches[1], $escapeSmarty); }, $str ); @@ -1587,7 +1587,7 @@ class CRM_Utils_Token { return $str; } - $fn = 'get' . ucFirst($entity) . 'tokenReplacement'; + $fn = 'get' . ucfirst($entity) . 'tokenReplacement'; //since we already know the tokens lets just use them & do str_replace which is faster & simpler than preg_replace foreach ($knownTokens[$entity] as $token) { $replaceMent = CRM_Utils_Token::$fn($token, $entityArray, $escapeSmarty); @@ -1623,7 +1623,7 @@ class CRM_Utils_Token { $str = preg_replace_callback( self::tokenRegex($key), function ($matches) use(&$contribution, $html, $escapeSmarty) { - return CRM_Utils_Token::getContributionTokenReplacement($matches[1], $contribution, $html, $escapeSmarty); + return CRM_Utils_Token::getContributionTokenReplacement($matches[1], $contribution, $html, $escapeSmarty); }, $str ); @@ -1680,33 +1680,36 @@ class CRM_Utils_Token { public static function getMembershipTokenReplacement($token, $membership, $escapeSmarty = FALSE) { $entity = 'membership'; self::_buildMembershipTokens(); - switch ($token) { - case 'type': - $value = $membership['membership_name']; - break; - case 'status': - $statuses = CRM_Member_BAO_Membership::buildOptions('status_id'); - $value = $statuses[$membership['status_id']]; - break; - case 'fee': - try{ - $value = civicrm_api3('membership_type', 'getvalue', array('id' => $membership['membership_type_id'], 'return' => 'minimum_fee')); - } - catch (CiviCRM_API3_Exception $e) { - // we can anticipate we will get an error if the minimum fee is set to 'NULL' because of the way the - // api handles NULL (4.4) - $value = 0; - } - break; - default: - if (in_array($token, self::$_tokens[$entity])) { - $value = $membership[$token]; - } - else { - //ie unchanged - $value = "{$entity}.{$token}"; - } - break; + switch ($token) { + case 'type': + $value = $membership['membership_name']; + break; + + case 'status': + $statuses = CRM_Member_BAO_Membership::buildOptions('status_id'); + $value = $statuses[$membership['status_id']]; + break; + + case 'fee': + try{ + $value = civicrm_api3('membership_type', 'getvalue', array('id' => $membership['membership_type_id'], 'return' => 'minimum_fee')); + } + catch (CiviCRM_API3_Exception $e) { + // we can anticipate we will get an error if the minimum fee is set to 'NULL' because of the way the + // api handles NULL (4.4) + $value = 0; + } + break; + + default: + if (in_array($token, self::$_tokens[$entity])) { + $value = $membership[$token]; + } + else { + //ie unchanged + $value = "{$entity}.{$token}"; + } + break; } if ($escapeSmarty) { @@ -1749,7 +1752,6 @@ class CRM_Utils_Token { break; } - if ($escapeSmarty) { $value = self::tokenEscapeSmarty($value); } diff --git a/CRM/Utils/Tree.php b/CRM/Utils/Tree.php index 82bee5ee61..68034b0e0f 100644 --- a/CRM/Utils/Tree.php +++ b/CRM/Utils/Tree.php @@ -110,7 +110,7 @@ class CRM_Utils_Tree { * @param array (ref) $parentNode which parent node should we search in ? * * @return array( - ref) | false node if found else false + ref) | false node if found else false * */ //public function &findNode(&$parentNode, $name) @@ -148,7 +148,7 @@ class CRM_Utils_Tree { * Currently leaf nodes are strings and non-leaf nodes are arrays * * @param array( - ref) $node node which needs to checked + ref) $node node which needs to checked * * @return boolean * diff --git a/CRM/Utils/Type.php b/CRM/Utils/Type.php index 19b2675cdb..8b54738a19 100644 --- a/CRM/Utils/Type.php +++ b/CRM/Utils/Type.php @@ -112,7 +112,7 @@ class CRM_Utils_Type { $string = 'Blob'; break; - // CRM-10404 + // CRM-10404 case 12: case 256: $string = 'Timestamp'; @@ -165,7 +165,7 @@ class CRM_Utils_Type { break; case 'Positive': - // CRM-8925 the 3 below are for custom fields of this type + // CRM-8925 the 3 below are for custom fields of this type case 'Country': case 'StateProvince': // Checked for multi valued state/country value diff --git a/CRM/Utils/VersionCheck.php b/CRM/Utils/VersionCheck.php index a821244a65..39d8b832c5 100644 --- a/CRM/Utils/VersionCheck.php +++ b/CRM/Utils/VersionCheck.php @@ -87,7 +87,7 @@ class CRM_Utils_VersionCheck { * @var array */ protected $stats = array(); - + /** * Path to cache file * @@ -107,7 +107,7 @@ class CRM_Utils_VersionCheck { $this->cacheFile = $config->uploadDir . self::CACHEFILE_NAME; if (file_exists($localFile)) { - require_once ($localFile); + require_once $localFile; } if (function_exists('civicrmVersion')) { $info = civicrmVersion(); @@ -245,7 +245,7 @@ class CRM_Utils_VersionCheck { public function versionAlert() { $versionAlertSetting = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'versionAlert', NULL, 1); $securityAlertSetting = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'securityUpdateAlert', NULL, 3); - $settingsUrl = CRM_Utils_System::url('civicrm/admin/setting/misc', 'reset=1', FALSE, NULL, FALSE, FALSE, TRUE); + $settingsUrl = CRM_Utils_System::url('civicrm/admin/setting/misc', 'reset=1', FALSE, NULL, FALSE, FALSE, TRUE); if (CRM_Core_Permission::check('administer CiviCRM') && $securityAlertSetting > 1 && $this->isSecurityUpdateAvailable()) { $session = CRM_Core_Session::singleton(); if ($session->timer('version_alert', 24 * 60 * 60)) { diff --git a/CRM/Utils/Weight.php b/CRM/Utils/Weight.php index 53f10af11c..4fc7659087 100644 --- a/CRM/Utils/Weight.php +++ b/CRM/Utils/Weight.php @@ -105,7 +105,7 @@ class CRM_Utils_Weight { return FALSE; } - $weight = (int)$object->weight; + $weight = (int) $object->weight; if ($weight < 1) { return FALSE; } @@ -295,11 +295,11 @@ class CRM_Utils_Weight { $fieldValues = NULL, $queryData, $additionalWhere = NULL, - $orderBy = NULL, - $groupBy = NULL + $orderBy = NULL, + $groupBy = NULL ) { - require_once (str_replace('_', DIRECTORY_SEPARATOR, $daoName) . ".php"); + require_once str_replace('_', DIRECTORY_SEPARATOR, $daoName) . ".php"; $dao = new $daoName; $table = $dao->getTablename(); @@ -459,13 +459,15 @@ class CRM_Utils_Weight { $tableName = $object->tableName(); $query = "UPDATE $tableName SET weight = %1 WHERE $idName = %2"; - $params = array(1 => array($dstWeight, 'Integer'), + $params = array( + 1 => array($dstWeight, 'Integer'), 2 => array($src, 'Integer'), ); CRM_Core_DAO::executeQuery($query, $params); if ($dir == 'swap') { - $params = array(1 => array($srcWeight, 'Integer'), + $params = array( + 1 => array($srcWeight, 'Integer'), 2 => array($dst, 'Integer'), ); CRM_Core_DAO::executeQuery($query, $params); @@ -476,7 +478,8 @@ class CRM_Utils_Weight { if ($filter) { $query .= " AND $filter"; } - $params = array(1 => array($src, 'Integer'), + $params = array( + 1 => array($src, 'Integer'), 2 => array($srcWeight, 'Integer'), ); CRM_Core_DAO::executeQuery($query, $params); @@ -487,7 +490,8 @@ class CRM_Utils_Weight { if ($filter) { $query .= " AND $filter"; } - $params = array(1 => array($src, 'Integer'), + $params = array( + 1 => array($src, 'Integer'), 2 => array($srcWeight, 'Integer'), ); CRM_Core_DAO::executeQuery($query, $params); diff --git a/CRM/Utils/XML.php b/CRM/Utils/XML.php index 093d52c549..e4c7ffe2df 100644 --- a/CRM/Utils/XML.php +++ b/CRM/Utils/XML.php @@ -104,7 +104,7 @@ class CRM_Utils_XML { $parts = array(); if ($error->file) { - $parts[] = "File=$error->file"; + $parts[] = "File=$error->file"; } $parts[] = "Line=$error->line"; $parts[] = "Column=$error->column"; diff --git a/CRM/Utils/Zip.php b/CRM/Utils/Zip.php index a93ce02dfd..d2d8172e82 100644 --- a/CRM/Utils/Zip.php +++ b/CRM/Utils/Zip.php @@ -142,7 +142,7 @@ class CRM_Utils_Zip { } $zip->close(); } else { - return FALSE; + return FALSE; } return TRUE; }