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