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