]> git.mxchange.org Git - mailer.git/blob - inc/libs/network_functions.php
More networks added, EL "post" added, templates fixed:
[mailer.git] / inc / libs / network_functions.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 11/04/2009 *
4  * ===================                          Last change: 11/04/2009 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : network_functions.php                            *
8  * -------------------------------------------------------------------- *
9  * Short description : Functions for ext-network                        *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Funktionen fuer ext-network                      *
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  * Copyright (c) 2009, 2010 by Mailer Developer Team                    *
22  * For more information visit: http://www.mxchange.org                  *
23  *                                                                      *
24  * This program is free software; you can redistribute it and/or modify *
25  * it under the terms of the GNU General Public License as published by *
26  * the Free Software Foundation; either version 2 of the License, or    *
27  * (at your option) any later version.                                  *
28  *                                                                      *
29  * This program is distributed in the hope that it will be useful,      *
30  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
31  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
32  * GNU General Public License for more details.                         *
33  *                                                                      *
34  * You should have received a copy of the GNU General Public License    *
35  * along with this program; if not, write to the Free Software          *
36  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
37  * MA  02110-1301  USA                                                  *
38  ************************************************************************/
39
40 // Some security stuff...
41 if (!defined('__SECURITY')) {
42         die();
43 } // END - if
44
45 // Private setter for current network id
46 function setCurrentNetworkId ($id) {
47         $GLOBALS['current_network_id'] = bigintval($id);
48 }
49
50 // Private getter for current network id
51 function getCurrentNetworkId () {
52         return $GLOBALS['current_network_id'];
53 }
54
55 // Handle a (maybe) sent form here
56 function doNetworkHandleForm () {
57         // Was the form sent?
58         if ((isFormSent()) || (isFormSent('edit')) || (isFormSent('del')) || (isFormSent('change')) || (isFormSent('remove'))) {
59                 // Do we have a 'do'?
60                 if (isGetRequestParameterSet('do')) {
61                         // Process the request
62                         doAdminNetworkProcessForm();
63                 } else {
64                         // No 'do' found
65                         loadTemplate('admin_settings_unsaved', false, '{--ADMIN_NETWORK_DO_404--}');
66                 }
67         } // END - if
68 }
69
70 // Processes an admin form
71 function doAdminNetworkProcessForm () {
72         // Form really sent?
73         if ((!isFormSent()) && (!isFormSent('edit')) && (!isFormSent('del')) && (!isFormSent('change')) && (!isFormSent('remove'))) {
74                 // Abort here
75                 loadTemplate('admin_settings_unsaved', false, '{--ADMIN_NETWORK_FORM_NOT_SENT--}');
76                 return;
77         } elseif (!isGetRequestParameterSet('do')) {
78                 // No 'do' found
79                 loadTemplate('admin_settings_unsaved', false, '{--ADMIN_NETWORK_DO_404--}');
80                 return;
81         }
82
83         // Create function name
84         $functionName = sprintf("doAdminNetworkProcess%s", capitalizeUnderscoreString(getRequestParameter('do')));
85
86         // Is the function valid?
87         if (!function_exists($functionName)) {
88                 // Invalid function name
89                 debug_report_bug(__FUNCTION__, __LINE__, 'Invalid do ' . getRequestParameter('do') . ', function ' . $functionName .' does not exist.', false);
90         } // END - if
91
92         // Call-back the method handling our request
93         call_user_func($functionName);
94 }
95
96 // Checks wether the (short) network name is already used (valid)
97 function isNetworkNameValid ($name) {
98         // Query for it
99         $result = SQL_QUERY_ESC("SELECT `network_id` FROM `{?_MYSQL_PREFIX?}_network_data` WHERE `network_short_name`='%s' LIMIT 1",
100                 array($name), __FUNCTION__, __LINE__);
101
102         // Does it exist?
103         $isValid = (SQL_NUMROWS($result) == 1);
104
105         // Free result
106         SQL_FREERESULT($result);
107
108         // Return result
109         return $isValid;
110 }
111
112 // Checks wether the given network type is already used (valid)
113 function isNetworkTypeHandleValid ($type, $networkId) {
114         // Query for it
115         $result = SQL_QUERY_ESC("SELECT `network_type_id` FROM `{?_MYSQL_PREFIX?}_network_types` WHERE `network_id`=%s AND `network_type_handle`='%s' LIMIT 1",
116                 array($networkId, $type), __FUNCTION__, __LINE__);
117
118         // Does it exist?
119         $isValid = (SQL_NUMROWS($result) == 1);
120
121         // Free result
122         SQL_FREERESULT($result);
123
124         // Return result
125         return $isValid;
126 }
127
128 // Checks wether the given network request parameter is already used (valid)
129 function isNetworkRequestParameterValid ($key, $type, $networkId) {
130         // Query for it
131         $result = SQL_QUERY_ESC("SELECT `network_param_id` FROM `{?_MYSQL_PREFIX?}_network_request_params` WHERE `network_id`=%s AND `network_type_id`=%s AND `request_param_key`='%s' LIMIT 1",
132                 array($networkId, $type, $key), __FUNCTION__, __LINE__);
133
134         // Does it exist?
135         $isValid = (SQL_NUMROWS($result) == 1);
136
137         // Free result
138         SQL_FREERESULT($result);
139
140         // Return result
141         return $isValid;
142 }
143
144 // Checks wether the given network API array translation
145 function isNetworkApiTranslationValid ($key, $type, $networkId) {
146         // Query for it
147         $result = SQL_QUERY_ESC("SELECT `network_api_id` FROM `{?_MYSQL_PREFIX?}_network_api_translation` WHERE `network_id`=%s AND `network_type_id`=%s AND `network_api_index`='%s' LIMIT 1",
148                 array($networkId, $type, $key), __FUNCTION__, __LINE__);
149
150         // Does it exist?
151         $isValid = (SQL_NUMROWS($result) == 1);
152
153         // Free result
154         SQL_FREERESULT($result);
155
156         // Return result
157         return $isValid;
158 }
159
160 // "Getter" for a network's data by provided id number
161 function getNetworkDataById ($id, $column = '') {
162         // Ids lower one are not accepted
163         if ($id < 1) {
164                 // Not good, should be fixed
165                 debug_report_bug(__FUNCTION__, __LINE__, 'Network id ' . $id . ' is smaller than 1.');
166         } // END - if
167
168         // Set current network id
169         setCurrentNetworkId($id);
170
171         // Is it cached?
172         if (!isset($GLOBALS['network_data'][$id])) {
173                 // By default we have no data
174                 $GLOBALS['network_data'][$id] = array();
175
176                 // Query for the network data
177                 $result = SQL_QUERY_ESC("SELECT
178         `network_id`, `network_short_name`, `network_title`, `network_reflink`, `network_data_seperator`, `network_row_seperator`, `network_request_type`, `network_charset`
179 FROM
180         `{?_MYSQL_PREFIX?}_network_data`
181 WHERE
182         `network_id`=%s
183 LIMIT 1",
184                         array(bigintval($id)), __FUNCTION__, __LINE__);
185
186                 // Do we have an entry?
187                 if (SQL_NUMROWS($result) == 1) {
188                         // Then get it
189                         $GLOBALS['network_data'][$id] = SQL_FETCHARRAY($result);
190                 } // END - if
191
192                 // Free result
193                 SQL_FREERESULT($result);
194         } // END - if
195
196         // Return result
197         if (empty($column)) {
198                 // Return array
199                 return $GLOBALS['network_data'][$id];
200         } else {
201                 // Return column
202                 return $GLOBALS['network_data'][$id][$column];
203         }
204 }
205
206 // "Getter" for a network's data by provided type id number
207 function getNetworkDataByTypeId ($id, $column = '') {
208         // Ids lower one are not accepted
209         if ($id < 1) {
210                 // Not good, should be fixed
211                 debug_report_bug(__FUNCTION__, __LINE__, 'Network type id ' . $id . ' is smaller than 1.');
212         } // END - if
213
214         // Set current network id
215         setCurrentNetworkId($id);
216
217         // Is it cached?
218         if (!isset($GLOBALS['network_data'][$id])) {
219                 // By default we have no data
220                 $GLOBALS['network_data'][$id] = array();
221
222                 // Query for the network data
223                 $result = SQL_QUERY_ESC("SELECT
224         d.`network_id`, d.`network_short_name`, d.`network_title`, d.`network_reflink`, d.`network_data_seperator`, d.`network_row_seperator`, d.`network_request_type`, d.`network_charset`,
225         t.`network_type_handle`, t.`network_type_api_url`, t.`network_type_click_url`, t.`network_type_banner_url`
226 FROM
227         `{?_MYSQL_PREFIX?}_network_data` AS d
228 LEFT JOIN
229         `{?_MYSQL_PREFIX?}_network_types` AS t
230 ON
231         d.`network_id`=t.`network_id`
232 WHERE
233         t.`network_type_id`=%s
234 LIMIT 1",
235                         array(bigintval($id)), __FUNCTION__, __LINE__);
236
237                 // Do we have an entry?
238                 if (SQL_NUMROWS($result) == 1) {
239                         // Then get it
240                         $GLOBALS['network_data'][$id] = SQL_FETCHARRAY($result);
241                 } // END - if
242
243                 // Free result
244                 SQL_FREERESULT($result);
245         } // END - if
246
247         // Return result
248         if (empty($column)) {
249                 // Return array
250                 return $GLOBALS['network_data'][$id];
251         } else {
252                 // Return column
253                 return $GLOBALS['network_data'][$id][$column];
254         }
255 }
256
257 // "Getter" for a network type data by provided id number
258 function getNetworkTypeDataById ($id) {
259         // Ids lower one are not accepted
260         if ($id < 1) {
261                 // Not good, should be fixed
262                 debug_report_bug(__FUNCTION__, __LINE__, 'Network type id ' . $id . ' is smaller than 1.');
263         } // END - if
264
265         // By default we have no data
266         $GLOBALS['network_type_data'][$id] = array();
267
268         // Query for the network data
269         $result = SQL_QUERY_ESC("SELECT
270         `network_type_id`, `network_id`, `network_type_handle`, `network_type_api_url`, `network_type_click_url`, `network_type_banner_url`
271 FROM
272         `{?_MYSQL_PREFIX?}_network_types`
273 WHERE
274         `network_type_id`=%s
275 LIMIT 1",
276                 array(bigintval($id)), __FUNCTION__, __LINE__);
277
278         // Do we have an entry?
279         if (SQL_NUMROWS($result) == 1) {
280                 // Then get it
281                 $GLOBALS['network_type_data'][$id] = SQL_FETCHARRAY($result);
282         } // END - if
283
284         // Free result
285         SQL_FREERESULT($result);
286
287         // Return result
288         return $GLOBALS['network_type_data'][$id];
289 }
290
291 // "Getter" for a network request parameter data by provided id number
292 function getNetworkRequestParamsDataById ($id) {
293         // Ids lower one are not accepted
294         if ($id < 1) {
295                 // Not good, should be fixed
296                 debug_report_bug(__FUNCTION__, __LINE__, 'Network request parameter id ' . $id . ' is smaller than 1.');
297         } // END - if
298
299         // By default we have no data
300         $networkRequestData = array();
301
302         // Query for the network data
303         $result = SQL_QUERY_ESC("SELECT
304         `network_param_id`, `network_id`, `network_type_id`, `request_param_key`, `request_param_value`, `request_param_default`
305 FROM
306         `{?_MYSQL_PREFIX?}_network_request_params`
307 WHERE
308         `network_param_id`=%s
309 LIMIT 1",
310                 array(bigintval($id)), __FUNCTION__, __LINE__);
311
312         // Do we have an entry?
313         if (SQL_NUMROWS($result) == 1) {
314                 // Then get it
315                 $networkRequestData = SQL_FETCHARRAY($result);
316         } // END - if
317
318         // Free result
319         SQL_FREERESULT($result);
320
321         // Return result
322         return $networkRequestData;
323 }
324
325 // Updates given network (id) with data from array
326 function doNetworkUpdateDataByArray ($id, $networkData) {
327         // Ids lower one are not accepted
328         if ($id < 1) {
329                 // Not good, should be fixed
330                 debug_report_bug(__FUNCTION__, __LINE__, 'Network id ' . $id . ' is smaller than 1.');
331         } // END - if
332
333         // Just call our inner method
334         return adminSaveSettings($networkData, '_network_data', sprintf("`network_id`=%s", bigintval($id)), array(), false, false);
335 }
336
337 // Updates given network type handler (id) with data from array
338 function doNetworkUpdateTypeByArray ($id, $networkTypeData) {
339         // Ids lower one are not accepted
340         if ($id < 1) {
341                 // Not good, should be fixed
342                 debug_report_bug(__FUNCTION__, __LINE__, 'Network type handler id ' . $id . ' is smaller than 1.');
343         } // END - if
344
345         // Just call our inner method
346         return adminSaveSettings($networkTypeData, '_network_types', sprintf("`network_type_id`=%s", bigintval($id)), array(), false, false);
347 }
348
349 // Updates given network request parameters (id) with data from array
350 function doNetworkUpdateParamsByArray ($id, $networkParamData) {
351         // Ids lower one are not accepted
352         if ($id < 1) {
353                 // Not good, should be fixed
354                 debug_report_bug(__FUNCTION__, __LINE__, 'Network request parameter id ' . $id . ' is smaller than 1.');
355         } // END - if
356
357         // Just call our inner method
358         return adminSaveSettings($networkParamData, '_network_request_params', sprintf("`network_param_id`=%s", bigintval($id)), array(), false, false);
359 }
360
361 // Removes given network entry
362 function doAdminRemoveNetworkEntry ($table, $column, $id, $limit = 1) {
363         // Remove the entry
364         SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_network_%s` WHERE `%s`=%s LIMIT %s",
365                 array($table, $column, $id, $limit), __FUNCTION__, __LINE__);
366
367         // Return affected rows
368         return SQL_AFFECTEDROWS();
369 }
370
371 // Generates a list of networks for given script and returns it
372 function generateAdminNetworkList () {
373         // Init output
374         $content = '';
375
376         // Query for all networks
377         $result = SQL_QUERY('SELECT
378         `network_id`, `network_short_name`, `network_title`
379 FROM
380         `{?_MYSQL_PREFIX?}_network_data`
381 ORDER BY
382         `network_short_name` ASC', __FUNCTION__, __LINE__);
383
384         // Do we have entries?
385         if (!SQL_HASZERONUMS($result)) {
386                 // List all entries
387                 $rows = array();
388                 while ($row = SQL_FETCHARRAY($result)) {
389                         // Is this valid, then add it
390                         if ((is_array($row)) && (isset($row['network_id']))) {
391                                 // Add entry
392                                 $rows[$row['network_id']] = $row;
393                         } // END - if
394                 } // END - while
395
396                 // Generate the selection box
397                 $content = generateSelectionBoxFromArray($rows, 'network', 'network_id');
398         } else {
399                 // Nothing selected
400                 $content = loadTemplate('admin_settings_unsaved', false, '{--ADMIN_ENTRIES_404--}');
401         }
402
403         // Free the result
404         SQL_FREERESULT($result);
405
406         // Return the list
407         return $content;
408 }
409
410 // Generator (somewhat getter) for a list of network types for given network id
411 function generateAdminNetworkTypeList ($networkId) {
412         // Init content
413         $content = '';
414
415         // Query all types of this network
416         $result = SQL_QUERY_ESC("SELECT
417         `network_type_id`, `network_type_handle`
418 FROM
419         `{?_MYSQL_PREFIX?}_network_types`
420 WHERE
421         `network_id`=%s
422 ORDER BY
423         `network_type_handle` ASC",
424                 array(
425                         bigintval($networkId)
426                 ), __FUNCTION__, __LINE__);
427
428         // Do we have entries?
429         if (!SQL_HASZERONUMS($result)) {
430                 // List all entries
431                 $rows = array();
432                 while ($row = SQL_FETCHARRAY($result)) {
433                         // Is this valid, then add it
434                         if ((is_array($row)) && (isset($row['network_type_id']))) {
435                                 // Add entry
436                                 $rows[$row['network_type_id']] = $row;
437                         } // END - if
438                 } // END - while
439
440                 // Generate the selection box
441                 $content = generateSelectionBoxFromArray($rows, 'network_type', 'network_type_id');
442         } else {
443                 // Nothing selected
444                 $content = loadTemplate('admin_settings_unsaved', false, '{--ADMIN_ENTRIES_404--}');
445         }
446
447         // Free the result
448         SQL_FREERESULT($result);
449
450         // Return content
451         return $content;
452 }
453
454 // Generator (somewhat getter) for a list of network types for all types
455 function generateAdminDistinctNetworkTypeList () {
456         // Init content
457         $content = '';
458
459         // Query all types of this network
460         $result = SQL_QUERY('SELECT
461         t.`network_type_id`, t.`network_type_handle`, d.`network_title`
462 FROM
463         `{?_MYSQL_PREFIX?}_network_types` AS t
464 LEFT JOIN
465         `{?_MYSQL_PREFIX?}_network_data` AS d
466 ON
467         t.`network_id`=d.`network_id`
468 ORDER BY
469         d.`network_short_name` ASC,
470         t.`network_type_handle` ASC', __FUNCTION__, __LINE__);
471
472         // Do we have entries?
473         if (!SQL_HASZERONUMS($result)) {
474                 // List all entries
475                 $rows = array();
476                 while ($row = SQL_FETCHARRAY($result)) {
477                         // Is this valid, then add it
478                         if ((is_array($row)) && (isset($row['network_type_id']))) {
479                                 // Add entry
480                                 $rows[$row['network_type_id']] = $row;
481                         } // END - if
482                 } // END - while
483
484                 // Generate the selection box
485                 $content = generateSelectionBoxFromArray($rows, 'network_type', 'network_type_id', '', '_title');
486         } else {
487                 // Nothing selected
488                 $content = loadTemplate('admin_settings_unsaved', false, '{--ADMIN_ENTRIES_404--}');
489         }
490
491         // Free the result
492         SQL_FREERESULT($result);
493         //* DEBUG: */ die('<pre>'.encodeEntities($content).'</pre>');
494
495         // Return content
496         return $content;
497 }
498
499 // Generator (somewhat getter) for network type options
500 function generateNetworkTypeOptions ($id) {
501         // Is this an array, then we just came back from edit/delete actions
502         if (is_array($id)) $id = '';
503
504         // Is this cached?
505         if (!isset($GLOBALS[__FUNCTION__][$id])) {
506                 // Generate output and cache it
507                 $GLOBALS[__FUNCTION__][$id] = generateOptionList(
508                         'network_types',
509                         'network_type_id',
510                         'network_type_handle',
511                         $id,
512                         '',
513                         sprintf(
514                                 "WHERE `network_id`=%s",
515                                 bigintval(getRequestParameter('network'))
516                         ),
517                         '',
518                         'translateNetworkTypeHandler'
519                 );
520         } // END - if
521
522         // Return content
523         return $GLOBALS[__FUNCTION__][$id];
524 }
525
526 // Generates an options list of all available (hard-coded) handlers
527 function generateNetworkTypesAvailableOptions () {
528         // Is it cached?
529         if (!isset($GLOBALS[__FUNCTION__])) {
530                 // Generate list
531                 $GLOBALS[__FUNCTION__] = generateOptionList(
532                         '/ARRAY/',
533                         array(
534                                 'banner',
535                                 'banner_click',
536                                 'banner_view',
537                                 'button',
538                                 'button_click',
539                                 'button_view',
540                                 'surfbar',
541                                 'surfbar_click',
542                                 'surfbar_view',
543                                 'forcedbanner',
544                                 'forcedtextlink',
545                                 'textlink',
546                                 'textlink_click',
547                                 'textlink_view',
548                                 'skybanner',
549                                 'skybanner_click',
550                                 'skybanner_view',
551                                 'layer',
552                                 'layer_click',
553                                 'layer_view',
554                                 'popup',
555                                 'popdown',
556                                 'textmail',
557                                 'htmlmail',
558                                 'lead',
559                                 'sale',
560                                 'payperactive',
561                                 'pagepeel',
562                                 'traffic'
563                         ),
564                         array(),
565                         '', '', '',
566                         $GLOBALS['network_types_disabled'],
567                         'translateNetworkTypeHandler'
568                 );
569         } // END - if
570
571         // Return content
572         return $GLOBALS[__FUNCTION__];
573 }
574
575 // Generates an options list (somewhat getter) ofr request keys
576 function generateNetworkRequestKeyOptions () {
577         // Is it cached?
578         if (!isset($GLOBALS[__FUNCTION__])) {
579                 // Generate and cache it
580                 $GLOBALS[__FUNCTION__] = generateOptionList(
581                         '/ARRAY/',
582                         array(
583                                 'id',
584                                 'sid',
585                                 'hash',
586                                 'password',
587                                 'reload',
588                                 'maximum_stay',
589                                 'minimum_stay',
590                                 'currency',
591                                 'type',
592                                 'remain',
593                                 'reward',
594                                 'size',
595                                 'erotic',
596                                 'extra',
597                                 'country'
598                         ),
599                         array(
600                                 '{--ADMIN_NETWORK_REQUEST_PARAMETER_ID--}',
601                                 '{--ADMIN_NETWORK_REQUEST_PARAMETER_SID--}',
602                                 '{--ADMIN_NETWORK_REQUEST_PARAMETER_HASH--}',
603                                 '{--ADMIN_NETWORK_REQUEST_PARAMETER_PASSWORD--}',
604                                 '{--ADMIN_NETWORK_REQUEST_PARAMETER_RELOAD--}',
605                                 '{--ADMIN_NETWORK_REQUEST_PARAMETER_MAXIMUM_STAY--}',
606                                 '{--ADMIN_NETWORK_REQUEST_PARAMETER_MINIMUM_STAY--}',
607                                 '{--ADMIN_NETWORK_REQUEST_PARAMETER_CURRENCY--}',
608                                 '{--ADMIN_NETWORK_REQUEST_PARAMETER_TYPE--}',
609                                 '{--ADMIN_NETWORK_REQUEST_PARAMETER_REMAIN--}',
610                                 '{--ADMIN_NETWORK_REQUEST_PARAMETER_REWARD--}',
611                                 '{--ADMIN_NETWORK_REQUEST_PARAMETER_SIZE--}',
612                                 '{--ADMIN_NETWORK_REQUEST_PARAMETER_EROTIC--}',
613                                 '{--ADMIN_NETWORK_REQUEST_PARAMETER_EXTRA--}',
614                                 '{--ADMIN_NETWORK_REQUEST_PARAMETER_COUNTRY--}'
615                         ),
616                         '',
617                         '', '',
618                         $GLOBALS['network_params_disabled']
619                 );
620         } // END - if
621
622         // Return content
623         return $GLOBALS[__FUNCTION__];
624 }
625
626 // Generator (somewhat getter) for (return) array translation
627 function generateNetworkTranslationOptions ($default = '') {
628         // Is it cached?
629         if (!isset($GLOBALS[__FUNCTION__][$default])) {
630                 // Generate and cache it
631                 $GLOBALS[__FUNCTION__][$default] = generateOptionList(
632                         'network_translations',
633                         'network_translation_id',
634                         'network_translation_name',
635                         $default,
636                         '',
637                         '',
638                         $GLOBALS['network_translation_disabled'],
639                         'translateNetworkTranslationName'
640                 );
641         } // END - if
642
643         // Return content
644         return $GLOBALS[__FUNCTION__][$default];
645 }
646
647 // Generates an option list of request types
648 function generateNetworkRequestTypeOptions ($default = '') {
649         // Do we have cache?
650         if (!isset($GLOBALS[__FUNCTION__][$default])) {
651                 // Generate the list
652                 $GLOBALS[__FUNCTION__][$default] = generateOptionList(
653                         '/ARRAY/',
654                         array(
655                                 'GET',
656                                 'POST'
657                         ),
658                         array(
659                                 '{--ADMIN_NETWORK_REQUEST_TYPE_GET--}',
660                                 '{--ADMIN_NETWORK_REQUEST_TYPE_POST--}'
661                         ),
662                         $default
663                 );
664         } // END - if
665
666         // Return cache
667         return $GLOBALS[__FUNCTION__][$default];
668 }
669
670 // Translates 'translate_name' for e.g. templates
671 function translateNetworkTranslationName ($name) {
672         // Get the message id
673         return getMessage('ADMIN_NETWORK_TRANSLATE_' . strtoupper($name) . '_NAME');
674 }
675
676 // Translates the network type handler (e.g. banner, paidmail) for templates
677 function translateNetworkTypeHandler ($type) {
678         // Get the message id
679         return getMessage('ADMIN_NETWORK_TYPES_' . strtoupper($type) . '');
680 }
681
682 // Translates request type
683 function translateNetworkRequestType ($name) {
684         // Get the message id
685         return getMessage('ADMIN_NETWORK_REQUEST_TYPE_' . strtoupper($name) . '');
686 }
687
688 // Translates API index
689 function translateNetworkApiIndex ($index) {
690         // Do we have cache?
691         if (!isset($GLOBALS['network_api_index'])) {
692                 // Get an array of all API array indexes
693                 $GLOBALS['network_api_index'] = array();
694
695                 // Get all entries
696                 $result = SQL_QUERY('SELECT
697         `network_api_id`, `network_api_index`, `network_translation_name`
698 FROM
699         `{?_MYSQL_PREFIX?}_network_api_translation`
700 INNER JOIN
701         `{?_MYSQL_PREFIX?}_network_translations`
702 ON
703         `network_api_index`=`network_translation_id`
704 ORDER BY
705         `sort` ASC', __FUNCTION__, __LINE__);
706
707                 // Do we have entries?
708                 if (SQL_NUMROWS($result) > 0) {
709                         // Get all entries
710                         while ($row = SQL_FETCHARRAY($result)) {
711                                 // Add it to our global array
712                                 $GLOBALS['network_api_index'][$row['network_api_index']] = $row;
713                         } // END - while
714                 } // END - if
715
716                 // Free result
717                 SQL_FREERESULT($result);
718         } // END - if
719
720         // Default name is unknown
721         $name = 'unknown';
722
723         // Is the entry there?
724         if (isset($GLOBALS['network_api_index'][$index])) {
725                 // Then get the name
726                 $name = $GLOBALS['network_api_index'][$index]['network_translation_name'];
727         } // END - if
728
729         // Return translation
730         return translateNetworkTranslationName($name);
731 }
732
733 //------------------------------------------------------------------------------
734 //                             Call-back functions
735 //------------------------------------------------------------------------------
736
737 // Callback function to add new network
738 function doAdminNetworkProcessAddNetwork () {
739         // We can say here, the form is sent, so check if the network is already added
740         if (isNetworkNameValid(postRequestParameter('network_short_name'))) {
741                 // Already there
742                 loadTemplate('admin_settings_unsaved', false, getMaskedMessage('ADMIN_NETWORK_ALREADY_ADDED', postRequestParameter('network_short_name')));
743                 return false;
744         } // END - if
745
746         // Remove the 'ok' part
747         unsetPostRequestParameter('ok');
748
749         // Add the whole request to database
750         SQL_QUERY('INSERT INTO
751         `{?_MYSQL_PREFIX?}_network_data`
752 (
753         `' . implode('`,`', array_keys(postRequestArray())) . "`
754 ) VALUES (
755         '" . implode("','", array_values(postRequestArray())) . "'
756 )", __FUNCTION__, __LINE__);
757
758         // Add the id for output only
759         setPostRequestParameter('network_id', SQL_INSERTID());
760
761         // Output message
762         if (SQL_AFFECTEDROWS() == 1) {
763                 // Successfully added
764                 loadTemplate('admin_network_added', false, postRequestArray());
765         } else {
766                 // Not added
767                 loadTemplate('admin_settings_unsaved', false, getMaskedMessage('ADMIN_NETWORK_DATA_NOT_ADDED', postRequestParameter('network_short_name')));
768         }
769 }
770
771 // Displays selected networks for editing
772 function doAdminNetworkProcessHandleNetwork () {
773         // Do we have selections?
774         if (ifPostContainsSelections()) {
775                 // Something has been selected, so start displaying one by one
776                 $OUT = '';
777                 foreach (postRequestParameter('sel') as $id => $sel) {
778                         // Is this selected?
779                         if ($sel == 1) {
780                                 // Load this network's data
781                                 $networkData = getNetworkDataById($id);
782
783                                 // Do we have found the network?
784                                 if (count($networkData) > 0) {
785                                         if (isFormSent('edit')) {
786                                                 // Add row template for editing
787                                                 $OUT .= loadTemplate('admin_edit_networks_row', true, $networkData);
788                                         } elseif (isFormSent('del')) {
789                                                 // Add row template for deleting
790                                                 $OUT .= loadTemplate('admin_del_networks_row', true, $networkData);
791                                         } else {
792                                                 // Problem!
793                                                 debug_report_bug(__FUNCTION__, __LINE__, 'Cannot detect edit/del.');
794                                         }
795                                 } // END - if
796                         } // END - if
797                 } // END - foreach
798
799                 // If we have no rows, we don't need to display the edit form
800                 if (!empty($OUT)) {
801                         // Output main template
802                         if (isFormSent('edit')) {
803                                 loadTemplate('admin_edit_networks', false, $OUT);
804                         } elseif (isFormSent('del')) {
805                                 loadTemplate('admin_del_networks', false, $OUT);
806                         } else {
807                                 // Problem!
808                                 debug_report_bug(__FUNCTION__, __LINE__, 'Cannot detect edit/del.');
809                         }
810
811                         // Don't display the list/add new form
812                         $GLOBALS['network_display'] = false;
813                 } else {
814                         // Nothing selected/found
815                         loadTemplate('admin_settings_unsaved', false, '{--ADMIN_NETWORK_NOTHING_FOUND--}');
816                 }
817         } // END - if
818 }
819
820 // Handle network type form
821 function doAdminNetworkProcessHandleNetworkType () {
822         // Do we have selections?
823         if (ifPostContainsSelections()) {
824                 // Load network data
825                 $networkData = getNetworkDataById(getRequestParameter('network'));
826
827                 // Something has been selected, so start displaying one by one
828                 $OUT = '';
829                 foreach (postRequestParameter('sel') as $id => $sel) {
830                         // Is this selected?
831                         if ($sel == 1) {
832                                 // Load this network's data
833                                 $networkTypeData = getNetworkTypeDataById($id);
834
835                                 // Do we have found the network?
836                                 if (count($networkTypeData) > 0) {
837                                         if (isFormSent('edit')) {
838                                                 // Add row template for deleting
839                                                 $OUT .= loadTemplate('admin_edit_network_types_row', true, $networkTypeData);
840                                         } elseif (isFormSent('del')) {
841                                                 // Add row template for deleting
842                                                 $OUT .= loadTemplate('admin_del_network_types_row', true, $networkTypeData);
843                                         } else {
844                                                 // Problem!
845                                                 debug_report_bug(__FUNCTION__, __LINE__, 'Cannot detect edit/del.');
846                                         }
847                                 } // END - if
848                         } // END - if
849                 } // END - foreach
850
851                 // If we have no rows, we don't need to display the edit form
852                 if (!empty($OUT)) {
853                         // Output main template
854                         if (isFormSent('edit')) {
855                                 loadTemplate('admin_edit_network_types', false, $OUT);
856                         } elseif (isFormSent('del')) {
857                                 loadTemplate('admin_del_network_types', false, $OUT);
858                         } else {
859                                 // Problem!
860                                 debug_report_bug(__FUNCTION__, __LINE__, 'Cannot detect edit/del.');
861                         }
862
863                         // Don't display the list/add new form
864                         $GLOBALS['network_display'] = false;
865                 } else {
866                         // Nothing selected/found
867                         loadTemplate('admin_settings_unsaved', false, '{--ADMIN_NETWORK_TYPES_NOTHING_FOUND--}');
868                 }
869         } // END - if
870 }
871
872 // Handle network request parameter form
873 function doAdminNetworkProcessHandleRequestParams () {
874         // Do we have selections?
875         if (ifPostContainsSelections()) {
876                 // Init cache array
877                 $GLOBALS['network_params_disabled'] = array();
878
879                 // Load network data
880                 $networkData = getNetworkDataById(getRequestParameter('network'));
881
882                 // Something has been selected, so start displaying one by one
883                 $OUT = '';
884                 foreach (postRequestParameter('sel') as $id => $sel) {
885                         // Is this selected?
886                         if ($sel == 1) {
887                                 // Load this network's data
888                                 $networkRequestData = getNetworkRequestParamsDataById($id);
889
890                                 // Do we have found the network?
891                                 if (count($networkRequestData) > 0) {
892                                         if (isFormSent('edit')) {
893                                                 // Add row template for deleting
894                                                 $OUT .= loadTemplate('admin_edit_network_params_row', true, $networkRequestData);
895                                         } elseif (isFormSent('del')) {
896                                                 // Get type data
897                                                 $networkRequestData['network_type_data'] = getNetworkTypeDataById($networkRequestData['network_type_id']);
898
899                                                 // Add row template for deleting
900                                                 $OUT .= loadTemplate('admin_del_network_params_row', true, $networkRequestData);
901                                         } else {
902                                                 // Problem!
903                                                 debug_report_bug(__FUNCTION__, __LINE__, 'Cannot detect edit/del.');
904                                         }
905                                 } // END - if
906                         } // END - if
907                 } // END - foreach
908
909                 // If we have no rows, we don't need to display the edit form
910                 if (!empty($OUT)) {
911                         // Output main template
912                         if (isFormSent('edit')) {
913                                 loadTemplate('admin_edit_network_params', false, $OUT);
914                         } elseif (isFormSent('del')) {
915                                 loadTemplate('admin_del_network_params', false, $OUT);
916                         } else {
917                                 // Problem!
918                                 debug_report_bug(__FUNCTION__, __LINE__, 'Cannot detect edit/del.');
919                         }
920
921                         // Don't display the list/add new form
922                         $GLOBALS['network_display'] = false;
923                 } else {
924                         // Nothing selected/found
925                         loadTemplate('admin_settings_unsaved', false, '{--ADMIN_NETWORK_REQUEST_PARAMETER_NOTHING_FOUND--}');
926                 }
927         } // END - if
928 }
929
930 // Changes given networks
931 function doAdminNetworkProcessChangeNetwork () {
932         // Do we have selections?
933         if (ifPostContainsSelections()) {
934                 // By default nothing is updated
935                 $updated = 0;
936
937                 // Something has been selected, so start updating them
938                 foreach (postRequestParameter('sel') as $id => $sel) {
939                         // Update this entry?
940                         if ($sel == 1) {
941                                 // Init data array
942                                 $networkData = array();
943
944                                 // Transfer whole array, except 'sel'
945                                 foreach (postRequestArray() as $key => $entry) {
946                                         // Skip 'sel' and submit button
947                                         if (in_array($key, array('sel', 'change'))) continue;
948
949                                         // Do we have this enty?
950                                         if (!isset($entry[$id])) {
951                                                 // Not found, needs fixing
952                                                 debug_report_bug(__FUNCTION__, __LINE__, 'No entry in key=' . $key . ', id=' . $id . ' found.');
953                                         } // END - if
954
955                                         // Add this entry
956                                         $networkData[$key] = $entry[$id];
957                                 } // END - foreach
958
959                                 // Update the network data
960                                 $updated += doNetworkUpdateDataByArray($id, $networkData);
961                         } // END - if
962                 } // END - foreach
963
964                 // Do we have updates?
965                 if ($updated > 0) {
966                         // Updates done
967                         loadTemplate('admin_settings_saved', false, getMaskedMessage('ADMIN_NETWORK_UPDATED', $updated));
968                 } else {
969                         // Nothing changed
970                         loadTemplate('admin_settings_unsaved', false, '{--ADMIN_NETWORK_NOTHING_CHANGED--}');
971                 }
972         } // END - if
973 }
974
975 // Removes given networks
976 function doAdminNetworkProcessRemoveNetwork () {
977         // Do we have selections?
978         if (ifPostContainsSelections()) {
979                 // By default nothing is removed
980                 $removed = 0;
981
982                 // Something has been selected, so start updating them
983                 foreach (postRequestParameter('sel') as $id => $sel) {
984                         // Update this entry?
985                         if ($sel == 1) {
986                                 // Remove this entry
987                                 $removed += doAdminRemoveNetworkEntry('data', 'network_id', $id);
988                         } // END - if
989                 } // END - foreach
990
991                 // Do we have removes?
992                 if ($removed > 0) {
993                         // Removals done
994                         loadTemplate('admin_settings_saved', false, getMaskedMessage('ADMIN_NETWORK_REMOVED', $removed));
995                 } else {
996                         // Nothing removed
997                         loadTemplate('admin_settings_unsaved', false, '{--ADMIN_NETWORK_NOTHING_REMOVED--}');
998                 }
999         } // END - if
1000 }
1001
1002 // Add a network type handler if not yet found
1003 function doAdminNetworkProcessAddNetworkType () {
1004         // Is the network type handle already used with given network?
1005         if (isNetworkTypeHandleValid(postRequestParameter('network_type_handle'), getRequestParameter('network'))) {
1006                 // Already added
1007                 loadTemplate('admin_settings_unsaved', false, getMaskedMessage('ADMIN_NETWORK_TYPES_HANDLE_ALREADY_ADDED', postRequestParameter('network_type_handle')));
1008
1009                 // ... so abort here
1010                 return false;
1011         } // END - if
1012
1013         // Remove the 'ok' part
1014         unsetPostRequestParameter('ok');
1015
1016         // Add id
1017         setPostRequestParameter('network_id', bigintval(getRequestParameter('network')));
1018
1019         // Is network_type_banner_url set?
1020         if (postRequestParameter('network_type_banner_url') == '') {
1021                 // Remove empty value to get a NULL for an optional entry
1022                 unsetPostRequestParameter('network_type_banner_url');
1023         } // END - if
1024
1025         // Add the whole request to database
1026         SQL_QUERY('INSERT INTO
1027         `{?_MYSQL_PREFIX?}_network_types`
1028 (
1029         `' . implode('`,`', array_keys(postRequestArray())) . "`
1030 ) VALUES (
1031         '" . implode("','", array_values(postRequestArray())) . "'
1032 )", __FUNCTION__, __LINE__);
1033
1034         // Output message
1035         if (SQL_AFFECTEDROWS() == 1) {
1036                 // Successfully added
1037                 loadTemplate('admin_network_type_added', false, postRequestArray());
1038         } else {
1039                 // Not added
1040                 loadTemplate('admin_settings_unsaved', false, getMaskedMessage('ADMIN_NETWORK_TYPES_NOT_ADDED', postRequestParameter('network_type_handle')));
1041         }
1042 }
1043
1044 // Changes given network type handlers
1045 function doAdminNetworkProcessChangeNetworkType () {
1046         // Do we have selections?
1047         if (ifPostContainsSelections()) {
1048                 // By default nothing is updated
1049                 $updated = 0;
1050
1051                 // Something has been selected, so start updating them
1052                 foreach (postRequestParameter('sel') as $id => $sel) {
1053                         // Update this entry?
1054                         if ($sel == 1) {
1055                                 // Init data array
1056                                 $networkTypeData = array();
1057
1058                                 // Transfer whole array, except 'sel'
1059                                 foreach (postRequestArray() as $key => $entry) {
1060                                         // Skip 'sel' and submit button
1061                                         if (in_array($key, array('sel', 'change'))) continue;
1062
1063                                         // Do we have this enty?
1064                                         if (!isset($entry[$id])) {
1065                                                 // Not found, needs fixing
1066                                                 debug_report_bug(__FUNCTION__, __LINE__, 'No entry in key=' . $key . ', id=' . $id . ' found.');
1067                                         } // END - if
1068
1069                                         // Fix empty network_type_banner_url to NULL
1070                                         if (($key == 'network_type_banner_url') && (trim($entry[$id]) == '')) {
1071                                                 // Set it to NULL
1072                                                 $entry[$id] = null;
1073                                         } // END - if
1074
1075                                         // Add this entry
1076                                         $networkTypeData[$key] = $entry[$id];
1077                                 } // END - foreach
1078
1079                                 // Update the network data
1080                                 $updated += doNetworkUpdateTypeByArray($id, $networkTypeData);
1081                         } // END - if
1082                 } // END - foreach
1083
1084                 // Do we have updates?
1085                 if ($updated > 0) {
1086                         // Updates done
1087                         loadTemplate('admin_settings_saved', false, getMaskedMessage('ADMIN_NETWORK_TYPES_UPDATED', $updated));
1088                 } else {
1089                         // Nothing changed
1090                         loadTemplate('admin_settings_unsaved', false, '{--ADMIN_NETWORK_TYPES_NOTHING_CHANGED--}');
1091                 }
1092         } // END - if
1093 }
1094
1095 // Changes given network request parameters
1096 function doAdminNetworkProcessChangeNetworkParam () {
1097         // Do we have selections?
1098         if (ifPostContainsSelections()) {
1099                 // By default nothing is updated
1100                 $updated = 0;
1101
1102                 // Something has been selected, so start updating them
1103                 foreach (postRequestParameter('sel') as $id => $sel) {
1104                         // Update this entry?
1105                         if ($sel == 1) {
1106                                 // Init data array
1107                                 $networkParamsData = array();
1108
1109                                 // Transfer whole array, except 'sel'
1110                                 foreach (postRequestArray() as $key => $entry) {
1111                                         // Skip 'sel' and submit button
1112                                         if (in_array($key, array('sel', 'change'))) continue;
1113
1114                                         // Do we have this enty?
1115                                         if (!isset($entry[$id])) {
1116                                                 // Not found, needs fixing
1117                                                 debug_report_bug(__FUNCTION__, __LINE__, 'No entry in key=' . $key . ', id=' . $id . ' found.');
1118                                         } // END - if
1119
1120                                         // Fix empty request_param_default to NULL
1121                                         if (($key == 'request_param_default') && (trim($entry[$id]) == '')) {
1122                                                 // Set it to NULL
1123                                                 $entry[$id] = null;
1124                                         } // END - if
1125
1126                                         // Add this entry
1127                                         $networkParamsData[$key] = $entry[$id];
1128                                 } // END - foreach
1129
1130                                 // Update the network data
1131                                 $updated += doNetworkUpdateParamsByArray($id, $networkParamsData);
1132                         } // END - if
1133                 } // END - foreach
1134
1135                 // Do we have updates?
1136                 if ($updated > 0) {
1137                         // Updates done
1138                         loadTemplate('admin_settings_saved', false, getMaskedMessage('ADMIN_NETWORK_REQUEST_PARAMETER_UPDATED', $updated));
1139                 } else {
1140                         // Nothing changed
1141                         loadTemplate('admin_settings_unsaved', false, '{--ADMIN_NETWORK_REQUEST_PARAMETER_NOTHING_CHANGED--}');
1142                 }
1143         } // END - if
1144 }
1145
1146 // Removes given network type handlers
1147 function doAdminNetworkProcessRemoveNetworkType () {
1148         // Do we have selections?
1149         if (ifPostContainsSelections()) {
1150                 // By default nothing is removed
1151                 $removed = 0;
1152
1153                 // Something has been selected, so start updating them
1154                 foreach (postRequestParameter('sel') as $id => $sel) {
1155                         // Update this entry?
1156                         if ($sel == 1) {
1157                                 // Remove this entry
1158                                 $removed += doAdminRemoveNetworkEntry('types', 'network_type_id', $id);
1159                         } // END - if
1160                 } // END - foreach
1161
1162                 // Do we have removes?
1163                 if ($removed > 0) {
1164                         // Removals done
1165                         loadTemplate('admin_settings_saved', false, getMaskedMessage('ADMIN_NETWORK_TYPES_REMOVED', $removed));
1166                 } else {
1167                         // Nothing removed
1168                         loadTemplate('admin_settings_unsaved', false, '{--ADMIN_NETWORK_TYPES_NOTHING_REMOVED--}');
1169                 }
1170         } // END - if
1171 }
1172
1173 // Removes given network request parameters
1174 function doAdminNetworkProcessRemoveNetworkParam () {
1175         // Do we have selections?
1176         if (ifPostContainsSelections()) {
1177                 // By default nothing is removed
1178                 $removed = 0;
1179
1180                 // Something has been selected, so start updating them
1181                 foreach (postRequestParameter('sel') as $id => $sel) {
1182                         // Update this entry?
1183                         if ($sel == 1) {
1184                                 // Remove this entry
1185                                 $removed += doAdminRemoveNetworkEntry('request_params', 'network_param_id', $id);
1186                         } // END - if
1187                 } // END - foreach
1188
1189                 // Do we have removes?
1190                 if ($removed > 0) {
1191                         // Removals done
1192                         loadTemplate('admin_settings_saved', false, getMaskedMessage('ADMIN_NETWORK_REQUEST_PARAMETER_REMOVED', $removed));
1193                 } else {
1194                         // Nothing removed
1195                         loadTemplate('admin_settings_unsaved', false, '{--ADMIN_NETWORK_REQUEST_PARAMETER_NOTHING_REMOVED--}');
1196                 }
1197         } // END - if
1198 }
1199
1200 // Adds a request parameter to given network and type
1201 function doAdminNetworkProcessAddNetworkParam () {
1202         // Is the request parameter already used with given network?
1203         if (isNetworkRequestParameterValid(postRequestParameter('request_param_key'), postRequestParameter('network_type_id'), getRequestParameter('network'))) {
1204                 // Already added
1205                 loadTemplate('admin_settings_unsaved', false, getMaskedMessage('ADMIN_NETWORK_REQUEST_PARAMETER_ALREADY_ADDED', postRequestParameter('request_param_key')));
1206
1207                 // ... so abort here
1208                 return false;
1209         } // END - if
1210
1211         // Remove the 'ok' part
1212         unsetPostRequestParameter('ok');
1213
1214         // Add id
1215         setPostRequestParameter('network_id', bigintval(getRequestParameter('network')));
1216
1217         // Is request_param_default set?
1218         if (postRequestParameter('request_param_default') == '') {
1219                 // Remove empty value to get a NULL for an optional entry
1220                 unsetPostRequestParameter('request_param_default');
1221         } // END - if
1222
1223         // Add the whole request to database
1224         SQL_QUERY('INSERT INTO
1225         `{?_MYSQL_PREFIX?}_network_request_params`
1226 (
1227         `' . implode('`,`', array_keys(postRequestArray())) . "`
1228 ) VALUES (
1229         '" . implode("','", array_values(postRequestArray())) . "'
1230 )", __FUNCTION__, __LINE__);
1231
1232         // Output message
1233         if (SQL_AFFECTEDROWS() == 1) {
1234                 // Successfully added
1235                 loadTemplate('admin_network_request_param_added', false, postRequestArray());
1236         } else {
1237                 // Not added
1238                 loadTemplate('admin_settings_unsaved', false, getMaskedMessage('ADMIN_NETWORK_REQUEST_PARAMETER_NOT_ADDED', postRequestParameter('request_param_key')));
1239         }
1240 }
1241
1242 // Adds a API response array entry
1243 function doAdminNetworkProcessAddNetworkApiTranslation () {
1244         // Is the request parameter already used with given network?
1245         if (isNetworkApiTranslationValid(postRequestParameter('network_api_index'), postRequestParameter('network_type_id'), getRequestParameter('network'))) {
1246                 // Already added
1247                 loadTemplate('admin_settings_unsaved', false, getMaskedMessage('ADMIN_NETWORK_API_TRANSLATION_ALREADY_ADDED', postRequestParameter('network_api_index')));
1248
1249                 // ... so abort here
1250                 return false;
1251         } // END - if
1252
1253         // Remove the 'ok' part
1254         unsetPostRequestParameter('ok');
1255
1256         // Add id
1257         setPostRequestParameter('network_id', bigintval(getRequestParameter('network')));
1258
1259         // Add sorting
1260         setPostRequestParameter('sort', (countSumTotalData(
1261                 postRequestParameter('network_id'),
1262                 'network_api_translation',
1263                 'network_api_id',
1264                 'network_id',
1265                 true,
1266                 sprintf(" AND `network_type_id`=%s", bigintval(postRequestParameter('network_type_id')))
1267         ) + 1));
1268
1269         // Add the whole request to database
1270         SQL_QUERY('INSERT INTO
1271         `{?_MYSQL_PREFIX?}_network_api_translation`
1272 (
1273         `' . implode('`,`', array_keys(postRequestArray())) . "`
1274 ) VALUES (
1275         '" . implode("','", array_values(postRequestArray())) . "'
1276 )", __FUNCTION__, __LINE__);
1277
1278         // Output message
1279         if (SQL_AFFECTEDROWS() == 1) {
1280                 // Successfully added
1281                 loadTemplate('admin_network_api_translation_added', false, postRequestArray());
1282         } else {
1283                 // Not added
1284                 loadTemplate('admin_settings_unsaved', false, getMaskedMessage('ADMIN_NETWORK_API_TRANSLATION_NOT_ADDED', postRequestParameter('network_api_index')));
1285         }
1286 }
1287
1288 // Do expression code for this extension
1289 function doExpressionNetwork ($data) {
1290         // Construct replacer
1291         $replacer = sprintf(
1292                 "{DQUOTE} . %s(%s, '%s') . {DQUOTE}",
1293                 $data['callback'],
1294                 $data['matches'][4][$data['key']],
1295                 $data['extra_func']
1296         );
1297
1298         // Replace %network% with the current network id
1299         $replacer = str_replace('%network%', getCurrentNetworkId(), $replacer);
1300
1301         // Replace the code
1302         $code = replaceExpressionCode($data, $replacer);
1303
1304         // Return it
1305         return $code;
1306 }
1307
1308 // [EOF]
1309 ?>