text: function checkAddUser(a){if(a.elements.pred_hostname.value=="userdefined"&&a.elements.hostname.value==""){alert(PMA_messages.strHostEmpty);a.elements.hostname.focus();return false}if(a.elements.pred_username.value=="userdefined"&&a.elements.username.value==""){alert(PMA_messages.strUserEmpty);a.elements.username.focus();return false}return PMA_checkPassword($(a))}function appendNewUser(j,e,l){var b=$("#usersForm").find("tbody").find("tr:last");var h=$("#usersForm").find("tbody").find("tr:first");var f=h.find("label").html().substr(0,1).toUpperCase();var c=b.find("label").html().substr(0,1).toUpperCase();var g=b.find("input:checkbox").attr("id").match(/\d+/)[0];var a=parseFloat(g);var i=a+1;var k="checkbox_sel_users_"+i;var d=(f!=c)?true:false;if((c==e)||d){$(j).insertAfter(b).find("input:checkbox").attr("id",k).val(function(){return $(this).val().replace(/&/,"&amp;")}).end().find("label").attr("for",k).end()}$("#usersForm").find("tbody").PMA_sort_table("label");$("#initials_table").find("td:contains("+e+")").html(l);$(checkboxes_sel).trigger("change")}function addUser(a){if(!checkAddUser(a.get(0))){return false}$.post(a.attr("action"),a.serialize()+"&adduser_submit="+$("input[name=adduser_submit]").val(),function(d){if(d.success==true){if($("#add_user_dialog #createdb-1:checked").length){PMA_reloadNavigation()}$("#page_content").show();$("#add_user_dialog").remove();PMA_ajaxShowMessage(d.message);$("#result_query").remove();$("#page_content").prepend(d.sql_query);$("#result_query").css({"margin-top":"0.5em"});var c=$("#result_query").find(".notice");if(c.text()==""){c.remove()}if($("#fieldset_add_user a.ajax").attr("name")=="db_specific"){var b=$("#fieldset_add_user a.ajax").attr("rel");if(b.substring(b.length-23,b.length)=="&goto=db_operations.php"){b=b.substring(0,b.length-23)}b=b+"&ajax_request=true&db_specific=true";$.post(a.attr("action"),b,function(e){if($("#userFormDiv").length!=0){$("#userFormDiv").remove()}else{$("#usersForm").remove()}if(e.success==true){$('<div id="userFormDiv"></div>').html(e.user_form).insertAfter("#result_query")}else{PMA_ajaxShowMessage(PMA_messages.strErrorProcessingRequest+" : "+e.error,false)}})}else{appendNewUser(d.new_user_string,d.new_user_initial,d.new_user_initial_string)}}else{PMA_ajaxShowMessage(d.error,false)}})}AJAX.registerTeardown("server_privileges.js",function(){$("#fieldset_add_user a.ajax").die("click");$("form[name=usersForm]").unbind("submit");$("#reload_privileges_anchor.ajax").die("click");$("#fieldset_delete_user_footer #buttonGo.ajax").die("click");$("a.edit_user_anchor.ajax").die("click");$("#edit_user_dialog").find("form.ajax").die("submit");$("button.mult_submit[value=export]").die("click");$("a.export_user_anchor.ajax").die("click");$("#initials_table").find("a.ajax").die("click");$("#checkbox_drop_users_db").unbind("click")});AJAX.registerOnload("server_privileges.js",function(){$("#fieldset_add_user a.ajax").live("click",function(a){a.preventDefault();var b=PMA_ajaxShowMessage();$.get($(this).attr("href"),{ajax_request:true},function(d){if(d.success==true){$("#page_content").hide();var c=$("#add_user_dialog");if(c.length==0){c=$('<div id="add_user_dialog" style="margin: 0.5em;"></div>').insertBefore("#page_content")}else{c.empty()}c.html(d.message).find("form[name=usersForm]").append('<input type="hidden" name="ajax_request" value="true" />').end();displayPasswordGenerateButton();PMA_showHints(c);PMA_ajaxRemoveMessage(b);c.find("input.autofocus").focus();c.find("form[name=usersForm]").bind("submit",function(e){e.preventDefault();addUser($(this))})}else{PMA_ajaxShowMessage(d.error,false)}})});$("#reload_privileges_anchor.ajax").live("click",function(a){a.preventDefault();var b=PMA_ajaxShowMessage(PMA_messages.strReloadingPrivileges);$.get($(this).attr("href"),{ajax_request:true},function(c){if(c.success==true){PMA_ajaxRemoveMessage(b)}else{PMA_ajaxShowMessage(c.error,false)}})});$("#fieldset_delete_user_footer #buttonGo.ajax").live("click",function(b){b.preventDefault();PMA_ajaxShowMessage(PMA_messages.strRemovingSelectedUsers);var a=$("#usersForm");$.post(a.attr("action"),a.serialize()+"&delete="+$(this).val()+"&ajax_request=true",function(c){if(c.success==true){PMA_ajaxShowMessage(c.message);if($("#checkbox_drop_users_db:checked").length){PMA_reloadNavigation()}a.find("input:checkbox:checked").parents("tr").slideUp("medium",function(){var d=$(this).find("input:checkbox").val().charAt(0).toUpperCase();$(this).remove();if($("#tableuserrights").find("input:checkbox[value^="+d+"]").length==0){$("#initials_table").find("td > a:contains("+d+")").parent("td").html(d)}a.find("tbody").find("tr:odd").removeClass("even").addClass("odd").end().find("tr:even").removeClass("odd").addClass("even");$(checkboxes_sel).trigger("change")})}else{PMA_ajaxShowMessage(c.error,false)}})});$("a.edit_user_anchor.ajax").live("click",function(b){b.preventDefault();var c=PMA_ajaxShowMessage();$(this).parents("tr").addClass("current_row");var a=$(this).parents("form").find('input[name="token"]').val();$.get($(this).attr("href"),{ajax_request:true,edit_user_dialog:true,token:a},function(e){if(e.success==true){$("#page_content").hide();var d=$("#edit_user_dialog");if(d.length==0){d=$('<div id="edit_user_dialog" style="margin: 0.5em;"></div>').insertBefore("#page_content")}else{d.empty()}d.html(e.message);displayPasswordGenerateButton();PMA_ajaxRemoveMessage(c);PMA_showHints(d)}else{PMA_ajaxShowMessage(e.error,false)}})});$("#edit_user_dialog").find("form.ajax").live("submit",function(d){d.preventDefault();var g=$(this);if(g.is(".copyUserForm")&&!PMA_checkPassword(g)){return false}PMA_ajaxShowMessage(PMA_messages.strProcessingRequest);g.append('<input type="hidden" name="ajax_request" value="true" />');var c=g.find(".tblFooters").find("input:submit").attr("name");var f=g.find(".tblFooters").find("input:submit").val();var b;if(c=="change_copy"&&$("input[name=mode]:checked","#fieldset_mode").val()!="4"){var e=g.find('input[name="old_username"]').val();var a=g.find('input[name="old_hostname"]').val();$("#usersForm tbody tr").each(function(){var h=$(this);if(h.find("td:nth-child(2) label").text()==e&&h.find("td:nth-child(3)").text()==a){b=h;return false}})}$.post(g.attr("action"),g.serialize()+"&"+c+"="+f,function(k){if(k.success==true){$("#page_content").show();$("#edit_user_dialog").remove();PMA_ajaxShowMessage(k.message);if(k.sql_query){$("#result_query").remove();$("#page_content").prepend(k.sql_query);$("#result_query").css({"margin-top":"0.5em"});var j=$("#result_query").find(".notice");if(j.text()==""){j.remove()}}if(b!=null){b.remove()}if(k.new_user_string){appendNewUser(k.new_user_string,k.new_user_initial,k.new_user_initial_string)}var i=!!($("#dbspecificuserrights").length);var h=false;if(k.db_specific_privs==false||(i==k.db_specific_privs)){h=true}if(k.db_wildcard_privs){h=false}if(k.new_privileges&&h){$("#usersForm").find(".current_row").find("code").html(k.new_privileges)}$("#usersForm").find(".current_row").removeClass("current_row")}else{PMA_ajaxShowMessage(k.error,false)}})});$("button.mult_submit[value=export]").live("click",function(b){b.preventDefault();if($(this.form).find("input:checked").length==0){return}var c=PMA_ajaxShowMessage();var a={};a[PMA_messages.strClose]=function(){$(this).dialog("close")};$.post($(this.form).prop("action"),$(this.form).serialize()+"&submit_mult=export&ajax_request=true",function(e){if(e.success==true){var d=$("<div />").append(e.message).dialog({title:e.title,width:500,buttons:a,close:function(){$(this).remove()}});PMA_ajaxRemoveMessage(c);if(typeof CodeMirror!="undefined"){CodeMirror.fromTextArea(d.find("textarea")[0],{lineNumbers:true,matchBrackets:true,indentUnit:4,mode:"text/x-mysql"})}}else{PMA_ajaxShowMessage(e.error,false)}})});if($("textarea.export").length>0&&typeof CodeMirror!="undefined"){CodeMirror.fromTextArea($("textarea.export")[0],{lineNumbers:true,matchBrackets:true,indentUnit:4,mode:"text/x-mysql"})}$("a.export_user_anchor.ajax").live("click",function(b){b.preventDefault();var c=PMA_ajaxShowMessage();var a={};a[PMA_messages.strClose]=function(){$(this).dialog("close")};$.get($(this).attr("href"),{ajax_request:true},function(e){if(e.success==true){var d=$("<div />").append(e.message).dialog({title:e.title,width:500,buttons:a,close:function(){$(this).remove()}});PMA_ajaxRemoveMessage(c);if(typeof CodeMirror!="undefined"){CodeMirror.fromTextArea(d.find("textarea")[0],{lineNumbers:true,matchBrackets:true,indentUnit:4,mode:"text/x-mysql"})}}else{PMA_ajaxShowMessage(e.error,false)}})});$("#initials_table").find("a.ajax").live("click",function(a){a.preventDefault();var b=PMA_ajaxShowMessage();$.get($(this).attr("href"),{ajax_request:true},function(c){if(c.success==true){PMA_ajaxRemoveMessage(b);$("div.notice").remove();$("#usersForm").hide("medium").remove();$("#fieldset_add_user").hide("medium").remove();$("#initials_table").after(c.message).show("medium").siblings("h2").not(":first").remove()}else{PMA_ajaxShowMessage(c.error,false)}})});$("#checkbox_drop_users_db").click(function(){var b=$(this);if(b.is(":checked")){var a=confirm(PMA_messages.strDropDatabaseStrongWarning+"\n"+$.sprintf(PMA_messages.strDoYouReally,"DROP DATABASE"));if(!a){b.prop("checked",false)}}});displayPasswordGenerateButton()});