Commit e3822ed8 authored by Peter Tönnies's avatar Peter Tönnies

Merge branch 'Feature/PT-makeReportsListAccesible'

parents 38d4c8b4 cd6a3680
Pipeline #83602689 canceled with stages
in 2 minutes and 56 seconds
......@@ -45,6 +45,7 @@
- Updated the wording regarding "not more than 2 foodsavers per pickup !1029 @peter.toennies
- Fixed bell notifications for new wallposts in stores !1030 @jofranz
- The map is zoomed out in case no address is specified instead of showing the ocean !1053 @dthulke
- A region's reports are now accessible for the ambassadors in charge via the region menus !1041 @peter.toennies
## Bugfixes
- Profile button "remove from all slots" is now only enabled for orga !968 #362 @fs_k
......
......@@ -101,6 +101,14 @@
>
<i class="fas fa-address-card" />Ausweise
</a>
<a
v-if="region.isBot"
:href="$url('reports', region.id)"
role="menuitem"
class="dropdown-item dropdown-item-sub"
>
<i class="fas fa-poo" />{{ $i18n('terminology.reports') }}
</a>
</b-collapse>
</div>
<div
......
......@@ -55,5 +55,6 @@ export default {
press: () => '/?page=content&sub=presse',
imprint: () => '/impressum',
donate: () => '/unterstuetzung',
changelog: () => '/?page=content&sub=changelog'
changelog: () => '/?page=content&sub=changelog',
reports: (regionId) => `/?page=report&bid=${regionId}`
}
......@@ -131,6 +131,7 @@ terminology:
admins: Administratoren
wall: Pinnwand
statistic: Statistik
reports: Regelverletzungen (Preview)
fsp: Fair-Teiler
groups: Arbeitsgruppen
group: Arbeitsgruppe
......
......@@ -8,6 +8,7 @@ use Foodsharing\Modules\Event\EventGateway;
use Foodsharing\Modules\FairTeiler\FairTeilerGateway;
use Foodsharing\Modules\Foodsaver\FoodsaverGateway;
use Foodsharing\Permissions\ForumPermissions;
use Foodsharing\Permissions\ReportPermissions;
use Foodsharing\Services\ForumService;
use Foodsharing\Services\ImageService;
use Symfony\Component\Form\FormFactoryBuilder;
......@@ -32,6 +33,7 @@ final class RegionControl extends Control
private $forumPermissions;
private $regionHelper;
private $imageService;
private $reportPermissions;
/**
* @required
......@@ -59,6 +61,7 @@ final class RegionControl extends Control
ForumService $forumService,
RegionGateway $gateway,
RegionHelper $regionHelper,
ReportPermissions $reportPermissions,
ImageService $imageService
) {
$this->gateway = $gateway;
......@@ -70,6 +73,7 @@ final class RegionControl extends Control
$this->forumFollowerGateway = $forumFollowerGateway;
$this->forumService = $forumService;
$this->regionHelper = $regionHelper;
$this->reportPermissions = $reportPermissions;
$this->imageService = $imageService;
parent::__construct();
......@@ -83,28 +87,32 @@ final class RegionControl extends Control
private function regionViewData($region, $activeSubpage)
{
$isWorkGroup = $this->isWorkGroup($region);
$regionId = (int)$region['id'];
$menu = [
['name' => 'terminology.forum', 'href' => '/?page=bezirk&bid=' . (int)$region['id'] . '&sub=forum'],
['name' => 'terminology.events', 'href' => '/?page=bezirk&bid=' . (int)$region['id'] . '&sub=events'],
['name' => 'group.members', 'href' => '/?page=bezirk&bid=' . (int)$region['id'] . '&sub=members'],
['name' => 'terminology.forum', 'href' => '/?page=bezirk&bid=' . $regionId . '&sub=forum'],
['name' => 'terminology.events', 'href' => '/?page=bezirk&bid=' . $regionId . '&sub=events'],
['name' => 'group.members', 'href' => '/?page=bezirk&bid=' . $regionId . '&sub=members'],
];
if ($this->forumPermissions->mayAccessAmbassadorBoard($region['id']) && !$isWorkGroup) {
$menu[] = ['name' => 'terminology.ambassador_forum', 'href' => '/?page=bezirk&bid=' . (int)$region['id'] . '&sub=botforum'];
$menu[] = ['name' => 'terminology.ambassador_forum', 'href' => '/?page=bezirk&bid=' . $regionId . '&sub=botforum'];
}
if ($isWorkGroup) {
$menu[] = ['name' => 'terminology.wall', 'href' => '/?page=bezirk&bid=' . (int)$region['id'] . '&sub=wall'];
$menu[] = ['name' => 'terminology.wall', 'href' => '/?page=bezirk&bid=' . $regionId . '&sub=wall'];
if ($region['has_children'] === 1) {
$menu[] = ['name' => 'terminology.subgroup', 'href' => '/?page=groups&p=' . (int)$region['id']];
$menu[] = ['name' => 'terminology.subgroup', 'href' => '/?page=groups&p=' . $regionId];
}
if ($this->session->may('orga') || $this->session->isAdminFor($region['id'])) {
$menu[] = ['name' => 'Gruppe verwalten', 'href' => '/?page=groups&sub=edit&id=' . (int)$region['id']];
$menu[] = ['name' => 'Gruppe verwalten', 'href' => '/?page=groups&sub=edit&id=' . $regionId];
}
} else {
$menu[] = ['name' => 'terminology.fsp', 'href' => '/?page=bezirk&bid=' . (int)$region['id'] . '&sub=fairteiler'];
$menu[] = ['name' => 'terminology.groups', 'href' => '/?page=groups&p=' . (int)$region['id']];
$menu[] = ['name' => 'terminology.statistic', 'href' => '/?page=bezirk&bid=' . (int)$region['id'] . '&sub=statistic'];
$menu[] = ['name' => 'terminology.fsp', 'href' => '/?page=bezirk&bid=' . $regionId . '&sub=fairteiler'];
$menu[] = ['name' => 'terminology.groups', 'href' => '/?page=groups&p=' . $regionId];
$menu[] = ['name' => 'terminology.statistic', 'href' => '/?page=bezirk&bid=' . $regionId . '&sub=statistic'];
if ($this->reportPermissions->mayAccessReportsForRegion($regionId)) {
$menu[] = ['name' => 'terminology.reports', 'href' => '/?page=report&bid=' . $regionId];
}
}
if ($this->mayAccessApplications($region['id'])) {
if ($requests = $this->gateway->listRequests($region['id'])) {
......
......@@ -14,7 +14,7 @@ class ReportPermissions
$this->session = $session;
}
public function mayAccessReportsForRegion($regionId): bool
public function mayAccessReportsForRegion(int $regionId): bool
{
/* from https://gitlab.com/foodsharing-dev/foodsharing/issues/296
* and https://gitlab.com/foodsharing-dev/foodsharing/merge_requests/529
......
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