]> git.mxchange.org Git - mailer.git/blobdiff - inc/mysql-manager.php
Some rewrites, you don't need to do: bigintval(getUserData('some_id_column')) as...
[mailer.git] / inc / mysql-manager.php
index 21ddd007d23b0696aaaa51865f48eae3fbea452c..bcf674209b87f802cd4e703dbe1d55a1c3e02a60 100644 (file)
@@ -792,7 +792,7 @@ function getActionFromModuleWhat ($module, $what) {
        $data['action'] = '';
 
        if (!isExtensionInstalledAndNewer('sql_patches', '0.0.5')) {
-               // sql_patches is missing so choose depending on mode
+               // ext-sql_patches is missing so choose depending on mode
                $what = determineWhat($module);
        } elseif ((empty($what)) && ($module != 'admin')) {
                // Use configured 'home'
@@ -841,7 +841,7 @@ function getActionFromModuleWhat ($module, $what) {
                // Free memory
                SQL_FREERESULT($result);
        } elseif ((!isExtensionInstalled('sql_patches')) && ($module != 'admin') && ($module != 'unknown')) {
-               // No sql_patches installed, but maybe we need to register an admin?
+               // No ext-sql_patches installed, but maybe we need to register an admin?
                if (isAdminRegistered()) {
                        // Redirect to admin area
                        redirectToUrl('admin.php');
@@ -967,7 +967,7 @@ function removeReceiver (&$receivers, $key, $userid, $poolId, $statsId = 0, $isB
                                                $type
                                        ), __FUNCTION__, __LINE__);
 
-                               // Update 'mails_sent' if sql_patches is updated
+                               // Update 'mails_sent' if ext-sql_patches is updated
                                if (isExtensionInstalledAndNewer('sql_patches', '0.7.4')) {
                                        // Update the pool
                                        SQL_QUERY_ESC('UPDATE `{?_MYSQL_PREFIX?}_pool` SET `mails_sent`=`mails_sent`+1 WHERE `id`=%s LIMIT 1',
@@ -1243,7 +1243,7 @@ function getAdminDefaultAcl ($adminId) {
        // By default an invalid ACL value is returned
        $data['default_acl'] = 'NO-ACL';
 
-       // Is sql_patches there and was it found in cache?
+       // Is ext-sql_patches there and was it found in cache?
        if (!isExtensionActive('sql_patches')) {
                // Not found, which is bad, so we need to allow all
                $data['default_acl'] =  'allow';
@@ -1280,7 +1280,7 @@ function getAdminMenuMode ($adminId) {
        // By default an invalid mode
        $data['la_mode'] = 'INVALID';
 
-       // Is sql_patches there and was it found in cache?
+       // Is ext-sql_patches there and was it found in cache?
        if (!isExtensionActive('sql_patches')) {
                // Not found, which is bad, so we need to allow all
                $data['la_mode'] =  'global';
@@ -1418,9 +1418,9 @@ function deleteUserAccount ($userid, $reason) {
        $result = SQL_QUERY_ESC("SELECT
        (SUM(p.`points`) - d.`used_points`) AS `points`
 FROM
-       `{?_MYSQL_PREFIX?}_user_points` AS p
+       `{?_MYSQL_PREFIX?}_user_points` AS `p`
 LEFT JOIN
-       `{?_MYSQL_PREFIX?}_user_data` AS d
+       `{?_MYSQL_PREFIX?}_user_data` AS `d`
 ON
        p.`userid`=d.`userid`
 WHERE
@@ -1782,7 +1782,10 @@ function reduceRecipientReceivedMails ($column, $id, $count) {
                if (count($userids) > 0) {
                        // Now update all user accounts
                        SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `emails_received`=`emails_received`-1 WHERE `userid` IN (%s) LIMIT %s",
-                               array(implode(',', $userids), count($userids)), __FUNCTION__, __LINE__);
+                               array(
+                                       implode(',', $userids),
+                                       count($userids)
+                               ), __FUNCTION__, __LINE__);
                } else {
                        // Nothing deleted
                        displayMessage('{%message,ADMIN_MAIL_NOTHING_DELETED=' . $id . '%}');
@@ -1796,7 +1799,7 @@ function reduceRecipientReceivedMails ($column, $id, $count) {
 // Creates a new task
 function createNewTask ($subject, $notes, $taskType, $userid = NULL, $adminId = NULL, $strip = TRUE) {
        // Insert the task data into the database
-       SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_task_system` (`assigned_admin`, `userid`, `status`, `task_type`, `subject`, `text`, `task_created`) VALUES (%s,%s,'NEW','%s','%s','%s', UNIX_TIMESTAMP())",
+       SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_task_system` (`assigned_admin`, `userid`, `status`, `task_type`, `subject`, `text`, `task_created`) VALUES (%s, %s, 'NEW', '%s', '%s', '%s', UNIX_TIMESTAMP())",
                array(
                        convertZeroToNull($adminId),
                        convertZeroToNull($userid),
@@ -1810,23 +1813,20 @@ function createNewTask ($subject, $notes, $taskType, $userid = NULL, $adminId =
 }
 
 // Updates last module / online time
-function updateLastActivity($userid) {
+function updateLastActivity ($userid) {
        // Is 'what' set?
        if (isWhatSet()) {
                // Run the update query
                SQL_QUERY_ESC("UPDATE
        `{?_MYSQL_PREFIX?}_user_data`
 SET
-       `%s`='%s',
+       `{%%pipe,getUserLastWhatName%%}`='{%%pipe,getWhat%%}',
        `last_online`=UNIX_TIMESTAMP(),
-       `REMOTE_ADDR`='%s'
+       `REMOTE_ADDR`='{%%pipe,detectRemoteAddr%%}'
 WHERE
        `userid`=%s
 LIMIT 1",
                array(
-                       getUserLastWhatName(),
-                       getWhat(),
-                       detectRemoteAddr(),
                        bigintval($userid)
                ), __FUNCTION__, __LINE__);
        } else {
@@ -1834,15 +1834,13 @@ LIMIT 1",
                SQL_QUERY_ESC("UPDATE
        `{?_MYSQL_PREFIX?}_user_data`
 SET
-       `%s`=NULL,
+       `{%%pipe,getUserLastWhatName%%}`=NULL,
        `last_online`=UNIX_TIMESTAMP(),
-       `REMOTE_ADDR`='%s'
+       `REMOTE_ADDR`='{%%pipe,detectRemoteAddr%%}'
 WHERE
        `userid`=%s
 LIMIT 1",
                array(
-                       getUserLastWhatName(),
-                       detectRemoteAddr(),
                        bigintval($userid)
                ), __FUNCTION__, __LINE__);
        }