Skip to content

Commit

Permalink
CRM-20751: Support Drupal aliases for event links in Views
Browse files Browse the repository at this point in the history
  • Loading branch information
twomice committed Jun 20, 2017
1 parent 86664cd commit 9914e49
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 45 deletions.
33 changes: 12 additions & 21 deletions modules/views/civicrm/civicrm_handler_field_event_link.inc
Original file line number Diff line number Diff line change
Expand Up @@ -100,48 +100,39 @@ class civicrm_handler_field_event_link extends views_handler_field {

case 'page':
if (user_access('view event info') && $data !== NULL && $data !== '') {
return civicrm_views_href($data,
'civicrm/event/info',
"reset=1&id={$values->{$this->aliases['id']}}"
);
$path = "civicrm/event/info?reset=1&id={$values->{$this->aliases['id']}}";
return civicrm_views_href($data, drupal_get_path_alias($path), NULL);
}

// LINKING TO EVENT REGISTRATION PAGE
case 'registration':
if (user_access('register for events') && $data !== NULL && $data !== '') {
require_once 'CRM/Core/Config.php';
$config = CRM_Core_Config::singleton();
if ($enable_cart =
CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::EVENT_PREFERENCES_NAME, 'enable_cart')) {
if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::EVENT_PREFERENCES_NAME, 'enable_cart')) {
require_once 'CRM/Event/Cart/BAO/EventInCart.php';
//TODO don't call for every row
$link = CRM_Event_Cart_BAO_EventInCart::get_registration_link($values->{$this->aliases['id']});
return civicrm_views_href($link['label'], $link['path'], $link['query']);
$label = $link['label'];
$path = "{$link['path']}?{$link['query']}";
}
else {
return civicrm_views_href($data,
'civicrm/event/register',
"reset=1&id={$values->{$this->aliases['id']}}"
);
$label = $data;
$path = "civicrm/event/register?reset=1&id={$values->{$this->aliases['id']}}";
}
return civicrm_views_href($label, drupal_get_path_alias($path), NULL);
}

// LINKING TO EVENT CONFIG PAGE
case 'config':
if (user_access('access CiviEvent') && $data !== NULL && $data !== '') {
return civicrm_views_href($data,
'civicrm/event/manage/eventInfo',
"action=update&id={$values->{$this->aliases['id']}}&reset=1"
);
$path = "civicrm/event/manage/settings?action=update&id={$values->{$this->aliases['id']}}&reset=1";
return civicrm_views_href($data, drupal_get_path_alias($path), NULL);
}

// LINKING TO EVENT PARTICIPANTS LIST
case 'participants':
if (user_access('access CiviEvent') && $data !== NULL && $data !== '') {
return civicrm_views_href($data,
'civicrm/event/search',
"reset=1&force=1&event={$values->{$this->aliases['id']}}"
);
$path = "civicrm/event/search?reset=1&force=1&event={$values->{$this->aliases['id']}}";
return civicrm_views_href($data, drupal_get_path_alias($path), NULL);
}

// CUSTOM NODE LINKAGE, GOOD FOR LINKING TO OTHER VIEWS WITH AN ARGUMENT
Expand Down
36 changes: 12 additions & 24 deletions modules/views/civicrm/civicrm_handler_field_link_event.inc
Original file line number Diff line number Diff line change
Expand Up @@ -107,55 +107,43 @@ class civicrm_handler_field_link_event extends views_handler_field {

case 'page':
if (user_access('view event info') && $link_text !== NULL && $link_text !== '') {
return civicrm_views_href($link_text,
'civicrm/event/info',
"id={$values->id}&reset=1"
);
$path = "civicrm/event/info?reset=1&id={$values->{$this->aliases['id']}}";
return civicrm_views_href($link_text, drupal_get_path_alias($path), NULL);
}

// LINKING TO EVENT REGISTRATION
case 'register':
if (user_access('register for events') && $link_text !== NULL && $link_text !== '') {
return civicrm_views_href($link_text,
'civicrm/event/register',
"id={$values->id}&reset=1"
);
$path = "civicrm/event/register?reset=1&id={$values->{$this->aliases['id']}}";
return civicrm_views_href($link_text, drupal_get_path_alias($path), NULL);
}

// LINKING TO EVENT CONFIG
case 'config':
if (user_access('access CiviEvent') && $link_text !== NULL && $link_text !== '') {
return civicrm_views_href($link_text,
'civicrm/event/manage',
"action=update&id={$values->id}&reset=1"
);
$path = "civicrm/event/manage/settings?action=update&id={$values->{$this->aliases['id']}}&reset=1";
return civicrm_views_href($link_text, drupal_get_path_alias($path), NULL);
}

// LINKING TO EVENT PARTICIPANT LISTING
case 'listing':
if (user_access('view event participants') && $link_text !== NULL && $link_text !== '') {
return civicrm_views_href($link_text,
'civicrm/event/participant',
"reset=1&id={$values->id}"
);
$path = "civicrm/event/participant?reset=1&id={$values->id}";
return civicrm_views_href($link_text, drupal_get_path_alias($path), NULL);
}

// LINKING TO EVENT PARTICIPANTS
case 'participants':
if (user_access('edit event participants') && $link_text !== NULL && $link_text !== '') {
return civicrm_views_href($link_text,
'civicrm/event/search',
"reset=1&force=1&event={$values->id}"
);
$path = "civicrm/event/search?reset=1&force=1&event={$values->{$this->aliases['id']}}";
return civicrm_views_href($link_text, drupal_get_path_alias($path), NULL);
}

// LINKING TO EVENT DELETION
case 'delete':
if (user_access('access CiviEvent') && $link_text !== NULL && $link_text !== '') {
return civicrm_views_href($link_text,
'civicrm/event/manage',
"action=delete&id={$values->id}"
);
$path = "civicrm/event/manage?action=delete&id={$values->id}";
return civicrm_views_href($link_text, drupal_get_path_alias($path), NULL);
}

// CUSTOM NODE LINKAGE, GOOD FOR LINKING TO OTHER VIEWS WITH AN ARGUMENT
Expand Down

0 comments on commit 9914e49

Please sign in to comment.