function cannedResp($params) { $sql = 'SELECT answer FROM ' . KB_PREMADE_TABLE . ' WHERE isenabled=1 AND premade_id=' . db_input($params['id']); if (($res = db_query($sql)) && db_num_rows($res)) { list($response) = db_fetch_row($res); } if ($response && $params['tid'] && strpos($response, '%') !== false) { include_once INCLUDE_DIR . 'class.ticket.php'; $ticket = new Ticket($params['tid']); if ($ticket && $ticket->getId()) { $response = $ticket->replaceTemplateVars($response); } } return $response; }
public function inserir(TicketPost &$t, Ticket $ti) { parent::inserir($t); if ($t->getArquivo()->nome != '') { $arquivo = $t->getArquivo()->saveArquivo(Sistema::$caminhoDiretorio . Sistema::$caminhoDataTickets); } $this->con->executar("INSERT INTO " . Sistema::$BDPrefixo . $this->tabela . "(" . self::TICKET . ", " . self::TEXTO . ", " . self::ARQUIVO . ", " . self::DATAHORA . ", " . self::NOME . ") VALUES('" . $ti->getId() . "','" . $t->texto . "','" . $arquivo . "','" . $t->getDataHora()->mostrar("YmdHi") . "','" . $t->nome . "')"); $id = $this->con->getId(); $class = __CLASS__; $l = new $class(); $l->condicoes('', $id, self::ID); $t = $l->listar(); $lT = new ListaTickets(); $lT->alterar($ti); parent::alterar($t); }
require_once INCLUDE_DIR . 'class.ticket.php'; require_once INCLUDE_DIR . 'class.dept.php'; require_once INCLUDE_DIR . 'class.banlist.php'; $page = ''; $ticket = null; //clean start. //LOCKDOWN...See if the id provided is actually valid and if the user has access. if (!$errors && ($id = $_REQUEST['id'] ? $_REQUEST['id'] : $_POST['ticket_id']) && is_numeric($id)) { $deptID = 0; $ticket = new Ticket($id); if (!$ticket or !$ticket->getDeptId()) { $errors['err'] = _('Unknown ticket ID#') . $id; } elseif (!$thisuser->isAdmin() && (!$thisuser->canAccessDept($ticket->getDeptId()) && $thisuser->getId() != $ticket->getStaffId())) { $errors['err'] = _('Access denied. Contact admin if you believe this is in error.'); } if (!$errors && $ticket->getId() == $id) { $page = 'viewticket.inc.php'; } //Default - view } elseif (isset($_REQUEST['a']) && $_REQUEST['a'] == 'open') { //TODO: Check perm here.. $page = 'newticket.inc.php'; } //At this stage we know the access status. we can process the post. if ($_POST && !$errors) { if ($ticket && $ticket->getId()) { $errors = array(); $lock = $ticket->getLock(); //Ticket lock if any $statusKeys = array('open' => 'Open', 'Reopen' => 'Open', 'Close' => 'Closed'); switch (strtolower($_POST['a'])) {
/** * Return total number of changes recorded for a specific ticket * * @param Ticket $ticket * @return integer */ function countByTicket($ticket) { return (int) array_var(db_execute_one("SELECT COUNT(id) AS 'row_count' FROM " . TABLE_PREFIX . 'ticket_changes WHERE ticket_id = ?', $ticket->getId()), 'row_count'); }
$loginmsg = 'Excessive failed login attempts'; $errors['err'] = 'You\'ve reached maximum failed login attempts allowed. Try again later or <a href="open.php">open a new ticket</a>'; } else { //Timeout is over. //Reset the counter for next round of attempts after the timeout. $_SESSION['_client']['laststrike'] = null; $_SESSION['_client']['strikes'] = 0; } } //See if we can fetch local ticket id associated with the ID given if (!$errors && is_numeric($ticketID) && Validator::is_email($email) && ($tid = Ticket::getIdByExtId($ticketID))) { //At this point we know the ticket is valid. $ticket = new Ticket($tid); //TODO: 1) Check how old the ticket is...3 months max?? 2) Must be the latest 5 tickets?? //Check the email given. if ($ticket->getId() && strcasecmp($ticket->getEMail(), $email) == 0) { //valid match...create session goodies for the client. $user = new ClientSession($email, $ticket->getId()); $_SESSION['_client'] = array(); //clear. $_SESSION['_client']['userID'] = $ticket->getEmail(); //Email $_SESSION['_client']['key'] = $ticket->getExtId(); //Ticket ID --acts as password when used with email. See above. $_SESSION['_client']['token'] = $user->getSessionToken(); $_SESSION['TZ_OFFSET'] = $cfg->getTZoffset(); $_SESSION['daylight'] = $cfg->observeDaylightSaving(); //Log login info... $msg = sprintf("%s/%s logged in [%s]", $ticket->getEmail(), $ticket->getExtId(), $_SERVER['REMOTE_ADDR']); Sys::log(LOG_DEBUG, 'User login', $msg); //Redirect tickets.php
<?php include '../../config.inc.php'; global $currentUser; $response['success'] = false; $errors = array(); if (empty($currentUser)) { $errors[] = 'You must be logged in to perform this action.'; } if (empty($_POST['message'])) { $errors[] = 'Message is required'; } if (empty($errors)) { $ticket = new Ticket(array('issue_title' => $_POST['title'], 'description' => $_POST['message'], 'opened_by' => array('id' => $currentUser->getId()), 'category' => array('id' => 1), 'date_opened' => time())); if ($ticket->add()) { $response['success'] = true; $response['tickets_id'] = $ticket->getId(); } else { $response['error'] = "Adding the new ticket failed."; } } else { $response['error'] = implode("<br />", $errors); } echo json_encode($response);
function lookup($id) { //Assuming local ID is the only lookup used! return $id && is_numeric($id) && ($ticket = new Ticket($id)) && $ticket->getId() == $id ? $ticket : null; }
static function prepareTicketUser(Ticket $ticket) { global $DB; $query = "SELECT\n DISTINCT users_id, type\n FROM (\n SELECT usr.id as users_id, tu.type as type\n FROM `glpi_tickets_users` tu\n LEFT JOIN glpi_users usr\n ON tu.users_id = usr.id\n WHERE tu.`tickets_id` = " . $ticket->getId() . "\n \n UNION \n \n SELECT usr.id as users_id, gt.type as type\n FROM glpi_groups_tickets gt\n LEFT JOIN glpi_groups_users gu\n ON gu.groups_id = gt.groups_id\n LEFT JOIN glpi_users usr\n ON gu.users_id = usr.id\n WHERE gt.tickets_id = " . $ticket->getId() . "\n \n UNION \n \n SELECT usr.id as users_id, '2' as type\n FROM glpi_profiles prof\n LEFT JOIN glpi_profiles_users pu\n ON pu.profiles_id = prof.id\n LEFT JOIN glpi_users usr\n ON usr.id = pu.users_id\n LEFT JOIN glpi_profilerights pr\n ON pr.profiles_id = prof.id\n WHERE pr.name = 'ticket'\n AND pr.rights & " . Ticket::OWN . " = " . Ticket::OWN . "\n ) AS allactors\n WHERE type != " . CommonItilActor::OBSERVER . "\n GROUP BY users_id\n ORDER BY type DESC"; $res = $DB->query($query); $ticket_users_keys = array(); while ($current_tu = $DB->fetch_assoc($res)) { $ticket_users_keys[$current_tu['users_id']] = $current_tu['type']; } return $ticket_users_keys; }
<?php /** * Migrates the client_id on tickets * * After I wrote the migration scripts, I found out I had forgot * the client_id field. This script runs through all the tickets * that had clients, and updates the tickets in the new system. * * @copyright 2012 City of Bloomington, Indiana * @license http://www.gnu.org/licenses/agpl.txt GNU/AGPL, see LICENSE.txt * @author Cliff Ingham <*****@*****.**> */ include '../../../configuration.inc'; // Connect to the old Mongo database // Make sure to open up the mongo port (27017) in the firewall $connection = new Mongo('mongodb://rogue.bloomington.in.gov'); $mongo = $connection->crm; $result = $mongo->tickets->find(array('client_id' => array('$exists' => true))); foreach ($result as $r) { $client = new Client("{$r['client_id']}"); $ticket = new Ticket($r['number']); $ticket->setClient($client); $ticket->save(); echo "{$ticket->getId()}: {$ticket->getClient()->getName()}\n"; }
} $instance_sub_table = new Table("cc_ticket_comment", "*"); foreach ($comments as $comment) { if($comment->getViewed(2)) { $instance_sub_table->Update_table($DBHandle, "viewed_admin = '0'", "id = '" . $comment->getId() . "'"); } } $smarty->display('main.tpl'); ?> <table class="epayment_conf_table"> <tr class="form_head"> <td ><font color="#FFFFFF"><?php echo gettext("TICKET: "); ?></font><font color="#FFFFFF"><b><?php echo $ticket->getTitle(); ?></b></font></td> <td align="center" ><font color="#FFFFFF"><?php echo gettext("Number"); ?> : </font><font color="Red"> <?php echo $ticket->getId(); ?></font></td> </tr> <tr> <td> </td> </tr> <tr> <td colspan="2"> <font style="font-weight:bold; " ><?php echo gettext("BY : "); ?></font> <?php echo $ticket->getCreatorname(); ?> </td> </tr> <tr> <td> <font style="font-weight:bold; " ><?php echo gettext("PRIORITY : "); ?></font> <?php echo $ticket->getPriorityDisplay(); ?>
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 ''; } }
public function addTicket(Ticket $ticket) { if (array_key_exists($ticket->getId(), $this->tickets)) { throw new Exception('Ticket of ID ' . $ticket->getId() . ' already exists'); } else { $this->tickets[$ticket->getId()] = $ticket; } }
public static function generateSubject(Ticket $ticket) { return 'Re: [F1LAB-HLPDSK-' . $ticket->getId() . '] ' . $ticket->getName(); }
/** * Update existing ticket * * @param void * @return null */ function edit() { $mode = $_GET['mode']; if (!empty($mode) and $mode == 'reminder_only_update_mode') { $this->register_reminder_info($this->active_ticket->getId(), array('date' => dateval($_POST['reminder']), 'period' => $_POST['recurring_period'], 'type' => $_POST['recurring_period_type'])); $this->redirectToUrl($this->active_ticket->getViewUrl()); } else { $this->wireframe->print_button = false; if ($this->request->isApiCall() && !$this->request->isSubmitted()) { $this->httpError(HTTP_ERR_BAD_REQUEST); } // ifs if ($this->active_ticket->isNew()) { $this->httpError(HTTP_ERR_NOT_FOUND); } // if if (!$this->active_ticket->canEdit($this->logged_user)) { $this->httpError(HTTP_ERR_FORBIDDEN); } // if $ticket_data = $this->request->post('ticket'); if (!is_array($ticket_data)) { $ticket_data = array('name' => $this->active_ticket->getName(), 'body' => $this->active_ticket->getBody(), 'visibility' => $this->active_ticket->getVisibility(), 'parent_id' => $this->active_ticket->getParentId(), 'milestone_id' => $this->active_ticket->getMilestoneId(), 'priority' => $this->active_ticket->getPriority(), 'assignees' => Assignments::findAssignmentDataByObject($this->active_ticket), 'tags' => $this->active_ticket->getTags(), 'due_on' => $this->active_ticket->getDueOn()); } // if //BOF:mod 20121116 $options = array(); $options[] = array('url' => 'javascript:convert_object_to_milestone(\'' . $this->active_ticket->getProjectId() . '\', \'' . $this->active_ticket->getId() . '\', \'' . $this->active_ticket->getType() . '\');', 'text' => 'Milestone'); $options[] = array('url' => 'javascript:convert_object_to_page(\'' . $this->active_ticket->getProjectId() . '\', \'' . $this->active_ticket->getId() . '\', \'' . $this->active_ticket->getType() . '\');', 'text' => 'Page'); $this->wireframe->addPageAction(lang('Convert To'), 'javascript://', $options); //EOF:mod 20121116 $this->smarty->assign('ticket_data', $ticket_data); $this->smarty->assign('reminder', $this->get_reminder_info($this->active_ticket->getId())); //BOF:mod 13052011 $this->smarty->assign('ticket_id', $this->active_ticket->getId()); //EOF:mod 13052011 if ($this->request->isSubmitted()) { if (!isset($ticket_data['assignees'])) { $ticket_data['assignees'] = array(array(), 0); } // if db_begin_work(); $this->active_ticket->setAttributes($ticket_data); $save = $this->active_ticket->save(); if ($save && !is_error($save)) { db_commit(); //BOF: mod $this->active_ticket->register_departments(!empty($ticket_data['departments']) ? $ticket_data['departments'] : array()); $this->register_reminder_info($this->active_ticket->getId(), array('date' => dateval($ticket_data['reminder']), 'period' => $ticket_data['recurring_period'], 'type' => $ticket_data['recurring_period_type'])); //EOF: mod $assignees_flag_data = $this->request->post('assignee'); $this->active_ticket->register_assignees_flag($assignees_flag_data); //BOF:mod 13052011 //if ($ticket_data['flag_fyi'] || $ticket_data['flag_actionrequest']){ // $this->register_flag_fyi_actionrequest($ticket_data['flag_fyi'], $ticket_data['flag_actionrequest']); //} //EOF:mod 13052011 if ($ticket_data['new_team_id'] != $this->active_project->getId()) { $link = mysql_connect(DB_HOST, DB_USER, DB_PASS); mysql_select_db(DB_NAME); $query = "select max(integer_field_1) as count from healingcrystals_project_objects where project_id='" . $ticket_data['new_team_id'] . "' and type='Ticket'"; $result = mysql_query($query, $link); $cur_ticket_id = '1'; if (mysql_num_rows($result)) { $info = mysql_fetch_assoc($result); if ($info['count']) { $cur_ticket_id = (int) $info['count'] + 1; } } $query = "update healingcrystals_project_objects set project_id='" . $ticket_data['new_team_id'] . "', milestone_id=null, integer_field_1='" . $cur_ticket_id . "', updated_on=now(), updated_by_id='" . $this->logged_user->getId() . "' where id='" . $this->active_ticket->getId() . "' and project_id='" . $this->active_project->getId() . "'"; mysql_query($query); $query = "update healingcrystals_project_objects set project_id='" . $ticket_data['new_team_id'] . "', milestone_id=null, updated_on=now(), updated_by_id='" . $this->logged_user->getId() . "' where parent_id='" . $this->active_ticket->getId() . "' and project_id='" . $this->active_project->getId() . "'"; mysql_query($query); mysql_close($link); $this->redirectToUrl(assemble_url('project_ticket', array('project_id' => $ticket_data['new_team_id'], 'ticket_id' => $cur_ticket_id))); } if ($this->request->getFormat() == FORMAT_HTML) { flash_success('Ticket #:ticket_id has been updated', array('ticket_id' => $this->active_ticket->getTicketId())); $this->redirectToUrl($this->active_ticket->getViewUrl()); } else { $this->serveData($this->active_ticket, 'ticket'); } // if } else { db_rollback(); if ($this->request->getFormat() == FORMAT_HTML) { $this->smarty->assign('errors', $save); } else { $this->serveData($save); } // if } // if } // if } }
// Just ignore bad Resolutions } try { $zend_db->insert('tickets', $data); } catch (Exception $e) { // Just log the problem tickets and move on // We'll need to check the log once we're done echo "Ticket save failed: {$e->getMessage()}\n"; fwrite($TICKET_FAILURE_LOG, $e->getMessage() . "\n"); fwrite($TICKET_FAILURE_LOG, print_r($data, true)); fwrite($TICKET_FAILURE_LOG, print_r($r, true)); continue; } $ticket = new Ticket($data['id']); $ticketCount++; echo "[{$ticketCount}] Ticket: {$ticket->getId()} "; if (isset($r['history'])) { foreach ($r['history'] as $h) { createHistory($ticket, $h); } } echo "Issues"; $count = 0; foreach ($r['issues'] as $i) { $issue = new Issue(); $issue->setTicket($ticket); if (!empty($i['contactMethod'])) { handleContactMethod($issue, $i, 'contactMethod'); } if (!empty($i['responseMethod'])) { handleContactMethod($issue, $i, 'responseMethod');
$person = new Person($row2['username']); $history->setEnteredByPerson($person); $history->setActionPerson($person); $ticket->updateHistory($history); } // // responses go in issueHistory // $sql = "select r.date as date,r.notes as notes,\n u.username as username, c.name as contactMethod\n\t\tfrom responses r\n left join referrals rf on r.referral_id = rf.id\n left join users u on r.user_id = u.id\n left join contactMethods c on r.contactMethod_id = c.id\n\t\twhere rf.request_id=" . $row['id']; $result2 = $pdo->query($sql); while ($result2 && ($row2 = $result2->fetch(PDO::FETCH_ASSOC))) { $history = new History(); $history->setAction('response'); $history->setEnteredDate($row2['date']); $history->setActionDate($row2['date']); $history->setNotes($row2['notes']); $person = new Person($row2['username']); $history->setEnteredByPerson($person); $history->setActionPerson($person); $ticket->updateHistory($history); } try { $ticket->save(); echo $ticket->getId() . " {$cnt}\n"; $cnt++; } catch (Exception $e) { echo $e->getMessage() . "\n"; print_r($e); exit; } }
$instance_sub_table->Update_table($DBHandle, "viewed_agent = '0'", "id = '" . $comment->getId() . "'"); } } $smarty->display('main.tpl'); ?> <table class="epayment_conf_table"> <tr class="form_head"> <td ><font color="#FFFFFF"><?php echo gettext("TICKET: "); ?> </font><font color="#FFFFFF"><b><?php echo $ticket->getTitle(); ?> </b></font></td> <td align="center" ><font color="#FFFFFF">Number : </font><font color="Red"> <?php echo $ticket->getId(); ?> </font></td> </tr> <tr> <td> </td> </tr> <tr> <td colspan="2"> <font style="font-weight:bold; " ><?php echo gettext("BY : "); ?> </font> <?php echo $ticket->getCreatorname();
<?php /** * This runs through all the tickets and calls the validation function * for each one. Any bad tickets will be reported. * * @copyright 2013 City of Bloomington, Indiana * @license http://www.gnu.org/licenses/agpl.txt GNU/AGPL, see LICENSE.txt * @author Cliff Ingham <*****@*****.**> */ include '../configuration.inc'; $sql = 'select * from tickets'; $zend_db = Database::getConnection(); $query = $zend_db->query($sql); while ($row = $query->fetch()) { $ticket = new Ticket($row); try { $ticket->validate(); } catch (Exception $e) { echo "Ticket {$ticket->getId()} fails validation: {$e->getMessage()}\n"; } }