/** * updates the ticket's status & priority. * A log entry about this will be created only if the newStatus is different from the current status and also when the newPriority is different from the current priority. * @todo break this function up into a updateStatus (already exists) and updatePriority function and perhaps write a wrapper function for the combo. * @param $ticket_id the id of the ticket of which we want to change the status & priority * @param $newStatus the new status value (integer) * @param $newPriority the new priority value (integer) * @param $author the user (id) that performed the update */ public static function updateTicketStatusAndPriority($ticket_id, $newStatus, $newPriority, $author) { $ticket = new Ticket(); $ticket->load_With_TId($ticket_id); if ($ticket->getStatus() != $newStatus) { $ticket->setStatus($newStatus); Ticket_Log::createLogEntry($ticket_id, $author, 5, $newStatus); } if ($ticket->getPriority() != $newPriority) { $ticket->setPriority($newPriority); Ticket_Log::createLogEntry($ticket_id, $author, 6, $newPriority); } $ticket->update(); }
function convertToTicket(&$logged_user, &$error) { db_begin_work(); $ticket = new Ticket(); $ticket->setProjectId($this->getProjectId()); $ticket->setName($this->getName()); $ticket->setBody($this->getBody()); $ticket->setState($this->getState()); $ticket->setVisibility($this->getVisibility()); $ticket->setPriority($this->getPriority()); $ticket->setCommentsCount($this->getCommentsCount()); $ticket->setIsLocked($this->getIsLocked()); $ticket->setCreatedById($logged_user->getId()); $ticket->setCreatedByName($logged_user->getName()); $ticket->setCreatedByEmail($logged_user->getEmail()); if ($this->getType() == 'Page') { $ticket->setMilestoneId($this->setMilestoneId()); } $save = $ticket->save(); if ($save && !is_error($save)) { db_commit(); $ticket->ready(); $link = mysql_connect(DB_HOST, DB_USER, DB_PASS); mysql_select_db(DB_NAME); $query = "update healingcrystals_project_objects set parent_id='" . $ticket->getId() . "', parent_type='Ticket' where parent_id='" . $this->getId() . "' and project_id='" . $this->getProjectId() . "' and type in ('Comment', 'Task')"; mysql_query($query); $query = "update healingcrystals_project_objects set parent_id=null, parent_type=null where parent_id='" . $this->getId() . "' and project_id='" . $this->getProjectId() . "' and type not in ('Comment', 'Task')"; mysql_query($query); if ($this->getType() == 'Milestone') { $query = "update healingcrystals_project_objects set milestone_id=null where milestone_id='" . $this->getId() . "' and project_id='" . $this->getProjectId() . "'"; mysql_query($query); } $query = "select * from healingcrystals_assignments where object_id='" . $this->getId() . "'"; $result = mysql_query($query); while ($entry = mysql_fetch_assoc($result)) { $query = "insert into healingcrystals_assignments (user_id, object_id, is_owner) values ('" . $entry['user_id'] . "', '" . $ticket->getId() . "', '" . $entry['is_owner'] . "')"; mysql_query($query); } $query = "select * from healingcrystals_project_object_categories where object_id='" . $this->getId() . "'"; $result = mysql_query($query); while ($entry = mysql_fetch_assoc($result)) { $query = "insert ignore into healingcrystals_project_object_categories (object_id, category_id) values ('" . $ticket->getId() . "', '" . $entry['category_id'] . "')"; mysql_query($query); } mysql_close($link); $this->moveToTrash(); return $ticket->getIntegerField1(); } else { db_rollback(); $error = $save; return ''; } }
} } else { $errors['err'] = $errors['err'] ? $errors['err'] : 'Error(s) occured. Unable to post the note.'; } break; case 'process': $isdeptmanager = $deptId == $thisuser->getDeptId() ? true : false; switch (strtolower($_POST['do'])) { case 'change_priority': if (!$thisuser->isadmin() && !$isdeptmanager) { $errors['err'] = 'Perm. Denied. You are not allowed to change ticket\'s priority'; } elseif (!$_POST['ticket_priority'] or !is_numeric($_POST['ticket_priority'])) { $errors['err'] = 'You must select priority'; } if (!$errors) { if ($ticket->setPriority($_POST['ticket_priority'])) { $msg = 'Priority Changed Successfully'; } else { $errors['err'] = 'Problems changing priority. Try again'; } } break; case 'close': if (!$thisuser->isadmin() && !$thisuser->canCloseTickets()) { $errors['err'] = 'Perm. Denied. You are not allowed to close tickets.'; } else { if ($ticket->close()) { $msg = 'Ticket status set to CLOSED'; } else { $errors['err'] = 'Problems closing the ticket. Try again'; }
function change_priority() { $this->active_ticket->setPriority($this->request->post('priority')); $save = $this->active_ticket->save(); }