Multiline arrays aren't always the most readable.
These were all done by an autoformatting tool which got a little too zealous
about breaking every array into multiple lines. They are especially silly within if() statements.
foreach ($result as $id => $activity) {
$isBulkActivity = (!$bulkActivityTypeID || ($bulkActivityTypeID === $activity['activity_type_id']));
foreach ($mappingParams as $apiKey => $expectedName) {
- if (in_array($apiKey, [
- 'target_contact_name',
- ])) {
+ if (in_array($apiKey, ['target_contact_name'])) {
if ($isBulkActivity) {
// @todo - how is this used? Couldn't we use 'is_bulk' or something clearer?
// Check for required permissions, CRM-6264.
if ($this->_activityId &&
- in_array($this->_action, [
- CRM_Core_Action::UPDATE,
- CRM_Core_Action::VIEW,
- ]) &&
+ in_array($this->_action, [CRM_Core_Action::UPDATE, CRM_Core_Action::VIEW]) &&
!CRM_Activity_BAO_Activity::checkPermission($this->_activityId, $this->_action)
) {
CRM_Core_Error::statusBounce(ts('You do not have permission to access this page.'));
}
$this->assign('searchKey', $qfKey);
}
- elseif (in_array($this->_context, [
- 'standalone',
- 'home',
- 'dashlet',
- 'dashletFullscreen',
- ])
- ) {
+ elseif (in_array($this->_context, ['standalone', 'home', 'dashlet', 'dashletFullscreen'])) {
$urlParams = 'reset=1';
$urlString = 'civicrm/dashboard';
}
}
$session = CRM_Core_Session::singleton();
- if (!in_array($context, [
- 'home',
- 'dashlet',
- 'dashletFullscreen',
- ])
- ) {
+ if (!in_array($context, ['home', 'dashlet', 'dashletFullscreen'])) {
$url = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$cid}&selectedChild=activity");
}
else {
// Mark previous activity as deleted. If it was a non-case activity
// then just change the subject.
- if (in_array($params['mode'], [
- 'move',
- 'file',
- ])) {
+ if (in_array($params['mode'], ['move', 'file'])) {
$caseActivity = new CRM_Case_DAO_CaseActivity();
$caseActivity->case_id = $params['caseID'];
$caseActivity->activity_id = $otherActivity->id;
'Print PDF Letter'
);
- if (in_array($activityTypeId, [
- $emailTypeValue,
- $letterTypeValue,
- ])) {
+ if (in_array($activityTypeId, [$emailTypeValue, $letterTypeValue])) {
return;
}
}
$select = $from = [];
foreach ($returnProperties as $property => $ignore) {
- $value = (in_array($property, [
- 'city',
- 'street_address',
- ])) ? 'address' : $property;
+ $value = (in_array($property, ['city', 'street_address'])) ? 'address' : $property;
switch ($property) {
case 'sort_name':
case 'contact_type':
//operation for state machine.
$this->_operation = CRM_Utils_Request::retrieve('op', 'String', $this, FALSE, 'reserve');
//validate operation.
- if (!in_array($this->_operation, [
- 'reserve',
- 'release',
- 'interview',
- ])
- ) {
+ if (!in_array($this->_operation, ['reserve', 'release', 'interview'])) {
$this->_operation = 'reserve';
$this->set('op', $this->_operation);
}
$this->_reserveToInterview = $this->get('reserveToInterview');
if ($this->_reserveToInterview || $this->_votingTab) {
//user came from voting tab / reserve form.
- foreach ([
- 'surveyId',
- 'contactIds',
- 'interviewerId',
- ] as $fld) {
+ foreach (['surveyId', 'contactIds', 'interviewerId'] as $fld) {
$this->{"_$fld"} = $this->get($fld);
}
//get the target voter ids.
}
elseif ($buttonName == '_qf_Interview_next_interviewToRelease') {
//get ready to jump to release form.
- foreach ([
- 'surveyId',
- 'contactIds',
- 'interviewerId',
- ] as $fld) {
+ foreach (['surveyId', 'contactIds', 'interviewerId'] as $fld) {
$this->controller->set($fld, $this->{"_$fld"});
}
$this->controller->set('interviewToRelease', TRUE);
$this->_interviewToRelease = $this->get('interviewToRelease');
if ($this->_interviewToRelease) {
//user came from interview form.
- foreach ([
- 'surveyId',
- 'contactIds',
- 'interviewerId',
- ] as $fld) {
+ foreach (['surveyId', 'contactIds', 'interviewerId'] as $fld) {
$this->{"_$fld"} = $this->get($fld);
}
}
//format multi-select group and contact types.
- foreach ([
- 'group',
- 'contact_type',
- ] as $param) {
+ foreach (['group', 'contact_type'] as $param) {
$paramValue = $params[$param] ?? NULL;
if ($paramValue) {
unset($params[$param]);
//CRM-4570
if ($printReport) {
- if (!in_array($label, [
- 'Activity Type',
- 'Status',
- ])
- ) {
+ if (!in_array($label, ['Activity Type', 'Status'])) {
$caseActivities[$activityindex][$fieldindex] = [];
$caseActivities[$activityindex][$fieldindex]['name'] = $name;
$caseActivities[$activityindex][$fieldindex]['label'] = $label;
//has permissions.
if (!empty($hasPermissions)) {
//need to check activity object specific.
- if (in_array($operation, [
- 'view',
- 'edit',
- ])
- ) {
+ if (in_array($operation, ['view', 'edit'])) {
// Check for super permission.
if (in_array('access all cases and activities', $hasPermissions[$operation])) {
$allowOperations[$operation] = $allow = TRUE;
elseif ($context == 'dashboard') {
$url = CRM_Utils_System::url('civicrm/case', 'reset=1');
}
- elseif (in_array($context, [
- 'dashlet',
- 'dashletFullscreen',
- ])) {
+ elseif (in_array($context, ['dashlet', 'dashletFullscreen'])) {
$url = CRM_Utils_System::url('civicrm/dashboard', 'reset=1');
}
$session = CRM_Core_Session::singleton();
elseif ($context == 'dashboard') {
$url = CRM_Utils_System::url('civicrm/case', 'reset=1');
}
- elseif (in_array($context, [
- 'dashlet',
- 'dashletFullscreen',
- ])) {
+ elseif (in_array($context, ['dashlet', 'dashletFullscreen'])) {
$url = CRM_Utils_System::url('civicrm/dashboard', 'reset=1');
}
$session = CRM_Core_Session::singleton();
$fields = CRM_Contact_DAO_Contact::import();
// get the fields thar are meant for contact types
- if (in_array($contactType, [
- 'Individual',
- 'Household',
- 'Organization',
- 'All',
- ])) {
+ if (in_array($contactType, ['Individual', 'Household', 'Organization', 'All'])) {
$fields = array_merge($fields, CRM_Core_OptionValue::getFields('', $contactType));
}
$fields = CRM_Contact_DAO_Contact::export();
// The fields are meant for contact types.
- if (in_array($contactType, [
- 'Individual',
- 'Household',
- 'Organization',
- 'All',
- ])) {
+ if (in_array($contactType, ['Individual', 'Household', 'Organization', 'All'])) {
$fields = array_merge($fields, CRM_Core_OptionValue::getFields('', $contactType));
}
// add current employer for individuals
continue;
}
// build directly accessible action menu.
- if (in_array($values['ref'], [
- 'view-contact',
- 'edit-contact',
- ])) {
+ if (in_array($values['ref'], ['view-contact', 'edit-contact'])) {
$contextMenu['primaryActions'][$key] = [
'title' => $values['title'],
'ref' => $values['ref'],
) {
$hasAllPermissions = TRUE;
}
- elseif (in_array($menuOptions['ref'], [
- 'new-email',
- ])) {
+ elseif (in_array($menuOptions['ref'], ['new-email'])) {
// grant permissions for these tasks.
$hasAllPermissions = TRUE;
}
}
// check permission on acl basis.
- if (in_array($task, [
- 'view',
- 'edit',
- ])) {
+ if (in_array($task, ['view', 'edit'])) {
$aclPermission = CRM_Core_Permission::VIEW;
if ($task == 'edit') {
$aclPermission = CRM_Core_Permission::EDIT;
if (!empty($blockValues['is_primary'])) {
$hasPrimary[] = $instance;
if (!$primaryID &&
- in_array($name, [
- 'email',
- 'openid',
- ]) && !empty($blockValues[$name])
+ in_array($name, ['email', 'openid']) &&
+ !empty($blockValues[$name])
) {
$primaryID = $blockValues[$name];
}
'street_name',
'street_unit',
] as $fld) {
- if (in_array($fld, [
- 'street_name',
- 'street_unit',
- ])) {
+ if (in_array($fld, ['street_name', 'street_unit'])) {
$streetAddress .= ' ';
}
// CRM-17619 - if the street number suffix begins with a number, add a space
'street_name',
'street_unit',
] as $fld) {
- if (in_array($fld, [
- 'street_name',
- 'street_unit',
- ])) {
+ if (in_array($fld, ['street_name', 'street_unit'])) {
$streetAddress .= ' ';
}
// CRM-17619 - if the street number suffix begins with a number, add a space
$params = $this->controller->exportValues($this->_name);
$locType = CRM_Core_BAO_LocationType::getDefault();
- foreach ([
- 'phone',
- 'email',
- 'address',
- ] as $locFld) {
+ foreach (['phone', 'email', 'address'] as $locFld) {
if (!empty($this->_defaults[$locFld]) && $this->_defaults[$locFld][1]['location_type_id']) {
$params[$locFld][1]['is_primary'] = $this->_defaults[$locFld][1]['is_primary'];
$params[$locFld][1]['location_type_id'] = $this->_defaults[$locFld][1]['location_type_id'];
$this->set('searchRows', '');
$context = $this->get('context');
- if (in_array($context, [
- 'smog',
- 'amtg',
- ])) {
+ if (in_array($context, ['smog', 'amtg'])) {
$urlParams = 'reset=1&force=1&context=smog&gid=';
$urlParams .= ($context == 'smog') ? $this->get('gid') : $this->get('amtgID');
$session->replaceUserContext(CRM_Utils_System::url('civicrm/group/search', $urlParams));
self::LABEL_CONTACTS => self::$_tasks[self::LABEL_CONTACTS]['title'],
];
- foreach ([
- self::MAP_CONTACTS,
- self::CREATE_MAILING,
- self::TASK_SMS,
- ] as $task) {
+ foreach ([self::MAP_CONTACTS, self::CREATE_MAILING, self::TASK_SMS] as $task) {
if (isset(self::$_tasks[$task]) &&
!empty(self::$_tasks[$task]['title'])
) {
elseif (!empty($this->_values['is_for_organization'])) {
// no on behalf of an organization, CRM-5519
// so reset loc blocks from main params.
- foreach ([
- 'phone',
- 'email',
- 'address',
- ] as $blk) {
+ foreach (['phone', 'email', 'address'] as $blk) {
if (isset($this->_params[$blk])) {
unset($this->_params[$blk]);
}
$val = $defaultVal;
}
- if (in_array($field, [
- 'min_amount',
- 'max_amount',
- ])) {
+ if (in_array($field, ['min_amount', 'max_amount'])) {
$val = CRM_Utils_Rule::cleanMoney($val);
}
$this->_formValues['is_template'] = 0;
}
- foreach ([
- 'contribution_amount_low',
- 'contribution_amount_high',
- ] as $f) {
+ foreach (['contribution_amount_low', 'contribution_amount_high'] as $f) {
if (isset($this->_formValues[$f])) {
// @todo - stop changing formValues - respect submitted form values, change a working array.
$this->_formValues[$f] = CRM_Utils_Rule::cleanMoney($this->_formValues[$f]);
//get contribution dates.
$dates = CRM_Contribute_BAO_Contribution::getContributionDates();
- foreach ([
- 'now',
- 'yearDate',
- 'monthDate',
- ] as $date) {
+ foreach (['now', 'yearDate', 'monthDate'] as $date) {
$$date = $dates[$date];
}
// fiscal years end date
];
// overwriting $streetUnitFormats for 'en_CA' and 'fr_CA' locale
- if (in_array($locale, [
- 'en_CA',
- 'fr_CA',
- ])) {
+ if (in_array($locale, ['en_CA', 'fr_CA'])) {
$streetUnitFormats = ['APT', 'APP', 'SUITE', 'BUREAU', 'UNIT'];
}
//@todo per CRM-14459 this regex picks up words with the string in them - e.g APT picks up
$block = [];
foreach (self::properties() as $id => $value) {
if ($value['active']) {
- if (in_array($id, [
- self::ADD,
- self::CREATE_NEW,
- ])) {
+ if (in_array($id, [self::ADD, self::CREATE_NEW])) {
$hasAccess = TRUE;
if (!CRM_Core_Permission::check('add contacts') &&
!CRM_Core_Permission::check('edit groups')
$this->postProcessHook();
// Respond with JSON if in AJAX context (also support legacy value '6')
- if ($allowAjax && !empty($_REQUEST['snippet']) && in_array($_REQUEST['snippet'], [
- CRM_Core_Smarty::PRINT_JSON,
- 6,
- ])) {
+ if ($allowAjax && !empty($_REQUEST['snippet']) && in_array($_REQUEST['snippet'], [CRM_Core_Smarty::PRINT_JSON, 6])) {
$this->ajaxResponse['buttonName'] = str_replace('_qf_' . $this->getAttribute('id') . '_', '', $this->controller->getButtonName());
$this->ajaxResponse['action'] = $this->_action;
if (isset($this->_id) || isset($this->id)) {
elseif ($mode == '') {
//the fields email greeting and postal greeting are meant only for Individual and Household
//the field addressee is meant for all contact types, CRM-4575
- if (in_array($contactType, [
- 'Individual',
- 'Household',
- 'Organization',
- 'All',
- ])) {
+ if (in_array($contactType, ['Individual', 'Household', 'Organization', 'All'])) {
$nameTitle = [
'addressee' => [
'name' => 'addressee',
);
// lets output only required fields.
foreach ($addressOptions as $element => $isSet) {
- if ($isSet && (!in_array($element, [
- 'im',
- 'openid',
- ]))) {
- if (in_array($element, [
- 'country',
- 'state_province',
- 'county',
- ])) {
+ if ($isSet && (!in_array($element, ['im', 'openid']))) {
+ if (in_array($element, ['country', 'state_province', 'county'])) {
$element .= '_id';
}
elseif ($element == 'address_name') {
$fld = "address[1][{$element}]";
$value = $location['address'][1][$element] ?? NULL;
$value = $value ?: "";
- $result[str_replace([
- '][',
- '[',
- "]",
- ], ['_', '_', ''], $fld)] = $value;
+ $result[str_replace(['][', '[', ']'], ['_', '_', ''], $fld)] = $value;
}
}
- foreach ([
- 'email',
- 'phone_type_id',
- 'phone',
- ] as $element) {
+ foreach (['email', 'phone_type_id', 'phone'] as $element) {
$block = ($element == 'phone_type_id') ? 'phone' : $element;
for ($i = 1; $i < 3; $i++) {
$fld = "{$block}[{$i}][{$element}]";
$value = $location[$block][$i][$element] ?? NULL;
$value = $value ?: "";
- $result[str_replace([
- '][',
- '[',
- "]",
- ], ['_', '_', ''], $fld)] = $value;
+ $result[str_replace(['][', '[', ']'], ['_', '_', ''], $fld)] = $value;
}
}
$baseContactParams['return.' . $field] = 1;
}
- foreach ([
- 'target',
- 'assignee',
- ] as $role) {
+ foreach (['target', 'assignee'] as $role) {
$contact = [];
if (!empty($activity[$role . '_contact_id'])) {
$contact_id = array_shift($activity[$role . '_contact_id']);
}
// handle {birth,deceased}_date
- foreach ([
- 'birth_date',
- 'deceased_date',
- ] as $date) {
+ foreach (['birth_date', 'deceased_date'] as $date) {
if (!empty($fields[$date])) {
$flat[$date] = $fields[$date];
if (is_array($flat[$date])) {
}
$noteValue = NULL;
$hasNoteField = FALSE;
- foreach ([
- 'note',
- 'participant_note',
- ] as $noteFld) {
+ foreach (['note', 'participant_note'] as $noteFld) {
if (array_key_exists($noteFld, $params)) {
$noteValue = $params[$noteFld];
$hasNoteField = TRUE;
case 'event_type_id':
case 'event_title':
$qillName = $name;
- if (in_array($name, [
- 'event_id',
- 'event_title',
- 'event_is_public',
- ])) {
+ if (in_array($name, ['event_id', 'event_title', 'event_is_public'])) {
$name = str_replace('event_', '', $name);
}
$dataType = !empty($fields[$qillName]['type']) ? CRM_Utils_Type::typeToString($fields[$qillName]['type']) : 'String';
$taxAmount += $v['tax_amount'];
if (is_array($v)) {
$this->cleanMoneyFields($v);
- foreach ([
- 'first_name',
- 'last_name',
- ] as $name) {
+ foreach (['first_name', 'last_name'] as $name) {
if (isset($v['billing_' . $name]) &&
!isset($v[$name])
) {
}
//set values for ipn code.
- foreach ([
- 'fee_amount',
- 'check_number',
- 'payment_instrument_id',
- ] as $field) {
+ foreach (['fee_amount', 'check_number', 'payment_instrument_id'] as $field) {
if (!$input[$field] = CRM_Utils_Array::value($field, $params)) {
$input[$field] = $contribution->$field;
}
return CRM_Core_BAO_CustomField::displayValue($fieldValue, $cfID);
}
- elseif (in_array($field, [
- 'email_greeting',
- 'postal_greeting',
- 'addressee',
- ])) {
+ elseif (in_array($field, ['email_greeting', 'postal_greeting', 'addressee'])) {
//special case for greeting replacement
$fldValue = "{$field}_display";
return $iterationDAO->$fldValue;
$fieldValue = $imProviders[$relationValue] ?? NULL;
}
// CRM-13995
- elseif (is_object($relDAO) && in_array($relationField, [
- 'email_greeting',
- 'postal_greeting',
- 'addressee',
- ])) {
+ elseif (is_object($relDAO) &&
+ in_array($relationField, ['email_greeting', 'postal_greeting', 'addressee'])
+ ) {
//special case for greeting replacement
$fldValue = "{$relationField}_display";
$fieldValue = $relDAO->$fldValue;
*/
public static function getProcessorForEntity($entityID, $component = 'contribute', $type = 'id') {
$result = NULL;
- if (!in_array($component, [
- 'membership',
- 'contribute',
- 'recur',
- ])
- ) {
+ if (!in_array($component, ['membership', 'contribute', 'recur'])) {
return $result;
}
if ($this->_action & CRM_Core_Action::UPDATE) {
$params['id'] = $this->_id;
}
- foreach ([
- 'is_active',
- 'is_deductible',
- 'is_tax',
- 'is_default',
- ] as $field) {
+ foreach (['is_active', 'is_deductible', 'is_tax', 'is_default'] as $field) {
$params[$field] = $params[$field] ?? FALSE;
}
$financialAccount = CRM_Financial_BAO_FinancialAccount::writeRecord($params);
if ($this->_id) {
$params['id'] = $this->_id;
}
- foreach ([
- 'is_active',
- 'is_reserved',
- 'is_deductible',
- ] as $field) {
+ foreach (['is_active', 'is_reserved', 'is_deductible'] as $field) {
$params[$field] = $params[$field] ?? FALSE;
}
$financialType = civicrm_api3('FinancialType', 'create', $params);
$pcomponent = CRM_Utils_Request::retrieve('pcomponent', 'String', $this, TRUE);
- if (in_array($pcomponent, [
- 'contribute',
- 'event',
- ])) {
+ if (in_array($pcomponent, ['contribute', 'event'])) {
$values = [];
$params = ['id' => $this->_entityId];
CRM_Core_DAO::commonRetrieve('CRM_Contribute_DAO_ContributionPage',
$this->preparedTemplates = [];
- foreach ([
- 'html',
- 'text',
- 'subject',
- ] as $key) {
+ foreach (['html', 'text', 'subject'] as $key) {
if (!isset($templates[$key])) {
continue;
}
$InvalidTokens = ['action.forward' => ts("This token can only be used in send mailing context (body, header, footer)..")];
}
$errors = [];
- foreach ([
- 'text',
- 'html',
- ] as $type) {
+ foreach (['text', 'html'] as $type) {
$dataErrors = [];
foreach ($InvalidTokens as $token => $desc) {
if ($params['body_' . $type]) {
public function maildir($name) {
$config = CRM_Core_Config::singleton();
$dir = $config->customFileUploadDir . DIRECTORY_SEPARATOR . $name;
- foreach ([
- 'cur',
- 'new',
- 'tmp',
- ] as $sub) {
+ foreach (['cur', 'new', 'tmp'] as $sub) {
if (!file_exists($dir . DIRECTORY_SEPARATOR . $sub)) {
if ($this->_debug) {
print "creating $dir/$sub\n";
// set property text attachment as file CRM-5408
$parser->options->parseTextAttachmentsAsFiles = TRUE;
- foreach ([
- 'cur',
- 'new',
- ] as $subdir) {
+ foreach (['cur', 'new'] as $subdir) {
$dir = $this->_dir . DIRECTORY_SEPARATOR . $subdir;
foreach (scandir($dir) as $file) {
if ($file == '.' or $file == '..') {
$actionMask = CRM_Core_Action::PREVIEW;
}
}
- if (in_array($row['status'], [
- 'Scheduled',
- 'Running',
- 'Paused',
- ])) {
- if ($allAccess ||
- ($showApprovalLinks && $showCreateLinks && $showScheduleLinks)
- ) {
+ if (in_array($row['status'], ['Scheduled', 'Running', 'Paused'])) {
+ if ($allAccess || ($showApprovalLinks && $showCreateLinks && $showScheduleLinks)) {
$actionMask |= CRM_Core_Action::DISABLE;
if ($row['status'] === "Paused") {
$membershipTypeDetails = self::getMembershipTypeDetails($membershipTypeId);
// Convert all dates to 'Y-m-d' format.
- foreach ([
- 'joinDate',
- 'startDate',
- 'endDate',
- ] as $dateParam) {
+ foreach (['joinDate', 'startDate', 'endDate'] as $dateParam) {
if (!empty($$dateParam)) {
$$dateParam = CRM_Utils_Date::processDate($$dateParam, NULL, FALSE, 'Y-m-d');
}
//get the membership status and type values.
$statusANDType = CRM_Member_BAO_Membership::getStatusANDTypeValues($dao->id);
- foreach ([
- 'status',
- 'membership_type',
- ] as $fld) {
+ foreach (['status', 'membership_type'] as $fld) {
$membership[$dao->id][$fld] = $statusANDType[$dao->id][$fld] ?? NULL;
}
if (!empty($statusANDType[$dao->id]['is_current_member'])) {
$pcpBlock->find(TRUE);
if (!empty($pcpBlock->id) && CRM_PCP_BAO_PCP::getPcpBlockInUse($pcpBlock->id)) {
- foreach ([
- 'target_entity_type',
- 'target_entity_id',
- ] as $element_name) {
+ foreach (['target_entity_type', 'target_entity_id'] as $element_name) {
$element = $this->getElement($element_name);
$element->freeze();
}
}
}
- elseif (!empty($this->_multiRecordFields)
- && (!$this->_multiRecord || !in_array($this->_multiRecord, [
- CRM_Core_Action::DELETE,
- CRM_Core_Action::UPDATE,
- ]))
+ elseif (!empty($this->_multiRecordFields) &&
+ (!$this->_multiRecord || !in_array($this->_multiRecord, [CRM_Core_Action::DELETE, CRM_Core_Action::UPDATE]))
) {
CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js', 1, 'html-header');
//multi-record listing page
$value[$item] = 1;
}
}
- elseif (in_array($key, [
- 'birth_date',
- 'deceased_date',
- ])) {
+ elseif (in_array($key, ['birth_date', 'deceased_date'])) {
list($value) = CRM_Utils_Date::setDateDefaults($value);
}
$locationTypeName = $locationTypes[$lType];
}
- if (in_array($fieldName, [
- 'phone',
- 'im',
- 'email',
- ])) {
+ if (in_array($fieldName, ['phone', 'im', 'email'])) {
if ($type) {
$name = "`$locationTypeName-$fieldName-$type`";
}
continue;
}
$locationTypeName = str_replace(' ', '_', $locationTypeName);
- if (in_array($fieldName, [
- 'phone',
- 'im',
- 'email',
- ])) {
+ if (in_array($fieldName, ['phone', 'im', 'email'])) {
if ($type) {
$names[] = "{$locationTypeName}-{$fieldName}-{$type}";
}
$dname = $name . '_display';
$row[] = $result->$dname;
}
- elseif (in_array($name, [
- 'birth_date',
- 'deceased_date',
- ])) {
+ elseif (in_array($name, ['birth_date', 'deceased_date'])) {
$row[] = CRM_Utils_Date::customFormat($result->$name);
}
elseif (isset($result->$name)) {
protected function activate() {
$this->active = TRUE;
$this->backup = [];
- foreach ([
- 'display_errors',
- 'html_errors',
- 'xmlrpc_errors',
- ] as $key) {
+ foreach (['display_errors', 'html_errors', 'xmlrpc_errors'] as $key) {
$this->backup[$key] = ini_get($key);
ini_set($key, 0);
}
*/
protected function deactivate() {
restore_error_handler();
- foreach ([
- 'display_errors',
- 'html_errors',
- 'xmlrpc_errors',
- ] as $key) {
+ foreach (['display_errors', 'html_errors', 'xmlrpc_errors'] as $key) {
ini_set($key, $this->backup[$key]);
}
$this->active = FALSE;
protected function isFieldFiltered($prop) {
if (!empty($prop['filters']) && $this->_customGroupFilters) {
foreach ($prop['filters'] as $fieldAlias => $val) {
- foreach ([
- 'value',
- 'min',
- 'max',
- 'relative',
- 'from',
- 'to',
- ] as $attach) {
+ foreach (['value', 'min', 'max', 'relative', 'from', 'to'] as $attach) {
if (isset($this->_params[$fieldAlias . '_' . $attach]) &&
(!empty($this->_params[$fieldAlias . '_' . $attach])
|| ($attach != 'relative' &&
if ($responseField->option_group_id) {
//show value for print and pdf.
$value = $responseField->label;
- if (in_array($this->_outputMode, [
- 'print',
- 'pdf',
- ])) {
+ if (in_array($this->_outputMode, ['print', 'pdf'])) {
$value = $responseField->value;
}
$fieldValueMap[$responseField->option_group_id][$responseField->value] = $value;
$errors = $self->customDataFormRule($fields, $ignoreFields);
if (empty($fields['fields']['total_amount'])) {
- foreach ([
- 'total_count_value',
- 'total_sum_value',
- 'total_avg_value',
- ] as $val) {
+ foreach (['total_count_value', 'total_sum_value', 'total_avg_value'] as $val) {
if (!empty($fields[$val])) {
$errors[$val] = ts("Please select the Amount Statistics");
}
$op = $fields['total_range_op'] ?? NULL;
$val = $fields['total_range_value'] ?? NULL;
- if (!in_array($op, [
- 'eq',
- 'lte',
- ])
- ) {
+ if (!in_array($op, ['eq', 'lte'])) {
$errors['total_range_op'] = ts("Please select 'Is equal to' OR 'Is Less than or equal to' operator");
}
if (!empty($field['required']) ||
!empty($this->_params['fields'][$fieldName])
) {
- if (in_array($fieldName, [
- 'unsubscribe_id',
- 'optout_id',
- 'forward_id',
- 'reply_id',
- ])) {
+ if (in_array($fieldName, ['unsubscribe_id', 'optout_id', 'forward_id', 'reply_id'])) {
$select[] = "IF({$field['dbAlias']} IS NULL, 'No', 'Yes') as {$tableName}_{$fieldName}";
$this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = $field['type'] ?? NULL;
$this->_columnHeaders["{$tableName}_{$fieldName}"]['no_display'] = $field['no_display'] ?? NULL;
$this->assign('statistics', $this->statistics($rows));
if (!empty($this->_params['charts'])) {
- foreach ([
- 'receive_date',
- $this->_interval,
- 'value',
- ] as $ignore) {
+ foreach (['receive_date', $this->_interval, 'value'] as $ignore) {
unset($graphRows[$ignore][$count - 1]);
}
$allStatus = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
$pendingStatus = array_search('Pending', $allStatus);
- foreach ([
- 'Pending',
- 'In Progress',
- 'Overdue',
- ] as $statusKey) {
+ foreach (['Pending', 'In Progress', 'Overdue'] as $statusKey) {
if ($key = CRM_Utils_Array::key($statusKey, $allStatus)) {
$unpaidStatus[] = $key;
}
*/
public static function processChart(&$defaults) {
$chartType = $_GET["charts"] ?? NULL;
- if (in_array($chartType, [
- 'barChart',
- 'pieChart',
- ])) {
+ if (in_array($chartType, ['barChart', 'pieChart'])) {
$defaults["charts"] = $chartType;
}
}
$groups = [];
- foreach ([
- 'name',
- 'group_id',
- 'is_sms',
- 'sms_provider_id',
- ] as $n) {
+ foreach (['name', 'group_id', 'is_sms', 'sms_provider_id'] as $n) {
if (!empty($values[$n])) {
$params[$n] = $values[$n];
if ($n == 'sms_provider_id') {
$mailingTableName = CRM_Mailing_BAO_Mailing::getTableName();
// delete previous includes/excludes, if mailing already existed
- foreach ([
- 'groups',
- 'mailings',
- ] as $entity) {
+ foreach (['groups', 'mailings'] as $entity) {
$mg = new CRM_Mailing_DAO_MailingGroup();
$mg->mailing_id = $ids['mailing_id'];
$mg->entity_table = ($entity == 'groups') ? $groupTableName : $mailingTableName;
* List of errors to be posted back to the form.
*/
public static function formRuleSubType($fieldType, $groupType, &$errors) {
- if (in_array($fieldType, [
- 'Participant',
- 'Contribution',
- 'Membership',
- 'Activity',
- ])) {
+ if (in_array($fieldType, ['Participant', 'Contribution', 'Membership', 'Activity'])) {
$individualSubTypes = CRM_Contact_BAO_ContactType::subTypes('Individual');
foreach ($groupType as $value) {
if (!in_array($value, $individualSubTypes) &&
$errors['field_name'] = ts('Please select a field name');
}
- if ($in_selector && in_array($entityName, [
- 'Contribution',
- 'Participant',
- 'Membership',
- 'Activity',
- ])
+ if ($in_selector && in_array($entityName, ['Contribution', 'Participant', 'Membership', 'Activity'])
) {
$errors['in_selector'] = ts("'Results Column' cannot be checked for %1 fields.", [1 => $entityName]);
}
protected function setMessageIfCountryNotAboveState($fieldName, $locationTypeID, $weight, $ufGroupID) {
$message = ts('For best results, the Country field should precede the State-Province field in your Profile form. You can use the up and down arrows on field listing page for this profile to change the order of these fields or manually edit weight for Country/State-Province Field.');
- if (in_array($fieldName, [
- 'country',
- 'state_province',
- ]) && count(CRM_Core_Config::singleton()->countryLimit) > 1
+ if (in_array($fieldName, ['country', 'state_province']) &&
+ count(CRM_Core_Config::singleton()->countryLimit) > 1
) {
// get state or country field weight if exists
$ufFieldDAO = new CRM_Core_DAO_UFField();
$chartData['yname'] = $rows['yname'] ?? NULL;
// carry some chart params if pass.
- foreach ([
- 'xSize',
- 'ySize',
- 'divName',
- ] as $f) {
+ foreach (['xSize', 'ySize', 'divName'] as $f) {
if (!empty($rows[$f])) {
$chartData[$f] = $rows[$f];
}
}
// carry some chart params if pass.
- foreach ([
- 'xSize',
- 'ySize',
- 'divName',
- ] as $f) {
+ foreach (['xSize', 'ySize', 'divName'] as $f) {
if (!empty($rows[$f])) {
$chartData[$f] = $rows[$f];
}
}
// special case for greeting replacement
- foreach ([
- 'email_greeting',
- 'postal_greeting',
- 'addressee',
- ] as $val) {
+ foreach (['email_greeting', 'postal_greeting', 'addressee'] as $val) {
if (!empty($contactDetails[$contactID][$val])) {
$contactDetails[$contactID][$val] = $contactDetails[$contactID]["{$val}_display"];
}
public static function flattenTokens(&$tokens) {
$flattenTokens = [];
- foreach ([
- 'html',
- 'text',
- 'subject',
- ] as $prop) {
+ foreach (['html', 'text', 'subject'] as $prop) {
if (!isset($tokens[$prop])) {
continue;
}
function _civicrm_activity_get_handleSourceContactNameOrderBy(&$params, &$options, $sql) {
$sourceContactID = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_ActivityContact', 'record_type_id', 'Activity Source');
if (!empty($options['sort'])
- && in_array($options['sort'], [
- 'source_contact_name',
- 'source_contact_name desc',
- 'source_contact_name asc',
- ])) {
+ && in_array($options['sort'], ['source_contact_name', 'source_contact_name desc', 'source_contact_name asc'])) {
$order = substr($options['sort'], -4) === 'desc' ? 'desc' : 'asc';
$sql->join(
'source_contact',
SimpleFilter::byValue($e, 'text', function ($value, $t, $e) use ($test) {
$test->assertInstanceOf('Civi\FlexMailer\FlexMailerTask', $t);
$test->assertInstanceOf('Civi\FlexMailer\Event\ComposeBatchEvent', $e);
- $test->assertTrue(in_array($value, [
- 'eat more cheese',
- 'eat more ice cream',
- ]));
+ $test->assertTrue(in_array($value, ['eat more cheese', 'eat more ice cream']));
return preg_replace('/more/', 'thoughtfully considered quantities of', $value);
});
';
foreach ($this->_columns as $fieldName) {
- if (in_array($fieldName, [
- 'contact_id',
- 'participant_id',
- 'display_name',
- ])) {
+ if (in_array($fieldName, ['contact_id', 'participant_id', 'display_name'])) {
continue;
}
$sql .= "{$fieldName} int default 0,\n";
contact_a.display_name as display_name";
foreach ($this->_columns as $dontCare => $fieldName) {
- if (in_array($fieldName, [
- 'contact_id',
- 'display_name',
- ])) {
+ if (in_array($fieldName, ['contact_id', 'display_name'])) {
continue;
}
$selectClause .= ",\ntempTable.{$fieldName} as {$fieldName}";
$entity[$fieldName] = strtolower($entity[$fieldName]);
}
// typecast with array to satisfy changes made in CRM-13160
- if ($entityName == 'MembershipType' && in_array($fieldName, [
- 'relationship_type_id',
- 'relationship_direction',
- ])) {
+ if ($entityName == 'MembershipType' && in_array($fieldName, ['relationship_type_id', 'relationship_direction'])) {
$entity[$fieldName] = (array) $entity[$fieldName];
}
}