2539e16300381cc65e277c1f90a87f51b06e4418
[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  *                                                                      *
14  * -------------------------------------------------------------------- *
15  * Copyright (c) 2003 - 2008 by Roland Haeder                           *
16  * For more information visit: http://www.mxchange.org                  *
17  *                                                                      *
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.       *
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         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4)."/security.php";
36         require($INC);
37 } elseif ((!EXT_IS_ACTIVE("sponsor"))) {
38         addFatalMessage(__FILE__, __LINE__, getMessage('EXTENSION_PROBLEM_EXT_INACTIVE'), "sponsor");
39         return;
40 }
41
42 // Add description as navigation point
43 ADD_DESCR("guest", __FILE__);
44
45 // Init both results (see footer of this file)
46 $result_act = false;
47 $result_pay = false;
48
49 // Load all sponsor actions
50 $result_act = SQL_QUERY("SELECT DISTINCT m.title, c.conv_rate, c.conv_name
51 FROM `{!_MYSQL_PREFIX!}_sponsor_menu` AS m
52 LEFT JOIN `{!_MYSQL_PREFIX!}_sponsor_action_convert` AS c ON m.what=c.ext_name
53 LEFT JOIN `{!_MYSQL_PREFIX!}_sponsor_registry` AS r ON m.what=r.ext_name
54 WHERE m.action='actions' AND r.is_active='Y'
55 ORDER BY m.sort ASC", __FILE__, __LINE__);
56
57 if (SQL_NUMROWS($result_act) > 0) {
58         // Load all actions
59         $OUT_ACT = ""; $SW = 2;
60         while ($content = SQL_FETCHARRAY($result_act)) {
61                 // Prepare data for the row template
62                 // @TODO Rewritings: conv->conv_rate,name->conv_name in template
63                 $content = array(
64                         'sw'    => $SW,
65                         'title' => $content['title'],
66                         'conv'  => round($content['conv_rate']),
67                         'name'  => $content['conv_name'],
68                 );
69
70                 // Load row template and switch color
71                 $OUT_ACT .= LOAD_TEMPLATE("guest_sponsor_act_row", true, $content);
72                 $SW = 3 - $SW;
73         } // END - while
74
75         // Check for pay types
76         $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__);
77         if (SQL_NUMROWS($result_pay) > 0) {
78                 // Load all pay types
79                 $OUT_PAY = ""; $SW = 2;
80                 while ($content = SQL_FETCHARRAY($result_pay)) {
81                         // Prepare data for the row template
82                         // @TODO Rewritings: name->pay_name,min->pay_min_count,min->pay_min_count,curr->pay_currency
83                         $content = array(
84                                 'sw'    => $SW,
85                                 'name'  => $content['pay_name'],
86                                 'rate'  => TRANSLATE_COMMA($content['pay_rate']),
87                                 'min'   => $content['pay_min_count'],
88                                 'curr'  => $content['pay_currency'],
89                                 'price' => TRANSLATE_COMMA($content['pay_min_count']),
90                         );
91
92                         // Load row template and switch color
93                         $OUT_PAY .= LOAD_TEMPLATE("guest_sponsor_pay_row", true, $content);
94                         $SW = 3 - $SW;
95                 }
96         } else {
97                 // No pay types setuped so far!
98                 $OUT_PAY = LOAD_TEMPLATE("guest_sponsor_infos_none_row", LOAD_TEMPLATE("admin_settings_saved", true, getMessage('SPONSOR_NO_ACTIONS_ACTIVATED')));
99         }
100 } else {
101         // No actions activated so far!
102         $OUT_ACT = LOAD_TEMPLATE("guest_sponsor_infos_none_row", LOAD_TEMPLATE("admin_settings_saved", true, getMessage('SPONSOR_NO_ACTIONS_ACTIVATED')));
103         $OUT_PAY = LOAD_TEMPLATE("guest_sponsor_infos_none_row", LOAD_TEMPLATE("admin_settings_saved", true, getMessage('SPONSOR_NO_ACTIONS_ACTIVATED')));
104 }
105
106 // Free memory
107 SQL_FREERESULT($result_act);
108 SQL_FREERESULT($result_pay);
109
110 // Transfer rows to an array
111 $content = array(
112         'actions'  => $OUT_ACT,
113         'paytypes' => $OUT_PAY
114 );
115
116 // Load main template
117 LOAD_TEMPLATE("guest_sponsor_infos", false, $content);
118
119 //
120 ?>