Fixes for various bugs (e.g.: 'secret file could not be read', SQL error and more)
[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 - 2013 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 more extensions
261                 // @TODO This can be rewritten to filter
262                 if (isExtensionInstalledAndNewer('holiday', '0.1.3')) {
263                         // Recent ext-holiday found
264                         $userExclusionSql .= " AND `d`.`holiday_active`='N'";
265                 } // END - if
266
267                 // Check for all accounts
268                 addSql("SELECT
269         `d`.`userid`,
270         `d`.`email`,
271         `d`.`last_online`
272 FROM
273         `{?_MYSQL_PREFIX?}_user_data` AS `d`
274 WHERE
275         `d`.`status`='CONFIRMED' AND
276         (UNIX_TIMESTAMP() - `d`.`joined`) >= {?ap_inactive_since?} AND
277         (UNIX_TIMESTAMP() - `d`.`last_online`) >= {?ap_inactive_since?} AND
278         (UNIX_TIMESTAMP() - `d`.`ap_notified`) >= {?ap_inactive_since?}
279         " . runFilterChain('user_exclusion_sql', $userExclusionSql) . "
280 ORDER BY
281         `d`.`userid` ASC");
282                 $WHATs[]  = 'list_autopurge';
283                 $DESCRs[] = '{--ADMIN_TASK_INACTIVE_AUTOPURGE--}';
284                 $TITLEs[] = '{--ADMIN_TASK_INACTIVE_AUTOPURGE_TITLE--}';
285         } // END - if
286
287         if ((isExtensionInstalledAndNewer('sql_patches', '0.3.4')) && (isExtensionActive('user'))) {
288                 // Check for accounts without referral
289                 addSql('SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `refid`=0 OR `refid` IS NULL ' . runFilterChain('user_exclusion_sql', ' ') . ' ORDER BY `userid` ASC');
290                 $DESCRs[] = '{--ADMIN_TASK_LIST_ACCOUNT_NO_REFERRAL--}';
291                 $TITLEs[] = '{--ADMIN_TASK_LIST_ACCOUNT_NO_REFERRAL_TITLE--}';
292                 $WHATs[]  = 'list_user&amp;do=norefs';
293         } // END - if
294
295         if (isExtensionActive('payout')) {
296                 // List new payout requests
297                 addSql("SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_payouts` WHERE `status`='NEW' ORDER BY `userid` ASC");
298                 $WHATs[]  = 'list_payouts';
299                 $DESCRs[] = '{--ADMIN_TASK_LIST_PAYOUTS_WAITING--}';
300                 $TITLEs[] = '{--ADMIN_TASK_LIST_PAYOUTS_WAITING_TITLE--}';
301                 addSql('SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_payouts` ORDER BY `userid` ASC');
302                 $WHATs[]  = 'list_payouts';
303                 $DESCRs[] = '{--ADMIN_TASK_LIST_PAYOUTS_ALL--}';
304                 $TITLEs[] = '{--ADMIN_TASK_LIST_PAYOUTS_ALL_TITLE--}';
305         } // END - if
306
307         if (isExtensionActive('wernis')) {
308                 // List new wernis requests
309                 addSql('SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_wernis` ORDER BY `userid` ASC');
310                 $WHATs[]  = 'list_wernis';
311                 $DESCRs[] = '{--ADMIN_TASK_LIST_WERNIS_ALL--}';
312                 $TITLEs[] = '{--ADMIN_TASK_LIST_WERNIS_ALL_TITLE--}';
313         } // END - if
314
315         if (isExtensionActive('holiday')) {
316                 // List holiday requests
317                 addSql('SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_holidays` ORDER BY `userid` ASC');
318                 $WHATs[]  = 'list_holiday';
319                 $DESCRs[] = '{--ADMIN_TASK_LIST_HOLIDAYS--}';
320                 $TITLEs[] = '{--ADMIN_TASK_LIST_HOLIDAYS_TITLE--}';
321         } // END - if
322
323         if (isExtensionInstalledAndNewer('bonus', '0.8.7')) {
324                 // List all notifications
325                 addSql("SELECT `id` FROM `{?_MYSQL_PREFIX?}_bonus` WHERE `is_notify`='Y' ORDER BY `timestamp` DESC");
326                 $WHATs[]  = 'list_notifications';
327                 $DESCRs[] = '{--ADMIN_TASK_LIST_NOTIFICATIONS--}';
328                 $TITLEs[] = '{--ADMIN_TASK_LIST_NOTIFICATIONS_TITLE--}';
329         } // END - if
330
331         // Both extensions must be there
332         if ((isExtensionInstalledAndNewer('bonus', '0.2.3')) && (isExtensionActive('user'))) {
333                 // Get more columns
334                 $add = trim(runFilterChain('add_bonus_points_user_columns', ''));
335
336                 // Active rallye, so add more point columns, if not empty
337                 $pointsColumns = '';
338                 if (!empty($add)) {
339                         $pointsColumns = '(0' . $add . ')';
340                 } // END - if
341
342                 // Init variable
343                 $lastOnline = '';
344
345                 // Autopurge installed?
346                 if ((isExtensionActive('autopurge')) && (isAutopurgeInactiveEnabled()) && (getApInactiveSince() > 0)) {
347                         // Use last online timestamp to keep inactive members away from here
348                         $lastOnline   = ' AND (UNIX_TIMESTAMP() - `last_online`) < {?ap_inactive_since?}';
349                 } // END - if
350
351                 // Is it empty?
352                 if (!empty($ointsColumns)) {
353                         // No, then add it
354                         addSql("SELECT
355         " . $pointsColumns . " AS `points`
356 FROM
357         `{?_MYSQL_PREFIX?}_user_data`
358 WHERE
359         `status`='CONFIRMED' AND
360         " . $pointsColumns . " > 0
361         " . $lastOnline . "
362 ORDER BY
363         `points` DESC,
364         `userid` ASC");
365                         $WHATs[]  = 'list_bonus';
366                         $DESCRs[] = '{--ADMIN_TASK_LIST_BONUS--}';
367                         $TITLEs[] = '{--ADMIN_TASK_LIST_BONUS_TITLE--}';
368                 } // END - if
369         } // END - if
370
371         // Again both extensions must be there
372         if ((isExtensionInstalledAndNewer('beg', '0.1.2')) && (isExtensionActive('user'))) {
373                 // ----- Begging rallye -----
374
375                 // Init variable
376                 $lastOnline = '';
377
378                 // Autopurge installed?
379                 if ((isExtensionActive('autopurge')) && (isAutopurgeInactiveEnabled()) && (getApInactiveSince() > 0)) {
380                         // Use last online timestamp to keep inactive members away from here
381                         $lastOnline   = ' AND (UNIX_TIMESTAMP() - `last_online`) < {?ap_inactive_since?}';
382                 } // END - if
383
384                 addSql("SELECT
385         `userid`
386 FROM
387         `{?_MYSQL_PREFIX?}_user_data`
388 WHERE
389         `status`='CONFIRMED' AND
390         `beg_points` > 0
391         ".$lastOnline."
392 ORDER BY
393         `beg_points` DESC,
394         `userid` ASC");
395                 $WHATs[]  = 'list_beg';
396                 $DESCRs[] = '{--ADMIN_TASK_LIST_BEG--}';
397                 $TITLEs[] = '{--ADMIN_TASK_LIST_BEG_TITLE--}';
398         } // END - if
399
400         if (isExtensionActive('doubler')) {
401                 // List waiting payouts
402                 addSql("SELECT `id` FROM `{?_MYSQL_PREFIX?}_doubler` WHERE `completed`='N' ORDER BY `id` ASC");
403                 $WHATs[]  = 'list_doubler&amp;do=waiting&amp;select=all';
404                 $DESCRs[] = '{--ADMIN_TASK_LIST_DOUBLER_WAITING--}';
405                 $TITLEs[] = '{--ADMIN_TASK_LIST_DOUBLER_WAITING_TITLE--}';
406                 addSql('SELECT `id` FROM `{?_MYSQL_PREFIX?}_doubler` ORDER BY `id` ASC');
407                 $WHATs[]  = 'list_doubler';
408                 $DESCRs[] = '{--ADMIN_TASK_LIST_DOUBLER_ALL--}';
409                 $TITLEs[] = '{--ADMIN_TASK_LIST_DOUBLER_ALL_TITLE--}';
410         } // END - if
411
412         //
413         // All referral banner
414         //
415         addSql('SELECT `id` FROM `{?_MYSQL_PREFIX?}_refbanner` ORDER BY `id` ASC');
416         $WHATs[] = 'refbanner';
417         $DESCRs[] = '{--ADMIN_TASK_LIST_REFBANNER_ALL--}';
418         $TITLEs[] = '{--ADMIN_TASK_LIST_REFBANNER_ALL_TITLE--}';
419
420         //
421         // All activated referral banner
422         //
423         addSql("SELECT `id` FROM `{?_MYSQL_PREFIX?}_refbanner` WHERE `visible`='Y' ORDER BY `id` ASC");
424         $WHATs[] = 'refbanner';
425         $DESCRs[] = '{--ADMIN_TASK_LIST_REFBANNER_ACTIVE--}';
426         $TITLEs[] = '{--ADMIN_TASK_LIST_REFBANNER_ACTIVE_TITLE--}';
427
428         //
429         // All extensions
430         //
431         addSql('SELECT `id` FROM `{?_MYSQL_PREFIX?}_extensions` ORDER BY `id` ASC');
432         $WHATs[] = 'extensions';
433         $DESCRs[] = '{--ADMIN_TASK_LIST_EXTENSIONS_ALL--}';
434         $TITLEs[] = '{--ADMIN_TASK_LIST_EXTENSIONS_ALL_TITLE--}';
435
436         //
437         // All activated extensions
438         //
439         addSql("SELECT `id` FROM `{?_MYSQL_PREFIX?}_extensions` WHERE `ext_active`='Y' ORDER BY `id` ASC");
440         $WHATs[]  = 'extensions&amp;active=Y';
441         $DESCRs[] = '{--ADMIN_TASK_LIST_EXTENSIONS_ACTIVE--}';
442         $TITLEs[] = '{--ADMIN_TASK_LIST_EXTENSIONS_ACTIVE_TITLE--}';
443
444         if (isExtensionActive('sponsor')) {
445                 // List all sponsors
446                 addSql('SELECT `id` FROM `{?_MYSQL_PREFIX?}_sponsor_data` ORDER BY `id` ASC');
447                 $WHATs[]  = 'list_sponsor';
448                 $DESCRs[] = '{--ADMIN_TASK_LIST_SPONSOR--}';
449                 $TITLEs[] = '{--ADMIN_TASK_LIST_SPONSOR_TITLE--}';
450
451                 // List confirmed sponsor accounts
452                 addSql("SELECT `id` FROM `{?_MYSQL_PREFIX?}_sponsor_data` WHERE `status`='CONFIRMED' ORDER BY `id` ASC");
453                 $WHATs[]  = 'list_sponsor';
454                 $DESCRs[] = '{--ADMIN_TASK_LIST_SPONSOR_CONFIRMED--}';
455                 $TITLEs[] = '{--ADMIN_TASK_LIST_SPONSOR_CONFIRMED_TITLE--}';
456
457                 // List unconfirmed sponsor accounts
458                 addSql("SELECT `id` FROM `{?_MYSQL_PREFIX?}_sponsor_data` WHERE `status`='UNCONFIRMED' ORDER BY `id` ASC");
459                 $WHATs[]  = 'list_sponsor';
460                 $DESCRs[] = '{--ADMIN_TASK_LIST_SPONSOR_UNCONFIRMED--}';
461                 $TITLEs[] = '{--ADMIN_TASK_LIST_SPONSOR_UNCONFIRMED_TITLE--}';
462
463                 // List locked sponsor accounts
464                 addSql("SELECT `id` FROM `{?_MYSQL_PREFIX?}_sponsor_data` WHERE `status`='LOCKED' ORDER BY `id` ASC");
465                 $WHATs[]  = 'list_sponsor';
466                 $DESCRs[] = '{--ADMIN_TASK_LIST_SPONSOR_LOCKED--}';
467                 $TITLEs[] = '{--ADMIN_TASK_LIST_SPONSOR_LOCKED_TITLE--}';
468
469                 // List waiting sponsor accounts to be approved
470                 addSql("SELECT `id` FROM `{?_MYSQL_PREFIX?}_sponsor_data` WHERE `status`='PENDING' ORDER BY `id` ASC");
471                 $WHATs[]  = 'unlock_sponsor';
472                 $DESCRs[] = '{--ADMIN_TASK_LIST_SPONSOR_PENDING--}';
473                 $TITLEs[] = '{--ADMIN_TASK_LIST_SPONSOR_PENDING_TITLE--}';
474
475                 // Waiting payments
476                 addSql("SELECT `id` FROM `{?_MYSQL_PREFIX?}_sponsor_orders` WHERE `pay_status`='PENDING' ORDER BY `id` ASC");
477                 $WHATs[]  = 'list_sponsor_pays';
478                 $DESCRs[] = '{--ADMIN_TASK_LIST_SPONSOR_ORDERS--}';
479                 $TITLEs[] = '{--ADMIN_TASK_LIST_SPONSOR_ORDERS_TITLE--}';
480         } // END - if
481
482         if (isExtensionActive('country')) {
483                 // List country codes
484                 addSql('SELECT `id` FROM `{?_MYSQL_PREFIX?}_countries` ORDER BY `id` ASC');
485                 $WHATs[]  = 'list_country';
486                 $DESCRs[] = '{--ADMIN_TASK_LIST_COUNTRY--}';
487                 $TITLEs[] = '{--ADMIN_TASK_LIST_COUNTRY_TITLE--}';
488         } // END - if
489
490         if (isExtensionActive('theme')) {
491                 // List all themes
492                 addSql('SELECT `id` FROM `{?_MYSQL_PREFIX?}_themes` ORDER BY `id` ASC');
493                 $WHATs[]  = 'theme_edit';
494                 $DESCRs[] = '{--ADMIN_TASK_LIST_THEME_ALL--}';
495                 $TITLEs[] = '{--ADMIN_TASK_LIST_THEME_ALL_TITLE--}';
496
497                 // List active themes
498                 addSql("SELECT `id` FROM `{?_MYSQL_PREFIX?}_themes` WHERE `theme_active`='Y' ORDER BY `id` ASC");
499                 $WHATs[]  = 'theme_edit';
500                 $DESCRs[] = '{--ADMIN_TASK_LIST_THEME_ACTIVE--}';
501                 $TITLEs[] = '{--ADMIN_TASK_LIST_THEME_ACTIVE_TITLE--}';
502         } // END - if
503
504         if (isExtensionActive('admins')) {
505                 // List all administrator logins
506                 addSql('SELECT `id` FROM `{?_MYSQL_PREFIX?}_admins` ORDER BY `id` ASC');
507                 $WHATs[]  = 'admins_edit';
508                 $DESCRs[] = '{--ADMIN_TASK_LIST_ADMINS_ALL--}';
509                 $TITLEs[] = '{--ADMIN_TASK_LIST_ADMINS_ALL_TITLE--}';
510         } // END - if
511
512         if (isExtensionActive('surfbar')) {
513                 // List all URLs in surfbar
514                 addSql('SELECT `url_id` FROM `{?_MYSQL_PREFIX?}_surfbar_urls` ORDER BY `url_id` ASC');
515                 $WHATs[]  = 'list_surfbar_urls';
516                 $DESCRs[] = '{--ADMIN_TASK_LIST_SURFBAR_URLS_ALL--}';
517                 $TITLEs[] = '{--ADMIN_TASK_LIST_SURFBAR_URLS_ALL_TITLE--}';
518
519                 // List all pending URLs in surfbar
520                 addSql("SELECT `url_id` FROM `{?_MYSQL_PREFIX?}_surfbar_urls` WHERE `url_status`='PENDING' ORDER BY `url_id` ASC");
521                 $WHATs[]  = 'unlock_surfbar_urls';
522                 $DESCRs[] = '{--ADMIN_TASK_LIST_SURFBAR_URLS_PENDING--}';
523                 $TITLEs[] = '{--ADMIN_TASK_LIST_SURFBAR_URLS_PENDING_TITLE--}';
524         } // END - if
525
526         if (isExtensionInstalledAndNewer('sql_patches', '0.9.2')) {
527                 // Check for wrong "SERVER_NAME" entries
528                 addSql('SELECT `server_name_id` FROM `{?_MYSQL_PREFIX?}_server_name_log`');
529                 $DESCRs[] = '{--ADMIN_TASK_LIST_SERVER_NAME_LOG--}';
530                 $TITLEs[] = '{--ADMIN_TASK_LIST_SERVER_NAME_LOG_TITLE--}';
531                 $WHATs[]  = 'list_server_name';
532         } // END - if
533
534         if (isExtensionInstalled('network')) {
535                 // Check for HTTP logging entries
536                 addSql('SELECT `network_header_id` FROM `{?_MYSQL_PREFIX?}_network_header_logging`');
537                 $DESCRs[] = '{--ADMIN_TASK_LIST_NETWORK_HEADER_LOG--}';
538                 $TITLEs[] = '{--ADMIN_TASK_LIST_NETWORK_HEADER_LOG_TITLE--}';
539                 $WHATs[]  = 'list_network_http_header';
540         } // END - if
541
542         // Generate extra overview rows
543         $EXTRAS .= createExtraTaskRows($WHATs, $DESCRs, $TITLEs);
544
545         // If empty just keep a forced-space left for CSS issues
546         if (empty($EXTRAS)) {
547                 $EXTRAS = '&nbsp;';
548         } // END - if
549
550         // Add compiled string to constant for final template
551         $content['extra_table'] = $EXTRAS;
552
553         // Simply load the template... :-)
554         loadTemplate('admin_overview_task', FALSE, $content);
555 }
556
557 //
558 function createExtraTaskRows ($WHATs, $DESCRs, $TITLEs) {
559         // Init variables
560         $OUT = '';
561
562         // Sadly this cannot be rewritten to a filter... :(
563         foreach (getSqls() as $sqls) {
564                 // New format...
565                 foreach ($sqls as $key => $sql) {
566                         // Run SQL command, get line numbers and free memory
567                         $result = sqlQuery($sql, __FUNCTION__, __LINE__);
568
569                         // Prepare array for output
570                         $content = array(
571                                 'row_descr' => $DESCRs[$key],
572                                 'bottom'    => '',
573                         );
574
575                         // Rewrite CSS class if not last entry is reached
576                         if ($key < (count($sqls) - 1)) {
577                                 $content['bottom'] = 'bottom';
578                         } // END - if
579
580                         if ((!ifSqlHasZeroNums($result)) && (!empty($WHATs[$key]))) {
581                                 if (empty($TITLEs[$key])) {
582                                         $TITLEs[$key] = '{--ADMIN_TASK_UNKNOWN_LIST_TITLE--}';
583                                 } // END - if
584                                 $content['row_link'] = '<a href="{%url=modules.php?module=admin&amp;what=' . $WHATs[$key] . '%}" title="' . $TITLEs[$key] . '">' . sqlNumRows($result) . '</a>';
585                         } else {
586                                 $content['row_link'] = '0';
587                         }
588
589                         // Free result
590                         sqlFreeResult($result);
591
592                         // And insert the final string into extras template
593                         $OUT .= loadTemplate('admin_overview_task_rows', TRUE, $content);
594                 } // END- foreach
595         } // END - foreach
596
597         // Return output in the template
598         return loadTemplate('admin_overview_task_extras', TRUE, $OUT);
599 }
600
601 // [EOF]
602 ?>