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