Added update_year.sh (still not fully flexible) and updated all years with it.
[mailer.git] / inc / libs / task_functions.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 08/03/2004 *
4  * ===================                          Last change: 11/19/2005 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : task_functions.php                               *
8  * -------------------------------------------------------------------- *
9  * Short description : Special task functions                           *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Spezielle task-Funktionen                        *
12  * -------------------------------------------------------------------- *
13  * $Revision::                                                        $ *
14  * $Date::                                                            $ *
15  * $Tag:: 0.2.1-FINAL                                                 $ *
16  * $Author::                                                          $ *
17  * -------------------------------------------------------------------- *
18  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
19  * Copyright (c) 2009 - 2015 by Mailer Developer Team                   *
20  * For more information visit: http://mxchange.org                      *
21  *                                                                      *
22  * This program is free software; you can redistribute it and/or modify *
23  * it under the terms of the GNU General Public License as published by *
24  * the Free Software Foundation; either version 2 of the License, or    *
25  * (at your option) any later version.                                  *
26  *                                                                      *
27  * This program is distributed in the hope that it will be useful,      *
28  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
29  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
30  * GNU General Public License for more details.                         *
31  *                                                                      *
32  * You should have received a copy of the GNU General Public License    *
33  * along with this program; if not, write to the Free Software          *
34  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
35  * MA  02110-1301  USA                                                  *
36  ************************************************************************/
37
38 // Some security stuff...
39 if (!defined('__SECURITY')) {
40         die();
41 } // END - if
42
43 //
44 // The advanced overview shows detailed informations to your exchange script:
45 //  - Unconfirmed / locked accounts
46 //  - Mails waiting to be approved
47 //  - Open tasks
48 //  - Your own tasks
49 //  - ...
50 //
51 // @TODO Move all extension-dependent queries into filters
52 function outputAdvancedOverview (&$result_main) {
53         // Init variables/arrays
54         $EXTRAS = '';
55         $OUT    = '';
56         $WHATs  = array();
57         $DESCRs = array();
58         $TITLEs = array();
59
60         // Chheck for new extensions and updates
61         $jobsDone = outputStandardOverview($result_main);
62
63         // Init SQLs
64         initSqls();
65
66         // Init content
67         foreach (
68                 array(
69                         // Member accounts
70                         'confirmed_members','unconfirmed_members','locked_members','random_refid','testers',
71                         // Tasks
72                         'update_tasks','new_tasks','closed_tasks','your_tasks','deleted_tasks','solved_tasks',
73                         // Mail orders
74                         'pending_mails','canceled_mails','send_emails',
75                         // Bonus mails
76                         'send_bonus_mails',
77                         // Purging
78                         'purged_mails','purged_bonus_mails'
79                 ) as $entry) {
80                 // Set it to zero
81                 $content[$entry] = '0';
82         } // END - foreach
83
84         // Extension updates found
85         $value = countSumTotalData(getCurrentAdminId(), 'task_system', 'id', 'assigned_admin', TRUE, " AND `status`='NEW' AND `task_type`='EXTENSION_UPDATE'");
86
87         if ($value > 0) {
88                 $content['update_tasks'] = '<a href="{%url=modules.php?module=admin&amp;what=list_task&amp;type=updates%}">' . $value . '</a>';
89         } // END - if
90
91         // Do this only if ext-user is installed
92         if (isExtensionInstalled('user')) {
93                 //
94                 // First check for all account status seperately
95                 //
96                 // Confirmed accounts
97                 $value = getTotalConfirmedUser();
98                 if ($value > 0) {
99                         $content['confirmed_members'] = '<a href="{%url=modules.php?module=admin&amp;what=list_user&amp;status=confirmed%}">' . $value . '</a>';
100                 } // END - if
101
102                 // Unconfirmed accounts
103                 $value = getTotalUnconfirmedUser();
104                 if ($value > 0) {
105                         $content['unconfirmed_members'] = '<a href="{%url=modules.php?module=admin&amp;what=list_user&amp;status=unconfirmed%}">' . $value . '</a>';
106                 } // END - if
107
108                 // Locked accounts
109                 $value = getTotalLockedUser();
110                 if ($value > 0) {
111                         $content['locked_members'] = '<a href="{%url=modules.php?module=admin&amp;what=list_user&amp;status=locked%}">' . $value . '</a>';
112                 } // END - if
113         } // END - if
114
115         if (isExtensionInstalledAndNewer('user', '0.3.4')) {
116                 // And random refid
117                 $value = getTotalRandomRefidUser();
118                 if ($value > 0) {
119                         $content['random_refid'] = '<a href="{%url=modules.php?module=admin&amp;what=list_user&amp;do=random_refid%}">' . $value . '</a>';
120                 } // END - if
121
122                 if (isExtensionInstalledAndNewer('user', '0.5.0')) {
123                         // And tester accounts
124                         $value = getTotalTesterUsers();
125                         if ($value > 0) {
126                                 $content['testers'] = '<a href="{%url=modules.php?module=admin&amp;what=list_user&amp;do=testers%}">' . $value . '</a>';
127                         } // END - if
128                 } // END - if
129         } // END - if
130
131         //
132         // Unassigned tasks
133         //
134         $value = countSumTotalData(NULL, 'task_system', 'id', 'assigned_admin', TRUE, " AND `status` != 'DELETED'");
135
136         if ($value > 0) {
137                 $content['new_tasks'] = '<a href="{%url=modules.php?module=admin&amp;what=list_task&amp;type=unassigned%}">' . $value . '</a>';
138         } // END - if
139
140         //
141         // Closed tasks
142         //
143         $value = countSumTotalData('CLOSED', 'task_system', 'id', 'status', TRUE);
144
145         if ($value > 0) {
146                 $content['closed_tasks'] = '<a href="{%url=modules.php?module=admin&amp;what=list_task&amp;type=closed%}">' . $value . '</a>';
147         } // END - if
148
149         //
150         // Deleted tasks
151         //
152         $value = countSumTotalData('DELETED', 'task_system', 'id', 'status', TRUE);
153
154         if ($value > 0) {
155                 $content['deleted_tasks'] = '<a href="{%url=modules.php?module=admin&amp;what=list_task&amp;type=deleted%}">' . $value . '</a>';
156         } // END - if
157
158         //
159         // Solved tasks
160         //
161         $value = countSumTotalData('SOLVED', 'task_system', 'id', 'status', TRUE, sprintf(" AND `assigned_admin`=%s", getCurrentAdminId()));
162
163         if ($value > 0) {
164                 $content['solved_tasks'] = '<a href="{%url=modules.php?module=admin&amp;what=list_task&amp;type=solved%}">' . $value . '</a>';
165         } // END - if
166
167         //
168         // Your tasks
169         //
170         $value = countSumTotalData(getCurrentAdminId(), 'task_system', 'id', 'assigned_admin', TRUE, " AND `status`='NEW' AND task_type != 'EXTENSION_UPDATE'");
171
172         if ($value > 0) {
173                 $content['your_tasks'] = '<a href="{%url=modules.php?module=admin&amp;what=list_task%}">' . $value . '</a>';
174         } // END - if
175
176         //
177         // Mails waiting to be approved
178         //
179         $value = countSumTotalData('ADMIN', 'pool', 'id', 'data_type', TRUE);
180
181         if ($value > 0) {
182                 $content['pending_mails'] = '<a href="{%url=modules.php?module=admin&amp;what=unlock_emails%}">' . $value . '</a>';
183         } // END - if
184
185         //
186         // Unfinished mail orders
187         //
188         $value = countSumTotalData('TEMP', 'pool', 'id', 'data_type', TRUE);
189
190         if ($value > 0) {
191                 $content['canceled_mails'] = '<a href="{%url=modules.php?module=admin&amp;what=email_details%}">' . $value . '</a>';
192         } // END - if
193
194         //
195         // Sent mail orders
196         //
197         $value = countSumTotalData('SEND', 'pool', 'id', 'data_type', TRUE);
198
199         if ($value > 0) {
200                 $content['send_emails'] = '<a href="{%url=modules.php?module=admin&amp;what=email_archiv%}">' . $value . '</a>';
201         } // END - if
202
203         //
204         // Autopurged mails
205         //
206         if (isExtensionActive('autopurge')) {
207                 // Get auto-purged mails
208                 $value = countSumTotalData('DELETED', 'pool', 'id', 'data_type', TRUE);
209
210                 if ($value > 0) {
211                         $content['purged_mails'] = '<a href="{%url=modules.php?module=admin&amp;what=email_details%}">' . $value . '</a>';
212                 } // END - if
213
214                 //
215                 // Autopurged bonus mails
216                 //
217                 if (isExtensionInstalledAndNewer('bonus', '0.1.8')) {
218                         // Get auto-purged bonus mails
219                         $value = countSumTotalData('DELETED', 'bonus', 'id', 'data_type', TRUE);
220
221                         if ($value > 0) {
222                                 $content['purged_bonus_mails'] = '<a href="{%url=modules.php?module=admin&amp;what=email_details%}">' . $value . '</a>';
223                         } // END - if
224                 } elseif (isExtensionActive('bonus')) {
225                         $content['purged_bonus_mails'] = '{%message,ADMIN_EXTENSION_BONUS_OUTDATED=0.1.8%}';
226                 } else {
227                         $content['purged_bonus_mails'] = '<span class="bad">{--ADMIN_EXTENSION_BONUS_404--}</span>';
228                 }
229         } else {
230                 $content['purged_bonus_mails'] = '<span class="bad">{--ADMIN_EXTENSION_AUTOPURGE_404--}</span>';
231                 $content['purged_mails'] = '<span class="bad">{--ADMIN_EXTENSION_AUTOPURGE_404--}</span>';
232         }
233
234         //
235         // Sent bonus mails
236         //
237         if (isExtensionInstalledAndNewer('bonus', '0.1.8')) {
238                 // Get sent bonus mails (but not notifications)
239                 $value = countSumTotalData('SEND', 'bonus', 'id', 'data_type', TRUE, " AND `is_notify`='N'");
240
241                 if ($value > 0) {
242                         $content['send_bonus_mails'] = '<a href="{%url=modules.php?module=admin&amp;what=email_details%}">' . $value . '</a>';
243                 } // END - if
244         } elseif (isExtensionActive('bonus')) {
245                 $content['send_bonus_mails'] = '{%message,ADMIN_EXTENSION_BONUS_OUTDATED=0.1.8%}';
246         } else {
247                 $content['send_bonus_mails'] = '{--ADMIN_EXTENSION_BONUS_404--}';
248         }
249
250         // Both extensions must be there
251         if ((isExtensionActive('autopurge')) && (isExtensionActive('user'))) {
252                 // Start finding them...
253                 $userExclusionSql = ' ';
254                 $excludedUserids = runFilterChain('config_userid_exclusion_sql', array());
255                 if (count($excludedUserids) > 0) {
256                         // Exclude all
257                         $userExclusionSql .= ' AND `d`.`userid` NOT IN (' . implode(', ', $excludedUserids) . ')';
258                 } // END - if
259
260                 // Check for all accounts
261                 addSql("SELECT
262         `d`.`userid`,
263         `d`.`email`,
264         `d`.`last_online`
265 FROM
266         `{?_MYSQL_PREFIX?}_user_data` AS `d`
267 WHERE
268         `d`.`status`='CONFIRMED' AND
269         (UNIX_TIMESTAMP() - `d`.`joined`) >= {?ap_inactive_since?} AND
270         (UNIX_TIMESTAMP() - `d`.`last_online`) >= {?ap_inactive_since?} AND
271         (UNIX_TIMESTAMP() - `d`.`ap_notified`) >= {?ap_inactive_since?}
272         " . runFilterChain('user_exclusion_sql', ' ' . $userExclusionSql) . "
273 ORDER BY
274         `d`.`userid` ASC");
275                 $WHATs[]  = 'list_autopurge';
276                 $DESCRs[] = '{--ADMIN_TASK_INACTIVE_AUTOPURGE--}';
277                 $TITLEs[] = '{--ADMIN_TASK_INACTIVE_AUTOPURGE_TITLE--}';
278         } // END - if
279
280         if ((isExtensionInstalledAndNewer('sql_patches', '0.3.4')) && (isExtensionActive('user'))) {
281                 // Check for accounts without referral
282                 addSql('SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `refid`=0 OR `refid` IS NULL ' . runFilterChain('user_exclusion_sql', ' ') . ' ORDER BY `userid` ASC');
283                 $DESCRs[] = '{--ADMIN_TASK_LIST_ACCOUNT_NO_REFERRAL--}';
284                 $TITLEs[] = '{--ADMIN_TASK_LIST_ACCOUNT_NO_REFERRAL_TITLE--}';
285                 $WHATs[]  = 'list_user&amp;do=norefs';
286         } // END - if
287
288         if (isExtensionActive('payout')) {
289                 // List new payout requests
290                 addSql("SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_payouts` WHERE `status`='NEW' ORDER BY `userid` ASC");
291                 $WHATs[]  = 'list_payouts';
292                 $DESCRs[] = '{--ADMIN_TASK_LIST_PAYOUTS_WAITING--}';
293                 $TITLEs[] = '{--ADMIN_TASK_LIST_PAYOUTS_WAITING_TITLE--}';
294                 addSql('SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_payouts` ORDER BY `userid` ASC');
295                 $WHATs[]  = 'list_payouts';
296                 $DESCRs[] = '{--ADMIN_TASK_LIST_PAYOUTS_ALL--}';
297                 $TITLEs[] = '{--ADMIN_TASK_LIST_PAYOUTS_ALL_TITLE--}';
298         } // END - if
299
300         if (isExtensionActive('wernis')) {
301                 // List new wernis requests
302                 addSql('SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_wernis` ORDER BY `userid` ASC');
303                 $WHATs[]  = 'list_wernis';
304                 $DESCRs[] = '{--ADMIN_TASK_LIST_WERNIS_ALL--}';
305                 $TITLEs[] = '{--ADMIN_TASK_LIST_WERNIS_ALL_TITLE--}';
306         } // END - if
307
308         if (isExtensionActive('holiday')) {
309                 // List holiday requests
310                 addSql('SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_holidays` ORDER BY `userid` ASC');
311                 $WHATs[]  = 'list_holiday';
312                 $DESCRs[] = '{--ADMIN_TASK_LIST_HOLIDAYS--}';
313                 $TITLEs[] = '{--ADMIN_TASK_LIST_HOLIDAYS_TITLE--}';
314         } // END - if
315
316         if (isExtensionInstalledAndNewer('bonus', '0.8.7')) {
317                 // List all notifications
318                 addSql("SELECT `id` FROM `{?_MYSQL_PREFIX?}_bonus` WHERE `is_notify`='Y' ORDER BY `timestamp` DESC");
319                 $WHATs[]  = 'list_notifications';
320                 $DESCRs[] = '{--ADMIN_TASK_LIST_NOTIFICATIONS--}';
321                 $TITLEs[] = '{--ADMIN_TASK_LIST_NOTIFICATIONS_TITLE--}';
322         } // END - if
323
324         // Both extensions must be there
325         if ((isExtensionInstalledAndNewer('bonus', '0.2.3')) && (isExtensionActive('user'))) {
326                 // Get more columns
327                 $add = trim(runFilterChain('add_bonus_points_user_columns', ''));
328
329                 // Active rallye, so add more point columns, if not empty
330                 $pointsColumns = '';
331                 if (!empty($add)) {
332                         $pointsColumns = '(0' . $add . ')';
333                 } // END - if
334
335                 // Init variable
336                 $lastOnline = '';
337
338                 // Autopurge installed?
339                 if ((isExtensionActive('autopurge')) && (isAutopurgeInactiveEnabled()) && (getApInactiveSince() > 0)) {
340                         // Use last online timestamp to keep inactive members away from here
341                         $lastOnline   = ' AND (UNIX_TIMESTAMP() - `last_online`) < {?ap_inactive_since?}';
342                 } // END - if
343
344                 // Is it empty?
345                 if (!empty($ointsColumns)) {
346                         // No, then add it
347                         addSql("SELECT
348         " . $pointsColumns . " AS `points`
349 FROM
350         `{?_MYSQL_PREFIX?}_user_data`
351 WHERE
352         `status`='CONFIRMED' AND
353         " . $pointsColumns . " > 0
354         " . $lastOnline . "
355 ORDER BY
356         `points` DESC,
357         `userid` ASC");
358                         $WHATs[]  = 'list_bonus';
359                         $DESCRs[] = '{--ADMIN_TASK_LIST_BONUS--}';
360                         $TITLEs[] = '{--ADMIN_TASK_LIST_BONUS_TITLE--}';
361                 } // END - if
362         } // END - if
363
364         // Again both extensions must be there
365         if ((isExtensionInstalledAndNewer('beg', '0.1.2')) && (isExtensionActive('user'))) {
366                 // ----- Begging rallye -----
367
368                 // Init variable
369                 $lastOnline = '';
370
371                 // Autopurge installed?
372                 if ((isExtensionActive('autopurge')) && (isAutopurgeInactiveEnabled()) && (getApInactiveSince() > 0)) {
373                         // Use last online timestamp to keep inactive members away from here
374                         $lastOnline   = ' AND (UNIX_TIMESTAMP() - `last_online`) < {?ap_inactive_since?}';
375                 } // END - if
376
377                 addSql("SELECT
378         `userid`
379 FROM
380         `{?_MYSQL_PREFIX?}_user_data`
381 WHERE
382         `status`='CONFIRMED' AND
383         `beg_points` > 0
384         ".$lastOnline."
385 ORDER BY
386         `beg_points` DESC,
387         `userid` ASC");
388                 $WHATs[]  = 'list_beg';
389                 $DESCRs[] = '{--ADMIN_TASK_LIST_BEG--}';
390                 $TITLEs[] = '{--ADMIN_TASK_LIST_BEG_TITLE--}';
391         } // END - if
392
393         if (isExtensionActive('doubler')) {
394                 // List waiting payouts
395                 addSql("SELECT `id` FROM `{?_MYSQL_PREFIX?}_doubler` WHERE `completed`='N' ORDER BY `id` ASC");
396                 $WHATs[]  = 'list_doubler&amp;do=waiting&amp;select=all';
397                 $DESCRs[] = '{--ADMIN_TASK_LIST_DOUBLER_WAITING--}';
398                 $TITLEs[] = '{--ADMIN_TASK_LIST_DOUBLER_WAITING_TITLE--}';
399                 addSql('SELECT `id` FROM `{?_MYSQL_PREFIX?}_doubler` ORDER BY `id` ASC');
400                 $WHATs[]  = 'list_doubler';
401                 $DESCRs[] = '{--ADMIN_TASK_LIST_DOUBLER_ALL--}';
402                 $TITLEs[] = '{--ADMIN_TASK_LIST_DOUBLER_ALL_TITLE--}';
403         } // END - if
404
405         //
406         // All referral banner
407         //
408         addSql('SELECT `id` FROM `{?_MYSQL_PREFIX?}_refbanner` ORDER BY `id` ASC');
409         $WHATs[] = 'refbanner';
410         $DESCRs[] = '{--ADMIN_TASK_LIST_REFBANNER_ALL--}';
411         $TITLEs[] = '{--ADMIN_TASK_LIST_REFBANNER_ALL_TITLE--}';
412
413         //
414         // All activated referral banner
415         //
416         addSql("SELECT `id` FROM `{?_MYSQL_PREFIX?}_refbanner` WHERE `visible`='Y' ORDER BY `id` ASC");
417         $WHATs[] = 'refbanner';
418         $DESCRs[] = '{--ADMIN_TASK_LIST_REFBANNER_ACTIVE--}';
419         $TITLEs[] = '{--ADMIN_TASK_LIST_REFBANNER_ACTIVE_TITLE--}';
420
421         //
422         // All extensions
423         //
424         addSql('SELECT `id` FROM `{?_MYSQL_PREFIX?}_extensions` ORDER BY `id` ASC');
425         $WHATs[] = 'extensions';
426         $DESCRs[] = '{--ADMIN_TASK_LIST_EXTENSIONS_ALL--}';
427         $TITLEs[] = '{--ADMIN_TASK_LIST_EXTENSIONS_ALL_TITLE--}';
428
429         //
430         // All activated extensions
431         //
432         addSql("SELECT `id` FROM `{?_MYSQL_PREFIX?}_extensions` WHERE `ext_active`='Y' ORDER BY `id` ASC");
433         $WHATs[]  = 'extensions&amp;active=Y';
434         $DESCRs[] = '{--ADMIN_TASK_LIST_EXTENSIONS_ACTIVE--}';
435         $TITLEs[] = '{--ADMIN_TASK_LIST_EXTENSIONS_ACTIVE_TITLE--}';
436
437         if (isExtensionActive('sponsor')) {
438                 // List all sponsors
439                 addSql('SELECT `id` FROM `{?_MYSQL_PREFIX?}_sponsor_data` ORDER BY `id` ASC');
440                 $WHATs[]  = 'list_sponsor';
441                 $DESCRs[] = '{--ADMIN_TASK_LIST_SPONSOR--}';
442                 $TITLEs[] = '{--ADMIN_TASK_LIST_SPONSOR_TITLE--}';
443
444                 // List confirmed sponsor accounts
445                 addSql("SELECT `id` FROM `{?_MYSQL_PREFIX?}_sponsor_data` WHERE `status`='CONFIRMED' ORDER BY `id` ASC");
446                 $WHATs[]  = 'list_sponsor';
447                 $DESCRs[] = '{--ADMIN_TASK_LIST_SPONSOR_CONFIRMED--}';
448                 $TITLEs[] = '{--ADMIN_TASK_LIST_SPONSOR_CONFIRMED_TITLE--}';
449
450                 // List unconfirmed sponsor accounts
451                 addSql("SELECT `id` FROM `{?_MYSQL_PREFIX?}_sponsor_data` WHERE `status`='UNCONFIRMED' ORDER BY `id` ASC");
452                 $WHATs[]  = 'list_sponsor';
453                 $DESCRs[] = '{--ADMIN_TASK_LIST_SPONSOR_UNCONFIRMED--}';
454                 $TITLEs[] = '{--ADMIN_TASK_LIST_SPONSOR_UNCONFIRMED_TITLE--}';
455
456                 // List locked sponsor accounts
457                 addSql("SELECT `id` FROM `{?_MYSQL_PREFIX?}_sponsor_data` WHERE `status`='LOCKED' ORDER BY `id` ASC");
458                 $WHATs[]  = 'list_sponsor';
459                 $DESCRs[] = '{--ADMIN_TASK_LIST_SPONSOR_LOCKED--}';
460                 $TITLEs[] = '{--ADMIN_TASK_LIST_SPONSOR_LOCKED_TITLE--}';
461
462                 // List waiting sponsor accounts to be approved
463                 addSql("SELECT `id` FROM `{?_MYSQL_PREFIX?}_sponsor_data` WHERE `status`='PENDING' ORDER BY `id` ASC");
464                 $WHATs[]  = 'unlock_sponsor';
465                 $DESCRs[] = '{--ADMIN_TASK_LIST_SPONSOR_PENDING--}';
466                 $TITLEs[] = '{--ADMIN_TASK_LIST_SPONSOR_PENDING_TITLE--}';
467
468                 // Waiting payments
469                 addSql("SELECT `id` FROM `{?_MYSQL_PREFIX?}_sponsor_orders` WHERE `pay_status`='PENDING' ORDER BY `id` ASC");
470                 $WHATs[]  = 'list_sponsor_pays';
471                 $DESCRs[] = '{--ADMIN_TASK_LIST_SPONSOR_ORDERS--}';
472                 $TITLEs[] = '{--ADMIN_TASK_LIST_SPONSOR_ORDERS_TITLE--}';
473         } // END - if
474
475         if (isExtensionActive('country')) {
476                 // List country codes
477                 addSql('SELECT `id` FROM `{?_MYSQL_PREFIX?}_countries` ORDER BY `id` ASC');
478                 $WHATs[]  = 'list_country';
479                 $DESCRs[] = '{--ADMIN_TASK_LIST_COUNTRY--}';
480                 $TITLEs[] = '{--ADMIN_TASK_LIST_COUNTRY_TITLE--}';
481         } // END - if
482
483         if (isExtensionActive('theme')) {
484                 // List all themes
485                 addSql('SELECT `id` FROM `{?_MYSQL_PREFIX?}_themes` ORDER BY `id` ASC');
486                 $WHATs[]  = 'theme_edit';
487                 $DESCRs[] = '{--ADMIN_TASK_LIST_THEME_ALL--}';
488                 $TITLEs[] = '{--ADMIN_TASK_LIST_THEME_ALL_TITLE--}';
489
490                 // List active themes
491                 addSql("SELECT `id` FROM `{?_MYSQL_PREFIX?}_themes` WHERE `theme_active`='Y' ORDER BY `id` ASC");
492                 $WHATs[]  = 'theme_edit';
493                 $DESCRs[] = '{--ADMIN_TASK_LIST_THEME_ACTIVE--}';
494                 $TITLEs[] = '{--ADMIN_TASK_LIST_THEME_ACTIVE_TITLE--}';
495         } // END - if
496
497         if (isExtensionActive('admins')) {
498                 // List all administrator logins
499                 addSql('SELECT `id` FROM `{?_MYSQL_PREFIX?}_admins` ORDER BY `id` ASC');
500                 $WHATs[]  = 'admins_edit';
501                 $DESCRs[] = '{--ADMIN_TASK_LIST_ADMINS_ALL--}';
502                 $TITLEs[] = '{--ADMIN_TASK_LIST_ADMINS_ALL_TITLE--}';
503         } // END - if
504
505         if (isExtensionActive('surfbar')) {
506                 // List all URLs in surfbar
507                 addSql('SELECT `url_id` FROM `{?_MYSQL_PREFIX?}_surfbar_urls` ORDER BY `url_id` ASC');
508                 $WHATs[]  = 'list_surfbar_urls';
509                 $DESCRs[] = '{--ADMIN_TASK_LIST_SURFBAR_URLS_ALL--}';
510                 $TITLEs[] = '{--ADMIN_TASK_LIST_SURFBAR_URLS_ALL_TITLE--}';
511
512                 // List all pending URLs in surfbar
513                 addSql("SELECT `url_id` FROM `{?_MYSQL_PREFIX?}_surfbar_urls` WHERE `url_status`='PENDING' ORDER BY `url_id` ASC");
514                 $WHATs[]  = 'unlock_surfbar_urls';
515                 $DESCRs[] = '{--ADMIN_TASK_LIST_SURFBAR_URLS_PENDING--}';
516                 $TITLEs[] = '{--ADMIN_TASK_LIST_SURFBAR_URLS_PENDING_TITLE--}';
517         } // END - if
518
519         if (isExtensionInstalledAndNewer('sql_patches', '0.9.2')) {
520                 // Check for wrong "SERVER_NAME" entries
521                 addSql('SELECT `server_name_id` FROM `{?_MYSQL_PREFIX?}_server_name_log`');
522                 $DESCRs[] = '{--ADMIN_TASK_LIST_SERVER_NAME_LOG--}';
523                 $TITLEs[] = '{--ADMIN_TASK_LIST_SERVER_NAME_LOG_TITLE--}';
524                 $WHATs[]  = 'list_server_name';
525         } // END - if
526
527         if (isExtensionInstalled('network')) {
528                 // Check for HTTP logging entries
529                 addSql('SELECT `network_header_id` FROM `{?_MYSQL_PREFIX?}_network_header_logging`');
530                 $DESCRs[] = '{--ADMIN_TASK_LIST_NETWORK_HEADER_LOG--}';
531                 $TITLEs[] = '{--ADMIN_TASK_LIST_NETWORK_HEADER_LOG_TITLE--}';
532                 $WHATs[]  = 'list_network_http_header';
533
534                 // Check for API cache entries
535                 addSql('SELECT `network_cache_id` FROM `{?_MYSQL_PREFIX?}_network_cache`');
536                 $DESCRs[] = '{--ADMIN_TASK_LIST_NETWORK_API_CACHE--}';
537                 $TITLEs[] = '{--ADMIN_TASK_LIST_NETWORK_API_CACHE_TITLE--}';
538                 $WHATs[]  = 'list_network_api';
539         } // END - if
540
541         // Generate extra overview rows
542         $EXTRAS .= createExtraTaskRows($WHATs, $DESCRs, $TITLEs);
543
544         // If empty just keep a forced-space left for CSS issues
545         if (empty($EXTRAS)) {
546                 $EXTRAS = '&nbsp;';
547         } // END - if
548
549         // Add compiled string to constant for final template
550         $content['extra_table'] = $EXTRAS;
551
552         // Simply load the template... :-)
553         loadTemplate('admin_overview_task', FALSE, $content);
554 }
555
556 //
557 function createExtraTaskRows ($WHATs, $DESCRs, $TITLEs) {
558         // Init variables
559         $OUT = '';
560
561         // Sadly this cannot be rewritten to a filter... :(
562         foreach (getSqls() as $sqls) {
563                 // New format...
564                 foreach ($sqls as $key => $sql) {
565                         // Run SQL command, get line numbers and free memory
566                         $result = sqlQuery($sql, __FUNCTION__, __LINE__);
567
568                         // Prepare array for output
569                         $content = array(
570                                 'row_descr' => $DESCRs[$key],
571                                 'bottom'    => '',
572                         );
573
574                         // Rewrite CSS class if not last entry is reached
575                         if ($key < (count($sqls) - 1)) {
576                                 $content['bottom'] = 'bottom';
577                         } // END - if
578
579                         if ((!ifSqlHasZeroNums($result)) && (!empty($WHATs[$key]))) {
580                                 if (empty($TITLEs[$key])) {
581                                         $TITLEs[$key] = '{--ADMIN_TASK_UNKNOWN_LIST_TITLE--}';
582                                 } // END - if
583                                 $content['row_link'] = '<a href="{%url=modules.php?module=admin&amp;what=' . $WHATs[$key] . '%}" title="' . $TITLEs[$key] . '">' . sqlNumRows($result) . '</a>';
584                         } else {
585                                 $content['row_link'] = '0';
586                         }
587
588                         // Free result
589                         sqlFreeResult($result);
590
591                         // And insert the final string into extras template
592                         $OUT .= loadTemplate('admin_overview_task_rows', TRUE, $content);
593                 } // END- foreach
594         } // END - foreach
595
596         // Return output in the template
597         return loadTemplate('admin_overview_task_extras', TRUE, $OUT);
598 }
599
600 // [EOF]
601 ?>