Compare commits

..

7 Commits

19 changed files with 162 additions and 109 deletions

View File

@ -25,7 +25,7 @@ content:
label: above
settings: { }
third_party_settings: { }
weight: 5
weight: 4
region: content
name:
type: string
@ -33,17 +33,9 @@ content:
settings:
link_to_entity: false
third_party_settings: { }
weight: 4
region: content
oc_provider:
type: entity_reference_label
label: above
settings:
link: true
third_party_settings: { }
weight: 2
region: content
oc_target:
oc_provider:
type: entity_reference_label
label: above
settings:
@ -63,6 +55,7 @@ content:
weight: 3
region: content
hidden:
oc_target: true
search_api_excerpt: true
status: true
user_id: true

View File

@ -25,7 +25,7 @@ content:
label: above
settings: { }
third_party_settings: { }
weight: 5
weight: 4
region: content
name:
type: string
@ -33,17 +33,9 @@ content:
settings:
link_to_entity: false
third_party_settings: { }
weight: 4
region: content
oc_provider:
type: entity_reference_label
label: above
settings:
link: true
third_party_settings: { }
weight: 2
region: content
oc_target:
oc_provider:
type: entity_reference_label
label: above
settings:
@ -63,6 +55,7 @@ content:
weight: 3
region: content
hidden:
oc_target: true
search_api_excerpt: true
status: true
user_id: true

View File

@ -39,14 +39,14 @@ content:
scale: 2
prefix_suffix: true
third_party_settings: { }
weight: 5
weight: 4
region: content
field_funds_for:
type: list_default
label: above
settings: { }
third_party_settings: { }
weight: 4
weight: 3
region: content
name:
type: string
@ -54,17 +54,9 @@ content:
settings:
link_to_entity: false
third_party_settings: { }
weight: 3
weight: 2
region: content
oc_provider:
type: entity_reference_label
label: above
settings:
link: true
third_party_settings: { }
weight: 2
region: content
oc_target:
type: entity_reference_label
label: above
settings:
@ -72,8 +64,19 @@ content:
third_party_settings: { }
weight: 1
region: content
time_taken:
type: number_decimal
label: above
settings:
thousand_separator: ''
decimal_separator: .
scale: 2
prefix_suffix: true
third_party_settings: { }
weight: 5
region: content
hidden:
oc_target: true
search_api_excerpt: true
status: true
time_taken: true
user_id: true

View File

@ -29,7 +29,7 @@ content:
region: content
name:
type: string
label: above
label: hidden
settings:
link_to_entity: false
third_party_settings: { }

View File

@ -29,21 +29,13 @@ content:
region: content
name:
type: string
label: above
label: hidden
settings:
link_to_entity: false
third_party_settings: { }
weight: 3
weight: 2
region: content
oc_provider:
type: entity_reference_label
label: above
settings:
link: true
third_party_settings: { }
weight: 2
region: content
oc_target:
type: entity_reference_label
label: above
settings:
@ -51,8 +43,19 @@ content:
third_party_settings: { }
weight: 1
region: content
time_taken:
type: number_decimal
label: above
settings:
thousand_separator: ''
decimal_separator: .
scale: 2
prefix_suffix: true
third_party_settings: { }
weight: 3
region: content
hidden:
oc_target: true
search_api_excerpt: true
status: true
time_taken: true
user_id: true

View File

@ -29,21 +29,13 @@ content:
region: content
name:
type: string
label: above
label: hidden
settings:
link_to_entity: false
third_party_settings: { }
weight: 3
weight: 2
region: content
oc_provider:
type: entity_reference_label
label: above
settings:
link: true
third_party_settings: { }
weight: 2
region: content
oc_target:
type: entity_reference_label
label: above
settings:
@ -51,8 +43,19 @@ content:
third_party_settings: { }
weight: 1
region: content
time_taken:
type: number_decimal
label: above
settings:
thousand_separator: ''
decimal_separator: .
scale: 2
prefix_suffix: true
third_party_settings: { }
weight: 3
region: content
hidden:
oc_target: true
search_api_excerpt: true
status: true
time_taken: true
user_id: true

View File

@ -29,7 +29,7 @@ content:
region: content
name:
type: string
label: above
label: hidden
settings:
link_to_entity: false
third_party_settings: { }

View File

@ -8,7 +8,7 @@ slogan: ''
page:
403: /user/login
404: ''
front: /opencase/actors/client
front: /opencase/my-cases
admin_compact_mode: false
weight_select_max: 100
default_langcode: en

View File

@ -26,43 +26,12 @@ permissions:
- 'access shortcuts'
- 'access site-wide contact form'
- 'add activity entities'
- 'add case entities'
- 'add client entities'
- 'add equal opps entities'
- 'add event entities'
- 'add organisation entities'
- 'add staff_member entities'
- 'add volunteer entities'
- 'edit activity entities'
- 'edit bank account entities'
- 'edit case entities'
- 'edit client entities'
- 'edit equal opps entities'
- 'edit event entities'
- 'edit organisation entities'
- 'edit staff_member entities'
- 'edit volunteer entities'
- 'post comments'
- 'revert all activity revisions'
- 'revert all client revisions'
- 'revert all organisation revisions'
- 'revert all staff_member revisions'
- 'revert all volunteer revisions'
- 'search content'
- 'skip comment approval'
- 'use opencase'
- 'use text format basic_html'
- 'view all activity revisions'
- 'view all client revisions'
- 'view all organisation revisions'
- 'view all staff_member revisions'
- 'view all volunteer revisions'
- 'view published activity entities'
- 'view published case provision entities'
- 'view published client entities'
- 'view published equal opps entities'
- 'view published event entities'
- 'view published organisation entities'
- 'view published organisation relation entities'
- 'view published staff_member entities'
- 'view published volunteer entities'

View File

@ -3,7 +3,10 @@ langcode: en
status: true
dependencies:
config:
- user.role.authenticated
- user.role.administrator
- user.role.opencase_admin
- user.role.overseer
- user.role.volunteer_co_ord
module:
- opencase_entities
- user
@ -186,7 +189,10 @@ display:
type: role
options:
role:
authenticated: authenticated
administrator: administrator
overseer: overseer
volunteer_co_ord: volunteer_co_ord
opencase_admin: opencase_admin
cache:
type: tag
options: { }

View File

@ -4,7 +4,10 @@ status: true
dependencies:
config:
- system.menu.opencase
- user.role.authenticated
- user.role.administrator
- user.role.opencase_admin
- user.role.overseer
- user.role.volunteer_co_ord
module:
- opencase_cases
- user
@ -318,7 +321,10 @@ display:
type: role
options:
role:
authenticated: authenticated
administrator: administrator
overseer: overseer
volunteer_co_ord: volunteer_co_ord
opencase_admin: opencase_admin
cache:
type: tag
options: { }

View File

@ -3,7 +3,10 @@ langcode: en
status: true
dependencies:
config:
- user.role.authenticated
- user.role.administrator
- user.role.opencase_admin
- user.role.overseer
- user.role.volunteer_co_ord
module:
- opencase_entities
- user
@ -120,7 +123,10 @@ display:
type: role
options:
role:
authenticated: authenticated
administrator: administrator
overseer: overseer
volunteer_co_ord: volunteer_co_ord
opencase_admin: opencase_admin
cache:
type: tag
options: { }

View File

@ -3,7 +3,10 @@ langcode: en
status: true
dependencies:
config:
- user.role.authenticated
- user.role.administrator
- user.role.opencase_admin
- user.role.overseer
- user.role.volunteer_co_ord
module:
- opencase_entities
- user
@ -120,7 +123,10 @@ display:
type: role
options:
role:
authenticated: authenticated
administrator: administrator
overseer: overseer
volunteer_co_ord: volunteer_co_ord
opencase_admin: opencase_admin
cache:
type: tag
options: { }

View File

@ -139,12 +139,9 @@ function _opencase_cases_delete_activity_redirect($form, &$form_state) {
$entity = $form_state->getFormObject()->getEntity();
// for some reason this fires when deleting an activity type, shouldn't do but.s
if ($entity instanceof \Drupal\opencase_entities\Entity\OCActivityType) return;
if (!IsEmpty($entity->oc_case)) {
$case_id = $entity->oc_case->target_id;
$case_id = $entity->oc_case->target_id;
if ($case_id) {
$form_state->setRedirect('entity.oc_case.canonical', ['oc_case' => $case_id]);
} else {
$target_actor_id = $entity->oc_target->target_id;
$form_state->setRedirect('entity.oc_actor.canonical', ['oc_actor' => $target_actor_id]);
}
}
/**

View File

@ -20,12 +20,12 @@ function opencase_form_user_login_form_alter(&$form, FormStateInterface $form_st
}
/**
* If the user does not have permissions to see all cases, then when the login they are
* redirected to a view of just their own cases.
* If the user has permission to see all cases, then when the login they are
* redirected to the all cases view.
*/
function opencase_user_login_form_submit($form, FormStateInterface $form_state) {
if (!\Drupal::currentUser()->hasPermission('view published case entities')) {
$form_state->setRedirectUrl(Url::fromRoute('view.cases_by_provider.page_1'));
if (Drupal::currentUser()->hasPermission('view published case entities')) {
$form_state->setRedirectUrl( Url::fromUserInput('/opencase/cases/all'));
}
}

View File

@ -2,4 +2,8 @@ use opencase:
title: 'Use OpenCase'
description: 'Use the OpenCase case management system'
restrict access: true
view opencase add new things menu:
title: 'View OpenCase "add new things" menu'
description: 'View OpenCase "add new things" menu'
restrict access: true

View File

@ -5,12 +5,12 @@ opencase.opencase_admin_menu:
opencase.opencase_cases_menu:
path: '/'
requirements:
_permission: 'use opencase'
_permission: 'view published case entities'
opencase.opencase_add_new_things_menu:
path: '/'
requirements:
_permission: 'use opencase'
_permission: 'view published case entities'
opencase.opencase_reporting_menu:
path: '/'
requirements:
_permission: 'use opencase'
_permission: 'view published case entities'

View File

@ -5,4 +5,9 @@ services:
# Priority determines the order in which Breadcrumb services run.
tags:
- { name: breadcrumb_builder, priority: 100 }
- { name: breadcrumb_builder, priority: 100 }
opencase.subscriber:
class: Drupal\opencase\EventSubscriber\OpencaseSubscriber
tags:
- { name: event_subscriber }

View File

@ -0,0 +1,59 @@
<?php
namespace Drupal\opencase\EventSubscriber;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use Drupal\Core\Url;
/**
* Class OpencaseSubscriber.
*
* @package Drupal\opencase\EventSubscriber
*/
class OpencaseSubscriber implements EventSubscriberInterface {
private $alternativeHomePage = '/opencase/cases/all';
/**
* Registers the methods in this class that should be listeners.
*
* @return array
* An array of event listener definitions.
*/
public static function getSubscribedEvents() {
$events[KernelEvents::REQUEST][] = ['onRequest'];
return $events;
}
/**
* Manipulates the request object.
*
* @param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event
* The Event to process.
*/
public function onRequest(GetResponseEvent $event): void {
if ($this->requestIsForHomePage($event) && $this->currentUserShouldBeDirectedToAlternativeHomePage()){
$this->redirectToAlternativeHomePage($event);
}
}
private function requestIsForHomePage($event):bool {
return $event->getRequest()->getRequestUri() == '/';
}
private function currentUserShouldBeDirectedToAlternativeHomePage():bool {
return $this->currentUserCanSeeAllCases();
}
private function currentUserCanSeeAllCases():bool {
return \Drupal::currentUser()->hasPermission('view published case entities');
}
private function redirectToAlternativeHomePage(GetResponseEvent $event):void {
$redirect_target_url = Url::fromUserInput($this->alternativeHomePage);
$response = new RedirectResponse($redirect_target_url->setAbsolute()->toString());
$event->setResponse($response);
}
}