]> git.mxchange.org Git - mailer.git/blobdiff - inc/libs/task_functions.php
Renamed ifSqlHasZeroNums() to ifSqlHasZeroNumRows() and improved some queries.
[mailer.git] / inc / libs / task_functions.php
index b1243ce216ca3653d9701a2ff569eb9b8cb68832..5be0adbd3737835a5cd1a6300c4f9d08e9ac0eb0 100644 (file)
@@ -16,7 +16,7 @@
  * $Author::                                                          $ *
  * -------------------------------------------------------------------- *
  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
- * Copyright (c) 2009 - 2012 by Mailer Developer Team                   *
+ * Copyright (c) 2009 - 2015 by Mailer Developer Team                   *
  * For more information visit: http://mxchange.org                      *
  *                                                                      *
  * This program is free software; you can redistribute it and/or modify *
@@ -88,25 +88,28 @@ function outputAdvancedOverview (&$result_main) {
                $content['update_tasks'] = '<a href="{%url=modules.php?module=admin&amp;what=list_task&amp;type=updates%}">' . $value . '</a>';
        } // END - if
 
-       //
-       // First check for all account status seperately
-       //
-       // Confirmed accounts
-       $value = getTotalConfirmedUser();
-       if ($value > 0) {
-               $content['confirmed_members'] = '<a href="{%url=modules.php?module=admin&amp;what=list_user&amp;status=confirmed%}">' . $value . '</a>';
-       } // END - if
+       // Do this only if ext-user is installed
+       if (isExtensionInstalled('user')) {
+               //
+               // First check for all account status seperately
+               //
+               // Confirmed accounts
+               $value = getTotalConfirmedUser();
+               if ($value > 0) {
+                       $content['confirmed_members'] = '<a href="{%url=modules.php?module=admin&amp;what=list_user&amp;status=confirmed%}">' . $value . '</a>';
+               } // END - if
 
-       // Unconfirmed accounts
-       $value = getTotalUnconfirmedUser();
-       if ($value > 0) {
-               $content['unconfirmed_members'] = '<a href="{%url=modules.php?module=admin&amp;what=list_user&amp;status=unconfirmed%}">' . $value . '</a>';
-       } // END - if
+               // Unconfirmed accounts
+               $value = getTotalUnconfirmedUser();
+               if ($value > 0) {
+                       $content['unconfirmed_members'] = '<a href="{%url=modules.php?module=admin&amp;what=list_user&amp;status=unconfirmed%}">' . $value . '</a>';
+               } // END - if
 
-       // Locked accounts
-       $value = getTotalLockedUser();
-       if ($value > 0) {
-               $content['locked_members'] = '<a href="{%url=modules.php?module=admin&amp;what=list_user&amp;status=locked%}">' . $value . '</a>';
+               // Locked accounts
+               $value = getTotalLockedUser();
+               if ($value > 0) {
+                       $content['locked_members'] = '<a href="{%url=modules.php?module=admin&amp;what=list_user&amp;status=locked%}">' . $value . '</a>';
+               } // END - if
        } // END - if
 
        if (isExtensionInstalledAndNewer('user', '0.3.4')) {
@@ -128,7 +131,7 @@ function outputAdvancedOverview (&$result_main) {
        //
        // Unassigned tasks
        //
-       $value = countSumTotalData(0, 'task_system', 'id', 'assigned_admin', TRUE, " AND `status` != 'DELETED'");
+       $value = countSumTotalData(NULL, 'task_system', 'id', 'assigned_admin', TRUE, " AND `status` != 'DELETED'");
 
        if ($value > 0) {
                $content['new_tasks'] = '<a href="{%url=modules.php?module=admin&amp;what=list_task&amp;type=unassigned%}">' . $value . '</a>';
@@ -248,36 +251,27 @@ function outputAdvancedOverview (&$result_main) {
        if ((isExtensionActive('autopurge')) && (isExtensionActive('user'))) {
                // Start finding them...
                $userExclusionSql = ' ';
-
-               // Exclude test accounts
-               $userExclusionSql = runFilterChain('user_exclusion_sql', ' ');
-
-               // Check for more extensions
-               // @TODO These can be rewritten to filter
-               if (isValidUserId(getDefRefid()))              $userExclusionSql .= ' AND d.`userid` != {?def_refid?}';
-               if (isExtensionActive('beg'))                  $userExclusionSql .= ' AND d.`userid` != {?beg_userid?}';
-               if (isExtensionActive('bonus'))                $userExclusionSql .= ' AND d.`userid` != {?bonus_userid?}';
-               if (isExtensionActive('doubler'))              $userExclusionSql .= ' AND d.`userid` != {?doubler_userid?}';
-               if (isExtensionInstalledAndNewer('holiday', '0.1.3')) {
-                       // Recent ext-holiday found
-                       $userExclusionSql .= " AND d.`holiday_active`='N'";
+               $excludedUserids = runFilterChain('config_userid_exclusion_sql', array());
+               if (count($excludedUserids) > 0) {
+                       // Exclude all
+                       $userExclusionSql .= ' AND `d`.`userid` NOT IN (' . implode(', ', $excludedUserids) . ')';
                } // END - if
 
                // Check for all accounts
                addSql("SELECT
-       d.`userid`,
-       d.`email`,
-       d.`last_online`
+       `d`.`userid`,
+       `d`.`email`,
+       `d`.`last_online`
 FROM
        `{?_MYSQL_PREFIX?}_user_data` AS `d`
 WHERE
-       d.`status`='CONFIRMED' AND
-       (UNIX_TIMESTAMP() - d.`joined`) >= {?ap_inactive_since?} AND
-       (UNIX_TIMESTAMP() - d.`last_online`) >= {?ap_inactive_since?} AND
-       (UNIX_TIMESTAMP() - d.`ap_notified`) >= {?ap_inactive_since?}
-" . $userExclusionSql . "
+       `d`.`status`='CONFIRMED' AND
+       (UNIX_TIMESTAMP() - `d`.`joined`) >= {?ap_inactive_since?} AND
+       (UNIX_TIMESTAMP() - `d`.`last_online`) >= {?ap_inactive_since?} AND
+       (UNIX_TIMESTAMP() - `d`.`ap_notified`) >= {?ap_inactive_since?}
+       " . runFilterChain('user_exclusion_sql', ' ' . $userExclusionSql) . "
 ORDER BY
-       d.`userid` ASC");
+       `d`.`userid` ASC");
                $WHATs[]  = 'list_autopurge';
                $DESCRs[] = '{--ADMIN_TASK_INACTIVE_AUTOPURGE--}';
                $TITLEs[] = '{--ADMIN_TASK_INACTIVE_AUTOPURGE_TITLE--}';
@@ -330,10 +324,10 @@ ORDER BY
        // Both extensions must be there
        if ((isExtensionInstalledAndNewer('bonus', '0.2.3')) && (isExtensionActive('user'))) {
                // Get more columns
-               $add = runFilterChain('add_bonus_points_user_columns', '');
+               $add = trim(runFilterChain('add_bonus_points_user_columns', ''));
 
                // Active rallye, so add more point columns, if not empty
-               $pointsColumns = '`turbo_bonus`';
+               $pointsColumns = '';
                if (!empty($add)) {
                        $pointsColumns = '(0' . $add . ')';
                } // END - if
@@ -347,7 +341,10 @@ ORDER BY
                        $lastOnline   = ' AND (UNIX_TIMESTAMP() - `last_online`) < {?ap_inactive_since?}';
                } // END - if
 
-               addSql("SELECT
+               // Is it empty?
+               if (!empty($ointsColumns)) {
+                       // No, then add it
+                       addSql("SELECT
        " . $pointsColumns . " AS `points`
 FROM
        `{?_MYSQL_PREFIX?}_user_data`
@@ -358,10 +355,11 @@ WHERE
 ORDER BY
        `points` DESC,
        `userid` ASC");
-               $WHATs[]  = 'list_bonus';
-               $DESCRs[] = '{--ADMIN_TASK_LIST_BONUS--}';
-               $TITLEs[] = '{--ADMIN_TASK_LIST_BONUS_TITLE--}';
-       }
+                       $WHATs[]  = 'list_bonus';
+                       $DESCRs[] = '{--ADMIN_TASK_LIST_BONUS--}';
+                       $TITLEs[] = '{--ADMIN_TASK_LIST_BONUS_TITLE--}';
+               } // END - if
+       } // END - if
 
        // Again both extensions must be there
        if ((isExtensionInstalledAndNewer('beg', '0.1.2')) && (isExtensionActive('user'))) {
@@ -519,13 +517,27 @@ ORDER BY
        } // END - if
 
        if (isExtensionInstalledAndNewer('sql_patches', '0.9.2')) {
-               // Check for accounts without referral
+               // Check for wrong "SERVER_NAME" entries
                addSql('SELECT `server_name_id` FROM `{?_MYSQL_PREFIX?}_server_name_log`');
                $DESCRs[] = '{--ADMIN_TASK_LIST_SERVER_NAME_LOG--}';
                $TITLEs[] = '{--ADMIN_TASK_LIST_SERVER_NAME_LOG_TITLE--}';
                $WHATs[]  = 'list_server_name';
        } // END - if
 
+       if (isExtensionInstalled('network')) {
+               // Check for HTTP logging entries
+               addSql('SELECT `network_header_id` FROM `{?_MYSQL_PREFIX?}_network_header_logging`');
+               $DESCRs[] = '{--ADMIN_TASK_LIST_NETWORK_HEADER_LOG--}';
+               $TITLEs[] = '{--ADMIN_TASK_LIST_NETWORK_HEADER_LOG_TITLE--}';
+               $WHATs[]  = 'list_network_http_header';
+
+               // Check for API cache entries
+               addSql('SELECT `network_cache_id` FROM `{?_MYSQL_PREFIX?}_network_cache`');
+               $DESCRs[] = '{--ADMIN_TASK_LIST_NETWORK_API_CACHE--}';
+               $TITLEs[] = '{--ADMIN_TASK_LIST_NETWORK_API_CACHE_TITLE--}';
+               $WHATs[]  = 'list_network_api';
+       } // END - if
+
        // Generate extra overview rows
        $EXTRAS .= createExtraTaskRows($WHATs, $DESCRs, $TITLEs);
 
@@ -551,7 +563,7 @@ function createExtraTaskRows ($WHATs, $DESCRs, $TITLEs) {
                // New format...
                foreach ($sqls as $key => $sql) {
                        // Run SQL command, get line numbers and free memory
-                       $result = SQL_QUERY($sql, __FUNCTION__, __LINE__);
+                       $result = sqlQuery($sql, __FUNCTION__, __LINE__);
 
                        // Prepare array for output
                        $content = array(
@@ -564,17 +576,17 @@ function createExtraTaskRows ($WHATs, $DESCRs, $TITLEs) {
                                $content['bottom'] = 'bottom';
                        } // END - if
 
-                       if ((!SQL_HASZERONUMS($result)) && (!empty($WHATs[$key]))) {
+                       if ((!ifSqlHasZeroNumRows($result)) && (!empty($WHATs[$key]))) {
                                if (empty($TITLEs[$key])) {
                                        $TITLEs[$key] = '{--ADMIN_TASK_UNKNOWN_LIST_TITLE--}';
                                } // END - if
-                               $content['row_link'] = '<a href="{%url=modules.php?module=admin&amp;what=' . $WHATs[$key] . '%}" title="' . $TITLEs[$key] . '">' . SQL_NUMROWS($result) . '</a>';
+                               $content['row_link'] = '<a href="{%url=modules.php?module=admin&amp;what=' . $WHATs[$key] . '%}" title="' . $TITLEs[$key] . '">' . sqlNumRows($result) . '</a>';
                        } else {
                                $content['row_link'] = '0';
                        }
 
                        // Free result
-                       SQL_FREERESULT($result);
+                       sqlFreeResult($result);
 
                        // And insert the final string into extras template
                        $OUT .= loadTemplate('admin_overview_task_rows', TRUE, $content);