*
* @var array
*/
- static $_links = NULL;
+ public static $_links = NULL;
/**
* We use desc to remind us what that column is, name is used in the tpl
*
* @var array
*/
- static $_columnHeaders;
+ public static $_columnHeaders;
/**
* Properties of contact we're interested in displaying
* @var array
*/
- static $_properties = array(
+ public static $_properties = [
'contact_id',
'contact_type',
'contact_sub_type',
'do_not_email',
'do_not_phone',
'do_not_mail',
- );
+ ];
/**
* FormValues is the array returned by exportValues called on
$searchContext = ($context) ? "&context=$context" : NULL;
if (!(self::$_links)) {
- self::$_links = array(
- CRM_Core_Action::VIEW => array(
+ self::$_links = [
+ CRM_Core_Action::VIEW => [
'name' => ts('View'),
'url' => 'civicrm/contact/view',
'class' => 'no-popup',
'qs' => "reset=1&cid=%%id%%{$searchContext}{$extraParams}",
'title' => ts('View Contact Details'),
'ref' => 'view-contact',
- ),
- CRM_Core_Action::UPDATE => array(
+ ],
+ CRM_Core_Action::UPDATE => [
'name' => ts('Edit'),
'url' => 'civicrm/contact/add',
'class' => 'no-popup',
'qs' => "reset=1&action=update&cid=%%id%%{$searchContext}{$extraParams}",
'title' => ts('Edit Contact Details'),
'ref' => 'edit-contact',
- ),
- );
+ ],
+ ];
$config = CRM_Core_Config::singleton();
//CRM-16552: mapAPIKey is not mandatory as google no longer requires an API Key
if ($config->mapProvider && ($config->mapAPIKey || $config->mapProvider == 'Google')) {
- self::$_links[CRM_Core_Action::MAP] = array(
+ self::$_links[CRM_Core_Action::MAP] = [
'name' => ts('Map'),
'url' => 'civicrm/contact/map',
'qs' => "reset=1&cid=%%id%%{$searchContext}{$extraParams}",
'title' => ts('Map Contact'),
- );
+ ];
}
// Adding Context Menu Links in more action
$qs = "atype=3&action=add&reset=1&cid=%%id%%{$extraParams}";
}
- self::$_links[$counter++] = array(
+ self::$_links[$counter++] = [
'name' => $value['title'],
'url' => $url,
'qs' => $qs,
'title' => $value['title'],
'ref' => $value['ref'],
'class' => CRM_Utils_Array::value('class', $value),
- );
+ ];
}
}
}
*/
public function &getColHeads($action = NULL, $output = NULL) {
$colHeads = self::_getColumnHeaders();
- $colHeads[] = array('desc' => ts('Actions'), 'name' => ts('Action'));
+ $colHeads[] = ['desc' => ts('Actions'), 'name' => ts('Action')];
return $colHeads;
}
// unset return property elements that we don't care
if (!empty($this->_returnProperties)) {
- $doNotCareElements = array(
+ $doNotCareElements = [
'contact_type',
'contact_sub_type',
'sort_name',
- );
+ ];
foreach ($doNotCareElements as $value) {
unset($this->_returnProperties[$value]);
}
}
if ($output == CRM_Core_Selector_Controller::EXPORT) {
- $csvHeaders = array(ts('Contact ID'), ts('Contact Type'));
+ $csvHeaders = [ts('Contact ID'), ts('Contact Type')];
foreach ($this->getColHeads($action, $output) as $column) {
if (array_key_exists('name', $column)) {
$csvHeaders[] = $column['name'];
$headers = $csvHeaders;
}
elseif ($output == CRM_Core_Selector_Controller::SCREEN) {
- $csvHeaders = array(ts('Name'));
+ $csvHeaders = [ts('Name')];
foreach ($this->getColHeads($action, $output) as $key => $column) {
if (array_key_exists('name', $column) &&
$column['name'] &&
elseif ($this->_ufGroupID) {
// we dont use the cached value of column headers
// since it potentially changed because of the profile selected
- static $skipFields = array('group', 'tag');
+ static $skipFields = ['group', 'tag'];
$direction = CRM_Utils_Sort::ASCENDING;
$empty = TRUE;
if (!self::$_columnHeaders) {
- self::$_columnHeaders = array(
- array('name' => ''),
- array(
+ self::$_columnHeaders = [
+ ['name' => ''],
+ [
'name' => ts('Name'),
'sort' => 'sort_name',
'direction' => CRM_Utils_Sort::ASCENDING,
- ),
- );
+ ],
+ ];
$locationTypes = CRM_Core_DAO_Address::buildOptions('location_type_id', 'validate');
$locationTypeName = $locationTypes[$lType];
}
- if (in_array($fieldName, array(
+ if (in_array($fieldName, [
'phone',
'im',
'email',
- ))) {
+ ])) {
if ($type) {
$name = "`$locationTypeName-$fieldName-$type`";
}
$name = 'contact_id';
}
- self::$_columnHeaders[] = array(
+ self::$_columnHeaders[] = [
'name' => $field['title'],
'sort' => $name,
'direction' => $direction,
- );
+ ];
$direction = CRM_Utils_Sort::DONTCARE;
$empty = FALSE;
}
// if we dont have any valid columns, dont add the implicit ones
// this allows the template to check on emptiness of column headers
if ($empty) {
- self::$_columnHeaders = array();
+ self::$_columnHeaders = [];
}
else {
- self::$_columnHeaders[] = array('desc' => ts('Actions'), 'name' => ts('Action'));
+ self::$_columnHeaders[] = ['desc' => ts('Actions'), 'name' => ts('Action')];
}
}
$headers = self::$_columnHeaders;
}
elseif (!empty($this->_returnProperties)) {
- self::$_columnHeaders = array(
- array('name' => ''),
- array(
+ self::$_columnHeaders = [
+ ['name' => ''],
+ [
'name' => ts('Name'),
'sort' => 'sort_name',
'direction' => CRM_Utils_Sort::ASCENDING,
- ),
- );
+ ],
+ ];
$properties = self::makeProperties($this->_returnProperties);
foreach ($properties as $prop) {
CRM_Core_PseudoConstant::getKey('CRM_Core_DAO_Address', 'location_type_id', $loc)
)
);
- // use field name instead of table alias
- $prop = $fld;
+
}
elseif (isset($this->_query->_fields[$prop]) && isset($this->_query->_fields[$prop]['title'])) {
$title = $this->_query->_fields[$prop]['title'];
$title = '';
}
- self::$_columnHeaders[] = array('name' => $title, 'sort' => $prop);
+ self::$_columnHeaders[] = ['name' => $title, 'sort' => $prop];
}
- self::$_columnHeaders[] = array('name' => ts('Actions'));
+ self::$_columnHeaders[] = ['name' => ts('Actions')];
$headers = self::$_columnHeaders;
}
else {
}
// process the result of the query
- $rows = array();
- $permissions = array(CRM_Core_Permission::getPermission());
+ $rows = [];
+ $permissions = [CRM_Core_Permission::getPermission()];
if (CRM_Core_Permission::check('delete contacts')) {
$permissions[] = CRM_Core_Permission::DELETE;
}
if ($this->_ufGroupID) {
$locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id');
- $names = array();
- static $skipFields = array('group', 'tag');
+ $names = [];
+ static $skipFields = ['group', 'tag'];
foreach ($this->_fields as $key => $field) {
if (!empty($field['in_selector']) &&
!in_array($key, $skipFields)
}
$locationTypeName = str_replace(' ', '_', $locationTypeName);
- if (in_array($fieldName, array(
+ if (in_array($fieldName, [
'phone',
'im',
'email',
- ))) {
+ ])) {
if ($type) {
$names[] = "{$locationTypeName}-{$fieldName}-{$type}";
}
//check explicitly added contact to a Smart Group.
$groupID = CRM_Utils_Array::value('group', $this->_formValues);
- $pseudoconstants = array();
+ $pseudoconstants = [];
// for CRM-3157 purposes
if (in_array('world_region', $names)) {
- $pseudoconstants['world_region'] = array(
+ $pseudoconstants['world_region'] = [
'dbName' => 'worldregion_id',
'values' => CRM_Core_PseudoConstant::worldRegion(),
- );
+ ];
}
foreach ($resultSet as $result) {
- $row = array();
+ $row = [];
$this->_query->convertToPseudoNames($result);
// the columns we are interested in
foreach ($names as $property) {
$row[$property] = $result->$property . " ({$providerName})";
}
}
- elseif (in_array($property, array(
+ elseif (in_array($property, [
'addressee',
'email_greeting',
'postal_greeting',
- ))) {
+ ])) {
$greeting = $property . '_display';
$row[$property] = $result->$greeting;
}
) {
$contactID = $result->contact_id;
if ($contactID) {
- $gcParams = array(
+ $gcParams = [
'contact_id' => $contactID,
'group_id' => $groupID,
- );
+ ];
- $gcDefaults = array();
+ $gcDefaults = [];
CRM_Core_DAO::commonRetrieve('CRM_Contact_DAO_GroupContact', $gcParams, $gcDefaults);
if (empty($gcDefaults)) {
if (!empty($this->_formValues['deleted_contacts']) && CRM_Core_Permission::check('access deleted contacts')
) {
- $links = array(
- array(
+ $links = [
+ [
'name' => ts('View'),
'url' => 'civicrm/contact/view',
'qs' => 'reset=1&cid=%%id%%',
'class' => 'no-popup',
'title' => ts('View Contact Details'),
- ),
- array(
+ ],
+ [
'name' => ts('Restore'),
'url' => 'civicrm/contact/view/delete',
'qs' => 'reset=1&cid=%%id%%&restore=1',
'title' => ts('Restore Contact'),
- ),
- );
+ ],
+ ];
if (CRM_Core_Permission::check('delete contacts')) {
- $links[] = array(
+ $links[] = [
'name' => ts('Delete Permanently'),
'url' => 'civicrm/contact/view/delete',
'qs' => 'reset=1&cid=%%id%%&skip_undelete=1',
'title' => ts('Permanently Delete Contact'),
- );
+ ];
}
$row['action'] = CRM_Core_Action::formLink(
$links,
NULL,
- array('id' => $result->contact_id),
+ ['id' => $result->contact_id],
ts('more'),
FALSE,
'contact.selector.row',
$row['action'] = CRM_Core_Action::formLink(
$links,
$mask,
- array('id' => $result->contact_id),
+ ['id' => $result->contact_id],
ts('more'),
FALSE,
'contact.selector.row',
$row['action'] = CRM_Core_Action::formLink(
$links,
$mapMask,
- array('id' => $result->contact_id),
+ ['id' => $result->contact_id],
ts('more'),
FALSE,
'contact.selector.row',
*/
public function addActions(&$rows) {
- $basicPermissions = CRM_Core_Permission::check('delete contacts') ? array(CRM_Core_Permission::DELETE) : array();
+ $basicPermissions = CRM_Core_Permission::check('delete contacts') ? [CRM_Core_Permission::DELETE] : [];
// get permissions on an individual level (CRM-12645)
// @todo look at storing this to the session as this is called twice during search results render.
foreach ($rows as $id => & $row) {
$links = $links_template;
if (in_array($id, $can_edit_list)) {
- $mask = CRM_Core_Action::mask(array_merge(array(CRM_Core_Permission::EDIT), $basicPermissions));
+ $mask = CRM_Core_Action::mask(array_merge([CRM_Core_Permission::EDIT], $basicPermissions));
}
else {
- $mask = CRM_Core_Action::mask(array_merge(array(CRM_Core_Permission::VIEW), $basicPermissions));
+ $mask = CRM_Core_Action::mask(array_merge([CRM_Core_Permission::VIEW], $basicPermissions));
}
if ((!is_numeric(CRM_Utils_Array::value('geo_code_1', $row))) &&
if (!empty($this->_formValues['deleted_contacts']) && CRM_Core_Permission::check('access deleted contacts')
) {
- $links = array(
- array(
+ $links = [
+ [
'name' => ts('View'),
'url' => 'civicrm/contact/view',
'qs' => 'reset=1&cid=%%id%%',
'class' => 'no-popup',
'title' => ts('View Contact Details'),
- ),
- array(
+ ],
+ [
'name' => ts('Restore'),
'url' => 'civicrm/contact/view/delete',
'qs' => 'reset=1&cid=%%id%%&restore=1',
'title' => ts('Restore Contact'),
- ),
- );
+ ],
+ ];
if (CRM_Core_Permission::check('delete contacts')) {
- $links[] = array(
+ $links[] = [
'name' => ts('Delete Permanently'),
'url' => 'civicrm/contact/view/delete',
'qs' => 'reset=1&cid=%%id%%&skip_undelete=1',
'title' => ts('Permanently Delete Contact'),
- );
+ ];
}
$row['action'] = CRM_Core_Action::formLink(
$links,
NULL,
- array('id' => $row['contact_id']),
+ ['id' => $row['contact_id']],
ts('more'),
FALSE,
'contact.selector.actions',
$row['action'] = CRM_Core_Action::formLink(
$links,
$mask,
- array('id' => $row['contact_id']),
+ ['id' => $row['contact_id']],
ts('more'),
FALSE,
'contact.selector.actions',
$selectSQL = "SELECT DISTINCT %1, contact_a.id, contact_a.sort_name";
- $sql = str_ireplace(array("SELECT contact_a.id as contact_id", "SELECT contact_a.id as id"), $selectSQL, $sql);
+ $sql = str_ireplace(["SELECT contact_a.id as contact_id", "SELECT contact_a.id as id"], $selectSQL, $sql);
try {
Civi::service('prevnext')->fillWithSql($cacheKey, $sql, [1 => [$cacheKey, 'String']]);
}
'address_options', TRUE, NULL, TRUE
);
- self::$_columnHeaders = array(
- 'contact_type' => array('desc' => ts('Contact Type')),
- 'sort_name' => array(
+ self::$_columnHeaders = [
+ 'contact_type' => ['desc' => ts('Contact Type')],
+ 'sort_name' => [
'name' => ts('Name'),
'sort' => 'sort_name',
'direction' => CRM_Utils_Sort::ASCENDING,
- ),
- );
+ ],
+ ];
- $defaultAddress = array(
- 'street_address' => array('name' => ts('Address')),
- 'city' => array(
+ $defaultAddress = [
+ 'street_address' => ['name' => ts('Address')],
+ 'city' => [
'name' => ts('City'),
'sort' => 'city',
'direction' => CRM_Utils_Sort::DONTCARE,
- ),
- 'state_province' => array(
+ ],
+ 'state_province' => [
'name' => ts('State'),
'sort' => 'state_province',
'direction' => CRM_Utils_Sort::DONTCARE,
- ),
- 'postal_code' => array(
+ ],
+ 'postal_code' => [
'name' => ts('Postal'),
'sort' => 'postal_code',
'direction' => CRM_Utils_Sort::DONTCARE,
- ),
- 'country' => array(
+ ],
+ 'country' => [
'name' => ts('Country'),
'sort' => 'country',
'direction' => CRM_Utils_Sort::DONTCARE,
- ),
- );
+ ],
+ ];
foreach ($defaultAddress as $columnName => $column) {
if (!empty($addressOptions[$columnName])) {
}
}
- self::$_columnHeaders['email'] = array(
+ self::$_columnHeaders['email'] = [
'name' => ts('Email'),
'sort' => 'email',
'direction' => CRM_Utils_Sort::DONTCARE,
- );
+ ];
- self::$_columnHeaders['phone'] = array('name' => ts('Phone'));
+ self::$_columnHeaders['phone'] = ['name' => ts('Phone')];
}
return self::$_columnHeaders;
}
$queryOperator
);
}
- $value = $query->searchQuery(0, 0, $sort,
- FALSE, FALSE, FALSE,
- FALSE, FALSE
- );
- return $value;
+ return $query->searchQuery(0, 0, $sort);
}
/**
* @return array
*/
public function &makeProperties(&$returnProperties) {
- $properties = array();
+ $properties = [];
foreach ($returnProperties as $name => $value) {
if ($name != 'location') {
// special handling for group and tag
- if (in_array($name, array('group', 'tag'))) {
+ if (in_array($name, ['group', 'tag'])) {
$name = "{$name}s";
}
// special handling for notes
- if (in_array($name, array('note', 'note_subject', 'note_body'))) {
+ if (in_array($name, ['note', 'note_subject', 'note_body'])) {
$name = "notes";
}