Commit e7292422 authored by totten's avatar totten
Browse files

INFRA-132 - CRM/Utils - phpcbf

parent e418776c
......@@ -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
......
......@@ -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
}
......
......@@ -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),
......
......@@ -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
......
......@@ -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;
......
......@@ -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;
......
......@@ -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);
}
......
......@@ -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);
}
}
......
......@@ -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),"<?php //".serialize ($value));
file_put_contents($this->fileName($key), "<?php //".serialize($value));
}
/**
* @param string $key
*/
public function delete($key) {
if (file_exists($this->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);
......
......@@ -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:
}
}
......
......@@ -108,7 +108,6 @@ class CRM_Utils_Check_Env {
'checkOutboundMail',
ts('Warning: Outbound email is disabled in <a href="%1">system settings</a>. Proper settings should be enabled on production servers.',
array(1 => CRM_Utils_System::url('civicrm/admin/setting/smtp', 'reset=1'))),
ts('Outbound Email Settings')
);
}
......
......@@ -45,6 +45,7 @@ class CRM_Utils_Check_Security {
switch ($config->userFramework) {
case 'Joomla':
return '/media/';
default:
return '/files/';
}
......
......@@ -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));
......
......@@ -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));
}
}
......
......@@ -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;
......
......@@ -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;
}
}
......
......@@ -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');
}
......
......@@ -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.
......
......@@ -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.
......
......@@ -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.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment