"copied"
[mailer.git] / 0.2.1-FINAL / inc / modules / admin / what-list_notifications.php
1 <?php
2 /************************************************************************
3  * MXChange v0.2.1                                    Start: 10/07/2008 *
4  * ===============                              Last change: 10/07/2008 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : what-list_notifications.php                      *
8  * -------------------------------------------------------------------- *
9  * Short description : See all notification emails (beg/active rallye)  *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Alle Benachrichtigungen sehen (Bettel-/Aktiv-R.) *
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')) || (!IS_ADMIN())) {
36         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
37         require($INC);
38 }
39
40 // Add description as navigation point
41 ADD_DESCR("admin", __FILE__);
42
43 // Init variables
44 $WHO = _ALL;
45 $SQL2 = "";
46
47 // Set offset an current page to default values
48 if (empty($_GET['page']))   $_GET['page']   = "1";
49 if (empty($_GET['offset'])) $_GET['offset'] = getConfig('mails_page');
50
51 if ((EXT_IS_ACTIVE("bonus")) && ($WHO == _ALL)) {
52         // Bonus mails sent by you
53         //               0     1       2        3        4      5       6          7       8      9         10          11        12
54         $SQL2 = "SELECT id, subject, text, receivers, points, time, data_type, timestamp, url, cat_id, target_send, mails_sent, clicks
55 FROM "._MYSQL_PREFIX."_bonus
56 WHERE is_notify='Y'
57 ORDER BY timestamp DESC";
58
59         // Check for maximum pages
60         $result_max = SQL_QUERY($SQL2, __FILE__, __LINE__);
61 } else {
62         // Bonus extension required!
63 }
64
65 // Create limitation line
66 $ADD = " LIMIT ".(bigintval($_GET['offset']) * bigintval($_GET['page']) - bigintval($_GET['offset'])).", ".bigintval($_GET['offset']);
67
68 // Add limitation
69 if (!empty($SQL2)) $SQL2 .= $ADD;
70
71 if ((EXT_IS_ACTIVE("bonus")) && (SQL_NUMROWS($result_max) > 0) && (!empty($SQL2))) {
72         // Run SQL query for notification mails
73         $result_bonus = SQL_QUERY($SQL2, __FILE__, __LINE__);
74
75         // Load bonus mails only when extension is active
76         if (SQL_NUMROWS($result_bonus) > 0) {
77                 // Calculate pages
78                 $PAGES = round(SQL_NUMROWS($result_bonus) / getConfig('mails_page') + 0.5);
79
80                 // List emails
81                 $OUT = ""; $content = array();
82                 while ($bonus = SQL_FETCHARRAY($result_bonus)) {
83                         // Calculate unconfirmed emails
84                         $bonus['unconfirmed'] = $bonus['mails_sent'] - $bonus['clicks'];
85
86                         // Add link?
87                         if ($bonus['unconfirmed'] > 0) {
88                                 // Add link to list_unconfirmed what-file
89                                 $bonus['unconfirmed'] = "<STRONG><A href=\"".URL."/modules.php?module=admin&amp;what=list_unconfirmed&amp;bid=".$bonus['id']."\">".$bonus['unconfirmed']."</A></STRONG>";
90                         } // END - if
91
92                         // Prepare content
93                         $content = $bonus;
94                         $content['time']        = CREATE_FANCY_TIME($content['time']);
95                         $content['category']    = GET_CATEGORY($content['cat_id']);
96                         $content['receivers']   = str_replace(";", ", ", $content['receivers']);
97                         $content['type']        = TRANSLATE_POOL_TYPE($content['data_type']);
98                         $content['frametester'] = FRAMETESTER($content['url']);
99                         $content['timestamp']   = MAKE_DATETIME($content['timestamp'], "0");
100
101                         // Load row template
102                         $OUT .= LOAD_TEMPLATE("admin_list_notify_emails_row", true, $content);
103                 }
104
105                 // Add navigation (without change box but with colspan=3)
106                 $content['nav'] = "";
107                 if ($PAGES > 1) $content['nav'] = ADD_EMAIL_NAV($PAGES, getConfig('mails_page'), false, "3", true);
108
109                 // Prepare content
110                 $content['rows'] = $OUT;
111
112                 // Load main template
113                 LOAD_TEMPLATE("admin_list_notify_emails", false, $content);
114         }
115 }
116
117 //
118 ?>