/** * Test for PMA_getExtraDataForAjaxBehavior * * @return void */ public function testPMAGetExtraDataForAjaxBehavior() { $password = "******"; $sql_query = "pma_sql_query"; $username = "******"; $hostname = "pma_hostname"; $GLOBALS['dbname'] = "pma_dbname"; $_REQUEST['adduser_submit'] = "adduser_submit"; $_REQUEST['change_copy'] = "change_copy"; $_REQUEST['validate_username'] = "******"; $_REQUEST['username'] = "******"; $_POST['update_privs'] = "update_privs"; //PMA_getExtraDataForAjaxBehavior $extra_data = PMA_getExtraDataForAjaxBehavior($password, $sql_query, $hostname, $username); //user_exists $this->assertEquals(false, $extra_data['user_exists']); //db_wildcard_privs $this->assertEquals(true, $extra_data['db_wildcard_privs']); //user_exists $this->assertEquals(false, $extra_data['db_specific_privs']); //new_user_initial $this->assertEquals('P', $extra_data['new_user_initial']); //sql_query $this->assertEquals(PMA\libraries\Util::getMessage(null, $sql_query), $extra_data['sql_query']); //new_user_string $this->assertContains(htmlspecialchars($hostname), $extra_data['new_user_string']); $this->assertContains(htmlspecialchars($username), $extra_data['new_user_string']); //new_privileges $this->assertContains(join(', ', PMA_extractPrivInfo(null, true)), $extra_data['new_privileges']); }
&& ! isset($_REQUEST['export']) && (! isset($_REQUEST['submit_mult']) || $_REQUEST['submit_mult'] != 'export') && (! isset($_REQUEST['adduser']) || $_add_user_error) && (! isset($_REQUEST['initial']) || empty($_REQUEST['initial'])) && ! isset($_REQUEST['showall']) && ! isset($_REQUEST['edit_user_dialog']) && ! isset($_REQUEST['db_specific']) ) { $isPass = false; if (isset($password)) { $isPass = true; } $extra_data = PMA_getExtraDataForAjaxBehavior( $isPass, $link_export, (isset($sql_query) ? $sql_query : ''), $link_edit, $dbname_is_wildcard, $hostname, $username ); if ($message instanceof PMA_Message) { $response = PMA_Response::getInstance(); $response->isSuccess($message->isSuccess()); $response->addJSON('message', $message); $response->addJSON($extra_data); exit; } } /** * Displays the links */
$sql_query = join("\n", $queries); } /** * Reloads the privilege tables into memory */ $message_ret = PMA_updateMessageForReload(); if (isset($message_ret)) { $message = $message_ret; unset($message_ret); } /** * If we are in an Ajax request for Create User/Edit User/Revoke User/ * Flush Privileges, show $message and exit. */ if ($GLOBALS['is_ajax_request'] && empty($_REQUEST['ajax_page_request']) && !isset($_REQUEST['export']) && (!isset($_REQUEST['submit_mult']) || $_REQUEST['submit_mult'] != 'export') && (!isset($_REQUEST['initial']) || $_REQUEST['initial'] === null || $_REQUEST['initial'] === '' || isset($_REQUEST['delete']) && $_REQUEST['delete'] === 'Go') && !isset($_REQUEST['showall']) && !isset($_REQUEST['edit_user_group_dialog']) && !isset($_REQUEST['db_specific'])) { $extra_data = PMA_getExtraDataForAjaxBehavior(isset($password) ? $password : '', isset($sql_query) ? $sql_query : '', isset($hostname) ? $hostname : '', isset($username) ? $username : ''); if (!empty($message) && $message instanceof PMA_Message) { $response = PMA_Response::getInstance(); $response->isSuccess($message->isSuccess()); $response->addJSON('message', $message); $response->addJSON($extra_data); exit; } } /** * Displays the links */ if (isset($_REQUEST['viewing_mode']) && $_REQUEST['viewing_mode'] == 'db') { $GLOBALS['db'] = $_REQUEST['db'] = $_REQUEST['checkprivsdb']; $url_query .= '&goto=db_operations.php'; // Gets the database structure
/** * If we are in an Ajax request for Create User/Edit User/Revoke User/ * Flush Privileges, show $message and exit. */ if ($GLOBALS['is_ajax_request'] && ! isset($_REQUEST['export']) && (! isset($_REQUEST['submit_mult']) || $_REQUEST['submit_mult'] != 'export') && (! isset($_REQUEST['adduser']) || $_add_user_error) && (! isset($_REQUEST['initial']) || empty($_REQUEST['initial'])) && ! isset($_REQUEST['showall']) && ! isset($_REQUEST['edit_user_dialog']) && ! isset($_REQUEST['db_specific']) ) { $extra_data = PMA_getExtraDataForAjaxBehavior( (isset ($password) ? $password : ''), $link_export, (isset($sql_query) ? $sql_query : ''), $link_edit, $hostname, $username ); if ($message instanceof PMA_Message) { $response = PMA_Response::getInstance(); $response->isSuccess($message->isSuccess()); $response->addJSON('message', $message); $response->addJSON($extra_data); exit; } } /** * Displays the links */