Copyright (c) 2006-2013 osTicket
http://www.osticket.com
Released under the GNU General Public License WITHOUT ANY WARRANTY.
See LICENSE.TXT for details.
vim: expandtab sw=4 ts=4 sts=4:
**********************************************************************/
if(!defined('INCLUDE_DIR')) die('!');
require_once INCLUDE_DIR.'class.ajax.php';
class ContentAjaxAPI extends AjaxController {
function log($id) {
if($id && ($log=Log::lookup($id))) {
$content=sprintf('
',
$log->getTitle(),
Format::display(str_replace(',',', ',$log->getText())),
__('Log Date'),
Format::daydatetime($log->getCreateDate()),
__('IP Address'),
$log->getIP());
}else {
$content=' '.__('Error').':'.
sprintf(__('%s: Unknown or invalid ID.'), __('log entry')).'
';
}
return $content;
}
function ticket_variables() {
$content='
'.__('Ticket Variables').'
'.__('Please note that non-base variables depend on the context of use. Visit osTicket Wiki for up to date documentation.').'
'.__('Base Variables').' | '.__('Other Variables').' |
%{ticket.id} | '.__('Ticket ID').' ('.__('internal ID').') |
%{ticket.number} | '.__('Ticket Number').' ('.__('external ID').') |
%{ticket.email} | '.__('Email Address').' |
%{ticket.name} | '.__('Full Name').' —
'.__('see name expansion').' |
%{ticket.subject} | '.__('Subject').' |
%{ticket.phone} | '.__('Phone number | ext').' |
%{ticket.status} | '.__('Status').' |
%{ticket.priority} | '.__('Priority').' |
%{ticket.assigned} | '.__('Assigned Agent / Team').' |
%{ticket.create_date} | '.__('Date Created').' |
%{ticket.due_date} | '.__('Due Date').' |
%{ticket.close_date} | '.__('Date Closed').' |
%{ticket.recipients} | '.__('List of all recipient names').' |
%{recipient.ticket_link} | '.__('Auth. token used for auto-login').'
'.__('Agent\'s ticket view link').' |
'.__('Expandable Variables').' |
%{ticket.topic} | '.__('Help Topic').' |
%{ticket.dept} | '.__('Department').' |
%{ticket.staff} | '.__('Assigned/closing agent').' |
%{ticket.team} | '.__('Assigned/closing team').' |
%{ticket.thread} | '.__('Ticket Thread').' |
|
%{message} | '.__('Incoming message').' |
%{response} | '.__('Outgoing response').' |
%{comments} | '.__('Assign/transfer comments').' |
%{note} | '.__('Internal note (expandable)').' |
%{assignee} | '.__('Assigned Agent / Team').' |
%{assigner} | '.__('Agent assigning the ticket').' |
%{url} | '.__('osTicket\'s base url (FQDN)').' |
%{reset_link} |
'.__('Reset link used by the password reset feature').' |
'.__('Name Expansion').' |
.first | '.__('First Name').' |
.last | '.__('Last Name').' |
.full | '.__('First Last').' |
.short | '.__('First L.').' |
.shortformal | '.__('F. Last').' |
.lastfirst | '.__('Last, First').' |
'.__('Ticket Thread expansions').' |
.original | '.__('Original Message').' |
.lastmessage | '.__('Last Message').' |
'.__('Thread Entry expansions').' |
.poster | '.__('Poster').' |
.create_date | '.__('Date Created').' |
|
';
return $content;
}
function getSignature($type, $id=null) {
global $thisstaff;
if (!$thisstaff)
Http::response(403, 'Login Required');
switch ($type) {
case 'none':
break;
case 'agent':
if (!($staff = Staff::lookup($id)))
Http::response(404, 'No such staff member');
echo Format::viewableImages($staff->getSignature());
break;
case 'mine':
echo Format::viewableImages($thisstaff->getSignature());
break;
case 'dept':
if (!($dept = Dept::lookup($id)))
Http::response(404, 'No such department');
echo Format::viewableImages($dept->getSignature());
break;
default:
Http::response(400, 'Unknown signature type');
break;
}
}
function manageContent($id, $lang=false) {
global $thisstaff, $cfg;
if (!$thisstaff)
Http::response(403, 'Login Required');
$content = Page::lookup($id, $lang);
$langs = Internationalization::getConfiguredSystemLanguages();
$translations = $content->getAllTranslations();
$info = array(
'title' => $content->getName(),
'body' => $content->getBody(),
);
foreach ($translations as $t) {
if (!($data = $t->getComplex()))
continue;
$info['trans'][$t->lang] = array(
'title' => $data['name'],
'body' => $data['body'],
);
}
include STAFFINC_DIR . 'templates/content-manage.tmpl.php';
}
function manageNamedContent($type, $lang=false) {
global $thisstaff, $cfg;
if (!$thisstaff)
Http::response(403, 'Login Required');
$langs = $cfg->getSecondaryLanguages();
$content = Page::lookupByType($type, $lang);
$info = $content->getHashtable();
include STAFFINC_DIR . 'templates/content-manage.tmpl.php';
}
function updateContent($id) {
global $thisstaff;
if (!$thisstaff)
Http::response(403, 'Login Required');
elseif (!($content = Page::lookup($id)))
Http::response(404, 'No such content');
if (!isset($_POST['body']))
$_POST['body'] = '';
$vars = array_merge($content->getHashtable(), $_POST);
$errors = array();
// Allow empty content for the staff banner
if ($content->update($vars, $errors,
$content->getType() == 'banner-staff')
) {
Http::response(201, 'Have a great day!');
}
if (!$errors['err'])
$errors['err'] = __('Correct any errors below and try again.');
$info = $_POST;
$errors = Format::htmlchars($errors);
include STAFFINC_DIR . 'templates/content-manage.tmpl.php';
}
function context() {
global $thisstaff;
if (!$thisstaff)
Http::response(403, 'Login Required');
if (!$_GET['root'])
Http::response(400, '`root` is required parameter');
$items = VariableReplacer::getContextForRoot($_GET['root']);
if (!$items)
Http::response(422, 'No such context');
header('Content-Type: application/json');
return $this->encode($items);
}
}
?>