8d9e24c187edba13d46f425116cfe3ff97d2cf4d
[mailer.git] / inc / libs / task_functions.php
1 <?php
2 /************************************************************************
3  * MXChange v0.2.1                                    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  * Needs to be in all Files and every File needs "svn propset           *
18  * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
19  * -------------------------------------------------------------------- *
20  * Copyright (c) 2003 - 2008 by Roland Haeder                           *
21  * For more information visit: http://www.mxchange.org                  *
22  *                                                                      *
23  * This program is free software; you can redistribute it and/or modify *
24  * it under the terms of the GNU General Public License as published by *
25  * the Free Software Foundation; either version 2 of the License, or    *
26  * (at your option) any later version.                                  *
27  *                                                                      *
28  * This program is distributed in the hope that it will be useful,      *
29  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
30  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
31  * GNU General Public License for more details.                         *
32  *                                                                      *
33  * You should have received a copy of the GNU General Public License    *
34  * along with this program; if not, write to the Free Software          *
35  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
36  * MA  02110-1301  USA                                                  *
37  ************************************************************************/
38
39 // Some security stuff...
40 if (!defined('__SECURITY')) {
41         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), '/inc') + 4) . '/security.php';
42         require($INC);
43 }
44
45 //
46 // The advanced overview shows detailed informations to your exchange script:
47 //  - Unconfirmed / locked accounts
48 //  - Mails waiting to be approved
49 //  - Open tasks
50 //  - Your own tasks
51 //  - ...
52 //
53 // @TODO Move all extension-dependent queries into filters
54 function OUTPUT_ADVANCED_OVERVIEW (&$result_main) {
55         // Init variables/arrays
56         $EXTRAS = '';
57         $OUT = '';
58         $WHATs = array();
59         $DESCRs = array();
60         $TITLEs = array();
61
62         // Chheck for new extensions and updates
63         $jobsDone = OUTPUT_STANDARD_OVERVIEW($result_main);
64
65         // Init SQLs
66         INIT_SQLS();
67
68         if (!$jobsDone) {
69                 // New extensions or updates found
70                 $value = GET_TOTAL_DATA(GET_CURRENT_ADMIN_ID(), "task_system", "id", "assigned_admin", true, " AND `status`='NEW' AND task_type='EXTENSION_UPDATE'");
71
72                 if ($value > 0) {
73                         define('__TASK_UPDATE_VALUE', "<a href=\"{!URL!}/modules.php?module=admin&amp;what=list_task&amp;type=updates\">".$value."</a>");
74                 } else {
75                         define('__TASK_UPDATE_VALUE', "0");
76                 }
77         } else {
78                 define('__TASK_UPDATE_VALUE', "0");
79         }
80
81         //
82         // First check for all account status seperately
83         //
84         // Confirmed accounts
85         $value = GET_TOTAL_DATA("CONFIRMED", "user_data", 'userid', "status", true);
86
87         if ($value > 0) {
88                 define('__CONFIRMED_VALUE', "<a href=\"{!URL!}/modules.php?module=admin&amp;what=list_user&amp;status=confirmed\">".$value."</a>");
89         } else {
90                 define('__CONFIRMED_VALUE', "0");
91         }
92
93         // Unconfirmed accounts
94         $value = GET_TOTAL_DATA("UNCONFIRMED", "user_data", 'userid', "status", true);
95
96         if ($value > 0) {
97                 define('__UNCONFIRMED_VALUE', "<a href=\"{!URL!}/modules.php?module=admin&amp;what=chk_regs\">".$value."</a>");
98         } else {
99                 define('__UNCONFIRMED_VALUE', "0");
100         }
101
102         // And locked accounts
103         $value = GET_TOTAL_DATA("LOCKED", "user_data", 'userid', "status", true);
104
105         if ($value > 0) {
106                 define('__LOCKED_VALUE', "<a href=\"{!URL!}/modules.php?module=admin&amp;what=list_user&amp;status=locked\">".$value."</a>");
107         } else {
108                 define('__LOCKED_VALUE', "0");
109         }
110
111         //
112         // Unassigned tasks
113         //
114         $value = GET_TOTAL_DATA("0", "task_system", "id", "assigned_admin", true, " AND `status` != 'DELETED'");
115
116         if ($value > 0) {
117                 define('__TASK_NEW_VALUE', "<a href=\"{!URL!}/modules.php?module=admin&amp;what=list_task&amp;type=unassigned\">".$value."</a>");
118         } else {
119                 define('__TASK_NEW_VALUE', "0");
120         }
121
122         //
123         // Closed tasks
124         //
125         $value = GET_TOTAL_DATA("CLOSED", "task_system", "id", "status", true);
126
127         if ($value > 0) {
128                 define('__TASK_CLOSED_VALUE', "<a href=\"{!URL!}/modules.php?module=admin&amp;what=list_task&amp;type=closed\">".$value."</a>");
129         } else {
130                 define('__TASK_CLOSED_VALUE', "0");
131         }
132
133         //
134         // Deleted tasks
135         //
136         $value = GET_TOTAL_DATA("DELETED", "task_system", "id", "status", true);
137
138         if ($value > 0) {
139                 define('__TASK_DELETED_VALUE', "<a href=\"{!URL!}/modules.php?module=admin&amp;what=list_task&amp;type=deleted\">".$value."</a>");
140         } else {
141                 define('__TASK_DELETED_VALUE', "0");
142         }
143
144         //
145         // Solved tasks
146         //
147         $value = GET_TOTAL_DATA("SOLVED", "task_system", "id", "status", true, sprintf(" AND assigned_admin=%s", GET_CURRENT_ADMIN_ID()));
148
149         if ($value > 0) {
150                 define('__TASK_SOLVED_VALUE', "<a href=\"{!URL!}/modules.php?module=admin&amp;what=list_task&amp;type=solved\">".$value."</a>");
151         } else {
152                 define('__TASK_SOLVED_VALUE', "0");
153         }
154
155         //
156         // Your tasks
157         //
158         $value = GET_TOTAL_DATA(GET_CURRENT_ADMIN_ID(), "task_system", "id", "assigned_admin", true, " AND status = 'NEW' AND task_type != 'EXTENSION_UPDATE'");
159
160         if ($value > 0) {
161                 define('__TASK_YOUR_VALUE', "<a href=\"{!URL!}/modules.php?module=admin&amp;what=list_task\">".$value."</a>");
162         } else {
163                 define('__TASK_YOUR_VALUE', "0");
164         }
165
166         //
167         // Mails waiting to be approved
168         //
169         $value = GET_TOTAL_DATA("ADMIN", "pool", "id", "data_type", true);
170
171         if ($value > 0) {
172                 define('__MAIL_ADMIN_VALUE', "<a href=\"{!URL!}/modules.php?module=admin&amp;what=unlock_emails\">".$value."</a>");
173         } else {
174                 define('__MAIL_ADMIN_VALUE', "0");
175         }
176
177         //
178         // Unfinished mail orders
179         //
180         $value = GET_TOTAL_DATA("TEMP", "pool", "id", "data_type", true);
181
182         if ($value > 0) {
183                 define('__MAIL_TEMP_VALUE', "<a href=\"{!URL!}/modules.php?module=admin&amp;what=email_details\">".$value."</a>");
184         } else {
185                 define('__MAIL_TEMP_VALUE', "0");
186         }
187
188         //
189         // Sent mail orders
190         //
191         $value = GET_TOTAL_DATA("SEND", "pool", "id", "data_type", true);
192
193         if ($value > 0) {
194                 define('__MAIL_SEND_VALUE', "<a href=\"{!URL!}/modules.php?module=admin&amp;what=email_archiv\">".$value."</a>");
195         } else {
196                 define('__MAIL_SEND_VALUE', "0");
197         }
198
199         //
200         // Autopurged mails
201         //
202         if (EXT_IS_ACTIVE('autopurge')) {
203                 // Get auto-purged mails
204                 $value = GET_TOTAL_DATA("DELETED", "pool", "id", "data_type", true);
205
206                 if ($value > 0) {
207                         define('__MAIL_DELETED_VALUE', "<a href=\"{!URL!}/modules.php?module=admin&amp;what=email_details\">".$value."</a>");
208                 } else {
209                         define('__MAIL_DELETED_VALUE', "0");
210                 }
211
212                 //
213                 // Autopurged bonus mails
214                 //
215                 if (GET_EXT_VERSION('bonus') >= '0.1.8') {
216                         // Get auto-purged bonus mails
217                         $value = GET_TOTAL_DATA("DELETED", 'bonus', "id", "data_type", true);
218
219                         if ($value > 0) {
220                                 define('__MAIL_BONUS_AP_VALUE', "<a href=\"{!URL!}/modules.php?module=admin&amp;what=email_details\">".$value."</a>");
221                         } else {
222                                 define('__MAIL_BONUS_AP_VALUE', "0");
223                         }
224                 } elseif (EXT_IS_ACTIVE('bonus')) {
225                         define('__MAIL_BONUS_AP_VALUE', sprintf(getMessage('ADMIN_EXT_BONUS_OUTDATED', '0.1.8')));
226                 } else {
227                         define('__MAIL_BONUS_AP_VALUE', "<span class=\"admin_note\">{--ADMIN_EXT_BONUS_404--}</span>");
228                 }
229         } else {
230                 define('__MAIL_BONUS_AP_VALUE', "<span class=\"admin_note\">{--ADMIN_EXT_AUTOPURGE_404--}</span>");
231                 define('__MAIL_DELETED_VALUE', "<span class=\"admin_note\">{--ADMIN_EXT_AUTOPURGE_404--}</span>");
232         }
233
234         //
235         // Sent bonus mails
236         //
237         if (GET_EXT_VERSION('bonus') >= '0.1.8') {
238                 // Get sent bonus mails (but not notifications)
239                 $value = GET_TOTAL_DATA("SEND", 'bonus', "id", "data_type", true, " AND is_notify='N'");
240
241                 if ($value > 0) {
242                         define('__MAIL_BONUS_SEND_VALUE', "<a href=\"{!URL!}/modules.php?module=admin&amp;what=email_details\">".$value."</a>");
243                 } else {
244                         define('__MAIL_BONUS_SEND_VALUE', "0");
245                 }
246         } elseif (EXT_IS_ACTIVE('bonus')) {
247                 define('__MAIL_BONUS_SEND_VALUE', sprintf(getMessage('ADMIN_EXT_BONUS_OUTDATED', '0.1.8')));
248         } else {
249                 define('__MAIL_BONUS_SEND_VALUE', getMessage('ADMIN_EXT_BONUS_404'));
250         }
251
252         if (EXT_IS_ACTIVE('autopurge')) {
253                 // Start finding them...
254                 $since = getConfig('ap_inactive_since');
255                 $EXCLUDE_LIST = '';
256                 if (getConfig('def_refid') > 0) {
257                         $EXCLUDE_LIST = " AND d.userid != ".getConfig('def_refid')."";
258                 } // END - if
259
260                 // Check for more extensions
261                 // @TODO These can be rewritten to filter
262                 if (EXT_IS_ACTIVE('beg'))                  $EXCLUDE_LIST .= " AND d.userid != ".getConfig('beg_uid')."";
263                 if (EXT_IS_ACTIVE('bonus'))                $EXCLUDE_LIST .= " AND d.userid != ".getConfig('bonus_uid')."";
264                 if (EXT_IS_ACTIVE('doubler'))              $EXCLUDE_LIST .= " AND d.userid != ".getConfig('doubler_uid')."";
265                 if (GET_EXT_VERSION('holiday') >= '0.1.3') $EXCLUDE_LIST .= " AND d.`holiday_active`='N'";
266
267                 // Check for all accounts
268                 ADD_SQL("SELECT DISTINCT d.userid, d.email, d.last_online
269 FROM `{!_MYSQL_PREFIX!}_user_data` AS d
270 WHERE d.`status`='CONFIRMED' AND d.joined < (UNIX_TIMESTAMP() - ".$since.") AND d.last_online < (UNIX_TIMESTAMP() - ".$since.") AND d.ap_notified < (UNIX_TIMESTAMP() - ".$since.")
271 ".$EXCLUDE_LIST."
272 ORDER BY d.userid");
273                 $WHATs[]  = "list_autopurge";
274                 $DESCRs[] = getMessage('ADMIN_TASK_INACTIVE_AUTOPURGE');
275                 $TITLEs[] = getMessage('ADMIN_TASK_INACTIVE_AUTOPURGE_TITLE');
276         }
277
278         if (GET_EXT_VERSION('sql_patches') >= '0.3.4') {
279                 // Check for accounts without referal
280                 ADD_SQL("SELECT userid FROM `{!_MYSQL_PREFIX!}_user_data` WHERE refid='0' ORDER BY userid");
281                 $DESCRs[] = getMessage('ADMIN_TASK_LIST_ACCOUNT_NOREF');
282                 $TITLEs[] = getMessage('ADMIN_TASK_LIST_ACCOUNT_NOREF_TITLE');
283                 $WHATs[]  = "list_user&amp;mode=norefs";
284         }
285
286         if (EXT_IS_ACTIVE('payout')) {
287                 // List new payout requests
288                 ADD_SQL("SELECT userid FROM `{!_MYSQL_PREFIX!}_user_payouts` WHERE `status`='NEW' ORDER BY userid");
289                 $WHATs[]  = "list_payouts";
290                 $DESCRs[] = getMessage('ADMIN_TASK_LIST_PAYOUTS_WAITING');
291                 $TITLEs[] = getMessage('ADMIN_TASK_LIST_PAYOUTS_WAITING_TITLE');
292                 ADD_SQL("SELECT userid FROM `{!_MYSQL_PREFIX!}_user_payouts` ORDER BY userid");
293                 $WHATs[]  = "list_payouts";
294                 $DESCRs[] = getMessage('ADMIN_TASK_LIST_PAYOUTS_ALL');
295                 $TITLEs[] = getMessage('ADMIN_TASK_LIST_PAYOUTS_ALL_TITLE');
296         }
297
298         if (EXT_IS_ACTIVE('wernis')) {
299                 // List new wernis requests
300                 ADD_SQL("SELECT userid FROM `{!_MYSQL_PREFIX!}_user_wernis` ORDER BY userid");
301                 $WHATs[]  = "list_wernis";
302                 $DESCRs[] = getMessage('ADMIN_TASK_LIST_WERNIS_ALL');
303                 $TITLEs[] = getMessage('ADMIN_TASK_LIST_WERNIS_ALL_TITLE');
304         }
305
306         if (EXT_IS_ACTIVE('primera')) {
307                 // List new primera requests
308                 ADD_SQL("SELECT userid FROM `{!_MYSQL_PREFIX!}_user_primera` ORDER BY userid");
309                 $WHATs[]  = "list_primera";
310                 $DESCRs[] = getMessage('ADMIN_TASK_LIST_PRIMERA_ALL');
311                 $TITLEs[] = getMessage('ADMIN_TASK_LIST_PRIMERA_ALL_TITLE');
312         }
313
314         if (EXT_IS_ACTIVE('holiday')) {
315                 // List holiday requests
316                 ADD_SQL("SELECT userid FROM `{!_MYSQL_PREFIX!}_user_holidays` ORDER BY userid");
317                 $WHATs[]  = "list_holiday";
318                 $DESCRs[] = getMessage('ADMIN_TASK_LIST_HOLIDAYS');
319                 $TITLEs[] = getMessage('ADMIN_TASK_LIST_HOLIDAYS_TITLE');
320         }
321
322         if (GET_EXT_VERSION('bonus') >= '0.8.7') {
323                 // List all notifications
324                 ADD_SQL("SELECT id FROM `{!_MYSQL_PREFIX!}_bonus` WHERE is_notify='Y' ORDER BY timestamp DESC");
325                 $WHATs[]  = "list_notifications";
326                 $DESCRs[] = getMessage('ADMIN_TASK_LIST_NOTIFICATIONS');
327                 $TITLEs[] = getMessage('ADMIN_TASK_LIST_NOTIFICATIONS_TITLE');
328         } // END - if
329
330         if (GET_EXT_VERSION('bonus') >= '0.2.3') {
331                 // Active rallye
332                 if (GET_EXT_VERSION('bonus') >= '0.6.9') {
333                         // Add more bonus points here
334                         $USE = "(0";
335                         if (getConfig('bonus_click_yn') == 'Y') $USE .= " + turbo_bonus";
336                         if (getConfig('bonus_login_yn') == 'Y') $USE .= " + login_bonus";
337                         if (getConfig('bonus_order_yn') == 'Y') $USE .= " + bonus_order";
338                         if (getConfig('bonus_stats_yn') == 'Y') $USE .= " + bonus_stats";
339                         if (getConfig('bonus_ref_yn')   == 'Y') $USE .= " + bonus_ref";
340                         $USE .= ")";
341                 } else {
342                         // Old version ???
343                         $USE = "turbo_bonus";
344                 }
345
346                 // Autopurge installed?
347                 $lastOnline = '';
348                 if ((EXT_IS_ACTIVE('autopurge')) && (getConfig('autopurge_inactive') == 'Y') && (getConfig('ap_inactive_since') > 0)) {
349                         // Use last online timestamp to keep inactive members away from here
350                         $lastOnline   = sprintf(" AND last_online >= (UNIX_TIMESTAMP() - %s)", getConfig('ap_inactive_since'));
351                 }
352
353                 ADD_SQL("SELECT ".$USE." AS points
354 FROM `{!_MYSQL_PREFIX!}_user_data`
355 WHERE `status`='CONFIRMED' AND ".$USE.">0".$lastOnline."
356 ORDER BY points DESC, userid");
357                 $WHATs[]  = "list_bonus";
358                 $DESCRs[] = getMessage('ADMIN_TASK_LIST_BONUS');
359                 $TITLEs[] = getMessage('ADMIN_TASK_LIST_BONUS_TITLE');
360         }
361
362         if (GET_EXT_VERSION('beg') >= '0.1.2') {
363                 // Begging rallye
364
365                 // Autopurge installed?
366                 $lastOnline = '';
367                 if ((EXT_IS_ACTIVE('autopurge')) && (getConfig('autopurge_inactive') == 'Y') && (getConfig('ap_inactive_since') > 0)) {
368                         // Use last online timestamp to keep inactive members away from here
369                         $lastOnline   = sprintf(" AND last_online >= (UNIX_TIMESTAMP() - %s)", getConfig('ap_inactive_since'));
370                 }
371
372                 ADD_SQL("SELECT userid FROM `{!_MYSQL_PREFIX!}_user_data`
373 WHERE `status`='CONFIRMED' AND beg_points>0".$lastOnline."
374 ORDER BY beg_points DESC, userid");
375                 $WHATs[]  = "list_beg";
376                 $DESCRs[] = getMessage('ADMIN_TASK_LIST_BEG');
377                 $TITLEs[] = getMessage('ADMIN_TASK_LIST_BEG_TITLE');
378         }
379
380         if (EXT_IS_ACTIVE('doubler')) {
381                 // List waiting payouts
382                 ADD_SQL("SELECT id FROM `{!_MYSQL_PREFIX!}_doubler` WHERE completed='N' ORDER BY `id`");
383                 $WHATs[]  = "list_doubler&amp;mode=waiting&amp;select=all";
384                 $DESCRs[] = getMessage('ADMIN_TASK_LIST_DOUBLER_WAITING');
385                 $TITLEs[] = getMessage('ADMIN_TASK_LIST_DOUBLER_WAITING_TITLE');
386                 ADD_SQL("SELECT id FROM `{!_MYSQL_PREFIX!}_doubler` ORDER BY `id`");
387                 $WHATs[]  = "list_doubler";
388                 $DESCRs[] = getMessage('ADMIN_TASK_LIST_DOUBLER_ALL');
389                 $TITLEs[] = getMessage('ADMIN_TASK_LIST_DOUBLER_ALL_TITLE');
390         }
391
392         //
393         // All referal banner
394         //
395         ADD_SQL("SELECT id FROM `{!_MYSQL_PREFIX!}_refbanner` ORDER BY `id`");
396         $WHATs[] = "refbanner";
397         $DESCRs[] = getMessage('ADMIN_TASK_LIST_REFBANNER_ALL');
398         $TITLEs[] = getMessage('ADMIN_TASK_LIST_REFBANNER_ALL_TITLE');
399
400         //
401         // All activated referal banner
402         //
403         ADD_SQL("SELECT id FROM `{!_MYSQL_PREFIX!}_refbanner` WHERE `visible`='Y' ORDER BY `id`");
404         $WHATs[] = "refbanner";
405         $DESCRs[] = getMessage('ADMIN_TASK_LIST_REFBANNER_ACTIVE');
406         $TITLEs[] = getMessage('ADMIN_TASK_LIST_REFBANNER_ACTIVE_TITLE');
407
408         //
409         // All extensions
410         //
411         ADD_SQL("SELECT id FROM `{!_MYSQL_PREFIX!}_extensions` ORDER BY `id`");
412         $WHATs[] = "extensions";
413         $DESCRs[] = getMessage('ADMIN_TASK_LIST_EXTENSIONS_ALL');
414         $TITLEs[] = getMessage('ADMIN_TASK_LIST_EXTENSIONS_ALL_TITLE');
415
416         //
417         // All activated extensions
418         //
419         ADD_SQL("SELECT id FROM `{!_MYSQL_PREFIX!}_extensions` WHERE ext_active='Y' ORDER BY `id`");
420         $WHATs[]  = "extensions&amp;active=Y";
421         $DESCRs[] = getMessage('ADMIN_TASK_LIST_EXTENSIONS_ACTIVE');
422         $TITLEs[] = getMessage('ADMIN_TASK_LIST_EXTENSIONS_ACTIVE_TITLE');
423
424         if (EXT_IS_ACTIVE("engine")) {
425                 // List all export accounts
426                 ADD_SQL("SELECT id FROM `{!_MYSQL_PREFIX!}_engine_accounts` ORDER BY `id`");
427                 $WHATs[]  = "list_engine";
428                 $DESCRs[] = getMessage('ADMIN_TASK_LIST_ENGINE');
429                 $TITLEs[] = getMessage('ADMIN_TASK_LIST_ENGINE_TITLE');
430
431                 // List all pending accounts
432                 ADD_SQL("SELECT id FROM `{!_MYSQL_PREFIX!}_engine_accounts` WHERE `status`='UNCONFIRMED' ORDER BY `id`");
433                 $WHATs[]  = "unlock_engine";
434                 $DESCRs[] = getMessage('ADMIN_TASK_UNLOCK_ENGINE');
435                 $TITLEs[] = getMessage('ADMIN_TASK_UNLOCK_ENGINE_TITLE');
436
437                 // List all safes
438                 ADD_SQL("SELECT id FROM `{!_MYSQL_PREFIX!}_engine_safe` ORDER BY `id`");
439                 $WHATs[]  = "list_engine&amp;mode=safe";
440                 $DESCRs[] = getMessage('ADMIN_TASK_LIST_ENGINE_SAFES');
441                 $TITLEs[] = getMessage('ADMIN_TASK_LIST_ENGINE_SAFES_TITLE');
442
443                 // List all export URLs
444                 ADD_SQL("SELECT id FROM `{!_MYSQL_PREFIX!}_engine_urls` ORDER BY `id`");
445                 $WHATs[]  = "engine_urls";
446                 $DESCRs[] = getMessage('ADMIN_TASK_LIST_ENGINE_URLS');
447                 $TITLEs[] = getMessage('ADMIN_TASK_LIST_ENGINE_URLS_TITLE');
448         }
449
450         if (EXT_IS_ACTIVE('sponsor')) {
451                 // List all sponsors
452                 ADD_SQL("SELECT id FROM `{!_MYSQL_PREFIX!}_sponsor_data` ORDER BY `id`");
453                 $WHATs[]  = "list_sponsor";
454                 $DESCRs[] = getMessage('ADMIN_TASK_LIST_SPONSOR');
455                 $TITLEs[] = getMessage('ADMIN_TASK_LIST_SPONSOR_TITLE');
456
457                 // List confirmed sponsor accounts
458                 ADD_SQL("SELECT id FROM `{!_MYSQL_PREFIX!}_sponsor_data` WHERE `status`='CONFIRMED' ORDER BY `id`");
459                 $WHATs[]  = "list_sponsor";
460                 $DESCRs[] = getMessage('ADMIN_TASK_LIST_SPONSOR_CONFIRMED');
461                 $TITLEs[] = getMessage('ADMIN_TASK_LIST_SPONSOR_CONFIRMED_TITLE');
462
463                 // List unconfirmed sponsor accounts
464                 ADD_SQL("SELECT id FROM `{!_MYSQL_PREFIX!}_sponsor_data` WHERE `status`='UNCONFIRMED' ORDER BY `id`");
465                 $WHATs[]  = "list_sponsor";
466                 $DESCRs[] = getMessage('ADMIN_TASK_LIST_SPONSOR_UNCONFIRMED');
467                 $TITLEs[] = getMessage('ADMIN_TASK_LIST_SPONSOR_UNCONFIRMED_TITLE');
468
469                 // List locked sponsor accounts
470                 ADD_SQL("SELECT id FROM `{!_MYSQL_PREFIX!}_sponsor_data` WHERE `status`='LOCKED' ORDER BY `id`");
471                 $WHATs[]  = "list_sponsor";
472                 $DESCRs[] = getMessage('ADMIN_TASK_LIST_SPONSOR_LOCKED');
473                 $TITLEs[] = getMessage('ADMIN_TASK_LIST_SPONSOR_LOCKED_TITLE');
474
475                 // List waiting sponsor accounts to be approved
476                 ADD_SQL("SELECT id FROM `{!_MYSQL_PREFIX!}_sponsor_data` WHERE `status`='PENDING' ORDER BY `id`");
477                 $WHATs[]  = "unlock_sponsor";
478                 $DESCRs[] = getMessage('ADMIN_TASK_LIST_SPONSOR_PENDING');
479                 $TITLEs[] = getMessage('ADMIN_TASK_LIST_SPONSOR_PENDING_TITLE');
480
481                 // Waiting payments
482                 ADD_SQL("SELECT id FROM `{!_MYSQL_PREFIX!}_sponsor_orders` WHERE pay_`status`='PENDING' ORDER BY `id`");
483                 $WHATs[]  = "list_sponsor_pays";
484                 $DESCRs[] = getMessage('ADMIN_TASK_LIST_SPONSOR_ORDERS');
485                 $TITLEs[] = getMessage('ADMIN_TASK_LIST_SPONSOR_ORDERS_TITLE');
486         }
487
488         if (EXT_IS_ACTIVE('country')) {
489                 // List country codes
490                 ADD_SQL("SELECT id FROM `{!_MYSQL_PREFIX!}_countries` ORDER BY `id`");
491                 $WHATs[]  = "list_country";
492                 $DESCRs[] = getMessage('ADMIN_TASK_LIST_COUNTRY');
493                 $TITLEs[] = getMessage('ADMIN_TASK_LIST_COUNTRY_TITLE');
494         }
495
496         if (EXT_IS_ACTIVE('theme')) {
497                 // List all themes
498                 ADD_SQL("SELECT id FROM `{!_MYSQL_PREFIX!}_themes` ORDER BY `id`");
499                 $WHATs[]  = "theme_edit";
500                 $DESCRs[] = getMessage('ADMIN_TASK_LIST_THEME_ALL');
501                 $TITLEs[] = getMessage('ADMIN_TASK_LIST_THEME_ALL_TITLE');
502
503                 // List active themes
504                 ADD_SQL("SELECT id FROM `{!_MYSQL_PREFIX!}_themes` WHERE theme_active='Y' ORDER BY `id`");
505                 $WHATs[]  = "theme_edit";
506                 $DESCRs[] = getMessage('ADMIN_TASK_LIST_THEME_ACTIVE');
507                 $TITLEs[] = getMessage('ADMIN_TASK_LIST_THEME_ACTIVE_TITLE');
508         }
509
510         if (EXT_IS_ACTIVE('admins')) {
511                 // List all administrator logins
512                 ADD_SQL("SELECT id FROM `{!_MYSQL_PREFIX!}_admins` ORDER BY `id`");
513                 $WHATs[]  = "admins_edit";
514                 $DESCRs[] = getMessage('ADMIN_TASK_LIST_ADMINS_ALL');
515                 $TITLEs[] = getMessage('ADMIN_TASK_LIST_ADMINS_ALL_TITLE');
516         }
517
518         if (EXT_IS_ACTIVE('surfbar')) {
519                 // List all URLs in surfbar
520                 ADD_SQL("SELECT id FROM `{!_MYSQL_PREFIX!}_surfbar_urls` ORDER BY `id`");
521                 $WHATs[]  = "list_surfbar_urls";
522                 $DESCRs[] = getMessage('ADMIN_TASK_LIST_SURFBAR_URLS_ALL');
523                 $TITLEs[] = getMessage('ADMIN_TASK_LIST_SURFBAR_URLS_ALL_TITLE');
524
525                 // List all pending URLs in surfbar
526                 ADD_SQL("SELECT id FROM `{!_MYSQL_PREFIX!}_surfbar_urls` WHERE `status`='PENDING' ORDER BY `id`");
527                 $WHATs[]  = "unlock_surfbar_urls";
528                 $DESCRs[] = getMessage('ADMIN_TASK_LIST_SURFBAR_URLS_PENDING');
529                 $TITLEs[] = getMessage('ADMIN_TASK_LIST_SURFBAR_URLS_PENDING_TITLE');
530         }
531
532         // Generate extra overview rows
533         $EXTRAS .= TASK_CREATE_EXTRA_ROWS($WHATs, $DESCRs, $TITLEs);
534
535         // If empty just keep a forced-space left for CSS issues
536         if (empty($EXTRAS)) $EXTRAS = "&nbsp;";
537
538         // Add compiled string to constant for final template
539         define('__OVERVIEW_EXTRA_TABLE', $EXTRAS);
540
541         // Simply load the template... :-)
542         LOAD_TEMPLATE("admin_overview_task");
543 }
544
545 //
546 function TASK_CREATE_EXTRA_ROWS ($WHATs, $DESCRs, $TITLEs) {
547         // Init variables
548         $OUT = ''; $SW = 2;
549
550         // Sadly this cannot be rewritten to a filter... :(
551         foreach (GET_SQLS() as $key => $sql) {
552                 // Run SQL command, get line numbers and free memory
553                 $result = SQL_QUERY($sql, __FUNCTION__, __LINE__);
554
555                 // Get rows
556                 $value = SQL_NUMROWS($result);
557
558                 // Free result
559                 SQL_FREERESULT($result);
560
561                 // Prepare array for output
562                 $content = array(
563                         'row_descr' => $DESCRs[$key],
564                         'row_sw'    => $SW,
565                         'bottom'    => "",
566                 );
567
568                 // Rewrite CSS class if not last entry is reached
569                 if ($key < (COUNT_SQLS() - 1)) $content['bottom'] = "bottom2";
570
571                 if (($value > 0) && (!empty($WHATs[$key]))) {
572                         if (empty($TITLEs[$key])) $TITLEs[$key] = getMessage('ADMIN_TASK_UNKNOWN_LIST_TITLE');
573                         $content['row_link'] = "<a href=\"{!URL!}/modules.php?module=admin&amp;what=".$WHATs[$key]."\" title=\"".$TITLEs[$key]."\">".$value."</a>";
574                 } else {
575                         $content['row_link'] = 0;
576                 }
577
578                 // And insert the final string into extras template
579                 $OUT .= LOAD_TEMPLATE("admin_overview_task_rows", true, $content);
580
581                 // Switch color
582                 $SW = 3 - $SW;
583         } // END - if
584
585         // Return output in the template
586         return LOAD_TEMPLATE("admin_overview_task_extras", true, $OUT);
587 }
588
589 //
590 ?>