fooRequestElementBar() functions renamed, adding of request parameters added:
[mailer.git] / inc / modules / admin / what-list_yoomedia_tm.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 10/10/2008 *
4  * ===================                          Last change: 10/10/2008 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : what-list_yoomedia_tm.php                        *
8  * -------------------------------------------------------------------- *
9  * Short description : List Yoo!Media text mails                        *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Auflisten von Yoo!Media Textmails                *
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.       *
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 addMenuDescription('admin', __FILE__);
45
46 if (!isExtensionActive('yoomedia')) {
47         loadTemplate('admin_settings_saved', false, generateExtensionInactiveNotInstalledMessage('yoomedia'));
48         return;
49 } elseif (!isExtensionActive('bonus')) {
50         loadTemplate('admin_settings_saved', false, generateExtensionInactiveNotInstalledMessage('bonus'));
51         return;
52 }
53
54 // Do actions here
55 if (isFormSent()) {
56         // Prepare mail for delivery
57         YOOMEDIA_PREPARE_MAIL_DELIVERY(postRequestArray());
58         return;
59 } elseif (isPostRequestParameterSet('sent')) {
60         // Sent mail
61         YOOMEDIA_SEND_BONUS_MAIL(postRequestArray(), 'normal');
62 } elseif (isPostRequestParameterSet('remove')) {
63         // Add mail to exclude list
64         YOOMEDIA_EXCLUDE_MAIL(postRequestArray(), 'normal');
65 } elseif (isPostRequestParameterSet('unlist')) {
66         // Remove mail from exclude list
67         YOOMEDIA_UNLIST_MAIL(postRequestArray(), 'normal');
68 }
69
70 // Enougth queries left?
71 if (getConfig('yoomedia_requests_remain') == '0') {
72         // Output message
73         loadTemplate('admin_settings_saved', false, getMessage('ADMIN_YOOMEDIA_REQUESTS_DEPLETED'));
74
75         // Abort here!
76         return false;
77 } // END - if
78
79 // Get parsed array back
80 $result = YOOMEDIA_GET_PARSED_RESULT_TEXTMAILS();
81
82 // Sanity-check on result array
83 if ((!is_array($result)) || (count($result) == '0') || (!isset($result[0]['id']))) {
84         // Invalid result
85         loadTemplate('admin_settings_saved', false, getMessage('ADMIN_YOOMEDIA_INVALID_RESULT'));
86         return false;
87 } elseif (count($result[0]) < 7) {
88         // Error received so prepare error code
89         $code = YOOMEDIA_GET_ERRORCODE_FROM_RESULT($result);
90
91         // Output message
92         loadTemplate('admin_yoomedia_error', false, sprintf("{--ADMIN_YOOMEDIA_ERROR_%s--}", strtoupper(translateYooMediaError($code))));
93         return false;
94 }
95
96 // Prepare all entries
97 $OUT = ''; $SW = 2;
98 foreach ($result as $entry) {
99         // Translate some data
100         $entry['pay']    = translateComma($entry['pay'], true, 5);
101         $entry['remain'] = translateComma($entry['remain']);
102         $entry['sw']     = $SW;
103
104         // Check reload lock
105         $reload = YOOMEDIA_CHECK_RELOAD($entry['id'], $entry['reload'], 'textmail');
106
107         // Is this mail already sent?
108         if ($reload !== false) {
109                 // Init countdown
110                 $countdown = '0';
111
112                 // Not manually locked?
113                 if ($reload > 0) {
114                         // Calculate countdown
115                         $countdown = $reload + ($entry['reload'] * 60*60) - time();
116
117                         // Countdown < 60 seconds and bigger zero?
118                         if (($countdown < 60) && ($countdown > 0)) {
119                                 // Fix to one minute
120                                 $countdown = 60;
121                         } // END - if
122
123                         // Add reload lock
124                         $entry['already'] = getMaskedMessage('ADMIN_YOOMEDIA_TEXTMAIL_SEND_AGAIN', createFancyTime($countdown));
125                 } else {
126                         // Never resentable unless manual removal
127                         $entry['already'] = getMessage('ADMIN_YOOMEDIA_TEXTMAIL_MANUALLY_LOCKED');
128                 }
129
130                 // Load row template for displaying
131                 $OUT .= loadTemplate('admin_list_yoomedia_tm_already', true, $entry);
132         } else {
133                 // Load row template with buttons
134                 $OUT .= loadTemplate('admin_list_yoomedia_tm_row', true, $entry);
135         }
136
137         // Switch color
138         $SW = 3 - $SW;
139 } // END - if
140
141 // Load main template
142 loadTemplate('admin_list_yoomedia_tm', false, $OUT);
143
144 // [EOF]
145 ?>