diff --git a/include/ajax.users.php b/include/ajax.users.php index 04b29bec611ee3b19d167645590950b4d3cd40ab..f84fbd7d8d99b09986877fb5e6a81709be5c925b 100644 --- a/include/ajax.users.php +++ b/include/ajax.users.php @@ -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'); diff --git a/include/staff/templates/user.tmpl.php b/include/staff/templates/user.tmpl.php index 92bbe3754effd5161a51e2f3a1ebca4d9e65c910..43176c79609fce7b6da36bc1ff340e3ed414d466 100644 --- a/include/staff/templates/user.tmpl.php +++ b/include/staff/templates/user.tmpl.php @@ -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"> diff --git a/include/staff/ticket-edit.inc.php b/include/staff/ticket-edit.inc.php index 6294cda9205fda70173468c4fad871c8e8c3ce38..0fe5c8ee7f640518f8921fea819bbe572ab2530a 100644 --- a/include/staff/ticket-edit.inc.php +++ b/include/staff/ticket-edit.inc.php @@ -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"><<?php echo $user->getEmail(); ?>></span> + <<span id="client-email"><?php echo $user->getEmail(); ?></span>> + </a> <a class="action-button" style="float:none;overflow:inherit" href="#" onclick="javascript: $.userLookup('ajax.php/tickets/<?php echo $ticket->getId(); ?>/change-user', diff --git a/include/staff/ticket-open.inc.php b/include/staff/ticket-open.inc.php index f491756f34b0ebbe7a65b370d1931e8d15121a43..1c49b407308ba09a9487c4a465e9986a13db9c2f 100644 --- a/include/staff/ticket-open.inc.php +++ b/include/staff/ticket-open.inc.php @@ -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"><<?php echo $user->getEmail(); ?>></span> + <<span id="client-email"><?php echo $user->getEmail(); ?></span>> + </a> <a class="action-button" style="float:none;overflow:inherit" href="#" onclick="javascript: $.userLookup('ajax.php/users/select/'+$('input#uid').val(), diff --git a/include/staff/ticket-view.inc.php b/include/staff/ticket-view.inc.php index 9bc7823ab84d425b00da5dbebfa51dd25d52dfc7..1891bc07fb230a0cfb7149669d1a173fe91cde5e 100644 --- a/include/staff/ticket-view.inc.php +++ b/include/staff/ticket-view.inc.php @@ -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> <<?php echo $ticket->getEmail(); ?>> 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> <<?php echo $ticket->getEmail(); ?>> 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> diff --git a/scp/ajax.php b/scp/ajax.php index 106f3366a723a6e25a815796209c1dc5fed07f71..b40a6696da361f442555a7fc73a116f6c4988ecf 100644 --- a/scp/ajax.php +++ b/scp/ajax.php @@ -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'),