]> git.mxchange.org Git - mailer.git/blobdiff - inc/modules/guest/what-sponsor_infos.php
Renamed ifSqlHasZeroNums() to ifSqlHasZeroNumRows() and improved some queries.
[mailer.git] / inc / modules / guest / what-sponsor_infos.php
index 39cf47fe7ea9c0158da1e5ddaee4a35bfccea267..de1db90f2fcf1bc35ef74d223fc5e04e64e409f7 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /************************************************************************
- * MXChange v0.2.1                                    Start: 06/10/2005 *
- * ===============                              Last change: 05/18/2008 *
+ * Mailer v0.2.1-FINAL                                Start: 06/10/2005 *
+ * ===================                          Last change: 05/18/2008 *
  *                                                                      *
  * -------------------------------------------------------------------- *
  * File              : what-sponsor_infos.php                           *
  * -------------------------------------------------------------------- *
  * Kurzbeschreibung  : Informationen/Preise fuer den Sponsoren          *
  * -------------------------------------------------------------------- *
+ * Copyright (c) 2003 - 2009 by Roland Haeder                           *
+ * Copyright (c) 2009 - 2015 by Mailer Developer Team                   *
+ * For more information visit: http://mxchange.org                      *
  *                                                                      *
- * -------------------------------------------------------------------- *
- * Copyright (c) 2003 - 2008 by Roland Haeder                           *
- * For more information visit: http://www.mxchange.org                  *
- *                                                                      *
- * This program is free software. You can redistribute it and/or modify *
+ * 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 *
- * the Free Software Foundation; either version 2 of the License.       *
+ * the Free Software Foundation; either version 2 of the License, or    *
+ * (at your option) any later version.                                  *
  *                                                                      *
  * This program is distributed in the hope that it will be useful,      *
  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
 
 // Some security stuff...
 if (!defined('__SECURITY')) {
-       $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4)."/security.php";
-       require($INC);
-} elseif ((!EXT_IS_ACTIVE("sponsor"))) {
-       if (IS_ADMIN()) {
-               ADD_FATAL(sprintf(EXTENSION_PROBLEM_NOT_INSTALLED, "sponsor"));
-       } else {
-               ADD_FATAL(EXTENSION_PROBLEM_EXT_INACTIVE, "sponsor");
-       }
-       return;
-}
+       exit();
+} // END - if
 
 // Add description as navigation point
-ADD_DESCR("guest", __FILE__);
+addYouAreHereLink('guest', __FILE__);
+
+if ((!isExtensionActive('sponsor'))) {
+       displayMessage('{%pipe,generateExtensionInactiveNotInstalledMessage=sponsor%}');
+       return;
+} // END - if
+
+// Init both results (see footer of this file)
+$result_act = FALSE;
+$result_pay = FALSE;
 
-// Remove result_act
-unset($result_act);
+// ... and output variables
+$OUT_ACT = '';
+$OUT_PAY = '';
 
 // Load all sponsor actions
-$result_act = SQL_QUERY("SELECT DISTINCT m.title, c.conv_rate, c.conv_name
-FROM "._MYSQL_PREFIX."_sponsor_menu AS m
-LEFT JOIN "._MYSQL_PREFIX."_sponsor_action_convert AS c ON m.what=c.ext_name
-LEFT JOIN "._MYSQL_PREFIX."_sponsor_registry AS r ON m.what=r.ext_name
-WHERE m.action='actions' AND r.is_active='Y'
-ORDER BY m.sort ASC", __FILE__, __LINE__);
-$num_act = SQL_NUMROWS($result_act);
+$result_act = sqlQuery("SELECT
+       `m`.`title` AS `conv_title`,
+       `c`.`conv_rate`,
+       `c`.`conv_name`
+FROM
+       `{?_MYSQL_PREFIX?}_sponsor_menu` AS `m`
+LEFT JOIN
+       `{?_MYSQL_PREFIX?}_sponsor_action_convert` AS `c`
+ON
+       `m`.`what`=`c`.`ext_name`
+LEFT JOIN
+       `{?_MYSQL_PREFIX?}_sponsor_registry` AS `r`
+ON
+       `m`.`what`=`r`.`ext_name`
+WHERE
+       `m`.`action`='actions' AND
+       `r`.`is_active`='Y'
+ORDER BY
+       `m`.`sort` ASC", __FILE__, __LINE__);
 
-if ($num_act > 0) {
+if (!ifSqlHasZeroNumRows($result_act)) {
        // Load all actions
-       $OUT_ACT = ""; $SW = 2;
-       while (list($title, $conv, $name) = SQL_FETCHROW($result_act)) {
-               // Prepare data for the row template
-               $content = array(
-                       'sw'    => $SW,
-                       'title' => $title,
-                       'conv'  => round($conv),
-                       'name'  => $name,
-               );
-
+       while ($content = sqlFetchArray($result_act)) {
                // Load row template and switch color
-               $OUT_ACT .= LOAD_TEMPLATE("guest_sponsor_act_row", true, $content);
-               $SW = 3 - $SW;
+               $OUT_ACT .= loadTemplate('guest_sponsor_act_row', TRUE, $content);
        } // END - while
 
        // Check for pay types
-       $result_pay = SQL_QUERY("SELECT pay_name, pay_rate, pay_min_count, pay_currency FROM "._MYSQL_PREFIX."_sponsor_paytypes ORDER BY pay_name", __FILE__, __LINE__);
-       if (SQL_NUMROWS($result_pay) > 0) {
-               // Load all pay types
-               $OUT_PAY = ""; $SW = 2;
-               while (list($name, $rate, $min, $curr) = SQL_FETCHROW($result_pay)) {
-                       // Prepare data for the row template
-                       $content = array(
-                               'sw'    => $SW,
-                               'name'  => $name,
-                               'rate'  => TRANSLATE_COMMA($rate),
-                               'min'   => $min,
-                               'curr'  => $curr,
-                               'price' => TRANSLATE_COMMA($min),
-                       );
+       // @TODO Cache this static data
+       $result_pay = sqlQuery('SELECT
+       `pay_name`,
+       `pay_rate`,
+       `pay_min_count`,
+       `pay_currency`
+FROM
+       `{?_MYSQL_PREFIX?}_sponsor_paytypes`
+ORDER BY
+       `pay_name` ASC', __FILE__, __LINE__);
 
+       if (!ifSqlHasZeroNumRows($result_pay)) {
+               // Load all pay types
+               while ($content = sqlFetchArray($result_pay)) {
                        // Load row template and switch color
-                       $OUT_PAY .= LOAD_TEMPLATE("guest_sponsor_pay_row", true, $content);
-                       $SW = 3 - $SW;
-               }
+                       $OUT_PAY .= loadTemplate('guest_sponsor_pay_row', TRUE, $content);
+               } // END - while
        } else {
                // No pay types setuped so far!
-               $OUT_PAY = "<TR><TD colspan=\"2\">
-  ".LOAD_TEMPLATE("admin_settings_saved", true, SPONSOR_NO_ACTIONS_ACTIVATED)."
-</TD></TR>";
+               $OUT_PAY = loadTemplate('guest_sponsor_infos_none_row', TRUE, displayMessage('{--SPONSOR_NO_ACTIONS_ACTIVATED--}', TRUE));
        }
 } else {
        // No actions activated so far!
-       $OUT_ACT = "<TR><TD colspan=\"2\" class=\"bottom2\" style=\"padding-top: 10px; padding-bottom: 10px\">
-  ".LOAD_TEMPLATE("admin_settings_saved", true, SPONSOR_NO_ACTIONS_ACTIVATED)."
-</TD></TR>";
-       $OUT_PAY = "<TR><TD colspan=\"2\" class=\"bottom2\" style=\"padding-top: 10px; padding-bottom: 10px\">
-  ".LOAD_TEMPLATE("admin_settings_saved", true, SPONSOR_NO_ACTIONS_ACTIVATED)."
-</TD></TR>";
+       $OUT_ACT = loadTemplate('guest_sponsor_infos_none_row', TRUE, displayMessage('{--SPONSOR_NO_ACTIONS_ACTIVATED--}', TRUE));
+       $OUT_PAY = loadTemplate('guest_sponsor_infos_none_row', TRUE, displayMessage('{--SPONSOR_NO_ACTIONS_ACTIVATED--}', TRUE));
 }
 
-// Transfer rows to constans
-define('__SPONSOR_ACTIONS' , $OUT_ACT);
-define('__SPONSOR_PAYTYPES', $OUT_PAY);
-
 // Free memory
-if (isset($result_act)) SQL_FREERESULT($result_act);
-if (isset($result_pay)) SQL_FREERESULT($result_pay);
+sqlFreeResult($result_act);
+sqlFreeResult($result_pay);
+
+// Transfer rows to an array
+$content = array(
+       'actions'  => $OUT_ACT,
+       'paytypes' => $OUT_PAY
+);
 
 // Load main template
-LOAD_TEMPLATE("guest_sponsor_infos");
+loadTemplate('guest_sponsor_infos', FALSE, $content);
 
-//
+// [EOF]
 ?>