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