function createtask_POST(Web &$w) { $w->Task->navigation($w, "Create Task"); // unserialise input from step I and store in array: arr_req $arr_req = unserialize($w->request('formone')); // set relevant dt variables with: Today. $arr_req['dt_assigned'] = Date('c'); $arr_req['dt_first_assigned'] = Date('c'); // insert Task into database $task = new Task($w); $task->fill($arr_req); $task->insert(); // if insert is successful, store additional fields as task data // we do not want to store data from step I, the task_id (as a key=>value pair) nor the FLOW_SID if ($task->id) { foreach ($_POST as $name => $value) { if ($name != "formone" && $name != "FLOW_SID" && $name != "task_id" && $name !== CSRF::getTokenID()) { $tdata = new TaskData($w); $arr = array("task_id" => $task->id, "key" => $name, "value" => $value); $tdata->fill($arr); $tdata->insert(); unset($arr); } } // return to task dashboard $w->msg("Task " . $task->title . " added", "/task/viewtask/" . $task->id); } else { // if task insert was unsuccessful, say as much $w->msg("The Task could not be created. Please inform the IT Group", "/task/index/"); } }
/** * Create a new Task * * @param unknown $task_type * @param unknown $task_group_id * @param unknown $title * @param unknown $description * @param unknown $priority * @param unknown $dt_due * @param unknown $first_assignee_id */ function createTask($task_type, $task_group_id, $title, $description, $priority, $dt_due, $first_assignee_id) { $task = new Task($this->w); $task->task_type = $task_type; $task->task_group_id = $task_group_id; $task->title = $title; $task->description = $description; $task->priority = $priority; $task->dt_due = $dt_due; $task->first_assignee_id = $first_assignee_id; $task->assignee_id = $first_assignee_id; $task->dt_assigned = time(); $task->dt_first_assigned = time(); $task->insert(); return $task; }
} else { if ($_POST['action'] === "addtask") { if ($admin === true) { try { (new Teams())->login(htmlspecialchars_decode($team->name), $_POST['pass']); $task = new Task(); $task->name = $_POST['name']; $task->desc = implode("<%#:#%>", $_POST['desc']); $task->cat = $_POST['cat']; $task->status = $_POST['status']; $task->author = $_POST['author']; $task->solvers = explode(',', $_POST['solvers']); $task->point = $_POST['point']; //$task->flag = $_POST['flag']; $task->link = $_POST['link']; $task->insert(); $success = "HELAL LA EKLEDIN HAYIRLARA VESILE OLUR INS"; } catch (Exception $e) { $error .= $e->getMessage() . "\n"; } } } else { if ($_POST['action'] === "attempt") { if ($loggedin === true) { try { //throw new Exception("Contest has ended"); $task = new Task($_POST['id']); if ($task->attempt($_POST['flag']) === true) { $success = $ltask[6]; } else { $error = $ltask[7];
/** * start taskEdit-form with a new task * - figure out prio,label and estimated time from name * * @ingroup pages */ function TaskNew() { global $PH; $parent_task = NULL; $parent_task_id = 0; ### try to figure out parent_task ### if ($task_ids = getPassedIds('parent_task', 'tasks_*|folders_*', false)) { if (count($task_ids) != 1) { $PH->abortWarning(__("Please select only one item as parent"), ERROR_NOTE); } if ($task_ids[0] != 0) { if (!($parent_task = Task::getVisibleById($task_ids[0]))) { $PH->abortWarning(__("Insufficient rights for parent item."), ERROR_NOTE); } $parent_task_id = $parent_task->id; } else { $parent_task_id = 0; } } else { $parent_task_id = 0; } ### figure out project ### $prj_id = getOnePassedId('prj', 'projects_*', false); # NOT aborts with error if not found if (!$prj_id) { if (!$parent_task) { $PH->abortWarning(__("could not find project"), ERROR_NOTE); } $prj_id = $parent_task->project; } if (!($project = Project::getVisibleById($prj_id))) { $PH->abortWarning(__("could not find project"), ERROR_NOTE); } ### make sure parent_task is valid ### if ($parent_task_id && !($parent_task = Task::getVisibleById($parent_task_id))) { $PH->abortWarning(__("Parent task not found."), ERROR_NOTE); } $name = html_entity_decode(get('new_name')); # @@@ hack to get rid of slashed strings $estimated = '00:00:00'; ### for milestone ### $for_milestone_id = 0; if ($milestone = Task::getVisibleById(get('for_milestone'))) { $for_milestone_id = $milestone->id; } ### if parent-task is milestone for some reason, avoid parenting ### if ($parent_task && ($parent_task->category == TCATEGORY_MILESTONE || $parent_task->category == TCATEGORY_VERSION)) { $parent_task_id = 0; if (!$for_milestone_id) { $for_milestone_id = $parent_task->id; } } ### category ### $category = TCATEGORY_TASK; if (!is_null($cat = get('task_category'))) { global $g_tcategory_names; if (!isset($g_tcategory_names[$cat])) { $category = TCATEGORY_TASK; } else { $category = $cat; } } $folder_as_docu = get('task_show_folder_as_documentation', $category == TCATEGORY_DOCU ? 1 : 0); ### build dummy form ### $newtask = new Task(array('id' => 0, 'name' => $name, 'project' => $prj_id, 'state' => 1, 'estimated' => $estimated, 'category' => $category, 'parent_task' => $parent_task_id, 'for_milestone' => $for_milestone_id, 'show_folder_as_documentation' => intval($folder_as_docu))); ### set a valid create-level ### $newtask->pub_level = $project->getCurrentLevelCreate(); ### insert without editing ### if (get('noedit')) { $newtask->insert(); if (!$PH->showFromPage()) { $PH->show('projView', array('prj' => $prj)); } } else { $PH->show('taskEdit', array('tsk' => $newtask->id), $newtask); } }
function newEffortFromTimeTracking() { global $PH; global $auth; require_once confGet('DIR_STREBER') . 'db/class_effort.inc.php'; $time_end = intval(get('effort_end_seconds')); if ($time_end == 0) { $time_end = null; } $new_effort = new Effort(array('id' => 0, 'time_start' => getGMTString(get('effort_start_seconds')), 'time_end' => getGMTString($time_end), 'name' => get('description'), 'billing' => get('billing'), 'productivity' => get('productivity'))); ### get project ### $new_effort->project = get('effort_project_id'); if (!($project = Project::getVisibleById($new_effort->project))) { $PH->abortWarning(__("Could not get project of effort")); } if (!$project->isPersonVisibleTeamMember($auth->cur_user)) { $PH->abortWarning("ERROR: Insufficient rights"); } ### link to task ### $task_id = get('effort_task_id'); if (!(is_null($task_id) || $task_id == 0)) { if ($task_id == 0) { $new_effort->task = 0; } else { if ($task = Task::getVisibleById($task_id)) { $new_effort->task = $task->id; } } } else { if (get('task_name') != "") { ### create new task $newtask = new Task(array('id' => 0, 'name' => get('task_name'), 'project' => $project->id)); $newtask->insert(); $new_effort->task = $newtask->id; } } ### get person ### $new_effort->person = $auth->cur_user->id; ### go back to from if validation fails ### $failure = false; if (strToGMTime($new_effort->time_end) - strToGMTime($new_effort->time_start) < 0) { $failure = true; new FeedbackWarning(__("Cannot start before end.")); } ### write to db ### $new_effort->insert(); ### display taskView #### if (!$PH->showFromPage()) { $PH->show('projView', array('prj' => $effort->project)); } }
<?php $taskName = strip_tags($_POST['task']); $dueDate = empty($_POST['dueOn']) ? NULL : strip_tags($_POST['dueOn']); $priority = empty($_POST['prio']) ? NULL : strip_tags($_POST['prio']); require '../Models/Task.php'; if (isset($taskName)) { $newRow = Task::insert($taskName, $dueDate, $priority); echo Task::stringify($newRow); }
/** * Store a newly created resource in storage. * * @return Response */ public function store() { $model = new Task(); $a = $model->insert($_POST); return Redirect::to('project/' . $a); }