From 100b0ec65ef7a3a2d4a780de040351cd6cf53732 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Tue, 6 Jan 2015 13:09:18 -0800 Subject: [PATCH] INFRA-132 - CRM/ACL - phpcbf --- CRM/ACL/API.php | 16 ++++++++-------- CRM/ACL/BAO/ACL.php | 25 ++++--------------------- CRM/ACL/Form/ACL.php | 2 -- CRM/ACL/Form/ACLBasic.php | 4 ++-- CRM/ACL/Form/EntityRole.php | 2 -- CRM/ACL/Form/WordPress/Permissions.php | 12 ++++++------ CRM/ACL/Page/ACL.php | 16 ++++++++++------ CRM/ACL/Page/ACLBasic.php | 3 ++- CRM/ACL/Page/EntityRole.php | 3 ++- 9 files changed, 34 insertions(+), 49 deletions(-) diff --git a/CRM/ACL/API.php b/CRM/ACL/API.php index 7ada9d6f60..0d3c6925ee 100644 --- a/CRM/ACL/API.php +++ b/CRM/ACL/API.php @@ -93,8 +93,8 @@ class CRM_ACL_API { public static function whereClause($type, &$tables, &$whereTables, - $contactID = NULL, - $onlyDeleted = FALSE, + $contactID = NULL, + $onlyDeleted = FALSE, $skipDeleteClause = FALSE ) { // the default value which is valid for rhe final AND @@ -156,9 +156,9 @@ class CRM_ACL_API { */ public static function group( $type, - $contactID = NULL, - $tableName = 'civicrm_saved_search', - $allGroups = NULL, + $contactID = NULL, + $tableName = 'civicrm_saved_search', + $allGroups = NULL, $includedGroups = NULL ) { if ($contactID == NULL) { @@ -193,9 +193,9 @@ class CRM_ACL_API { public static function groupPermission( $type, $groupID, - $contactID = NULL, - $tableName = 'civicrm_saved_search', - $allGroups = NULL, + $contactID = NULL, + $tableName = 'civicrm_saved_search', + $allGroups = NULL, $includedGroups = NULL, $flush = FALSE ) { diff --git a/CRM/ACL/BAO/ACL.php b/CRM/ACL/BAO/ACL.php index 3c6c05298c..378579bc22 100644 --- a/CRM/ACL/BAO/ACL.php +++ b/CRM/ACL/BAO/ACL.php @@ -130,7 +130,6 @@ class CRM_ACL_BAO_ACL extends CRM_ACL_DAO_ACL { /* Include clause if we're looking for a specific table/id permission */ - if (!empty($object_table)) { $where .= " AND ( {$t['ACL']}.object_table IS null OR ({$t['ACL']}.object_table = '" . CRM_Utils_Type::escape($object_table, 'String') . "'"; @@ -143,7 +142,6 @@ class CRM_ACL_BAO_ACL extends CRM_ACL_DAO_ACL { /* Include clause if we're granting an ACL or ACL Role */ - if (!empty($acl_id)) { $where .= " AND ({$t['ACL']}.acl_id IS null OR {$t['ACL']}.acl_id = " . CRM_Utils_Type::escape($acl_id, 'Integer') . ')'; @@ -159,7 +157,6 @@ class CRM_ACL_BAO_ACL extends CRM_ACL_DAO_ACL { /* Query for permissions granted to all contacts in the domain */ - $query[] = "SELECT {$t['ACL']}.*, 0 as override FROM {$t['ACL']} @@ -168,7 +165,6 @@ class CRM_ACL_BAO_ACL extends CRM_ACL_DAO_ACL { /* Query for permissions granted to all contacts through an ACL group */ - $query[] = "SELECT {$t['ACL']}.*, 0 as override FROM {$t['ACL']} @@ -188,7 +184,6 @@ class CRM_ACL_BAO_ACL extends CRM_ACL_DAO_ACL { /* Query for permissions granted directly to the contact */ - $query[] = "SELECT {$t['ACL']}.*, 1 as override FROM {$t['ACL']} @@ -201,7 +196,6 @@ class CRM_ACL_BAO_ACL extends CRM_ACL_DAO_ACL { /* Query for permissions granted to the contact through an ACL group */ - $query[] = "SELECT {$t['ACL']}.*, 1 as override FROM {$t['ACL']} @@ -221,7 +215,6 @@ class CRM_ACL_BAO_ACL extends CRM_ACL_DAO_ACL { /* Query for permissions granted to the contact through a group */ - $query[] = "SELECT {$t['ACL']}.*, 0 as override FROM {$t['ACL']} @@ -234,11 +227,9 @@ class CRM_ACL_BAO_ACL extends CRM_ACL_DAO_ACL { AND {$t['GroupContact']}.contact_id = $contact_id AND {$t['GroupContact']}.status = 'Added')"; - /* Query for permissions granted through an ACL group to a Contact * group */ - $query[] = "SELECT {$t['ACL']}.*, 0 as override FROM {$t['ACL']} @@ -276,7 +267,6 @@ class CRM_ACL_BAO_ACL extends CRM_ACL_DAO_ACL { * 3) the rule governs the specific object we want */ - if (empty($dao->object_table) || ($dao->object_table == $object_table && (empty($dao->object_id) @@ -289,7 +279,6 @@ class CRM_ACL_BAO_ACL extends CRM_ACL_DAO_ACL { else { /* Otherwise try to generate a clause for this rule */ - $clause = self::getClause( $dao->object_table, $dao->object_id, $tables ); @@ -298,7 +287,6 @@ class CRM_ACL_BAO_ACL extends CRM_ACL_DAO_ACL { * (id is null) on a table other than the one we're interested * in. So skip it. */ - if (empty($clause)) { continue; } @@ -307,7 +295,6 @@ class CRM_ACL_BAO_ACL extends CRM_ACL_DAO_ACL { /* Now we figure out if this is an allow or deny rule, and possibly * a contact-level override */ - if ($dao->deny) { $deny[] = $clause; } @@ -373,7 +360,7 @@ class CRM_ACL_BAO_ACL extends CRM_ACL_DAO_ACL { * * @return array - Assoc. array of the ACL rule's properties */ - public function toArray($format = '%s', $hideEmpty = false) { + public function toArray($format = '%s', $hideEmpty = FALSE) { $result = array(); if (!self::$_fieldKeys) { @@ -417,7 +404,6 @@ class CRM_ACL_BAO_ACL extends CRM_ACL_DAO_ACL { $rule = new CRM_ACL_BAO_ACL(); - $acl = self::getTableName(); $contact = CRM_Contact_BAO_Contact::getTableName(); $c2g = CRM_Contact_BAO_GroupContact::getTableName(); @@ -540,7 +526,6 @@ class CRM_ACL_BAO_ACL extends CRM_ACL_DAO_ACL { $rule = new CRM_ACL_BAO_ACL(); - $acl = self::getTableName(); $c2g = CRM_Contact_BAO_GroupContact::getTableName(); $group = CRM_Contact_BAO_Group::getTableName(); @@ -588,7 +573,6 @@ SELECT $acl.* $acl = self::getTableName(); $aclRole = 'civicrm_acl_role'; - $aclER = CRM_ACL_DAO_EntityRole::getTableName(); $c2g = CRM_Contact_BAO_GroupContact::getTableName(); $group = CRM_Contact_BAO_Group::getTableName(); @@ -720,7 +704,6 @@ SELECT $acl.* return FALSE; } - $query = " SELECT count( a.id ) FROM civicrm_acl_cache c, civicrm_acl a @@ -869,9 +852,9 @@ SELECT g.* * @return array */ public static function group($type, - $contactID = NULL, - $tableName = 'civicrm_saved_search', - $allGroups = NULL, + $contactID = NULL, + $tableName = 'civicrm_saved_search', + $allGroups = NULL, $includedGroups = NULL ) { diff --git a/CRM/ACL/Form/ACL.php b/CRM/ACL/Form/ACL.php index 09585d7bf5..cc6c182c28 100644 --- a/CRM/ACL/Form/ACL.php +++ b/CRM/ACL/Form/ACL.php @@ -154,7 +154,6 @@ class CRM_ACL_Form_ACL extends CRM_Admin_Form { ' ', TRUE ); - $label = ts('Role'); $role = array( '-1' => ts('- select role -'), @@ -275,7 +274,6 @@ class CRM_ACL_Form_ACL extends CRM_Admin_Form { // note this also resets any ACL cache CRM_Core_BAO_Cache::deleteGroup('contact fields'); - if ($this->_action & CRM_Core_Action::DELETE) { CRM_ACL_BAO_ACL::del($this->_id); CRM_Core_Session::setStatus(ts('Selected ACL has been deleted.'), ts('Record Deleted'), 'success'); diff --git a/CRM/ACL/Form/ACLBasic.php b/CRM/ACL/Form/ACLBasic.php index 294992f961..1a00bb9103 100644 --- a/CRM/ACL/Form/ACLBasic.php +++ b/CRM/ACL/Form/ACLBasic.php @@ -93,9 +93,9 @@ SELECT object_table array('', '') ); - $label = ts('Role'); - $role = array('-1' => ts('- select role -'), + $role = array( + '-1' => ts('- select role -'), '0' => ts('Everyone'), ) + CRM_Core_OptionGroup::values('acl_role'); $entityID = &$this->add('select', 'entity_id', $label, $role, TRUE); diff --git a/CRM/ACL/Form/EntityRole.php b/CRM/ACL/Form/EntityRole.php index 97bbec7197..fe092af132 100644 --- a/CRM/ACL/Form/EntityRole.php +++ b/CRM/ACL/Form/EntityRole.php @@ -61,8 +61,6 @@ class CRM_ACL_Form_EntityRole extends CRM_Admin_Form { $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')); diff --git a/CRM/ACL/Form/WordPress/Permissions.php b/CRM/ACL/Form/WordPress/Permissions.php index 0c962ed907..21ad5f077c 100644 --- a/CRM/ACL/Form/WordPress/Permissions.php +++ b/CRM/ACL/Form/WordPress/Permissions.php @@ -44,7 +44,7 @@ class CRM_ACL_Form_WordPress_Permissions extends CRM_Core_Form { * * @return void */ - public function buildQuickForm( ) { + public function buildQuickForm() { CRM_Utils_System::setTitle( 'Wordpress Access Control' ); @@ -63,7 +63,7 @@ class CRM_ACL_Form_WordPress_Permissions extends CRM_Core_Form { $roleObj = $wp_roles->get_role($role); if (!empty($roleObj->capabilities)) { foreach ($roleObj->capabilities as $ckey => $cname) { - if (array_key_exists($ckey , $permissionsArray)) { + if (array_key_exists($ckey, $permissionsArray)) { $elementName = $role.'['.$ckey.']'; $defaults[$elementName] = 1; } @@ -74,7 +74,7 @@ class CRM_ACL_Form_WordPress_Permissions extends CRM_Core_Form { $rolePerms[$role] = $permissionsArray; foreach ( $rolePerms[$role] as $key => $value) { $elementName = $role.'['.$key.']'; - $this->add('checkbox' , $elementName , $value); + $this->add('checkbox', $elementName, $value); } $roles[$role] = $name; } @@ -87,11 +87,11 @@ class CRM_ACL_Form_WordPress_Permissions extends CRM_Core_Form { $this->addButtons( array( - array ( + array( 'type' => 'next', 'name' => ts('Save'), 'spacing' => '', - 'isDefault' => false ), + 'isDefault' => FALSE ), ) ); @@ -131,7 +131,7 @@ class CRM_ACL_Form_WordPress_Permissions extends CRM_Core_Form { if ($role == 'anonymous_user') { // Get the permissions into a format that matches what we get from WP $allWarningPermissions = CRM_Core_Permission::getAnonymousPermissionsWarnings(); - foreach ($allWarningPermissions as $key => $permission) { + foreach ($allWarningPermissions as $key => $permission) { $allWarningPermissions[$key] = CRM_utils_String::munge(strtolower($permission)); } $warningPermissions = array_intersect($allWarningPermissions, array_keys($rolePermissions)); diff --git a/CRM/ACL/Page/ACL.php b/CRM/ACL/Page/ACL.php index 8bf7a85afc..aaa149e23a 100644 --- a/CRM/ACL/Page/ACL.php +++ b/CRM/ACL/Page/ACL.php @@ -120,7 +120,8 @@ class CRM_ACL_Page_ACL extends CRM_Core_Page_Basic { ); // set breadcrumb to append to admin/access - $breadCrumb = array(array('title' => ts('Access Control'), + $breadCrumb = array(array( + 'title' => ts('Access Control'), 'url' => CRM_Utils_System::url('civicrm/admin/access', 'reset=1' ), @@ -170,17 +171,21 @@ ORDER BY entity_id $roles = CRM_Core_OptionGroup::values('acl_role'); - $group = array('-1' => ts('- select -'), + $group = array( + '-1' => ts('- select -'), '0' => ts('All Groups'), ) + CRM_Core_PseudoConstant::group(); - $customGroup = array('-1' => ts('- select -'), + $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 -'), + $ufGroup = array( + '-1' => ts('- select -'), '0' => ts('All Profiles'), ) + CRM_Core_PseudoConstant::get('CRM_Core_DAO_UFField', 'uf_group_id'); - $event = array('-1' => ts('- select -'), + $event = array( + '-1' => ts('- select -'), '0' => ts('All Events'), ) + CRM_Event_PseudoConstant::event(); @@ -194,7 +199,6 @@ ORDER BY entity_id $acl[$dao->id]['object_id'] = $dao->object_id; $acl[$dao->id]['is_active'] = $dao->is_active; - if ($acl[$dao->id]['entity_id']) { $acl[$dao->id]['entity'] = $roles[$acl[$dao->id]['entity_id']]; } diff --git a/CRM/ACL/Page/ACLBasic.php b/CRM/ACL/Page/ACLBasic.php index 82601b0fc6..afb403ebf8 100644 --- a/CRM/ACL/Page/ACLBasic.php +++ b/CRM/ACL/Page/ACLBasic.php @@ -108,7 +108,8 @@ class CRM_ACL_Page_ACLBasic extends CRM_Core_Page_Basic { ); // set breadcrumb to append to admin/access - $breadCrumb = array(array('title' => ts('Access Control'), + $breadCrumb = array(array( + 'title' => ts('Access Control'), 'url' => CRM_Utils_System::url('civicrm/admin/access', 'reset=1'), )); CRM_Utils_System::appendBreadCrumb($breadCrumb); diff --git a/CRM/ACL/Page/EntityRole.php b/CRM/ACL/Page/EntityRole.php index 66efb44070..b7a0791a22 100644 --- a/CRM/ACL/Page/EntityRole.php +++ b/CRM/ACL/Page/EntityRole.php @@ -120,7 +120,8 @@ class CRM_ACL_Page_EntityRole extends CRM_Core_Page_Basic { ); // set breadcrumb to append to admin/access - $breadCrumb = array(array('title' => ts('Access Control'), + $breadCrumb = array(array( + 'title' => ts('Access Control'), 'url' => CRM_Utils_System::url('civicrm/admin/access', 'reset=1' ), -- 2.25.1