'sequential' => 1,
'return' => ["enable_components"],
]);
- $enabled = array();
+ $enabled = [];
foreach ($result['values'][0]['enable_components'] as $component) {
$enabled[$component] = 1;
}
}
$sj = new CRM_Core_JobManager();
- $rows = $temp = array();
+ $rows = $temp = [];
foreach ($sj->jobs as $job) {
$action = array_sum(array_keys($this->links()));
}
$dao->find();
- $rows = array();
+ $rows = [];
while ($dao->fetch()) {
unset($row);
CRM_Core_DAO::storeValues($dao, $row);
*/
public function browse($action = NULL) {
// get all custom groups sorted by weight
- $paymentProcessor = array();
+ $paymentProcessor = [];
$dao = new CRM_Financial_DAO_PaymentProcessor();
$dao->is_test = 0;
$dao->domain_id = CRM_Core_Config::domainID();
$dao->find();
while ($dao->fetch()) {
- $paymentProcessor[$dao->id] = array();
+ $paymentProcessor[$dao->id] = [];
CRM_Core_DAO::storeValues($dao, $paymentProcessor[$dao->id]);
$paymentProcessor[$dao->id]['payment_processor_type'] = CRM_Core_PseudoConstant::getLabel(
'CRM_Financial_DAO_PaymentProcessor', 'payment_processor_type_id', $dao->payment_processor_type_id
*/
public function preProcess() {
$this->_done = FALSE;
- $this->_defaults = array();
+ $this->_defaults = [];
//set the button name.
$this->_printButtonName = $this->getButtonName('next', 'print');
$clientID,
$caseID
) {
- $case = $this->_redactionRegexRules = array();
+ $case = $this->_redactionRegexRules = [];
if (empty($this->_redactionStringRules)) {
- $this->_redactionStringRules = array();
+ $this->_redactionStringRules = [];
}
if ($this->_isRedact == 1) {
foreach ($xml->ActivitySets as $activitySetsXML) {
foreach ($activitySetsXML->ActivitySet as $activitySetXML) {
if ((string ) $activitySetXML->name == $activitySetName) {
- $activityTypes = array();
+ $activityTypes = [];
$allActivityTypes = CRM_Case_PseudoConstant::caseActivityType(TRUE, TRUE);
foreach ($activitySetXML->ActivityTypes as $activityTypesXML) {
foreach ($activityTypesXML as $activityTypeXML) {
* @return mixed
*/
public function &getActivityInfo($clientID, $activityID, $anyActivity = FALSE, $redact = 0) {
- static $activityInfos = array();
+ static $activityInfos = [];
if ($redact) {
$this->_isRedact = 1;
$this->getRedactionRules();
}
if (!array_key_exists($index, $activityInfos)) {
- $activityInfos[$index] = array();
+ $activityInfos[$index] = [];
$selectCaseActivity = "";
$joinCaseActivity = "";
*/
public function &getActivity($clientID, $activityDAO, &$activityTypeInfo) {
if (empty($this->_redactionStringRules)) {
- $this->_redactionStringRules = array();
+ $this->_redactionStringRules = [];
}
- $activity = array();
- $activity['fields'] = array();
+ $activity = [];
+ $activity['fields'] = [];
if ($clientID) {
$clientID = CRM_Utils_Type::escape($clientID, 'Integer');
if (!in_array($activityTypeInfo['name'], array(
}
if ($processTarget) {
- $targetRedacted = array();
+ $targetRedacted = [];
foreach ($targetNames as $targetID => $target) {
// add Recipient SortName as well as Display to the strings to be redacted across the case session
// suffixed with a randomly generated 4-digit number
$params = array(1 => array($activityDAO->id, 'Integer'));
- $customGroups = array();
+ $customGroups = [];
foreach ($sql as $tableName => $sqlClause) {
$dao = CRM_Core_DAO::executeQuery($sqlClause, $params);
if ($dao->fetch()) {
- $customGroup = array();
+ $customGroup = [];
foreach ($typeValues[$tableName] as $columnName => $typeValue) {
if (CRM_Utils_Array::value('type', $typeValue) == 'Date') {
* @return mixed
*/
public function getActivityTypeCustomSQL($activityTypeID, $dateFormat = NULL, $onlyActive = TRUE) {
- static $cache = array();
+ static $cache = [];
if (is_null($activityTypeID)) {
$activityTypeID = 0;
);
$dao = CRM_Core_DAO::executeQuery($query, $params);
- $result = $options = $sql = $groupTitle = array();
+ $result = $options = $sql = $groupTitle = [];
while ($dao->fetch()) {
if (!array_key_exists($dao->tableName, $result)) {
- $result[$dao->tableName] = array();
- $sql[$dao->tableName] = array();
+ $result[$dao->tableName] = [];
+ $sql[$dao->tableName] = [];
}
$result[$dao->tableName][$dao->columnName] = array(
'label' => $dao->label,
'fieldID' => $dao->fieldID,
);
- $options[$dao->fieldID] = array();
+ $options[$dao->fieldID] = [];
$options[$dao->fieldID]['attributes'] = array(
'label' => $dao->label,
'data_type' => $dao->dataType,
*
* @return mixed
*/
- private function redact($string, $printReport = FALSE, $replaceString = array()) {
+ private function redact($string, $printReport = FALSE, $replaceString = []) {
if ($printReport) {
return CRM_Utils_String::redaction($string, $replaceString);
}
$template->assign_by_ref('activitySet', $activitySet);
//now collect all the information about activities
- $activities = array();
+ $activities = [];
$form->getActivities($clientID, $caseID, $activityTypes, $activities);
$template->assign_by_ref('activities', $activities);
$activitySetName = CRM_Utils_Request::retrieve('asn', 'String');
$isRedact = CRM_Utils_Request::retrieve('redact', 'Boolean');
$includeActivities = CRM_Utils_Request::retrieve('all', 'Positive');
- $params = $otherRelationships = $globalGroupInfo = array();
+ $params = $otherRelationships = $globalGroupInfo = [];
$report = new CRM_Case_XMLProcessor_Report($isRedact);
if ($includeActivities) {
$params['include_activities'] = 1;
if ($isRedact) {
$params['is_redact'] = 1;
- $report->_redactionStringRules = array();
+ $report->_redactionStringRules = [];
}
$template = CRM_Core_Smarty::singleton();
$customValues = CRM_Core_BAO_CustomValueTable::getEntityValues($caseID, 'Case');
$extends = array('case');
$groupTree = CRM_Core_BAO_CustomGroup::getGroupDetail(NULL, NULL, $extends);
- $caseCustomFields = array();
+ $caseCustomFields = [];
foreach ($groupTree as $gid => $group_values) {
foreach ($group_values['fields'] as $id => $field_values) {
if (array_key_exists($id, $customValues)) {
$types = explode(CRM_Core_DAO::VALUE_SEPARATOR,
substr($defaults['group_type'], 1, -1)
);
- $defaults['group_type'] = array();
+ $defaults['group_type'] = [];
foreach ($types as $type) {
$defaults['group_type'][$type] = 1;
}
* list of errors to be posted back to the form
*/
public static function formRule($fields, $files, $self) {
- $errors = array();
+ $errors = [];
$invalidTagName = $invalidGroupName = FALSE;
if (!empty($fields['newTagName'])) {
// check if there is any error occurred
$errorStack = CRM_Core_Error::singleton();
$errors = $errorStack->getErrors();
- $errorMessage = array();
+ $errorMessage = [];
if (is_array($errors)) {
foreach ($errors as $key => $value) {
$mapper = $this->controller->exportValue('MapField', 'mapper');
- $mapperKeys = array();
- $mapperLocTypes = array();
- $mapperPhoneTypes = array();
- $mapperRelated = array();
- $mapperRelatedContactType = array();
- $mapperRelatedContactDetails = array();
- $mapperRelatedContactLocType = array();
- $mapperRelatedContactPhoneType = array();
+ $mapperKeys = [];
+ $mapperLocTypes = [];
+ $mapperPhoneTypes = [];
+ $mapperRelated = [];
+ $mapperRelatedContactType = [];
+ $mapperRelatedContactDetails = [];
+ $mapperRelatedContactLocType = [];
+ $mapperRelatedContactPhoneType = [];
foreach ($mapper as $key => $value) {
$mapperKeys[$key] = $mapper[$key][0];
$phoneTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id');
foreach ($mapper as $key => $value) {
- $header = array();
+ $header = [];
list($id, $first, $second) = explode('_', $mapper[$key][0]);
if (($first == 'a' && $second == 'b') || ($first == 'b' && $second == 'a')) {
$relationType = new CRM_Contact_DAO_RelationshipType();
}
if (is_array($groups)) {
- $groupAdditions = array();
+ $groupAdditions = [];
foreach ($groups as $groupId) {
$addCount = CRM_Contact_BAO_GroupContact::addContactsToGroup($contactIds, $groupId);
if (!empty($relatedContactIds)) {
if (is_array($tag)) {
- $tagAdditions = array();
+ $tagAdditions = [];
foreach ($tag as $tagId => $val) {
$addTagCount = CRM_Core_BAO_EntityTag::addContactsToTag($contactIds, $tagId);
if (!empty($relatedContactIds)) {
$errorStack = CRM_Core_Error::singleton();
$errors = $errorStack->getErrors();
- $errorMessage = array();
+ $errorMessage = [];
if (is_array($errors)) {
foreach ($errors as $key => $value) {
protected $_allTags;
protected $_mapper;
- protected $_mapperKeys = array();
+ protected $_mapperKeys = [];
protected $_mapFields;
protected $_parser;
*/
public function runImport(&$form, $timeout = 55) {
$mapper = $this->_mapper;
- $mapperFields = array();
+ $mapperFields = [];
$parserParameters = CRM_Contact_Import_Parser_Contact::getParameterForParser(count($mapper));
$phoneTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id');
$imProviders = CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id');
if ($newGroupName) {
/* Create a new group */
- $newGroupType = $newGroupType ?? array();
+ $newGroupType = $newGroupType ?? [];
$gParams = array(
'title' => $newGroupName,
'description' => $newGroupDesc,
}
if (is_array($this->_groups)) {
- $groupAdditions = array();
+ $groupAdditions = [];
foreach ($this->_groups as $groupId) {
$addCount = CRM_Contact_BAO_GroupContact::addContactsToGroup($contactIds, $groupId);
$totalCount = $addCount[1];
//add Tag to Import
if (is_array($this->_tag)) {
- $tagAdditions = array();
+ $tagAdditions = [];
foreach ($this->_tag as $tagId => $val) {
$addTagCount = CRM_Core_BAO_EntityTag::addEntitiesToTag($contactIds, $tagId, 'civicrm_contact', FALSE);
$totalTagCount = $addTagCount[1];
);
$session = CRM_Core_Session::singleton();
- $recentOther = array();
+ $recentOther = [];
if (($session->get('userID') == $this->getContactId()) ||
CRM_Contact_BAO_Contact_Permission::allow($this->getContactId(), CRM_Core_Permission::EDIT)
$session->pushUserContext($url);
$this->assignFieldMetadataToTemplate('Contact');
- $params = array();
- $defaults = array();
+ $params = [];
+ $defaults = [];
$params['id'] = $params['contact_id'] = $this->_contactId;
$params['noRelationships'] = $params['noNotes'] = $params['noGroups'] = TRUE;
}
// get contact name of shared contact names
- $sharedAddresses = array();
+ $sharedAddresses = [];
$shareAddressContactNames = CRM_Contact_BAO_Contact_Utils::getAddressShareContactNames($defaults['address']);
foreach ($defaults['address'] as $key => $addressValue) {
if (!empty($addressValue['master_id']) &&
*/
public function getTemplateFileName() {
if ($this->_contactId) {
- $contactSubtypes = $this->get('contactSubtype') ? explode(CRM_Core_DAO::VALUE_SEPARATOR, $this->get('contactSubtype')) : array();
+ $contactSubtypes = $this->get('contactSubtype') ? explode(CRM_Core_DAO::VALUE_SEPARATOR, $this->get('contactSubtype')) : [];
// there could be multiple subtypes. We check templates for each of the subtype, and return the first one found.
foreach ($contactSubtypes as $csType) {
* @return array
* set of tasks that are valid for the user
*/
- public static function permissionedTaskTitles($permission, $params = array()) {
+ public static function permissionedTaskTitles($permission, $params = []) {
if (!isset($params['deletedContacts'])) {
$params['deletedContacts'] = FALSE;
}
self::tasks();
- $tasks = array();
+ $tasks = [];
if ($params['deletedContacts']) {
if (CRM_Core_Permission::check('access deleted contacts')) {
$tasks[self::RESTORE] = self::$_tasks[self::RESTORE]['title'];
* Default values
*/
public function setDefaultValues() {
- $this->_defaults = array();
+ $this->_defaults = [];
if ($this->_subscriptionDetails->contact_id) {
- $fields = array();
+ $fields = [];
$names = array(
'first_name',
'middle_name',
* true if no errors, else array of errors
*/
public static function formRule($fields, $files, $self) {
- $errors = array();
+ $errors = [];
CRM_Core_Form::validateMandatoryFields($self->_fields, $fields, $errors);
// validate the payment instrument values (e.g. credit card number)
}
$fields["email-{$this->_bltID}"] = 1;
- $processorParams = array();
+ $processorParams = [];
foreach ($params as $key => $val) {
$key = str_replace('billing_', '', $key);
list($key) = explode('-', $key);
$this->search();
- $params = array();
+ $params = [];
$whereClause = $this->whereClause($params, FALSE);
$config = CRM_Core_Config::singleton();
if ($config->includeAlphabeticalPager) {
$this->pagerAToZ($whereClause, $params);
}
- $params = array();
+ $params = [];
$whereClause = $this->whereClause($params, TRUE);
$this->pager($whereClause, $params);
ORDER BY is_active desc, title asc
LIMIT $offset, $rowCount";
$contribPage = CRM_Core_DAO::executeQuery($query, $params, TRUE, 'CRM_Contribute_DAO_ContributionPage');
- $contribPageIds = array();
+ $contribPageIds = [];
while ($contribPage->fetch()) {
$contribPageIds[$contribPage->id] = $contribPage->id;
}
$configureActionLinks = self::configureActionLinks();
while ($dao->fetch()) {
- $contribution[$dao->id] = array();
+ $contribution[$dao->id] = [];
CRM_Core_DAO::storeValues($dao, $contribution[$dao->id]);
// form all action links
}
//build the configure links.
- $sectionsInfo = CRM_Utils_Array::value($dao->id, $contriPageSectionInfo, array());
+ $sectionsInfo = CRM_Utils_Array::value($dao->id, $contriPageSectionInfo, []);
$contribution[$dao->id]['configureActionLinks'] = CRM_Core_Action::formLink(self::formatConfigureLinks($sectionsInfo),
$action,
array('id' => $dao->id),
*/
public function whereClause(&$params, $sortBy = TRUE) {
// @todo Unused local variable can be safely removed.
- $values = $clauses = array();
+ $values = $clauses = [];
$title = $this->get('title');
$createdId = $this->get('cid');
}
$value = $this->get('financial_type_id');
- $val = array();
+ $val = [];
if ($value) {
if (is_array($value)) {
foreach ($value as $k => $v) {
public function getCampaignIds() {
// The unfiltered value from the session cannot be trusted, it needs to be
// processed to get a clean array of positive integers.
- $ids = array();
+ $ids = [];
foreach ((array) $this->get('campaign_id') as $id) {
if ((string) (int) $id === (string) $id && $id > 0) {
$ids[] = $id;
}
if (empty($sectionsInfo[$sectionName])) {
- $classes = array();
+ $classes = [];
if (isset($link['class'])) {
$classes = $link['class'];
}
// make links indexed sequentially instead of by bitmask
// otherwise it's next to impossible to reliably add new ones
- $seqLinks = array();
+ $seqLinks = [];
foreach ($links as $bit => $link) {
$link['bit'] = $bit;
$seqLinks[] = $link;
case 'Autocomplete-Select':
static $customUrls = [];
// Fixme: why is this a string in the first place??
- $attributes = array();
+ $attributes = [];
if ($field->attributes) {
foreach (explode(' ', $field->attributes) as $at) {
if (strpos($at, '=')) {
* $note CRM_Core_BAO_Note object
* @throws \CRM_Core_Exception
*/
- public static function add(&$params, $ids = array()) {
+ public static function add(&$params, $ids = []) {
$dataExists = self::dataExists($params);
if (!$dataExists) {
return NULL;
*
*/
public static function &getNote($id, $entityTable = 'civicrm_relationship') {
- $viewNote = array();
+ $viewNote = [];
$query = "
SELECT id,
* @return array
* Nested associative array beginning with direct children of given note.
*/
- private static function buildNoteTree($parentId, $maxDepth = 0, $snippet = FALSE, &$tree = array(), $depth = 0) {
+ private static function buildNoteTree($parentId, $maxDepth = 0, $snippet = FALSE, &$tree = [], $depth = 0) {
if ($maxDepth && $depth > $maxDepth) {
return FALSE;
}
* @return array
* One-dimensional array containing ids of all desendent notes
*/
- public static function getDescendentIds($parentId, &$ids = array()) {
+ public static function getDescendentIds($parentId, &$ids = []) {
// get direct children of given parentId note
$note = new CRM_Core_DAO_Note();
$note->entity_table = 'civicrm_note';
'template' => 'LangSwitch.tpl',
'info' => ts('CiviCRM Language Switcher'),
'subject' => '',
- 'templateValues' => array(),
+ 'templateValues' => [],
'active' => TRUE,
'cache' => BLOCK_NO_CACHE,
'visibility' => 1,
'template' => 'Event.tpl',
'info' => ts('CiviCRM Upcoming Events'),
'subject' => ts('Upcoming Events'),
- 'templateValues' => array(),
+ 'templateValues' => [],
'active' => TRUE,
'cache' => BLOCK_NO_CACHE,
'visibility' => 1,
*/
public static function getInfo() {
- $block = array();
+ $block = [];
foreach (self::properties() as $id => $value) {
if ($value['active']) {
if (in_array($id, array(
private static function setTemplateShortcutValues() {
$config = CRM_Core_Config::singleton();
- static $shortCuts = array();
+ static $shortCuts = [];
if (!($shortCuts)) {
if (CRM_Core_Permission::check('add contacts')) {
}
}
- $values = array();
+ $values = [];
foreach ($shortCuts as $key => $short) {
$values[$key] = self::setShortCutValues($short);
}
* @return array
*/
private static function setShortcutValues($short) {
- $value = array();
+ $value = [];
if (isset($short['url'])) {
$value['url'] = $short['url'];
}
* Create the list of dashboard links.
*/
private static function setTemplateDashboardValues() {
- static $dashboardLinks = array();
+ static $dashboardLinks = [];
if (CRM_Core_Permission::check('access Contact Dashboard')) {
$dashboardLinks = array(
array(
return NULL;
}
- $values = array();
+ $values = [];
foreach ($dashboardLinks as $dash) {
- $value = array();
+ $value = [];
if (isset($dash['url'])) {
$value['url'] = $dash['url'];
}
);
}
- $values = array();
+ $values = [];
foreach ($shortCuts as $short) {
- $value = array();
+ $value = [];
$value['url'] = CRM_Utils_System::url($short['path'], $short['query']);
$value['title'] = $short['title'];
$values[] = $value;
return NULL;
}
- $block = array();
+ $block = [];
$block['name'] = 'block-civicrm';
$block['id'] = $block['name'] . '_' . $id;
$block['subject'] = self::fetch($id, 'Subject.tpl',
// lets call a hook and get any additional files if needed
CRM_Utils_Hook::xmlMenu($files);
- self::$_items = array();
+ self::$_items = [];
foreach ($files as $file) {
self::read($file, self::$_items);
}
throw new CRM_Core_Exception('Unable to read XML file');
}
$path = (string ) $item->path;
- $menu[$path] = array();
+ $menu[$path] = [];
unset($item->path);
if ($item->ids_arguments) {
- $ids = array();
+ $ids = [];
foreach (array('json' => 'json', 'html' => 'html', 'exception' => 'exceptions') as $tag => $attr) {
- $ids[$attr] = array();
+ $ids[$attr] = [];
foreach ($item->ids_arguments->{$tag} as $value) {
$ids[$attr][] = (string) $value;
}
$elements = explode(';', $value);
$op = 'or';
}
- $items = array();
+ $items = [];
foreach ($elements as $element) {
$items[] = $element;
}
'page_arguments',
'is_ssl',
);
- $fieldsPresent = array();
+ $fieldsPresent = [];
foreach ($fieldsToPropagate as $field) {
$fieldsPresent[$field] = isset($menu[$path][$field]);
}
CRM_Core_BAO_SchemaHandler::checkIfFieldExists('civicrm_menu', 'module_data', FALSE)
) {
// Move unrecognized fields to $module_data.
- $module_data = array();
+ $module_data = [];
foreach (array_keys($item) as $key) {
if (!isset($daoFields[$key])) {
$module_data[$key] = $item[$key];
* @param array $menu
*/
public static function buildAdminLinks(&$menu) {
- $values = array();
+ $values = [];
foreach ($menu as $path => $item) {
if (empty($item['adminGroup'])) {
'extra' => $item['extra'] ?? NULL,
);
if (!array_key_exists($item['adminGroup'], $values)) {
- $values[$item['adminGroup']] = array();
- $values[$item['adminGroup']]['fields'] = array();
+ $values[$item['adminGroup']] = [];
+ $values[$item['adminGroup']]['fields'] = [];
}
$values[$item['adminGroup']]['fields']["{weight}.{$item['title']}"] = $value;
$values[$item['adminGroup']]['component_id'] = $item['component_id'];
* The breadcrumb for this path
*/
public static function buildBreadcrumb(&$menu, $path) {
- $crumbs = array();
+ $crumbs = [];
$pathElements = explode('/', $path);
array_pop($pathElements);
* @throws \CRM_Core_Exception
*/
public static function fillComponentIds(&$menu, $path) {
- static $cache = array();
+ static $cache = [];
if (array_key_exists('component_id', $menu[$path])) {
return;
$args = explode('/', $path);
- $elements = array();
+ $elements = [];
while (!empty($args)) {
$string = implode('/', $args);
$string = CRM_Core_DAO::escapeString($string);
$menu = new CRM_Core_DAO_Menu();
$menu->query($query);
- self::$_menuCache = array();
+ self::$_menuCache = [];
$menuPath = NULL;
while ($menu->fetch()) {
- self::$_menuCache[$menu->path] = array();
+ self::$_menuCache[$menu->path] = [];
CRM_Core_DAO::storeValues($menu, self::$_menuCache[$menu->path]);
// Move module_data into main item.
if (!is_string($pathArgs)) {
return;
}
- $args = array();
+ $args = [];
$elements = explode(',', $pathArgs);
foreach ($elements as $keyVal) {
}
if (array_key_exists('urlToSession', $arr)) {
- $urlToSession = array();
+ $urlToSession = [];
$params = explode(';', $arr['urlToSession']);
$count = 0;
$this->_isEventFull = $this->get('isEventFull');
$this->_lineItemParticipantsCount = $this->get('lineItemParticipants');
if (!is_array($this->_lineItem)) {
- $this->_lineItem = array();
+ $this->_lineItem = [];
}
if (!is_array($this->_lineItemParticipantsCount)) {
- $this->_lineItemParticipantsCount = array();
+ $this->_lineItemParticipantsCount = [];
}
$this->_availableRegistrations = $this->get('availableRegistrations');
$this->_participantIDS = $this->get('participantIDs');
}
// get all the values from the dao object
- $this->_values = $this->_fields = array();
+ $this->_values = $this->_fields = [];
//retrieve event information
$params = array('id' => $this->_eventId);
if ($contactID) {
//FIX CRM-9653
if (is_array($id)) {
- $fields = array();
+ $fields = [];
foreach ($id as $profileID) {
$field = CRM_Core_BAO_UFGroup::getFields($profileID, FALSE, CRM_Core_Action::ADD,
NULL, NULL, FALSE, NULL,
}
$eventFee = $form->_values['fee'] ?? NULL;
if (!is_array($eventFee) || empty($eventFee)) {
- $form->_values['fee'] = array();
+ $form->_values['fee'] = [];
}
//fix for non-upgraded price sets.CRM-4256.
$priceSetId = $form->get('priceSetId');
$addParticipantNum = substr($form->_name, 12);
- $priceSetFields = $priceSetDetails = array();
+ $priceSetFields = $priceSetDetails = [];
$hasPriceFieldsCount = FALSE;
if ($priceSetId) {
$priceSetDetails = $form->get('priceSet');
$priceSetDetails = $form->get('priceSet');
foreach ($params as $key => & $value) {
- $vals = array();
+ $vals = [];
if (strpos($key, 'price_') !== FALSE) {
$fieldId = substr($key, 6);
if (!array_key_exists($fieldId, $priceSetDetails['fields']) ||
$priceSet = $form->get('priceSet');
$priceSetId = $form->get('priceSetId');
- $optionsCount = array();
+ $optionsCount = [];
if (!$priceSetId ||
!is_array($priceSet) ||
empty($priceSet) ||
return $optionsCount;
}
- $priceSetFields = $priceMaxFieldDetails = array();
+ $priceSetFields = $priceMaxFieldDetails = [];
if (!empty($priceSet['optionsCountTotal'])) {
$priceSetFields = $priceSet['optionsCountDetails']['fields'];
}
* @param array $optionFullIds
* @param CRM_Core_Form $form
*/
- public static function resetElementValue($optionFullIds = array(), &$form) {
+ public static function resetElementValue($optionFullIds = [], &$form) {
if (!is_array($optionFullIds) ||
empty($optionFullIds) ||
!$form->isSubmitted()
* @param array $optionIds
* @param CRM_Core_Form $form
*/
- public static function resetSubmittedValue($elementName, $optionIds = array(), &$form) {
+ public static function resetSubmittedValue($elementName, $optionIds = [], &$form) {
if (empty($elementName) ||
!$form->elementExists($elementName) ||
!$form->getSubmitValue($elementName)
* @return array
*/
public static function validatePriceSet(&$form, $params) {
- $errors = array();
+ $errors = [];
$hasOptMaxValue = FALSE;
if (!is_array($params) || empty($params)) {
return $errors;
return $errors;
}
- $optionsCountDetails = $optionsMaxValueDetails = array();
+ $optionsCountDetails = $optionsMaxValueDetails = [];
if (
isset($priceSetDetails['optionsMaxValueTotal'])
&& $priceSetDetails['optionsMaxValueTotal']
$feeBlock = $priceSetDetails['fields'];
}
- $optionMaxValues = $fieldSelected = array();
+ $optionMaxValues = $fieldSelected = [];
foreach ($params as $pNum => $values) {
if (!is_array($values) || $values == 'skip') {
continue;
//validate for option max value.
foreach ($optionMaxValues as $fieldId => $values) {
- $options = CRM_Utils_Array::value('options', $feeBlock[$fieldId], array());
+ $options = CRM_Utils_Array::value('options', $feeBlock[$fieldId], []);
foreach ($values as $optId => $total) {
$optMax = $optionsMaxValueDetails[$fieldId]['options'][$optId];
$opDbCount = CRM_Utils_Array::value('db_total_count', $options[$optId], 0);
$this->_participantId = $participantID;
$this->set('participantId', $this->_participantId);
- $ids = $participantValues = array();
+ $ids = $participantValues = [];
$participantParams = array('id' => $this->_participantId);
CRM_Event_BAO_Participant::getValues($participantParams, $participantValues, $ids);
$this->_values['participant'] = $participantValues[$this->_participantId];
*/
public function processRegistration($params, $contactID = NULL) {
$session = CRM_Core_Session::singleton();
- $this->_participantInfo = array();
+ $this->_participantInfo = [];
// CRM-4320, lets build array of cancelled additional participant ids
// those are drop or skip by primary at the time of confirmation.
// get all in and then unset those are confirmed.
$cancelledIds = $this->_additionalParticipantIds;
- $participantCount = array();
+ $participantCount = [];
foreach ($params as $participantNum => $record) {
if ($record == 'skip') {
$participantCount[$participantNum] = 'skip';
$skipColumnHeader = $this->controller->exportValue('DataSource', 'skipColumnHeader');
$this->_onDuplicate = $this->get('onDuplicate');
- $highlightedFields = array();
+ $highlightedFields = [];
if ($skipColumnHeader) {
$this->assign('skipColumnHeader', $skipColumnHeader);
$this->assign('rowDisplayCount', 3);
//mapping is to be loaded from database
$params = array('id' => $savedMapping);
- $temp = array();
+ $temp = [];
$mappingDetails = CRM_Core_BAO_Mapping::retrieve($params, $temp);
$this->assign('loadedMapping', $mappingDetails->name);
$this->addFormRule(array('CRM_Event_Import_Form_MapField', 'formRule'), $this);
- $defaults = array();
+ $defaults = [];
$mapperKeys = array_keys($this->_mapperFields);
$hasHeaders = !empty($this->_columnHeaders);
$headerPatterns = $this->get('headerPatterns');
$jsSet = TRUE;
}
else {
- $defaults["mapper[$i]"] = array();
+ $defaults["mapper[$i]"] = [];
}
if (!$jsSet) {
for ($k = 1; $k < 4; $k++) {
* list of errors to be posted back to the form
*/
public static function formRule($fields, $files, $self) {
- $errors = array();
+ $errors = [];
// define so we avoid notices below
$errors['_qf_default'] = '';
$fieldMessage = NULL;
if (!array_key_exists('savedMapping', $fields)) {
- $importKeys = array();
+ $importKeys = [];
foreach ($fields['mapper'] as $mapperPart) {
$importKeys[] = $mapperPart[0];
}
$seperator = $this->controller->exportValue('DataSource', 'fieldSeparator');
$skipColumnHeader = $this->controller->exportValue('DataSource', 'skipColumnHeader');
- $mapperKeys = array();
- $mapper = array();
+ $mapperKeys = [];
+ $mapper = [];
$mapperKeys = $this->controller->exportValue($this->_name, 'mapper');
- $mapperKeysMain = array();
+ $mapperKeysMain = [];
for ($i = 0; $i < $this->_columnCount; $i++) {
$mapper[$i] = $this->_mapperFields[$mapperKeys[$i][0]];
$mappingFields->mapping_id = $params['mappingId'];
$mappingFields->find();
- $mappingFieldsId = array();
+ $mappingFieldsId = [];
while ($mappingFields->fetch()) {
if ($mappingFields->id) {
$mappingFieldsId[$mappingFields->column_number] = $mappingFields->id;
*/
public function checkRequirements() {
if (!$this->isEnabled()) {
- return array();
+ return [];
}
- $errors = array();
+ $errors = [];
if (!$this->cacheDir || !is_dir($this->cacheDir) || !is_writable($this->cacheDir)) {
$civicrmDestination = urlencode(CRM_Utils_System::url('civicrm/admin/extensions', 'reset=1'));
*/
public function getExtensions() {
if (!$this->isEnabled() || count($this->checkRequirements())) {
- return array();
+ return [];
}
- $exts = array();
+ $exts = [];
$remote = $this->_discoverRemote();
if (is_array($remote)) {
$remotes = json_decode($this->grabCachedJson(), TRUE);
}
- $this->_remotesDiscovered = array();
+ $this->_remotesDiscovered = [];
foreach ((array) $remotes as $id => $xml) {
$ext = CRM_Extension_Info::loadFromString($xml);
$this->_remotesDiscovered[] = $ext;
if (FALSE === $this->getRepositoryUrl()) {
// don't check if the user has configured civi not to check an external
// url for extensions. See CRM-10575.
- return array();
+ return [];
}
$filename = $this->cacheDir . DIRECTORY_SEPARATOR . self::CACHE_JSON_FILE . '.' . md5($this->getRepositoryUrl());
* @return array
*/
public function checkRequirements() {
- $errors = array();
+ $errors = [];
// In current configuration, we don't construct the default container
// unless baseDir is set, so this error condition is more theoretical.
* list of error messages; empty if OK
*/
public function checkRequirements($extensionInfo = NULL) {
- $errors = array();
+ $errors = [];
if (!$this->containerDir || !is_dir($this->containerDir) || !is_writable($this->containerDir)) {
$civicrmDestination = urlencode(CRM_Utils_System::url('civicrm/admin/extensions', 'reset=1'));
);
CRM_Utils_System::appendBreadCrumb($breadCrumb);
- $this->_groupValues = array();
+ $this->_groupValues = [];
$params = array('id' => $this->_id);
$this->_group = CRM_Contact_BAO_Group::retrieve($params, $this->_groupValues);
$this->_title = $this->_groupValues['title'];
* @return array
*/
public function setDefaultValues() {
- $defaults = array();
+ $defaults = [];
if (isset($this->_id)) {
$defaults = $this->_groupValues;
if (!empty($defaults['group_type'])) {
$types = explode(CRM_Core_DAO::VALUE_SEPARATOR,
substr($defaults['group_type'], 1, -1)
);
- $defaults['group_type'] = array();
+ $defaults['group_type'] = [];
foreach ($types as $type) {
$defaults['group_type'][$type] = 1;
}
* list of errors to be posted back to the form
*/
public static function formRule($fields, $fileParams, $options) {
- $errors = array();
+ $errors = [];
$doParentCheck = $options['doParentCheck'];
$self = &$options['selfObj'];
// CRM-21431 If all group_type are unchecked, the change will not be saved otherwise.
if (!isset($params['group_type'])) {
- $params['group_type'] = array();
+ $params['group_type'] = [];
}
$params['is_reserved'] = CRM_Utils_Array::value('is_reserved', $params, FALSE);
*/
public static function buildParentGroups(&$form) {
$groupNames = CRM_Core_PseudoConstant::group();
- $parentGroups = $parentGroupElements = array();
+ $parentGroups = $parentGroupElements = [];
if (isset($form->_id) && !empty($form->_groupValues['parents'])) {
$parentGroupIds = explode(',', $form->_groupValues['parents']);
foreach ($parentGroupIds as $parentGroupId) {
$potentialParentGroupIds = array_keys($groupNames);
}
- $parentGroupSelectValues = array();
+ $parentGroupSelectValues = [];
foreach ($potentialParentGroupIds as $potentialParentGroupId) {
if (array_key_exists($potentialParentGroupId, $groupNames)) {
$parentGroupSelectValues[$potentialParentGroupId] = $groupNames[$potentialParentGroupId];
$dao->query($query);
- $results = array();
+ $results = [];
while ($dao->fetch()) {
$url = CRM_Utils_System::url('civicrm/contact/view',
$skipColumnHeader = $this->controller->exportValue('DataSource', 'skipColumnHeader');
$this->_onDuplicate = $this->get('onDuplicate', $onDuplicate ?? "");
- $highlightedFields = array();
+ $highlightedFields = [];
if ($skipColumnHeader) {
$this->assign('skipColumnHeader', $skipColumnHeader);
$this->assign('rowDisplayCount', 3);
//mapping is to be loaded from database
$params = array('id' => $savedMapping);
- $temp = array();
+ $temp = [];
$mappingDetails = CRM_Core_BAO_Mapping::retrieve($params, $temp);
$this->assign('loadedMapping', $mappingDetails->name);
//-------- end of saved mapping stuff ---------
- $defaults = array();
+ $defaults = [];
$mapperKeys = array_keys($this->_mapperFields);
$hasHeaders = !empty($this->_columnHeaders);
$headerPatterns = $this->get('headerPatterns');
$jsSet = TRUE;
}
else {
- $defaults["mapper[$i]"] = array();
+ $defaults["mapper[$i]"] = [];
}
if (!$jsSet) {
for ($k = 1; $k < 4; $k++) {
* list of errors to be posted back to the form
*/
public static function formRule($fields, $files, $self) {
- $errors = array();
+ $errors = [];
if (!array_key_exists('savedMapping', $fields)) {
- $importKeys = array();
+ $importKeys = [];
foreach ($fields['mapper'] as $mapperPart) {
$importKeys[] = $mapperPart[0];
}
$seperator = $this->controller->exportValue('DataSource', 'fieldSeparator');
$skipColumnHeader = $this->controller->exportValue('DataSource', 'skipColumnHeader');
- $mapperKeys = array();
- $mapper = array();
+ $mapperKeys = [];
+ $mapper = [];
$mapperKeys = $this->controller->exportValue($this->_name, 'mapper');
- $mapperKeysMain = array();
- $mapperLocType = array();
- $mapperPhoneType = array();
+ $mapperKeysMain = [];
+ $mapperLocType = [];
+ $mapperPhoneType = [];
for ($i = 0; $i < $this->_columnCount; $i++) {
$mapper[$i] = $this->_mapperFields[$mapperKeys[$i][0]];
$mappingFields->mapping_id = $params['mappingId'];
$mappingFields->find();
- $mappingFieldsId = array();
+ $mappingFieldsId = [];
while ($mappingFields->fetch()) {
if ($mappingFields->id) {
$mappingFieldsId[$mappingFields->column_number] = $mappingFields->id;
}
$this->assign('membershipSummary', TRUE);
CRM_Utils_System::setTitle(ts('CiviMember'));
- $membershipSummary = array();
+ $membershipSummary = [];
$preMonth = date("Y-m-d", mktime(0, 0, 0, date("m") - 1, 01, date("Y")));
$preMonthEnd = date("Y-m-t", mktime(0, 0, 0, date("m") - 1, 01, date("Y")));
$isRecalculatePledgePayment = self::isPaymentsRequireRecalculation($params);
$transaction = new CRM_Core_Transaction();
- $paymentParams = array();
+ $paymentParams = [];
if (!empty($params['installment_amount'])) {
$params['amount'] = $params['installment_amount'] * $params['installments'];
}
"action=view&reset=1&id={$pledge->id}&cid={$pledge->contact_id}&context=home"
);
- $recentOther = array();
+ $recentOther = [];
if (CRM_Core_Permission::checkActionPermission('CiviPledge', CRM_Core_Action::UPDATE)) {
$recentOther['editUrl'] = CRM_Utils_System::url('civicrm/contact/view/pledge',
"action=update&reset=1&id={$pledge->id}&cid={$pledge->contact_id}&context=home"
* @return array|null
*/
public static function getTotalAmountAndCount($status = NULL, $startDate = NULL, $endDate = NULL) {
- $where = array();
+ $where = [];
$select = $from = $queryDate = NULL;
$statusId = CRM_Core_PseudoConstant::getKey('CRM_Pledge_BAO_Pledge', 'status_id', $status);
$start = substr($startDate, 0, 8);
$end = substr($endDate, 0, 8);
$pCount = 0;
- $pamount = array();
+ $pamount = [];
$dao = CRM_Core_DAO::executeQuery($query);
while ($dao->fetch()) {
$pCount += $dao->pledge_count;
),
);
- $where = array();
+ $where = [];
switch ($status) {
case 'Completed':
$select = 'sum( total_amount ) as received_pledge , count( cd.id ) as received_count';
";
if ($select) {
$dao = CRM_Core_DAO::executeQuery($query);
- $amount = array();
+ $amount = [];
$count = 0;
while ($dao->fetch()) {
* return the list of pledge fields
*/
public static function getHonorContacts($honorId) {
- $params = array();
+ $params = [];
$honorDAO = new CRM_Contribute_DAO_ContributionSoft();
$honorDAO->contact_id = $honorId;
$honorDAO->find();
*/
public static function sendAcknowledgment(&$form, $params) {
//handle Acknowledgment.
- $allPayments = $payments = array();
+ $allPayments = $payments = [];
// get All Payments status types.
$paymentStatusTypes = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
if (!empty($allPayments)) {
foreach ($allPayments as $payID => $values) {
- $contributionValue = $contributionStatus = array();
+ $contributionValue = $contributionStatus = [];
if (isset($values['contribution_id'])) {
$contributionParams = array('id' => $values['contribution_id']);
$returnProperties = array('contribution_status_id', 'receive_date');
'domain' => array('name', 'phone', 'address', 'email'),
'contact' => CRM_Core_SelectValues::contactTokens(),
);
- $domainValues = array();
+ $domainValues = [];
foreach ($tokens['domain'] as $token) {
$domainValues[$token] = CRM_Utils_Token::getDomainTokenReplacement($token, $domain);
}
if (!empty($params['hidden_custom'])) {
$groupTree = CRM_Core_BAO_CustomGroup::getTree('Pledge', NULL, $params['id']);
$pledgeParams = array(array('pledge_id', '=', $params['id'], 0, 0));
- $customGroup = array();
+ $customGroup = [];
// retrieve custom data
foreach ($groupTree as $groupID => $group) {
- $customFields = $customValues = array();
+ $customFields = $customValues = [];
if ($groupID == 'info') {
continue;
}
public static function exportableFields($checkPermission = TRUE) {
if (!self::$_exportableFields) {
if (!self::$_exportableFields) {
- self::$_exportableFields = array();
+ self::$_exportableFields = [];
}
$fields = CRM_Pledge_DAO_Pledge::export();
* associated array of pledge id(s)
*/
public static function getContactPledges($contactID) {
- $pledgeDetails = array();
+ $pledgeDetails = [];
$pledgeStatuses = CRM_Core_OptionGroup::values('pledge_status',
FALSE, FALSE, FALSE, NULL, 'name'
);
- $status = array();
+ $status = [];
// get pending and in progress status
foreach (array(
*/
public static function updatePledgeStatus($params) {
- $returnMessages = array();
+ $returnMessages = [];
$sendReminders = CRM_Utils_Array::value('send_reminders', $params, FALSE);
$dao = CRM_Core_DAO::executeQuery($query);
$now = date('Ymd');
- $pledgeDetails = $contactIds = $pledgePayments = $pledgeStatus = array();
+ $pledgeDetails = $contactIds = $pledgePayments = $pledgeStatus = [];
while ($dao->fetch()) {
$checksumValue = CRM_Contact_BAO_Contact_Utils::generateChecksum($dao->contact_id);
'contact' => CRM_Core_SelectValues::contactTokens(),
);
- $domainValues = array();
+ $domainValues = [];
foreach ($tokens['domain'] as $token) {
$domainValues[$token] = CRM_Utils_Token::getDomainTokenReplacement($token, $domain);
}
));
$paymentDAO->find();
- $paymentIDs = array();
+ $paymentIDs = [];
while ($paymentDAO->fetch()) {
$paymentIDs[] = $paymentDAO->id;
}
*
* @return array|bool
*/
- public static function buildOptions($fieldName, $context = NULL, $props = array()) {
+ public static function buildOptions($fieldName, $context = NULL, $props = []) {
$result = parent::buildOptions($fieldName, $context, $props);
if ($fieldName == 'status_id') {
$result = array_diff($result, array('Failed'));
* @return array
*/
public static function getPledgeBlock($pageID) {
- $pledgeBlock = array();
+ $pledgeBlock = [];
$dao = new CRM_Pledge_DAO_PledgeBlock();
$dao->entity_table = 'civicrm_contribution_page';
//build pledge payment fields.
if (!empty($form->_values['pledge_id'])) {
//get all payments required details.
- $allPayments = array();
+ $allPayments = [];
$returnProperties = array(
'status_id',
'scheduled_date',
// get all status
$allStatus = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
- $nextPayment = array();
+ $nextPayment = [];
$isNextPayment = FALSE;
- $overduePayments = array();
+ $overduePayments = [];
foreach ($allPayments as $payID => $value) {
if ($allStatus[$value['status_id']] == 'Overdue') {
$overduePayments[$payID] = array(
}
// build check box array for payments.
- $payments = array();
+ $payments = [];
if (!empty($overduePayments)) {
foreach ($overduePayments as $id => $payment) {
$label = ts("%1 - due on %2 (overdue)", array(
}
// Frequency unit drop-down label suffixes switch from *ly to *(s)
$freqUnitVals = explode(CRM_Core_DAO::VALUE_SEPARATOR, $pledgeBlock['pledge_frequency_unit']);
- $freqUnits = array();
+ $freqUnits = [];
$frequencyUnits = CRM_Core_OptionGroup::values('recur_frequency_units');
foreach ($freqUnitVals as $key => $val) {
if (array_key_exists($val, $frequencyUnits)) {
// CRM-18854
if (!empty($pledgeBlock['is_pledge_start_date_visible'])) {
if (!empty($pledgeBlock['pledge_start_date'])) {
- $defaults = array();
+ $defaults = [];
$date = (array) json_decode($pledgeBlock['pledge_start_date']);
foreach ($date as $field => $value) {
switch ($field) {
* say Q1, Q2 instead of the full title - to save space.
* @var array
*/
- private $_columnTitleOverrides = array();
+ private $_columnTitleOverrides = [];
/**
*/
public function __construct() {
//filter options for survey activity status.
$responseStatus = array('' => '- Any -');
- self::$_surveyRespondentStatus = array();
+ self::$_surveyRespondentStatus = [];
$activityStatus = CRM_Core_PseudoConstant::activityStatus('name');
if ($statusId = array_search('Scheduled', $activityStatus)) {
$responseStatus[$statusId] = ts('Reserved');
}
$optionGroups = CRM_Campaign_BAO_Survey::getResultSets('name');
- $resultOptions = array();
+ $resultOptions = [];
foreach ($optionGroups as $gid => $name) {
if ($name) {
- $value = array();
+ $value = [];
$value = CRM_Core_OptionGroup::values($name);
if (!empty($value)) {
$value = array_combine($value, $value);
}
public function select() {
- $select = array();
+ $select = [];
//add the survey response fields.
$this->_addSurveyResponseColumns();
- $this->_columnHeaders = array();
+ $this->_columnHeaders = [];
foreach ($this->_columns as $tableName => $table) {
if (!isset($table['fields'])) {
continue;
}
public function where() {
- $clauses = array();
+ $clauses = [];
foreach ($this->_columns as $tableName => $table) {
if (array_key_exists('filters', $table)) {
foreach ($table['filters'] as $fieldName => $field) {
return $coverSheet;
}
- $fieldIds = array();
+ $fieldIds = [];
- $surveyResponseFields = array();
+ $surveyResponseFields = [];
foreach ($this->_columns as $tableName => $values) {
if (!is_array($values['fields'])) {
continue;
WHERE field.id IN (' . implode(' , ', $fieldIds) . ' )
Order By val.weight';
$field = CRM_Core_DAO::executeQuery($query);
- $options = array();
+ $options = [];
while ($field->fetch()) {
$name = "custom_{$field->id}";
$surveyResponseFields[$name]['options'][$field->value] = $field->label;
WHERE survey.id IN ( ' . implode(' , ', array_values($surveyIds)) . ' )
Order By val.weight';
$resultSet = CRM_Core_DAO::executeQuery($query);
- $surveyResultFields = array();
+ $surveyResultFields = [];
while ($resultSet->fetch()) {
$surveyResultFields[$resultSet->id]['title'] = $resultSet->title;
$surveyResultFields[$resultSet->id]['options'][$resultSet->value] = $resultSet->label;
Order By val.weight';
$result = CRM_Core_DAO::executeQuery($query);
- $resultSet = array();
+ $resultSet = [];
while ($result->fetch()) {
$resultSet[$result->id][$result->value] = $result->label;
}
if (!empty($row['civicrm_activity_survey_id'])) {
$surveyId = $row['civicrm_activity_survey_id'];
}
- $result = CRM_Utils_Array::value($surveyId, $resultSet, array());
+ $result = CRM_Utils_Array::value($surveyId, $resultSet, []);
$resultLabel = $row['civicrm_activity_result'] ?? NULL;
if ($respondentStatus == 'Reserved') {
$row['civicrm_activity_result'] = implode(' | ', array_keys($result));
return;
}
- $surveyResponseFields = array();
- $surveyResponseFieldIds = array();
+ $surveyResponseFields = [];
+ $surveyResponseFieldIds = [];
foreach ($this->_columns as $tableName => $values) {
if (!is_array($values['fields'])) {
continue;
WHERE cf.id IN ( ' . implode(' , ', $surveyResponseFieldIds) . ' )
Order By ov.weight';
- $responseFields = array();
- $fieldValueMap = array();
+ $responseFields = [];
+ $fieldValueMap = [];
$properties = array(
'id',
'data_type',
in_array($this->_outputMode, array('print', 'pdf'))
) {
$optGrpId = $responseFields[$name]['option_group_id'] ?? NULL;
- $options = CRM_Utils_Array::value($optGrpId, $fieldValueMap, array());
+ $options = CRM_Utils_Array::value($optGrpId, $fieldValueMap, []);
$value = implode(' | ', array_keys($options));
}
else {
return;
}
- $responseFields = array();
+ $responseFields = [];
foreach ($surveyIds as $surveyId) {
$responseFields += CRM_Campaign_BAO_Survey::getSurveyResponseFields($surveyId);
$this->_surveyResponseFields = $responseFields;
$this->_locationBasedPhoneField = TRUE;
}
}
- $responseFieldIds = array();
+ $responseFieldIds = [];
foreach (array_keys($responseFields) as $key) {
$cfId = CRM_Core_BAO_CustomField::getKeyID($key);
if ($cfId) {
* @return array
*/
public static function formRule($fields, $files, $self) {
- $errors = $grouping = array();
+ $errors = $grouping = [];
return $errors;
}
$sql = $this->buildQuery(TRUE);
- $rows = $graphRows = array();
+ $rows = $graphRows = [];
$this->buildRows($sql, $rows);
$this->formatDisplay($rows);
* Override parent select for reasons someone will someday make sense of & document.
*/
public function select() {
- $select = array();
+ $select = [];
$append = NULL;
// since contact fields not related to financial type
if (array_key_exists('financial_type', $this->_params['group_bys']) ||
}
if (!$this->_amountClauseWithAND) {
- $amountClauseWithAND = array();
+ $amountClauseWithAND = [];
if (!empty($clauses['total_amount1'])) {
$amountClauseWithAND[] = str_replace("{$this->_aliases['civicrm_contribution']}.total_amount",
"{$this->_aliases['civicrm_contribution']}1.total_amount_sum", $clauses['total_amount1']);
*/
public static function formRule($fields, $files, $self) {
- $errors = $checkDate = $errorCount = array();
+ $errors = $checkDate = $errorCount = [];
$rules = array(
'id' => array(
foreach ($fields['fields'] as $fld_id => $value) {
if (!($fld_id == 'total_amount1') && !($fld_id == 'total_amount2') && !(substr($fld_id, 0, 7) === "custom_")) {
$found = FALSE;
- $invlidGroups = array();
+ $invlidGroups = [];
foreach ($fields['group_bys'] as $grp_id => $val) {
$validFields = $rules[$grp_id];
if (in_array($fld_id, $validFields)) {
$sql = "{$this->_select} {$this->_from} {$this->_where}";
$dao = $this->executeReportQuery($sql);
//store contributions in array 'contact_sums' for comparison
- $contact_sums = array();
+ $contact_sums = [];
while ($dao->fetch()) {
$contact_sums[$dao->contact_civireport_id] = array(
'contribution1_total_amount_sum' => $dao->contribution1_total_amount_sum,
";
$dao = $this->executeReportQuery($sql);
- $amount = $average = $amount2 = $average2 = array();
+ $amount = $average = $amount2 = $average2 = [];
$count = $count2 = 0;
while ($dao->fetch()) {
if ($dao->amount) {
$count = 0;
$sql = "{$this->_select} {$this->_from} {$this->_where} {$this->_groupBy} {$this->_orderBy} {$this->_limit}";
$dao = $this->executeReportQuery($sql);
- $rows = array();
+ $rows = [];
while ($dao->fetch()) {
foreach ($this->_columnHeaders as $key => $value) {
$rows[$count][$key] = $dao->$key;
ORDER BY cv.label
";
$dao = CRM_Core_DAO::executeQuery($query);
- $elements = array();
+ $elements = [];
while ($dao->fetch()) {
$elements[$dao->id] = "$dao->label\n";
}
}
public function select() {
- $select = array();
- $this->_columnHeaders = array();
+ $select = [];
+ $this->_columnHeaders = [];
//add blank column at the Start
if (array_key_exists('options', $this->_params) &&
* @return array
*/
public static function formRule($fields, $files, $self) {
- $errors = $grouping = array();
+ $errors = $grouping = [];
return $errors;
}
}
public function where() {
- $clauses = array();
+ $clauses = [];
foreach ($this->_columns as $tableName => $table) {
if (array_key_exists('filters', $table)) {
foreach ($table['filters'] as $fieldName => $field) {
$roleId = $row['civicrm_participant_role_id'];
if ($roleId) {
$roles = explode(CRM_Core_DAO::VALUE_SEPARATOR, $roleId);
- $roleId = array();
+ $roleId = [];
foreach ($roles as $role) {
$roleId[$role] = CRM_Event_PseudoConstant::participantRole($role, FALSE);
}
*/
public function browse($action = NULL) {
$providers = CRM_SMS_BAO_Provider::getProviders();
- $rows = array();
+ $rows = [];
foreach ($providers as $provider) {
$action = array_sum(array_keys($this->links()));
// update enable/disable links.
*
* @var object
*/
- static private $_singleton = array();
+ static private $_singleton = [];
const MAX_SMS_CHAR = 460;
/**
* @return object
* @throws CRM_Core_Exception
*/
- public static function &singleton($providerParams = array(), $force = FALSE) {
+ public static function &singleton($providerParams = [], $force = FALSE) {
$mailingID = $providerParams['mailing_id'] ?? NULL;
$providerID = $providerParams['provider_id'] ?? NULL;
$providerName = $providerParams['provider'] ?? NULL;
* @return self|null|object
* @throws CRM_Core_Exception
*/
- public function createActivity($apiMsgID, $message, $headers = array(), $jobID = NULL, $userID = NULL) {
+ public function createActivity($apiMsgID, $message, $headers = [], $jobID = NULL, $userID = NULL) {
if ($jobID) {
$sql = "
SELECT scheduled_id FROM civicrm_mailing m
* `Civi::$statics[__CLASS__]['foo'] = 'bar';
* ```
*/
- public static $statics = array();
+ public static $statics = [];
/**
* Retrieve a named cache instance.
* singletons, containers.
*/
public static function reset() {
- self::$statics = array();
+ self::$statics = [];
Civi\Core\Container::singleton();
}
* @see CRM_Utils_Hook::themes
*/
public function getAvailable() {
- $result = array();
+ $result = [];
foreach ($this->getAll() as $key => $theme) {
if ($key{0} !== '_') {
$result[$key] = $theme['title'];
public function resolveUrls($active, $cssExt, $cssFile) {
$all = $this->getAll();
if (!isset($all[$active])) {
- return array();
+ return [];
}
$cssId = $this->cssId($cssExt, $cssFile);
foreach ($all[$active]['search_order'] as $themeKey) {
if (isset($all[$themeKey]['excludes']) && in_array($cssId, $all[$themeKey]['excludes'])) {
- $result = array();
+ $result = [];
}
else {
$result = Civi\Core\Resolver::singleton()
*/
public function assertDBCompareValues($daoName, $searchParams, $expectedValues) {
//get the values from db
- $dbValues = array();
+ $dbValues = [];
\CRM_Core_DAO::commonRetrieve($daoName, $searchParams, $dbValues);
// compare db values with expected values
* @param array $actual
*/
public function assertTreeEquals($expected, $actual) {
- $e = array();
- $a = array();
+ $e = [];
+ $a = [];
\CRM_Utils_Array::flatten($expected, $e, '', ':::');
\CRM_Utils_Array::flatten($actual, $a, '', ':::');
ksort($e);
*
* @return int
*/
- public function createMailing($params = array()) {
+ public function createMailing($params = []) {
$params = array_merge(array(
'subject' => 'maild' . rand(),
'body_text' => 'bdkfhdskfhduew{domain.address}{action.optOutUrl}',
global $tplPath, $installType;
// Ex: $extraSettings[] = '$civicrm_settings["domain"]["foo"] = "bar";';
- $extraSettings = array();
+ $extraSettings = [];
$params = array(
'crmRoot' => $crmPath,
*/
class test_extension_manager_paymenttest extends CRM_Core_Payment {
- public static $counts = array();
+ public static $counts = [];
public function install() {
self::$counts['install'] = self::$counts['install'] ?? 0;
* @return string, sql fragment with conditional expressions
*/
public function where($includeContactIDs = FALSE) {
- $params = array();
+ $params = [];
$where = "contact_a.contact_type = 'Household'";
$count = 1;
- $clause = array();
+ $clause = [];
$name = CRM_Utils_Array::value('household_name',
$this->_formValues
);
*/
public function assertDBCompareValues(&$testCase, $daoName, $searchParams, $expectedValues) {
//get the values from db
- $dbValues = array();
+ $dbValues = [];
CRM_Core_DAO::commonRetrieve($daoName, $searchParams, $dbValues);
// compare db values with expected values
*
* @return \ezcMail|string
*/
- public function checkMailLog($strings, $absentStrings = array(), $prefix = '') {
+ public function checkMailLog($strings, $absentStrings = [], $prefix = '') {
$mail = $this->getMostRecentEmail('raw');
return $this->checkMailForStrings($strings, $absentStrings, $prefix, $mail);
}
*
* @return \ezcMail|string
*/
- public function checkAllMailLog($strings, $absentStrings = array(), $prefix = '') {
+ public function checkAllMailLog($strings, $absentStrings = [], $prefix = '') {
$mails = $this->getAllMessages('raw');
$mail = implode(',', $mails);
return $this->checkMailForStrings($strings, $absentStrings, $prefix, $mail);
* Array($msgPos => array($recipPos => $emailAddr)).
*/
public function assertRecipients($expectedRecipients) {
- $recipients = array();
+ $recipients = [];
foreach ($this->getAllMessages('ezc') as $message) {
$recipients[] = CRM_Utils_Array::collect('email', $message->to);
}
* Array(string $subj).
*/
public function assertSubjects($expectedSubjects) {
- $subjects = array();
+ $subjects = [];
foreach ($this->getAllMessages('ezc') as $message) {
/** @var ezcMail $message */
$subjects[] = $message->subject;
$reportName = array_pop($tmpReportVal);
$reportObj =& $controller->_pages[$reportName];
- $tmpGlobals = array();
+ $tmpGlobals = [];
$tmpGlobals['_REQUEST']['force'] = 1;
$tmpGlobals['_GET'][$config->userFrameworkURLVar] = 'civicrm/placeholder';
$tmpGlobals['_SERVER']['QUERY_STRING'] = '';
* @return array
*/
public function getArrayFromCsv($csvFile) {
- $arrFile = array();
+ $arrFile = [];
if (($handle = fopen($csvFile, "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$arrFile[] = $data;
* Test SMS provider to allow for testing
*/
class CiviTestSMSProvider extends CRM_SMS_Provider {
- protected $_providerInfo = array();
+ protected $_providerInfo = [];
protected $_id = 0;
- static private $_singleton = array();
+ static private $_singleton = [];
public function __construct($provider, $skipAuth = TRUE) {
$this->provider = $provider;
}
- public static function &singleton($providerParams = array(), $force = FALSE) {
+ public static function &singleton($providerParams = [], $force = FALSE) {
if (isset($providerParams['provider'])) {
$providers = CRM_SMS_BAO_Provider::getProviders(NULL, array('name' => $providerParams['provider']));
$provider = current($providers);
$cacheKey = (int) $providerID;
if (!isset(self::$_singleton[$cacheKey]) || $force) {
- $provider = array();
+ $provider = [];
if ($providerID) {
$provider = CRM_SMS_BAO_Provider::getProviderInfo($providerID);
}
// Pass 1: Check all *Tests.php files
// array(callable)
- $addTests = array();
+ $addTests = [];
//echo "start Pass 1 on {$dirInfo->getRealPath()}\n";
$dir = new DirectoryIterator($dirInfo->getRealPath());
foreach ($dir as $fileInfo) {
// Pass 2: Scan all subdirectories
// array(array(0 => $suite, 1 => $file, 2 => SplFileinfo))
- $addAllTests = array();
+ $addAllTests = [];
$dir = new DirectoryIterator($dirInfo->getRealPath());
//echo "start Pass 2 on {$dirInfo->getRealPath()}\n";
foreach ($dir as $fileInfo) {
// Pass 3: Check all *Test.php files in this directory
//echo "start Pass 3 on {$dirInfo->getRealPath()}\n";
// array(className)
- $addTestSuites = array();
+ $addTestSuites = [];
$dir = new DirectoryIterator($dirInfo->getRealPath());
foreach ($dir as $fileInfo) {
if ($fileInfo->isReadable() && $fileInfo->isFile()
* @return array
*/
public function getExamples() {
- $examples = array();
+ $examples = [];
$examples[] = array(
0 => 'square.txt',
$this->markTestSkipped('Missing siteKey');
}
- $this->old_api_keys = array();
+ $this->old_api_keys = [];
}
protected function getRestUrl() {
* @return array; each item is a list of parameters for testAPICalls
*/
public function apiTestCases() {
- $cases = array();
+ $cases = [];
// entity,action: omit apiKey, valid entity+action
$cases[] = array(
public function testAuthenticationBadKey() {
$client = $this->createClient();
$key = $client->authenticate($this->adminUser, $this->adminPass);
- $client->get_contact(mt_rand(), array());
+ $client->get_contact(mt_rand(), []);
}
/**