Some language strings fixed, renamed. Copyright notice updated
[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  * -------------------------------------------------------------------- *
18  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
19  * Copyright (c) 2009 - 2011 by Mailer Developer Team                   *
20  * For more information visit: http://www.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.       *
25  *                                                                      *
26  * This program is distributed in the hope that it will be useful,      *
27  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
28  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
29  * GNU General Public License for more details.                         *
30  *                                                                      *
31  * You should have received a copy of the GNU General Public License    *
32  * along with this program; if not, write to the Free Software          *
33  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
34  * MA  02110-1301  USA                                                  *
35  ************************************************************************/
36
37 // Some security stuff...
38 if ((!defined('__SECURITY')) || (!isAdmin())) {
39         die();
40 } // END - if
41
42 // Add description as navigation point
43 addYouAreHereLink('admin', __FILE__);
44
45 if (!isExtensionActive('yoomedia')) {
46         loadTemplate('admin_settings_saved', false, generateExtensionInactiveNotInstalledMessage('yoomedia'));
47         return;
48 } elseif (!isExtensionActive('bonus')) {
49         loadTemplate('admin_settings_saved', false, generateExtensionInactiveNotInstalledMessage('bonus'));
50         return;
51 }
52
53 // Do actions here
54 if (isFormSent()) {
55         // Prepare mail for delivery
56         YOOMEDIA_PREPARE_MAIL_DELIVERY(postRequestArray());
57         return;
58 } elseif (isPostRequestParameterSet('sent')) {
59         // Sent mail
60         YOOMEDIA_SEND_BONUS_MAIL(postRequestArray(), 'normal');
61 } elseif (isFormSent('remove')) {
62         // Add mail to exclude list
63         YOOMEDIA_EXCLUDE_MAIL(postRequestArray(), 'normal');
64 } elseif (isPostRequestParameterSet('unlist')) {
65         // Remove mail from exclude list
66         YOOMEDIA_UNLIST_MAIL(postRequestArray(), 'normal');
67 }
68
69 // Enougth queries left?
70 if (getConfig('yoomedia_requests_remain') == '0') {
71         // Output message
72         loadTemplate('admin_settings_saved', false, '{--ADMIN_YOOMEDIA_REQUESTS_DEPLETED--}');
73
74         // Abort here!
75         return false;
76 } // END - if
77
78 // Get parsed array back
79 $result = YOOMEDIA_GET_PARSED_RESULT_TEXTMAILS();
80
81 // Sanity-check on result array
82 if ((!is_array($result)) || (count($result) == 0) || (!isset($result[0]['id']))) {
83         // Invalid result
84         loadTemplate('admin_settings_saved', false, '{--ADMIN_YOOMEDIA_INVALID_RESULT--}');
85         return false;
86 } elseif (count($result[0]) < 7) {
87         // Error received so prepare error code
88         $code = YOOMEDIA_GET_ERRORCODE_FROM_RESULT($result);
89
90         // Output message
91         loadTemplate('admin_yoomedia_error', false, sprintf("{--ADMIN_YOOMEDIA_ERROR_%s--}", strtoupper(translateYooMediaError($code))));
92         return false;
93 }
94
95 // Prepare all entries
96 $OUT = '';
97 foreach ($result as $entry) {
98         // Translate some data
99         $entry['pay']    = translateComma($entry['pay'], true, 5);
100
101         // Check reload lock
102         $reload = YOOMEDIA_CHECK_RELOAD($entry['id'], $entry['reload'], 'textmail');
103
104         // Is this mail already sent?
105         if ($reload !== false) {
106                 // Init countdown
107                 $countdown = '0';
108
109                 // Not manually locked?
110                 if ($reload > 0) {
111                         // Calculate countdown
112                         $countdown = $reload + ($entry['reload'] * 60*60) - time();
113
114                         // Countdown < 60 seconds and bigger zero?
115                         if (($countdown < 60) && ($countdown > 0)) {
116                                 // Fix to one minute
117                                 $countdown = 60;
118                         } // END - if
119
120                         // Add reload lock
121                         $entry['already'] = getMaskedMessage('ADMIN_YOOMEDIA_TEXTMAIL_SEND_AGAIN', $countdown);
122                 } else {
123                         // Never resentable unless manual removal
124                         $entry['already'] = '{--ADMIN_YOOMEDIA_TEXTMAIL_MANUALLY_LOCKED--}';
125                 }
126
127                 // Load row template for displaying
128                 $OUT .= loadTemplate('admin_list_yoomedia_tm_already', true, $entry);
129         } else {
130                 // Load row template with buttons
131                 $OUT .= loadTemplate('admin_list_yoomedia_tm_row', true, $entry);
132         }
133 } // END - foreach
134
135 // Load main template
136 loadTemplate('admin_list_yoomedia_tm', false, $OUT);
137
138 // [EOF]
139 ?>