1<?php 2//~ include_once DOKU_PLUGIN."bez/models/bezcache.php"; 3 4$template['tid'] = isset($nparams['tid']) ? $nparams['tid'] : '-1'; 5$template['action'] = isset($nparams['action']) ? $nparams['action'] : '-default'; 6 7if (isset($_POST['tasktype'])) { 8 $tasktype = $_POST['tasktype']; 9} else { 10 $tasktype = $nparams['tasktype']; 11} 12$template['tasktype'] = $tasktype; 13 14try { 15 16 $task = $this->model->tasks->create_object( 17 array('tasktype' => $tasktype)); 18 $template['task'] = $task; 19 20 //$template['auth_level'] = $task->get_level(); 21 //$template['user'] = $task->get_user(); 22 $value['tasktype'] = $tasktype; 23 $value['executor'] = $this->model->user_nick; 24 25 if (count($_POST) > 0) { 26 //checkboxes 27 if (!isset($_POST['all_day_event'])) { 28 $_POST['all_day_event'] = '0'; 29 } 30 31 $task->set_data($_POST); 32 //update tasktype for admins 33 34 $tid = $this->model->tasks->save($task); 35// $title = 'Dodano zadanie'; 36// $exec = $task->executor; 37// $subject = "[$conf[title]] $title: #z$tid"; 38// $to = $this->model->users->get_user_full_name($exec).' <'.$this->model->users->get_user_email($exec).'>'; 39// $body = "$uri?id=".$this->id('show_task', 'tid', $tid); 40// $this->helper->mail($to, $subject, $body); 41 42 //don't send notification when user binds himself to the task. 43 if ($task->reporter !== $task->executor) { 44 $task->mail_notify_add(NULL, array($task->executor), 45 array('action' => $bezlang['mail_task_added_programme'])); 46 } 47 header("Location: ?id=bez:task:tid:$tid"); 48 } else { 49 if (isset($nparams['duplicate'])) { 50 $tid = (int)$nparams['duplicate']; 51 $task = $this->model->tasks->get_one($tid); 52 $value = $task->get_assoc(); 53 } else { 54 $value['all_day_event'] = '1'; 55 } 56 } 57// $template['task_button'] = $bezlang['add']; 58// $template['task_action'] = $this->id('task_report', 'tasktype', $nparams['tasktype']); 59 $template['users'] = $this->model->users->get_all(); 60 $template['tasktypes'] = $this->model->tasktypes->get_all(); 61 62} catch (ValidationException $e) { 63 $errors = $e->get_errors(); 64 $value = $_POST; 65} catch (DBException $e) { 66 echo nl2br($e); 67// header("Location: ?id=bez:tasks"); 68} 69 70 71 72//$template['user'] = $task->get_user(); 73//$template['user_name'] = $this->model->users->get_user_full_name($template['user']); 74// 75//$template['users'] = $this->model->users->get_all(); 76//$template['tasktypes'] = $this->model->tasktypes->get_all(); 77//$template['tasktype_name'] = $this->model->tasktypes->get_one($nparams['tasktype'])->type; 78