From cf0d1c08135c8b97ab513fd3da5f76dabe74baab Mon Sep 17 00:00:00 2001 From: eileen Date: Fri, 5 Apr 2019 17:21:19 +1300 Subject: [PATCH] Autoformat - just CRM/ACL dir --- CRM/ACL/API.php | 16 +++--- CRM/ACL/BAO/ACL.php | 54 +++++++++---------- CRM/ACL/BAO/Cache.php | 15 ++++-- CRM/ACL/BAO/EntityRole.php | 4 +- CRM/ACL/DAO/ACL.php | 4 +- CRM/ACL/DAO/Cache.php | 2 +- CRM/ACL/DAO/EntityRole.php | 2 +- CRM/ACL/Form/ACL.php | 52 +++++++++---------- CRM/ACL/Form/ACLBasic.php | 22 ++++---- CRM/ACL/Form/EntityRole.php | 6 +-- CRM/ACL/Form/WordPress/Permissions.php | 32 ++++++------ CRM/ACL/Page/ACL.php | 72 +++++++++++++------------- CRM/ACL/Page/ACLBasic.php | 26 +++++----- CRM/ACL/Page/EntityRole.php | 38 +++++++------- 14 files changed, 171 insertions(+), 174 deletions(-) diff --git a/CRM/ACL/API.php b/CRM/ACL/API.php index cff9541c49..80855ac01b 100644 --- a/CRM/ACL/API.php +++ b/CRM/ACL/API.php @@ -125,16 +125,12 @@ class CRM_ACL_API { return $deleteClause; } - $where = implode(' AND ', - array( - CRM_ACL_BAO_ACL::whereClause($type, - $tables, - $whereTables, - $contactID - ), - $deleteClause, - ) + $whereClause = CRM_ACL_BAO_ACL::whereClause($type, + $tables, + $whereTables, + $contactID ); + $where = implode(' AND ', [$whereClause, $deleteClause]); // Add permission on self if we really hate our server or have hardly any contacts. if (!$skipOwnContactClause && $contactID && (CRM_Core_Permission::check('edit my contact') || @@ -203,7 +199,7 @@ class CRM_ACL_API { ) { if (!isset(Civi::$statics[__CLASS__]) || !isset(Civi::$statics[__CLASS__]['group_permission'])) { - Civi::$statics[__CLASS__]['group_permission'] = array(); + Civi::$statics[__CLASS__]['group_permission'] = []; } if (!$contactID) { diff --git a/CRM/ACL/BAO/ACL.php b/CRM/ACL/BAO/ACL.php index 7c0eb1af7c..64ee29b15d 100644 --- a/CRM/ACL/BAO/ACL.php +++ b/CRM/ACL/BAO/ACL.php @@ -51,10 +51,10 @@ class CRM_ACL_BAO_ACL extends CRM_ACL_DAO_ACL { */ public static function entityTable() { if (!self::$_entityTable) { - self::$_entityTable = array( + self::$_entityTable = [ 'civicrm_contact' => ts('Contact'), 'civicrm_acl_role' => ts('ACL Role'), - ); + ]; } return self::$_entityTable; } @@ -64,12 +64,12 @@ class CRM_ACL_BAO_ACL extends CRM_ACL_DAO_ACL { */ public static function objectTable() { if (!self::$_objectTable) { - self::$_objectTable = array( + self::$_objectTable = [ 'civicrm_contact' => ts('Contact'), 'civicrm_group' => ts('Group'), 'civicrm_saved_search' => ts('Contact Group'), 'civicrm_admin' => ts('Import'), - ); + ]; } return self::$_objectTable; } @@ -79,14 +79,14 @@ class CRM_ACL_BAO_ACL extends CRM_ACL_DAO_ACL { */ public static function operation() { if (!self::$_operation) { - self::$_operation = array( + self::$_operation = [ 'View' => ts('View'), 'Edit' => ts('Edit'), 'Create' => ts('Create'), 'Delete' => ts('Delete'), 'Search' => ts('Search'), 'All' => ts('All'), - ); + ]; } return self::$_operation; } @@ -120,14 +120,14 @@ class CRM_ACL_BAO_ACL extends CRM_ACL_DAO_ACL { CRM_Core_Error::deprecatedFunctionWarning('unknown - this is really old & not used in core'); $dao = new CRM_ACL_DAO_ACL(); - $t = array( + $t = [ 'ACL' => self::getTableName(), 'ACLRole' => 'civicrm_acl_role', 'ACLEntityRole' => CRM_ACL_DAO_EntityRole::getTableName(), 'Contact' => CRM_Contact_DAO_Contact::getTableName(), 'Group' => CRM_Contact_DAO_Group::getTableName(), 'GroupContact' => CRM_Contact_DAO_GroupContact::getTableName(), - ); + ]; $contact_id = CRM_Core_Session::getLoggedInContactID(); @@ -158,7 +158,7 @@ class CRM_ACL_BAO_ACL extends CRM_ACL_DAO_ACL { } } - $query = array(); + $query = []; /* Query for permissions granted to all contacts in the domain */ @@ -261,9 +261,9 @@ class CRM_ACL_BAO_ACL extends CRM_ACL_DAO_ACL { $dao->query($union); - $allow = array(0); - $deny = array(0); - $override = array(); + $allow = [0]; + $deny = [0]; + $override = []; while ($dao->fetch()) { /* Instant bypass for the following cases: @@ -338,7 +338,7 @@ class CRM_ACL_BAO_ACL extends CRM_ACL_DAO_ACL { public static function getClause($table, $id, &$tables) { $table = CRM_Utils_Type::escape($table, 'String'); $id = CRM_Utils_Type::escape($id, 'Integer'); - $whereTables = array(); + $whereTables = []; $ssTable = CRM_Contact_BAO_SavedSearch::getTableName(); @@ -367,7 +367,7 @@ class CRM_ACL_BAO_ACL extends CRM_ACL_DAO_ACL { * Assoc. array of the ACL rule's properties */ public function toArray($format = '%s', $hideEmpty = FALSE) { - $result = array(); + $result = []; if (!self::$_fieldKeys) { $fields = CRM_ACL_DAO_ACL::fields(); @@ -397,7 +397,7 @@ class CRM_ACL_BAO_ACL extends CRM_ACL_DAO_ACL { * Array of assoc. arrays of ACL rules */ public static function &getACLs($contact_id = NULL, $group_id = NULL, $aclRoles = FALSE) { - $results = array(); + $results = []; if (empty($contact_id)) { return $results; @@ -505,7 +505,7 @@ class CRM_ACL_BAO_ACL extends CRM_ACL_DAO_ACL { } } - $results = array(); + $results = []; $rule->query($query); @@ -535,7 +535,7 @@ class CRM_ACL_BAO_ACL extends CRM_ACL_DAO_ACL { $acl = self::getTableName(); $c2g = CRM_Contact_BAO_GroupContact::getTableName(); $group = CRM_Contact_BAO_Group::getTableName(); - $results = array(); + $results = []; if ($contact_id) { $query = " @@ -603,7 +603,7 @@ SELECT $acl.* AND $c2g.contact_id = $contact_id AND $c2g.status = 'Added'"; - $results = array(); + $results = []; $rule->query($query); @@ -644,7 +644,7 @@ SELECT $acl.* * Assoc array of ACL rules */ public static function &getAllByContact($contact_id) { - $result = array(); + $result = []; /* First, the contact-specific ACLs, including ACL Roles */ $result += self::getACLs($contact_id, NULL, TRUE); @@ -718,7 +718,7 @@ SELECT count( a.id ) AND a.object_table = %1 AND a.id IN ( $aclKeys ) "; - $params = array(1 => array($str, 'String')); + $params = [1 => [$str, 'String']]; $count = CRM_Core_DAO::singleValueQuery($query, $params); return ($count) ? TRUE : FALSE; @@ -736,7 +736,7 @@ SELECT count( a.id ) $acls = CRM_ACL_BAO_Cache::build($contactID); $whereClause = NULL; - $clauses = array(); + $clauses = []; if (!empty($acls)) { $aclKeys = array_keys($acls); @@ -755,12 +755,12 @@ ORDER BY a.object_id $dao = CRM_Core_DAO::executeQuery($query); // do an or of all the where clauses u see - $ids = array(); + $ids = []; while ($dao->fetch()) { // make sure operation matches the type TODO if (self::matchType($type, $dao->operation)) { if (!$dao->object_id) { - $ids = array(); + $ids = []; $whereClause = ' ( 1 ) '; break; } @@ -834,7 +834,7 @@ SELECT g.* ) { $userCacheKey = "{$contactID}_{$type}_{$tableName}_" . CRM_Core_Config::domainID() . '_' . md5(implode(',', array_merge((array) $allGroups, (array) $includedGroups))); if (empty(Civi::$statics[__CLASS__]['permissioned_groups'])) { - Civi::$statics[__CLASS__]['permissioned_groups'] = array(); + Civi::$statics[__CLASS__]['permissioned_groups'] = []; } if (!empty(Civi::$statics[__CLASS__]['permissioned_groups'][$userCacheKey])) { return Civi::$statics[__CLASS__]['permissioned_groups'][$userCacheKey]; @@ -846,7 +846,7 @@ SELECT g.* $acls = CRM_ACL_BAO_Cache::build($contactID); - $ids = array(); + $ids = []; if (!empty($acls)) { $aclKeys = array_keys($acls); $aclKeys = implode(',', $aclKeys); @@ -855,7 +855,7 @@ SELECT g.* $cache = CRM_Utils_Cache::singleton(); $ids = $cache->get($cacheKey); if (!$ids) { - $ids = array(); + $ids = []; $query = " SELECT a.operation, a.object_id FROM civicrm_acl_cache c, civicrm_acl a @@ -866,7 +866,7 @@ SELECT a.operation, a.object_id GROUP BY a.operation,a.object_id ORDER BY a.object_id "; - $params = array(1 => array($tableName, 'String')); + $params = [1 => [$tableName, 'String']]; $dao = CRM_Core_DAO::executeQuery($query, $params); while ($dao->fetch()) { if ($dao->object_id) { diff --git a/CRM/ACL/BAO/Cache.php b/CRM/ACL/BAO/Cache.php index 2884ce8d68..f5ca812269 100644 --- a/CRM/ACL/BAO/Cache.php +++ b/CRM/ACL/BAO/Cache.php @@ -45,7 +45,7 @@ class CRM_ACL_BAO_Cache extends CRM_ACL_DAO_Cache { */ public static function &build($id) { if (!self::$_cache) { - self::$_cache = array(); + self::$_cache = []; } if (array_key_exists($id, self::$_cache)) { @@ -75,7 +75,7 @@ SELECT acl_id FROM civicrm_acl_cache WHERE contact_id = %1 "; - $params = array(1 => array($id, 'Integer')); + $params = [1 => [$id, 'Integer']]; if ($id == 0) { $query .= " OR contact_id IS NULL"; @@ -83,7 +83,7 @@ SELECT acl_id $dao = CRM_Core_DAO::executeQuery($query, $params); - $cache = array(); + $cache = []; while ($dao->fetch()) { $cache[$dao->acl_id] = 1; } @@ -122,7 +122,7 @@ SELECT acl_id DELETE FROM civicrm_acl_cache WHERE contact_id = %1 "; - $params = array(1 => array($id, 'Integer')); + $params = [1 => [$id, 'Integer']]; CRM_Core_DAO::executeQuery($query, $params); } @@ -154,7 +154,12 @@ FROM civicrm_acl_cache WHERE modified_date IS NULL OR (modified_date <= %1) "; - $params = array(1 => array(CRM_Contact_BAO_GroupContactCache::getCacheInvalidDateTime(), 'String')); + $params = [ + 1 => [ + CRM_Contact_BAO_GroupContactCache::getCacheInvalidDateTime(), + 'String', + ], + ]; CRM_Core_DAO::singleValueQuery($query, $params); // CRM_Core_DAO::singleValueQuery("TRUNCATE TABLE civicrm_acl_contact_cache"); // No, force-commits transaction diff --git a/CRM/ACL/BAO/EntityRole.php b/CRM/ACL/BAO/EntityRole.php index eb12167be4..a329052b80 100644 --- a/CRM/ACL/BAO/EntityRole.php +++ b/CRM/ACL/BAO/EntityRole.php @@ -44,10 +44,10 @@ class CRM_ACL_BAO_EntityRole extends CRM_ACL_DAO_EntityRole { */ public static function entityTable() { if (!self::$_entityTable) { - self::$_entityTable = array( + self::$_entityTable = [ 'civicrm_contact' => ts('Contact'), 'civicrm_group' => ts('Group'), - ); + ]; } return self::$_entityTable; } diff --git a/CRM/ACL/DAO/ACL.php b/CRM/ACL/DAO/ACL.php index 68ae1b22d8..a1d1b72bd3 100644 --- a/CRM/ACL/DAO/ACL.php +++ b/CRM/ACL/DAO/ACL.php @@ -121,7 +121,7 @@ class CRM_ACL_DAO_ACL extends CRM_Core_DAO { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Dynamic(self::getTableName(), 'entity_id', NULL, 'id', 'entity_table'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); } @@ -217,7 +217,7 @@ class CRM_ACL_DAO_ACL extends CRM_Core_DAO { ], 'pseudoconstant' => [ 'callback' => 'CRM_ACL_BAO_ACL::operation', - ] + ], ], 'object_table' => [ 'name' => 'object_table', diff --git a/CRM/ACL/DAO/Cache.php b/CRM/ACL/DAO/Cache.php index 9808031b48..208dce728f 100644 --- a/CRM/ACL/DAO/Cache.php +++ b/CRM/ACL/DAO/Cache.php @@ -72,7 +72,7 @@ class CRM_ACL_DAO_Cache extends CRM_Core_DAO { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'acl_id', 'civicrm_acl', 'id'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); diff --git a/CRM/ACL/DAO/EntityRole.php b/CRM/ACL/DAO/EntityRole.php index afc3850068..a4dda46a39 100644 --- a/CRM/ACL/DAO/EntityRole.php +++ b/CRM/ACL/DAO/EntityRole.php @@ -79,7 +79,7 @@ class CRM_ACL_DAO_EntityRole extends CRM_Core_DAO { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Dynamic(self::getTableName(), 'entity_id', NULL, 'id', 'entity_table'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); } diff --git a/CRM/ACL/Form/ACL.php b/CRM/ACL/Form/ACL.php index b66122ea70..76e5426562 100644 --- a/CRM/ACL/Form/ACL.php +++ b/CRM/ACL/Form/ACL.php @@ -114,24 +114,24 @@ class CRM_ACL_Form_ACL extends CRM_Admin_Form { $this->add('text', 'name', ts('Description'), CRM_Core_DAO::getAttribute('CRM_ACL_DAO_ACL', 'name'), TRUE); - $operations = array('' => ts('- select -')) + CRM_ACL_BAO_ACL::operation(); + $operations = ['' => ts('- select -')] + CRM_ACL_BAO_ACL::operation(); $this->add('select', 'operation', ts('Operation'), $operations, TRUE ); - $objTypes = array( + $objTypes = [ '1' => ts('A group of contacts'), '2' => ts('A profile'), '3' => ts('A set of custom data fields'), - ); + ]; if (CRM_Core_Permission::access('CiviEvent')) { $objTypes['4'] = ts('Events'); } - $extra = array('onclick' => "showObjectSelect();"); + $extra = ['onclick' => "showObjectSelect();"]; $this->addRadio('object_type', ts('Type of Data'), $objTypes, @@ -140,31 +140,31 @@ class CRM_ACL_Form_ACL extends CRM_Admin_Form { ); $label = ts('Role'); - $role = array( - '-1' => ts('- select role -'), - '0' => ts('Everyone'), - ) + CRM_Core_OptionGroup::values('acl_role'); + $role = [ + '-1' => ts('- select role -'), + '0' => ts('Everyone'), + ] + CRM_Core_OptionGroup::values('acl_role'); $this->add('select', 'entity_id', $label, $role, TRUE); - $group = array( - '-1' => ts('- select -'), - '0' => ts('All Groups'), - ) + CRM_Core_PseudoConstant::group(); + $group = [ + '-1' => ts('- select -'), + '0' => ts('All Groups'), + ] + CRM_Core_PseudoConstant::group(); - $customGroup = array( - '-1' => ts('- select -'), - '0' => ts('All Custom Groups'), - ) + CRM_Core_PseudoConstant::get('CRM_Core_DAO_CustomField', 'custom_group_id'); + $customGroup = [ + '-1' => ts('- select -'), + '0' => ts('All Custom Groups'), + ] + CRM_Core_PseudoConstant::get('CRM_Core_DAO_CustomField', 'custom_group_id'); - $ufGroup = array( - '-1' => ts('- select -'), - '0' => ts('All Profiles'), - ) + CRM_Core_PseudoConstant::get('CRM_Core_DAO_UFField', 'uf_group_id'); + $ufGroup = [ + '-1' => ts('- select -'), + '0' => ts('All Profiles'), + ] + CRM_Core_PseudoConstant::get('CRM_Core_DAO_UFField', 'uf_group_id'); - $event = array( - '-1' => ts('- select -'), - '0' => ts('All Events'), - ) + CRM_Event_PseudoConstant::event(NULL, FALSE, "( is_template IS NULL OR is_template != 1 )"); + $event = [ + '-1' => ts('- select -'), + '0' => ts('All Events'), + ] + CRM_Event_PseudoConstant::event(NULL, FALSE, "( is_template IS NULL OR is_template != 1 )"); $this->add('select', 'group_id', ts('Group'), $group); $this->add('select', 'custom_group_id', ts('Custom Data'), $customGroup); @@ -173,7 +173,7 @@ class CRM_ACL_Form_ACL extends CRM_Admin_Form { $this->add('checkbox', 'is_active', ts('Enabled?')); - $this->addFormRule(array('CRM_ACL_Form_ACL', 'formRule')); + $this->addFormRule(['CRM_ACL_Form_ACL', 'formRule']); } /** @@ -189,7 +189,7 @@ class CRM_ACL_Form_ACL extends CRM_Admin_Form { $errors['entity_id'] = ts('Please assign this permission to a Role.'); } - $validOperations = array('View', 'Edit'); + $validOperations = ['View', 'Edit']; $operationMessage = ts("Only 'View' and 'Edit' operations are valid for this type of data"); // Figure out which type of object we're permissioning on and make sure user has selected a value. diff --git a/CRM/ACL/Form/ACLBasic.php b/CRM/ACL/Form/ACLBasic.php index da7c2c7868..af902384fd 100644 --- a/CRM/ACL/Form/ACLBasic.php +++ b/CRM/ACL/Form/ACLBasic.php @@ -36,7 +36,7 @@ class CRM_ACL_Form_ACLBasic extends CRM_Admin_Form { * Set default values for the form. */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; if ($this->_id || $this->_id === '0' @@ -49,9 +49,9 @@ SELECT object_table WHERE entity_id = %1 AND ( object_table NOT IN ( 'civicrm_saved_search', 'civicrm_uf_group', 'civicrm_custom_group' ) ) "; - $params = array(1 => array($this->_id, 'Integer')); + $params = [1 => [$this->_id, 'Integer']]; $dao = CRM_Core_DAO::executeQuery($query, $params); - $defaults['object_table'] = array(); + $defaults['object_table'] = []; while ($dao->fetch()) { $defaults['object_table'][$dao->object_table] = 1; } @@ -75,14 +75,14 @@ SELECT object_table ts('ACL Type'), $permissions, NULL, NULL, TRUE, NULL, - array('', '') + ['', ''] ); $label = ts('Role'); - $role = array( - '-1' => ts('- select role -'), - '0' => ts('Everyone'), - ) + CRM_Core_OptionGroup::values('acl_role'); + $role = [ + '-1' => ts('- select role -'), + '0' => ts('Everyone'), + ] + CRM_Core_OptionGroup::values('acl_role'); $entityID = &$this->add('select', 'entity_id', $label, $role, TRUE); if ($this->_id) { @@ -90,7 +90,7 @@ SELECT object_table } $this->add('checkbox', 'is_active', ts('Enabled?')); - $this->addFormRule(array('CRM_ACL_Form_ACLBasic', 'formRule')); + $this->addFormRule(['CRM_ACL_Form_ACLBasic', 'formRule']); } /** @@ -100,7 +100,7 @@ SELECT object_table */ public static function formRule($params) { if ($params['entity_id'] == -1) { - $errors = array('entity_id' => ts('Role is a required field')); + $errors = ['entity_id' => ts('Role is a required field')]; return $errors; } @@ -123,7 +123,7 @@ DELETE WHERE entity_id = %1 AND ( object_table NOT IN ( 'civicrm_saved_search', 'civicrm_uf_group', 'civicrm_custom_group' ) ) "; - $deleteParams = array(1 => array($this->_id, 'Integer')); + $deleteParams = [1 => [$this->_id, 'Integer']]; CRM_Core_DAO::executeQuery($query, $deleteParams); if ($this->_action & CRM_Core_Action::DELETE) { diff --git a/CRM/ACL/Form/EntityRole.php b/CRM/ACL/Form/EntityRole.php index 4cfb17b1b8..1da21f89ea 100644 --- a/CRM/ACL/Form/EntityRole.php +++ b/CRM/ACL/Form/EntityRole.php @@ -42,14 +42,14 @@ class CRM_ACL_Form_EntityRole extends CRM_Admin_Form { return; } - $aclRoles = array('' => ts('- select -')) + CRM_Core_OptionGroup::values('acl_role'); + $aclRoles = ['' => ts('- select -')] + CRM_Core_OptionGroup::values('acl_role'); $this->add('select', 'acl_role_id', ts('ACL Role'), $aclRoles, TRUE ); $label = ts('Assigned to'); - $group = array('' => ts('- select group -')) + CRM_Core_PseudoConstant::staticGroup(FALSE, 'Access'); - $this->add('select', 'entity_id', $label, $group, TRUE, array('class' => 'crm-select2 huge')); + $group = ['' => ts('- select group -')] + CRM_Core_PseudoConstant::staticGroup(FALSE, 'Access'); + $this->add('select', 'entity_id', $label, $group, TRUE, ['class' => 'crm-select2 huge']); $this->add('checkbox', 'is_active', ts('Enabled?')); } diff --git a/CRM/ACL/Form/WordPress/Permissions.php b/CRM/ACL/Form/WordPress/Permissions.php index 24e63eaa60..65191fb979 100644 --- a/CRM/ACL/Form/WordPress/Permissions.php +++ b/CRM/ACL/Form/WordPress/Permissions.php @@ -77,7 +77,7 @@ class CRM_ACL_Form_WordPress_Permissions extends CRM_Core_Form { $this->setDefaults($defaults); - $descArray = array(); + $descArray = []; foreach ($permissionsDesc as $perm => $attr) { if (count($attr) > 1) { $descArray[$perm] = $attr[1]; @@ -85,7 +85,7 @@ class CRM_ACL_Form_WordPress_Permissions extends CRM_Core_Form { } // build table rows by merging role perms - $rows = array(); + $rows = []; foreach ($rolePerms as $role => $perms) { foreach ($perms as $name => $title) { $rows[$name] = $title; @@ -93,14 +93,14 @@ class CRM_ACL_Form_WordPress_Permissions extends CRM_Core_Form { } // Build array keyed by permission - $table = array(); + $table = []; foreach ($rows as $perm => $label) { // Init row with permission label - $table[$perm] = array( + $table[$perm] = [ 'label' => $label, - 'roles' => array(), - ); + 'roles' => [], + ]; // Add permission description and role names foreach ($roles as $key => $label) { @@ -117,14 +117,14 @@ class CRM_ACL_Form_WordPress_Permissions extends CRM_Core_Form { $this->assign('roles', $roles); $this->addButtons( - array( - array( + [ + [ 'type' => 'next', 'name' => ts('Save'), 'spacing' => '', 'isDefault' => FALSE, - ), - ) + ], + ] ); } @@ -165,16 +165,16 @@ class CRM_ACL_Form_WordPress_Permissions extends CRM_Core_Form { $allWarningPermissions[$key] = CRM_Utils_String::munge(strtolower($permission)); } $warningPermissions = array_intersect($allWarningPermissions, array_keys($rolePermissions)); - $warningPermissionNames = array(); + $warningPermissionNames = []; foreach ($warningPermissions as $permission) { $warningPermissionNames[$permission] = $permissionsArray[$permission]; } if (!empty($warningPermissionNames)) { CRM_Core_Session::setStatus( - ts('The %1 role was assigned one or more permissions that may prove dangerous for users of that role to have. Please reconsider assigning %2 to them.', array( - 1 => $wp_roles->role_names[$role], - 2 => implode(', ', $warningPermissionNames), - )), + ts('The %1 role was assigned one or more permissions that may prove dangerous for users of that role to have. Please reconsider assigning %2 to them.', [ + 1 => $wp_roles->role_names[$role], + 2 => implode(', ', $warningPermissionNames), + ]), ts('Unsafe Permission Settings') ); } @@ -214,7 +214,7 @@ class CRM_ACL_Form_WordPress_Permissions extends CRM_Core_Form { $permissions = CRM_Core_Permission::basicPermissions(FALSE, $descriptions); - $perms_array = array(); + $perms_array = []; foreach ($permissions as $perm => $title) { //order matters here, but we deal with that later $perms_array[CRM_Utils_String::munge(strtolower($perm))] = $title; diff --git a/CRM/ACL/Page/ACL.php b/CRM/ACL/Page/ACL.php index 4b45a0b502..f056c675ce 100644 --- a/CRM/ACL/Page/ACL.php +++ b/CRM/ACL/Page/ACL.php @@ -59,30 +59,30 @@ class CRM_ACL_Page_ACL extends CRM_Core_Page_Basic { */ public function &links() { if (!(self::$_links)) { - self::$_links = array( - CRM_Core_Action::UPDATE => array( + self::$_links = [ + CRM_Core_Action::UPDATE => [ 'name' => ts('Edit'), 'url' => 'civicrm/acl', 'qs' => 'reset=1&action=update&id=%%id%%', 'title' => ts('Edit ACL'), - ), - CRM_Core_Action::DISABLE => array( + ], + CRM_Core_Action::DISABLE => [ 'name' => ts('Disable'), 'ref' => 'crm-enable-disable', 'title' => ts('Disable ACL'), - ), - CRM_Core_Action::ENABLE => array( + ], + CRM_Core_Action::ENABLE => [ 'name' => ts('Enable'), 'ref' => 'crm-enable-disable', 'title' => ts('Enable ACL'), - ), - CRM_Core_Action::DELETE => array( + ], + CRM_Core_Action::DELETE => [ 'name' => ts('Delete'), 'url' => 'civicrm/acl', 'qs' => 'reset=1&action=delete&id=%%id%%', 'title' => ts('Delete ACL'), - ), - ); + ], + ]; } return self::$_links; } @@ -94,14 +94,12 @@ class CRM_ACL_Page_ACL extends CRM_Core_Page_Basic { */ public function run() { // set breadcrumb to append to admin/access - $breadCrumb = array( - array( + $breadCrumb = [ + [ 'title' => ts('Access Control'), - 'url' => CRM_Utils_System::url('civicrm/admin/access', - 'reset=1' - ), - ), - ); + 'url' => CRM_Utils_System::url('civicrm/admin/access', 'reset=1'), + ], + ]; CRM_Utils_System::appendBreadCrumb($breadCrumb); // parent run @@ -113,7 +111,7 @@ class CRM_ACL_Page_ACL extends CRM_Core_Page_Basic { */ public function browse() { // get all acl's sorted by weight - $acl = array(); + $acl = []; $query = " SELECT * FROM civicrm_acl @@ -124,26 +122,26 @@ ORDER BY entity_id $roles = CRM_Core_OptionGroup::values('acl_role'); - $group = array( - '-1' => ts('- select -'), - '0' => ts('All Groups'), - ) + CRM_Core_PseudoConstant::group(); - $customGroup = array( - '-1' => ts('- select -'), - '0' => ts('All Custom Groups'), - ) + CRM_Core_PseudoConstant::get('CRM_Core_DAO_CustomField', 'custom_group_id'); - $ufGroup = array( - '-1' => ts('- select -'), - '0' => ts('All Profiles'), - ) + CRM_Core_PseudoConstant::get('CRM_Core_DAO_UFField', 'uf_group_id'); + $group = [ + '-1' => ts('- select -'), + '0' => ts('All Groups'), + ] + CRM_Core_PseudoConstant::group(); + $customGroup = [ + '-1' => ts('- select -'), + '0' => ts('All Custom Groups'), + ] + CRM_Core_PseudoConstant::get('CRM_Core_DAO_CustomField', 'custom_group_id'); + $ufGroup = [ + '-1' => ts('- select -'), + '0' => ts('All Profiles'), + ] + CRM_Core_PseudoConstant::get('CRM_Core_DAO_UFField', 'uf_group_id'); - $event = array( - '-1' => ts('- select -'), - '0' => ts('All Events'), - ) + CRM_Event_PseudoConstant::event(); + $event = [ + '-1' => ts('- select -'), + '0' => ts('All Events'), + ] + CRM_Event_PseudoConstant::event(); while ($dao->fetch()) { - $acl[$dao->id] = array(); + $acl[$dao->id] = []; $acl[$dao->id]['name'] = $dao->name; $acl[$dao->id]['operation'] = $dao->operation; $acl[$dao->id]['entity_id'] = $dao->entity_id; @@ -194,7 +192,7 @@ ORDER BY entity_id $acl[$dao->id]['action'] = CRM_Core_Action::formLink( self::links(), $action, - array('id' => $dao->id), + ['id' => $dao->id], ts('more'), FALSE, 'ACL.manage.action', @@ -253,7 +251,7 @@ ORDER BY entity_id if ($mode & (CRM_Core_Action::UPDATE)) { if (isset($id)) { $aclName = CRM_Core_DAO::getFieldValue('CRM_ACL_DAO_ACL', $id); - CRM_Utils_System::setTitle(ts('Edit ACL – %1', array(1 => $aclName))); + CRM_Utils_System::setTitle(ts('Edit ACL – %1', [1 => $aclName])); } } parent::edit($mode, $id, $imageUpload, $pushUserContext); diff --git a/CRM/ACL/Page/ACLBasic.php b/CRM/ACL/Page/ACLBasic.php index 113d6117b3..2d03da6c96 100644 --- a/CRM/ACL/Page/ACLBasic.php +++ b/CRM/ACL/Page/ACLBasic.php @@ -57,20 +57,20 @@ class CRM_ACL_Page_ACLBasic extends CRM_Core_Page_Basic { */ public function &links() { if (!(self::$_links)) { - self::$_links = array( - CRM_Core_Action::UPDATE => array( + self::$_links = [ + CRM_Core_Action::UPDATE => [ 'name' => ts('Edit'), 'url' => 'civicrm/acl/basic', 'qs' => 'reset=1&action=update&id=%%id%%', 'title' => ts('Edit ACL'), - ), - CRM_Core_Action::DELETE => array( + ], + CRM_Core_Action::DELETE => [ 'name' => ts('Delete'), 'url' => 'civicrm/acl/basic', 'qs' => 'reset=1&action=delete&id=%%id%%', 'title' => ts('Delete ACL'), - ), - ); + ], + ]; } return self::$_links; } @@ -86,12 +86,12 @@ class CRM_ACL_Page_ACLBasic extends CRM_Core_Page_Basic { $id = $this->getIdAndAction(); // set breadcrumb to append to admin/access - $breadCrumb = array( - array( + $breadCrumb = [ + [ 'title' => ts('Access Control'), 'url' => CRM_Utils_System::url('civicrm/admin/access', 'reset=1'), - ), - ); + ], + ]; CRM_Utils_System::appendBreadCrumb($breadCrumb); // what action to take ? @@ -112,7 +112,7 @@ class CRM_ACL_Page_ACLBasic extends CRM_Core_Page_Basic { public function browse() { // get all acl's sorted by weight - $acl = array(); + $acl = []; $query = " SELECT * FROM civicrm_acl @@ -126,7 +126,7 @@ ORDER BY entity_id $permissions = CRM_Core_Permission::basicPermissions(); while ($dao->fetch()) { if (!array_key_exists($dao->entity_id, $acl)) { - $acl[$dao->entity_id] = array(); + $acl[$dao->entity_id] = []; $acl[$dao->entity_id]['name'] = $dao->name; $acl[$dao->entity_id]['entity_id'] = $dao->entity_id; $acl[$dao->entity_id]['entity_table'] = $dao->entity_table; @@ -146,7 +146,7 @@ ORDER BY entity_id $acl[$dao->entity_id]['action'] = CRM_Core_Action::formLink( self::links(), $action, - array('id' => $dao->entity_id), + ['id' => $dao->entity_id], ts('more'), FALSE, 'aclRole.manage.action', diff --git a/CRM/ACL/Page/EntityRole.php b/CRM/ACL/Page/EntityRole.php index 963f65e93a..947e7d78ef 100644 --- a/CRM/ACL/Page/EntityRole.php +++ b/CRM/ACL/Page/EntityRole.php @@ -59,30 +59,30 @@ class CRM_ACL_Page_EntityRole extends CRM_Core_Page_Basic { */ public function &links() { if (!(self::$_links)) { - self::$_links = array( - CRM_Core_Action::UPDATE => array( + self::$_links = [ + CRM_Core_Action::UPDATE => [ 'name' => ts('Edit'), 'url' => 'civicrm/acl/entityrole', 'qs' => 'action=update&id=%%id%%', 'title' => ts('Edit ACL Role Assignment'), - ), - CRM_Core_Action::DISABLE => array( + ], + CRM_Core_Action::DISABLE => [ 'name' => ts('Disable'), 'ref' => 'crm-enable-disable', 'title' => ts('Disable ACL Role Assignment'), - ), - CRM_Core_Action::ENABLE => array( + ], + CRM_Core_Action::ENABLE => [ 'name' => ts('Enable'), 'ref' => 'crm-enable-disable', 'title' => ts('Enable ACL Role Assignment'), - ), - CRM_Core_Action::DELETE => array( + ], + CRM_Core_Action::DELETE => [ 'name' => ts('Delete'), 'url' => 'civicrm/acl/entityrole', 'qs' => 'action=delete&id=%%id%%', 'title' => ts('Delete ACL Role Assignment'), - ), - ); + ], + ]; } return self::$_links; } @@ -98,14 +98,12 @@ class CRM_ACL_Page_EntityRole extends CRM_Core_Page_Basic { $id = $this->getIdAndAction(); // set breadcrumb to append to admin/access - $breadCrumb = array( - array( + $breadCrumb = [ + [ 'title' => ts('Access Control'), - 'url' => CRM_Utils_System::url('civicrm/admin/access', - 'reset=1' - ), - ), - ); + 'url' => CRM_Utils_System::url('civicrm/admin/access', 'reset=1'), + ], + ]; CRM_Utils_System::appendBreadCrumb($breadCrumb); CRM_Utils_System::setTitle(ts('Assign Users to Roles')); @@ -134,7 +132,7 @@ class CRM_ACL_Page_EntityRole extends CRM_Core_Page_Basic { public function browse() { // get all acl's sorted by weight - $entityRoles = array(); + $entityRoles = []; $dao = new CRM_ACL_DAO_EntityRole(); $dao->find(); @@ -142,7 +140,7 @@ class CRM_ACL_Page_EntityRole extends CRM_Core_Page_Basic { $groups = CRM_Core_PseudoConstant::staticGroup(); while ($dao->fetch()) { - $entityRoles[$dao->id] = array(); + $entityRoles[$dao->id] = []; CRM_Core_DAO::storeValues($dao, $entityRoles[$dao->id]); $entityRoles[$dao->id]['acl_role'] = CRM_Utils_Array::value($dao->acl_role_id, $aclRoles); @@ -160,7 +158,7 @@ class CRM_ACL_Page_EntityRole extends CRM_Core_Page_Basic { $entityRoles[$dao->id]['action'] = CRM_Core_Action::formLink( self::links(), $action, - array('id' => $dao->id), + ['id' => $dao->id], ts('more'), FALSE, 'entityRole.manage.action', -- 2.25.1