xref: /plugin/bez/ctl/8d.php (revision d5a60e5ac169029e79a301a30ed6a5cd36b654f3)
1<?php
2/** @var action_plugin_bez $this */
3
4use \dokuwiki\plugin\bez;
5
6$variant = $this->get_param('var', '1');
7
8//if we don't have a token, generate a new one and redirect
9if (!isset($_GET['t']) && $this->model->authentication_tokenFactory->can_create_token()) {
10    $token = $this->model->authentication_tokenFactory->create_token($this->id());
11    header('Location: ' .
12           wl($this->id('8d', 'id', $this->get_param('id'), 'var', $variant), array('t' => $token), false, '&'));
13}
14
15if ($this->model->get_level() < BEZ_AUTH_VIEWER) {
16    throw new bez\meta\PermissionDeniedException();
17}
18
19$this->tpl->set('variant', $variant);
20/** @var bez\mdl\Thread $thread */
21$thread = $this->model->threadFactory->get_one($this->get_param('id'));
22$this->tpl->set('thread', $thread);
23$this->tpl->set('causes',
24        $this->model->thread_commentFactory->
25        get_from_thread($thread, array('type' => 'cause'))->fetchAll());
26$this->tpl->set('risks',
27    $this->model->thread_commentFactory->
28    get_from_thread($thread, array('type' => 'risk'))->fetchAll());
29$this->tpl->set('opportunities',
30                $this->model->thread_commentFactory->
31                get_from_thread($thread, array('type' => 'opportunity'))->fetchAll());
32$tasks = $this->model->taskFactory->get_by_type($thread);
33$this->tpl->set('8d_tasks', $tasks);
34