public static function update($id) { self::check_logged_in(); $params = $_POST; $attributes = array('id' => $id, 'name' => $row['name'], 'laatija_id' => $row['laatija_id'], 'hero1' => $row['hero1'], 'hero2' => $row['hero2'], 'hero3' => $row['hero3'], 'hero4' => $row['hero4'], 'hero5' => $row['hero5'], 'vaikeus' => $row['vaikeus'], 'suunnitelma' => $row['suunnitelma']); $draft = new Draft($attributes); $errors = $draft->errors(); if (count($errors) == 0) { $draft->update(); Redirect::to('/drafts' . $draft->id, array('message' => 'Drafti on lisätty arkistoon!')); } else { View::make('drafts/new.html', array('errors' => $errors, 'attributes' => $attributes)); } }
if (!empty($_POST['draft_id'])) { Draft::remove($_POST['draft_id']); } // enter the time tracking entry about this new email if (!empty($_POST['time_spent'])) { $date = (array) $_POST['date']; $ttc_id = Time_Tracking::getCategoryId($prj_id, 'Email Discussion'); $time_spent = (int) $_POST['time_spent']; $summary = 'Time entry inserted when sending outgoing email.'; Time_Tracking::addTimeEntry($issue_id, $ttc_id, $time_spent, $date, $summary); } } elseif ($cat == 'save_draft') { $res = Draft::saveEmail($issue_id, $_POST['to'], $_POST['cc'], $_POST['subject'], $_POST['message'], $_POST['parent_id']); $tpl->assign('draft_result', $res); } elseif ($cat == 'update_draft') { $res = Draft::update($issue_id, $_POST['draft_id'], $_POST['to'], $_POST['cc'], $_POST['subject'], $_POST['message'], $_POST['parent_id']); $tpl->assign('draft_result', $res); } // enter the time tracking entry about this new email if ($cat == 'save_draft' || $cat == 'update_draft') { if (!empty($_POST['time_spent'])) { $date = (array) $_POST['date']; $ttc_id = Time_Tracking::getCategoryId($prj_id, 'Email Discussion'); $time_spent = (int) $_POST['time_spent']; $summary = 'Time entry inserted when saving an email draft.'; Time_Tracking::addTimeEntry($issue_id, $ttc_id, $time_spent, $date, $summary); } } if ($cat == 'view_draft') { $draft = Draft::getDetails($_GET['id']); $email = array('sup_subject' => $draft['emd_subject'], 'seb_body' => $draft['emd_body'], 'sup_from' => $draft['to'], 'cc' => implode('; ', $draft['cc']));
// remove the existing email draft, if appropriate if (!empty($HTTP_POST_VARS['draft_id'])) { Draft::remove($HTTP_POST_VARS['draft_id']); } // enter the time tracking entry about this new email if (!empty($HTTP_POST_VARS['time_spent'])) { $HTTP_POST_VARS['issue_id'] = $issue_id; $HTTP_POST_VARS['category'] = Time_Tracking::getCategoryID('Email Discussion'); $HTTP_POST_VARS['summary'] = 'Time entry inserted when sending outgoing email.'; Time_Tracking::insertEntry(); } } elseif (@$HTTP_POST_VARS["cat"] == "save_draft") { $res = Draft::saveEmail($issue_id, $HTTP_POST_VARS["to"], $HTTP_POST_VARS["cc"], $HTTP_POST_VARS["subject"], $HTTP_POST_VARS["message"], $HTTP_POST_VARS["parent_id"]); $tpl->assign("draft_result", $res); } elseif (@$HTTP_POST_VARS["cat"] == "update_draft") { $res = Draft::update($issue_id, $HTTP_POST_VARS["draft_id"], $HTTP_POST_VARS["to"], $HTTP_POST_VARS["cc"], $HTTP_POST_VARS["subject"], $HTTP_POST_VARS["message"], $HTTP_POST_VARS["parent_id"]); $tpl->assign("draft_result", $res); } elseif (Auth::getCurrentRole() >= User::getRoleID('Developer')) { $res = Issue::addUserAssociation($usr_id, $issue_id, $usr_id); } // enter the time tracking entry about this new email if (@$HTTP_POST_VARS["cat"] == "save_draft" || @$HTTP_POST_VARS["cat"] == "update_draft") { if (!empty($HTTP_POST_VARS['time_spent'])) { $HTTP_POST_VARS['issue_id'] = $issue_id; $HTTP_POST_VARS['category'] = Time_Tracking::getCategoryID('Email Discussion'); $HTTP_POST_VARS['summary'] = 'Time entry inserted when saving an email draft.'; Time_Tracking::insertEntry(); } } if (@$HTTP_GET_VARS['cat'] == 'view_draft') { $draft = Draft::getDetails($HTTP_GET_VARS['id']);