Renamed ifSqlHasZeroNums() to ifSqlHasZeroNumRows() and improved some queries.
[mailer.git] / inc / modules / guest / what-sponsor_infos.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 06/10/2005 *
4  * ===================                          Last change: 05/18/2008 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : what-sponsor_infos.php                           *
8  * -------------------------------------------------------------------- *
9  * Short description : Informations and prices for the sponsor          *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Informationen/Preise fuer den Sponsoren          *
12  * -------------------------------------------------------------------- *
13  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
14  * Copyright (c) 2009 - 2015 by Mailer Developer Team                   *
15  * For more information visit: http://mxchange.org                      *
16  *                                                                      *
17  * This program is free software; you can redistribute it and/or modify *
18  * it under the terms of the GNU General Public License as published by *
19  * the Free Software Foundation; either version 2 of the License, or    *
20  * (at your option) any later version.                                  *
21  *                                                                      *
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.                         *
26  *                                                                      *
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,               *
30  * MA  02110-1301  USA                                                  *
31  ************************************************************************/
32
33 // Some security stuff...
34 if (!defined('__SECURITY')) {
35         exit();
36 } // END - if
37
38 // Add description as navigation point
39 addYouAreHereLink('guest', __FILE__);
40
41 if ((!isExtensionActive('sponsor'))) {
42         displayMessage('{%pipe,generateExtensionInactiveNotInstalledMessage=sponsor%}');
43         return;
44 } // END - if
45
46 // Init both results (see footer of this file)
47 $result_act = FALSE;
48 $result_pay = FALSE;
49
50 // ... and output variables
51 $OUT_ACT = '';
52 $OUT_PAY = '';
53
54 // Load all sponsor actions
55 $result_act = sqlQuery("SELECT
56         `m`.`title` AS `conv_title`,
57         `c`.`conv_rate`,
58         `c`.`conv_name`
59 FROM
60         `{?_MYSQL_PREFIX?}_sponsor_menu` AS `m`
61 LEFT JOIN
62         `{?_MYSQL_PREFIX?}_sponsor_action_convert` AS `c`
63 ON
64         `m`.`what`=`c`.`ext_name`
65 LEFT JOIN
66         `{?_MYSQL_PREFIX?}_sponsor_registry` AS `r`
67 ON
68         `m`.`what`=`r`.`ext_name`
69 WHERE
70         `m`.`action`='actions' AND
71         `r`.`is_active`='Y'
72 ORDER BY
73         `m`.`sort` ASC", __FILE__, __LINE__);
74
75 if (!ifSqlHasZeroNumRows($result_act)) {
76         // Load all actions
77         while ($content = sqlFetchArray($result_act)) {
78                 // Load row template and switch color
79                 $OUT_ACT .= loadTemplate('guest_sponsor_act_row', TRUE, $content);
80         } // END - while
81
82         // Check for pay types
83         // @TODO Cache this static data
84         $result_pay = sqlQuery('SELECT
85         `pay_name`,
86         `pay_rate`,
87         `pay_min_count`,
88         `pay_currency`
89 FROM
90         `{?_MYSQL_PREFIX?}_sponsor_paytypes`
91 ORDER BY
92         `pay_name` ASC', __FILE__, __LINE__);
93
94         if (!ifSqlHasZeroNumRows($result_pay)) {
95                 // Load all pay types
96                 while ($content = sqlFetchArray($result_pay)) {
97                         // Load row template and switch color
98                         $OUT_PAY .= loadTemplate('guest_sponsor_pay_row', TRUE, $content);
99                 } // END - while
100         } else {
101                 // No pay types setuped so far!
102                 $OUT_PAY = loadTemplate('guest_sponsor_infos_none_row', TRUE, displayMessage('{--SPONSOR_NO_ACTIONS_ACTIVATED--}', TRUE));
103         }
104 } else {
105         // No actions activated so far!
106         $OUT_ACT = loadTemplate('guest_sponsor_infos_none_row', TRUE, displayMessage('{--SPONSOR_NO_ACTIONS_ACTIVATED--}', TRUE));
107         $OUT_PAY = loadTemplate('guest_sponsor_infos_none_row', TRUE, displayMessage('{--SPONSOR_NO_ACTIONS_ACTIVATED--}', TRUE));
108 }
109
110 // Free memory
111 sqlFreeResult($result_act);
112 sqlFreeResult($result_pay);
113
114 // Transfer rows to an array
115 $content = array(
116         'actions'  => $OUT_ACT,
117         'paytypes' => $OUT_PAY
118 );
119
120 // Load main template
121 loadTemplate('guest_sponsor_infos', FALSE, $content);
122
123 // [EOF]
124 ?>