diff --git a/include/ajax.users.php b/include/ajax.users.php index 43a7864b0bf801215d87b8a13d9e69230ad0519f..b17d742a478af318cc7127161b56172aef9d8157 100644 --- a/include/ajax.users.php +++ b/include/ajax.users.php @@ -79,6 +79,29 @@ class UsersAjaxAPI extends AjaxController { } + function preview($id) { + global $thisstaff; + + if(!$thisstaff) + Http::response(403, 'Login Required'); + elseif(!($user = User::lookup($id))) + Http::response(404, 'Unknown user'); + + $info = array('title' => ''); + + ob_start(); + echo sprintf('<div style="width:650px; padding: 2px 2px 0 5px;" + id="u%d">', $user->getId()); + include(STAFFINC_DIR . 'templates/user.tmpl.php'); + echo '</div>'; + $resp = ob_get_contents(); + ob_end_clean(); + + return $resp; + + } + + function editUser($id) { global $thisstaff; @@ -210,17 +233,19 @@ class UsersAjaxAPI extends AjaxController { return self::_lookupform(null, $info); } + function lookup() { + return self::addUser(); + } + function addUser() { $info = array(); - $info['title'] = 'Add New User'; - - $info['lookup'] = 'remote'; if (!AuthenticationBackend::getSearchDirectories()) - $info['lookup'] = false; + $info['lookup'] = 'local'; if ($_POST) { + $info['title'] = 'Add New User'; $form = UserForm::getUserForm()->getForm($_POST); if (($user = User::fromForm($form))) Http::response(201, $user->to_json()); @@ -274,10 +299,6 @@ class UsersAjaxAPI extends AjaxController { include STAFFINC_DIR . 'templates/user-import.tmpl.php'; } - function getLookupForm() { - return self::_lookupform(); - } - function selectUser($id) { if ($id) @@ -296,7 +317,7 @@ class UsersAjaxAPI extends AjaxController { static function _lookupform($form=null, $info=array()) { if (!$info or !$info['title']) - $info += array('title' => 'Select or Create a Client'); + $info += array('title' => 'Lookup or create a user'); ob_start(); include(STAFFINC_DIR . 'templates/user-lookup.tmpl.php'); diff --git a/include/staff/footer.inc.php b/include/staff/footer.inc.php index fb434ffb0f80b2a7bf510818b1e9cae9ba0c7b15..529fe8bfcd81aa4014ce0cbbb97a76b784d63f1a 100644 --- a/include/staff/footer.inc.php +++ b/include/staff/footer.inc.php @@ -26,7 +26,8 @@ if(is_object($thisstaff) && $thisstaff->isStaff()) { ?> if ($.support.pjax) { $(document).on('click', 'a', function(event) { if (!$(this).hasClass('no-pjax') - && !$(this).closest('.no-pjax').length) + && !$(this).closest('.no-pjax').length + && $(this).attr('href')[0] != '#') $.pjax.click(event, {container: $('#pjax-container'), timeout: 2000}); }) } diff --git a/include/staff/templates/ticket-preview.tmpl.php b/include/staff/templates/ticket-preview.tmpl.php index 82c3e392f80c91441330a5c9befee4e50e870752..8e0fc32b68647b851e8bf798f388a74d2e7c0b17 100644 --- a/include/staff/templates/ticket-preview.tmpl.php +++ b/include/staff/templates/ticket-preview.tmpl.php @@ -95,7 +95,7 @@ echo sprintf( ' <tr> <th>From:</th> - <td>%s <span class="faded">%s</span></td> + <td><a href="users.php?id=%d" class="no-pjax">%s</a> <span class="faded">%s</span></td> </tr> <tr> <th width="100">Department:</th> @@ -105,6 +105,7 @@ echo sprintf( <th>Help Topic:</th> <td>%s</td> </tr>', + $ticket->getUserId(), Format::htmlchars($ticket->getName()), $ticket->getEmail(), Format::htmlchars($ticket->getDeptName()), @@ -118,14 +119,16 @@ echo '</div>'; // ticket preview content. <table border="0" cellspacing="" cellpadding="1"> <colgroup><col style="min-width: 250px;"></col></colgroup> <?php - if (($users=$ticket->getCollaborators())) {?> + if (($collabs=$ticket->getCollaborators())) {?> <?php - foreach($users as $user) { - echo sprintf('<tr><td %s><i class="icon-%s"></i> %s <em><%s></em></td></tr>', - ($user->isActive()? '' : 'class="faded"'), - ($user->isActive()? 'comments' : 'comment-alt'), - $user->getName(), - $user->getEmail()); + foreach($collabs as $collab) { + echo sprintf('<tr><td %s><i class="icon-%s"></i> + <a href="users.php?id=%d" class="no-pjax">%s</a> <em><%s></em></td></tr>', + ($collab->isActive()? '' : 'class="faded"'), + ($collab->isActive()? 'comments' : 'comment-alt'), + $collab->getUserId(), + $collab->getName(), + $collab->getEmail()); } } else { echo "Ticket doesn't have collaborators."; diff --git a/include/staff/templates/user.tmpl.php b/include/staff/templates/user.tmpl.php index 7fa74fd6890ee8296c8f69670284bff22b039402..48cc87b6acc8de4dacc5b3e1356806e80bb777c8 100644 --- a/include/staff/templates/user.tmpl.php +++ b/include/staff/templates/user.tmpl.php @@ -1,11 +1,15 @@ <?php -if (!$info['title']) +if (!isset($info['title'])) $info['title'] = Format::htmlchars($user->getName()); -?> + +if ($info['title']) { ?> <h3><?php echo $info['title']; ?></h3> <b><a class="close" href="#"><i class="icon-remove-circle"></i></a></b> -<hr/> +<hr> <?php +} else { + echo '<div class="clear"></div>'; +} if ($info['error']) { echo sprintf('<p id="msg_error">%s</p>', $info['error']); } elseif ($info['msg']) { @@ -49,7 +53,7 @@ if ($info['error']) { <a href="users.php?id=<?php echo $user->getId(); ?>" title="Manage User" class="action"><i class="icon-share"></i></a> </div> - <table class="custom-info"> + <table class="custom-info" width="100%"> <?php foreach ($user->getDynamicData() as $entry) { ?> <tr><th colspan="2"><strong><?php diff --git a/include/staff/templates/users.tmpl.php b/include/staff/templates/users.tmpl.php index 11e094d28d89782da68235c6c0c4eb48c12712cb..d5beaf2c77fdcd50d8dde8bd189a84e7acf4e0e9 100644 --- a/include/staff/templates/users.tmpl.php +++ b/include/staff/templates/users.tmpl.php @@ -91,7 +91,7 @@ if ($num) { ?> ?> <tr id="<?php echo $row['id']; ?>"> <td> - <a href="users.php?id=<?php echo $row['id']; ?>"><?php echo $name; ?></a> + <a class="userPreview" href="users.php?id=<?php echo $row['id']; ?>"><?php echo $name; ?></a> <?php if ($row['tickets']) diff --git a/include/staff/user-view.inc.php b/include/staff/user-view.inc.php index 8e6514447332f4ed3e421139000957ae41edd2c6..52af878ed3e475c5e7d2541a0483ad043e6c89c7 100644 --- a/include/staff/user-view.inc.php +++ b/include/staff/user-view.inc.php @@ -84,9 +84,8 @@ $org = $user->getOrganization(); <span id="user-<?php echo $user->getId(); ?>-org"> <?php if ($org) - echo sprintf('<a href="#users/%d/org" - class="user-action">%s</a>', - $user->getId(), $org->getName()); + echo sprintf('<a href="orgs.php?id=%d">%s</a>', + $org->getId(), $org->getName()); else echo sprintf('<a href="#users/%d/org" class="user-action">Add Organization</a>', diff --git a/include/staff/users.inc.php b/include/staff/users.inc.php index b4d64f846a6897c984abdd3e564e3b6fdcd6ce83..91362ae32c8b0bc0afb9d0af276587717ed6afd8 100644 --- a/include/staff/users.inc.php +++ b/include/staff/users.inc.php @@ -139,7 +139,7 @@ else ?> <tr id="<?php echo $row['id']; ?>"> <td> - <a href="users.php?id=<?php echo $row['id']; ?>"><?php echo $name; ?></a> + <a class="userPreview" href="users.php?id=<?php echo $row['id']; ?>"><?php echo $name; ?></a> <?php if ($row['tickets']) diff --git a/scp/ajax.php b/scp/ajax.php index 75a3c4ac6597781f3cf366aef8aa9c4304dc4471..6f784080b2d8d018a35274792b4e6f8005403a9f 100644 --- a/scp/ajax.php +++ b/scp/ajax.php @@ -73,9 +73,10 @@ $dispatcher = patterns('', url_get('^/remote$', 'search', array('remote')), url_get('^/(?P<id>\d+)$', 'getUser'), url_post('^/(?P<id>\d+)$', 'updateUser'), + url_get('^/(?P<id>\d+)/preview$', 'preview'), url_get('^/(?P<id>\d+)/edit$', 'editUser'), url('^/lookup$', 'getUser'), - url_get('^/lookup/form$', 'getLookupForm'), + url_get('^/lookup/form$', 'lookup'), url_post('^/lookup/form$', 'addUser'), url_get('^/add$', 'addUser'), url('^/import$', 'importUsers'), diff --git a/scp/css/scp.css b/scp/css/scp.css index ffa7a31f6f990e5234191abe1a57bae79900aff8..0e5ee155d755d7543de1d4c932f343d0dcb6468d 100644 --- a/scp/css/scp.css +++ b/scp/css/scp.css @@ -8,10 +8,25 @@ body { } a { - color:#E65524; + color:#184E81; text-decoration:none; } +a:hover { + text-decoration: underline; +} + +#nav a:hover, +#sub_nav a:hover, +a:hover i[class^="icon-"], +.tabs a { + text-decoration: none; +} + +div#header a { + color:#E65524; +} + .form_table a:hover { text-decoration: underline; } @@ -1444,11 +1459,14 @@ time { } /* Dynamic forms in dialogs */ +.dialog th, .tip_box th { + text-align: left; +} + .dialog th { background-color: #eee; border: 1px dotted #bbb; padding: 0.3em; - text-align: left; padding-left: 0.3em; } diff --git a/scp/js/scp.js b/scp/js/scp.js index a1de92d4191b6f5f88366a8b0e3af61d3063afb2..cc816fd9997456f3f92d275e4e78c9bb79aec034 100644 --- a/scp/js/scp.js +++ b/scp/js/scp.js @@ -673,7 +673,7 @@ $('.quicknote .action.edit-note').live('click.note', function() { var note = $(this).closest('.quicknote'), body = note.find('.body'), T = $('<textarea>').text(body.html()); - if (note.closest('.dialog').length) + if (note.closest('.dialog, .tip_box').length) T.addClass('no-bar small'); body.replaceWith(T); $.redact(T); @@ -745,7 +745,7 @@ $('#new-note').live('click', function() { 'html' ); }); - if (note.closest('.dialog').length) + if (note.closest('.dialog, .tip_box').length) T.addClass('no-bar small'); note.replaceWith(T); $('<p>').addClass('submit').css('text-align', 'center') diff --git a/scp/js/tips.js b/scp/js/tips.js index db5a1aaf5d6e5feae57dad203a7cdf19eec2d438..a1b7f88d53224c906dc83d7e51716285fd5cc3d3 100644 --- a/scp/js/tips.js +++ b/scp/js/tips.js @@ -214,6 +214,32 @@ jQuery(function() { clearTimeout($(this).data('timer')); }); + //User preview + $('.userPreview').live('mouseover', function(e) { + e.preventDefault(); + var elem = $(this); + + var vars = elem.attr('href').split('='); + var url = 'ajax.php/users/'+vars[1]+'/preview'; + var id='u'+vars[1]; + var xoffset = 80; + + elem.data('timer', 0); + if(!elem.data('id')) { + elem.data('id', id); + if(e.type=='mouseover') { + /* wait about 1 sec - before showing the tip - mouseout kills the timeout*/ + elem.data('timer',setTimeout(function() { showtip(url,elem,xoffset);},750)) + }else{ + clearTimeout(elem.data('timer')); + showtip(url, elem, xoffset); + } + } + }).live('mouseout', function(e) { + $(this).data('id', 0); + clearTimeout($(this).data('timer')); + }); + $('body') .delegate('.tip_close', 'click', function(e) { e.preventDefault();