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