diff --git a/include/ajax.orgs.php b/include/ajax.orgs.php index 9a72c20449470d3c8ce8fa916132e063374fd862..faf8b38cfd4ea8383ac478b9467f07d7f55b6cfd 100644 --- a/include/ajax.orgs.php +++ b/include/ajax.orgs.php @@ -205,6 +205,15 @@ class OrgsAjaxAPI extends AjaxController { } + function createNote($id) { + if (!($org = Organization::lookup($id))) + Http::response(404, 'Unknown organization'); + + require_once INCLUDE_DIR . 'ajax.note.php'; + $ajax = new NoteAjaxAPI(); + return $ajax->createNote('O'.$id); + } + static function _lookupform($form=null, $info=array()) { if (!$info or !$info['title']) diff --git a/include/ajax.users.php b/include/ajax.users.php index 1fbe7fe6084de53cae776b41b2da63ef2ae35783..410c6ce9cafedece49be4a3c044c9f9cf8c241d1 100644 --- a/include/ajax.users.php +++ b/include/ajax.users.php @@ -349,5 +349,14 @@ class UsersAjaxAPI extends AjaxController { return $resp; } + function createNote($id) { + if (!($user = User::lookup($id))) + Http::response(404, 'Unknown user'); + + require_once INCLUDE_DIR . 'ajax.note.php'; + $ajax = new NoteAjaxAPI(); + return $ajax->createNote('U'.$id); + } + } ?> diff --git a/include/staff/org-view.inc.php b/include/staff/org-view.inc.php index 5f040395f9337fc872798cbd17473f33e0bdc7e6..5e334c12bcda70c12a995c945a0c81463292c3d4 100644 --- a/include/staff/org-view.inc.php +++ b/include/staff/org-view.inc.php @@ -70,7 +70,7 @@ include STAFFINC_DIR . 'templates/tickets.tmpl.php'; <div class="tab_content" id="notes" style="display:none"> <?php $notes = QuickNote::forOrganization($org); -$ext_id = 'O'.$org->getId(); +$create_note_url = 'orgs/'.$org->getId().'/note'; include STAFFINC_DIR . 'templates/notes.tmpl.php'; ?> </div> diff --git a/include/staff/templates/notes.tmpl.php b/include/staff/templates/notes.tmpl.php index dca6477151481303aee4325a04e97bd224d5dafb..360c519fe65d7752f80c5e45be7196b2d12f4e8a 100644 --- a/include/staff/templates/notes.tmpl.php +++ b/include/staff/templates/notes.tmpl.php @@ -5,7 +5,7 @@ foreach ($notes as $note) { include STAFFINC_DIR."templates/note.tmpl.php"; } ?> </div> -<div class="quicknote" id="new-note" data-ext-id="<?php echo $ext_id; ?>"> +<div class="quicknote" id="new-note" data-url="<?php echo $create_note_url; ?>"> <div class="body"> <a href="#"><i class="icon-plus icon-large"></i> Click to create a new note</a> </div> diff --git a/include/staff/templates/user.tmpl.php b/include/staff/templates/user.tmpl.php index abc451170355cd27e2380240fec8f3dd2f757e30..0f2a930d5e032ff58d8290f08ddcdd85d1025160 100644 --- a/include/staff/templates/user.tmpl.php +++ b/include/staff/templates/user.tmpl.php @@ -91,7 +91,8 @@ if ($info['error']) { foreach ($notes as $note) include STAFFINC_DIR . 'templates/note.tmpl.php'; ?> -<div class="quicknote no-options" id="new-note" data-ext-id="U<?php echo $user->getId(); ?>"> +<div class="quicknote no-options" id="new-note" + data-url="users/<?php echo $user->getId(); ?>/note"> <div class="body"> <a href="#"><i class="icon-plus icon-large"></i> Click to create a new note</a> </div> diff --git a/include/staff/user-view.inc.php b/include/staff/user-view.inc.php index 69cb2a55839fe369deb4815d597d789cbe90861e..4b267a9cc510d0bb4998ef34804bb1c885b014c4 100644 --- a/include/staff/user-view.inc.php +++ b/include/staff/user-view.inc.php @@ -131,7 +131,7 @@ include STAFFINC_DIR . 'templates/tickets.tmpl.php'; <div class="tab_content" id="notes" style="display:none"> <?php $notes = QuickNote::forUser($user); -$ext_id = 'U'.$user->getId(); +$create_note_url = 'users/'.$user->getId().'/note'; include STAFFINC_DIR . 'templates/notes.tmpl.php'; ?> </div> diff --git a/scp/ajax.php b/scp/ajax.php index a445bfeb92977fae99efd069859abb0468971135..20fddfc72bf111d3f8d6962b93368b06da0f12a7 100644 --- a/scp/ajax.php +++ b/scp/ajax.php @@ -89,7 +89,8 @@ $dispatcher = patterns('', url_post('^/(?P<id>\d+)/manage(?:/(?P<target>\w+))?$', 'manage'), url_get('^/(?P<id>\d+)/org(?:/(?P<orgid>\d+))?$', 'updateOrg'), url_post('^/(?P<id>\d+)/org$', 'updateOrg'), - url_get('^/staff$', 'searchStaff') + url_get('^/staff$', 'searchStaff'), + url_post('^/(?P<id>\d+)/note$', 'createNote') )), url('^/orgs', patterns('ajax.orgs.php:OrgsAjaxAPI', url_get('^$', 'search'), @@ -108,7 +109,8 @@ $dispatcher = patterns('', url_get('^/(?P<id>\d+)/add-user(?:/auth:(?P<userid>.+))?$', 'addUser', array(true)), url_post('^/(?P<id>\d+)/add-user$', 'addUser'), url_get('^/(?P<id>\d+)/delete$', 'delete'), - url_delete('^/(?P<id>\d+)/delete$', 'delete') + url_delete('^/(?P<id>\d+)/delete$', 'delete'), + url_post('^/(?P<id>\d+)/note$', 'createNote') )), url('^/tickets/', patterns('ajax.tickets.php:TicketsAjaxAPI', url_get('^(?P<tid>\d+)/change-user$', 'changeUserForm'), diff --git a/scp/js/scp.js b/scp/js/scp.js index 3712f8904f590d0b74d2434251dc9eb7c52321db..489cc72aecd056c9df19cf023d6fb3a9ec5dc1d5 100644 --- a/scp/js/scp.js +++ b/scp/js/scp.js @@ -728,7 +728,7 @@ $('#new-note').live('click', function() { T = $('<textarea>'), button = $('<input type="button">').val('Create'); button.click(function() { - $.post('ajax.php/note/attach/' + note.data('extId'), + $.post('ajax.php/' + note.data('url'), { note: T.redactor('get'), no_options: note.hasClass('no-options') }, function(response) { $(T).redactor('destroy').replaceWith(note);