Skip to content
Snippets Groups Projects
Commit 3ea63b04 authored by Peter Rotich's avatar Peter Rotich
Browse files

Add ticket owner edit/manage

parent 290b3c02
No related branches found
No related tags found
No related merge requests found
......@@ -449,6 +449,58 @@ class TicketsAjaxAPI extends AjaxController {
return $resp;
}
function viewUser($tid) {
global $thisstaff;
if(!$thisstaff
|| !($ticket=Ticket::lookup($tid))
|| !$ticket->checkStaffAccess($thisstaff))
Http::response(404, 'No such ticket');
if(!($user = $ticket->getOwner()))
Http::response(404, 'Unknown user');
$info = array(
'title' => sprintf('Ticket #%s: %s', $ticket->getNumber(), $user->getName())
);
ob_start();
include(STAFFINC_DIR . 'templates/user.tmpl.php');
$resp = ob_get_contents();
ob_end_clean();
return $resp;
}
function updateUser($tid) {
global $thisstaff;
if(!$thisstaff
|| !($ticket=Ticket::lookup($tid))
|| !$ticket->checkStaffAccess($thisstaff)
|| ! ($user = $ticket->getOwner()))
Http::response(404, 'No such ticket/user');
$errors = array();
if($user->updateInfo($_POST, $errors))
Http::response(201, $user->to_json());
$forms = $user->getForms();
$info = array(
'title' => sprintf('Ticket #%s: %s', $ticket->getNumber(), $user->getName())
);
ob_start();
include(STAFFINC_DIR . 'templates/user.tmpl.php');
$resp = ob_get_contents();
ob_end_clean();
return $resp;
}
function changeUserForm($tid) {
global $thisstaff;
......
<?php
if (!$info['title'])
$info['title'] = $user->getName();
?>
<h3><?php echo $info['title']; ?></h3>
<b><a class="close" href="#"><i class="icon-remove-circle"></i></a></b>
<hr/>
<?php
if ($info['error']) {
echo sprintf('<p id="msg_error">%s</p>', $info['error']);
} elseif ($info['msg']) {
echo sprintf('<p id="msg_notice">%s</p>', $info['msg']);
} ?>
<div id="user-profile" style="display:<?php echo $forms ? 'none' : 'block'; ?>;margin:5px;">
<i class="icon-user icon-4x pull-left icon-border"></i>
<?php
if ($ticket) { ?>
<a class="action-button pull-right change-user" style="overflow:inherit"
href="#tickets/<?php echo $ticket->getId(); ?>/change-user" ><i class="icon-user"></i> Change User</a>
<?php
} ?>
<div><b><a href="#" id="edituser"><i class="icon-edit"></i>&nbsp;<?php
echo $user->getName(); ?></a></b></div>
<div>&lt;<?php echo $user->getEmail(); ?>&gt;</div>
<div><?php echo $user->getPhoneNumber(); ?></div>
<div class="clear"></div>
<hr>
<div class="faded">Last updated <b><?php echo Format::db_datetime($user->getUpdateDate()); ?> </b></div>
</div>
<div id="user-form" style="display:<?php echo $forms ? 'block' : 'none'; ?>;">
<div><p id="msg_info"><i class="icon-info-sign"></i>&nbsp; Please note that updates will be reflected system-wide.</p></div>
<?php
$action = '#users/'.$user->getId();
if ($ticket && $ticket->getOwnerId() == $user->getId())
$action = '#tickets/'.$ticket->getId().'/user';
?>
<form method="post" class="user" action="<?php echo $action; ?>">
<input type="hidden" name="uid" value="<?php echo $user->getId(); ?>" />
<table width="100%">
<?php
if (!$forms) $forms = $user->getForms();
foreach ($forms as $form)
$form->render();
?>
</table>
<hr>
<p class="full-width">
<span class="buttons" style="float:left">
<input type="reset" value="Reset">
<input type="button" name="cancel" class="<?php echo $user ? 'cancel' : 'close' ?>" value="Cancel">
</span>
<span class="buttons" style="float:right">
<input type="submit" value="Update User">
</span>
</p>
</form>
</div>
<div class="clear"></div>
<script type="text/javascript">
$(function() {
$('a#edituser').click( function(e) {
e.preventDefault();
$('div#user-profile').hide();
$('div#user-form').fadeIn();
return false;
});
$(document).on('click', 'form.user input.cancel', function (e) {
e.preventDefault();
$('div#user-form').hide();
$('div#user-profile').fadeIn();
return false;
});
});
</script>
......@@ -69,6 +69,8 @@ $dispatcher = patterns('',
url('^/tickets/', patterns('ajax.tickets.php:TicketsAjaxAPI',
url_get('^(?P<tid>\d+)/change-user$', 'changeUserForm'),
url_post('^(?P<tid>\d+)/change-user$', 'changeUser'),
url_get('^(?P<tid>\d+)/user$', 'viewUser'),
url_post('^(?P<tid>\d+)/user$', 'updateUser'),
url_get('^(?P<tid>\d+)/preview', 'previewTicket'),
url_post('^(?P<tid>\d+)/lock', 'acquireLock'),
url_post('^(?P<tid>\d+)/lock/(?P<id>\d+)/renew', 'renewLock'),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment