Some cleanups/improvements
[mailer.git] / inc / modules / admin / what-admins_mails.php
index d4445560bf61889e507fe275266bbba971621806..fc188c5f11b2c3b54e354c5edc155e9319f9b02e 100644 (file)
@@ -50,11 +50,11 @@ if (isFormSent('edit')) {
                $rows = '';
                foreach (postRequestElement('sel') as $template => $sel) {
                        // First of all load data from DB
-                       $result = SQL_QUERY_ESC("SELECT `admin_id`, `id` FROM `{?_MYSQL_PREFIX?}_admins_mails` WHERE `mail_template`='%s' ORDER BY `id` ASC",
+                       $result = sqlQueryEscaped("SELECT `admin_id`, `id` FROM `{?_MYSQL_PREFIX?}_admins_mails` WHERE `mail_template`='%s' ORDER BY `id` ASC",
                                array($template), __FILE__, __LINE__);
                        $OUT = '';
                        $adminId2 = '0'; $id = '0';
-                       while ($content = SQL_FETCHARRAY($result)) {
+                       while ($content = sqlFetchArray($result)) {
                                // @TODO Can this be rewritten to an API function?
                                $OUT .= '<select name="admin_id[' . $content['id'] . ']" size="1" class="form_select">
 <option value="0"';
@@ -80,12 +80,12 @@ if (isFormSent('edit')) {
                        } // END - while
 
                        // Free memory
-                       SQL_FREERESULT($result);
+                       sqlFreeResult($result);
 
                        // Prepare content
                        $content['id']            = $id;
                        $content['mail_template'] = $template;
-                       $content['admins']        = generateOptions('admins', 'id', 'login', '', 'email');;
+                       $content['admins']        = generateOptions('admins', 'id', 'login', '', 'email');
 
                        if (isValidId($adminId2)) {
                                // Add form for an additional admin
@@ -107,7 +107,7 @@ if (isFormSent('edit')) {
        }
 } else {
        // Load all assigned mails
-       $result = SQL_QUERY("SELECT
+       $result = sqlQuery("SELECT
        `m`.`id`,
        `m`.`admin_id`,
        `a`.`login`,
@@ -124,7 +124,7 @@ ORDER BY
        `m`.`admin_id` ASC,
        `m`.`mail_template` ASC", __FILE__, __LINE__);
 
-       if (!SQL_HASZERONUMS($result)) {
+       if (!ifSqlHasZeroNums($result)) {
                // Shall I change entries?
                if (isFormSent('do_edit')) {
                        // Init SQLs
@@ -137,18 +137,18 @@ ORDER BY
                                $content['admin_id'] = bigintval($content['admin_id']);
 
                                // Update entry
-                               addSql(SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_admins_mails` SET `admin_id`=%s WHERE `id`=%s ORDER BY `id` LIMIT 1",
+                               addSql(sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_admins_mails` SET `admin_id`=%s WHERE `id`=%s ORDER BY `id` LIMIT 1",
                                        array($content['admin_id'], $id), __FILE__, __LINE__, FALSE));
 
                                if ((!isValidId($content['admin_id'])) && (isPostRequestElementSet('template', $id))) {
                                        // Remove any other admin entries
-                                       addSql(SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admins_mails` WHERE mail_template='%s' AND id != '%s'",
+                                       addSql(sqlQueryEscaped("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admins_mails` WHERE mail_template='%s' AND id != '%s'",
                                        array(postRequestElement('template', $id), $id), __FILE__, __LINE__, FALSE));
                                } // END - if
 
                                if (postRequestElement('admin_new', postRequestElement('template', $id)) > 0) {
                                        // Add new admin
-                                       addSql(SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_admins_mails` (admin_id, mail_template) VALUES ('%s','%s')",
+                                       addSql(sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_admins_mails` (admin_id, mail_template) VALUES ('%s','%s')",
                                        array($content['admin_id'], postRequestElement('template', $id)), __FILE__, __LINE__, FALSE));
                                } // END - if
                        } // END - foreach
@@ -157,7 +157,7 @@ ORDER BY
                        runFilterChain('run_sqls');
 
                        // Query again...
-                       $result = SQL_QUERY("SELECT
+                       $result = sqlQuery("SELECT
        `m`.`id`,
        `m`.`admin_id`,
        `a`.`login`,
@@ -177,13 +177,13 @@ ORDER BY
 
                // List found entries
                $OUT = '';
-               while ($content = SQL_FETCHARRAY($result)) {
+               while ($content = sqlFetchArray($result)) {
                        // Load row template
                        $OUT .= loadTemplate('admin_admins_mails_list_row', TRUE, $content);
                } // END - while
 
                // Free result
-               SQL_FREERESULT($result);
+               sqlFreeResult($result);
 
                // Load template
                loadTemplate('admin_admins_mails_list', FALSE, $OUT);