/** * Return array of ticket changes * * @param Ticket $ticket * @param integer $count * @return array */ function findByTicket($ticket, $count = null) { $count = (int) $count; if ($count < 1) { $rows = db_execute_all('SELECT * FROM ' . TABLE_PREFIX . 'ticket_changes WHERE ticket_id = ? ORDER BY version DESC', $ticket->getId()); } else { $rows = db_execute_all('SELECT * FROM ' . TABLE_PREFIX . "ticket_changes WHERE ticket_id = ? ORDER BY version DESC LIMIT 0, {$count}", $ticket->getId()); } // if if (is_foreachable($rows)) { $changes = array(); foreach ($rows as $row) { $change = new TicketChange(); $change->setTicketId($ticket->getId()); $change->setVersion($row['version']); $change->changes = unserialize($row['changes']); $change->created_on = $row['created_on'] ? new DateTimeValue($row['created_on']) : null; $change->created_by_id = (int) $row['created_by_id']; $change->created_by_name = $row['created_by_name']; $change->created_by_email = $row['created_by_email']; $changes[$row['version']] = $change; } // foreach return $changes; } else { return null; } // if }
/** * Save into database * * @return boolean */ function save() { if ($this->isNew()) { $this->setTicketId(Tickets::findNextTicketIdByProject($this->getProjectId())); } // if $changes = null; if ($this->isLoaded()) { $log_fields = array('project_id', 'milestone_id', 'parent_id', 'name', 'body', 'priority', 'due_on', 'completed_on'); $changes = new TicketChange(); $changes->setTicketId($this->getId()); $changes->setVersion($this->getVersion()); $changes->setCreatedOn(DateTimeValue::now()); $changes->setCreatedBy(get_logged_user()); if ($this->new_assignees !== false) { list($old_assignees, $old_owner_id) = $this->getAssignmentData(); if (is_array($this->new_assignees) && isset($this->new_assignees[0]) && isset($this->new_assignees[1])) { $new_assignees = $this->new_assignees[0]; $new_owner_id = $this->new_assignees[1]; } else { $new_assignees = array(); $new_owner_id = 0; } // if if ($new_owner_id != $old_owner_id) { $changes->addChange('owner', $old_owner_id, $new_owner_id); } // if sort($new_assignees); sort($old_assignees); if ($new_assignees != $old_assignees) { $changes->addChange('assignees', $old_assignees, $new_assignees); } // if } // if foreach ($this->modified_fields as $field) { if (!in_array($field, $log_fields)) { continue; } // if $old_value = array_var($this->old_values, $field); $new_value = array_var($this->values, $field); if ($old_value != $new_value) { $changes->addChange($field, $old_value, $new_value); } // if } // foreach } // if $save = parent::save(); if ($save && !is_error($save)) { if (instance_of($changes, 'TicketChange') && count($changes->changes)) { $this->changes = false; $changes->save(); } // if } // if return $save; }
public static function UserViewTicket($tid) { $xtpl = self::$xtpl; $xtpl->assign('SUPPCURR', 'current'); $xtpl->assign('TICKETSSCURR', 'current'); $tc = TicketChange::getInstance(); $user = User::getInstance(); $ticket = Ticket::getInstance(); $ticdata = $ticket->FetchData($tid); if (!is_numeric($tid) || !$ticdata) { $xtpl->parse('main.viewticket.ticketrinfo'); } elseif ($ticdata['userid'] != self::$userid) { $xtpl->parse('main.viewticket.ticketrights'); } else { $xtpl->assign('TID', $tid); $xtpl->assign('DEF' . $ticdata['status'], 'selected="selected"'); $tcs = $tc->GetButch('', '`ticketid` = "' . $tid . '"'); for ($i = 0; $i < count($tcs); $i++) { $user->id = $tcs[$i]['userid']; $xtpl->assign('USERNAME', $user->GetUsername()); $xtpl->assign('TC', $tcs[$i]); $xtpl->parse('main.viewticket.ticket.ticket' . $tcs[$i]['type']); } $xtpl->parse('main.viewticket.ticket'); } $xtpl->parse('main.viewticket'); $xtpl->parse('main'); $xtpl->out('main'); }
} */ Page::UserProfile(); break; case 'placeorder': $order = Order::getInstance(); $orderid = $order->Create($userinstance->GetID(), $_POST['pkgid'], 'new', '', '', '', '', $_POST['cycle']); Page::UserOrderPlaced($orderid); break; case 'addticket': $tc = TicketChange::getInstance(); $tid = $tc->NewTicket($_POST['subject'], $_POST['message'], $_POST['depid'], $userinstance->GetID(), $userinstance->GetID()); Page::UserViewTicket($tid); break; case 'addticketreply': $tc = TicketChange::getInstance(); $tc->ReplyTicket($_POST['message'], $_POST['ticketid'], $userinstance->GetID()); Page::UserViewTicket($_POST['ticketid']); break; case 'updatepersonalsettings': $us = UserSettings::getInstance(); $us->Set(Page::$userid, 'notifymodule', $_POST['notifymodule']); $us->Set(Page::$userid, 'language', $_POST['language']); $us->Set(Page::$userid, 'currency', $_POST['currency']); $us->Set(Page::$userid, 'notifyaddress', $_POST['notifyaddress']); if ($_POST['usernewinvoice']) { $us->Set(Page::$userid, 'usernewinvoice', 1); } else { $us->Set(Page::$userid, 'usernewinvoice', 0); } if ($_POST['userneworder']) {