1<?php 2 3/** @var action_plugin_bez_default $this */ 4 5use \dokuwiki\plugin\bez; 6 7$task_id = $this->get_param('tid'); 8if ($task_id != '') { 9 /** @var bez\mdl\Task $task */ 10 $task = $this->model->taskFactory->get_one($this->get_param('tid')); 11} else { 12 /** @var bez\mdl\Task $task */ 13 $task = $this->model->taskFactory->create_object(); 14} 15$this->tpl->set('task', $task); 16$this->tpl->set('task_programs', $this->model->task_programFactory->get_all()); 17 18if ($this->get_param('action') == 'add') { 19 20 $this->model->taskFactory->initial_save($task, $_POST); 21 22 $redirect = true; 23} 24 25if (isset($redirect) && $redirect == true) { 26 header("Location: " . $this->url('task', 'tid', $task->id)); 27} 28 29// 30//$template['tid'] = isset($nparams['tid']) ? $nparams['tid'] : '-1'; 31//$template['action'] = isset($nparams['action']) ? $nparams['action'] : '-default'; 32// 33//if (isset($_POST['tasktype'])) { 34// $tasktype = $_POST['tasktype']; 35//} else { 36// $tasktype = $nparams['tasktype']; 37//} 38//$template['tasktype'] = $tasktype; 39// 40//try { 41// 42// $task = $this->model->tasks->create_object( 43// array('tasktype' => $tasktype)); 44// $template['task'] = $task; 45// 46// //$template['auth_level'] = $task->get_level(); 47// //$template['user'] = $task->get_user(); 48// $value['tasktype'] = $tasktype; 49// $value['executor'] = $this->model->user_nick; 50// 51// if (count($_POST) > 0) { 52// //checkboxes 53// if (!isset($_POST['all_day_event'])) { 54// $_POST['all_day_event'] = '0'; 55// } 56// 57// $task->set_data($_POST); 58// 59// if ($task->issue == '') { 60// $task->add_subscribent($task->reporter); 61// $task->add_subscribent($task->executor); 62// } 63// 64// $tid = $this->model->tasks->save($task); 65// 66// 67// //don't send notification when user binds himself to the task. 68// if ($task->reporter !== $task->executor) { 69// $task->mail_notify_add(NULL, array($task->executor), 70// array('action' => $bezlang['mail_task_added_programme'])); 71// } 72// header("Location: ?id=bez:task:tid:$tid"); 73// } else { 74// if (isset($nparams['duplicate'])) { 75// $tid = (int)$nparams['duplicate']; 76// $task = $this->model->tasks->get_one($tid); 77// $value = $task->get_assoc(); 78// } else { 79// $value['all_day_event'] = '1'; 80// } 81// } 82// 83// $template['users'] = $this->model->users->get_all(); 84// $template['tasktypes'] = $this->model->tasktypes->get_all(); 85// 86//} catch (ValidationException $e) { 87// $errors = $e->get_errors(); 88// $value = $_POST; 89//} catch (DBException $e) { 90// echo nl2br($e); 91//// header("Location: ?id=bez:tasks"); 92//} 93 94