Skip to content
Snippets Groups Projects
Commit 431345ad authored by Jared Hancock's avatar Jared Hancock
Browse files

Allow edit of user on ticket-edit page

Previously, the user information could only be modified on the ticket-view
page. For instance, if creating a new ticket for a user, no new information
could be added or modified on the user until after the ticket was created

Fixes osTicket/osTicket-1.8#281
parent 50d3d706
No related branches found
No related tags found
No related merge requests found
......@@ -54,9 +54,41 @@ class UsersAjaxAPI extends AjaxController {
}
function getUser() {
function editUser($id) {
global $thisstaff;
if(($user=User::lookup($_REQUEST['id'])))
if(!$thisstaff)
Http::response(403, 'Login Required');
elseif(!($user = User::lookup($id)))
Http::response(404, 'Unknown user');
$info = array(
'title' => sprintf('Update %s', $user->getName())
);
$forms = $user->getForms();
include(STAFFINC_DIR . 'templates/user.tmpl.php');
}
function updateUser($id) {
global $thisstaff;
if(!$thisstaff)
Http::response(403, 'Login Required');
elseif(!($user = User::lookup($id)))
Http::response(404, 'Unknown user');
$errors = array();
if($user->updateInfo($_POST, $errors))
Http::response(201, $user->to_json());
$forms = $user->getForms();
include(STAFFINC_DIR . 'templates/user.tmpl.php');
}
function getUser($id=false) {
if(($user=User::lookup(($id) ? $id : $_REQUEST['id'])))
Http::response(201, $user->to_json());
$info = array('error' =>'Unknown or invalid user');
......
......@@ -47,7 +47,8 @@ if ($ticket && $ticket->getOwnerId() == $user->getId())
<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">
<input type="button" name="cancel" class="<?php
echo ($ticket && $user) ? 'cancel' : 'close' ?>" value="Cancel">
</span>
<span class="buttons" style="float:right">
<input type="submit" value="Update User">
......
......@@ -25,8 +25,17 @@ if ($_POST)
?>
<tr><td>Client:</td><td>
<div id="client-info">
<a href="#" onclick="javascript:
$.userLookup('ajax.php/users/<?php echo $ticket->getOwnerId(); ?>/edit',
function (user) {
$('#client-name').text(user.name);
$('#client-email').text(user.email);
});
return false;
"><i class="icon-user"></i>
<span id="client-name"><?php echo $user->getName(); ?></span>
<span id="client-email">&lt;<?php echo $user->getEmail(); ?>&gt;</span>
&lt;<span id="client-email"><?php echo $user->getEmail(); ?></span>&gt;
</a>
<a class="action-button" style="float:none;overflow:inherit" href="#"
onclick="javascript:
$.userLookup('ajax.php/tickets/<?php echo $ticket->getId(); ?>/change-user',
......
......@@ -32,8 +32,17 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info);
<tr><td>Client:</td><td>
<div id="client-info">
<input type="hidden" name="uid" id="uid" value="<?php echo $user->getId(); ?>" />
<a href="#" onclick="javascript:
$.userLookup('ajax.php/users/<?php echo $user->getId(); ?>/edit',
function (user) {
$('#client-name').text(user.name);
$('#client-email').text(user.email);
});
return false;
"><i class="icon-user"></i>
<span id="client-name"><?php echo $user->getName(); ?></span>
<span id="client-email">&lt;<?php echo $user->getEmail(); ?>&gt;</span>
&lt;<span id="client-email"><?php echo $user->getEmail(); ?></span>&gt;
</a>
<a class="action-button" style="float:none;overflow:inherit" href="#"
onclick="javascript:
$.userLookup('ajax.php/users/select/'+$('input#uid').val(),
......
......@@ -893,8 +893,10 @@ $tcount+= $ticket->getNumNotes();
Are you sure want to <b>unassign</b> ticket from <b><?php echo $ticket->getAssigned(); ?></b>?
</p>
<p class="confirm-action" style="display:none;" id="changeuser-confirm">
<p id="msg_warning">
<b><?php echo $ticket->getName(); ?></b> &lt;<?php echo $ticket->getEmail(); ?>&gt; will no longer have access to the ticket.
</p>
Are you sure want to <b>change</b> ticket owner to <b><span id="newuser">this guy</span></b>?
<br><br><b><?php echo $ticket->getName(); ?></b> &lt;<?php echo $ticket->getEmail(); ?>&gt; will no longer have access to the ticket.
</p>
<p class="confirm-action" style="display:none;" id="delete-confirm">
<font color="red"><strong>Are you sure you want to DELETE this ticket?</strong></font>
......
......@@ -60,6 +60,8 @@ $dispatcher = patterns('',
url('^/users', patterns('ajax.users.php:UsersAjaxAPI',
url_get('^$', 'search'),
url_get('^/(?P<id>\d+)$', 'getUser'),
url_post('^/(?P<id>\d+)$', 'updateUser'),
url_get('^/(?P<id>\d+)/edit$', 'editUser'),
url_get('^/lookup$', 'getUser'),
url_get('^/lookup/form$', 'getLookupForm'),
url_post('^/lookup/form$', 'addUser'),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment