private static $cache;
/**
- * @deprecated Please use the buildOptions() method in the appropriate BAO object.
- *
* activity type
* @var array
+ * @deprecated Please use the buildOptions() method in the appropriate BAO object.
*/
private static $activityType;
* States/provinces abbreviations
* @var array
*/
- private static $stateProvinceAbbreviation = array();
+ private static $stateProvinceAbbreviation = [];
/**
* Country.
private static $countryIsoCode;
/**
- * @deprecated Please use the buildOptions() method in the appropriate BAO object.
- *
* group
* @var array
+ * @deprecated Please use the buildOptions() method in the appropriate BAO object.
*/
private static $group;
private static $worldRegions;
/**
- * @deprecated Please use the buildOptions() method in the appropriate BAO object.
- *
* activity status
* @var array
+ * @deprecated Please use the buildOptions() method in the appropriate BAO object.
*/
private static $activityStatus;
* array on success, FALSE on error.
*
*/
- public static function get($daoName, $fieldName, $params = array(), $context = NULL) {
+ public static function get($daoName, $fieldName, $params = [], $context = NULL) {
CRM_Core_DAO::buildOptionsContext($context);
$flip = !empty($params['flip']);
// Historically this was 'false' but according to the notes in
// timidly changing for 'search' only to fix world_region in search options.
$localizeDefault = in_array($context, ['search']) ? TRUE : FALSE;
// Merge params with defaults
- $params += array(
+ $params += [
'grouping' => FALSE,
'localize' => $localizeDefault,
'onlyActive' => ($context == 'validate' || $context == 'get') ? FALSE : TRUE,
'fresh' => FALSE,
'context' => $context,
- );
+ ];
$entity = CRM_Core_DAO_AllCoreTables::getBriefName(CRM_Core_DAO_AllCoreTables::getCanonicalClassName($daoName));
// Custom fields are not in the schema
if ($options && $flip) {
$options = array_flip($options);
}
- $customField->free();
return $options;
}
// Core field: load schema
$dao = new $daoName();
$fieldSpec = $dao->getFieldSpec($fieldName);
- $dao->free();
// Ensure we have the canonical name for this field
$fieldName = CRM_Utils_Array::value('name', $fieldSpec, $fieldName);
}
// Merge params with schema defaults
- $params += array(
- 'condition' => CRM_Utils_Array::value('condition', $pseudoconstant, array()),
+ $params += [
+ 'condition' => CRM_Utils_Array::value('condition', $pseudoconstant, []),
'keyColumn' => CRM_Utils_Array::value('keyColumn', $pseudoconstant),
'labelColumn' => CRM_Utils_Array::value('labelColumn', $pseudoconstant),
- );
+ ];
if ($context == 'abbreviate') {
switch ($fieldName) {
// Get list of fields for the option table
$dao = new $daoName();
$availableFields = array_keys($dao->fieldKeys());
- $dao->free();
$select = "SELECT %1 AS id, %2 AS label";
$from = "FROM %3";
- $wheres = array();
+ $wheres = [];
$order = "ORDER BY %2";
// Use machine name in certain contexts
}
// onlyActive param will automatically filter on common flags
if (!empty($params['onlyActive'])) {
- foreach (array('is_active' => 1, 'is_deleted' => 0, 'is_test' => 0, 'is_hidden' => 0) as $flag => $val) {
+ foreach (['is_active' => 1, 'is_deleted' => 0, 'is_test' => 0, 'is_hidden' => 0] as $flag => $val) {
if (in_array($flag, $availableFields)) {
$wheres[] = "$flag = $val";
}
if (in_array('domain_id', $availableFields)) {
$wheres[] = 'domain_id = ' . CRM_Core_Config::domainID();
}
- $queryParams = array(
- 1 => array($params['keyColumn'], 'String', CRM_Core_DAO::QUERY_FORMAT_NO_QUOTES),
- 2 => array($params['labelColumn'], 'String', CRM_Core_DAO::QUERY_FORMAT_NO_QUOTES),
- 3 => array($pseudoconstant['table'], 'String', CRM_Core_DAO::QUERY_FORMAT_NO_QUOTES),
- );
+ $queryParams = [
+ 1 => [$params['keyColumn'], 'String', CRM_Core_DAO::QUERY_FORMAT_NO_QUOTES],
+ 2 => [$params['labelColumn'], 'String', CRM_Core_DAO::QUERY_FORMAT_NO_QUOTES],
+ 3 => [$pseudoconstant['table'], 'String', CRM_Core_DAO::QUERY_FORMAT_NO_QUOTES],
+ ];
// Add orderColumn param
if (!empty($params['orderColumn'])) {
- $queryParams[4] = array($params['orderColumn'], 'String', CRM_Core_DAO::QUERY_FORMAT_NO_QUOTES);
+ $queryParams[4] = [$params['orderColumn'], 'String', CRM_Core_DAO::QUERY_FORMAT_NO_QUOTES];
$order = "ORDER BY %4";
}
// Support no sorting if $params[orderColumn] is FALSE
$order = "ORDER BY weight";
}
- $output = array();
+ $output = [];
$query = "$select $from";
if ($wheres) {
$query .= " WHERE " . implode($wheres, ' AND ');
while ($dao->fetch()) {
$output[$dao->id] = $dao->label;
}
- $dao->free();
// Localize results
if (!empty($params['localize']) || $pseudoconstant['table'] == 'civicrm_country' || $pseudoconstant['table'] == 'civicrm_state_province') {
- $I18nParams = array();
+ $I18nParams = [];
if (isset($fieldSpec['localize_context'])) {
$I18nParams['context'] = $fieldSpec['localize_context'];
}
// Return "Yes" and "No" for boolean fields
elseif (CRM_Utils_Array::value('type', $fieldSpec) === CRM_Utils_Type::T_BOOLEAN) {
- $output = $context == 'validate' ? array(0, 1) : CRM_Core_SelectValues::boolean();
+ $output = $context == 'validate' ? [0, 1] : CRM_Core_SelectValues::boolean();
CRM_Utils_Hook::fieldOptions($entity, $fieldName, $output, $params);
return $flip ? array_flip($output) : $output;
}
}
/**
- * DEPRECATED generic populate method.
+ * @deprecated generic populate method.
* All pseudoconstant functions that use this method are also @deprecated
*
* The static array $var is populated from the db
}
$object->find();
- $var = array();
+ $var = [];
while ($object->fetch()) {
$var[$object->$key] = $object->$retrieve;
}
$index .= '_' . (int) $onlyComponentActivities;
if (NULL === self::$activityType) {
- self::$activityType = array();
+ self::$activityType = [];
}
if (!isset(self::$activityType[$index]) || $reset) {
$componentClause = " v.component_id IS NOT NULL";
}
- $componentIds = array();
+ $componentIds = [];
$compInfo = CRM_Core_Component::getEnabledComponents();
// build filter for listing activity types only if their
if ($limit) {
$countryIsoCodes = self::countryIsoCode();
$limitCodes = CRM_Core_BAO_Country::provinceLimit();
- $limitIds = array();
+ $limitIds = [];
foreach ($limitCodes as $code) {
$limitIds = array_merge($limitIds, array_keys($countryIsoCodes, $code));
}
$tsLocale = CRM_Core_I18n::getLocale();
if ($tsLocale != '' and $tsLocale != 'en_US') {
$i18n = CRM_Core_I18n::singleton();
- $i18n->localizeArray(self::$stateProvince, array(
+ $i18n->localizeArray(self::$stateProvince, [
'context' => 'province',
- ));
+ ]);
self::$stateProvince = CRM_Utils_Array::asort(self::$stateProvince);
}
}
$query = "SELECT abbreviation
FROM civicrm_state_province
WHERE id = %1";
- $params = array(
- 1 => array(
+ $params = [
+ 1 => [
$id,
'Integer',
- ),
- );
+ ],
+ ];
self::$stateProvinceAbbreviation[$id] = CRM_Core_DAO::singleValueQuery($query, $params);
}
return self::$stateProvinceAbbreviation[$id];
if ($limit) {
$countryIsoCodes = self::countryIsoCode();
$limitCodes = CRM_Core_BAO_Country::provinceLimit();
- $limitIds = array();
+ $limitIds = [];
foreach ($limitCodes as $code) {
$tmpArray = array_keys($countryIsoCodes, $code);
*/
public static function stateProvinceAbbreviationForCountry($countryID) {
if (!isset(\Civi::$statics[__CLASS__]['stateProvinceAbbreviationForCountry'][$countryID])) {
- \Civi::$statics[__CLASS__]['stateProvinceAbbreviationForCountry'][$countryID] = array();
+ \Civi::$statics[__CLASS__]['stateProvinceAbbreviationForCountry'][$countryID] = [];
}
self::populate(\Civi::$statics[__CLASS__]['stateProvinceAbbreviationForCountry'][$countryID], 'CRM_Core_DAO_StateProvince', TRUE, 'abbreviation', 'is_active', "country_id = " . (int) $countryID, 'abbreviation');
return \Civi::$statics[__CLASS__]['stateProvinceAbbreviationForCountry'][$countryID];
if (($id && !CRM_Utils_Array::value($id, self::$country)) || !self::$country || !$id) {
$config = CRM_Core_Config::singleton();
- $limitCodes = array();
+ $limitCodes = [];
if ($applyLimit) {
// limit the country list to the countries specified in CIVICRM_COUNTRY_LIMIT
// K/P: We need to fix this, i dont think it works with new setting files
$limitCodes = CRM_Core_BAO_Country::countryLimit();
if (!is_array($limitCodes)) {
- $limitCodes = array(
+ $limitCodes = [
$config->countryLimit => 1,
- );
+ ];
}
$limitCodes = array_intersect(self::countryIsoCode(), $limitCodes);
$tsLocale = CRM_Core_I18n::getLocale();
if ($tsLocale != '' and $tsLocale != 'en_US') {
$i18n = CRM_Core_I18n::singleton();
- $i18n->localizeArray(self::$country, array(
+ $i18n->localizeArray(self::$country, [
'context' => 'country',
- ));
+ ]);
self::$country = CRM_Utils_Array::asort(self::$country);
}
}
public static function &relationshipType($valueColumnName = 'label', $reset = FALSE, $isActive = 1) {
$cacheKey = $valueColumnName . '::' . $isActive;
if (!CRM_Utils_Array::value($cacheKey, self::$relationshipType) || $reset) {
- self::$relationshipType[$cacheKey] = array();
+ self::$relationshipType[$cacheKey] = [];
//now we have name/label columns CRM-3336
$column_a_b = "{$valueColumnName}_a_b";
$relationshipTypeDAO->find();
while ($relationshipTypeDAO->fetch()) {
- self::$relationshipType[$cacheKey][$relationshipTypeDAO->id] = array(
+ self::$relationshipType[$cacheKey][$relationshipTypeDAO->id] = [
'id' => $relationshipTypeDAO->id,
$column_a_b => $relationshipTypeDAO->$column_a_b,
$column_b_a => $relationshipTypeDAO->$column_b_a,
'contact_type_b' => "$relationshipTypeDAO->contact_type_b",
'contact_sub_type_a' => "$relationshipTypeDAO->contact_sub_type_a",
'contact_sub_type_b' => "$relationshipTypeDAO->contact_sub_type_b",
- );
+ ];
}
}
$query = "SELECT name FROM civicrm_currency";
$dao = CRM_Core_DAO::executeQuery($query);
- $currencyCode = array();
+ $currencyCode = [];
while ($dao->fetch()) {
self::$currencyCode[] = $dao->name;
}
*/
public static function &activityStatus($column = 'label') {
if (NULL === self::$activityStatus) {
- self::$activityStatus = array();
+ self::$activityStatus = [];
}
if (!array_key_exists($column, self::$activityStatus)) {
- self::$activityStatus[$column] = array();
+ self::$activityStatus[$column] = [];
self::$activityStatus[$column] = CRM_Core_OptionGroup::values('activity_status', FALSE, FALSE, FALSE, NULL, $column);
}
*/
public static function &visibility($column = 'label') {
if (!isset(self::$visibility)) {
- self::$visibility = array();
+ self::$visibility = [];
}
if (!isset(self::$visibility[$column])) {
$cacheKey = "{$countryID}_{$field}";
if (!$_cache) {
- $_cache = array();
+ $_cache = [];
}
if (!empty($_cache[$cacheKey])) {
FROM civicrm_state_province
WHERE country_id = %1
ORDER BY name";
- $params = array(
- 1 => array(
+ $params = [
+ 1 => [
$countryID,
'Integer',
- ),
- );
+ ],
+ ];
$dao = CRM_Core_DAO::executeQuery($query, $params);
- $result = array();
+ $result = [];
while ($dao->fetch()) {
$result[$dao->id] = $dao->name;
}
$tsLocale = CRM_Core_I18n::getLocale();
if ($tsLocale != '' and $tsLocale != 'en_US') {
$i18n = CRM_Core_I18n::singleton();
- $i18n->localizeArray($result, array(
+ $i18n->localizeArray($result, [
'context' => 'province',
- ));
+ ]);
$result = CRM_Utils_Array::asort($result);
}
$dao = CRM_Core_DAO::executeQuery($query);
- $result = array();
+ $result = [];
while ($dao->fetch()) {
$result[$dao->id] = $dao->abbreviation . ': ' . $dao->name;
}
$cacheKey = "{$stateID}_name";
if (!$_cache) {
- $_cache = array();
+ $_cache = [];
}
if (!empty($_cache[$cacheKey])) {
FROM civicrm_county
WHERE state_province_id = %1
ORDER BY name";
- $params = array(
- 1 => array(
+ $params = [
+ 1 => [
$stateID,
'Integer',
- ),
- );
+ ],
+ ];
$dao = CRM_Core_DAO::executeQuery($query, $params);
- $result = array();
+ $result = [];
while ($dao->fetch()) {
$result[$dao->id] = $dao->name;
}
FROM civicrm_state_province
WHERE id = %1
";
- $params = array(1 => array($stateID, 'Integer'));
+ $params = [1 => [$stateID, 'Integer']];
return CRM_Core_DAO::singleValueQuery($query, $params);
}
*/
public static function greeting($filter, $columnName = 'label') {
if (!isset(Civi::$statics[__CLASS__]['greeting'])) {
- Civi::$statics[__CLASS__]['greeting'] = array();
+ Civi::$statics[__CLASS__]['greeting'] = [];
}
$index = $filter['greeting_type'] . '_' . $columnName;
*/
public static function &getExtensions() {
if (!self::$extensions) {
- self::$extensions = array();
+ self::$extensions = [];
$sql = '
SELECT full_name, label
FROM civicrm_extension
return CRM_Extension_System::singleton()->getMapper()->getActiveModuleFiles($fresh);
}
-
/**
* Get all tax rates.
*
*/
public static function getTaxRates() {
if (!isset(Civi::$statics[__CLASS__]['taxRates'])) {
- Civi::$statics[__CLASS__]['taxRates'] = array();
- $option = civicrm_api3('option_value', 'get', array(
+ Civi::$statics[__CLASS__]['taxRates'] = [];
+ $option = civicrm_api3('option_value', 'get', [
'sequential' => 1,
'option_group_id' => 'account_relationship',
'name' => 'Sales Tax Account is',
- ));
- $value = array();
+ ]);
+ $value = [];
if ($option['count'] !== 0) {
if ($option['count'] > 1) {
foreach ($option['values'] as $opt) {
else {
$value[] = $option['values'][0]['value'];
}
- $where = 'AND efa.account_relationship IN (' . implode(', ', $value) . ' )';
+ $where = 'AND efa.account_relationship IN (' . implode(', ', $value) . ' )';
}
else {
$where = '';
* @return array
*/
public static function emailOnHoldOptions() {
- return array(
+ return [
'0' => ts('No'),
'1' => ts('On Hold Bounce'),
'2' => ts('On Hold Opt Out'),
- );
+ ];
}
}