diff --git a/ChangeLog b/ChangeLog index 5c3296a906..a79e19f98a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -24,6 +24,7 @@ phpMyAdmin - ChangeLog + rfe #175 Allow cross-database relations - [core] Dropped support for PHP 5.2. + rfe #487 and rfe #1405 Find and Replacing column wise ++ rfe #1373 Use same create view dialog for editing a view 4.0.5.0 (not yet released) - bug #3977 Not detected configuration storage diff --git a/js/functions.js b/js/functions.js index 7c1b840871..ac5339ec8a 100644 --- a/js/functions.js +++ b/js/functions.js @@ -3675,7 +3675,7 @@ function printPage() */ AJAX.registerTeardown('functions.js', function () { $('input#print').unbind('click'); - $('span a.create_view.ajax').die('click'); + $('a.create_view.ajax').die('click'); $('#createViewDialog').find('input, select').die('keydown'); }); @@ -3684,7 +3684,7 @@ AJAX.registerOnload('functions.js', function () { /** * Ajaxification for the "Create View" action */ - $('span a.create_view.ajax').live('click', function (e) { + $('a.create_view.ajax').live('click', function (e) { e.preventDefault(); PMA_createViewDialog($(this)); }); @@ -3698,13 +3698,29 @@ AJAX.registerOnload('functions.js', function () { $(this).closest('.ui-dialog').find('.ui-button:first').click(); } }); // end $.live() + + var $elm = $('textarea[name="view[as]"]'); + if ($elm.length > 0) { + if (typeof CodeMirror != 'undefined') { + syntaxHighlighter = CodeMirror.fromTextArea( + $elm[0], + { + lineNumbers: true, + matchBrackets: true, + indentUnit: 4, + mode: "text/x-mysql", + lineWrapping: true + } + ); + } + } }); function PMA_createViewDialog($this) { var $msg = PMA_ajaxShowMessage(); var syntaxHighlighter = null; - $.get($this.attr('href') + '&ajax_request=1', function (data) { + $.get($this.attr('href') + '&ajax_request=1&ajax_dialog=1', function (data) { if (data.success === true) { PMA_ajaxRemoveMessage($msg); var buttonOptions = {}; @@ -3728,21 +3744,19 @@ function PMA_createViewDialog($this) $(this).dialog("close"); }; var $dialog = $('
').attr('id', 'createViewDialog').append(data.message).dialog({ - width: 500, - minWidth: 300, - maxWidth: 620, + width: 600, + minWidth: 400, modal: true, buttons: buttonOptions, - title: $('legend', $(data.message)).html(), + title: PMA_messages.strCreateView, close: function () { $(this).remove(); } }); - $dialog.find('legend').remove(); // Attach syntax highlited editor if (typeof CodeMirror !== 'undefined') { var $elm = $dialog.find('textarea'); - var opts = {lineNumbers: true, matchBrackets: true, indentUnit: 4, mode: "text/x-mysql"}; + var opts = {lineNumbers: true, matchBrackets: true, indentUnit: 4, mode: "text/x-mysql", lineWrapping: true}; syntaxHighlighter = CodeMirror.fromTextArea($elm[0], opts); } $('input:visible[type=text]', $dialog).first().focus(); diff --git a/js/messages.php b/js/messages.php index 447dd9b25b..7f0f0cc7d6 100644 --- a/js/messages.php +++ b/js/messages.php @@ -376,6 +376,7 @@ $js_messages['strNewerVersion'] = __('A newer version of phpMyAdmin is available $js_messages['strLatestAvailable'] = __(', latest stable version:'); $js_messages['strUpToDate'] = __('up to date'); +$js_messages['strCreateView'] = __('Create view'); echo "var PMA_messages = new Array();\n"; foreach ($js_messages as $name => $js_message) { diff --git a/libraries/DatabaseInterface.class.php b/libraries/DatabaseInterface.class.php index 4d32d45666..5f7d91e611 100644 --- a/libraries/DatabaseInterface.class.php +++ b/libraries/DatabaseInterface.class.php @@ -1438,7 +1438,7 @@ class PMA_DatabaseInterface /** * Function called just after a connection to the MySQL database server has - * been established. It sets the connection collation, and determins the + * been established. It sets the connection collation, and determines the * version of MySQL which is running. * * @param mixed $link mysql link resource|object diff --git a/libraries/TableSearch.class.php b/libraries/TableSearch.class.php index 57d46d7d59..d3c367fd6b 100644 --- a/libraries/TableSearch.class.php +++ b/libraries/TableSearch.class.php @@ -192,11 +192,11 @@ class PMA_TableSearch } /** - * Returns an array with necessary configrations to create - * sub-tabs(Table Search and Zoom Search) in the table_select page. + * Returns an array with necessary configurations to create + * sub-tabs in the table_select page. * * @return array Array containing configuration (icon, text, link, id, args) - * of sub-tabs for Table Search and Zoom search + * of sub-tabs */ private function _getSubTabs() { diff --git a/libraries/dbi/DBIDummy.class.php b/libraries/dbi/DBIDummy.class.php index 1361629e23..163f885fe1 100644 --- a/libraries/dbi/DBIDummy.class.php +++ b/libraries/dbi/DBIDummy.class.php @@ -301,6 +301,61 @@ $GLOBALS['dummy_queries'] = array( " AND table_name = 'pma_test_table2'" . " ORDER BY version DESC", 'result' => array() + ), + array( + 'query' => "SHOW SLAVE STATUS", + 'result' => array( + array( + 'Slave_IO_State' => 'running', + 'Master_Host' => 'locahost', + 'Master_User' => 'Master_User', + 'Master_Port' => '1002', + 'Connect_Retry' => 'Connect_Retry', + 'Master_Log_File' => 'Master_Log_File', + 'Read_Master_Log_Pos' => 'Read_Master_Log_Pos', + 'Relay_Log_File' => 'Relay_Log_File', + 'Relay_Log_Pos' => 'Relay_Log_Pos', + 'Relay_Master_Log_File' => 'Relay_Master_Log_File', + 'Slave_IO_Running' => 'NO', + 'Slave_SQL_Running' => 'NO', + 'Replicate_Do_DB' => 'Replicate_Do_DB', + 'Replicate_Ignore_DB' => 'Replicate_Ignore_DB', + 'Replicate_Do_Table' => 'Replicate_Do_Table', + 'Replicate_Ignore_Table' => 'Replicate_Ignore_Table', + 'Replicate_Wild_Do_Table' => 'Replicate_Wild_Do_Table', + 'Replicate_Wild_Ignore_Table' => 'Replicate_Wild_Ignore_Table', + 'Last_Errno' => 'Last_Errno', + 'Last_Error' => 'Last_Error', + 'Skip_Counter' => 'Skip_Counter', + 'Exec_Master_Log_Pos' => 'Exec_Master_Log_Pos', + 'Relay_Log_Space' => 'Relay_Log_Space', + 'Until_Condition' => 'Until_Condition', + 'Until_Log_File' => 'Until_Log_File', + 'Until_Log_Pos' => 'Until_Log_Pos', + 'Master_SSL_Allowed' => 'Master_SSL_Allowed', + 'Master_SSL_CA_File' => 'Master_SSL_CA_File', + 'Master_SSL_CA_Path' => 'Master_SSL_CA_Path', + 'Master_SSL_Cert' => 'Master_SSL_Cert', + 'Master_SSL_Cipher' => 'Master_SSL_Cipher', + 'Master_SSL_Key' => 'Master_SSL_Key', + 'Seconds_Behind_Master' => 'Seconds_Behind_Master', + ) + ) + ), + array( + 'query' => "SHOW MASTER STATUS", + 'result' => array( + array( + "File" => "master-bin.000030", + "Position" => "107", + "Binlog_Do_DB" => "Binlog_Do_DB", + "Binlog_Ignore_DB" => "Binlog_Ignore_DB", + ) + ) + ), + array( + 'query' => "SHOW GRANTS", + 'result' => array() ) ); /** diff --git a/libraries/sqlparser.data.php b/libraries/sqlparser.data.php index fab1177d88..f511faa757 100644 --- a/libraries/sqlparser.data.php +++ b/libraries/sqlparser.data.php @@ -396,6 +396,7 @@ $PMA_SQPdata_reserved_word = array ( 'BINLOG', 'BOTH', 'BY', + 'CALL', 'CASCADE', 'CASE', 'CHANGE', diff --git a/libraries/structure.lib.php b/libraries/structure.lib.php index 6709f3d4c6..e25e36b3af 100644 --- a/libraries/structure.lib.php +++ b/libraries/structure.lib.php @@ -1445,18 +1445,34 @@ function PMA_getHtmlDivForMoveColumnsDialog() */ function PMA_getHtmlForEditView($url_params) { - $create_view = $GLOBALS['dbi']->getDefinition( - $GLOBALS['db'], 'VIEW', $GLOBALS['table'] + $retval = array(); + $query = "SELECT `VIEW_DEFINITION`, `CHECK_OPTION`, `DEFINER`, `SECURITY_TYPE`" + . " FROM `INFORMATION_SCHEMA`.`VIEWS`" + . " WHERE TABLE_SCHEMA='" . PMA_Util::sqlAddSlashes($GLOBALS['db']) . "'" + . " AND TABLE_NAME='" . PMA_Util::sqlAddSlashes($GLOBALS['table']) . "';"; + $item = $GLOBALS['dbi']->fetchSingleRow($query); + + $view = array( + 'operation' => 'alter', + 'definer' => $item['DEFINER'], + 'sql_security' => $item['SECURITY_TYPE'], + 'name' => $GLOBALS['table'], + 'as' => $item['VIEW_DEFINITION'], + 'with' => $item['CHECK_OPTION'], + ); + $url = 'view_create.php' . PMA_generate_common_url($url_params) . '&'; + $url .= implode( + '&', + array_map( + function($key, $val) { + return 'view[' . urlencode($key) . ']=' . urlencode($val); + }, + array_keys($view), + $view + ) ); - $create_view = preg_replace('@^CREATE@', 'ALTER', $create_view); $html_output = PMA_Util::linkOrButton( - 'tbl_sql.php' . PMA_generate_common_url( - $url_params + - array( - 'sql_query' => $create_view, - 'show_query' => '1', - ) - ), + $url, PMA_Util::getIcon('b_edit.png', __('Edit view'), true) ); return $html_output; diff --git a/po/es.po b/po/es.po index 6e6bd19a08..85a1e6c804 100644 --- a/po/es.po +++ b/po/es.po @@ -4,10 +4,10 @@ msgstr "" "Project-Id-Version: phpMyAdmin 4.1-dev\n" "Report-Msgid-Bugs-To: phpmyadmin-devel@lists.sourceforge.net\n" "POT-Creation-Date: 2013-07-12 16:06+0200\n" -"PO-Revision-Date: 2013-07-09 15:28+0200\n" +"PO-Revision-Date: 2013-07-12 21:25+0200\n" "Last-Translator: Matías Bellone \n" -"Language-Team: Spanish \n" +"Language-Team: Spanish " +"\n" "Language: es\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -1679,7 +1679,7 @@ msgstr "Agregar %d valor(es)" msgid "" "Note: If the file contains multiple tables, they will be combined into one." msgstr "" -"Nota: si la fila contiene múltiples tablas, van a ser combinadas en una" +"Nota: si la fila contiene múltiples tablas, van a ser combinadas en una." #: js/messages.php:262 msgid "Hide query box" @@ -2862,7 +2862,7 @@ msgstr "La clave primaria ha sido eliminada" #: libraries/Index.class.php:608 #, php-format msgid "Index %s has been dropped." -msgstr "El índice %s ha sido eliminado" +msgstr "El índice %s ha sido eliminado." #: libraries/Index.class.php:731 #, php-format @@ -3848,7 +3848,7 @@ msgstr "" #: libraries/sql_query_form.lib.php:483 msgid "The directory you set for upload work cannot be reached." msgstr "" -"No se puede acceder al directorio que seleccionó para subir los archivos" +"No se puede acceder al directorio que seleccionó para subir los archivos." #: libraries/Util.class.php:3452 msgid "There are no files to upload" @@ -8054,7 +8054,8 @@ msgstr "" #, php-format msgid "No activity within %s seconds; please log in again." msgstr "" -"No ha habido actividad desde hace %s o más segundos; inicie sesión nuevamente" +"No ha habido actividad desde hace %s o más segundos; inicie sesión " +"nuevamente." #: libraries/plugins/auth/AuthenticationCookie.class.php:667 #: libraries/plugins/auth/AuthenticationCookie.class.php:669 @@ -8079,7 +8080,7 @@ msgstr "El archivo %s no contiene ningún id de clave" #: libraries/plugins/auth/swekey/swekey.auth.lib.php:176 #: libraries/plugins/auth/swekey/swekey.auth.lib.php:196 msgid "Hardware authentication failed!" -msgstr "La autenticación de hardware fracasó" +msgstr "¡Fracasó la autenticación de hardware!" #: libraries/plugins/auth/swekey/swekey.auth.lib.php:183 msgid "No valid authentication key plugged" @@ -11316,7 +11317,7 @@ msgid "" msgstr "" "Parece haber un error en su consulta de SQL. La salida generada por el " "servidor de MySQL, de existir, aparece abajo, en cuyo caso puede ayudar a " -"diagnosticar el problema" +"diagnosticar el problema." #: libraries/sqlparser.lib.php:178 msgid "" diff --git a/po/fr.po b/po/fr.po index 3ad709085a..dbe0e88bde 100644 --- a/po/fr.po +++ b/po/fr.po @@ -4,10 +4,9 @@ msgstr "" "Project-Id-Version: phpMyAdmin-docs 4.0.0-dev\n" "Report-Msgid-Bugs-To: phpmyadmin-devel@lists.sourceforge.net\n" "POT-Creation-Date: 2013-07-12 16:06+0200\n" -"PO-Revision-Date: 2013-07-12 15:29+0200\n" +"PO-Revision-Date: 2013-07-14 01:43+0200\n" "Last-Translator: Marc Delisle \n" -"Language-Team: French \n" +"Language-Team: French \n" "Language: fr\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -1668,7 +1667,7 @@ msgstr "Ajouter %d valeur(s)" #: js/messages.php:259 msgid "" "Note: If the file contains multiple tables, they will be combined into one." -msgstr "Note : si le fichier contient plusieurs tables, elles seront combinées" +msgstr "Note : si le fichier contient plusieurs tables, elles seront combinées." #: js/messages.php:262 msgid "Hide query box" @@ -2848,7 +2847,7 @@ msgstr "La clé primaire a été effacée" #: libraries/Index.class.php:608 #, php-format msgid "Index %s has been dropped." -msgstr "L'index %s a été effacé" +msgstr "L'index %s a été effacé." #: libraries/Index.class.php:731 #, php-format @@ -3829,7 +3828,7 @@ msgstr "" #: libraries/Util.class.php:3441 libraries/insert_edit.lib.php:1183 #: libraries/sql_query_form.lib.php:483 msgid "The directory you set for upload work cannot be reached." -msgstr "Le répertoire de transfert est inaccessible" +msgstr "Le répertoire de transfert est inaccessible." #: libraries/Util.class.php:3452 msgid "There are no files to upload" @@ -8015,7 +8014,7 @@ msgstr "Le fichier %s ne contient pas d'identifiant de clé" #: libraries/plugins/auth/swekey/swekey.auth.lib.php:176 #: libraries/plugins/auth/swekey/swekey.auth.lib.php:196 msgid "Hardware authentication failed!" -msgstr "L'authentification matérielle a échoué" +msgstr "L'authentification matérielle a échoué !" #: libraries/plugins/auth/swekey/swekey.auth.lib.php:183 msgid "No valid authentication key plugged" diff --git a/po/tr.po b/po/tr.po index 7864369068..8d9c544962 100644 --- a/po/tr.po +++ b/po/tr.po @@ -4,10 +4,10 @@ msgstr "" "Project-Id-Version: phpMyAdmin 4.1-dev\n" "Report-Msgid-Bugs-To: phpmyadmin-devel@lists.sourceforge.net\n" "POT-Creation-Date: 2013-07-12 16:06+0200\n" -"PO-Revision-Date: 2013-07-09 12:21+0200\n" +"PO-Revision-Date: 2013-07-14 12:36+0200\n" "Last-Translator: Burak Yavuz \n" -"Language-Team: Turkish \n" +"Language-Team: Turkish " +"\n" "Language: tr\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -1663,7 +1663,7 @@ msgid "" "Note: If the file contains multiple tables, they will be combined into one." msgstr "" "Not: Eğer dosya çoklu tablolar içeriyorsa, bunlar bir tane içinde " -"birleştirilecektir" +"birleştirilecektir." #: js/messages.php:262 msgid "Hide query box" @@ -2832,7 +2832,7 @@ msgstr "Birincil anahtar kaldırıldı" #: libraries/Index.class.php:608 #, php-format msgid "Index %s has been dropped." -msgstr "%s indeksi kaldırıldı" +msgstr "%s indeksi kaldırıldı." #: libraries/Index.class.php:731 #, php-format @@ -3797,7 +3797,7 @@ msgstr "Web sunucusu gönderme dizininden %s seçin:" #: libraries/Util.class.php:3441 libraries/insert_edit.lib.php:1183 #: libraries/sql_query_form.lib.php:483 msgid "The directory you set for upload work cannot be reached." -msgstr "Gönderme işi için ayarladığınız dizine ulaşılamıyor" +msgstr "Gönderme işi için ayarladığınız dizine ulaşılamıyor." #: libraries/Util.class.php:3452 msgid "There are no files to upload" @@ -3932,7 +3932,7 @@ msgstr "%s %s veya sonrasına yükseltmelisiniz." #: libraries/common.inc.php:1075 msgid "Error: Token mismatch" -msgstr "Hata: Belirti uyuşmazlığı" +msgstr "Hata: Belirteç uyuşmazlığı" #: libraries/common.inc.php:1119 msgid "GLOBALS overwrite attempt" @@ -7954,7 +7954,7 @@ msgstr "" #: libraries/plugins/auth/AuthenticationSignon.class.php:254 #, php-format msgid "No activity within %s seconds; please log in again." -msgstr "%s saniye içinde hiçbir işlem yapılmadı, lütfen yeniden oturum açın" +msgstr "%s saniye içinde hiçbir işlem yapılmadı; lütfen tekrar oturum açın." #: libraries/plugins/auth/AuthenticationCookie.class.php:667 #: libraries/plugins/auth/AuthenticationCookie.class.php:669 @@ -7978,7 +7978,7 @@ msgstr "%s dosyası herhangi bir anahtar kimliği içermiyor" #: libraries/plugins/auth/swekey/swekey.auth.lib.php:176 #: libraries/plugins/auth/swekey/swekey.auth.lib.php:196 msgid "Hardware authentication failed!" -msgstr "Donanım kimlik doğrulaması başarısız" +msgstr "Donanım kimlik doğrulaması başarısız oldu!" #: libraries/plugins/auth/swekey/swekey.auth.lib.php:183 msgid "No valid authentication key plugged" @@ -11148,7 +11148,8 @@ msgid "" "below, if there is any, may also help you in diagnosing the problem." msgstr "" "SQL sorgunuzda bir hata olduğu görünüyor. MySQL sunucusu hata çıktısı " -"aşağıdadır, eğer varsa, sorunu teşhis etmenizde ayrıca size yardımcı olabilir" +"aşağıdadır, eğer varsa, sorunu teşhis etmenizde ayrıca size yardımcı " +"olabilir." #: libraries/sqlparser.lib.php:178 msgid "" diff --git a/po/zh_TW.po b/po/zh_TW.po index 78805d6c9b..51f047c4fc 100644 --- a/po/zh_TW.po +++ b/po/zh_TW.po @@ -4,10 +4,10 @@ msgstr "" "Project-Id-Version: phpMyAdmin 4.1-dev\n" "Report-Msgid-Bugs-To: phpmyadmin-devel@lists.sourceforge.net\n" "POT-Creation-Date: 2013-07-12 16:06+0200\n" -"PO-Revision-Date: 2013-07-05 16:35+0200\n" +"PO-Revision-Date: 2013-07-13 20:32+0200\n" "Last-Translator: Tony Chen \n" -"Language-Team: Traditional Chinese \n" +"Language-Team: Traditional Chinese " +"\n" "Language: zh_TW\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -1680,10 +1680,9 @@ msgid "Show search criteria" msgstr "顯示搜尋條件" #: js/messages.php:278 -#, fuzzy #| msgid "Hide search criteria" msgid "Hide find and replace criteria" -msgstr "隱藏搜尋條件" +msgstr "隱藏搜尋和替換條件" #: js/messages.php:279 msgid "Show find and replace criteria" @@ -2774,7 +2773,7 @@ msgstr "已刪除主鍵" #: libraries/Index.class.php:608 #, php-format msgid "Index %s has been dropped." -msgstr "已刪除索引 %s" +msgstr "已刪除索引 %s。" #: libraries/Index.class.php:731 #, php-format @@ -3161,7 +3160,7 @@ msgstr "資料表搜尋" #: libraries/TableSearch.class.php:217 libraries/TableSearch.class.php:1172 msgid "Find and Replace" -msgstr "" +msgstr "搜尋和替換" #: libraries/TableSearch.class.php:239 libraries/insert_edit.lib.php:1352 msgid "Edit/Insert" @@ -3226,20 +3225,18 @@ msgid "Reset zoom" msgstr "重設縮放大小" #: libraries/TableSearch.class.php:1281 -#, fuzzy #| msgid "Replace with" msgid "Replace with:" -msgstr "替換爲" +msgstr "替換爲:" #: libraries/TableSearch.class.php:1341 msgid "Find and replace - preview" msgstr "尋找和替換-預覽" #: libraries/TableSearch.class.php:1345 -#, fuzzy #| msgid "Column" msgid "Count" -msgstr "欄位" +msgstr "次數" #: libraries/TableSearch.class.php:1346 msgid "Original string" @@ -3722,7 +3719,7 @@ msgstr "選擇 Web 伺服器上傳目錄 %s:" #: libraries/Util.class.php:3441 libraries/insert_edit.lib.php:1183 #: libraries/sql_query_form.lib.php:483 msgid "The directory you set for upload work cannot be reached." -msgstr "設定之上傳目錄錯誤,無法使用" +msgstr "設定之上傳目錄錯誤,無法使用。" #: libraries/Util.class.php:3452 msgid "There are no files to upload" @@ -7666,7 +7663,7 @@ msgstr "空密碼登錄被禁止 (參見 允許空密碼)" #: libraries/plugins/auth/AuthenticationSignon.class.php:254 #, php-format msgid "No activity within %s seconds; please log in again." -msgstr "登錄超時 (%s 秒未操作),請重新登錄" +msgstr "登錄超時 (%s 秒未操作),請重新登錄。" #: libraries/plugins/auth/AuthenticationCookie.class.php:667 #: libraries/plugins/auth/AuthenticationCookie.class.php:669 @@ -7690,7 +7687,7 @@ msgstr "檔案 %s 未包含任何密鑰" #: libraries/plugins/auth/swekey/swekey.auth.lib.php:176 #: libraries/plugins/auth/swekey/swekey.auth.lib.php:196 msgid "Hardware authentication failed!" -msgstr "硬件認證失敗" +msgstr "硬體身份驗證失敗!" #: libraries/plugins/auth/swekey/swekey.auth.lib.php:183 msgid "No valid authentication key plugged" @@ -9180,7 +9177,7 @@ msgstr "顯示資料表格大小" #: libraries/schema/User_Schema.class.php:461 msgid "Same width for all tables" -msgstr "" +msgstr "所有資料表使用相同的寬度" #: libraries/schema/User_Schema.class.php:464 libraries/structure.lib.php:379 msgid "Data Dictionary" @@ -10710,9 +10707,7 @@ msgstr "僅查看" msgid "" "There seems to be an error in your SQL query. The MySQL server error output " "below, if there is any, may also help you in diagnosing the problem." -msgstr "" -"您的 SQL 查詢可能有錯。如果可能的話,以下會列出 MySQL 伺服器的錯誤輸出,這可" -"能對您解決問題有一定的幫助" +msgstr "您的 SQL 查詢可能有錯。如果可能的話,以下會列出 MySQL 伺服器的錯誤輸出,這可能對您解決問題有一定的幫助。" #: libraries/sqlparser.lib.php:178 msgid "" diff --git a/test/classes/plugin/import/ImportCsv_test.php b/test/classes/plugin/import/ImportCsv_test.php index 404b3ed131..63e1ec6140 100644 --- a/test/classes/plugin/import/ImportCsv_test.php +++ b/test/classes/plugin/import/ImportCsv_test.php @@ -18,6 +18,7 @@ require_once 'libraries/Util.class.php'; require_once 'libraries/url_generating.lib.php'; require_once 'libraries/php-gettext/gettext.inc'; require_once 'libraries/Table.class.php'; +require_once 'libraries/Tracker.class.php'; require_once 'libraries/database_interface.inc.php'; require_once 'libraries/import.lib.php'; require_once 'libraries/sanitizing.lib.php'; diff --git a/test/classes/plugin/import/ImportLdi_test.php b/test/classes/plugin/import/ImportLdi_test.php index 9a68cd191d..7703a36faa 100644 --- a/test/classes/plugin/import/ImportLdi_test.php +++ b/test/classes/plugin/import/ImportLdi_test.php @@ -19,6 +19,7 @@ require_once 'libraries/Util.class.php'; require_once 'libraries/url_generating.lib.php'; require_once 'libraries/php-gettext/gettext.inc'; require_once 'libraries/Table.class.php'; +require_once 'libraries/Tracker.class.php'; require_once 'libraries/database_interface.inc.php'; require_once 'libraries/import.lib.php'; /* Each PluginObserver instance contains a PluginManager instance */ diff --git a/test/classes/plugin/import/ImportMediawiki_test.php b/test/classes/plugin/import/ImportMediawiki_test.php index 1e66090d11..dfe89efbdd 100644 --- a/test/classes/plugin/import/ImportMediawiki_test.php +++ b/test/classes/plugin/import/ImportMediawiki_test.php @@ -17,6 +17,7 @@ require_once 'libraries/Util.class.php'; require_once 'libraries/url_generating.lib.php'; require_once 'libraries/php-gettext/gettext.inc'; require_once 'libraries/Table.class.php'; +require_once 'libraries/Tracker.class.php'; require_once 'libraries/database_interface.inc.php'; require_once 'libraries/import.lib.php'; diff --git a/test/classes/plugin/import/ImportOds_test.php b/test/classes/plugin/import/ImportOds_test.php index 51ce3df8b8..313fc7b398 100644 --- a/test/classes/plugin/import/ImportOds_test.php +++ b/test/classes/plugin/import/ImportOds_test.php @@ -18,6 +18,7 @@ require_once 'libraries/Util.class.php'; require_once 'libraries/url_generating.lib.php'; require_once 'libraries/php-gettext/gettext.inc'; require_once 'libraries/Table.class.php'; +require_once 'libraries/Tracker.class.php'; require_once 'libraries/database_interface.inc.php'; require_once 'libraries/import.lib.php'; require_once 'libraries/sanitizing.lib.php'; diff --git a/test/classes/plugin/import/ImportSql_test.php b/test/classes/plugin/import/ImportSql_test.php index 13c76aea38..dafb9c20c5 100644 --- a/test/classes/plugin/import/ImportSql_test.php +++ b/test/classes/plugin/import/ImportSql_test.php @@ -18,6 +18,7 @@ require_once 'libraries/Util.class.php'; require_once 'libraries/url_generating.lib.php'; require_once 'libraries/php-gettext/gettext.inc'; require_once 'libraries/Table.class.php'; +require_once 'libraries/Tracker.class.php'; require_once 'libraries/database_interface.inc.php'; require_once 'libraries/import.lib.php'; diff --git a/test/classes/plugin/import/ImportXml_test.php b/test/classes/plugin/import/ImportXml_test.php index 60e8314b2f..c1b3fb93cd 100644 --- a/test/classes/plugin/import/ImportXml_test.php +++ b/test/classes/plugin/import/ImportXml_test.php @@ -18,6 +18,7 @@ require_once 'libraries/Util.class.php'; require_once 'libraries/url_generating.lib.php'; require_once 'libraries/php-gettext/gettext.inc'; require_once 'libraries/Table.class.php'; +require_once 'libraries/Tracker.class.php'; require_once 'libraries/database_interface.inc.php'; require_once 'libraries/import.lib.php'; /* Each PluginObserver instance contains a PluginManager instance */ diff --git a/test/libraries/PMA_server_replication_test.php b/test/libraries/PMA_server_replication_test.php new file mode 100644 index 0000000000..cbf841d955 --- /dev/null +++ b/test/libraries/PMA_server_replication_test.php @@ -0,0 +1,310 @@ +'Server_id1', 'Host'=>'Host1'), + array('Server_id'=>'Server_id2', 'Host'=>'Host2'), + ); + + $fetchResult = array( + array( + "SHOW SLAVE HOSTS", + null, + null, + null, + 0, + $slave_host + ), + ); + + $dbi = $this->getMockBuilder('PMA_DatabaseInterface') + ->disableOriginalConstructor() + ->getMock(); + + $dbi->expects($this->any())->method('fetchResult') + ->will($this->returnValueMap($fetchResult)); + + $fields_info = array( + "Host" => array( + "Field" => "host", + "Type" => "char(60)", + "Null" => "NO", + ) + ); + $dbi->expects($this->any())->method('getColumns') + ->will($this->returnValue($fields_info)); + + $GLOBALS['dbi'] = $dbi; + } + + /** + * Test for PMA_getHtmlForMasterReplication + * + * @return void + */ + public function testPMAGetHtmlForMasterReplication() + { + global $master_variables; + global $master_variables_alerts; + global $master_variables_oks; + global $server_master_replication; + global $strReplicationStatus_master; + + $master_variables_alerts = null; + $master_variables_oks = null; + $strReplicationStatus_master = null; + + //Call the test function + $html = PMA_getHtmlForMasterReplication(); + + //validate 1: Master replication + $this->assertContains( + 'Master replication', + $html + ); + $this->assertContains( + 'This server is configured as master in a replication process.', + $html + ); + + //validate 2: PMA_getHtmlForReplicationStatusTable + $this->assertContains( + '
assertContains( + "Binlog_Do_DB", + $html + ); + $this->assertContains( + "Binlog_Ignore_DB", + $html + ); + //$server_master_replication + $this->assertContains( + "master-bin.000030", + $html + ); + + //validate 3: PMA_getHtmlForReplicationSlavesTable + $this->assertContains( + 'replication_slaves_section', + $html + ); + $this->assertContains( + 'Server ID', + $html + ); + $this->assertContains( + 'Host', + $html + ); + //slave host + $this->assertContains( + 'Server_id1', + $html + ); + $this->assertContains( + 'Server_id2', + $html + ); + $this->assertContains( + 'Host1', + $html + ); + $this->assertContains( + 'Host2', + $html + ); + //Notice + $this->assertContains( + 'Only slaves started with the', + $html + ); + + //validate 4: navigation URL + $this->assertContains( + '', + $html + ); + } + + /** + * Test for PMA_getHtmlForNotServerReplication + * + * @return void + */ + public function testPMAGetHtmlForNotServerReplication() + { + //Call the test function + $html = PMA_getHtmlForNotServerReplication(); + + $this->assertContains( + 'Master replication', + $html + ); + $this->assertContains( + 'This server is not configured as master in a replication process.', + $html + ); + } + + /** + * Test for PMA_getHtmlForSlaveConfiguration + * + * @return void + */ + public function testPMAGetHtmlForSlaveConfiguration() + { + global $server_slave_replication; + + //Call the test function + $html = PMA_getHtmlForSlaveConfiguration( + true, + $server_slave_replication + ); + + //legend + $this->assertContains( + 'Slave replication', + $html + ); + $this->assertContains( + '
', + $html + ); + //notice + $this->assertContains( + 'Server is configured as slave in a replication process.', + $html + ); + //slave session + $this->assertContains( + '
assertContains( + 'Master_SSL_CA_Path', + $html + ); + $this->assertContains( + 'Master_SSL_Cert', + $html + ); + $this->assertContains( + 'Master_SSL_Cipher', + $html + ); + $this->assertContains( + 'Seconds_Behind_Master', + $html + ); + } + + /** + * Test for PMA_getHtmlForReplicationChangeMaster + * + * @return void + */ + public function testPMAGetHtmlForReplicationChangeMaster() + { + //Call the test function + $html = PMA_getHtmlForReplicationChangeMaster("slave_changemaster"); + + $this->assertContains( + '
', + $html + ); + $this->assertContains( + 'Slave configuration', + $html + ); + $this->assertContains( + 'Change or reconfigure master server', + $html + ); + $notice = 'Make sure, you have unique server-id ' + . 'in your configuration file (my.cnf)'; + $this->assertContains( + $notice, + $html + ); + } +} diff --git a/view_create.php b/view_create.php index af53a5550c..0a2cae5f85 100644 --- a/view_create.php +++ b/view_create.php @@ -17,7 +17,7 @@ require_once './libraries/common.inc.php'; * Runs common work */ require './libraries/db_common.inc.php'; -$url_params['goto'] = $cfg['DefaultTabDatabase']; +$url_params['goto'] = 'tbl_structure.php'; $url_params['back'] = 'view_create.php'; $view_algorithm_options = array( @@ -27,26 +27,45 @@ $view_algorithm_options = array( ); $view_with_options = array( - 'CASCADED CHECK OPTION', - 'LOCAL CHECK OPTION' + 'CASCADED', + 'LOCAL' ); -if (isset($_REQUEST['createview'])) { +$view_sql_security_options = array( + 'DEFINER', + 'INVOKER' +); + +if (isset($_REQUEST['createview']) || isset($_REQUEST['alterview'])) { /** * Creates the view */ $sep = "\r\n"; - $sql_query = 'CREATE'; - - if (isset($_REQUEST['view']['or_replace'])) { - $sql_query .= ' OR REPLACE'; + if (isset($_REQUEST['createview'])) { + $sql_query = 'CREATE'; + if (isset($_REQUEST['view']['or_replace'])) { + $sql_query .= ' OR REPLACE'; + } + } else { + $sql_query = 'ALTER'; } if (PMA_isValid($_REQUEST['view']['algorithm'], $view_algorithm_options)) { $sql_query .= $sep . ' ALGORITHM = ' . $_REQUEST['view']['algorithm']; } + if (! empty($_REQUEST['view']['definer'])) { + $sql_query .= $sep . ' DEFINER = ' . $_REQUEST['view']['definer']; + } + + if (isset($_REQUEST['view']['sql_security'])) { + if (in_array($_REQUEST['view']['sql_security'], $view_sql_security_options)) { + $sql_query .= $sep . ' SQL SECURITY ' + . $_REQUEST['view']['sql_security']; + } + } + $sql_query .= $sep . ' VIEW ' . PMA_Util::backquote($_REQUEST['view']['name']); if (! empty($_REQUEST['view']['column_names'])) { @@ -56,44 +75,44 @@ if (isset($_REQUEST['createview'])) { $sql_query .= $sep . ' AS ' . $_REQUEST['view']['as']; if (isset($_REQUEST['view']['with'])) { - $options = array_intersect($_REQUEST['view']['with'], $view_with_options); - if (count($options)) { - $sql_query .= $sep . ' WITH ' . implode(' ', $options); + if (in_array($_REQUEST['view']['with'], $view_with_options)) { + $sql_query .= $sep . ' WITH ' . $_REQUEST['view']['with'] + . ' CHECK OPTION'; } } if ($GLOBALS['dbi']->tryQuery($sql_query)) { - + include_once './libraries/tbl_views.lib.php'; - + // If different column names defined for VIEW $view_columns = array(); if (isset($_REQUEST['view']['column_names'])) { $view_columns = explode(',', $_REQUEST['view']['column_names']); } - + $column_map = PMA_getColumnMap($_REQUEST['view']['as'], $view_columns); $pma_tranformation_data = PMA_getExistingTranformationData($GLOBALS['db']); - + if ($pma_tranformation_data !== false) { - + // SQL for store new transformation details of VIEW $new_transformations_sql = PMA_getNewTransformationDataSql( $pma_tranformation_data, $column_map, $_REQUEST['view']['name'], $GLOBALS['db'] - ); - + ); + // Store new transformations if ($new_transformations_sql != '') { $GLOBALS['dbi']->tryQuery($new_transformations_sql); } - + } unset($pma_tranformation_data); - - if ($GLOBALS['is_ajax_request'] != true) { + + if (! isset($_REQUEST['ajax_dialog'])) { $message = PMA_Message::success(); - include './' . $cfg['DefaultTabDatabase']; + include 'tbl_structure.php'; } else { $response = PMA_Response::getInstance(); $response->addJSON( @@ -102,12 +121,13 @@ if (isset($_REQUEST['createview'])) { PMA_Message::success(), $sql_query ) ); + $response->isSuccess(true); } - + exit; - + } else { - if ($GLOBALS['is_ajax_request'] != true) { + if (! isset($_REQUEST['ajax_dialog'])) { $message = PMA_Message::rawError($GLOBALS['dbi']->getError()); } else { $response = PMA_Response::getInstance(); @@ -126,12 +146,15 @@ if (isset($_REQUEST['createview'])) { // prefill values if not already filled from former submission $view = array( + 'operation' => 'create', 'or_replace' => '', 'algorithm' => '', + 'definer' => '', + 'sql_security' => '', 'name' => '', 'column_names' => '', 'as' => $sql_query, - 'with' => array(), + 'with' => '', ); if (PMA_isValid($_REQUEST['view'], 'array')) { @@ -149,21 +172,27 @@ $htmlString = '' . '' . PMA_generate_common_hidden_inputs($url_params) . '
' - . '' . __('Create view') - . PMA_Util::showMySQLDocu('SQL-Syntax', 'CREATE_VIEW') . '' - . '' - . '' - . '' - . '' - . '' - . '
' - . '
'; +if ($view['operation'] == 'create') { + $htmlString .= '' + . '' + . '' + . '' - . '' - . '' - . '' - . '' - . '' + . ''; + +$htmlString .= '' + . ''; + +$htmlString .= '' + . ''; + +if ($view['operation'] == 'create') { + $htmlString .= '' + . ''; +} else { + $htmlString .= ''; +} + +$htmlString .= '' . '' - . '' - . '' + . ''; + +$htmlString .= '' . '
' - . '
' . __('VIEW name') . '' - . '
' . __('Column names') . '
' . __('Definer') . '' + . '
SQL SECURITY' + . '
' . __('VIEW name') . '' + . '
' + . '
' . __('Column names') . '' - . '
AS
AS' . '