]> git.mxchange.org Git - mailer.git/blobdiff - inc/modules/admin/what-edit_emails.php
Renamed function, used more "pool functions":
[mailer.git] / inc / modules / admin / what-edit_emails.php
index f3c938ba991545f90a5e7ca561e8c3926c25e780..e1f325c56435d3a65b0b8fafa9774d11d8927bef 100644 (file)
@@ -48,49 +48,9 @@ if ((isFormSent()) && (!isPostRequestElementSet('id'))) {
 } // END - if
 
 // Form sent or anything else? ;-)
-if ((isFormSent()) && (isPostRequestElementSet('id')) && (isGetRequestElementSet('type')) && (postRequestElement('type') == 'normal')) {
-       // 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('id'))), __FILE__, __LINE__);
-
-       // Fetch row
-       $content = SQL_FETCHARRAY($result);
-
-       // Free result
-       SQL_FREERESULT($result);
-
-       // Load template
-       loadTemplate('admin_edit_email', FALSE, $content);
-} elseif ((isPostRequestElementSet('id')) && (isGetRequestElementSet('type')) && (postRequestElement('type') == 'normal')) {
-       // 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('id'))), __FILE__, __LINE__);
-
-       // Fetch row
-       $content = SQL_FETCHARRAY($result);
-
-       // Free result
-       SQL_FREERESULT($result);
+if ((isFormSent('edit')) && (isPostRequestElementSet('id')) && (isGetRequestElementSet('type')) && (postRequestElement('type') == 'normal')) {
+       // Get data
+       $content = getPoolDataFromId(postRequestElement('id'));
 
        // Load template
        loadTemplate('admin_edit_email', FALSE, $content);
@@ -120,23 +80,8 @@ LIMIT 1',
        // Save changes
        if ((isPostRequestElementSet('id')) && (isGetRequestElementSet('type')) && (postRequestElement('type') == 'normal')) {
                // Update pool
-               SQL_QUERY_ESC("UPDATE
-       `{?_MYSQL_PREFIX?}_pool`
-SET
-       `subject`='%s',
-       `text`='%s',
-       `url`='%s'
-WHERE
-       `id`=%s
-LIMIT 1",
-                       array(
-                               postRequestElement('subject'),
-                               postRequestElement('text'),
-                               postRequestElement('url'),
-                               bigintval(postRequestElement('id')),
-                       ), __FILE__, __LINE__);
-
-               if (!SQL_HASZEROAFFECTED()) {
+               $isUpdated = updatePoolDataById(postRequestElement('id'), NULL, array('subject' => postRequestElement('subject'), 'text' => postRequestElement('text'), 'url' => postRequestElemenet('url')));
+               if ($isUpdated === TRUE) {
                        $content = '{--ADMIN_EMAIL_CHANGES_SAVED--}';
                } else {
                        $content = '<span class="bad">{--ADMIN_EMAIL_CHANGES_NOT_SAVED--}</span>';
@@ -175,13 +120,14 @@ LIMIT 1",
        // Query the pool
        $result = SQL_QUERY('SELECT
        `id`,
-       `sender` AS `userid`,
+       `sender`,
        `subject`,
        `payment_id`,
        `cat_id`
 FROM
        `{?_MYSQL_PREFIX?}_pool`
 ORDER BY
+       `sender` ASC,
        `timestamp` ASC', __FILE__, __LINE__);
 
        // Entries found?