introduced isSqlResult() which encapsulates checking MySQL/i results
[mailer.git] / inc / modules / admin / what-list_notifications.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                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  * $Revision::                                                        $ *
14  * $Date::                                                            $ *
15  * $Tag:: 0.2.1-FINAL                                                 $ *
16  * $Author::                                                          $ *
17  * -------------------------------------------------------------------- *
18  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
19  * Copyright (c) 2009 - 2016 by Mailer Developer Team                   *
20  * For more information visit: http://mxchange.org                      *
21  *                                                                      *
22  * This program is free software; you can redistribute it and/or modify *
23  * it under the terms of the GNU General Public License as published by *
24  * the Free Software Foundation; either version 2 of the License, or    *
25  * (at your option) any later version.                                  *
26  *                                                                      *
27  * This program is distributed in the hope that it will be useful,      *
28  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
29  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
30  * GNU General Public License for more details.                         *
31  *                                                                      *
32  * You should have received a copy of the GNU General Public License    *
33  * along with this program; if not, write to the Free Software          *
34  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
35  * MA  02110-1301  USA                                                  *
36  ************************************************************************/
37
38 // Some security stuff...
39 if ((!defined('__SECURITY')) || (!isAdmin())) {
40         die();
41 } // END - if
42
43 // Add description as navigation point
44 addYouAreHereLink('admin', __FILE__);
45
46 // Init variables
47 $SQL2 = '';
48 $result_max = FALSE;
49
50 // Set offset an current page to default values
51 if (!isGetRequestElementSet('page'))   setGetRequestElement('page'  , 1);
52 if (!isGetRequestElementSet('offset')) setGetRequestElement('offset', getMailsPage());
53
54 if (isExtensionActive('bonus')) {
55         // Bonus mails sent by you
56         $SQL2 = "SELECT
57         `id`, `subject`, `text`, `receivers`, `points`, `time`, `data_type`, `timestamp`, `url`, `cat_id`, `target_send`,
58         `mails_sent`, `clicks`, (`mails_sent` - `clicks`) AS `unconfirmed`
59 FROM
60         `{?_MYSQL_PREFIX?}_bonus`
61 WHERE
62         `is_notify`='Y'
63 ORDER BY
64         `timestamp` DESC";
65
66         // Check for maximum pages
67         $result_max = sqlQuery($SQL2, __FILE__, __LINE__);
68 } else {
69         // Bonus extension required!
70         displayMessage('{%pipe,generateExtensionInactiveNotInstalledMessage=bonus%}');
71 }
72
73 // Create limitation line
74 $add = ' LIMIT ' . (bigintval(getRequestElement('offset')) * bigintval(getRequestElement('page')) - bigintval(getRequestElement('offset'))) . ', ' . bigintval(getRequestElement('offset'));
75
76 // Add limitation
77 if (!empty($SQL2)) {
78         $SQL2 .= $add;
79 } // END - if
80
81 if ((isExtensionActive('bonus')) && (!ifSqlHasZeroNumRows($result_max)) && (!empty($SQL2))) {
82         // Run SQL query for notification mails
83         $result_bonus = sqlQuery($SQL2, __FILE__, __LINE__);
84
85         // Load bonus mails only when extension is active
86         if (!ifSqlHasZeroNumRows($result_bonus)) {
87                 // Calculate pages
88                 $numPages = round(sqlNumRows($result_bonus) / getMailsPage() + 0.5);
89
90                 // List emails
91                 $OUT = ''; $content = array();
92                 while ($content = sqlFetchArray($result_bonus)) {
93                         // Add "unconfirmed-link"
94                         $content['unconfirmed_content'] = generateUnconfirmedAdminLink($content['id'], $content['unconfirmed'], 'bonus');
95
96                         // Prepare content
97                         $content['timestamp']   = generateDateTime($content['timestamp'], 0);
98
99                         // Load row template
100                         $OUT .= loadTemplate('admin_list_notify_emails_row', TRUE, $content);
101                 } // END - if
102
103                 // Add navigation (without change box but with colspan=3)
104                 $content['nav'] = addEmailNavigation($numPages, getMailsPage(), FALSE, 3, TRUE);
105
106                 // Prepare content
107                 $content['rows'] = $OUT;
108
109                 // Load main template
110                 loadTemplate('admin_list_notify_emails', FALSE, $content);
111         }
112 } elseif ((sqlNumRows($result_max) === 0) && (isSqlResult($result_max))) {
113         // No notifications found
114         displayMessage('{--ADMIN_NO_NOTIFICATIONS--}');
115 }
116
117 // [EOF]
118 ?>