Commit 22c7c006 authored by dealancer's avatar dealancer Committed by pingers

Issue #1967064 - reported by dealancer: Access denied on add activity screen.

parent a65ab82b
......@@ -157,6 +157,19 @@ function crm_core_activity_access($op, $activity, $account = NULL, $entity_type
return (user_access('administer crm_core_activity entities', $account)
|| user_access('delete any crm_core_activity entity', $account)
|| user_access('delete any crm_core_activity entity of bundle ' . $activity_type));
case 'create_view':
// Check if user has access permission to a view with create activity links.
if (user_access('administer crm_core_activity entities', $account)
|| user_access('create crm_core_activity entities', $account)) {
return TRUE;
}
// Allow access if account has create permissions for any crm core activity type .
foreach (array_keys(crm_core_activity_types()) as $type) {
if (entity_access('create', 'crm_core_activity', $type, $account)) {
return TRUE;
}
}
return FALSE;
}
}
......
......@@ -14,7 +14,7 @@ function crm_core_activity_ui_menu() {
'page callback' => 'crm_core_activity_ui_add_activity',
'page arguments' => array(2),
'access callback' => 'entity_access',
'access arguments' => array('create', 'crm_core_activity'),
'access arguments' => array('create_view', 'crm_core_activity'),
'type' => MENU_LOCAL_ACTION,
'file' => 'crm_core_activity_ui.pages.inc',
);
......
......@@ -200,17 +200,21 @@ function crm_core_activity_form_delete_confirm_submit($form, &$form_state) {
* CRM Core contact.
*/
function crm_core_activity_ui_add_activity($contact) {
global $user;
drupal_set_title(t('Add a activity'));
_crm_core_activity_ui_set_breadcrumb($contact);
$items = array();
$contact_uri = $contact->uri();
foreach (crm_core_activity_types() as $info) {
$items[] = array(
'title' => $info->label,
'href' => $contact_uri['path'] . '/activity/add/' . $info->type,
'localized_options' => array(),
'description' => $info->description,
);
if (entity_access('create', 'crm_core_activity', $info->type, $user)) {
$items[] = array(
'title' => $info->label,
'href' => $contact_uri['path'] . '/activity/add/' . $info->type,
'localized_options' => array(),
'description' => $info->description,
);
}
}
$empty = 'It is not possible to create Activities yet. Please create Activity Type fist.';
return empty($items) ? t($empty) : theme('crm_core_contact_ui_add_list', array('content' => $items));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment