Substitute foreign keys in e-mail fields
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@1079 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
parent
2e680bc9bd
commit
dea345cbd5
|
@ -324,9 +324,10 @@ class Adminer {
|
||||||
|
|
||||||
/** Process extras in select form
|
/** Process extras in select form
|
||||||
* @param array AND conditions
|
* @param array AND conditions
|
||||||
|
* @param array
|
||||||
* @return bool true if processed, false to process other parts of form
|
* @return bool true if processed, false to process other parts of form
|
||||||
*/
|
*/
|
||||||
function selectEmailProcess($where) {
|
function selectEmailProcess($where, $foreignKeys) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,8 @@ $TABLE = $_GET["select"];
|
||||||
$table_status = table_status($TABLE);
|
$table_status = table_status($TABLE);
|
||||||
$indexes = indexes($TABLE);
|
$indexes = indexes($TABLE);
|
||||||
$fields = fields($TABLE);
|
$fields = fields($TABLE);
|
||||||
|
$foreign_keys = column_foreign_keys($TABLE);
|
||||||
|
|
||||||
$rights = array(); // privilege => 0
|
$rights = array(); // privilege => 0
|
||||||
$columns = array(); // selectable columns
|
$columns = array(); // selectable columns
|
||||||
unset($text_length);
|
unset($text_length);
|
||||||
|
@ -52,7 +54,7 @@ if ($_POST && !$error) {
|
||||||
dump();
|
dump();
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
if (!$adminer->selectEmailProcess($where)) {
|
if (!$adminer->selectEmailProcess($where, $foreign_keys)) {
|
||||||
if (!$_POST["import"]) { // edit
|
if (!$_POST["import"]) { // edit
|
||||||
$result = true;
|
$result = true;
|
||||||
$affected = 0;
|
$affected = 0;
|
||||||
|
@ -120,7 +122,6 @@ if ($_POST && !$error) {
|
||||||
$table_name = $adminer->tableName($table_status);
|
$table_name = $adminer->tableName($table_status);
|
||||||
page_header(lang('Select') . ": $table_name", $error);
|
page_header(lang('Select') . ": $table_name", $error);
|
||||||
|
|
||||||
$foreign_keys = column_foreign_keys($TABLE);
|
|
||||||
echo "<p>";
|
echo "<p>";
|
||||||
if (isset($rights["insert"])) {
|
if (isset($rights["insert"])) {
|
||||||
$set = "";
|
$set = "";
|
||||||
|
@ -174,8 +175,6 @@ if (!$columns) {
|
||||||
: count($rows)
|
: count($rows)
|
||||||
);
|
);
|
||||||
|
|
||||||
$descriptions = $adminer->rowDescriptions($rows, $foreign_keys);
|
|
||||||
|
|
||||||
$backward_keys = $adminer->backwardKeys($TABLE);
|
$backward_keys = $adminer->backwardKeys($TABLE);
|
||||||
$table_names = array();
|
$table_names = array();
|
||||||
if ($backward_keys) {
|
if ($backward_keys) {
|
||||||
|
@ -204,7 +203,7 @@ if (!$columns) {
|
||||||
next($select);
|
next($select);
|
||||||
}
|
}
|
||||||
echo ($table_names ? "<th>" . lang('Relations') : "") . "</thead>\n";
|
echo ($table_names ? "<th>" . lang('Relations') : "") . "</thead>\n";
|
||||||
foreach ($descriptions as $n => $row) {
|
foreach ($adminer->rowDescriptions($rows, $foreign_keys) as $n => $row) {
|
||||||
$unique_idf = implode('&', unique_idf($rows[$n], $indexes));
|
$unique_idf = implode('&', unique_idf($rows[$n], $indexes));
|
||||||
echo "<tr" . odd() . "><td><input type='checkbox' name='check[]' value='$unique_idf' onclick=\"this.form['all'].checked = false; form_uncheck('all-page');\">" . (count($select) != count($group) || information_schema(DB) ? '' : " <a href='" . h(ME) . "edit=" . urlencode($TABLE) . "&$unique_idf'>" . lang('edit') . "</a>");
|
echo "<tr" . odd() . "><td><input type='checkbox' name='check[]' value='$unique_idf' onclick=\"this.form['all'].checked = false; form_uncheck('all-page');\">" . (count($select) != count($group) || information_schema(DB) ? '' : " <a href='" . h(ME) . "edit=" . urlencode($TABLE) . "&$unique_idf'>" . lang('edit') . "</a>");
|
||||||
foreach ($row as $key => $val) {
|
foreach ($row as $key => $val) {
|
||||||
|
|
|
@ -188,6 +188,7 @@ ORDER BY ORDINAL_POSITION"); //! requires MySQL 5
|
||||||
echo "<p>" . lang('From') . ": <input name='email_from'>\n";
|
echo "<p>" . lang('From') . ": <input name='email_from'>\n";
|
||||||
echo lang('Subject') . ": <input name='email_subject'>\n";
|
echo lang('Subject') . ": <input name='email_subject'>\n";
|
||||||
echo "<p><textarea name='email_message' rows='15' cols='60'></textarea>\n";
|
echo "<p><textarea name='email_message' rows='15' cols='60'></textarea>\n";
|
||||||
|
//! add UI for {$name} fields
|
||||||
echo "<p>" . (count($emailFields) == 1 ? '<input type="hidden" name="email_field" value="' . h(key($emailFields)) . '">' : '<select name="email_field">' . optionlist($emailFields) . '</select> ');
|
echo "<p>" . (count($emailFields) == 1 ? '<input type="hidden" name="email_field" value="' . h(key($emailFields)) . '">' : '<select name="email_field">' . optionlist($emailFields) . '</select> ');
|
||||||
echo "<input type='submit' name='email' value='" . lang('Send') . "'$confirm>\n";
|
echo "<input type='submit' name='email' value='" . lang('Send') . "'$confirm>\n";
|
||||||
echo "</div></fieldset>\n";
|
echo "</div></fieldset>\n";
|
||||||
|
@ -249,7 +250,7 @@ ORDER BY ORDINAL_POSITION"); //! requires MySQL 5
|
||||||
return "100";
|
return "100";
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectEmailProcess($where) {
|
function selectEmailProcess($where, $foreignKeys) {
|
||||||
global $dbh;
|
global $dbh;
|
||||||
if ($_POST["email"]) {
|
if ($_POST["email"]) {
|
||||||
$sent = 0;
|
$sent = 0;
|
||||||
|
@ -263,10 +264,14 @@ ORDER BY ORDINAL_POSITION"); //! requires MySQL 5
|
||||||
. ($where ? " AND " . implode(" AND ", $where) : "")
|
. ($where ? " AND " . implode(" AND ", $where) : "")
|
||||||
. ($_POST["all"] ? "" : " AND ((" . implode(") OR (", array_map('where_check', (array) $_POST["check"])) . "))")
|
. ($_POST["all"] ? "" : " AND ((" . implode(") OR (", array_map('where_check', (array) $_POST["check"])) . "))")
|
||||||
);
|
);
|
||||||
|
$rows = array();
|
||||||
while ($row = $result->fetch_assoc()) {
|
while ($row = $result->fetch_assoc()) {
|
||||||
|
$rows[] = $row;
|
||||||
|
}
|
||||||
|
foreach ($this->rowDescriptions($rows, $foreignKeys) as $row) {
|
||||||
$replace = array();
|
$replace = array();
|
||||||
foreach ($matches[1] as $val) {
|
foreach ($matches[1] as $val) {
|
||||||
$replace['{$' . "$val}"] = $row[$val]; //! substitute foreign keys
|
$replace['{$' . "$val}"] = $row[$val];
|
||||||
}
|
}
|
||||||
$email = $row[$_POST["email_field"]];
|
$email = $row[$_POST["email_field"]];
|
||||||
if (is_email($email) && mail($email, email_header(strtr($subject, $replace)), strtr($message, $replace),
|
if (is_email($email) && mail($email, email_header(strtr($subject, $replace)), strtr($message, $replace),
|
||||||
|
|
Loading…
Reference in a new issue