]> git.mxchange.org Git - mailer.git/blob - inc/modules/admin/what-config_network_types.php
Extension ext-network continued, links in bug report mail added:
[mailer.git] / inc / modules / admin / what-config_network_types.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 08/13/2011 *
4  * ===================                          Last change: 08/13/2011 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : what-config_network_types.php                    *
8  * -------------------------------------------------------------------- *
9  * Short description : Handler types configuration                      *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Werbe-Handler-Konfiguration                      *
12  * -------------------------------------------------------------------- *
13  * $Revision::                                                        $ *
14  * $Date::                                                            $ *
15  * $Tag:: 0.2.1-FINAL                                                 $ *
16  * $Author::                                                          $ *
17  * -------------------------------------------------------------------- *
18  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
19  * Copyright (c) 2009 - 2011 by Mailer Developer Team                   *
20  * For more information visit: http://mxchange.org                      *
21  *                                                                      *
22  * This program is free software; you can redistribute it and/or modify *
23  * it under the terms of the GNU General Public License as published by *
24  * the Free Software Foundation; either version 2 of the License, or    *
25  * (at your option) any later version.                                  *
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')) || (!isAdmin())) {
40         die();
41 } // END - if
42
43 // Add description as navigation point
44 addYouAreHereLink('admin', __FILE__);
45
46 // By default we should display list/add new forms
47 $GLOBALS['network_display'] = true;
48
49 // Handle form here
50 doNetworkHandleForm();
51
52 // Display forms?
53 if ($GLOBALS['network_display'] === false) {
54         // Abort here
55         return;
56 } // END - if
57
58 // Do we have a network selected?
59 if (isGetRequestElementSet('network_id')) {
60         // Set current network id
61         setCurrentNetworkId(getRequestElement('network_id'));
62
63         // Is a network type handler selected?
64         if (isGetRequestElementSet('network_type_id')) {
65                 // Load data for given network
66                 $result = SQL_QUERY_ESC('SELECT
67         `network_id`,
68         `network_type_id`,
69         `network_type_handle`,
70         `network_type_api_url`,
71         `network_type_click_url`,
72         `network_type_banner_url`,
73         NULL AS `network_data_id`,
74         NULL AS `network_max_reload_time`,
75         NULL AS `network_min_waiting_time`,
76         NULL AS `network_min_remain_clicks`,
77         NULL AS `network_min_payment`,
78         NULL AS `network_allow_erotic`
79 FROM
80         `{?_MYSQL_PREFIX?}_network_types`
81 WHERE
82         `network_id`=%s AND
83         `network_type_id`=%s
84 LIMIT 1',
85                         array(
86                                 bigintval(getRequestElement('network_id')),
87                                 bigintval(getRequestElement('network_type_id'))
88                         ), __FUNCTION__, __LINE__);
89
90                 // Do we have a record?
91                 if (SQL_NUMROWS($result) == 1) {
92                         // Load it
93                         $content = SQL_FETCHARRAY($result);
94
95                         // Check for network type configuration
96                         $result_config = SQL_QUERY_ESC('SELECT
97         `network_data_id`,
98         `network_max_reload_time`,
99         `network_min_waiting_time`
100         `network_min_remain_clicks`,
101         `network_min_payment`,
102         `network_allow_erotic`
103 FROM
104         `{?_MYSQL_PREFIX?}_network_types_config`
105 WHERE
106         `network_id`=%s AND
107         `network_type_id`=%s
108 LIMIT 1',
109                                 array(
110                                         bigintval(getRequestElement('network_id')),
111                                         bigintval($content['network_type_id'])
112                                 ), __FUNCTION__, __LINE__);
113
114                         // Do we also have configuration?
115                         if (SQL_NUMROWS($result_config) == 1) {
116                                 // Load as well and merge it
117                                 $content = merge_array($content, SQL_FETCHARRAY($result_config));
118                         } // END - if
119
120                         // Free result
121                         SQL_FREERESULT($result_config);
122
123                         // Load template
124                         loadTemplate('admin_add_config_network_type_form', false, $content);
125
126                         // Abort here
127                         return;
128                 } else {
129                         // No entry found
130                         displayMessage('{%message,ADMIN_ADD_CONFIG_NETWORK_TYPE_404', bigintval(getRequestElement('network_id')) . '/' . bigintval(getRequestElement('network_type_id')));
131                 } // END - if
132
133                 // Free result
134                 SQL_FREERESULT($result);
135         } // END - if
136
137         // Get all type handlers
138         $result = SQL_QUERY_ESC('SELECT
139         `network_id`,
140         `network_type_id`,
141         `network_type_handle`,
142         `network_type_api_url`,
143         `network_type_click_url`,
144         `network_type_banner_url`
145 FROM
146         `{?_MYSQL_PREFIX?}_network_types`
147 WHERE
148         `network_id`=%s
149 ORDER BY
150         `network_type_handle` ASC',
151                 array(
152                         bigintval(getRequestElement('network_id'))
153                 ), __FUNCTION__, __LINE__);
154
155         // Do we have entries left?
156         if (!SQL_HASZERONUMS($result)) {
157                 // Init row output
158                 $OUT = '';
159
160                 // List all entries
161                 while ($content = SQL_FETCHARRAY($result)) {
162                         // Check if config entry is there
163                         $result_config = SQL_QUERY_ESC('SELECT
164         `network_data_id`,
165         `network_max_reload_time`,
166         `network_min_waiting_time`,
167         `network_min_remain_clicks`,
168         `network_min_payment`,
169         `network_allow_erotic`
170 FROM
171         `{?_MYSQL_PREFIX?}_network_types_config`
172 WHERE
173         `network_id`=%s AND
174         `network_type_id`=%s
175 LIMIT 1',
176                                 array(
177                                         bigintval(getRequestElement('network_id')),
178                                         bigintval($content['network_type_id'])
179                                 ), __FUNCTION__, __LINE__);
180
181                         // Do we have an entry?
182                         if (SQL_NUMROWS($result_config) == 1) {
183                                 // Load this data as well
184                                 $contentConfig = SQL_FETCHARRAY($result_config);
185
186                                 // Add it with extra template
187                                 $content['network_type_config_content'] = loadTemplate('admin_show_config_network_type', true, $contentConfig);
188                         } else {
189                                 // No configuration found, so display form
190                                 $content['network_type_config_content'] = loadTemplate('admin_add_config_network_type', true, $content);
191                         }
192
193                         // Free result
194                         SQL_FREERESULT($result_config);
195
196                         // Load row template
197                         $OUT .= loadTemplate('admin_config_network_types_row', true, $content);
198                 } // END - while
199
200                 // Prepare array for main template
201                 $content = array(
202                         'network_id' => bigintval(getRequestElement('network_id')),
203                         'rows'       => $OUT
204                 );
205
206                 // Load main template
207                 loadTemplate('admin_config_network_types', false, $content);
208         } else {
209                 // No entries found
210                 displayMessage('{%message,ADMIN_CONFIG_NETWORK_TYPES_404=' . bigintval(getRequestElement('network_id')) . '%}');
211         }
212
213         // Free result
214         SQL_FREERESULT($result);
215 } else {
216         // Generate network list for this script
217         outputHtml(generateAdminNetworkList());
218 }
219
220 // [EOF]
221 ?>