Rewrote some parts:
[mailer.git] / inc / modules / admin / what-list_yoomedia_tm.php
index d8e3fc0..37f07a0 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /************************************************************************
- * M-XChange v0.2.1                                   Start: 10/10/2008 *
- * ================                             Last change: 10/10/2008 *
+ * Mailer v0.2.1-FINAL                                Start: 10/10/2008 *
+ * ===================                          Last change: 10/10/2008 *
  *                                                                      *
  * -------------------------------------------------------------------- *
  * File              : what-list_yoomedia_tm.php                        *
  * -------------------------------------------------------------------- *
  * Kurzbeschreibung  : Auflisten von Yoo!Media Textmails                *
  * -------------------------------------------------------------------- *
- *                                                                      *
+ * $Revision::                                                        $ *
+ * $Date::                                                            $ *
+ * $Tag:: 0.2.1-FINAL                                                 $ *
+ * $Author::                                                          $ *
  * -------------------------------------------------------------------- *
- * Copyright (c) 2003 - 2008 by Roland Haeder                           *
- * For more information visit: http://www.mxchange.org                  *
+ * Copyright (c) 2003 - 2009 by Roland Haeder                           *
+ * Copyright (c) 2009 - 2013 by Mailer Developer Team                   *
+ * For more information visit: http://mxchange.org                      *
  *                                                                      *
  * This program is free software. You can redistribute it and/or modify *
  * it under the terms of the GNU General Public License as published by *
  ************************************************************************/
 
 // Some security stuff...
-if ((!defined('__SECURITY')) || (!IS_ADMIN())) {
-       $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4)."/security.php";
-       require($INC);
-} elseif (!EXT_IS_ACTIVE("yoomedia")) {
-       ADD_FATAL(EXTENSION_PROBLEM_EXT_INACTIVE, "yoomedia");
-       return;
-} elseif (!EXT_IS_ACTIVE("bonus")) {
-       ADD_FATAL(EXTENSION_PROBLEM_EXT_INACTIVE, "bonus");
-       return;
-}
+if ((!defined('__SECURITY')) || (!isAdmin())) {
+       die();
+} // END - if
 
 // Add description as navigation point
-ADD_DESCR("admin", __FILE__);
+addYouAreHereLink('admin', __FILE__);
+
+if (!isExtensionActive('bonus')) {
+       displayMessage('{%pipe,generateExtensionInactiveNotInstalledMessage=bonus%}');
+       return;
+} // END - if
 
 // Do actions here
-if (isset($_POST['ok'])) {
+if (isFormSent()) {
        // Prepare mail for delivery
-       YOOMEDIA_PREPARE_MAIL_DELIVERY($_POST);
+       YOOMEDIA_PREPARE_MAIL_DELIVERY(postRequestArray());
        return;
-} elseif (isset($_POST['sent'])) {
+} elseif (isPostRequestElementSet('send')) {
        // Sent mail
-       YOOMEDIA_SEND_BONUS_MAIL($_POST, "normal");
-} elseif (isset($_POST['remove'])) {
+       YOOMEDIA_SEND_BONUS_MAIL(postRequestArray(), 'normal');
+} elseif (isFormSent('do_delete')) {
        // Add mail to exclude list
-       YOOMEDIA_EXCLUDE_MAIL($_POST, "normal");
-} elseif (isset($_POST['unlist'])) {
+       YOOMEDIA_EXCLUDE_MAIL(postRequestArray(), 'normal');
+} elseif (isPostRequestElementSet('unlist')) {
        // Remove mail from exclude list
-       YOOMEDIA_UNLIST_MAIL($_POST, "normal");
+       YOOMEDIA_UNLIST_MAIL(postRequestArray(), 'normal');
 }
 
 // Enougth queries left?
-if ($_CONFIG['yoomedia_requests_remain'] == 0) {
+if (getConfig('yoomedia_requests_remain') == '0') {
        // Output message
-       LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_YOOMEDIA_REQUESTS_DEPLETED);
+       displayMessage('{--ADMIN_YOOMEDIA_REQUESTS_DEPLETED--}');
 
        // Abort here!
-       //return false;
+       return FALSE;
 } // END - if
 
 // Get parsed array back
 $result = YOOMEDIA_GET_PARSED_RESULT_TEXTMAILS();
 
 // Sanity-check on result array
-if ((!is_array($result)) || (count($result) == 0) || (!isset($result[0]['id']))) {
+if ((!isFilledArray($result)) || (!isset($result[0]['id']))) {
        // Invalid result
-       LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_YOOMEDIA_INVALID_RESULT);
-       return false;
+       displayMessage('{--ADMIN_YOOMEDIA_INVALID_RESULT--}');
+       return FALSE;
 } elseif (count($result[0]) < 7) {
        // Error received so prepare error code
-       $code = explode(" ", $result[0]['id']);
-       $code = $code[0];
-       $code = explode("<br>", $code);
-       $code = $code[0];
+       $code = YOOMEDIA_GET_ERRORCODE_FROM_RESULT($result);
 
        // Output message
-       LOAD_TEMPLATE("admin_yoomedia_error", false, sprintf("{--ADMIN_YOOMEDIA_ERROR_%s--}", strtoupper(YOOMEDIA_TRANSLATE_ERROR($code))));
-       return false;
+       loadTemplate('admin_yoomedia_error', FALSE, sprintf('{--ADMIN_YOOMEDIA_ERROR_%s--}', strtoupper(translateYooMediaError($code))));
+       return FALSE;
 }
 
-// Temporary set max comma
-$_CONFIG['max_comma'] = 5;
-
 // Prepare all entries
-$OUT = ""; $SW = 2;
+$OUT = '';
 foreach ($result as $entry) {
        // Translate some data
-       $entry['pay']    = TRANSLATE_COMMA($entry['pay']);
-       $entry['remain'] = TRANSLATE_COMMA($entry['remain']);
-       $entry['sw']     = $SW;
+       $entry['pay']    = translateComma($entry['pay'], TRUE, 5);
 
        // Check reload lock
-       $reload = YOOMEDIA_CHECK_RELOAD($entry['id'], $entry['reload'], "textmail");
+       $reload = YOOMEDIA_CHECK_RELOAD($entry['id'], $entry['reload'], 'textmail');
 
        // Is this mail already sent?
-       if ($reload !== false) {
+       if ($reload !== FALSE) {
                // Init countdown
-               $countdown = 0;
+               $countdown = '0';
 
                // Not manually locked?
                if ($reload > 0) {
@@ -121,25 +115,22 @@ foreach ($result as $entry) {
                        } // END - if
 
                        // Add reload lock
-                       $entry['already'] = sprintf(ADMIN_YOOMEDIA_TEXTMAIL_SEND_AGAIN, CREATE_FANCY_TIME($countdown));
+                       $entry['already'] = '{%message,ADMIN_YOOMEDIA_TEXTMAIL_SEND_AGAIN=' . $countdown . '%}';
                } else {
                        // Never resentable unless manual removal
-                       $entry['already'] = ADMIN_YOOMEDIA_TEXTMAIL_MANUALLY_LOCKED;
+                       $entry['already'] = '{--ADMIN_YOOMEDIA_TEXTMAIL_MANUALLY_LOCKED--}';
                }
 
                // Load row template for displaying
-               $OUT .= LOAD_TEMPLATE("admin_list_yoomedia_tm_already", true, $entry);
+               $OUT .= loadTemplate('admin_list_yoomedia_tm_already', TRUE, $entry);
        } else {
                // Load row template with buttons
-               $OUT .= LOAD_TEMPLATE("admin_list_yoomedia_tm_row", true, $entry);
+               $OUT .= loadTemplate('admin_list_yoomedia_tm_row', TRUE, $entry);
        }
-
-       // Switch color
-       $SW = 3 - $SW;
-} // END - if
+} // END - foreach
 
 // Load main template
-LOAD_TEMPLATE("admin_list_yoomedia_tm", false, $OUT);
+loadTemplate('admin_list_yoomedia_tm', FALSE, $OUT);
 
-//
+// [EOF]
 ?>