]> git.mxchange.org Git - mailer.git/blob - inc/modules/admin/what-config_network_types.php
Extension ext-network continued:
[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_handler`,
70         `network_type_reload_time_unit`,
71         `network_active`,
72         NULL AS `network_data_id`,
73         NULL AS `network_max_reload_time`,
74         NULL AS `network_min_waiting_time`,
75         NULL AS `network_min_remain_clicks`,
76         NULL AS `network_min_payment`,
77         NULL AS `network_allow_erotic`
78 FROM
79         `{?_MYSQL_PREFIX?}_network_types`
80 WHERE
81         `network_id`=%s AND
82         `network_type_id`=%s
83 LIMIT 1',
84                         array(
85                                 bigintval(getRequestElement('network_id')),
86                                 bigintval(getRequestElement('network_type_id'))
87                         ), __FUNCTION__, __LINE__);
88
89                 // Do we have a record?
90                 if (SQL_NUMROWS($result) == 1) {
91                         // Load it
92                         $content = SQL_FETCHARRAY($result);
93
94                         // Is the network active?
95                         if ($content['network_active'] == 'N') {
96                                 // Not active
97                                 displayMessage('{--ADMIN_NETWORK_NOT_ACTIVE--}');
98                                 return;
99                         } // END - if
100
101                         // Check for network type configuration
102                         $result_config = SQL_QUERY_ESC('SELECT
103         `network_data_id`,
104         `network_max_reload_time`,
105         `network_min_waiting_time`,
106         `network_min_remain_clicks`,
107         `network_min_payment`,
108         `network_allow_erotic`
109 FROM
110         `{?_MYSQL_PREFIX?}_network_types_config`
111 WHERE
112         `network_id`=%s AND
113         `network_type_id`=%s
114 LIMIT 1',
115                                 array(
116                                         bigintval(getRequestElement('network_id')),
117                                         bigintval($content['network_type_id'])
118                                 ), __FUNCTION__, __LINE__);
119
120                         // Use template for adding
121                         $templateName = 'admin_add_config_network_type_form';
122
123                         // Do we also have configuration?
124                         if (SQL_NUMROWS($result_config) == 1) {
125                                 // Load as well and merge it
126                                 $content = merge_array($content, SQL_FETCHARRAY($result_config));
127
128                                 // Use template for editing
129                                 $templateName = 'admin_edit_config_network_type_form';
130                         } // END - if
131
132                         // Free result
133                         SQL_FREERESULT($result_config);
134
135                         // "Translate" some values
136                         $content['network_max_reload_time']  = createTimeSelections($content['network_max_reload_time'], 'network_max_reload_time', 'WDhms');
137
138                         // Load template
139                         loadTemplate($templateName, false, $content);
140
141                         // Abort here
142                         return;
143                 } else {
144                         // No entry found
145                         displayMessage('{%message,ADMIN_ADD_CONFIG_NETWORK_HANDLER_TYPE_404', bigintval(getRequestElement('network_id')) . '/' . bigintval(getRequestElement('network_type_id')));
146                 } // END - if
147
148                 // Free result
149                 SQL_FREERESULT($result);
150         } // END - if
151
152         // Get all type handlers
153         $result = SQL_QUERY_ESC('SELECT
154         `network_id`,
155         `network_type_id`,
156         `network_type_handler`,
157         `network_type_reload_time_unit`
158 FROM
159         `{?_MYSQL_PREFIX?}_network_types`
160 WHERE
161         `network_id`=%s
162 ORDER BY
163         `network_type_handler` ASC',
164                 array(
165                         bigintval(getRequestElement('network_id'))
166                 ), __FUNCTION__, __LINE__);
167
168         // Do we have entries left?
169         if (!SQL_HASZERONUMS($result)) {
170                 // Init row output
171                 $OUT = '';
172
173                 // List all entries
174                 while ($content = SQL_FETCHARRAY($result)) {
175                         // Check if config entry is there
176                         $result_config = SQL_QUERY_ESC('SELECT
177         `network_data_id`,
178         `network_max_reload_time`,
179         `network_min_waiting_time`,
180         `network_min_remain_clicks`,
181         `network_min_payment`,
182         `network_allow_erotic`
183 FROM
184         `{?_MYSQL_PREFIX?}_network_types_config`
185 WHERE
186         `network_id`=%s AND
187         `network_type_id`=%s
188 LIMIT 1',
189                                 array(
190                                         bigintval(getRequestElement('network_id')),
191                                         bigintval($content['network_type_id'])
192                                 ), __FUNCTION__, __LINE__);
193
194                         // Do we have an entry?
195                         if (SQL_NUMROWS($result_config) == 1) {
196                                 // Load this data as well
197                                 $content = merge_array($content, SQL_FETCHARRAY($result_config));
198
199                                 // Add it with extra template
200                                 $content['network_type_config_content'] = loadTemplate('admin_show_config_network_type', true, $content);
201                         } else {
202                                 // No configuration found, so display form
203                                 $content['network_type_config_content'] = loadTemplate('admin_add_config_network_type', true, $content);
204                         }
205
206                         // Free result
207                         SQL_FREERESULT($result_config);
208
209                         // Load row template
210                         $OUT .= loadTemplate('admin_config_network_types_row', true, $content);
211                 } // END - while
212
213                 // Prepare array for main template
214                 $content = array(
215                         'network_id' => bigintval(getRequestElement('network_id')),
216                         'rows'       => $OUT
217                 );
218
219                 // Load main template
220                 loadTemplate('admin_config_network_types', false, $content);
221         } else {
222                 // No entries found
223                 displayMessage('{%message,ADMIN_CONFIG_NETWORK_HANDLER_TYPES_404=' . bigintval(getRequestElement('network_id')) . '%}');
224         }
225
226         // Free result
227         SQL_FREERESULT($result);
228 } else {
229         // Generate network list for this script
230         outputHtml(generateAdminNetworkList());
231 }
232
233 // [EOF]
234 ?>