1<?php 2/** @var action_plugin_bez_default $this */ 3 4use \dokuwiki\plugin\bez; 5 6if ($this->get_param('tid') == '') { 7 header('Location: ' . $this->url('tasks')); 8} 9 10/** @var bez\mdl\Task $task */ 11$task = $this->model->taskFactory->get_one($this->get_param('tid')); 12$this->tpl->set('task', $task); 13$this->tpl->set('task_comments', $this->model->task_commentFactory->get_from_task($task)); 14$this->tpl->set('task_programs', $this->model->task_programFactory->get_all()); 15 16if ($this->get_param('action') == 'comment_add') { 17 18 /** @var bez\mdl\Thread_comment $thread_comment */ 19 $task_comment = $this->model->task_commentFactory->create_object(array('task' => $task)); 20 $this->model->task_commentFactory->initial_save($task_comment, $_POST); 21 22 $anchor = 'k'.$task_comment->id; 23 $redirect = true; 24 25} elseif ($this->get_param('action') == 'subscribe') { 26 27 $task->set_participant_flags($this->model->user_nick, array('subscribent')); 28 $redirect = true; 29 30} elseif ($this->get_param('action') == 'unsubscribe') { 31 32 $task->remove_participant_flags($this->model->user_nick, array('subscribent')); 33 34 $this->add_notification($this->getLang('unsubscribed_com')); 35 $redirect = true; 36 37} elseif ($this->get_param('action') == 'invite') { 38 $client = $_POST['client']; 39 40 $task->invite($client); 41 $this->add_notification($this->model->userFactory->get_user_email($client), $this->getLang('invitation_has_been_send')); 42 43 $redirect = true; 44} elseif ($this->get_param('action') == 'comment_delete') { 45 /** @var bez\mdl\Task_comment $task_comment */ 46 $task_comment = $this->model->task_commentFactory->get_one($this->get_param('zkid'), array('task' => $task)); 47 $this->model->task_commentFactory->delete($task_comment); 48 49 $redirect = true; 50} elseif ($this->get_param('action') == 'comment_edit') { 51 /** @var bez\mdl\Task_comment $task_comment */ 52 $task_comment = $this->model->task_commentFactory->get_one($this->get_param('zkid'), array('thread' => $thread)); 53 54 if(count($_POST) === 0) { 55 $this->tpl->set_values($task_comment->get_assoc()); 56 } else { 57 $this->model->task_commentFactory->update_save($task_comment, $_POST); 58 59 $anchor = 'zk' . $task_comment->id; 60 $redirect = true; 61 } 62} elseif ($this->get_param('action') == 'task_edit') { 63 //save 64 if (count($_POST) === 0) { 65 $this->tpl->set_values($task->get_assoc()); 66 } else { 67 $this->model->taskFactory->update_save($task, $_POST); 68 $redirect = true; 69 } 70} 71 72if (isset($redirect) && $redirect == true) { 73 if (isset($anchor)) { 74 $anchor = '#'.$anchor; 75 } else { 76 $anchor = ''; 77 } 78 header("Location: " . $this->url('task', 'tid', $task->id) . $anchor); 79}