[Phpmyadmin-git] [SCM] phpMyAdmin branch, master, updated. RELEASE_3_4_0RC1-1032-g57e3aba

Marc Delisle lem9 at users.sourceforge.net
Wed Apr 20 12:32:12 CEST 2011


The branch, master has been updated
       via  57e3aba8ffdfc8caa0ad8db36ac99556b3a67f9a (commit)
      from  90d15973449ba1a5c400e7957ffe7072def71fcc (commit)


- Log -----------------------------------------------------------------
commit 57e3aba8ffdfc8caa0ad8db36ac99556b3a67f9a
Author: Marc Delisle <marc at infomarc.info>
Date:   Wed Apr 20 06:32:00 2011 -0400

    Bug #3168733 Synchronization does not honor AllowArbitraryServer

-----------------------------------------------------------------------

Summary of changes:
 Documentation.html       |    2 +-
 js/server_synchronize.js |   52 ++++++++++++++++++++++++++++++----------------
 server_synchronize.php   |   38 ++++++++++++++++++++++++--------
 3 files changed, 63 insertions(+), 29 deletions(-)

diff --git a/Documentation.html b/Documentation.html
index 887b8a0..b928cb7 100644
--- a/Documentation.html
+++ b/Documentation.html
@@ -1421,7 +1421,7 @@ CREATE DATABASE,ALTER DATABASE,DROP DATABASE</pre>
         comments. Defaults to <tt>TRUE</tt>.</dd>
     <dt id="AllowArbitraryServer">
         <span id="cfg_AllowArbitraryServer">$cfg['AllowArbitraryServer']</span> boolean</dt>
-    <dd>If enabled allows you to log in to arbitrary servers using cookie auth.
+    <dd>If enabled, allows you to log in to arbitrary servers using cookie auth and permits to specify servers of your choice in the Synchronize dialog.
         <br /><br />
 
         <b>NOTE:</b> Please use this carefully, as this may allow users access to
diff --git a/js/server_synchronize.js b/js/server_synchronize.js
index 4857530..e1645ae 100644
--- a/js/server_synchronize.js
+++ b/js/server_synchronize.js
@@ -301,26 +301,42 @@ function validateConnectionParams()
     return form_is_ok;
 }
 
+/**
+ * Handles the dynamic display of form fields related to a server selector
+ */
+
+function hideOrDisplayServerFields($server_selector, selected_option)
+{
+    $tbody = $server_selector.closest('tbody');
+    if (selected_option == 'cur') {
+        $tbody.children('.current-server').css('display', '');
+        $tbody.children('.remote-server').css('display', 'none');
+    } else if (selected_option == 'rmt') {
+        $tbody.children('.current-server').css('display', 'none');
+        $tbody.children('.remote-server').css('display', '');
+    } else {
+        $tbody.children('.current-server').css('display', 'none');
+        $tbody.children('.remote-server').css('display', '');
+        var parts = selected_option.split('||||');
+        $tbody.find('.server-host').val(parts[0]);
+        $tbody.find('.server-port').val(parts[1]);
+        $tbody.find('.server-socket').val(parts[2]);
+        $tbody.find('.server-user').val(parts[3]);
+        $tbody.find('.server-pass').val('');
+        $tbody.find('.server-db').val(parts[4])
+    }
+}
+
 $(document).ready(function() {
     $('.server_selector').change(function(evt) {
-        var server = $(evt.target).val();
-        if (server == 'cur') {
-            $(this).closest('tbody').children('.current-server').css('display', '');
-            $(this).closest('tbody').children('.remote-server').css('display', 'none');
-        } else if (server == 'rmt') {
-            $(this).closest('tbody').children('.current-server').css('display', 'none');
-            $(this).closest('tbody').children('.remote-server').css('display', '');
-        } else {
-            $(this).closest('tbody').children('.current-server').css('display', 'none');
-            $(this).closest('tbody').children('.remote-server').css('display', '');
-            var parts = server.split('||||');
-            $(this).closest('tbody').find('.server-host').val(parts[0]);
-            $(this).closest('tbody').find('.server-port').val(parts[1]);
-            $(this).closest('tbody').find('.server-socket').val(parts[2]);
-            $(this).closest('tbody').find('.server-user').val(parts[3]);
-            $(this).closest('tbody').find('.server-pass').val('');
-            $(this).closest('tbody').find('.server-db').val(parts[4])
-        }
+        var selected_option = $(evt.target).val();
+        hideOrDisplayServerFields($(evt.target), selected_option);
+    });
+
+    // initial display of the selectors
+    $('.server_selector').each(function() {
+        var selected_option = $(this).val();
+        hideOrDisplayServerFields($(this), selected_option);
     });
 
     $('.struct_img').hover( 
diff --git a/server_synchronize.php b/server_synchronize.php
index 4fc0ac9..bb08fd6 100644
--- a/server_synchronize.php
+++ b/server_synchronize.php
@@ -1104,21 +1104,39 @@ if (isset($_REQUEST['synchronize_db'])) {
     $databases = PMA_DBI_get_databases_full(null, false, null, 'SCHEMA_NAME',
         'ASC', 0, true);
 
+    if ($GLOBALS['cfg']['AllowArbitraryServer'] === false) {
+        $possibly_disabled = ' disabled="disabled"';
+    } else {
+        $possibly_disabled = '';
+    }
+
     foreach ($cons as $type) {
         if ('src' == $type) {
             $database_header = __('Source database');
         } else {
             $database_header = __('Target database');
         }
+
+        $database_header .= PMA_showHint(PMA_sanitize(sprintf('%sAllowArbitraryServer%s', '[a at ./Documentation.html#AllowArbitraryServer at _blank]', '[/a]')));
 ?>
       <table id="serverconnection_<?php echo $type; ?>_remote" class="data">
       <caption class="tblHeaders"><?php echo $database_header; ?></caption>
       <tr class="odd">
 	  <td colspan="2" style="text-align: center">
 	     <select name="<?php echo $type; ?>_type" id="<?php echo $type; ?>_type" class="server_selector">
-	      <option value="rmt"><?php echo __('Enter manually'); ?></option>
-	      <option value="cur"><?php echo __('Current connection'); ?></option>
 <?php
+        if ($GLOBALS['cfg']['AllowArbitraryServer']) {
+            $preselected_option = 'rmt';
+            echo '<option value="rmt" selected="selected">' . __('Enter manually') . '</option>';
+        } else {
+            $preselected_option = 'cur';
+        }
+        echo '<option value="cur"';
+        if ('cur' == $preselected_option) {
+            echo ' selected="selected"';
+        }
+        echo '>' .  __('Current connection') . '</option>';
+
         foreach ($GLOBALS['cfg']['Servers'] as $key => $tmp_server) {
             if (empty($tmp_server['host'])) {
                 continue;
@@ -1145,8 +1163,8 @@ if (isset($_REQUEST['synchronize_db'])) {
             $value .= $tmp_server['user'];
             $value .= '||||';
             $value .= $tmp_server['only_db'];
-            echo '<option value="' . $value . '">'
-                . htmlspecialchars(sprintf(__('Configuration: %s'), $label)) . '</option>' . "\n";
+            echo '<option value="' . $value . '" >'
+                . htmlspecialchars(sprintf(__('Configuration: %s'), $label)) . '</option>';
         } // end foreach
 ?>
 	     </select>
@@ -1154,27 +1172,27 @@ if (isset($_REQUEST['synchronize_db'])) {
       </tr>
 	<tr class="even toggler remote-server">
 	    <td><?php echo __('Server'); ?></td>
-	    <td><input type="text" name="<?php echo $type; ?>_host" class="server-host" /></td>
+        <td><input type="text" name="<?php echo $type; ?>_host" class="server-host" <?php echo $possibly_disabled; ?>/></td>
 	</tr>
 	<tr class="odd toggler remote-server">
 	    <td><?php echo __('Port'); ?></td>
-	    <td><input type="text" name="<?php echo $type; ?>_port" class="server-port" value="3306" maxlength="5" size="5" /></td>
+        <td><input type="text" name="<?php echo $type; ?>_port" class="server-port" <?php echo $possibly_disabled; ?> value="3306" maxlength="5" size="5" /></td>
 	</tr>
 	<tr class="even toggler remote-server">
 	    <td><?php echo __('Socket'); ?></td>
-	    <td><input type="text" name="<?php echo $type; ?>_socket" class="server-socket" /></td>
+        <td><input type="text" name="<?php echo $type; ?>_socket" class="server-socket" <?php echo $possibly_disabled; ?>/></td>
 	</tr>
 	<tr class="odd toggler remote-server">
 	    <td><?php echo __('User name'); ?></td>
-	    <td><input type="text" name="<?php echo $type; ?>_username" class="server-user" /></td>
+        <td><input type="text" name="<?php echo $type; ?>_username" class="server-user" <?php echo $possibly_disabled; ?>/></td>
 	</tr>
 	<tr class="even toggler remote-server">
 	    <td><?php echo __('Password'); ?></td>
-	    <td><input type="password" name="<?php echo $type; ?>_pass" class="server-pass" /> </td>
+        <td><input type="password" name="<?php echo $type; ?>_pass" class="server-pass" <?php echo $possibly_disabled; ?>/> </td>
 	</tr>
 	<tr class="odd toggler remote-server">
 	    <td><?php echo __('Database'); ?></td>
-	    <td><input type="text" name="<?php echo $type; ?>_db" class="server-db" /></td>
+        <td><input type="text" name="<?php echo $type; ?>_db" class="server-db" <?php echo $possibly_disabled; ?>/></td>
 	</tr>
 	<tr class="even toggler current-server" style="display: none;">
 	    <td><?php echo __('Database'); ?></td>


hooks/post-receive
-- 
phpMyAdmin




More information about the Git mailing list