public function setUp() {
parent::setUp();
- // CRM_Contact_BAO_Group::getPermissionClause sets a static variable.
- // Ensure it is reset before each run.
- $force = TRUE;
- CRM_Contact_BAO_Group::getPermissionClause($force);
$this->_params = array(
'page' => 1,
'rp' => 50,
public function setHookAndRequest($permission, $hook) {
CRM_Core_Config::singleton()->userPermissionClass->permissions = (array) $permission;
$this->hookClass->setHook('civicrm_aclGroup', array($this, $hook));
- CRM_Contact_BAO_Group::getPermissionClause(TRUE);
global $_REQUEST;
$_REQUEST = $this->_params;
}
$params = $this->_params;
$groups = CRM_Contact_BAO_Group::getGroupListSelector($params);
$this->assertEquals(2, $groups['recordsTotal']);
- $this->assertEquals('<span><a href="/index.php?q=civicrm/group/search&reset=1&force=1&context=smog&gid=4" class="action-item crm-hover-button" title=\'Group Contacts\' >Contacts</a></span>', $groups['data'][0]['links']);
- $this->assertEquals('<span><a href="/index.php?q=civicrm/group/search&reset=1&force=1&context=smog&gid=2" class="action-item crm-hover-button" title=\'Group Contacts\' >Contacts</a></span>', $groups['data'][1]['links']);
+ $this->assertEquals('<span><a href="/index.php?q=civicrm/group/search&reset=1&force=1&context=smog&gid=4&component_mode=1" class="action-item crm-hover-button" title=\'Group Contacts\' >Contacts</a></span>', $groups['data'][0]['links']);
+ $this->assertEquals('<span><a href="/index.php?q=civicrm/group/search&reset=1&force=1&context=smog&gid=2&component_mode=1" class="action-item crm-hover-button" title=\'Group Contacts\' >Contacts</a></span>', $groups['data'][1]['links']);
// as per changes made in PR-6822
$this->setPermissionAndRequest(array('view all contacts', 'edit groups'));
$params = $this->_params;
$groups = CRM_Contact_BAO_Group::getGroupListSelector($params);
$this->assertEquals(2, $groups['recordsTotal']);
- $this->assertEquals('<span><a href="/index.php?q=civicrm/group/search&reset=1&force=1&context=smog&gid=4" class="action-item crm-hover-button" title=\'Group Contacts\' >Contacts</a><a href="/index.php?q=civicrm/group&reset=1&action=update&id=4" class="action-item crm-hover-button" title=\'Edit Group\' >Settings</a></span><span class=\'btn-slide crm-hover-button\'>more<ul class=\'panel\'><li><a href="#" class="action-item crm-hover-button crm-enable-disable" title=\'Disable Group\' >Disable</a></li><li><a href="/index.php?q=civicrm/group&reset=1&action=delete&id=4" class="action-item crm-hover-button small-popup" title=\'Delete Group\' >Delete</a></li></ul></span>', $groups['data'][0]['links']);
- $this->assertEquals('<span><a href="/index.php?q=civicrm/group/search&reset=1&force=1&context=smog&gid=2" class="action-item crm-hover-button" title=\'Group Contacts\' >Contacts</a><a href="/index.php?q=civicrm/group&reset=1&action=update&id=2" class="action-item crm-hover-button" title=\'Edit Group\' >Settings</a></span><span class=\'btn-slide crm-hover-button\'>more<ul class=\'panel\'><li><a href="#" class="action-item crm-hover-button crm-enable-disable" title=\'Disable Group\' >Disable</a></li><li><a href="/index.php?q=civicrm/group&reset=1&action=delete&id=2" class="action-item crm-hover-button small-popup" title=\'Delete Group\' >Delete</a></li></ul></span>', $groups['data'][1]['links']);
+ $this->assertEquals('<span><a href="/index.php?q=civicrm/group/search&reset=1&force=1&context=smog&gid=4&component_mode=1" class="action-item crm-hover-button" title=\'Group Contacts\' >Contacts</a><a href="/index.php?q=civicrm/group&reset=1&action=update&id=4" class="action-item crm-hover-button" title=\'Edit Group\' >Settings</a></span><span class=\'btn-slide crm-hover-button\'>more<ul class=\'panel\'><li><a href="#" class="action-item crm-hover-button crm-enable-disable" title=\'Disable Group\' >Disable</a></li><li><a href="/index.php?q=civicrm/group&reset=1&action=delete&id=4" class="action-item crm-hover-button small-popup" title=\'Delete Group\' >Delete</a></li></ul></span>', $groups['data'][0]['links']);
+ $this->assertEquals('<span><a href="/index.php?q=civicrm/group/search&reset=1&force=1&context=smog&gid=2&component_mode=1" class="action-item crm-hover-button" title=\'Group Contacts\' >Contacts</a><a href="/index.php?q=civicrm/group&reset=1&action=update&id=2" class="action-item crm-hover-button" title=\'Edit Group\' >Settings</a></span><span class=\'btn-slide crm-hover-button\'>more<ul class=\'panel\'><li><a href="#" class="action-item crm-hover-button crm-enable-disable" title=\'Disable Group\' >Disable</a></li><li><a href="/index.php?q=civicrm/group&reset=1&action=delete&id=2" class="action-item crm-hover-button small-popup" title=\'Delete Group\' >Delete</a></li></ul></span>', $groups['data'][1]['links']);
}
/**
*/
public function testGroupListAccessCiviCRM() {
$this->setPermissionAndRequest('access CiviCRM');
- $permissionClause = CRM_Contact_BAO_Group::getPermissionClause(TRUE);
+ $permissionClause = CRM_Contact_BAO_Group::getPermissionClause();
$this->assertEquals('1 = 0', $permissionClause);
$params = $this->_params;
$groups = CRM_Contact_BAO_Group::getGroupListSelector($params);
}
}
+ public function testEditAllGroupsACL() {
+ $this->setupEditAllGroupsACL();
+ $params = $this->_params;
+ $groups = CRM_Contact_BAO_Group::getGroupListSelector($params);
+ $this->assertNotEmpty($groups, 'If Edit All Groups is granted, at least one group should be visible');
+ }
+
+ /**
+ * Set up an acl allowing Authenticated contacts to Edit All Groups
+ *
+ * You need to have pre-created these groups & created the user e.g
+ * $this->createLoggedInUser();
+ *
+ */
+ public function setupEditAllGroupsACL() {
+ global $_REQUEST;
+ $_REQUEST = $this->_params;
+
+ CRM_Core_Config::singleton()->userPermissionClass->permissions = array('access CiviCRM');
+ $optionGroupID = $this->callAPISuccessGetValue('option_group', array('return' => 'id', 'name' => 'acl_role'));
+ $ov = new CRM_Core_DAO_OptionValue();
+ $ov->option_group_id = $optionGroupID;
+ $ov->value = 55;
+ if ($ov->find(TRUE)) {
+ CRM_Core_DAO::executeQuery("DELETE FROM civicrm_option_value WHERE id = {$ov->id}");
+ }
+ $optionValue = $this->callAPISuccess('option_value', 'create', array(
+ 'option_group_id' => $optionGroupID,
+ 'label' => 'groupmaster',
+ 'value' => 55,
+ ));
+ $groupId = $this->groupCreate(['name' => 'groupmaster group']);
+ // Assign groupmaster to groupmaster group in civicrm_acl_entity_role
+ CRM_Core_DAO::executeQuery("
+ INSERT INTO civicrm_acl_entity_role (
+ `acl_role_id`, `entity_table`, `entity_id`, `is_active`
+ ) VALUES (55, 'civicrm_group', $groupId, 1);
+ ");
+ // Put the user into this group
+ $this->_loggedInUser = CRM_Core_Session::singleton()->get('userID');
+ $this->callAPISuccess('group_contact', 'create', array(
+ 'group_id' => $groupId,
+ 'contact_id' => $this->_loggedInUser,
+ ));
+ // Add the ACL
+ CRM_Core_DAO::executeQuery("
+ INSERT INTO civicrm_acl (
+ `name`, `entity_table`, `entity_id`, `operation`, `object_table`, `object_id`, `is_active`
+ )
+ VALUES (
+ 'core-580', 'civicrm_acl_role', 55, 'Edit', 'civicrm_saved_search', 0, 1
+ );
+ ");
+
+ }
+
}