added japanese language
[openemr.git] / phpmyadmin / js / server_privileges.js
blobc77cc521c74099dda9cbc7e35915193e69f9a170
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                 'server' : PMA_commonParams.get('server'),
197                 'validate_username' : true,
198                 'username' : username
199             };
200             $.get(href, params, function (data) {
201                 if (data.user_exists) {
202                     $warning.show();
203                 } else {
204                     $warning.hide();
205                 }
206             });
207         } else {
208             $warning.hide();
209         }
210     });
211     /**
212      * AJAX event handler for 'Add a New User'
213      *
214      * @see         PMA_ajaxShowMessage()
215      * @see         appendNewUser()
216      * @memberOf    jQuery
217      * @name        add_user_click
218      *
219      */
220     $("#fieldset_add_user a.ajax").live("click", function (event) {
221         /** @lends jQuery */
222         event.preventDefault();
223         var $msgbox = PMA_ajaxShowMessage();
225         $.get($(this).attr("href"), {'ajax_request': true}, function (data) {
226             if (data.success === true) {
227                 $('#page_content').hide();
228                 var $div = $('#add_user_dialog');
229                 if ($div.length === 0) {
230                     $div = $('<div id="add_user_dialog" style="margin: 0.5em;"></div>')
231                         .insertBefore('#page_content');
232                 } else {
233                     $div.empty();
234                 }
235                 $div.html(data.message)
236                     .find("form[name=usersForm]")
237                     .append('<input type="hidden" name="ajax_request" value="true" />')
238                     .end();
239                 PMA_highlightSQL($div);
240                 displayPasswordGenerateButton();
241                 PMA_showHints($div);
242                 PMA_ajaxRemoveMessage($msgbox);
243                 $div.find("input.autofocus").focus();
245                 $div.find('form[name=usersForm]').bind('submit', function (event) {
246                     event.preventDefault();
247                     addUser($(this));
248                 });
249             } else {
250                 PMA_ajaxShowMessage(data.error, false);
251             }
252         }); // end $.get()
254     });//end of Add New User AJAX event handler
256     /**
257      * AJAX handler for 'Revoke User'
258      *
259      * @see         PMA_ajaxShowMessage()
260      * @memberOf    jQuery
261      * @name        revoke_user_click
262      */
263     $("#fieldset_delete_user_footer #buttonGo.ajax").live('click', function (event) {
264         event.preventDefault();
266         $drop_users_db_checkbox = $("#checkbox_drop_users_db");
267         if ($drop_users_db_checkbox.is(':checked')) {
268             var is_confirmed = confirm(PMA_messages.strDropDatabaseStrongWarning + '\n' + $.sprintf(PMA_messages.strDoYouReally, 'DROP DATABASE'));
269             if (! is_confirmed) {
270                 // Uncheck the drop users database checkbox
271                 $drop_users_db_checkbox.prop('checked', false);
272             }
273         }
275         PMA_ajaxShowMessage(PMA_messages.strRemovingSelectedUsers);
277         var $form = $("#usersForm");
279         $.post($form.attr('action'), $form.serialize() + "&delete=" + $(this).val() + "&ajax_request=true", function (data) {
280             if (data.success === true) {
281                 PMA_ajaxShowMessage(data.message);
282                 // Refresh navigation, if we droppped some databases with the name
283                 // that is the same as the username of the deleted user
284                 if ($('#checkbox_drop_users_db:checked').length) {
285                     PMA_reloadNavigation();
286                 }
287                 //Remove the revoked user from the users list
288                 $form.find("input:checkbox:checked").parents("tr").slideUp("medium", function () {
289                     var this_user_initial = $(this).find('input:checkbox').val().charAt(0).toUpperCase();
290                     $(this).remove();
292                     //If this is the last user with this_user_initial, remove the link from #initials_table
293                     if ($("#tableuserrights").find('input:checkbox[value^="' + this_user_initial + '"]').length === 0) {
294                         $("#initials_table").find('td > a:contains(' + this_user_initial + ')').parent('td').html(this_user_initial);
295                     }
297                     //Re-check the classes of each row
298                     $form
299                     .find('tbody').find('tr:odd')
300                     .removeClass('even').addClass('odd')
301                     .end()
302                     .find('tr:even')
303                     .removeClass('odd').addClass('even');
305                     //update the checkall checkbox
306                     $(checkboxes_sel).trigger("change");
307                 });
308             } else {
309                 PMA_ajaxShowMessage(data.error, false);
310             }
311         }); // end $.post()
312     }); // end Revoke User
314     $("a.edit_user_group_anchor.ajax").live('click', function (event) {
315         event.preventDefault();
316         $(this).parents('tr').addClass('current_row');
317         var token = $(this).parents('form').find('input[name="token"]').val();
318         var $msg = PMA_ajaxShowMessage();
319         $.get(
320             $(this).attr('href'),
321             {
322                 'ajax_request': true,
323                 'edit_user_group_dialog': true,
324                 'token': token
325             },
326             function (data) {
327                 if (data.success === true) {
328                     PMA_ajaxRemoveMessage($msg);
329                     var buttonOptions = {};
330                     buttonOptions[PMA_messages.strGo] = function () {
331                         var usrGroup = $('#changeUserGroupDialog')
332                             .find('select[name="userGroup"]')
333                             .val();
334                         var $message = PMA_ajaxShowMessage();
335                         $.get(
336                             'server_privileges.php',
337                             $('#changeUserGroupDialog').find('form').serialize() + '&ajax_request=1',
338                             function (data) {
339                                 PMA_ajaxRemoveMessage($message);
340                                 if (data.success === true) {
341                                     $("#usersForm")
342                                         .find('.current_row')
343                                         .removeClass('current_row')
344                                         .find('.usrGroup')
345                                         .text(usrGroup);
346                                 } else {
347                                     PMA_ajaxShowMessage(data.error, false);
348                                     $("#usersForm")
349                                         .find('.current_row')
350                                         .removeClass('current_row');
351                                 }
352                             }
353                         );
354                         $(this).dialog("close");
355                     };
356                     buttonOptions[PMA_messages.strClose] = function () {
357                         $(this).dialog("close");
358                     };
359                     var $dialog = $('<div/>')
360                         .attr('id', 'changeUserGroupDialog')
361                         .append(data.message)
362                         .dialog({
363                             width: 500,
364                             minWidth: 300,
365                             modal: true,
366                             buttons: buttonOptions,
367                             title: $('legend', $(data.message)).text(),
368                             close: function () {
369                                 $(this).remove();
370                             }
371                         });
372                     $dialog.find('legend').remove();
373                 } else {
374                     PMA_ajaxShowMessage(data.error, false);
375                     $("#usersForm")
376                         .find('.current_row')
377                         .removeClass('current_row');
378                 }
379             }
380         );
381     });
383     /**
384      * AJAX handler for 'Edit User'
385      *
386      * @see         PMA_ajaxShowMessage()
387      *
388      */
390     /**
391      * Step 1: Load Edit User Dialog
392      * @memberOf    jQuery
393      * @name        edit_user_click
394      */
395     $("a.edit_user_anchor.ajax").live('click', function (event) {
396         /** @lends jQuery */
397         event.preventDefault();
399         var $msgbox = PMA_ajaxShowMessage();
401         $(this).parents('tr').addClass('current_row');
403         var token = $(this).parents('form').find('input[name="token"]').val();
404         $.get(
405             $(this).attr('href'),
406             {
407                 'ajax_request': true,
408                 'edit_user_dialog': true,
409                 'token': token
410             },
411             function (data) {
412                 if (data.success === true) {
413                     $('#page_content').hide();
414                     var $div = $('#edit_user_dialog');
415                     if ($div.length === 0) {
416                         $div = $('<div id="edit_user_dialog" style="margin: 0.5em;"></div>')
417                             .insertBefore('#page_content');
418                     } else {
419                         $div.empty();
420                     }
421                     $div.html(data.message);
422                     PMA_highlightSQL($div);
423                     $div = $('#edit_user_dialog');
424                     displayPasswordGenerateButton();
425                     addOrUpdateSubmenu();
426                     $(checkboxes_sel).trigger("change");
427                     PMA_ajaxRemoveMessage($msgbox);
428                     PMA_showHints($div);
429                 } else {
430                     PMA_ajaxShowMessage(data.error, false);
431                 }
432             }
433         ); // end $.get()
434     });
436     /**
437      * Step 2: Submit the Edit User Dialog
438      *
439      * @see         PMA_ajaxShowMessage()
440      * @memberOf    jQuery
441      * @name        edit_user_submit
442      */
443     $("#edit_user_dialog").find("form.ajax").live('submit', function (event) {
444         /** @lends jQuery */
445         event.preventDefault();
447         var $t = $(this);
449         if ($t.is('.copyUserForm') && ! PMA_checkPassword($t)) {
450             return false;
451         }
453         PMA_ajaxShowMessage(PMA_messages.strProcessingRequest);
455         $t.append('<input type="hidden" name="ajax_request" value="true" />');
457         /**
458          * @var curr_submit_name    name of the current button being submitted
459          */
460         var curr_submit_name = $t.find('.tblFooters').find('input:submit').attr('name');
462         /**
463          * @var curr_submit_value    value of the current button being submitted
464          */
465         var curr_submit_value = $t.find('.tblFooters').find('input:submit').val();
467         // If any option other than 'keep the old one'(option 4) is chosen, we need to remove
468         // the old one from the table.
469         var $row_to_remove;
470         if (curr_submit_name == 'change_copy' &&
471             $('input[name=mode]:checked', '#fieldset_mode').val() != '4'
472         ) {
473             var old_username = $t.find('input[name="old_username"]').val();
474             var old_hostname = $t.find('input[name="old_hostname"]').val();
475             $('#usersForm tbody tr').each(function () {
476                 var $tr = $(this);
477                 if ($tr.find('td:nth-child(2) label').text() == old_username &&
478                     $tr.find('td:nth-child(3)').text() == old_hostname
479                 ) {
480                     $row_to_remove = $tr;
481                     return false;
482                 }
483             });
484         }
486         $.post($t.attr('action'), $t.serialize() + '&' + curr_submit_name + '=' + curr_submit_value, function (data) {
487             if (data.success === true) {
488                 $('#page_content').show();
489                 $("#edit_user_dialog").remove();
491                 PMA_ajaxShowMessage(data.message);
493                 if (data.sql_query) {
494                     $("#result_query").remove();
495                     $('#page_content').prepend(data.sql_query);
496                     PMA_highlightSQL($('#page_content'));
497                     $("#result_query").css({
498                         'margin-top' : '0.5em'
499                     });
500                     var $notice_class = $("#result_query").find('.notice');
501                     if ($notice_class.text() === '') {
502                         $notice_class.remove();
503                     }
504                 } //Show SQL Query that was executed
506                 // Remove the old row if the old user is deleted
507                 if (typeof $row_to_remove != 'undefined' && $row_to_remove !== null) {
508                     $row_to_remove.remove();
509                 }
511                 //Append new user if necessary
512                 if (data.new_user_string) {
513                     appendNewUser(data.new_user_string, data.new_user_initial, data.new_user_initial_string);
514                 }
516                 //Check if we are on the page of the db-specific privileges
517                 var db_priv_page = !!($('#dbspecificuserrights').length); // the "!!" part is merely there to ensure a value of type boolean
518                 // we always need to reload on the db-specific privilege page
519                 // and on the global page when adjusting global privileges,
520                 // but not on the global page when adjusting db-specific privileges.
521                 var reload_privs = false;
522                 if (data.db_specific_privs === false || (db_priv_page == data.db_specific_privs)) {
523                     reload_privs = true;
524                 }
525                 if (data.db_wildcard_privs) {
526                     reload_privs = false;
527                 }
529                 //Change privileges, if they were edited and need to be reloaded
530                 if (data.new_privileges && reload_privs) {
531                     $("#usersForm")
532                     .find('.current_row')
533                     .find('code')
534                     .html(data.new_privileges);
535                 }
537                 $("#usersForm")
538                 .find('.current_row')
539                 .removeClass('current_row');
540             } else {
541                 PMA_ajaxShowMessage(data.error, false);
542             }
543         });
544     });
545     //end Edit user
547     /**
548      * AJAX handler for 'Export Privileges'
549      *
550      * @see         PMA_ajaxShowMessage()
551      * @memberOf    jQuery
552      * @name        export_user_click
553      */
554     $("button.mult_submit[value=export]").live('click', function (event) {
555         event.preventDefault();
556         // can't export if no users checked
557         if ($(this.form).find("input:checked").length === 0) {
558             return;
559         }
560         var $msgbox = PMA_ajaxShowMessage();
561         var button_options = {};
562         button_options[PMA_messages.strClose] = function () {
563             $(this).dialog("close");
564         };
565         $.post(
566             $(this.form).prop('action'),
567             $(this.form).serialize() + '&submit_mult=export&ajax_request=true',
568             function (data) {
569                 if (data.success === true) {
570                     var $ajaxDialog = $('<div />')
571                     .append(data.message)
572                     .dialog({
573                         title: data.title,
574                         width: 500,
575                         buttons: button_options,
576                         close: function () {
577                             $(this).remove();
578                         }
579                     });
580                     PMA_ajaxRemoveMessage($msgbox);
581                     // Attach syntax highlighted editor to export dialog
582                     if (typeof CodeMirror != 'undefined') {
583                         CodeMirror.fromTextArea(
584                             $ajaxDialog.find('textarea')[0],
585                             {
586                                 lineNumbers: true,
587                                 matchBrackets: true,
588                                 indentUnit: 4,
589                                 mode: "text/x-mysql",
590                                 lineWrapping: true
591                             }
592                         );
593                     }
594                 } else {
595                     PMA_ajaxShowMessage(data.error, false);
596                 }
597             }
598         ); //end $.post
599     });
600     // if exporting non-ajax, highlight anyways
601     if ($("textarea.export").length > 0 && typeof CodeMirror != 'undefined') {
602         CodeMirror.fromTextArea(
603             $('textarea.export')[0],
604             {
605                 lineNumbers: true,
606                 matchBrackets: true,
607                 indentUnit: 4,
608                 mode: "text/x-mysql",
609                 lineWrapping: true
610             }
611         );
612     }
614     $("a.export_user_anchor.ajax").live('click', function (event) {
615         event.preventDefault();
616         var $msgbox = PMA_ajaxShowMessage();
617         /**
618          * @var button_options  Object containing options for jQueryUI dialog buttons
619          */
620         var button_options = {};
621         button_options[PMA_messages.strClose] = function () {
622             $(this).dialog("close");
623         };
624         $.get($(this).attr('href'), {'ajax_request': true}, function (data) {
625             if (data.success === true) {
626                 var $ajaxDialog = $('<div />')
627                 .append(data.message)
628                 .dialog({
629                     title: data.title,
630                     width: 500,
631                     buttons: button_options,
632                     close: function () {
633                         $(this).remove();
634                     }
635                 });
636                 PMA_ajaxRemoveMessage($msgbox);
637                 // Attach syntax highlighted editor to export dialog
638                 if (typeof CodeMirror != 'undefined') {
639                     CodeMirror.fromTextArea(
640                         $ajaxDialog.find('textarea')[0],
641                         {
642                             lineNumbers: true,
643                             matchBrackets: true,
644                             indentUnit: 4,
645                             mode: "text/x-mysql",
646                             lineWrapping: true
647                         }
648                     );
649                 }
650             } else {
651                 PMA_ajaxShowMessage(data.error, false);
652             }
653         }); //end $.get
654     }); //end export privileges
656     /**
657      * AJAX handler to Paginate the Users Table
658      *
659      * @see         PMA_ajaxShowMessage()
660      * @name        paginate_users_table_click
661      * @memberOf    jQuery
662      */
663     $("#initials_table").find("a.ajax").live('click', function (event) {
664         event.preventDefault();
665         var $msgbox = PMA_ajaxShowMessage();
666         $.get($(this).attr('href'), {'ajax_request' : true}, function (data) {
667             if (data.success === true) {
668                 PMA_ajaxRemoveMessage($msgbox);
669                 // This form is not on screen when first entering Privileges
670                 // if there are more than 50 users
671                 $("div.notice").remove();
672                 $("#usersForm").hide("medium").remove();
673                 $("#fieldset_add_user").hide("medium").remove();
674                 $("#initials_table")
675                     .prop("id", "initials_table_old")
676                     .after(data.message).show("medium")
677                     .siblings("h2").not(":first").remove();
678                 // prevent double initials table
679                 $("#initials_table_old").remove();
680             } else {
681                 PMA_ajaxShowMessage(data.error, false);
682             }
683         }); // end $.get
684     }); // end of the paginate users table
686     displayPasswordGenerateButton();
688     /*
689      * Create submenu for simpler interface
690      */
691     var addOrUpdateSubmenu = function () {
692         var $topmenu2 = $("#topmenu2"),
693             $edit_user_dialog = $("#edit_user_dialog"),
694             submenu_label,
695             submenu_link,
696             link_number;
698         // if submenu exists yet, remove it first
699         if ($topmenu2.length > 0) {
700             $topmenu2.remove();
701         }
703         // construct a submenu from the existing fieldsets
704         $topmenu2 = $("<ul/>").prop("id", "topmenu2");
706         $("#edit_user_dialog .submenu-item").each(function () {
707             submenu_label = $(this).find("legend[data-submenu-label]").data("submenu-label");
709             submenu_link = $("<a/>")
710             .prop("href", "#")
711             .html(submenu_label);
713             $("<li/>")
714             .append(submenu_link)
715             .appendTo($topmenu2);
716         });
718         // click handlers for submenu
719         $topmenu2.find("a").click(function (e) {
720             e.preventDefault();
721             // if already active, ignore click
722             if ($(this).hasClass("tabactive")) {
723                 return;
724             }
725             $topmenu2.find("a").removeClass("tabactive");
726             $(this).addClass("tabactive");
728             // which section to show now?
729             link_number = $topmenu2.find("a").index($(this));
730             // hide all sections but the one to show
731             $("#edit_user_dialog .submenu-item").hide().eq(link_number).show();
732         });
734         // make first menu item active
735         // TODO: support URL hash history
736         $topmenu2.find("> :first-child a").addClass("tabactive");
737         $edit_user_dialog.prepend($topmenu2);
739         // hide all sections but the first
740         $("#edit_user_dialog .submenu-item").hide().eq(0).show();
741     };