Bad things are now 'classified' as bad (CSS class 'bad' is being used instead of...
[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 - 2011 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',
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         //
92         // First check for all account status seperately
93         //
94         // Confirmed accounts
95         $value = getTotalConfirmedUser();
96
97         if ($value > 0) {
98                 $content['confirmed_members'] = '<a href="{%url=modules.php?module=admin&amp;what=list_user&amp;status=confirmed%}">' . $value . '</a>';
99         } // END - if
100
101         // Unconfirmed accounts
102         $value = getTotalUnconfirmedUser();
103
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         // And 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
114         if (isExtensionInstalledAndNewer('user', '0.3.4')) {
115                 // And random refid
116                 $value = getTotalRandomRefidUser();
117                 if ($value > 0) {
118                         $content['random_refid'] = '<a href="{%url=modules.php?module=admin&amp;what=list_user&amp;mode=random_refid%}">' . $value . '</a>';
119                 } // END - if
120         } // END - if
121
122         //
123         // Unassigned tasks
124         //
125         $value = countSumTotalData(0, 'task_system', 'id', 'assigned_admin', true, " AND `status` != 'DELETED'");
126
127         if ($value > 0) {
128                 $content['new_tasks'] = '<a href="{%url=modules.php?module=admin&amp;what=list_task&amp;type=unassigned%}">' . $value . '</a>';
129         } // END - if
130
131         //
132         // Closed tasks
133         //
134         $value = countSumTotalData('CLOSED', 'task_system', 'id', 'status', true);
135
136         if ($value > 0) {
137                 $content['closed_tasks'] = '<a href="{%url=modules.php?module=admin&amp;what=list_task&amp;type=closed%}">' . $value . '</a>';
138         } // END - if
139
140         //
141         // Deleted tasks
142         //
143         $value = countSumTotalData('DELETED', 'task_system', 'id', 'status', true);
144
145         if ($value > 0) {
146                 $content['deleted_tasks'] = '<a href="{%url=modules.php?module=admin&amp;what=list_task&amp;type=deleted%}">' . $value . '</a>';
147         } // END - if
148
149         //
150         // Solved tasks
151         //
152         $value = countSumTotalData('SOLVED', 'task_system', 'id', 'status', true, sprintf(" AND `assigned_admin`=%s", getCurrentAdminId()));
153
154         if ($value > 0) {
155                 $content['solved_tasks'] = '<a href="{%url=modules.php?module=admin&amp;what=list_task&amp;type=solved%}">' . $value . '</a>';
156         } // END - if
157
158         //
159         // Your tasks
160         //
161         $value = countSumTotalData(getCurrentAdminId(), 'task_system', 'id', 'assigned_admin', true, " AND `status`='NEW' AND task_type != 'EXTENSION_UPDATE'");
162
163         if ($value > 0) {
164                 $content['your_tasks'] = '<a href="{%url=modules.php?module=admin&amp;what=list_task%}">' . $value . '</a>';
165         } // END - if
166
167         //
168         // Mails waiting to be approved
169         //
170         $value = countSumTotalData('ADMIN', 'pool', 'id', 'data_type', true);
171
172         if ($value > 0) {
173                 $content['pending_mails'] = '<a href="{%url=modules.php?module=admin&amp;what=unlock_emails%}">' . $value . '</a>';
174         } // END - if
175
176         //
177         // Unfinished mail orders
178         //
179         $value = countSumTotalData('TEMP', 'pool', 'id', 'data_type', true);
180
181         if ($value > 0) {
182                 $content['canceled_mails'] = '<a href="{%url=modules.php?module=admin&amp;what=email_details%}">' . $value . '</a>';
183         } // END - if
184
185         //
186         // Sent mail orders
187         //
188         $value = countSumTotalData('SEND', 'pool', 'id', 'data_type', true);
189
190         if ($value > 0) {
191                 $content['send_emails'] = '<a href="{%url=modules.php?module=admin&amp;what=email_archiv%}">' . $value . '</a>';
192         } // END - if
193
194         //
195         // Autopurged mails
196         //
197         if (isExtensionActive('autopurge')) {
198                 // Get auto-purged mails
199                 $value = countSumTotalData('DELETED', 'pool', 'id', 'data_type', true);
200
201                 if ($value > 0) {
202                         $content['purged_mails'] = '<a href="{%url=modules.php?module=admin&amp;what=email_details%}">' . $value . '</a>';
203                 } // END - if
204
205                 //
206                 // Autopurged bonus mails
207                 //
208                 if (isExtensionInstalledAndNewer('bonus', '0.1.8')) {
209                         // Get auto-purged bonus mails
210                         $value = countSumTotalData('DELETED', 'bonus', 'id', 'data_type', true);
211
212                         if ($value > 0) {
213                                 $content['purged_bonus_mails'] = '<a href="{%url=modules.php?module=admin&amp;what=email_details%}">' . $value . '</a>';
214                         } // END - if
215                 } elseif (isExtensionActive('bonus')) {
216                         $content['purged_bonus_mails'] = '{%message,ADMIN_EXTENSION_BONUS_OUTDATED=0.1.8%}';
217                 } else {
218                         $content['purged_bonus_mails'] = '<span class="bad">{--ADMIN_EXTENSION_BONUS_404--}</span>';
219                 }
220         } else {
221                 $content['purged_bonus_mails'] = '<span class="bad">{--ADMIN_EXTENSION_AUTOPURGE_404--}</span>';
222                 $content['purged_mails'] = '<span class="bad">{--ADMIN_EXTENSION_AUTOPURGE_404--}</span>';
223         }
224
225         //
226         // Sent bonus mails
227         //
228         if (isExtensionInstalledAndNewer('bonus', '0.1.8')) {
229                 // Get sent bonus mails (but not notifications)
230                 $value = countSumTotalData('SEND', 'bonus', 'id', 'data_type', true, " AND `is_notify`='N'");
231
232                 if ($value > 0) {
233                         $content['send_bonus_mails'] = '<a href="{%url=modules.php?module=admin&amp;what=email_details%}">' . $value . '</a>';
234                 } // END - if
235         } elseif (isExtensionActive('bonus')) {
236                 $content['send_bonus_mails'] = '{%message,ADMIN_EXTENSION_BONUS_OUTDATED=0.1.8%}';
237         } else {
238                 $content['send_bonus_mails'] = '{--ADMIN_EXTENSION_BONUS_404--}';
239         }
240
241         // Both extensions must be there
242         if ((isExtensionActive('autopurge')) && (isExtensionActive('user'))) {
243                 // Start finding them...
244                 $EXCLUDE_LIST = '';
245
246                 // Check for more extensions
247                 // @TODO These can be rewritten to filter
248                 if (isValidUserId(getDefRefid()))              $EXCLUDE_LIST .= ' AND d.`userid` != {?def_refid?}';
249                 if (isExtensionActive('beg'))                  $EXCLUDE_LIST .= ' AND d.`userid` != {?beg_userid?}';
250                 if (isExtensionActive('bonus'))                $EXCLUDE_LIST .= ' AND d.`userid` != {?bonus_userid?}';
251                 if (isExtensionActive('doubler'))              $EXCLUDE_LIST .= ' AND d.`userid` != {?doubler_userid?}';
252                 if (isExtensionInstalledAndNewer('holiday', '0.1.3')) {
253                         // Recent ext-holiday found
254                         $EXCLUDE_LIST .= " AND d.`holiday_active`='N'";
255                 } // END - if
256
257                 // Check for all accounts
258                 addSql("SELECT
259         d.userid, d.email, d.last_online
260 FROM
261         `{?_MYSQL_PREFIX?}_user_data` AS d
262 WHERE
263         d.`status`='CONFIRMED' AND
264         (UNIX_TIMESTAMP() - d.`joined`) >= {?ap_inactive_since?} AND
265         (UNIX_TIMESTAMP() - d.`last_online`) >= {?ap_inactive_since?} AND
266         (UNIX_TIMESTAMP() - d.`ap_notified`) >= {?ap_inactive_since?}
267 ".$EXCLUDE_LIST."
268 ORDER BY
269         d.userid ASC");
270                 $WHATs[]  = 'list_autopurge';
271                 $DESCRs[] = '{--ADMIN_TASK_INACTIVE_AUTOPURGE--}';
272                 $TITLEs[] = '{--ADMIN_TASK_INACTIVE_AUTOPURGE_TITLE--}';
273         }
274
275         if ((isExtensionInstalledAndNewer('sql_patches', '0.3.4')) && (isExtensionActive('user'))) {
276                 // Check for accounts without referral
277                 addSql("SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `refid`=0 OR `refid` IS NULL ORDER BY `userid` ASC");
278                 $DESCRs[] = '{--ADMIN_TASK_LIST_ACCOUNT_NO_REFERRAL--}';
279                 $TITLEs[] = '{--ADMIN_TASK_LIST_ACCOUNT_NO_REFERRAL_TITLE--}';
280                 $WHATs[]  = 'list_user&amp;mode=norefs';
281         } // END - if
282
283         if (isExtensionActive('payout')) {
284                 // List new payout requests
285                 addSql("SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_payouts` WHERE `status`='NEW' ORDER BY `userid` ASC");
286                 $WHATs[]  = 'list_payouts';
287                 $DESCRs[] = '{--ADMIN_TASK_LIST_PAYOUTS_WAITING--}';
288                 $TITLEs[] = '{--ADMIN_TASK_LIST_PAYOUTS_WAITING_TITLE--}';
289                 addSql('SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_payouts` ORDER BY `userid` ASC');
290                 $WHATs[]  = 'list_payouts';
291                 $DESCRs[] = '{--ADMIN_TASK_LIST_PAYOUTS_ALL--}';
292                 $TITLEs[] = '{--ADMIN_TASK_LIST_PAYOUTS_ALL_TITLE--}';
293         } // END - if
294
295         if (isExtensionActive('wernis')) {
296                 // List new wernis requests
297                 addSql('SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_wernis` ORDER BY `userid` ASC');
298                 $WHATs[]  = 'list_wernis';
299                 $DESCRs[] = '{--ADMIN_TASK_LIST_WERNIS_ALL--}';
300                 $TITLEs[] = '{--ADMIN_TASK_LIST_WERNIS_ALL_TITLE--}';
301         } // END - if
302
303         if (isExtensionActive('primera')) {
304                 // List new primera requests
305                 addSql('SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_primera` ORDER BY `userid` ASC');
306                 $WHATs[]  = 'list_primera';
307                 $DESCRs[] = '{--ADMIN_TASK_LIST_PRIMERA_ALL--}';
308                 $TITLEs[] = '{--ADMIN_TASK_LIST_PRIMERA_ALL_TITLE--}';
309         } // END - if
310
311         if (isExtensionActive('holiday')) {
312                 // List holiday requests
313                 addSql('SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_holidays` ORDER BY `userid` ASC');
314                 $WHATs[]  = 'list_holiday';
315                 $DESCRs[] = '{--ADMIN_TASK_LIST_HOLIDAYS--}';
316                 $TITLEs[] = '{--ADMIN_TASK_LIST_HOLIDAYS_TITLE--}';
317         } // END - if
318
319         if (isExtensionInstalledAndNewer('bonus', '0.8.7')) {
320                 // List all notifications
321                 addSql("SELECT `id` FROM `{?_MYSQL_PREFIX?}_bonus` WHERE `is_notify`='Y' ORDER BY `timestamp` DESC");
322                 $WHATs[]  = 'list_notifications';
323                 $DESCRs[] = '{--ADMIN_TASK_LIST_NOTIFICATIONS--}';
324                 $TITLEs[] = '{--ADMIN_TASK_LIST_NOTIFICATIONS_TITLE--}';
325         } // END - if
326
327         // Both extensions must be there
328         if ((isExtensionInstalledAndNewer('bonus', '0.2.3')) && (isExtensionActive('user'))) {
329                 // Get more columns
330                 $add = runFilterChain('add_bonus_points_user_columns', '');
331
332                 // Active rallye, so add more point columns, if not empty
333                 $USE = '`turbo_bonus`';
334                 if (!empty($add)) {
335                         $USE = '(0' . $add . ')';
336                 } // END - if
337
338                 // Init variable
339                 $lastOnline = '';
340
341                 // Autopurge installed?
342                 if ((isExtensionActive('autopurge')) && (isAutopurgeInactiveEnabled()) && (getApInactiveSince() > 0)) {
343                         // Use last online timestamp to keep inactive members away from here
344                         $lastOnline   = ' AND (UNIX_TIMESTAMP() - `last_online`) < {?ap_inactive_since?}';
345                 } // END - if
346
347                 addSql("SELECT
348         " . $USE . " AS `points`
349 FROM
350         `{?_MYSQL_PREFIX?}_user_data`
351 WHERE
352         `status`='CONFIRMED' AND
353         " . $USE . " > 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         }
362
363         // Again both extensions must be there
364         if ((isExtensionInstalledAndNewer('beg', '0.1.2')) && (isExtensionActive('user'))) {
365                 // ----- Begging rallye -----
366
367                 // Init variable
368                 $lastOnline = '';
369
370                 // Autopurge installed?
371                 if ((isExtensionActive('autopurge')) && (isAutopurgeInactiveEnabled()) && (getApInactiveSince() > 0)) {
372                         // Use last online timestamp to keep inactive members away from here
373                         $lastOnline   = ' AND (UNIX_TIMESTAMP() - `last_online`) < {?ap_inactive_since?}';
374                 } // END - if
375
376                 addSql("SELECT
377         `userid`
378 FROM
379         `{?_MYSQL_PREFIX?}_user_data`
380 WHERE
381         `status`='CONFIRMED' AND
382         `beg_points` > 0
383         ".$lastOnline."
384 ORDER BY
385         `beg_points` DESC,
386         `userid` ASC");
387                 $WHATs[]  = 'list_beg';
388                 $DESCRs[] = '{--ADMIN_TASK_LIST_BEG--}';
389                 $TITLEs[] = '{--ADMIN_TASK_LIST_BEG_TITLE--}';
390         } // END - if
391
392         if (isExtensionActive('doubler')) {
393                 // List waiting payouts
394                 addSql("SELECT `id` FROM `{?_MYSQL_PREFIX?}_doubler` WHERE `completed`='N' ORDER BY `id` ASC");
395                 $WHATs[]  = 'list_doubler&amp;mode=waiting&amp;select=all';
396                 $DESCRs[] = '{--ADMIN_TASK_LIST_DOUBLER_WAITING--}';
397                 $TITLEs[] = '{--ADMIN_TASK_LIST_DOUBLER_WAITING_TITLE--}';
398                 addSql('SELECT `id` FROM `{?_MYSQL_PREFIX?}_doubler` ORDER BY `id` ASC');
399                 $WHATs[]  = 'list_doubler';
400                 $DESCRs[] = '{--ADMIN_TASK_LIST_DOUBLER_ALL--}';
401                 $TITLEs[] = '{--ADMIN_TASK_LIST_DOUBLER_ALL_TITLE--}';
402         } // END - if
403
404         //
405         // All referral banner
406         //
407         addSql('SELECT `id` FROM `{?_MYSQL_PREFIX?}_refbanner` ORDER BY `id` ASC');
408         $WHATs[] = 'refbanner';
409         $DESCRs[] = '{--ADMIN_TASK_LIST_REFBANNER_ALL--}';
410         $TITLEs[] = '{--ADMIN_TASK_LIST_REFBANNER_ALL_TITLE--}';
411
412         //
413         // All activated referral banner
414         //
415         addSql("SELECT `id` FROM `{?_MYSQL_PREFIX?}_refbanner` WHERE `visible`='Y' ORDER BY `id` ASC");
416         $WHATs[] = 'refbanner';
417         $DESCRs[] = '{--ADMIN_TASK_LIST_REFBANNER_ACTIVE--}';
418         $TITLEs[] = '{--ADMIN_TASK_LIST_REFBANNER_ACTIVE_TITLE--}';
419
420         //
421         // All extensions
422         //
423         addSql('SELECT `id` FROM `{?_MYSQL_PREFIX?}_extensions` ORDER BY `id` ASC');
424         $WHATs[] = 'extensions';
425         $DESCRs[] = '{--ADMIN_TASK_LIST_EXTENSIONS_ALL--}';
426         $TITLEs[] = '{--ADMIN_TASK_LIST_EXTENSIONS_ALL_TITLE--}';
427
428         //
429         // All activated extensions
430         //
431         addSql("SELECT `id` FROM `{?_MYSQL_PREFIX?}_extensions` WHERE `ext_active`='Y' ORDER BY `id` ASC");
432         $WHATs[]  = 'extensions&amp;active=Y';
433         $DESCRs[] = '{--ADMIN_TASK_LIST_EXTENSIONS_ACTIVE--}';
434         $TITLEs[] = '{--ADMIN_TASK_LIST_EXTENSIONS_ACTIVE_TITLE--}';
435
436         if (isExtensionActive('sponsor')) {
437                 // List all sponsors
438                 addSql('SELECT `id` FROM `{?_MYSQL_PREFIX?}_sponsor_data` ORDER BY `id` ASC');
439                 $WHATs[]  = 'list_sponsor';
440                 $DESCRs[] = '{--ADMIN_TASK_LIST_SPONSOR--}';
441                 $TITLEs[] = '{--ADMIN_TASK_LIST_SPONSOR_TITLE--}';
442
443                 // List confirmed sponsor accounts
444                 addSql("SELECT `id` FROM `{?_MYSQL_PREFIX?}_sponsor_data` WHERE `status`='CONFIRMED' ORDER BY `id` ASC");
445                 $WHATs[]  = 'list_sponsor';
446                 $DESCRs[] = '{--ADMIN_TASK_LIST_SPONSOR_CONFIRMED--}';
447                 $TITLEs[] = '{--ADMIN_TASK_LIST_SPONSOR_CONFIRMED_TITLE--}';
448
449                 // List unconfirmed sponsor accounts
450                 addSql("SELECT `id` FROM `{?_MYSQL_PREFIX?}_sponsor_data` WHERE `status`='UNCONFIRMED' ORDER BY `id` ASC");
451                 $WHATs[]  = 'list_sponsor';
452                 $DESCRs[] = '{--ADMIN_TASK_LIST_SPONSOR_UNCONFIRMED--}';
453                 $TITLEs[] = '{--ADMIN_TASK_LIST_SPONSOR_UNCONFIRMED_TITLE--}';
454
455                 // List locked sponsor accounts
456                 addSql("SELECT `id` FROM `{?_MYSQL_PREFIX?}_sponsor_data` WHERE `status`='LOCKED' ORDER BY `id` ASC");
457                 $WHATs[]  = 'list_sponsor';
458                 $DESCRs[] = '{--ADMIN_TASK_LIST_SPONSOR_LOCKED--}';
459                 $TITLEs[] = '{--ADMIN_TASK_LIST_SPONSOR_LOCKED_TITLE--}';
460
461                 // List waiting sponsor accounts to be approved
462                 addSql("SELECT `id` FROM `{?_MYSQL_PREFIX?}_sponsor_data` WHERE `status`='PENDING' ORDER BY `id` ASC");
463                 $WHATs[]  = 'unlock_sponsor';
464                 $DESCRs[] = '{--ADMIN_TASK_LIST_SPONSOR_PENDING--}';
465                 $TITLEs[] = '{--ADMIN_TASK_LIST_SPONSOR_PENDING_TITLE--}';
466
467                 // Waiting payments
468                 addSql("SELECT `id` FROM `{?_MYSQL_PREFIX?}_sponsor_orders` WHERE `pay_status`='PENDING' ORDER BY `id` ASC");
469                 $WHATs[]  = 'list_sponsor_pays';
470                 $DESCRs[] = '{--ADMIN_TASK_LIST_SPONSOR_ORDERS--}';
471                 $TITLEs[] = '{--ADMIN_TASK_LIST_SPONSOR_ORDERS_TITLE--}';
472         } // END - if
473
474         if (isExtensionActive('country')) {
475                 // List country codes
476                 addSql('SELECT `id` FROM `{?_MYSQL_PREFIX?}_countries` ORDER BY `id` ASC');
477                 $WHATs[]  = 'list_country';
478                 $DESCRs[] = '{--ADMIN_TASK_LIST_COUNTRY--}';
479                 $TITLEs[] = '{--ADMIN_TASK_LIST_COUNTRY_TITLE--}';
480         } // END - if
481
482         if (isExtensionActive('theme')) {
483                 // List all themes
484                 addSql('SELECT `id` FROM `{?_MYSQL_PREFIX?}_themes` ORDER BY `id` ASC');
485                 $WHATs[]  = 'theme_edit';
486                 $DESCRs[] = '{--ADMIN_TASK_LIST_THEME_ALL--}';
487                 $TITLEs[] = '{--ADMIN_TASK_LIST_THEME_ALL_TITLE--}';
488
489                 // List active themes
490                 addSql("SELECT `id` FROM `{?_MYSQL_PREFIX?}_themes` WHERE `theme_active`='Y' ORDER BY `id` ASC");
491                 $WHATs[]  = 'theme_edit';
492                 $DESCRs[] = '{--ADMIN_TASK_LIST_THEME_ACTIVE--}';
493                 $TITLEs[] = '{--ADMIN_TASK_LIST_THEME_ACTIVE_TITLE--}';
494         } // END - if
495
496         if (isExtensionActive('admins')) {
497                 // List all administrator logins
498                 addSql('SELECT `id` FROM `{?_MYSQL_PREFIX?}_admins` ORDER BY `id` ASC');
499                 $WHATs[]  = 'admins_edit';
500                 $DESCRs[] = '{--ADMIN_TASK_LIST_ADMINS_ALL--}';
501                 $TITLEs[] = '{--ADMIN_TASK_LIST_ADMINS_ALL_TITLE--}';
502         } // END - if
503
504         if (isExtensionActive('surfbar')) {
505                 // List all URLs in surfbar
506                 addSql('SELECT `url_id` FROM `{?_MYSQL_PREFIX?}_surfbar_urls` ORDER BY `url_id` ASC');
507                 $WHATs[]  = 'list_surfbar_urls';
508                 $DESCRs[] = '{--ADMIN_TASK_LIST_SURFBAR_URLS_ALL--}';
509                 $TITLEs[] = '{--ADMIN_TASK_LIST_SURFBAR_URLS_ALL_TITLE--}';
510
511                 // List all pending URLs in surfbar
512                 addSql("SELECT `url_id` FROM `{?_MYSQL_PREFIX?}_surfbar_urls` WHERE `url_status`='PENDING' ORDER BY `url_id` ASC");
513                 $WHATs[]  = 'unlock_surfbar_urls';
514                 $DESCRs[] = '{--ADMIN_TASK_LIST_SURFBAR_URLS_PENDING--}';
515                 $TITLEs[] = '{--ADMIN_TASK_LIST_SURFBAR_URLS_PENDING_TITLE--}';
516         } // END - if
517
518         // Generate extra overview rows
519         $EXTRAS .= createExtraTaskRows($WHATs, $DESCRs, $TITLEs);
520
521         // If empty just keep a forced-space left for CSS issues
522         if (empty($EXTRAS)) {
523                 $EXTRAS = '&nbsp;';
524         } // END - if
525
526         // Add compiled string to constant for final template
527         $content['extra_table'] = $EXTRAS;
528
529         // Simply load the template... :-)
530         loadTemplate('admin_overview_task', false, $content);
531 }
532
533 //
534 function createExtraTaskRows ($WHATs, $DESCRs, $TITLEs) {
535         // Init variables
536         $OUT = '';
537
538         // Sadly this cannot be rewritten to a filter... :(
539         foreach (getSqls() as $sqls) {
540                 // New format...
541                 foreach ($sqls as $key => $sql) {
542                         // Run SQL command, get line numbers and free memory
543                         $result = SQL_QUERY($sql, __FUNCTION__, __LINE__);
544
545                         // Prepare array for output
546                         $content = array(
547                                 'row_descr' => $DESCRs[$key],
548                                 'bottom'    => '',
549                         );
550
551                         // Rewrite CSS class if not last entry is reached
552                         if ($key < (count($sqls) - 1)) {
553                                 $content['bottom'] = 'bottom';
554                         } // END - if
555
556                         if ((!SQL_HASZERONUMS($result)) && (!empty($WHATs[$key]))) {
557                                 if (empty($TITLEs[$key])) {
558                                         $TITLEs[$key] = '{--ADMIN_TASK_UNKNOWN_LIST_TITLE--}';
559                                 } // END - if
560                                 $content['row_link'] = '<a href="{%url=modules.php?module=admin&amp;what=' . $WHATs[$key] . '%}" title="' . $TITLEs[$key] . '">' . SQL_NUMROWS($result) . '</a>';
561                         } else {
562                                 $content['row_link'] = '0';
563                         }
564
565                         // Free result
566                         SQL_FREERESULT($result);
567
568                         // And insert the final string into extras template
569                         $OUT .= loadTemplate('admin_overview_task_rows', true, $content);
570                 } // END- foreach
571         } // END - foreach
572
573         // Return output in the template
574         return loadTemplate('admin_overview_task_extras', true, $OUT);
575 }
576
577 // [EOF]
578 ?>