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