RevBomb patch applied (thanks to profi-concept)
[mailer.git] / inc / modules / guest / what-sponsor_infos.php
1 <?php
2 /************************************************************************
3  * MXChange v0.2.1                                    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  * $Revision:: 856                                                    $ *
14  * $Date:: 2009-03-06 20:24:32 +0100 (Fr, 06. Mär 2009)              $ *
15  * $Tag:: 0.2.1-FINAL                                                 $ *
16  * $Author:: stelzi                                                   $ *
17  * Needs to be in all Files and every File needs "svn propset           *
18  * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
19  * -------------------------------------------------------------------- *
20  * Copyright (c) 2003 - 2008 by Roland Haeder                           *
21  * For more information visit: http://www.mxchange.org                  *
22  *                                                                      *
23  * This program is free software. You can redistribute it and/or modify *
24  * it under the terms of the GNU General Public License as published by *
25  * the Free Software Foundation; either version 2 of the License.       *
26  *                                                                      *
27  * This program is distributed in the hope that it will be useful,      *
28  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
29  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
30  * GNU General Public License for more details.                         *
31  *                                                                      *
32  * You should have received a copy of the GNU General Public License    *
33  * along with this program; if not, write to the Free Software          *
34  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
35  * MA  02110-1301  USA                                                  *
36  ************************************************************************/
37
38 // Some security stuff...
39 if (!defined('__SECURITY')) {
40         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4)."/security.php";
41         require($INC);
42 } elseif ((!EXT_IS_ACTIVE("sponsor"))) {
43         addFatalMessage(__FILE__, __LINE__, getMessage('EXTENSION_PROBLEM_EXT_INACTIVE'), "sponsor");
44         return;
45 }
46
47 // Add description as navigation point
48 ADD_DESCR("guest", __FILE__);
49
50 // Init both results (see footer of this file)
51 $result_act = false;
52 $result_pay = false;
53
54 // Load all sponsor actions
55 $result_act = SQL_QUERY("SELECT DISTINCT m.title, c.conv_rate, c.conv_name
56 FROM `{!_MYSQL_PREFIX!}_sponsor_menu` AS m
57 LEFT JOIN `{!_MYSQL_PREFIX!}_sponsor_action_convert` AS c ON m.what=c.ext_name
58 LEFT JOIN `{!_MYSQL_PREFIX!}_sponsor_registry` AS r ON m.what=r.ext_name
59 WHERE m.action='actions' AND r.is_active='Y'
60 ORDER BY m.sort ASC", __FILE__, __LINE__);
61
62 if (SQL_NUMROWS($result_act) > 0) {
63         // Load all actions
64         $OUT_ACT = ""; $SW = 2;
65         while ($content = SQL_FETCHARRAY($result_act)) {
66                 // Prepare data for the row template
67                 // @TODO Rewritings: conv->conv_rate,name->conv_name in template
68                 $content = array(
69                         'sw'    => $SW,
70                         'title' => $content['title'],
71                         'conv'  => round($content['conv_rate']),
72                         'name'  => $content['conv_name'],
73                 );
74
75                 // Load row template and switch color
76                 $OUT_ACT .= LOAD_TEMPLATE("guest_sponsor_act_row", true, $content);
77                 $SW = 3 - $SW;
78         } // END - while
79
80         // Check for pay types
81         $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__);
82         if (SQL_NUMROWS($result_pay) > 0) {
83                 // Load all pay types
84                 $OUT_PAY = ""; $SW = 2;
85                 while ($content = SQL_FETCHARRAY($result_pay)) {
86                         // Prepare data for the row template
87                         // @TODO Rewritings: name->pay_name,min->pay_min_count,min->pay_min_count,curr->pay_currency
88                         $content = array(
89                                 'sw'    => $SW,
90                                 'name'  => $content['pay_name'],
91                                 'rate'  => TRANSLATE_COMMA($content['pay_rate']),
92                                 'min'   => $content['pay_min_count'],
93                                 'curr'  => $content['pay_currency'],
94                                 'price' => TRANSLATE_COMMA($content['pay_min_count']),
95                         );
96
97                         // Load row template and switch color
98                         $OUT_PAY .= LOAD_TEMPLATE("guest_sponsor_pay_row", true, $content);
99                         $SW = 3 - $SW;
100                 }
101         } else {
102                 // No pay types setuped so far!
103                 $OUT_PAY = LOAD_TEMPLATE("guest_sponsor_infos_none_row", LOAD_TEMPLATE("admin_settings_saved", true, getMessage('SPONSOR_NO_ACTIONS_ACTIVATED')));
104         }
105 } else {
106         // No actions activated so far!
107         $OUT_ACT = LOAD_TEMPLATE("guest_sponsor_infos_none_row", LOAD_TEMPLATE("admin_settings_saved", true, getMessage('SPONSOR_NO_ACTIONS_ACTIVATED')));
108         $OUT_PAY = LOAD_TEMPLATE("guest_sponsor_infos_none_row", LOAD_TEMPLATE("admin_settings_saved", true, getMessage('SPONSOR_NO_ACTIONS_ACTIVATED')));
109 }
110
111 // Free memory
112 SQL_FREERESULT($result_act);
113 SQL_FREERESULT($result_pay);
114
115 // Transfer rows to an array
116 $content = array(
117         'actions'  => $OUT_ACT,
118         'paytypes' => $OUT_PAY
119 );
120
121 // Load main template
122 LOAD_TEMPLATE("guest_sponsor_infos", false, $content);
123
124 //
125 ?>