本文整理汇总了PHP中Ticket::lookup方法的典型用法代码示例。如果您正苦于以下问题:PHP Ticket::lookup方法的具体用法?PHP Ticket::lookup怎么用?PHP Ticket::lookup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ticket
的用法示例。
在下文中一共展示了Ticket::lookup方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onTicketCreated
function onTicketCreated($answer)
{
try {
global $ost;
if (!($ticket = Ticket::lookup($answer->object_id))) {
die('Unknown or invalid ticket ID.');
}
//Slack payload
$payload = array('attachments' => array(array('pretext' => "New Ticket <" . $ost->getConfig()->getUrl() . "scp/tickets.php?id=" . $ticket->getId() . "|#" . $ticket->getId() . "> in " . Format::htmlchars($ticket->getDept() instanceof Dept ? $ticket->getDept()->getName() : '') . " via " . $ticket->getSource() . " (" . Format::db_datetime($ticket->getCreateDate()) . ")", 'fallback' => "New Ticket <" . $ost->getConfig()->getUrl() . "scp/tickets.php?id=" . $ticket->getId() . "|#" . $ticket->getId() . "> in " . Format::htmlchars($ticket->getDept() instanceof Dept ? $ticket->getDept()->getName() : '') . " via " . $ticket->getSource() . " (" . Format::db_datetime($ticket->getCreateDate()) . ")", 'color' => "#D00000", 'fields' => array(array('title' => "From: " . mb_convert_case(Format::htmlchars($ticket->getName()), MB_CASE_TITLE) . " (" . $ticket->getEmail() . ")", 'value' => '', 'short' => false)))));
//Curl to webhook
$data_string = utf8_encode(json_encode($payload));
$url = $this->getConfig()->get('slack-webhook-url');
if (!function_exists('curl_init')) {
error_log('osticket slackplugin error: cURL is not installed!');
}
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$result = curl_exec($ch);
if ($result === false) {
error_log($url . ' - ' . curl_error($ch));
} else {
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($statusCode != '200') {
error_log($url . ' Http code: ' . $statusCode);
}
}
curl_close($ch);
} catch (Exception $e) {
error_log('Error posting to Slack. ' . $e->getMessage());
}
}
示例2: delete
function delete()
{
if (($ticket = Ticket::lookup($this->getId())) && @$ticket->delete()) {
return true;
}
return false;
}
示例3: cannedResp
function cannedResp($id, $format = '')
{
global $thisstaff, $_GET;
include_once INCLUDE_DIR . 'class.canned.php';
if (!$id || !($canned = Canned::lookup($id)) || !$canned->isEnabled()) {
Http::response(404, 'No such premade reply');
}
//Load ticket.
if ($_GET['tid']) {
include_once INCLUDE_DIR . 'class.ticket.php';
$ticket = Ticket::lookup($_GET['tid']);
}
switch ($format) {
case 'json':
$resp['id'] = $canned->getId();
$resp['ticket'] = $canned->getTitle();
$resp['response'] = $ticket ? $ticket->replaceVars($canned->getResponse()) : $canned->getResponse();
$resp['files'] = $canned->getAttachments();
$response = $this->json_encode($resp);
break;
case 'txt':
default:
$response = $ticket ? $ticket->replaceVars($canned->getResponse()) : $canned->getResponse();
}
return $response;
}
示例4: addByTicketAction
public function addByTicketAction($id = 0)
{
$args = array();
if (isset($id) && $id > 0) {
$ticket = Ticket::lookup($id);
}
$ticket_items = Equipment_Ticket::getAllTickets();
$tickets = array();
foreach ($ticket_items as $item) {
$ti = array('id' => $item->getId(), 'number' => $item->getNumber(), 'subject' => $item->getSubject());
$tickets[] = $ti;
}
$equipment_items = Equipment_Ticket::getAllEquipment();
$equipments = array();
foreach ($equipment_items as $item) {
$ti = array('id' => $item->id, 'asset_id' => $item->asset_id);
$equipments[] = $ti;
}
$title = 'New Recurring Ticket';
$args['ticket'] = $ticket;
$args['tickets'] = $tickets;
$args['equipments'] = $equipments;
$args['title'] = $title;
$template_name = $this->getAddTemplateName();
$this->render($template_name, $args);
}
示例5: getTicket
public function getTicket()
{
if ($this->ticket_id > 0) {
return \Ticket::lookup($this->ticket_id);
}
return null;
}
示例6: acquireLock
function acquireLock($tid)
{
global $cfg, $thisstaff;
if (!$tid or !is_numeric($tid) or !$thisstaff or !$cfg) {
return 0;
}
$ticket = Ticket::lookup($tid);
if (!$ticket || !$ticket->checkStaffAccess($thisstaff)) {
return $this->json_encode(array('id' => 0, 'retry' => false, 'msg' => 'Lock denied!'));
}
//is the ticket already locked?
if ($ticket->isLocked() && ($lock = $ticket->getLock()) && !$lock->isExpired()) {
/*Note: Ticket->acquireLock does the same logic...but we need it here since we need to know who owns the lock up front*/
//Ticket is locked by someone else.??
if ($lock->getStaffId() != $thisstaff->getId()) {
return $this->json_encode(array('id' => 0, 'retry' => false, 'msg' => 'Unable to acquire lock.'));
}
//Ticket already locked by staff...try renewing it.
$lock->renew();
//New clock baby!
return $this->json_encode(array('id' => $lock->getId(), 'time' => $lock->getTime()));
}
//Ticket is not locked or the lock is expired...try locking it...
if ($lock = $ticket->acquireLock($thisstaff->getId(), $cfg->getLockTime())) {
//Set the lock.
return $this->json_encode(array('id' => $lock->getId(), 'time' => $lock->getTime()));
}
//unable to obtain the lock..for some really weired reason!
//Client should watch for possible loop on retries. Max attempts?
return $this->json_encode(array('id' => 0, 'retry' => true));
}
示例7: getTicket
function getTicket()
{
if (!$this->ticket && $this->getTicketId()) {
$this->ticket = Ticket::lookup($this->getTicketId());
}
return $this->ticket;
}
示例8: onThreadEntry
function onThreadEntry($threadEntry)
{
if ($threadEntry->getType() == "N") {
return;
}
//system entry
$ticket = Ticket::lookup($threadEntry->ht['ticket_id']);
$recip = $ticket->getRecipients();
// conntact api for each recipient
foreach ($recip as $user) {
//skip thread entry creator
if ($threadEntry->getUserId() == $user->getId()) {
continue;
}
//$fields = $this->getConfig()->get('webapi-fields');
try {
//format Your payload as Your api need
$payload = array('method' => 'addNotification', 'params' => array('ticketID' => $ticket->getId(), 'title' => $ticket->getSubject(), 'value' => $threadEntry->getBody(), 'poster' => $threadEntry->getPoster()));
$data_string = utf8_encode(json_encode($payload));
$url = $this->getConfig()->get('webapi-url');
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Content-Length: ' . strlen($data_string)));
$content = curl_exec($ch);
if ($content === false) {
throw new Exception($url . ' - ' . curl_error($ch));
} else {
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($statusCode != '200') {
throw new Exception($url . ' Http code: ' . $statusCode);
}
}
curl_close($ch);
} catch (Exception $e) {
error_log('Error posting to Web API. ' . $e->getMessage());
}
}
}
示例9: require
<?php
require('staff.inc.php');
require_once(INCLUDE_DIR.'class.ticket.php');
require_once(INCLUDE_DIR.'class.dept.php');
if($_REQUEST['transferDeptId']==0)
{
echo ("not an available department");
}
else{
$dept=Dept::lookup($_REQUEST['transferDeptId']);
$count = count($_REQUEST['tids']);
$i=0;
foreach ($_REQUEST['tids'] as $tid) {
if (($ticket=Ticket::lookup($tid)))
{
$ticket->setDeptId($_REQUEST['transferDeptId']);
$ticket->setStaffId(0);
$ticket->setTeamId(0);
$ticket->setSLAId($dept->getSLAId());
if($ticket->getTeamId()==0&&$ticket->getStaffId()==0)
$i++;
}
}
echo "Transferred ".$i." tickets successfully";
}
?>
示例10: IndexOldStuff
/**
* Cooperates with the cron system to automatically find content that is
* not index in the _search table and add it to the index.
*/
function IndexOldStuff()
{
$class = get_class();
$auto_create = function ($db_error) use($class) {
if ($db_error != 1146) {
// Perform the standard error handling
return true;
}
// Create the search table automatically
$class::__init();
};
// THREADS ----------------------------------
$sql = "SELECT A1.`id`, A1.`title`, A1.`body`, A1.`format` FROM `" . TICKET_THREAD_TABLE . "` A1\n LEFT JOIN `" . TABLE_PREFIX . "_search` A2 ON (A1.`id` = A2.`object_id` AND A2.`object_type`='H')\n WHERE A2.`object_id` IS NULL AND (A1.poster <> 'SYSTEM')\n AND (LENGTH(A1.`title`) + LENGTH(A1.`body`) > 0)\n ORDER BY A1.`id` DESC";
if (!($res = db_query_unbuffered($sql, $auto_create))) {
return false;
}
while ($row = db_fetch_row($res)) {
$body = ThreadBody::fromFormattedText($row[2], $row[3]);
$body = $body->getSearchable();
$title = Format::searchable($row[1]);
if (!$body && !$title) {
continue;
}
$record = array('H', $row[0], $title, $body);
if (!$this->__index($record)) {
return;
}
}
// TICKETS ----------------------------------
$sql = "SELECT A1.`ticket_id` FROM `" . TICKET_TABLE . "` A1\n LEFT JOIN `" . TABLE_PREFIX . "_search` A2 ON (A1.`ticket_id` = A2.`object_id` AND A2.`object_type`='T')\n WHERE A2.`object_id` IS NULL\n ORDER BY A1.`ticket_id` DESC";
if (!($res = db_query_unbuffered($sql, $auto_create))) {
return false;
}
while ($row = db_fetch_row($res)) {
$ticket = Ticket::lookup($row[0]);
$cdata = $ticket->loadDynamicData();
$content = array();
foreach ($cdata as $k => $a) {
if ($k != 'subject' && ($v = $a->getSearchable())) {
$content[] = $v;
}
}
$record = array('T', $ticket->getId(), Format::searchable($ticket->getNumber() . ' ' . $ticket->getSubject()), implode("\n", $content));
if (!$this->__index($record)) {
return;
}
}
// USERS ------------------------------------
$sql = "SELECT A1.`id` FROM `" . USER_TABLE . "` A1\n LEFT JOIN `" . TABLE_PREFIX . "_search` A2 ON (A1.`id` = A2.`object_id` AND A2.`object_type`='U')\n WHERE A2.`object_id` IS NULL\n ORDER BY A1.`id` DESC";
if (!($res = db_query_unbuffered($sql, $auto_create))) {
return false;
}
while ($row = db_fetch_row($res)) {
$user = User::lookup($row[0]);
$cdata = $user->getDynamicData();
$content = array();
foreach ($user->emails as $e) {
$content[] = $e->address;
}
foreach ($cdata as $e) {
foreach ($e->getAnswers() as $a) {
if ($c = $a->getSearchable()) {
$content[] = $c;
}
}
}
$record = array('U', $user->getId(), Format::searchable($user->getFullName()), trim(implode("\n", $content)));
if (!$this->__index($record)) {
return;
}
}
// ORGANIZATIONS ----------------------------
$sql = "SELECT A1.`id` FROM `" . ORGANIZATION_TABLE . "` A1\n LEFT JOIN `" . TABLE_PREFIX . "_search` A2 ON (A1.`id` = A2.`object_id` AND A2.`object_type`='O')\n WHERE A2.`object_id` IS NULL\n ORDER BY A1.`id` DESC";
if (!($res = db_query_unbuffered($sql, $auto_create))) {
return false;
}
while ($row = db_fetch_row($res)) {
$org = Organization::lookup($row[0]);
$cdata = $org->getDynamicData();
$content = array();
foreach ($cdata as $e) {
foreach ($e->getAnswers() as $a) {
if ($c = $a->getSearchable()) {
$content[] = $c;
}
}
}
$record = array('O', $org->getId(), Format::searchable($org->getName()), trim(implode("\n", $content)));
if (!$this->__index($record)) {
return null;
}
}
// KNOWLEDGEBASE ----------------------------
require_once INCLUDE_DIR . 'class.faq.php';
$sql = "SELECT A1.`faq_id` FROM `" . FAQ_TABLE . "` A1\n LEFT JOIN `" . TABLE_PREFIX . "_search` A2 ON (A1.`faq_id` = A2.`object_id` AND A2.`object_type`='K')\n WHERE A2.`object_id` IS NULL\n ORDER BY A1.`faq_id` DESC";
if (!($res = db_query_unbuffered($sql, $auto_create))) {
//.........这里部分代码省略.........
示例11: require
<?php
// this is an ajax API to remove the collaborators for a ticket
require('staff.inc.php');
require_once(INCLUDE_DIR.'class.ticket.php');
if(($tid=$_POST['ticketId'])&&($ticket=Ticket::lookup($tid))&&($ticket->deleteCollaborators()))
{
echo $tid;
}
else
echo 'false';
?>
示例12: previewTicket
function previewTicket($tid)
{
global $thisstaff;
if (!$thisstaff || !($ticket = Ticket::lookup($tid)) || !$ticket->checkStaffAccess($thisstaff)) {
Http::response(404, 'No such ticket');
}
$staff = $ticket->getStaff();
$lock = $ticket->getLock();
$error = $msg = $warn = null;
if ($lock && $lock->getStaffId() == $thisstaff->getId()) {
$warn .= ' <span class="Icon lockedTicket">Ticket is locked by ' . $lock->getStaffName() . '</span>';
} elseif ($ticket->isOverdue()) {
$warn .= ' <span class="Icon overdueTicket">Marked overdue!</span>';
}
ob_start();
echo sprintf('<div style="width:500px; padding: 2px 2px 0 5px;">
<h2>%s</h2><br>', Format::htmlchars($ticket->getSubject()));
if ($error) {
echo sprintf('<div id="msg_error">%s</div>', $error);
} elseif ($msg) {
echo sprintf('<div id="msg_notice">%s</div>', $msg);
} elseif ($warn) {
echo sprintf('<div id="msg_warning">%s</div>', $warn);
}
echo '<table border="0" cellspacing="" cellpadding="1" width="100%" class="ticket_info">';
$ticket_state = sprintf('<span>%s</span>', ucfirst($ticket->getStatus()));
if ($ticket->isOpen()) {
if ($ticket->isOverdue()) {
$ticket_state .= ' — <span>Overdue</span>';
} else {
$ticket_state .= sprintf(' — <span>%s</span>', $ticket->getPriority());
}
}
echo sprintf('
<tr>
<th width="100">Ticket State:</th>
<td>%s</td>
</tr>
<tr>
<th>Create Date:</th>
<td>%s</td>
</tr>', $ticket_state, Format::db_datetime($ticket->getCreateDate()));
if ($ticket->isClosed()) {
echo sprintf('
<tr>
<th>Close Date:</th>
<td>%s <span class="faded">by %s</span></td>
</tr>', Format::db_datetime($ticket->getCloseDate()), $staff ? $staff->getName() : 'staff');
} elseif ($ticket->getDueDate()) {
echo sprintf('
<tr>
<th>Due Date:</th>
<td>%s</td>
</tr>', Format::db_datetime($ticket->getDueDate()));
}
echo '</table>';
echo '<hr>
<table border="0" cellspacing="" cellpadding="1" width="100%" class="ticket_info">';
if ($ticket->isOpen()) {
echo sprintf('
<tr>
<th width="100">Assigned To:</th>
<td>%s</td>
</tr>', $ticket->isAssigned() ? implode('/', $ticket->getAssignees()) : ' <span class="faded">— Unassigned —</span>');
}
echo sprintf(' <tr>
<th width="100">Department:</th>
<td>%s</td>
</tr>
<tr>
<th>Help Topic:</th>
<td>%s</td>
</tr>
<tr>
<th>From:</th>
<td>%s <span class="faded">%s</span></td>
</tr>', Format::htmlchars($ticket->getDeptName()), Format::htmlchars($ticket->getHelpTopic()), Format::htmlchars($ticket->getName()), $ticket->getEmail());
echo '
</table>';
$options[] = array('action' => 'Thread (' . $ticket->getThreadCount() . ')', 'url' => "tickets.php?id={$tid}");
if ($ticket->getNumNotes()) {
$options[] = array('action' => 'Notes (' . $ticket->getNumNotes() . ')', 'url' => "tickets.php?id={$tid}#notes");
}
if ($ticket->isOpen()) {
$options[] = array('action' => 'Reply', 'url' => "tickets.php?id={$tid}#reply");
}
if ($thisstaff->canAssignTickets()) {
$options[] = array('action' => $ticket->isAssigned() ? 'Reassign' : 'Assign', 'url' => "tickets.php?id={$tid}#assign");
}
if ($thisstaff->canTransferTickets()) {
$options[] = array('action' => 'Transfer', 'url' => "tickets.php?id={$tid}#transfer");
}
$options[] = array('action' => 'Post Note', 'url' => "tickets.php?id={$tid}#note");
if ($thisstaff->canEditTickets()) {
$options[] = array('action' => 'Edit Ticket', 'url' => "tickets.php?id={$tid}&a=edit");
}
if ($options) {
echo '<ul class="tip_menu">';
foreach ($options as $option) {
echo sprintf('<li><a href="%s">%s</a></li>', $option['url'], $option['action']);
//.........这里部分代码省略.........
示例13: tickets
$i++;
$t->logNote('Ticket Marked Overdue', $note, $thisstaff);
}
}
if ($i == $count) {
$msg = "Selected tickets ({$i}) marked overdue";
} elseif ($i) {
$warn = "{$i} of {$count} selected tickets marked overdue";
} else {
$errors['err'] = 'Unable to flag selected tickets as overdue';
}
break;
case 'delete':
if ($thisstaff->canDeleteTickets()) {
foreach ($_POST['tids'] as $k => $v) {
if (($t = Ticket::lookup($v)) && @$t->delete()) {
$i++;
}
}
//Log a warning
if ($i) {
$log = sprintf('%s (%s) just deleted %d ticket(s)', $thisstaff->getName(), $thisstaff->getUserName(), $i);
$ost->logWarning('Tickets deleted', $log, false);
}
if ($i == $count) {
$msg = "Selected tickets ({$i}) deleted successfully";
} elseif ($i) {
$warn = "{$i} of {$count} selected tickets deleted";
} else {
$errors['err'] = 'Unable to delete selected tickets';
}
示例14: validate
protected function validate($authkey)
{
$regex = '/^(?P<type>\\w{1})(?P<id>\\d+)t(?P<tid>\\d+)h(?P<hash>.*)$/i';
$matches = array();
if (!preg_match($regex, $authkey, $matches)) {
return false;
}
$user = null;
switch ($matches['type']) {
case 'c':
//Collaborator
$criteria = array('userId' => $matches['id'], 'ticketId' => $matches['tid']);
if (($c = Collaborator::lookup($criteria)) && $c->getTicketId() == $matches['tid']) {
$user = new ClientSession($c);
}
break;
case 'o':
//Ticket owner
if (($ticket = Ticket::lookup($matches['tid'])) && ($o = $ticket->getOwner()) && $o->getId() == $matches['id']) {
$user = new ClientSession($o);
}
break;
}
//Make sure the authkey matches.
if (!$user || strcmp($this->getAuthKey($user), $authkey)) {
return null;
}
$user->flagGuest();
return $user;
}
示例15: cannedResponse
function cannedResponse($tid, $cid, $format = 'text')
{
global $thisstaff, $cfg;
if (!($ticket = Ticket::lookup($tid)) || !$ticket->checkStaffAccess($thisstaff)) {
Http::response(404, 'Unknown ticket ID');
}
if ($cid && !is_numeric($cid)) {
if (!($response = $ticket->getThread()->getVar($cid))) {
Http::response(422, 'Unknown ticket variable');
}
// Ticket thread variables are assumed to be quotes
$response = "<br/><blockquote>{$response}</blockquote><br/>";
// Return text if html thread is not enabled
if (!$cfg->isHtmlThreadEnabled()) {
$response = Format::html2text($response, 90);
}
// XXX: assuming json format for now.
return Format::json_encode(array('response' => $response));
}
if (!$cfg->isHtmlThreadEnabled()) {
$format .= '.plain';
}
$varReplacer = function (&$var) use($ticket) {
return $ticket->replaceVars($var);
};
include_once INCLUDE_DIR . 'class.canned.php';
if (!$cid || !($canned = Canned::lookup($cid)) || !$canned->isEnabled()) {
Http::response(404, 'No such premade reply');
}
return $canned->getFormattedResponse($format, $varReplacer);
}