Translated using Weblate (Italian)
[phpmyadmin.git] / js / server_privileges.js
blob1016a803c9724a77c9eeabe29a83e6b5378a0bb4
1 /* vim: set expandtab sw=4 ts=4 sts=4: */
2 /**
3  * @fileoverview    functions used in server privilege pages
4  * @name            Server Privileges
5  *
6  * @requires    jQuery
7  * @requires    jQueryUI
8  * @requires    js/functions.js
9  *
10  */
12 /**
13  * Validates the "add a user" form
14  *
15  * @return boolean  whether the form is validated or not
16  */
17 function checkAddUser(the_form)
19     if (the_form.elements.pred_hostname.value == 'userdefined' && the_form.elements.hostname.value === '') {
20         alert(PMA_messages.strHostEmpty);
21         the_form.elements.hostname.focus();
22         return false;
23     }
25     if (the_form.elements.pred_username.value == 'userdefined' && the_form.elements.username.value === '') {
26         alert(PMA_messages.strUserEmpty);
27         the_form.elements.username.focus();
28         return false;
29     }
31     return PMA_checkPassword($(the_form));
32 } // end of the 'checkAddUser()' function
34 /**
35  * When a new user is created and retrieved over Ajax, append the user's row to
36  * the user's table
37  *
38  * @param new_user_string         the html for the new user's row
39  * @param new_user_initial        the first alphabet of the user's name
40  * @param new_user_initial_string html to replace the initial for pagination
41  */
42 function appendNewUser(new_user_string, new_user_initial, new_user_initial_string)
44     //Append the newly retrieved user to the table now
46     //Calculate the index for the new row
47     var $curr_last_row = $("#usersForm").find('tbody').find('tr:last');
48     var $curr_first_row = $("#usersForm").find('tbody').find('tr:first');
49     var first_row_initial = $curr_first_row.find('label').html().substr(0, 1).toUpperCase();
50     var curr_shown_initial = $curr_last_row.find('label').html().substr(0, 1).toUpperCase();
51     var curr_last_row_index_string = $curr_last_row.find('input:checkbox').attr('id').match(/\d+/)[0];
52     var curr_last_row_index = parseFloat(curr_last_row_index_string);
53     var new_last_row_index = curr_last_row_index + 1;
54     var new_last_row_id = 'checkbox_sel_users_' + new_last_row_index;
55     var is_show_all = (first_row_initial != curr_shown_initial) ? true : false;
57     //Append to the table and set the id/names correctly
58     if ((curr_shown_initial == new_user_initial) || is_show_all) {
59         $(new_user_string)
60         .insertAfter($curr_last_row)
61         .find('input:checkbox')
62         .attr('id', new_last_row_id)
63         .val(function () {
64             //the insert messes up the &27; part. let's fix it
65             return $(this).val().replace(/&/, '&');
66         })
67         .end()
68         .find('label')
69         .attr('for', new_last_row_id)
70         .end();
71     }
73     //Let us sort the table alphabetically
74     $("#usersForm").find('tbody').PMA_sort_table('label');
76     $("#initials_table").find('td:contains(' + new_user_initial + ')')
77     .html(new_user_initial_string);
79     //update the checkall checkbox
80     $(checkboxes_sel).trigger("change");
83 function addUser($form)
85     if (! checkAddUser($form.get(0))) {
86         return false;
87     }
89     //We also need to post the value of the submit button in order to get this to work correctly
90     $.post($form.attr('action'), $form.serialize() + "&adduser_submit=" + $("input[name=adduser_submit]").val(), function (data) {
91         if (data.success === true) {
92             // Refresh navigation, if we created a database with the name
93             // that is the same as the username of the new user
94             if ($('#add_user_dialog #createdb-1:checked').length) {
95                 PMA_reloadNavigation();
96             }
98             $('#page_content').show();
99             $("#add_user_dialog").remove();
101             PMA_ajaxShowMessage(data.message);
102             $("#result_query").remove();
103             $('#page_content').prepend(data.sql_query);
104             PMA_highlightSQL($('#page_content'));
105             $("#result_query").css({
106                 'margin-top' : '0.5em'
107             });
109             //Remove the empty notice div generated due to a NULL query passed to PMA_getMessage()
110             var $notice_class = $("#result_query").find('.notice');
111             if ($notice_class.text() === '') {
112                 $notice_class.remove();
113             }
114             if ($('#fieldset_add_user a.ajax').attr('name') == 'db_specific') {
116                 /*process the fieldset_add_user attribute and get the val of privileges*/
117                 var url = $('#fieldset_add_user a.ajax').attr('rel');
119                 if (url.substring(url.length - 23, url.length) == "&goto=db_operations.php") {
120                     url = url.substring(0, url.length - 23);
121                 }
122                 url = url + "&ajax_request=true&db_specific=true";
124                 /* post request for get the updated userForm table */
125                 $.post($form.attr('action'), url, function (priv_data) {
127                     /*Remove the old userForm table*/
128                     if ($('#userFormDiv').length !== 0) {
129                         $('#userFormDiv').remove();
130                     } else {
131                         $("#usersForm").remove();
132                     }
133                     if (priv_data.success === true) {
134                         $('<div id="userFormDiv"></div>')
135                             .html(priv_data.user_form)
136                             .insertAfter('#result_query');
137                     } else {
138                         PMA_ajaxShowMessage(PMA_messages.strErrorProcessingRequest + " : " + priv_data.error, false);
139                     }
140                 });
141             } else {
142                 appendNewUser(data.new_user_string, data.new_user_initial, data.new_user_initial_string);
143             }
144         } else {
145             PMA_ajaxShowMessage(data.error, false);
146         }
147     });
151  * AJAX scripts for server_privileges page.
153  * Actions ajaxified here:
154  * Add user
155  * Revoke a user
156  * Edit privileges
157  * Export privileges
158  * Paginate table of users
159  * Flush privileges
161  * @memberOf    jQuery
162  * @name        document.ready
163  */
167  * Unbind all event handlers before tearing down a page
168  */
169 AJAX.registerTeardown('server_privileges.js', function () {
170     $("#fieldset_add_user_login input[name='username']").die("focusout");
171     $("#fieldset_add_user a.ajax").die("click");
172     $('form[name=usersForm]').unbind('submit');
173     $("#fieldset_delete_user_footer #buttonGo.ajax").die('click');
174     $("a.edit_user_anchor.ajax").die('click');
175     $("a.edit_user_group_anchor.ajax").die('click');
176     $("#edit_user_dialog").find("form.ajax").die('submit');
177     $("button.mult_submit[value=export]").die('click');
178     $("a.export_user_anchor.ajax").die('click');
179     $("#initials_table").find("a.ajax").die('click');
180     $('#checkbox_drop_users_db').unbind('click');
181     $(".checkall_box").die("click");
184 AJAX.registerOnload('server_privileges.js', function () {
185     /**
186      * Display a warning if there is already a user by the name entered as the username.
187      */
188     $("#fieldset_add_user_login input[name='username']").live("focusout", function () {
189         var username = $(this).val();
190         var $warning = $("#user_exists_warning");
191         if ($("#select_pred_username").val() == 'userdefined' && username !== '') {
192             var href = $("form[name='usersForm']").attr('action');
193             var params = {
194                 'ajax_request' : true,
195                 'token' : PMA_commonParams.get('token'),
196                 'validate_username' : true,
197                 'username' : username
198             };
199             $.get(href, params, function (data) {
200                 if (data.user_exists) {
201                     $warning.show();
202                 } else {
203                     $warning.hide();
204                 }
205             });
206         } else {
207             $warning.hide();
208         }
209     });
210     /**
211      * AJAX event handler for 'Add a New User'
212      *
213      * @see         PMA_ajaxShowMessage()
214      * @see         appendNewUser()
215      * @memberOf    jQuery
216      * @name        add_user_click
217      *
218      */
219     $("#fieldset_add_user a.ajax").live("click", function (event) {
220         /** @lends jQuery */
221         event.preventDefault();
222         var $msgbox = PMA_ajaxShowMessage();
224         $.get($(this).attr("href"), {'ajax_request': true}, function (data) {
225             if (data.success === true) {
226                 $('#page_content').hide();
227                 var $div = $('#add_user_dialog');
228                 if ($div.length === 0) {
229                     $div = $('<div id="add_user_dialog" style="margin: 0.5em;"></div>')
230                         .insertBefore('#page_content');
231                 } else {
232                     $div.empty();
233                 }
234                 $div.html(data.message)
235                     .find("form[name=usersForm]")
236                     .append('<input type="hidden" name="ajax_request" value="true" />')
237                     .end();
238                 PMA_highlightSQL($div);
239                 displayPasswordGenerateButton();
240                 PMA_showHints($div);
241                 PMA_ajaxRemoveMessage($msgbox);
242                 $div.find("input.autofocus").focus();
244                 $div.find('form[name=usersForm]').bind('submit', function (event) {
245                     event.preventDefault();
246                     addUser($(this));
247                 });
248             } else {
249                 PMA_ajaxShowMessage(data.error, false);
250             }
251         }); // end $.get()
253     });//end of Add New User AJAX event handler
255     /**
256      * AJAX handler for 'Revoke User'
257      *
258      * @see         PMA_ajaxShowMessage()
259      * @memberOf    jQuery
260      * @name        revoke_user_click
261      */
262     $("#fieldset_delete_user_footer #buttonGo.ajax").live('click', function (event) {
263         event.preventDefault();
265         $drop_users_db_checkbox = $("#checkbox_drop_users_db");
266         if ($drop_users_db_checkbox.is(':checked')) {
267             var is_confirmed = confirm(PMA_messages.strDropDatabaseStrongWarning + '\n' + $.sprintf(PMA_messages.strDoYouReally, 'DROP DATABASE'));
268             if (! is_confirmed) {
269                 // Uncheck the drop users database checkbox
270                 $drop_users_db_checkbox.prop('checked', false);
271             }
272         }
274         PMA_ajaxShowMessage(PMA_messages.strRemovingSelectedUsers);
276         var $form = $("#usersForm");
278         $.post($form.attr('action'), $form.serialize() + "&delete=" + $(this).val() + "&ajax_request=true", function (data) {
279             if (data.success === true) {
280                 PMA_ajaxShowMessage(data.message);
281                 // Refresh navigation, if we droppped some databases with the name
282                 // that is the same as the username of the deleted user
283                 if ($('#checkbox_drop_users_db:checked').length) {
284                     PMA_reloadNavigation();
285                 }
286                 //Remove the revoked user from the users list
287                 $form.find("input:checkbox:checked").parents("tr").slideUp("medium", function () {
288                     var this_user_initial = $(this).find('input:checkbox').val().charAt(0).toUpperCase();
289                     $(this).remove();
291                     //If this is the last user with this_user_initial, remove the link from #initials_table
292                     if ($("#tableuserrights").find('input:checkbox[value^="' + this_user_initial + '"]').length === 0) {
293                         $("#initials_table").find('td > a:contains(' + this_user_initial + ')').parent('td').html(this_user_initial);
294                     }
296                     //Re-check the classes of each row
297                     $form
298                     .find('tbody').find('tr:odd')
299                     .removeClass('even').addClass('odd')
300                     .end()
301                     .find('tr:even')
302                     .removeClass('odd').addClass('even');
304                     //update the checkall checkbox
305                     $(checkboxes_sel).trigger("change");
306                 });
307             } else {
308                 PMA_ajaxShowMessage(data.error, false);
309             }
310         }); // end $.post()
311     }); // end Revoke User
313     $("a.edit_user_group_anchor.ajax").live('click', function (event) {
314         event.preventDefault();
315         $(this).parents('tr').addClass('current_row');
316         var token = $(this).parents('form').find('input[name="token"]').val();
317         var $msg = PMA_ajaxShowMessage();
318         $.get(
319             $(this).attr('href'),
320             {
321                 'ajax_request': true,
322                 'edit_user_group_dialog': true,
323                 'token': token
324             },
325             function (data) {
326                 if (data.success === true) {
327                     PMA_ajaxRemoveMessage($msg);
328                     var buttonOptions = {};
329                     buttonOptions[PMA_messages.strGo] = function () {
330                         var usrGroup = $('#changeUserGroupDialog')
331                             .find('select[name="userGroup"]')
332                             .val();
333                         var $message = PMA_ajaxShowMessage();
334                         $.get(
335                             'server_privileges.php',
336                             $('#changeUserGroupDialog').find('form').serialize() + '&ajax_request=1',
337                             function (data) {
338                                 PMA_ajaxRemoveMessage($message);
339                                 if (data.success === true) {
340                                     $("#usersForm")
341                                         .find('.current_row')
342                                         .removeClass('current_row')
343                                         .find('.usrGroup')
344                                         .text(usrGroup);
345                                 } else {
346                                     PMA_ajaxShowMessage(data.error, false);
347                                     $("#usersForm")
348                                         .find('.current_row')
349                                         .removeClass('current_row');
350                                 }
351                             }
352                         );
353                         $(this).dialog("close");
354                     };
355                     buttonOptions[PMA_messages.strClose] = function () {
356                         $(this).dialog("close");
357                     };
358                     var $dialog = $('<div/>')
359                         .attr('id', 'changeUserGroupDialog')
360                         .append(data.message)
361                         .dialog({
362                             width: 500,
363                             minWidth: 300,
364                             modal: true,
365                             buttons: buttonOptions,
366                             title: $('legend', $(data.message)).text(),
367                             close: function () {
368                                 $(this).remove();
369                             }
370                         });
371                     $dialog.find('legend').remove();
372                 } else {
373                     PMA_ajaxShowMessage(data.error, false);
374                     $("#usersForm")
375                         .find('.current_row')
376                         .removeClass('current_row');
377                 }
378             }
379         );
380     });
382     /**
383      * AJAX handler for 'Edit User'
384      *
385      * @see         PMA_ajaxShowMessage()
386      *
387      */
389     /**
390      * Step 1: Load Edit User Dialog
391      * @memberOf    jQuery
392      * @name        edit_user_click
393      */
394     $("a.edit_user_anchor.ajax").live('click', function (event) {
395         /** @lends jQuery */
396         event.preventDefault();
398         var $msgbox = PMA_ajaxShowMessage();
400         $(this).parents('tr').addClass('current_row');
402         var token = $(this).parents('form').find('input[name="token"]').val();
403         $.get(
404             $(this).attr('href'),
405             {
406                 'ajax_request': true,
407                 'edit_user_dialog': true,
408                 'token': token
409             },
410             function (data) {
411                 if (data.success === true) {
412                     $('#page_content').hide();
413                     var $div = $('#edit_user_dialog');
414                     if ($div.length === 0) {
415                         $div = $('<div id="edit_user_dialog" style="margin: 0.5em;"></div>')
416                             .insertBefore('#page_content');
417                     } else {
418                         $div.empty();
419                     }
420                     $div.html(data.message);
421                     PMA_highlightSQL($div);
422                     $div = $('#edit_user_dialog');
423                     displayPasswordGenerateButton();
424                     addOrUpdateSubmenu();
425                     $(checkboxes_sel).trigger("change");
426                     PMA_ajaxRemoveMessage($msgbox);
427                     PMA_showHints($div);
428                 } else {
429                     PMA_ajaxShowMessage(data.error, false);
430                 }
431             }
432         ); // end $.get()
433     });
435     /**
436      * Step 2: Submit the Edit User Dialog
437      *
438      * @see         PMA_ajaxShowMessage()
439      * @memberOf    jQuery
440      * @name        edit_user_submit
441      */
442     $("#edit_user_dialog").find("form.ajax").live('submit', function (event) {
443         /** @lends jQuery */
444         event.preventDefault();
446         var $t = $(this);
448         if ($t.is('.copyUserForm') && ! PMA_checkPassword($t)) {
449             return false;
450         }
452         PMA_ajaxShowMessage(PMA_messages.strProcessingRequest);
454         $t.append('<input type="hidden" name="ajax_request" value="true" />');
456         /**
457          * @var curr_submit_name    name of the current button being submitted
458          */
459         var curr_submit_name = $t.find('.tblFooters').find('input:submit').attr('name');
461         /**
462          * @var curr_submit_value    value of the current button being submitted
463          */
464         var curr_submit_value = $t.find('.tblFooters').find('input:submit').val();
466         // If any option other than 'keep the old one'(option 4) is chosen, we need to remove
467         // the old one from the table.
468         var $row_to_remove;
469         if (curr_submit_name == 'change_copy' &&
470             $('input[name=mode]:checked', '#fieldset_mode').val() != '4'
471         ) {
472             var old_username = $t.find('input[name="old_username"]').val();
473             var old_hostname = $t.find('input[name="old_hostname"]').val();
474             $('#usersForm tbody tr').each(function () {
475                 var $tr = $(this);
476                 if ($tr.find('td:nth-child(2) label').text() == old_username &&
477                     $tr.find('td:nth-child(3)').text() == old_hostname
478                 ) {
479                     $row_to_remove = $tr;
480                     return false;
481                 }
482             });
483         }
485         $.post($t.attr('action'), $t.serialize() + '&' + curr_submit_name + '=' + curr_submit_value, function (data) {
486             if (data.success === true) {
487                 $('#page_content').show();
488                 $("#edit_user_dialog").remove();
490                 PMA_ajaxShowMessage(data.message);
492                 if (data.sql_query) {
493                     $("#result_query").remove();
494                     $('#page_content').prepend(data.sql_query);
495                     PMA_highlightSQL($('#page_content'));
496                     $("#result_query").css({
497                         'margin-top' : '0.5em'
498                     });
499                     var $notice_class = $("#result_query").find('.notice');
500                     if ($notice_class.text() === '') {
501                         $notice_class.remove();
502                     }
503                 } //Show SQL Query that was executed
505                 // Remove the old row if the old user is deleted
506                 if (typeof $row_to_remove != 'undefined' && $row_to_remove !== null) {
507                     $row_to_remove.remove();
508                 }
510                 //Append new user if necessary
511                 if (data.new_user_string) {
512                     appendNewUser(data.new_user_string, data.new_user_initial, data.new_user_initial_string);
513                 }
515                 //Check if we are on the page of the db-specific privileges
516                 var db_priv_page = !!($('#dbspecificuserrights').length); // the "!!" part is merely there to ensure a value of type boolean
517                 // we always need to reload on the db-specific privilege page
518                 // and on the global page when adjusting global privileges,
519                 // but not on the global page when adjusting db-specific privileges.
520                 var reload_privs = false;
521                 if (data.db_specific_privs === false || (db_priv_page == data.db_specific_privs)) {
522                     reload_privs = true;
523                 }
524                 if (data.db_wildcard_privs) {
525                     reload_privs = false;
526                 }
528                 //Change privileges, if they were edited and need to be reloaded
529                 if (data.new_privileges && reload_privs) {
530                     $("#usersForm")
531                     .find('.current_row')
532                     .find('code')
533                     .html(data.new_privileges);
534                 }
536                 $("#usersForm")
537                 .find('.current_row')
538                 .removeClass('current_row');
539             } else {
540                 PMA_ajaxShowMessage(data.error, false);
541             }
542         });
543     });
544     //end Edit user
546     /**
547      * AJAX handler for 'Export Privileges'
548      *
549      * @see         PMA_ajaxShowMessage()
550      * @memberOf    jQuery
551      * @name        export_user_click
552      */
553     $("button.mult_submit[value=export]").live('click', function (event) {
554         event.preventDefault();
555         // can't export if no users checked
556         if ($(this.form).find("input:checked").length === 0) {
557             return;
558         }
559         var $msgbox = PMA_ajaxShowMessage();
560         var button_options = {};
561         button_options[PMA_messages.strClose] = function () {
562             $(this).dialog("close");
563         };
564         $.post(
565             $(this.form).prop('action'),
566             $(this.form).serialize() + '&submit_mult=export&ajax_request=true',
567             function (data) {
568                 if (data.success === true) {
569                     var $ajaxDialog = $('<div />')
570                     .append(data.message)
571                     .dialog({
572                         title: data.title,
573                         width: 500,
574                         buttons: button_options,
575                         close: function () {
576                             $(this).remove();
577                         }
578                     });
579                     PMA_ajaxRemoveMessage($msgbox);
580                     // Attach syntax highlighted editor to export dialog
581                     if (typeof CodeMirror != 'undefined') {
582                         CodeMirror.fromTextArea(
583                             $ajaxDialog.find('textarea')[0],
584                             {
585                                 lineNumbers: true,
586                                 matchBrackets: true,
587                                 indentUnit: 4,
588                                 mode: "text/x-mysql",
589                                 lineWrapping: true
590                             }
591                         );
592                     }
593                 } else {
594                     PMA_ajaxShowMessage(data.error, false);
595                 }
596             }
597         ); //end $.post
598     });
599     // if exporting non-ajax, highlight anyways
600     if ($("textarea.export").length > 0 && typeof CodeMirror != 'undefined') {
601         CodeMirror.fromTextArea(
602             $('textarea.export')[0],
603             {
604                 lineNumbers: true,
605                 matchBrackets: true,
606                 indentUnit: 4,
607                 mode: "text/x-mysql",
608                 lineWrapping: true
609             }
610         );
611     }
613     $("a.export_user_anchor.ajax").live('click', function (event) {
614         event.preventDefault();
615         var $msgbox = PMA_ajaxShowMessage();
616         /**
617          * @var button_options  Object containing options for jQueryUI dialog buttons
618          */
619         var button_options = {};
620         button_options[PMA_messages.strClose] = function () {
621             $(this).dialog("close");
622         };
623         $.get($(this).attr('href'), {'ajax_request': true}, function (data) {
624             if (data.success === true) {
625                 var $ajaxDialog = $('<div />')
626                 .append(data.message)
627                 .dialog({
628                     title: data.title,
629                     width: 500,
630                     buttons: button_options,
631                     close: function () {
632                         $(this).remove();
633                     }
634                 });
635                 PMA_ajaxRemoveMessage($msgbox);
636                 // Attach syntax highlighted editor to export dialog
637                 if (typeof CodeMirror != 'undefined') {
638                     CodeMirror.fromTextArea(
639                         $ajaxDialog.find('textarea')[0],
640                         {
641                             lineNumbers: true,
642                             matchBrackets: true,
643                             indentUnit: 4,
644                             mode: "text/x-mysql",
645                             lineWrapping: true
646                         }
647                     );
648                 }
649             } else {
650                 PMA_ajaxShowMessage(data.error, false);
651             }
652         }); //end $.get
653     }); //end export privileges
655     /**
656      * AJAX handler to Paginate the Users Table
657      *
658      * @see         PMA_ajaxShowMessage()
659      * @name        paginate_users_table_click
660      * @memberOf    jQuery
661      */
662     $("#initials_table").find("a.ajax").live('click', function (event) {
663         event.preventDefault();
664         var $msgbox = PMA_ajaxShowMessage();
665         $.get($(this).attr('href'), {'ajax_request' : true}, function (data) {
666             if (data.success === true) {
667                 PMA_ajaxRemoveMessage($msgbox);
668                 // This form is not on screen when first entering Privileges
669                 // if there are more than 50 users
670                 $("div.notice").remove();
671                 $("#usersForm").hide("medium").remove();
672                 $("#fieldset_add_user").hide("medium").remove();
673                 $("#initials_table")
674                     .prop("id", "initials_table_old")
675                     .after(data.message).show("medium")
676                     .siblings("h2").not(":first").remove();
677                 // prevent double initials table
678                 $("#initials_table_old").remove();
679             } else {
680                 PMA_ajaxShowMessage(data.error, false);
681             }
682         }); // end $.get
683     }); // end of the paginate users table
685     displayPasswordGenerateButton();
687     /*
688      * Create submenu for simpler interface
689      */
690     var addOrUpdateSubmenu = function () {
691         var $topmenu2 = $("#topmenu2"),
692             $edit_user_dialog = $("#edit_user_dialog"),
693             submenu_label,
694             submenu_link,
695             link_number;
697         // if submenu exists yet, remove it first
698         if ($topmenu2.length > 0) {
699             $topmenu2.remove();
700         }
702         // construct a submenu from the existing fieldsets
703         $topmenu2 = $("<ul/>").prop("id", "topmenu2");
705         $("#edit_user_dialog .submenu-item").each(function () {
706             submenu_label = $(this).find("legend[data-submenu-label]").data("submenu-label");
708             submenu_link = $("<a/>")
709             .prop("href", "#")
710             .html(submenu_label);
712             $("<li/>")
713             .append(submenu_link)
714             .appendTo($topmenu2);
715         });
717         // click handlers for submenu
718         $topmenu2.find("a").click(function (e) {
719             e.preventDefault();
720             // if already active, ignore click
721             if ($(this).hasClass("tabactive")) {
722                 return;
723             }
724             $topmenu2.find("a").removeClass("tabactive");
725             $(this).addClass("tabactive");
727             // which section to show now?
728             link_number = $topmenu2.find("a").index($(this));
729             // hide all sections but the one to show
730             $("#edit_user_dialog .submenu-item").hide().eq(link_number).show();
731         });
733         // make first menu item active
734         // TODO: support URL hash history
735         $topmenu2.find("> :first-child a").addClass("tabactive");
736         $edit_user_dialog.prepend($topmenu2);
738         // hide all sections but the first
739         $("#edit_user_dialog .submenu-item").hide().eq(0).show();
740     };