Opencase_cases.module is still in broken state
This commit is contained in:
parent
715f5f34c4
commit
06b2409c61
@ -35,14 +35,13 @@ function opencase_cases_theme() {
|
|||||||
'render element' => 'elements',
|
'render element' => 'elements',
|
||||||
'file' => 'oc_case.page.inc',
|
'file' => 'oc_case.page.inc',
|
||||||
'template' => 'oc_case',
|
'template' => 'oc_case',
|
||||||
]
|
],
|
||||||
'oc_case_content_add_list' => [
|
'oc_case_content_add_list' => [
|
||||||
'render element' => 'content',
|
'render element' => 'content',
|
||||||
'variables' => ['content' => NULL],
|
'variables' => ['content' => NULL],
|
||||||
'file' => 'oc_case.page.inc',
|
'file' => 'oc_case.page.inc',
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function opencase_cases_entity_base_field_info($entity_type) {
|
function opencase_cases_entity_base_field_info($entity_type) {
|
||||||
@ -68,13 +67,13 @@ function opencase_cases_entity_base_field_info($entity_type) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When creating an activity, it sets the case id from the URL.
|
/* When creating an activity, it sets the case id from the URL.
|
||||||
*/
|
/*/
|
||||||
public static function opencase_cases_default_activity_case_value() {
|
public static function opencase_cases_default_activity_case_value() {
|
||||||
return array(\Drupal::request()->query->get('case_id'));
|
return array(\Drupal::request()->query->get('case_id'));
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
|
/**
|
||||||
* Implementation of hook_form_alter()
|
* Implementation of hook_form_alter()
|
||||||
* Changes what page is redirected to after deleting things
|
* Changes what page is redirected to after deleting things
|
||||||
*/
|
*/
|
||||||
@ -87,31 +86,31 @@ function opencase_cases_form_alter(&$form, &$form_state, $form_id) {
|
|||||||
$form['actions']['submit']['#submit'][] = '_opencase_cases_delete_activity_redirect';
|
$form['actions']['submit']['#submit'][] = '_opencase_cases_delete_activity_redirect';
|
||||||
$form['actions']['cancel']['#url'] = $form_state->getFormObject()->getEntity()->toUrl();
|
$form['actions']['cancel']['#url'] = $form_state->getFormObject()->getEntity()->toUrl();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function _opencase_cases_redirect_to_home($form, &$form_state) {
|
function _opencase_cases_redirect_to_home($form, &$form_state) {
|
||||||
$form_state->setRedirect('<front>');
|
$form_state->setRedirect('<front>');
|
||||||
}
|
|
||||||
function _opencase_cases_delete_activity_redirect($form, &$form_state) {
|
function _opencase_cases_delete_activity_redirect($form, &$form_state) {
|
||||||
$case_id = $form_state->getFormObject()->getEntity()->oc_case->target_id;
|
$case_id = $form_state->getFormObject()->getEntity()->oc_case->target_id;
|
||||||
$form_state->setRedirect('entity.oc_case.canonical', ['oc_case' => $case_id]);
|
$form_state->setRedirect('entity.oc_case.canonical', ['oc_case' => $case_id]);
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* Implements hook_theme_suggestions_HOOK().
|
* Implements hook_theme_suggestions_HOOK().
|
||||||
*/
|
*/
|
||||||
function opencase_cases_theme_suggestions_oc_case(array $variables) {
|
function opencase_cases_theme_suggestions_oc_case(array $variables) {
|
||||||
$suggestions = [];
|
$suggestions = [];
|
||||||
$entity = $variables['elements']['#oc_case'];
|
$entity = $variables['elements']['#oc_case'];
|
||||||
$sanitized_view_mode = strtr($variables['elements']['#view_mode'], '.', '_');
|
$sanitized_view_mode = strtr($variables['elements']['#view_mode'], '.', '_');
|
||||||
|
|
||||||
$suggestions[] = 'oc_case__' . $sanitized_view_mode;
|
$suggestions[] = 'oc_case__' . $sanitized_view_mode;
|
||||||
$suggestions[] = 'oc_case__' . $entity->bundle();
|
$suggestions[] = 'oc_case__' . $entity->bundle();
|
||||||
$suggestions[] = 'oc_case__' . $entity->bundle() . '__' . $sanitized_view_mode;
|
$suggestions[] = 'oc_case__' . $entity->bundle() . '__' . $sanitized_view_mode;
|
||||||
$suggestions[] = 'oc_case__' . $entity->id();
|
$suggestions[] = 'oc_case__' . $entity->id();
|
||||||
$suggestions[] = 'oc_case__' . $entity->id() . '__' . $sanitized_view_mode;
|
$suggestions[] = 'oc_case__' . $entity->id() . '__' . $sanitized_view_mode;
|
||||||
return $suggestions;
|
return $suggestions;
|
||||||
}
|
}
|
||||||
|
|
||||||
function opencase_views_query_alter(Drupal\views\ViewExecutable $view, $query) {
|
function opencase_views_query_alter(Drupal\views\ViewExecutable $view, $query) {
|
||||||
if ($view->getBaseEntityType() && $view->getBaseEntityType()->id() == 'oc_case') {
|
if ($view->getBaseEntityType() && $view->getBaseEntityType()->id() == 'oc_case') {
|
||||||
$query->addTag('oc_case_access');
|
$query->addTag('oc_case_access');
|
||||||
@ -119,8 +118,8 @@ function opencase_views_query_alter(Drupal\views\ViewExecutable $view, $query) {
|
|||||||
if ($view->getBaseEntityType() && $view->getBaseEntityType()->id() == 'oc_activity') {
|
if ($view->getBaseEntityType() && $view->getBaseEntityType()->id() == 'oc_activity') {
|
||||||
$query->addTag('oc_activity_access');
|
$query->addTag('oc_activity_access');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function opencase_query_oc_case_access_alter($query) {
|
function opencase_query_oc_case_access_alter($query) {
|
||||||
if (\Drupal::currentUser()->hasPermission('view published case entities')) {
|
if (\Drupal::currentUser()->hasPermission('view published case entities')) {
|
||||||
return;
|
return;
|
||||||
@ -128,8 +127,8 @@ function opencase_query_oc_case_access_alter($query) {
|
|||||||
$linked_actor_id = CaseInvolvement::getLinkedActorId(\Drupal::currentUser());
|
$linked_actor_id = CaseInvolvement::getLinkedActorId(\Drupal::currentUser());
|
||||||
$query->addJoin('INNER', 'oc_case__actors_involved', 'access_filter', 'access_filter.entity_id = oc_case_field_data.id');
|
$query->addJoin('INNER', 'oc_case__actors_involved', 'access_filter', 'access_filter.entity_id = oc_case_field_data.id');
|
||||||
$query->condition('access_filter.actors_involved_target_id', $linked_actor_id);
|
$query->condition('access_filter.actors_involved_target_id', $linked_actor_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
function opencase_query_oc_activity_access_alter($query) {
|
function opencase_query_oc_activity_access_alter($query) {
|
||||||
if (\Drupal::currentUser()->hasPermission('view published case entities')) {
|
if (\Drupal::currentUser()->hasPermission('view published case entities')) {
|
||||||
return;
|
return;
|
||||||
@ -137,4 +136,4 @@ function opencase_query_oc_activity_access_alter($query) {
|
|||||||
$linked_actor_id = CaseInvolvement::getLinkedActorId(\Drupal::currentUser());
|
$linked_actor_id = CaseInvolvement::getLinkedActorId(\Drupal::currentUser());
|
||||||
$query->addJoin('INNER', 'oc_case__actors_involved', 'access_filter', 'access_filter.entity_id = oc_activity_field_data.oc_case');
|
$query->addJoin('INNER', 'oc_case__actors_involved', 'access_filter', 'access_filter.entity_id = oc_activity_field_data.oc_case');
|
||||||
$query->condition('access_filter.actors_involved_target_id', $linked_actor_id);
|
$query->condition('access_filter.actors_involved_target_id', $linked_actor_id);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user