Heacy rewrite/cleanup:
[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 = 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                 addSql("SELECT
352         " . $pointsColumns . " AS `points`
353 FROM
354         `{?_MYSQL_PREFIX?}_user_data`
355 WHERE
356         `status`='CONFIRMED' AND
357         " . $pointsColumns . " > 0
358         " . $lastOnline . "
359 ORDER BY
360         `points` DESC,
361         `userid` ASC");
362                 $WHATs[]  = 'list_bonus';
363                 $DESCRs[] = '{--ADMIN_TASK_LIST_BONUS--}';
364                 $TITLEs[] = '{--ADMIN_TASK_LIST_BONUS_TITLE--}';
365         }
366
367         // Again both extensions must be there
368         if ((isExtensionInstalledAndNewer('beg', '0.1.2')) && (isExtensionActive('user'))) {
369                 // ----- Begging rallye -----
370
371                 // Init variable
372                 $lastOnline = '';
373
374                 // Autopurge installed?
375                 if ((isExtensionActive('autopurge')) && (isAutopurgeInactiveEnabled()) && (getApInactiveSince() > 0)) {
376                         // Use last online timestamp to keep inactive members away from here
377                         $lastOnline   = ' AND (UNIX_TIMESTAMP() - `last_online`) < {?ap_inactive_since?}';
378                 } // END - if
379
380                 addSql("SELECT
381         `userid`
382 FROM
383         `{?_MYSQL_PREFIX?}_user_data`
384 WHERE
385         `status`='CONFIRMED' AND
386         `beg_points` > 0
387         ".$lastOnline."
388 ORDER BY
389         `beg_points` DESC,
390         `userid` ASC");
391                 $WHATs[]  = 'list_beg';
392                 $DESCRs[] = '{--ADMIN_TASK_LIST_BEG--}';
393                 $TITLEs[] = '{--ADMIN_TASK_LIST_BEG_TITLE--}';
394         } // END - if
395
396         if (isExtensionActive('doubler')) {
397                 // List waiting payouts
398                 addSql("SELECT `id` FROM `{?_MYSQL_PREFIX?}_doubler` WHERE `completed`='N' ORDER BY `id` ASC");
399                 $WHATs[]  = 'list_doubler&amp;do=waiting&amp;select=all';
400                 $DESCRs[] = '{--ADMIN_TASK_LIST_DOUBLER_WAITING--}';
401                 $TITLEs[] = '{--ADMIN_TASK_LIST_DOUBLER_WAITING_TITLE--}';
402                 addSql('SELECT `id` FROM `{?_MYSQL_PREFIX?}_doubler` ORDER BY `id` ASC');
403                 $WHATs[]  = 'list_doubler';
404                 $DESCRs[] = '{--ADMIN_TASK_LIST_DOUBLER_ALL--}';
405                 $TITLEs[] = '{--ADMIN_TASK_LIST_DOUBLER_ALL_TITLE--}';
406         } // END - if
407
408         //
409         // All referral banner
410         //
411         addSql('SELECT `id` FROM `{?_MYSQL_PREFIX?}_refbanner` ORDER BY `id` ASC');
412         $WHATs[] = 'refbanner';
413         $DESCRs[] = '{--ADMIN_TASK_LIST_REFBANNER_ALL--}';
414         $TITLEs[] = '{--ADMIN_TASK_LIST_REFBANNER_ALL_TITLE--}';
415
416         //
417         // All activated referral banner
418         //
419         addSql("SELECT `id` FROM `{?_MYSQL_PREFIX?}_refbanner` WHERE `visible`='Y' ORDER BY `id` ASC");
420         $WHATs[] = 'refbanner';
421         $DESCRs[] = '{--ADMIN_TASK_LIST_REFBANNER_ACTIVE--}';
422         $TITLEs[] = '{--ADMIN_TASK_LIST_REFBANNER_ACTIVE_TITLE--}';
423
424         //
425         // All extensions
426         //
427         addSql('SELECT `id` FROM `{?_MYSQL_PREFIX?}_extensions` ORDER BY `id` ASC');
428         $WHATs[] = 'extensions';
429         $DESCRs[] = '{--ADMIN_TASK_LIST_EXTENSIONS_ALL--}';
430         $TITLEs[] = '{--ADMIN_TASK_LIST_EXTENSIONS_ALL_TITLE--}';
431
432         //
433         // All activated extensions
434         //
435         addSql("SELECT `id` FROM `{?_MYSQL_PREFIX?}_extensions` WHERE `ext_active`='Y' ORDER BY `id` ASC");
436         $WHATs[]  = 'extensions&amp;active=Y';
437         $DESCRs[] = '{--ADMIN_TASK_LIST_EXTENSIONS_ACTIVE--}';
438         $TITLEs[] = '{--ADMIN_TASK_LIST_EXTENSIONS_ACTIVE_TITLE--}';
439
440         if (isExtensionActive('sponsor')) {
441                 // List all sponsors
442                 addSql('SELECT `id` FROM `{?_MYSQL_PREFIX?}_sponsor_data` ORDER BY `id` ASC');
443                 $WHATs[]  = 'list_sponsor';
444                 $DESCRs[] = '{--ADMIN_TASK_LIST_SPONSOR--}';
445                 $TITLEs[] = '{--ADMIN_TASK_LIST_SPONSOR_TITLE--}';
446
447                 // List confirmed sponsor accounts
448                 addSql("SELECT `id` FROM `{?_MYSQL_PREFIX?}_sponsor_data` WHERE `status`='CONFIRMED' ORDER BY `id` ASC");
449                 $WHATs[]  = 'list_sponsor';
450                 $DESCRs[] = '{--ADMIN_TASK_LIST_SPONSOR_CONFIRMED--}';
451                 $TITLEs[] = '{--ADMIN_TASK_LIST_SPONSOR_CONFIRMED_TITLE--}';
452
453                 // List unconfirmed sponsor accounts
454                 addSql("SELECT `id` FROM `{?_MYSQL_PREFIX?}_sponsor_data` WHERE `status`='UNCONFIRMED' ORDER BY `id` ASC");
455                 $WHATs[]  = 'list_sponsor';
456                 $DESCRs[] = '{--ADMIN_TASK_LIST_SPONSOR_UNCONFIRMED--}';
457                 $TITLEs[] = '{--ADMIN_TASK_LIST_SPONSOR_UNCONFIRMED_TITLE--}';
458
459                 // List locked sponsor accounts
460                 addSql("SELECT `id` FROM `{?_MYSQL_PREFIX?}_sponsor_data` WHERE `status`='LOCKED' ORDER BY `id` ASC");
461                 $WHATs[]  = 'list_sponsor';
462                 $DESCRs[] = '{--ADMIN_TASK_LIST_SPONSOR_LOCKED--}';
463                 $TITLEs[] = '{--ADMIN_TASK_LIST_SPONSOR_LOCKED_TITLE--}';
464
465                 // List waiting sponsor accounts to be approved
466                 addSql("SELECT `id` FROM `{?_MYSQL_PREFIX?}_sponsor_data` WHERE `status`='PENDING' ORDER BY `id` ASC");
467                 $WHATs[]  = 'unlock_sponsor';
468                 $DESCRs[] = '{--ADMIN_TASK_LIST_SPONSOR_PENDING--}';
469                 $TITLEs[] = '{--ADMIN_TASK_LIST_SPONSOR_PENDING_TITLE--}';
470
471                 // Waiting payments
472                 addSql("SELECT `id` FROM `{?_MYSQL_PREFIX?}_sponsor_orders` WHERE `pay_status`='PENDING' ORDER BY `id` ASC");
473                 $WHATs[]  = 'list_sponsor_pays';
474                 $DESCRs[] = '{--ADMIN_TASK_LIST_SPONSOR_ORDERS--}';
475                 $TITLEs[] = '{--ADMIN_TASK_LIST_SPONSOR_ORDERS_TITLE--}';
476         } // END - if
477
478         if (isExtensionActive('country')) {
479                 // List country codes
480                 addSql('SELECT `id` FROM `{?_MYSQL_PREFIX?}_countries` ORDER BY `id` ASC');
481                 $WHATs[]  = 'list_country';
482                 $DESCRs[] = '{--ADMIN_TASK_LIST_COUNTRY--}';
483                 $TITLEs[] = '{--ADMIN_TASK_LIST_COUNTRY_TITLE--}';
484         } // END - if
485
486         if (isExtensionActive('theme')) {
487                 // List all themes
488                 addSql('SELECT `id` FROM `{?_MYSQL_PREFIX?}_themes` ORDER BY `id` ASC');
489                 $WHATs[]  = 'theme_edit';
490                 $DESCRs[] = '{--ADMIN_TASK_LIST_THEME_ALL--}';
491                 $TITLEs[] = '{--ADMIN_TASK_LIST_THEME_ALL_TITLE--}';
492
493                 // List active themes
494                 addSql("SELECT `id` FROM `{?_MYSQL_PREFIX?}_themes` WHERE `theme_active`='Y' ORDER BY `id` ASC");
495                 $WHATs[]  = 'theme_edit';
496                 $DESCRs[] = '{--ADMIN_TASK_LIST_THEME_ACTIVE--}';
497                 $TITLEs[] = '{--ADMIN_TASK_LIST_THEME_ACTIVE_TITLE--}';
498         } // END - if
499
500         if (isExtensionActive('admins')) {
501                 // List all administrator logins
502                 addSql('SELECT `id` FROM `{?_MYSQL_PREFIX?}_admins` ORDER BY `id` ASC');
503                 $WHATs[]  = 'admins_edit';
504                 $DESCRs[] = '{--ADMIN_TASK_LIST_ADMINS_ALL--}';
505                 $TITLEs[] = '{--ADMIN_TASK_LIST_ADMINS_ALL_TITLE--}';
506         } // END - if
507
508         if (isExtensionActive('surfbar')) {
509                 // List all URLs in surfbar
510                 addSql('SELECT `url_id` FROM `{?_MYSQL_PREFIX?}_surfbar_urls` ORDER BY `url_id` ASC');
511                 $WHATs[]  = 'list_surfbar_urls';
512                 $DESCRs[] = '{--ADMIN_TASK_LIST_SURFBAR_URLS_ALL--}';
513                 $TITLEs[] = '{--ADMIN_TASK_LIST_SURFBAR_URLS_ALL_TITLE--}';
514
515                 // List all pending URLs in surfbar
516                 addSql("SELECT `url_id` FROM `{?_MYSQL_PREFIX?}_surfbar_urls` WHERE `url_status`='PENDING' ORDER BY `url_id` ASC");
517                 $WHATs[]  = 'unlock_surfbar_urls';
518                 $DESCRs[] = '{--ADMIN_TASK_LIST_SURFBAR_URLS_PENDING--}';
519                 $TITLEs[] = '{--ADMIN_TASK_LIST_SURFBAR_URLS_PENDING_TITLE--}';
520         } // END - if
521
522         if (isExtensionInstalledAndNewer('sql_patches', '0.9.2')) {
523                 // Check for wrong "SERVER_NAME" entries
524                 addSql('SELECT `server_name_id` FROM `{?_MYSQL_PREFIX?}_server_name_log`');
525                 $DESCRs[] = '{--ADMIN_TASK_LIST_SERVER_NAME_LOG--}';
526                 $TITLEs[] = '{--ADMIN_TASK_LIST_SERVER_NAME_LOG_TITLE--}';
527                 $WHATs[]  = 'list_server_name';
528         } // END - if
529
530         if (isExtensionInstalled('network')) {
531                 // Check for HTTP logging entries
532                 addSql('SELECT `network_header_id` FROM `{?_MYSQL_PREFIX?}_network_header_logging`');
533                 $DESCRs[] = '{--ADMIN_TASK_LIST_NETWORK_HEADER_LOG--}';
534                 $TITLEs[] = '{--ADMIN_TASK_LIST_NETWORK_HEADER_LOG_TITLE--}';
535                 $WHATs[]  = 'list_network_http_header';
536         } // END - if
537
538         // Generate extra overview rows
539         $EXTRAS .= createExtraTaskRows($WHATs, $DESCRs, $TITLEs);
540
541         // If empty just keep a forced-space left for CSS issues
542         if (empty($EXTRAS)) {
543                 $EXTRAS = '&nbsp;';
544         } // END - if
545
546         // Add compiled string to constant for final template
547         $content['extra_table'] = $EXTRAS;
548
549         // Simply load the template... :-)
550         loadTemplate('admin_overview_task', FALSE, $content);
551 }
552
553 //
554 function createExtraTaskRows ($WHATs, $DESCRs, $TITLEs) {
555         // Init variables
556         $OUT = '';
557
558         // Sadly this cannot be rewritten to a filter... :(
559         foreach (getSqls() as $sqls) {
560                 // New format...
561                 foreach ($sqls as $key => $sql) {
562                         // Run SQL command, get line numbers and free memory
563                         $result = sqlQuery($sql, __FUNCTION__, __LINE__);
564
565                         // Prepare array for output
566                         $content = array(
567                                 'row_descr' => $DESCRs[$key],
568                                 'bottom'    => '',
569                         );
570
571                         // Rewrite CSS class if not last entry is reached
572                         if ($key < (count($sqls) - 1)) {
573                                 $content['bottom'] = 'bottom';
574                         } // END - if
575
576                         if ((!ifSqlHasZeroNums($result)) && (!empty($WHATs[$key]))) {
577                                 if (empty($TITLEs[$key])) {
578                                         $TITLEs[$key] = '{--ADMIN_TASK_UNKNOWN_LIST_TITLE--}';
579                                 } // END - if
580                                 $content['row_link'] = '<a href="{%url=modules.php?module=admin&amp;what=' . $WHATs[$key] . '%}" title="' . $TITLEs[$key] . '">' . sqlNumRows($result) . '</a>';
581                         } else {
582                                 $content['row_link'] = '0';
583                         }
584
585                         // Free result
586                         sqlFreeResult($result);
587
588                         // And insert the final string into extras template
589                         $OUT .= loadTemplate('admin_overview_task_rows', TRUE, $content);
590                 } // END- foreach
591         } // END - foreach
592
593         // Return output in the template
594         return loadTemplate('admin_overview_task_extras', TRUE, $OUT);
595 }
596
597 // [EOF]
598 ?>