* $this->_permissionedDisabledGroup = $this->groupCreate(array('title' => 'pick-me-disabled', 'is_active' => 0, 'name' => 'pick-me-disabled'));
* $this->_permissionedGroup = $this->groupCreate(array('title' => 'pick-me-active', 'is_active' => 1, 'name' => 'pick-me-active'));
*/
- public function setupACL() {
+ public function setupACL($isProfile = FALSE) {
global $_REQUEST;
$_REQUEST = $this->_params;
CRM_Core_DAO::executeQuery("
INSERT INTO civicrm_acl_entity_role (
- `acl_role_id`, `entity_table`, `entity_id`
- ) VALUES (55, 'civicrm_group', {$this->_permissionedGroup});
+ `acl_role_id`, `entity_table`, `entity_id`, `is_active`
+ ) VALUES (55, 'civicrm_group', {$this->_permissionedGroup}, 1);
");
- CRM_Core_DAO::executeQuery("
- INSERT INTO civicrm_acl (
- `name`, `entity_table`, `entity_id`, `operation`, `object_table`, `object_id`, `is_active`
- )
- VALUES (
- 'view picked', 'civicrm_group', $this->_permissionedGroup , 'Edit', 'civicrm_saved_search', {$this->_permissionedGroup}, 1
- );
- ");
+ if ($isProfile) {
+ CRM_Core_DAO::executeQuery("
+ INSERT INTO civicrm_acl (
+ `name`, `entity_table`, `entity_id`, `operation`, `object_table`, `object_id`, `is_active`
+ )
+ VALUES (
+ 'view picked', 'civicrm_acl_role', 55, 'Edit', 'civicrm_uf_group', 0, 1
+ );
+ ");
+ }
+ else {
+ CRM_Core_DAO::executeQuery("
+ INSERT INTO civicrm_acl (
+ `name`, `entity_table`, `entity_id`, `operation`, `object_table`, `object_id`, `is_active`
+ )
+ VALUES (
+ 'view picked', 'civicrm_group', $this->_permissionedGroup , 'Edit', 'civicrm_saved_search', {$this->_permissionedGroup}, 1
+ );
+ ");
+
+ CRM_Core_DAO::executeQuery("
+ INSERT INTO civicrm_acl (
+ `name`, `entity_table`, `entity_id`, `operation`, `object_table`, `object_id`, `is_active`
+ )
+ VALUES (
+ 'view picked', 'civicrm_group', $this->_permissionedGroup, 'Edit', 'civicrm_saved_search', {$this->_permissionedDisabledGroup}, 1
+ );
+ ");
+ //flush cache
+ CRM_ACL_BAO_Cache::resetCache();
+ CRM_Contact_BAO_Group::getPermissionClause(TRUE);
+ CRM_ACL_API::groupPermission('whatever', 9999, NULL, 'civicrm_saved_search', NULL, NULL, TRUE);
+ }
- CRM_Core_DAO::executeQuery("
- INSERT INTO civicrm_acl (
- `name`, `entity_table`, `entity_id`, `operation`, `object_table`, `object_id`, `is_active`
- )
- VALUES (
- 'view picked', 'civicrm_group', $this->_permissionedGroup, 'Edit', 'civicrm_saved_search', {$this->_permissionedDisabledGroup}, 1
- );
- ");
$this->_loggedInUser = CRM_Core_Session::singleton()->get('userID');
$this->callAPISuccess('group_contact', 'create', array(
'group_id' => $this->_permissionedGroup,
'contact_id' => $this->_loggedInUser,
));
- //flush cache
- CRM_ACL_BAO_Cache::resetCache();
- CRM_Contact_BAO_Group::getPermissionClause(TRUE);
- CRM_ACL_API::groupPermission('whatever', 9999, NULL, 'civicrm_saved_search', NULL, NULL, TRUE);
}
/**
'uf_group_id' => $this->_ufGroupId,
'option.autoweight' => FALSE,
'values' => $baseFields,
+ 'check_permissions' => TRUE,
);
$result = $this->callAPIAndDocument('uf_field', 'replace', $params, __FUNCTION__, __FILE__);
}
}
+ /**
+ * Check Profile API permission without ACL.
+ */
+ public function testProfilesWithoutACL() {
+ $this->createLoggedInUser();
+ $baseFields[] = array(
+ 'field_name' => 'first_name',
+ 'field_type' => 'Contact',
+ 'visibility' => 'Public Pages and Listings',
+ 'weight' => 3,
+ 'label' => 'Test First Name',
+ 'is_searchable' => 1,
+ 'is_active' => 1,
+ );
+ CRM_Core_Config::singleton()->userPermissionClass->permissions = array('access CiviCRM');
+ $params = array(
+ 'uf_group_id' => $this->_ufGroupId,
+ 'option.autoweight' => FALSE,
+ 'values' => $baseFields,
+ 'check_permissions' => TRUE,
+ );
+ $this->_loggedInUser = CRM_Core_Session::singleton()->get('userID');
+ $result = $this->callAPIFailure('uf_field', 'replace', $params);
+ }
+
+ /**
+ * Check Profile ACL for API permission.
+ */
+ public function testACLPermissionforProfiles() {
+ $this->createLoggedInUser();
+ $this->_permissionedGroup = $this->groupCreate(array(
+ 'title' => 'Edit Profiles',
+ 'is_active' => 1,
+ 'name' => 'edit-profiles',
+ ));
+ $this->setupACL(TRUE);
+ $this->testReplaceUFFields();
+ }
+
}