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