]> git.mxchange.org Git - mailer.git/blobdiff - inc/libs/network_functions.php
More rewrites to make use of (cached) wrapper functions
[mailer.git] / inc / libs / network_functions.php
index b33bfea63ba7edea3f7d49082ede2fad9a7fb682..246e054dfc7823cfb59a8702d6445797e58ab5a0 100644 (file)
@@ -42,6 +42,16 @@ if (!defined('__SECURITY')) {
        die();
 } // END - if
 
+// Private setter for current network id
+function setCurrentNetworkId ($id) {
+       $GLOBALS['current_network_id'] = bigintval($id);
+}
+
+// Private getter for current network id
+function getCurrentNetworkId () {
+       return $GLOBALS['current_network_id'];
+}
+
 // Handle a (maybe) sent form here
 function doNetworkHandleForm () {
        // Was the form sent?
@@ -52,7 +62,7 @@ function doNetworkHandleForm () {
                        doAdminNetworkProcessForm();
                } else {
                        // No 'do' found
-                       loadTemplate('admin_settings_unsaved', false, getMessage('ADMIN_NETWORK_DO_404'));
+                       loadTemplate('admin_settings_unsaved', false, '{--ADMIN_NETWORK_DO_404--}');
                }
        } // END - if
 }
@@ -62,11 +72,11 @@ function doAdminNetworkProcessForm () {
        // Form really sent?
        if ((!isFormSent()) && (!isFormSent('edit')) && (!isFormSent('del')) && (!isFormSent('change')) && (!isFormSent('remove'))) {
                // Abort here
-               loadTemplate('admin_settings_unsaved', false, getMessage('ADMIN_NETWORK_FORM_NOT_SENT'));
+               loadTemplate('admin_settings_unsaved', false, '{--ADMIN_NETWORK_FORM_NOT_SENT--}');
                return;
        } elseif (!isGetRequestParameterSet('do')) {
                // No 'do' found
-               loadTemplate('admin_settings_unsaved', false, getMessage('ADMIN_NETWORK_DO_404'));
+               loadTemplate('admin_settings_unsaved', false, '{--ADMIN_NETWORK_DO_404--}');
                return;
        }
 
@@ -76,7 +86,7 @@ function doAdminNetworkProcessForm () {
        // Is the function valid?
        if (!function_exists($functionName)) {
                // Invalid function name
-               debug_report_bug('Invalid do ' . getRequestParameter('do') . ', function ' . $functionName .' does not exist.', false);
+               debug_report_bug(__FUNCTION__, __LINE__, 'Invalid do ' . getRequestParameter('do') . ', function ' . $functionName .' does not exist.', false);
        } // END - if
 
        // Call-back the method handling our request
@@ -136,9 +146,12 @@ function getNetworkDataById ($id, $column = '') {
        // Ids lower one are not accepted
        if ($id < 1) {
                // Not good, should be fixed
-               debug_report_bug('Network id ' . $id . ' is smaller than 1.');
+               debug_report_bug(__FUNCTION__, __LINE__, 'Network id ' . $id . ' is smaller than 1.');
        } // END - if
 
+       // Set current network id
+       setCurrentNetworkId($id);
+
        // Is it cached?
        if (!isset($GLOBALS['network_data'][$id])) {
                // By default we have no data
@@ -174,12 +187,63 @@ LIMIT 1",
        }
 }
 
+// "Getter" for a network's data by provided type id number
+function getNetworkDataByTypeId ($id, $column = '') {
+       // Ids lower one are not accepted
+       if ($id < 1) {
+               // Not good, should be fixed
+               debug_report_bug(__FUNCTION__, __LINE__, 'Network type id ' . $id . ' is smaller than 1.');
+       } // END - if
+
+       // Set current network id
+       setCurrentNetworkId($id);
+
+       // Is it cached?
+       if (!isset($GLOBALS['network_data'][$id])) {
+               // By default we have no data
+               $GLOBALS['network_data'][$id] = array();
+
+               // Query for the network data
+               $result = SQL_QUERY_ESC("SELECT
+       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`,
+       t.`network_type_handle`, t.`network_type_api_url`, t.`network_type_click_url`, t.`network_type_banner_url`
+FROM
+       `{?_MYSQL_PREFIX?}_network_data` AS d
+LEFT JOIN
+       `{?_MYSQL_PREFIX?}_network_types` AS t
+ON
+       d.`network_id`=t.`network_id`
+WHERE
+       t.`network_type_id`=%s
+LIMIT 1",
+                       array(bigintval($id)), __FUNCTION__, __LINE__);
+
+               // Do we have an entry?
+               if (SQL_NUMROWS($result) == 1) {
+                       // Then get it
+                       $GLOBALS['network_data'][$id] = SQL_FETCHARRAY($result);
+               } // END - if
+
+               // Free result
+               SQL_FREERESULT($result);
+       } // END - if
+
+       // Return result
+       if (empty($column)) {
+               // Return array
+               return $GLOBALS['network_data'][$id];
+       } else {
+               // Return column
+               return $GLOBALS['network_data'][$id][$column];
+       }
+}
+
 // "Getter" for a network type data by provided id number
 function getNetworkTypeDataById ($id) {
        // Ids lower one are not accepted
        if ($id < 1) {
                // Not good, should be fixed
-               debug_report_bug('Network type id ' . $id . ' is smaller than 1.');
+               debug_report_bug(__FUNCTION__, __LINE__, 'Network type id ' . $id . ' is smaller than 1.');
        } // END - if
 
        // By default we have no data
@@ -213,7 +277,7 @@ function getNetworkRequestParamsDataById ($id) {
        // Ids lower one are not accepted
        if ($id < 1) {
                // Not good, should be fixed
-               debug_report_bug('Network request parameter id ' . $id . ' is smaller than 1.');
+               debug_report_bug(__FUNCTION__, __LINE__, 'Network request parameter id ' . $id . ' is smaller than 1.');
        } // END - if
 
        // By default we have no data
@@ -247,7 +311,7 @@ function doNetworkUpdateDataByArray ($id, $networkData) {
        // Ids lower one are not accepted
        if ($id < 1) {
                // Not good, should be fixed
-               debug_report_bug('Network id ' . $id . ' is smaller than 1.');
+               debug_report_bug(__FUNCTION__, __LINE__, 'Network id ' . $id . ' is smaller than 1.');
        } // END - if
 
        // Just call our inner method
@@ -259,7 +323,7 @@ function doNetworkUpdateTypeByArray ($id, $networkTypeData) {
        // Ids lower one are not accepted
        if ($id < 1) {
                // Not good, should be fixed
-               debug_report_bug('Network type handler id ' . $id . ' is smaller than 1.');
+               debug_report_bug(__FUNCTION__, __LINE__, 'Network type handler id ' . $id . ' is smaller than 1.');
        } // END - if
 
        // Just call our inner method
@@ -271,7 +335,7 @@ function doNetworkUpdateParamsByArray ($id, $networkParamData) {
        // Ids lower one are not accepted
        if ($id < 1) {
                // Not good, should be fixed
-               debug_report_bug('Network request parameter id ' . $id . ' is smaller than 1.');
+               debug_report_bug(__FUNCTION__, __LINE__, 'Network request parameter id ' . $id . ' is smaller than 1.');
        } // END - if
 
        // Just call our inner method
@@ -282,7 +346,7 @@ function doNetworkUpdateParamsByArray ($id, $networkParamData) {
 function doAdminRemoveNetworkEntry ($table, $column, $id, $limit = 1) {
        // Remove the entry
        SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_network_%s` WHERE `%s`=%s LIMIT %s",
-               array($table, $column, $id, $limit), __FILE__, __LINE__);
+               array($table, $column, $id, $limit), __FUNCTION__, __LINE__);
 
        // Return affected rows
        return SQL_AFFECTEDROWS();
@@ -299,10 +363,10 @@ function generateAdminNetworkList () {
 FROM
        `{?_MYSQL_PREFIX?}_network_data`
 ORDER BY
-       `network_short_name` ASC", __FILE__, __LINE__);
+       `network_short_name` ASC", __FUNCTION__, __LINE__);
 
        // Do we have entries?
-       if (SQL_NUMROWS($result) > 0) {
+       if (!SQL_HASZERONUMS($result)) {
                // List all entries
                $rows = array();
                while ($row = SQL_FETCHARRAY($result)) {
@@ -317,7 +381,7 @@ ORDER BY
                $content = generateSelectionBoxFromArray($rows, 'network', 'network_id');
        } else {
                // Nothing selected
-               $content = loadTemplate('admin_settings_unsaved', false, getMessage('ADMIN_ENTRIES_404'));
+               $content = loadTemplate('admin_settings_unsaved', false, '{--ADMIN_ENTRIES_404--}');
        }
 
        // Free the result
@@ -343,10 +407,10 @@ ORDER BY
        `network_type_handle` ASC",
                array(
                        bigintval($networkId)
-               ), __FILE__, __LINE__);
+               ), __FUNCTION__, __LINE__);
 
        // Do we have entries?
-       if (SQL_NUMROWS($result) > 0) {
+       if (!SQL_HASZERONUMS($result)) {
                // List all entries
                $rows = array();
                while ($row = SQL_FETCHARRAY($result)) {
@@ -361,7 +425,7 @@ ORDER BY
                $content = generateSelectionBoxFromArray($rows, 'network_type', 'network_type_id');
        } else {
                // Nothing selected
-               $content = loadTemplate('admin_settings_unsaved', false, getMessage('ADMIN_ENTRIES_404'));
+               $content = loadTemplate('admin_settings_unsaved', false, '{--ADMIN_ENTRIES_404--}');
        }
 
        // Free the result
@@ -371,6 +435,51 @@ ORDER BY
        return $content;
 }
 
+// Generator (somewhat getter) for a list of network types for all types
+function generateAdminDistinctNetworkTypeList () {
+       // Init content
+       $content = '';
+
+       // Query all types of this network
+       $result = SQL_QUERY("SELECT
+       t.`network_type_id`, t.`network_type_handle`, d.`network_title`
+FROM
+       `{?_MYSQL_PREFIX?}_network_types` AS t
+LEFT JOIN
+       `{?_MYSQL_PREFIX?}_network_data` AS d
+ON
+       t.`network_id`=d.`network_id`
+ORDER BY
+       d.`network_short_name` ASC,
+       t.`network_type_handle` ASC", __FUNCTION__, __LINE__);
+
+       // Do we have entries?
+       if (!SQL_HASZERONUMS($result)) {
+               // List all entries
+               $rows = array();
+               while ($row = SQL_FETCHARRAY($result)) {
+                       // Is this valid, then add it
+                       if ((is_array($row)) && (isset($row['network_type_id']))) {
+                               // Add entry
+                               $rows[$row['network_type_id']] = $row;
+                       } // END - if
+               } // END - while
+
+               // Generate the selection box
+               $content = generateSelectionBoxFromArray($rows, 'network_type', 'network_type_id', '', '_title');
+       } else {
+               // Nothing selected
+               $content = loadTemplate('admin_settings_unsaved', false, '{--ADMIN_ENTRIES_404--}');
+       }
+
+       // Free the result
+       SQL_FREERESULT($result);
+       //* DEBUG: */ die('<pre>'.encodeEntities($content).'</pre>');
+
+       // Return content
+       return $content;
+}
+
 // Generator (somewhat getter) for network type options
 function generateNetworkTypeOptions ($id) {
        // Is this an array, then we just came back from edit/delete actions
@@ -451,14 +560,16 @@ function generateNetworkArrayTranslationOptions ($default) {
        if (!isset($GLOBALS['network_array_translation'][$default])) {
                // Generate and cache it
                $GLOBALS['network_array_translation'][$default] = generateOptionList(
-                       'network_request_params',
-                       'network_param_id',
-                       'request_param_key',
+                       'network_translations',
+                       'network_translation',
+                       'network_translation',
                        $default,
                        '',
-                       sprintf("WHERE `network_id`='%s'", bigintval(getRequestParameter('network'))),
+                       sprintf("WHERE `network_type_id`=%s",
+                               bigintval(getRequestParameter('network_type'))
+                       ),
                        $GLOBALS['network_array_translation_disabled'],
-                       'ADMIN_NETWORK_REQUEST_PARAMETER_'
+                       'ADMIN_NETWORK_ARRAY_TRANSLATION_'
                );
        } // END - if
 
@@ -507,9 +618,9 @@ function doAdminNetworkProcessAddnetworkForm () {
 // Displays selected networks for editing
 function doAdminNetworkProcessHandlenetworkForm () {
        // Do we have selections?
-       if (countPostSelection() > 0) {
+       if (ifPostContainsSelections()) {
                // Something has been selected, so start displaying one by one
-               $SW = 2; $OUT = '';
+               $OUT = '';
                foreach (postRequestParameter('sel') as $id => $sel) {
                        // Is this selected?
                        if ($sel == 1) {
@@ -518,9 +629,6 @@ function doAdminNetworkProcessHandlenetworkForm () {
 
                                // Do we have found the network?
                                if (count($networkData) > 0) {
-                                       // Add color
-                                       $networkData['sw'] = $SW;
-
                                        if (isFormSent('edit')) {
                                                // Make selection box for network_request_type
                                                $networkData['network_request_type'] = generateOptionList(
@@ -530,8 +638,8 @@ function doAdminNetworkProcessHandlenetworkForm () {
                                                                'POST'
                                                        ),
                                                        array(
-                                                               getMessage('ADMIN_NETWORK_REQUEST_TYPE_GET'),
-                                                               getMessage('ADMIN_NETWORK_REQUEST_TYPE_POST')
+                                                               '{--ADMIN_NETWORK_REQUEST_TYPE_GET--}',
+                                                               '{--ADMIN_NETWORK_REQUEST_TYPE_POST--}'
                                                        ),
                                                        $networkData['network_request_type']
                                                );
@@ -540,17 +648,14 @@ function doAdminNetworkProcessHandlenetworkForm () {
                                                $OUT .= loadTemplate('admin_edit_networks_row', true, $networkData);
                                        } elseif (isFormSent('del')) {
                                                // Translate the request type
-                                               $networkData['network_request_type'] = getMessage('ADMIN_NETWORK_REQUEST_TYPE_' . $networkData['network_request_type']);
+                                               $networkData['network_request_type'] = '{--ADMIN_NETWORK_REQUEST_TYPE_' . $networkData['network_request_type'] . '--}';
 
                                                // Add row template for deleting
                                                $OUT .= loadTemplate('admin_del_networks_row', true, $networkData);
                                        } else {
                                                // Problem!
-                                               debug_report_bug('Cannot detect edit/del.');
+                                               debug_report_bug(__FUNCTION__, __LINE__, 'Cannot detect edit/del.');
                                        }
-
-                                       // Switch colors
-                                       $SW = 3 - $SW;
                                } // END - if
                        } // END - if
                } // END - foreach
@@ -564,14 +669,14 @@ function doAdminNetworkProcessHandlenetworkForm () {
                                loadTemplate('admin_del_networks', false, $OUT);
                        } else {
                                // Problem!
-                               debug_report_bug('Cannot detect edit/del.');
+                               debug_report_bug(__FUNCTION__, __LINE__, 'Cannot detect edit/del.');
                        }
 
                        // Don't display the list/add new form
                        $GLOBALS['network_display'] = false;
                } else {
                        // Nothing selected/found
-                       loadTemplate('admin_settings_unsaved', false, getMessage('ADMIN_NETWORK_NOTHING_FOUND'));
+                       loadTemplate('admin_settings_unsaved', false, '{--ADMIN_NETWORK_NOTHING_FOUND--}');
                }
        } // END - if
 }
@@ -579,12 +684,12 @@ function doAdminNetworkProcessHandlenetworkForm () {
 // Handle network type form
 function doAdminNetworkProcessHandlenetworktypeForm () {
        // Do we have selections?
-       if (countPostSelection() > 0) {
+       if (ifPostContainsSelections()) {
                // Load network data
                $networkData = getNetworkDataById(getRequestParameter('network'));
 
                // Something has been selected, so start displaying one by one
-               $SW = 2; $OUT = '';
+               $OUT = '';
                foreach (postRequestParameter('sel') as $id => $sel) {
                        // Is this selected?
                        if ($sel == 1) {
@@ -593,25 +698,16 @@ function doAdminNetworkProcessHandlenetworktypeForm () {
 
                                // Do we have found the network?
                                if (count($networkTypeData) > 0) {
-                                       // Add color
-                                       $networkTypeData['sw'] = $SW;
-
                                        if (isFormSent('edit')) {
                                                // Add row template for deleting
                                                $OUT .= loadTemplate('admin_edit_network_types_row', true, $networkTypeData);
                                        } elseif (isFormSent('del')) {
-                                               // Fix empty banner URL
-                                               if (trim($networkTypeData['network_type_banner_url']) == '') $networkTypeData['network_type_banner_url'] = '---';
-
                                                // Add row template for deleting
                                                $OUT .= loadTemplate('admin_del_network_types_row', true, $networkTypeData);
                                        } else {
                                                // Problem!
-                                               debug_report_bug('Cannot detect edit/del.');
+                                               debug_report_bug(__FUNCTION__, __LINE__, 'Cannot detect edit/del.');
                                        }
-
-                                       // Switch colors
-                                       $SW = 3 - $SW;
                                } // END - if
                        } // END - if
                } // END - foreach
@@ -631,14 +727,14 @@ function doAdminNetworkProcessHandlenetworktypeForm () {
                                loadTemplate('admin_del_network_types', false, $content);
                        } else {
                                // Problem!
-                               debug_report_bug('Cannot detect edit/del.');
+                               debug_report_bug(__FUNCTION__, __LINE__, 'Cannot detect edit/del.');
                        }
 
                        // Don't display the list/add new form
                        $GLOBALS['network_display'] = false;
                } else {
                        // Nothing selected/found
-                       loadTemplate('admin_settings_unsaved', false, getMessage('ADMIN_NETWORK_TYPES_NOTHING_FOUND'));
+                       loadTemplate('admin_settings_unsaved', false, '{--ADMIN_NETWORK_TYPES_NOTHING_FOUND--}');
                }
        } // END - if
 }
@@ -646,7 +742,7 @@ function doAdminNetworkProcessHandlenetworktypeForm () {
 // Handle network request parameter form
 function doAdminNetworkProcessHandlerequestparamsForm () {
        // Do we have selections?
-       if (countPostSelection() > 0) {
+       if (ifPostContainsSelections()) {
                // Init cache array
                $GLOBALS['network_params_disabled'] = array();
 
@@ -654,7 +750,7 @@ function doAdminNetworkProcessHandlerequestparamsForm () {
                $networkData = getNetworkDataById(getRequestParameter('network'));
 
                // Something has been selected, so start displaying one by one
-               $SW = 2; $OUT = '';
+               $OUT = '';
                foreach (postRequestParameter('sel') as $id => $sel) {
                        // Is this selected?
                        if ($sel == 1) {
@@ -663,9 +759,6 @@ function doAdminNetworkProcessHandlerequestparamsForm () {
 
                                // Do we have found the network?
                                if (count($networkRequestData) > 0) {
-                                       // Add color
-                                       $networkRequestData['sw'] = $SW;
-
                                        if (isFormSent('edit')) {
                                                // Add options list for network type
                                                $networkRequestData['type_options'] = generateNetworkTypeOptions($networkRequestData['network_type_id']);
@@ -676,9 +769,6 @@ function doAdminNetworkProcessHandlerequestparamsForm () {
                                                // Add row template for deleting
                                                $OUT .= loadTemplate('admin_edit_network_params_row', true, $networkRequestData);
                                        } elseif (isFormSent('del')) {
-                                               // Fix empty banner URL
-                                               if (trim($networkRequestData['request_param_default']) == '') $networkRequestData['request_param_default'] = '---';
-
                                                // Get type data
                                                $networkRequestData['network_type_data'] = getNetworkTypeDataById($networkRequestData['network_type_id']);
 
@@ -686,11 +776,8 @@ function doAdminNetworkProcessHandlerequestparamsForm () {
                                                $OUT .= loadTemplate('admin_del_network_params_row', true, $networkRequestData);
                                        } else {
                                                // Problem!
-                                               debug_report_bug('Cannot detect edit/del.');
+                                               debug_report_bug(__FUNCTION__, __LINE__, 'Cannot detect edit/del.');
                                        }
-
-                                       // Switch colors
-                                       $SW = 3 - $SW;
                                } // END - if
                        } // END - if
                } // END - foreach
@@ -710,14 +797,14 @@ function doAdminNetworkProcessHandlerequestparamsForm () {
                                loadTemplate('admin_del_network_params', false, $content);
                        } else {
                                // Problem!
-                               debug_report_bug('Cannot detect edit/del.');
+                               debug_report_bug(__FUNCTION__, __LINE__, 'Cannot detect edit/del.');
                        }
 
                        // Don't display the list/add new form
                        $GLOBALS['network_display'] = false;
                } else {
                        // Nothing selected/found
-                       loadTemplate('admin_settings_unsaved', false, getMessage('ADMIN_NETWORK_REQUEST_PARAMETER_NOTHING_FOUND'));
+                       loadTemplate('admin_settings_unsaved', false, '{--ADMIN_NETWORK_REQUEST_PARAMETER_NOTHING_FOUND--}');
                }
        } // END - if
 }
@@ -725,7 +812,7 @@ function doAdminNetworkProcessHandlerequestparamsForm () {
 // Changes given networks
 function doAdminNetworkProcessChangenetworkForm () {
        // Do we have selections?
-       if (countPostSelection() > 0) {
+       if (ifPostContainsSelections()) {
                // By default nothing is updated
                $updated = 0;
 
@@ -744,7 +831,7 @@ function doAdminNetworkProcessChangenetworkForm () {
                                        // Do we have this enty?
                                        if (!isset($entry[$id])) {
                                                // Not found, needs fixing
-                                               debug_report_bug('No entry in key=' . $key . ', id=' . $id . ' found.');
+                                               debug_report_bug(__FUNCTION__, __LINE__, 'No entry in key=' . $key . ', id=' . $id . ' found.');
                                        } // END - if
 
                                        // Add this entry
@@ -762,7 +849,7 @@ function doAdminNetworkProcessChangenetworkForm () {
                        loadTemplate('admin_settings_saved', false, getMaskedMessage('ADMIN_NETWORK_UPDATED', $updated));
                } else {
                        // Nothing changed
-                       loadTemplate('admin_settings_unsaved', false, getMessage('ADMIN_NETWORK_NOTHING_CHANGED'));
+                       loadTemplate('admin_settings_unsaved', false, '{--ADMIN_NETWORK_NOTHING_CHANGED--}');
                }
        } // END - if
 }
@@ -770,7 +857,7 @@ function doAdminNetworkProcessChangenetworkForm () {
 // Removes given networks
 function doAdminNetworkProcessRemovenetworkForm () {
        // Do we have selections?
-       if (countPostSelection() > 0) {
+       if (ifPostContainsSelections()) {
                // By default nothing is removed
                $removed = 0;
 
@@ -789,7 +876,7 @@ function doAdminNetworkProcessRemovenetworkForm () {
                        loadTemplate('admin_settings_saved', false, getMaskedMessage('ADMIN_NETWORK_REMOVED', $removed));
                } else {
                        // Nothing removed
-                       loadTemplate('admin_settings_unsaved', false, getMessage('ADMIN_NETWORK_NOTHING_REMOVED'));
+                       loadTemplate('admin_settings_unsaved', false, '{--ADMIN_NETWORK_NOTHING_REMOVED--}');
                }
        } // END - if
 }
@@ -839,7 +926,7 @@ function doAdminNetworkProcessAddnetworktypeForm () {
 // Changes given network type handlers
 function doAdminNetworkProcessChangenetworktypeForm () {
        // Do we have selections?
-       if (countPostSelection() > 0) {
+       if (ifPostContainsSelections()) {
                // By default nothing is updated
                $updated = 0;
 
@@ -858,7 +945,7 @@ function doAdminNetworkProcessChangenetworktypeForm () {
                                        // Do we have this enty?
                                        if (!isset($entry[$id])) {
                                                // Not found, needs fixing
-                                               debug_report_bug('No entry in key=' . $key . ', id=' . $id . ' found.');
+                                               debug_report_bug(__FUNCTION__, __LINE__, 'No entry in key=' . $key . ', id=' . $id . ' found.');
                                        } // END - if
 
                                        // Fix empty network_type_banner_url to NULL
@@ -882,7 +969,7 @@ function doAdminNetworkProcessChangenetworktypeForm () {
                        loadTemplate('admin_settings_saved', false, getMaskedMessage('ADMIN_NETWORK_TYPES_UPDATED', $updated));
                } else {
                        // Nothing changed
-                       loadTemplate('admin_settings_unsaved', false, getMessage('ADMIN_NETWORK_TYPES_NOTHING_CHANGED'));
+                       loadTemplate('admin_settings_unsaved', false, '{--ADMIN_NETWORK_TYPES_NOTHING_CHANGED--}');
                }
        } // END - if
 }
@@ -890,7 +977,7 @@ function doAdminNetworkProcessChangenetworktypeForm () {
 // Changes given network request parameters
 function doAdminNetworkProcessChangenetworkparamForm () {
        // Do we have selections?
-       if (countPostSelection() > 0) {
+       if (ifPostContainsSelections()) {
                // By default nothing is updated
                $updated = 0;
 
@@ -909,7 +996,7 @@ function doAdminNetworkProcessChangenetworkparamForm () {
                                        // Do we have this enty?
                                        if (!isset($entry[$id])) {
                                                // Not found, needs fixing
-                                               debug_report_bug('No entry in key=' . $key . ', id=' . $id . ' found.');
+                                               debug_report_bug(__FUNCTION__, __LINE__, 'No entry in key=' . $key . ', id=' . $id . ' found.');
                                        } // END - if
 
                                        // Fix empty request_param_default to NULL
@@ -933,7 +1020,7 @@ function doAdminNetworkProcessChangenetworkparamForm () {
                        loadTemplate('admin_settings_saved', false, getMaskedMessage('ADMIN_NETWORK_REQUEST_PARAMETER_UPDATED', $updated));
                } else {
                        // Nothing changed
-                       loadTemplate('admin_settings_unsaved', false, getMessage('ADMIN_NETWORK_REQUEST_PARAMETER_NOTHING_CHANGED'));
+                       loadTemplate('admin_settings_unsaved', false, '{--ADMIN_NETWORK_REQUEST_PARAMETER_NOTHING_CHANGED--}');
                }
        } // END - if
 }
@@ -941,7 +1028,7 @@ function doAdminNetworkProcessChangenetworkparamForm () {
 // Removes given network type handlers
 function doAdminNetworkProcessRemovenetworktypeForm () {
        // Do we have selections?
-       if (countPostSelection() > 0) {
+       if (ifPostContainsSelections()) {
                // By default nothing is removed
                $removed = 0;
 
@@ -960,7 +1047,7 @@ function doAdminNetworkProcessRemovenetworktypeForm () {
                        loadTemplate('admin_settings_saved', false, getMaskedMessage('ADMIN_NETWORK_TYPES_REMOVED', $removed));
                } else {
                        // Nothing removed
-                       loadTemplate('admin_settings_unsaved', false, getMessage('ADMIN_NETWORK_TYPES_NOTHING_REMOVED'));
+                       loadTemplate('admin_settings_unsaved', false, '{--ADMIN_NETWORK_TYPES_NOTHING_REMOVED--}');
                }
        } // END - if
 }
@@ -968,7 +1055,7 @@ function doAdminNetworkProcessRemovenetworktypeForm () {
 // Removes given network request parameters
 function doAdminNetworkProcessRemovenetworkparamForm () {
        // Do we have selections?
-       if (countPostSelection() > 0) {
+       if (ifPostContainsSelections()) {
                // By default nothing is removed
                $removed = 0;
 
@@ -987,7 +1074,7 @@ function doAdminNetworkProcessRemovenetworkparamForm () {
                        loadTemplate('admin_settings_saved', false, getMaskedMessage('ADMIN_NETWORK_REQUEST_PARAMETER_REMOVED', $removed));
                } else {
                        // Nothing removed
-                       loadTemplate('admin_settings_unsaved', false, getMessage('ADMIN_NETWORK_REQUEST_PARAMETER_NOTHING_REMOVED'));
+                       loadTemplate('admin_settings_unsaved', false, '{--ADMIN_NETWORK_REQUEST_PARAMETER_NOTHING_REMOVED--}');
                }
        } // END - if
 }
@@ -1038,12 +1125,15 @@ function doAdminNetworkProcessAddnetworkparamForm () {
 function doExpressionNetwork ($data) {
        // Construct replacer
        $replacer = sprintf(
-               "\" . %s(%s, '%s') . \"",
+               "{DQUOTE} . %s(%s, '%s') . {DQUOTE}",
                $data['callback'],
                $data['matches'][4][$data['key']],
                $data['extra_func']
        );
 
+       // Replace %network% with the current network id
+       $replacer = str_replace('%network%', getCurrentNetworkId(), $replacer);
+
        // Replace the code
        $code = replaceExpressionCode($data, $replacer);
 
@@ -1053,3 +1143,4 @@ function doExpressionNetwork ($data) {
 
 // [EOF]
 ?>
+