make-euros has replied me, now when you add request parameters only those from select...
[mailer.git] / inc / modules / admin / what-list_network_params.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 11/26/2009 *
4  * ===================                          Last change: 11/26/2009 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : what-list_network_params.php                     *
8  * -------------------------------------------------------------------- *
9  * Short description : List/manage network API query parameters         *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Verwaltet API-Abfrageparameter                   *
12  * -------------------------------------------------------------------- *
13  * $Revision::                                                        $ *
14  * $Date::                                                            $ *
15  * $Tag:: 0.2.1-FINAL                                                 $ *
16  * $Author::                                                          $ *
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 - 2009 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, or    *
26  * (at your option) any later version.                                  *
27  *                                                                      *
28  * This program is distributed in the hope that it will be useful,      *
29  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
30  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
31  * GNU General Public License for more details.                         *
32  *                                                                      *
33  * You should have received a copy of the GNU General Public License    *
34  * along with this program; if not, write to the Free Software          *
35  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
36  * MA  02110-1301  USA                                                  *
37  ************************************************************************/
38
39 // Some security stuff...
40 if ((!defined('__SECURITY')) || (!isAdmin())) {
41         die();
42 } // END - if
43
44 // Add description as navigation point
45 addMenuDescription('admin', __FILE__);
46
47 // These are expert settings!
48 if (doVerifyExpertSettings() != 'agreed') {
49         // Abort here
50         return;
51 } // END - if
52
53 // By default we should display list/add new forms
54 $GLOBALS['network_display'] = true;
55
56 // Handle form here
57 doNetworkHandleForm();
58
59 // Display forms?
60 if ($GLOBALS['network_display'] === false) {
61         // Abort here
62         return;
63 } // END - if
64
65 // Do we have a network selected?
66 if (isGetRequestParameterSet('network')) {
67         // Get its data for template
68         $networkData = getNetworkDataById(getRequestParameter('network'));
69
70         // Init disabled list
71         $networkData['disabled'] = array();
72
73         // Only show params from given type handler if choosen
74         $ADD = '';
75         if (isPostRequestParameterSet('network_type_id')) {
76                 // Only show from current type handler
77                 $ADD = sprintf(" AND p.`network_type_id`=%s", bigintval(postRequestParameter('network_type_id')));
78
79                 // Display message
80                 loadTemplate('admin_settings_saved', false, getMessage('ADMIN_NETWORK_PARAMS_LIST_LIMITED_TO_TYPE'));
81         } // END - if
82
83         // Load all advert types for given network
84         $result = SQL_QUERY_ESC("SELECT
85         p.`network_param_id`, t.`network_type_id`, t.`network_type_handle`, p.`request_param_key`, p.`request_param_value`, p.`request_param_default`
86 FROM
87         `{?_MYSQL_PREFIX?}_network_request_params` AS p
88 INNER JOIN
89         `{?_MYSQL_PREFIX?}_network_types` AS t
90 ON
91         p.`network_type_id`=t.`network_type_id`
92 WHERE
93         p.`network_id`=%s".$ADD."
94 ORDER BY
95         t.`network_type_handle` ASC,
96         p.`network_param_id` ASC",
97                 array(getRequestParameter('network')), __FILE__, __LINE__);
98
99         // Do we have entries?
100         if (SQL_NUMROWS($result) > 0) {
101                 // List all entries
102                 $OUT = ''; $SW = 2;
103                 while ($row = SQL_FETCHARRAY($result)) {
104                         // Add/translate some data
105                         $row['sw'] = $SW;
106
107                         // Add it to network if the type matches selected
108                         if ($row['network_type_id'] == postRequestParameter('network_type_id')) {
109                                 // Matches, then add it for disabling this entry
110                                 $networkData['disabled'][$row['request_param_key']] = true;
111                         } // END - if
112
113                         // Is default value empty or null?
114                         if ((is_null($row['request_param_default'])) || (trim($row['request_param_default']) == '')) {
115                                 // Fix it to three dashes
116                                 $row['request_param_default'] = '---';
117                         } // END - if
118
119                         // Add row template and switch color
120                         $OUT .= loadTemplate('admin_list_network_params_row', true, $row);
121                         $SW = 3 - $SW;
122                 } // END - while
123
124                 // Prepare data for template
125                 $content = array(
126                         'rows'            => $OUT,
127                         'network_id'      => getRequestParameter('network'),
128                         'network_title'   => $networkData['network_title'],
129                         'network_reflink' => $networkData['network_reflink'],
130                 );
131
132                 // Load main template
133                 loadTemplate('admin_list_network_params', false, $content);
134         } else {
135                 // No entries found
136                 loadTemplate('admin_settings_saved', false, getMaskedMessage('ADMIN_NETWORK_PARAMS_404', $networkData['network_title']));
137         }
138
139         // Free result
140         SQL_FREERESULT($result);
141
142         // Add options list for network type
143         $networkData['type_options'] = generateOptionList(
144                 'network_types',
145                 'network_type_id',
146                 'network_type_handle',
147                 postRequestParameter('network_type_id'),
148                 '',
149                 sprintf("WHERE `network_id`=%s", getRequestParameter('network'))
150         );
151
152         // Add options for parameter keys
153         $networkData['key_options'] = generateOptionList(
154                 '/ARRAY/',
155                 array(
156                         'id',
157                         'sid',
158                         'password',
159                         'reload',
160                         'max_stay',
161                         'min_stay',
162                         'currency',
163                         'type',
164                         'remain',
165                         'reward',
166                         'size',
167                         'erotic',
168                         'extra'
169                 ),
170                 array(
171                         '{--ADMIN_NETWORK_PARAMS_ID--}',
172                         '{--ADMIN_NETWORK_PARAMS_SID--}',
173                         '{--ADMIN_NETWORK_PARAMS_PASSWORD--}',
174                         '{--ADMIN_NETWORK_PARAMS_RELOAD--}',
175                         '{--ADMIN_NETWORK_PARAMS_MAXIMUM_STAY--}',
176                         '{--ADMIN_NETWORK_PARAMS_MINIMUM_STAY--}',
177                         '{--ADMIN_NETWORK_PARAMS_CURRENCY--}',
178                         '{--ADMIN_NETWORK_PARAMS_TYPE--}',
179                         '{--ADMIN_NETWORK_PARAMS_REMAIN--}',
180                         '{--ADMIN_NETWORK_PARAMS_REWARD--}',
181                         '{--ADMIN_NETWORK_PARAMS_SIZE--}',
182                         '{--ADMIN_NETWORK_PARAMS_EROTIC--}',
183                         '{--ADMIN_NETWORK_PARAMS_EXTRA--}'
184                 ),
185                 '', '', '',
186                 $networkData['disabled']
187         );
188
189         // Add form for adding new params
190         loadTemplate('admin_add_network_params', false, $networkData);
191 } else {
192         // Generate network list for this script
193         outputHtml(generateAdminNetworkList());
194 }
195
196 // [EOF]
197 ?>