From 10ee1757de79d15839257aee1f14ba800882acb9 Mon Sep 17 00:00:00 2001 From: Peter Rotich <peter@enhancesoft.com> Date: Tue, 26 Nov 2013 04:07:27 +0000 Subject: [PATCH] Retire old user update code --- include/ajax.forms.php | 65 ---------------------- include/staff/templates/user-info.tmpl.php | 41 -------------- include/staff/ticket-view.inc.php | 3 - scp/ajax.php | 4 +- 4 files changed, 1 insertion(+), 112 deletions(-) delete mode 100644 include/staff/templates/user-info.tmpl.php diff --git a/include/ajax.forms.php b/include/ajax.forms.php index 5765c7286..cdd643a1b 100644 --- a/include/ajax.forms.php +++ b/include/ajax.forms.php @@ -37,71 +37,6 @@ class DynamicFormsAjaxAPI extends AjaxController { $field->save(); } - function getUserInfo($user_id) { - $user = User::lookup($user_id); - - $data = $user->ht; - $data['email'] = $user->default_email->address; - - $custom = array(); - foreach ($user->getDynamicData() as $cd) { - $cd->addMissingFields(); - foreach ($cd->getFields() as $f) { - if ($f->get('name') == 'name') - $f->value = $user->getFullName(); - elseif ($f->get('name') == 'email') - $f->value = $user->getEmail(); - } - $custom[] = $cd->getForm(); - } - - include(STAFFINC_DIR . 'templates/user-info.tmpl.php'); - } - - function saveUserInfo($user_id) { - $user = User::lookup($user_id); - - //TODO: Move save user logic to user class. - $custom_data = $user->getDynamicData(); - $custom = array(); - $valid = true; - foreach ($custom_data as $cd) { - $cd->addMissingFields(); - $cf = $custom[] = $cd->getForm(); - $valid &= $cd->isValid(); - } - - if ($valid) { - // Make sure email is uniqueue - foreach ($custom_data as $cd) { - if (($f=$cd->getField('email')) - && ($u=User::lookup(array('emails__address'=>$f->getClean()))) - && $u->id != $user_id) { - $valid = false; - $f->addError('Email is assigned to another user'); - } - } - // Save custom data - if ($valid) { - foreach ($custom_data as $cd) { - foreach ($cd->getFields() as $f) { - if ($f->get('name') == 'name') { - $user->name = $f->getClean(); - $user->save(); - } elseif ($f->get('name') == 'email') { - $user->default_email->address = $f->getClean(); - $user->default_email->save(); - } - } - $cd->save(); - } - return Http::response(201, $user->to_json()); - } - } - - include(STAFFINC_DIR . 'templates/user-info.tmpl.php'); - return; - } } ?> diff --git a/include/staff/templates/user-info.tmpl.php b/include/staff/templates/user-info.tmpl.php deleted file mode 100644 index 09b99b727..000000000 --- a/include/staff/templates/user-info.tmpl.php +++ /dev/null @@ -1,41 +0,0 @@ -<h3><?php echo $user->getFullName() ?></h3> -<a class="close" href=""><i class="icon-remove-circle"></i></a> -<br> -<div><p id="msg_info"><i class="icon-info-sign"></i> Please note that updates will be reflected system-wide.</p></div> -<hr/> -<form method="post" action="ajax.php/form/user-info/<?php - echo $user->get('id'); ?>" onsubmit="javascript: - var form = $(this); - var dialog = form.closest('.dialog'); - $.post(this.action, form.serialize(), function(data, status, xhr) { - if(xhr && xhr.status == 201) { - var user = $.parseJSON(xhr.responseText); - $('#user-'+user.id+'-name').html(user.name); - $('div.body', dialog).empty(); - dialog.hide(); - $('#overlay').hide(); - } else { - $('div.body', dialog).html(data); - } - }); - return false; - "> - <table width="100%"> - <?php - echo csrf_token(); - foreach ($custom as $form) - $form->render(); - ?> - </table> - <hr> - <p class="full-width"> - <span class="buttons" style="float:left"> - <input type="reset" value="Reset"> - <input type="button" value="Cancel" class="close"> - </span> - <span class="buttons" style="float:right"> - <input type="submit" value="Save"> - </span> - </p> -</form> -<div class="clear"></div> diff --git a/include/staff/ticket-view.inc.php b/include/staff/ticket-view.inc.php index 38db1af32..a8a028627 100644 --- a/include/staff/ticket-view.inc.php +++ b/include/staff/ticket-view.inc.php @@ -786,9 +786,6 @@ $tcount+= $ticket->getNumNotes(); <?php } ?> </div> -<div style="display:none;" class="dialog draggable" id="user-info"> - <div class="body"></div> -</div> <div style="display:none;" class="dialog" id="print-options"> <h3>Ticket Print Options</h3> <a class="close" href=""><i class="icon-remove-circle"></i></a> diff --git a/scp/ajax.php b/scp/ajax.php index ddf0ab893..02895d6e3 100644 --- a/scp/ajax.php +++ b/scp/ajax.php @@ -48,9 +48,7 @@ $dispatcher = patterns('', url('^/form/', patterns('ajax.forms.php:DynamicFormsAjaxAPI', url_get('^help-topic/(?P<id>\d+)$', 'getFormsForHelpTopic'), url_get('^field-config/(?P<id>\d+)$', 'getFieldConfiguration'), - url_post('^field-config/(?P<id>\d+)$', 'saveFieldConfiguration'), - url_get('^user-info/(?P<id>\d+)$', 'getUserInfo'), - url_post('^user-info/(?P<id>\d+)$', 'saveUserInfo') + url_post('^field-config/(?P<id>\d+)$', 'saveFieldConfiguration') )), url('^/report/overview/', patterns('ajax.reports.php:OverviewReportAjaxAPI', # Send -- GitLab