PATH:
home
/
centosnipponia
/
public_html
/
ticketing.nipponia.com
/
include
<?php /********************************************************************* ajax.thread.php AJAX interface for thread Peter Rotich <peter@osticket.com> Copyright (c) 2015 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('403'); include_once(INCLUDE_DIR.'class.ticket.php'); require_once(INCLUDE_DIR.'class.ajax.php'); require_once(INCLUDE_DIR.'class.note.php'); include_once INCLUDE_DIR . 'class.thread_actions.php'; class ThreadAjaxAPI extends AjaxController { function lookup() { global $thisstaff; if(!is_numeric($_REQUEST['q'])) return self::lookupByEmail(); $limit = isset($_REQUEST['limit']) ? (int) $_REQUEST['limit']:25; $tickets=array(); $visibility = $thisstaff->getTicketsVisibility(); $hits = Ticket::objects() ->filter(Q::any(array( 'number__startswith' => $_REQUEST['q'], ))) ->filter($visibility) ->values('number', 'user__emails__address') ->annotate(array('tickets' => SqlAggregate::COUNT('ticket_id'))) ->order_by('-created') ->limit($limit); foreach ($hits as $T) { $tickets[] = array('id'=>$T['number'], 'value'=>$T['number'], 'info'=>"{$T['number']} — {$T['user__emails__address']}", 'matches'=>$_REQUEST['q']); } if (!$tickets) return self::lookupByEmail(); return $this->json_encode($tickets); } function addRemoteCollaborator($tid, $type, $bk, $id) { global $thisstaff; if (!($thread=Thread::lookup($tid)) || !($object=$thread->getObject()) || !$object->checkStaffPerm($thisstaff)) Http::response(404, 'No such thread'); elseif (!$bk || !$id) Http::response(422, 'Backend and user id required'); elseif (!($backend = StaffAuthenticationBackend::getBackend($bk))) Http::response(404, 'User not found'); $user_info = $backend->lookup($id); $form = UserForm::getUserForm()->getForm($user_info); $info = array(); if (!$user_info) $info['error'] = __('Unable to find user in directory'); return self::_addcollaborator($thread, null, $form, $type, $info); } //Collaborators utils function addCollaborator($tid, $type=null, $uid=0) { global $thisstaff; if (!($thread=Thread::lookup($tid)) || !($object=$thread->getObject()) || !is_subclass_of($object, 'Threadable') || !$object->checkStaffPerm($thisstaff)) Http::response(404, __('No such thread')); $user = $uid? User::lookup($uid) : null; //If not a post then assume new collaborator form if(!$_POST) return self::_addcollaborator($thread, $user, null, $type); $user = $form = null; if (isset($_POST['id']) && $_POST['id']) { //Existing user/ $user = User::lookup($_POST['id']); } else { //We're creating a new user! $form = UserForm::getUserForm()->getForm($_POST); $user = User::fromForm($form); } $errors = $info = $vars = array(); if ($user && ($c=$object->addCollaborator($user, $vars, $errors))) { $info = array('msg' => sprintf(__('%s added as a collaborator'), Format::htmlchars($c->getName()))); return self::_collaborators($thread, $info); } if ($errors && $errors['err']) { $info +=array('error' => $errors['err']); } else { $info +=array('error' =>__('Unable to add collaborator.').' '.__('Internal error occurred')); } return self::_addcollaborator($thread, $user, $form, $type, $info); } function updateCollaborator($tid, $cid) { global $thisstaff; if (!($thread=Thread::lookup($tid)) || !($object=$thread->getObject()) || !$object->checkStaffPerm($thisstaff)) Http::response(405, 'No such thread'); if (!($c=Collaborator::lookup(array( 'id' => $cid, 'thread_id' => $thread->getId()))) || !($user=$c->getUser())) Http::response(406, 'Unknown collaborator'); $errors = array(); if(!$user->updateInfo($_POST, $errors)) return self::_collaborator($c ,$user->getForms($_POST), $errors); $info = array('msg' => sprintf('%s updated successfully', Format::htmlchars($c->getName()))); return self::_collaborators($thread, $info); } function viewCollaborator($tid, $cid) { global $thisstaff; if (!($thread=Thread::lookup($tid)) || !($object=$thread->getObject()) || !$object->checkStaffPerm($thisstaff)) Http::response(404, 'No such thread'); if (!($collaborator=Collaborator::lookup(array( 'id' => $cid, 'thread_id' => $thread->getId())))) Http::response(404, 'Unknown collaborator'); return self::_collaborator($collaborator); } function showCollaborators($tid) { global $thisstaff; if(!($thread=Thread::lookup($tid)) || !($object=$thread->getObject()) || !$object->checkStaffPerm($thisstaff)) Http::response(404, 'No such thread'); if ($thread->getCollaborators()) return self::_collaborators($thread); return self::_addcollaborator($thread); } function previewCollaborators($tid, $manage=true) { global $thisstaff; if (!($thread=Thread::lookup($tid)) || !($object=$thread->getObject()) || !$object->checkStaffPerm($thisstaff)) Http::response(404, 'No such thread'); ob_start(); include STAFFINC_DIR . 'templates/collaborators-preview.tmpl.php'; $resp = ob_get_contents(); ob_end_clean(); return $resp; } static function _addcollaborator($thread, $user=null, $form=null, $type=null, $info=array()) { global $thisstaff; $info += array( 'title' => __('Add a collaborator'), 'action' => sprintf('#thread/%d/add-collaborator/%s', $thread->getId(), $type), 'onselect' => sprintf('ajax.php/thread/%d/add-collaborator/%s/', $thread->getId(), $type), ); ob_start(); include STAFFINC_DIR . 'templates/user-lookup.tmpl.php'; $resp = ob_get_contents(); ob_end_clean(); return $resp; } function updateCollaborators($tid) { global $thisstaff; if (!($thread=Thread::lookup($tid)) || !($object=$thread->getObject()) || !$object->checkStaffPerm($thisstaff)) Http::response(404, 'No such thread'); $errors = $info = array(); $thread->updateCollaborators($_POST, $errors); if($errors && $errors['err']) $info +=array('error' => $errors['err']); return self::_collaborators($thread, $info); } static function _collaborator($collaborator, $form=null, $info=array()) { global $thisstaff; $info += array('action' => sprintf('#thread/%d/collaborators/%d', $collaborator->thread_id, $collaborator->getId())); $user = $collaborator->getUser(); ob_start(); include(STAFFINC_DIR . 'templates/user.tmpl.php'); $resp = ob_get_contents(); ob_end_clean(); return $resp; } static function _collaborators($thread, $info=array()) { ob_start(); include(STAFFINC_DIR . 'templates/collaborators.tmpl.php'); $resp = ob_get_contents(); ob_end_clean(); return $resp; } function triggerThreadAction($ticket_id, $thread_id, $action) { $thread = ThreadEntry::lookup($thread_id); if (!$thread) Http::response(404, 'No such ticket thread entry'); if ($thread->getThread()->getObjectId() != $ticket_id) Http::response(404, 'No such ticket thread entry'); $valid = false; foreach ($thread->getActions() as $group=>$list) { foreach ($list as $name=>$A) { if ($A->getId() == $action) { $valid = true; break; } } } if (!$valid) Http::response(400, 'Not a valid action for this thread'); $thread->triggerAction($action); } } ?>
[+]
..
[-] class.model.php
[edit]
[-] ajax.i18n.php
[edit]
[-] class.json.php
[edit]
[-] class.mime.php
[edit]
[-] class.orm.php
[edit]
[-] class.dept.php
[edit]
[-] ajax.filter.php
[edit]
[-] api.tickets.php
[edit]
[-] ajax.note.php
[edit]
[-] class.2fa.php
[edit]
[-] class.setup.php
[edit]
[-] ajax.orgs.php
[edit]
[-] class.format.php
[edit]
[-] class.message.php
[edit]
[-] class.xml.php
[edit]
[-] class.priority.php
[edit]
[-] class.app.php
[edit]
[-] index.php
[edit]
[-] ajax.forms.php
[edit]
[-] ajax.config.php
[edit]
[-] ajax.tickets.php
[edit]
[-] ajax.content.php
[edit]
[-] class.file.php
[edit]
[-] ajax.email.php
[edit]
[-] class.cli.php
[edit]
[-] class.company.php
[edit]
[-] class.mailer.php
[edit]
[-] class.list.php
[edit]
[-] class.canned.php
[edit]
[-] class.client.php
[edit]
[+]
upgrader
[-] class.csrf.php
[edit]
[-] ost-sampleconfig.php
[edit]
[-] class.http.php
[edit]
[-] ajax.staff.php
[edit]
[-] class.search.php
[edit]
[-] JSON.php
[edit]
[-] class.avatar.php.bak
[edit]
[-] class.error.php
[edit]
[-] class.mail.php
[edit]
[-] class.sla.php
[edit]
[-] class.draft.php
[edit]
[-] class.dispatcher.php
[edit]
[-] class.note.php
[edit]
[-] class.mailparse.php
[edit]
[-] class.filter_action.php
[edit]
[-] class.queue.php
[edit]
[-] class.i18n.php
[edit]
[-] class.osticket.php
[edit]
[-] ajax.users.php
[edit]
[-] class.staff.php
[edit]
[+]
fpdf
[-] class.crypto.php
[edit]
[+]
laminas-mail
[-] class.misc.php
[edit]
[-] class.auth.php
[edit]
[-] html2text.php
[edit]
[-] class.translation.php
[edit]
[-] class.util.php
[edit]
[-] class.schedule.php
[edit]
[-] class.banlist.php
[edit]
[-] class.config.php
[edit]
[-] ajax.upgrader.php
[edit]
[+]
mpdf
[-] class.email.php
[edit]
[-] ajax.admin.php
[edit]
[+]
config
[-] ajax.thread.php
[edit]
[-] class.user.php
[edit]
[-] class.passwd.php
[edit]
[-] class.import.php
[edit]
[+]
client
[-] ajax.tips.php
[edit]
[-] tnef_decoder.php
[edit]
[-] class.oauth2.php
[edit]
[-] class.plugin.php
[edit]
[-] class.timezone.php
[edit]
[-] class.ticket.php
[edit]
[-] class.nav.php
[edit]
[-] class.category.php
[edit]
[-] class.charset.php
[edit]
[+]
cli
[-] class.cron.php
[edit]
[-] class.captcha.php
[edit]
[-] class.dynamic_forms.php
[edit]
[-] class.faq.php
[edit]
[+]
plugins
[-] class.pdf.php
[edit]
[-] ajax.schedule.php
[edit]
[-] class.usersession.php
[edit]
[-] class.topic.php
[edit]
[-] class.base32.php
[edit]
[-] htmLawed.php
[edit]
[-] ajax.sequence.php
[edit]
[+]
i18n
[-] class.signal.php
[edit]
[-] class.mailfetch.php
[edit]
[-] UniversalClassLoader.php
[edit]
[-] class.sequence.php
[edit]
[-] class.businesshours.php
[edit]
[-] class.role.php
[edit]
[+]
pear
[-] class.yaml.php
[edit]
[-] Spyc.php
[edit]
[-] mysqli.php
[edit]
[-] class.thread_actions.php
[edit]
[-] class.export.php
[edit]
[-] ajax.plugins.php
[edit]
[-] class.collaborator.php
[edit]
[-] class.ostsession.php
[edit]
[+]
staff
[-] class.attachment.php
[edit]
[-] class.template.php
[edit]
[-] class.filter.php
[edit]
[-] class.controller.php
[edit]
[-] class.team.php
[edit]
[-] class.session.php
[edit]
[-] class.avatar.php
[edit]
[-] ajax.kbase.php
[edit]
[-] class.variable.php
[edit]
[-] class.validator.php
[edit]
[-] ajax.tasks.php
[edit]
[-] class.upgrader.php
[edit]
[-] class.page.php
[edit]
[-] ajax.export.php
[edit]
[-] ajax.search.php
[edit]
[-] PasswordHash.php
[edit]
[-] class.report.php
[edit]
[-] class.forms.php
[edit]
[-] class.task.php
[edit]
[-] class.migrater.php
[edit]
[-] class.lock.php
[edit]
[-] class.organization.php
[edit]
[-] class.pagenate.php
[edit]
[-] api.cron.php
[edit]
[-] class.api.php
[edit]
[-] class.thread.php
[edit]
[-] class.knowledgebase.php
[edit]
[-] .MANIFEST
[edit]
[-] class.log.php
[edit]
[-] ajax.draft.php
[edit]
[-] class.ajax.php
[edit]
[-] ost-config.php
[edit]
[-] txets.php
[edit]
[-] .htaccess.disabled
[edit]