2 /************************************************************************
3 * M-XChange v0.2.1 Start: 10/10/2008 *
4 * ================ Last change: 10/10/2008 *
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 * -------------------------------------------------------------------- *
14 * -------------------------------------------------------------------- *
15 * Copyright (c) 2003 - 2008 by Roland Haeder *
16 * For more information visit: http://www.mxchange.org *
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. *
22 * This program is distributed in the hope that it will be useful, *
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
25 * GNU General Public License for more details. *
27 * You should have received a copy of the GNU General Public License *
28 * along with this program; if not, write to the Free Software *
29 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
31 ************************************************************************/
33 // Some security stuff...
34 if ((!defined('__SECURITY')) || (!IS_ADMIN())) {
35 $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4)."/security.php";
37 } elseif (!EXT_IS_ACTIVE("yoomedia")) {
38 addFatalMessage(__FILE__, __LINE__, getMessage('EXTENSION_PROBLEM_EXT_INACTIVE'), "yoomedia");
40 } elseif (!EXT_IS_ACTIVE("bonus")) {
41 addFatalMessage(__FILE__, __LINE__, getMessage('EXTENSION_PROBLEM_EXT_INACTIVE'), "bonus");
45 // Add description as navigation point
46 ADD_DESCR("admin", __FILE__);
50 // Prepare mail for delivery
51 YOOMEDIA_PREPARE_MAIL_DELIVERY(REQUEST_POST_ARRAY());
53 } elseif (REQUEST_ISSET_POST(('sent'))) {
55 YOOMEDIA_SEND_BONUS_MAIL(REQUEST_POST_ARRAY(), "normal");
56 } elseif (REQUEST_ISSET_POST(('remove'))) {
57 // Add mail to exclude list
58 YOOMEDIA_EXCLUDE_MAIL(REQUEST_POST_ARRAY(), "normal");
59 } elseif (REQUEST_ISSET_POST(('unlist'))) {
60 // Remove mail from exclude list
61 YOOMEDIA_UNLIST_MAIL(REQUEST_POST_ARRAY(), "normal");
64 // Enougth queries left?
65 if (getConfig('yoomedia_requests_remain') == 0) {
67 LOAD_TEMPLATE("admin_settings_saved", false, getMessage('ADMIN_YOOMEDIA_REQUESTS_DEPLETED'));
73 // Get parsed array back
74 $result = YOOMEDIA_GET_PARSED_RESULT_TEXTMAILS();
76 // Sanity-check on result array
77 if ((!is_array($result)) || (count($result) == 0) || (!isset($result[0]['id']))) {
79 LOAD_TEMPLATE("admin_settings_saved", false, getMessage('ADMIN_YOOMEDIA_INVALID_RESULT'));
81 } elseif (count($result[0]) < 7) {
82 // Error received so prepare error code
83 $code = explode(" ", $result[0]['id']);
85 $code = explode("<br />", $code);
89 LOAD_TEMPLATE("admin_yoomedia_error", false, sprintf("{--ADMIN_YOOMEDIA_ERROR_%s--}", strtoupper(YOOMEDIA_TRANSLATE_ERROR($code))));
93 // Prepare all entries
95 foreach ($result as $entry) {
96 // Translate some data
97 $entry['pay'] = TRANSLATE_COMMA($entry['pay'], true, 5);
98 $entry['remain'] = TRANSLATE_COMMA($entry['remain']);
102 $reload = YOOMEDIA_CHECK_RELOAD($entry['id'], $entry['reload'], "textmail");
104 // Is this mail already sent?
105 if ($reload !== false) {
109 // Not manually locked?
111 // Calculate countdown
112 $countdown = $reload + ($entry['reload'] * 60*60) - time();
114 // Countdown < 60 seconds and bigger zero?
115 if (($countdown < 60) && ($countdown > 0)) {
121 $entry['already'] = sprintf(ADMIN_YOOMEDIA_TEXTMAIL_SEND_AGAIN, CREATE_FANCY_TIME($countdown));
123 // Never resentable unless manual removal
124 $entry['already'] = ADMIN_YOOMEDIA_TEXTMAIL_MANUALLY_LOCKED;
127 // Load row template for displaying
128 $OUT .= LOAD_TEMPLATE("admin_list_yoomedia_tm_already", true, $entry);
130 // Load row template with buttons
131 $OUT .= LOAD_TEMPLATE("admin_list_yoomedia_tm_row", true, $entry);
138 // Load main template
139 LOAD_TEMPLATE("admin_list_yoomedia_tm", false, $OUT);