-$result = SQL_QUERY("SELECT id, sender, subject, payment_id, cat_id FROM `{?_MYSQL_PREFIX?}_pool` ORDER BY timestamp", __FILE__, __LINE__);
-if (SQL_NUMROWS($result) > 0) {
- if (isFormSent()) {
- // Make mail editable...
- $result = SQL_QUERY_ESC("SELECT subject, text, url FROM `{?_MYSQL_PREFIX?}_pool` WHERE `id`=%s LIMIT 1",
- array(bigintval(postRequestParameter('id'))), __FILE__, __LINE__);
- list($subj, $text, $url) = SQL_FETCHROW($result);
- SQL_FREERESULT($result);
+// Form sent or anything else? ;-)
+if ((isFormSent()) && (isPostRequestElementSet('mid'))) {
+ // Make mail editable...
+ $result = SQL_QUERY_ESC("SELECT
+ `id`,`sender` AS `userid`,`subject`,`text`,`url`
+FROM
+ `{?_MYSQL_PREFIX?}_pool`
+WHERE
+ `id`=%s
+LIMIT 1",
+ array(bigintval(postRequestElement('mid'))), __FILE__, __LINE__);
+
+ // Fetch row
+ $content = SQL_FETCHARRAY($result);
+
+ // Free result
+ SQL_FREERESULT($result);
+
+ // Load template
+ loadTemplate('admin_edit_email', false, $content);
+} elseif (isGetRequestElementSet('mid')) {
+ // Make also this email editable
+ $result = SQL_QUERY_ESC("SELECT
+ `id`,`sender` AS `userid`,`subject`,`text`,`url`
+FROM
+ `{?_MYSQL_PREFIX?}_pool`
+WHERE
+ `id`=%s
+LIMIT 1",
+ array(bigintval(getRequestElement('mid'))), __FILE__, __LINE__);
+
+ // Fetch row
+ $content = SQL_FETCHARRAY($result);
+
+ // Free result
+ SQL_FREERESULT($result);
+
+ // Load template
+ loadTemplate('admin_edit_email', false, $content);
+} elseif (isGetRequestElementSet('bid')) {
+ // Make also this email editable
+ $result = SQL_QUERY_ESC("SELECT
+ `id`,`subject`,`text`,`url`
+FROM
+ `{?_MYSQL_PREFIX?}_bonus`
+WHERE
+ `id`=%s
+LIMIT 1",
+ array(bigintval(getRequestElement('bid'))), __FILE__, __LINE__);
+
+ // Fetch row
+ $content = SQL_FETCHARRAY($result);