+// Add a network type handler if not yet found
+function doAdminNetworkProcessAddnetworktypeForm () {
+ // Is the network type handle already used with given network?
+ if (isNetworkTypeHandleValid(postRequestParameter('network_type_handle'), getRequestParameter('network'))) {
+ // Already added
+ loadTemplate('admin_settings_unsaved', false, getMaskedMessage('ADMIN_NETWORK_TYPES_HANDLE_ALREADY_ADDED', postRequestParameter('network_type_handle')));
+
+ // ... so abort here
+ return false;
+ } // END - if
+
+ // Remove the 'ok' part
+ unsetPostRequestParameter('ok');
+
+ // Add id
+ setPostRequestParameter('network_id', getRequestParameter('network'));
+
+ // Is network_type_banner_url set?
+ if (postRequestParameter('network_type_banner_url') == '') {
+ // Remove empty value to get a NULL for an optional entry
+ unsetPostRequestParameter('network_type_banner_url');
+ } // END - if
+
+ // Add the whole request to database
+ SQL_QUERY("INSERT INTO
+ `{?_MYSQL_PREFIX?}_network_types`
+(
+ `" . implode('`,`', array_keys(postRequestArray())) . "`
+) VALUES (
+ '" . implode("','", array_values(postRequestArray())) . "'
+)", __FUNCTION__, __LINE__);
+
+ // Output message
+ if (SQL_AFFECTEDROWS() == 1) {
+ // Successfully added
+ loadTemplate('admin_network_type_added', false, postRequestArray());
+ } else {
+ // Not added
+ loadTemplate('admin_settings_unsaved', false, getMaskedMessage('ADMIN_NETWORK_TYPES_NOT_ADDED', postRequestParameter('network_type_handle')));
+ }
+}
+
+// Changes given network type handlers
+function doAdminNetworkProcessChangenetworktypeForm () {
+ // Do we have selections?
+ if (countPostSelection() > 0) {
+ // By default nothing is updated
+ $updated = 0;
+
+ // Something has been selected, so start updating them
+ foreach (postRequestParameter('sel') as $id => $sel) {
+ // Update this entry?
+ if ($sel == 1) {
+ // Init data array
+ $networkTypeData = array();
+
+ // Transfer whole array, except 'sel'
+ foreach (postRequestArray() as $key => $entry) {
+ // Skip 'sel' and submit button
+ if (in_array($key, array('sel', 'change'))) continue;
+
+ // Do we have this enty?
+ if (!isset($entry[$id])) {
+ // Not found, needs fixing
+ debug_report_bug('No entry in key=' . $key . ', id=' . $id . ' found.');
+ } // END - if
+
+ // Add this entry
+ $networkTypeData[$key] = $entry[$id];
+ } // END - foreach
+
+ // Update the network data
+ $updated += doNetworkUpdateTypeByArray($id, $networkTypeData);
+ } // END - if
+ } // END - foreach
+
+ // Do we have updates?
+ if ($updated > 0) {
+ // Updates done
+ 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'));
+ }
+ } // END - if
+}
+
+// Removes given network type handlers
+function doAdminNetworkProcessRemovenetworktypeForm () {
+ // Do we have selections?
+ if (countPostSelection() > 0) {
+ // By default nothing is removed
+ $removed = 0;
+
+ // Something has been selected, so start updating them
+ foreach (postRequestParameter('sel') as $id => $sel) {
+ // Update this entry?
+ if ($sel == 1) {
+ // Remove this entry
+ $removed += doAdminRemoveNetworkEntry('types', 'network_type_id', $id);
+ } // END - if
+ } // END - foreach
+
+ // Do we have removes?
+ if ($removed > 0) {
+ // Removals done
+ 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'));
+ }
+ } // END - if
+}
+
+// Adds a request parameter to given network and type
+function doAdminNetworkProcessAddnetworkparamForm () {
+ // Is the request parameter already used with given network?
+ if (isNetworkRequestParameterValid(postRequestParameter('request_param_key'), postRequestParameter('network_type_id'), getRequestParameter('network'))) {
+ // Already added
+ loadTemplate('admin_settings_unsaved', false, getMaskedMessage('ADMIN_NETWORK_REQUEST_PARAMETER_ALREADY_ADDED', postRequestParameter('request_param_key')));
+
+ // ... so abort here
+ return false;
+ } // END - if
+
+ // Remove the 'ok' part
+ unsetPostRequestParameter('ok');
+
+ // Add id
+ setPostRequestParameter('network_id', getRequestParameter('network'));
+
+ // Is request_param_default set?
+ if (postRequestParameter('request_param_default') == '') {
+ // Remove empty value to get a NULL for an optional entry
+ unsetPostRequestParameter('request_param_default');
+ } // END - if
+
+ // Add the whole request to database
+ SQL_QUERY("INSERT INTO
+ `{?_MYSQL_PREFIX?}_network_request_params`
+(
+ `" . implode('`,`', array_keys(postRequestArray())) . "`
+) VALUES (
+ '" . implode("','", array_values(postRequestArray())) . "'
+)", __FUNCTION__, __LINE__);
+
+ // Output message
+ if (SQL_AFFECTEDROWS() == 1) {
+ // Successfully added
+ loadTemplate('admin_network_request_param_added', false, postRequestArray());
+ } else {
+ // Not added
+ loadTemplate('admin_settings_unsaved', false, getMaskedMessage('ADMIN_NETWORK_REQUEST_PARAMETER_NOT_ADDED', postRequestParameter('request_param_key')));
+ }
+}
+