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 7try { 8 if ($template['tid'] === '-1') { 9 10 $task = $this->model->tasks->create_object_program( 11 array('tasktype' => $_POST['tasktype'])); 12 13 $template['auth_level'] = $task->get_level(); 14 $value['tasktype'] = $nparams['tasktype']; 15 16 if (count($_POST) > 0) { 17 //checkboxes 18 if (!isset($_POST['all_day_event'])) { 19 $_POST['all_day_event'] = '0'; 20 } 21 22 $task->set_data($_POST); 23 //update tasktype for admins 24 25 $tid = $this->model->tasks->save($task); 26// $title = 'Dodano zadanie'; 27// $exec = $task->executor; 28// $subject = "[$conf[title]] $title: #z$tid"; 29// $to = $this->model->users->get_user_full_name($exec).' <'.$this->model->users->get_user_email($exec).'>'; 30// $body = "$uri?id=".$this->id('show_task', 'tid', $tid); 31// $this->helper->mail($to, $subject, $body); 32 33 header("Location: ?id=bez:task:tid:$tid"); 34 } else { 35 $value['all_day_event'] = '1'; 36 if (isset($nparams['duplicate'])) { 37 $tid = (int)$nparams['duplicate']; 38 $task = $this->model->tasks->get_one($tid); 39 $value = $task->get_assoc(); 40 } 41 } 42// $template['task_button'] = $bezlang['add']; 43// $template['task_action'] = $this->id('task_report', 'tasktype', $nparams['tasktype']); 44 /*edycja*/ 45 } else { 46 $task = $this->model->tasks->get_one($template['tid']); 47 48 $template['task'] = $task; 49 $template['auth_level'] = $task->get_level(); 50 51 if (count($_POST) > 0) { 52 //checkboxes 53 if (!isset($_POST['all_day_event'])) { 54 $_POST['all_day_event'] = '0'; 55 } 56 $task->set_data($_POST); 57 //for reason 58 $task->set_state($_POST); 59 60 $this->model->tasks->save($task); 61 //~ $bezcache = new Bezcache(); 62 //~ $bezcache->task_toupdate($task->id); 63 64 header("Location: ?id=bez:task:tid:".$task->id); 65 } else { 66 $value = $task->get_assoc(); 67 } 68 } 69} catch (ValidationException $e) { 70 $errors = $e->get_errors(); 71 $value = $_POST; 72} catch (Exception $e) { 73 header("Location: ?id=bez:issue:id:$issue_id"); 74} 75 76$template['action'] = $action; 77 78$template['user'] = $task->get_user(); 79$template['user_name'] = $this->model->users->get_user_full_name($template['user']); 80 81$template['users'] = $this->model->users->get_all(); 82$template['tasktypes'] = $this->model->tasktypes->get_all(); 83$template['tasktype_name'] = $this->model->tasktypes->get_one($nparams['tasktype'])->type; 84