+// Handle network type form
+function doAdminNetworkProcessHandlenetworktypeForm () {
+ // Do we have selections?
+ if (countPostSelection() > 0) {
+ // Load network data
+ $networkData = getNetworkDataById(getRequestElement('network'));
+
+ // Something has been selected, so start displaying one by one
+ $SW = 2; $OUT = '';
+ foreach (postRequestElement('sel') as $id => $sel) {
+ // Is this selected?
+ if ($sel == 1) {
+ // Load this network's data
+ $networkTypeData = getNetworkTypeDataById($id);
+
+ // Do we have found the network?
+ if (count($networkTypeData) > 0) {
+ // Add color
+ $networkTypeData['sw'] = $SW;
+
+ if (isPostRequestElementSet('edit')) {
+ // Add row template for deleting
+ $OUT .= loadTemplate('admin_edit_network_types_row', true, $networkTypeData);
+ } elseif (isPostRequestElementSet('del')) {
+ // Add row template for deleting
+ $OUT .= loadTemplate('admin_del_network_types_row', true, $networkTypeData);
+ } else {
+ // Problem!
+ debug_report_bug('Cannot detect edit/del.');
+ }
+
+ // Switch colors
+ $SW = 3 - $SW;
+ } // END - if
+ } // END - if
+ } // END - foreach
+
+ // If we have no rows, we don't need to display the edit form
+ if (!empty($OUT)) {
+ // Prepare content for template
+ $content = array(
+ 'rows' => $OUT,
+ 'network_data' => getNetworkDataById(getRequestElement('network'))
+ );
+
+ // Output main template
+ if (isPostRequestElementSet('edit')) {
+ loadTemplate('admin_edit_network_types', false, $content);
+ } elseif (isPostRequestElementSet('del')) {
+ loadTemplate('admin_del_network_types', false, $content);
+ } else {
+ // Problem!
+ debug_report_bug('Cannot detect edit/del.');
+ }
+
+ // Don't display the list/add new form
+ $GLOBALS['network_display'] = false;
+ } else {
+ // Nothing selected/found
+ loadTemplate('admin_settings_saved', false, getMessage('ADMIN_NETWORK_TYPE_NOTHING_FOUND'));
+ }
+ } // END - if
+}
+
+// Changes given networks
+function doAdminNetworkProcessChangenetworkForm () {
+ // Do we have selections?
+ if (countPostSelection() > 0) {
+ // By default nothing is updated
+ $updated = 0;
+
+ // Something has been selected, so start updating them
+ foreach (postRequestElement('sel') as $id => $sel) {
+ // Update this entry?
+ if ($sel == 1) {
+ // Init data array
+ $networkData = 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
+ $networkData[$key] = $entry[$id];
+ } // END - foreach
+
+ // Update the network data
+ $updated += doNetworkUpdateDataByArray($id, $networkData);
+ } // END - if
+ } // END - foreach
+
+ // Do we have updates?
+ if ($updated > 0) {
+ // Updates done
+ loadTemplate('admin_settings_saved', false, getMaskedMessage('ADMIN_NETWORK_UPDATED', $updated));
+ } else {
+ // Nothing changed
+ loadTemplate('admin_settings_saved', false, getMessage('ADMIN_NETWORK_NOTHING_CHANGED'));
+ }
+ } // END - if
+}
+
+// Removes given networks
+function doAdminNetworkProcessRemovenetworkForm () {
+ // Do we have selections?
+ if (countPostSelection() > 0) {
+ // By default nothing is removed
+ $removed = 0;
+
+ // Something has been selected, so start updating them
+ foreach (postRequestElement('sel') as $id => $sel) {
+ // Update this entry?
+ if ($sel == 1) {
+ // Remove this entry
+ $removed += doAdminRemoveNetworkEntry('data', 'network_id', $id);
+ } // END - if
+ } // END - foreach
+
+ // Do we have removes?
+ if ($removed > 0) {
+ // Removals done
+ loadTemplate('admin_settings_saved', false, getMaskedMessage('ADMIN_NETWORK_REMOVED', $removed));
+ } else {
+ // Nothing removed
+ loadTemplate('admin_settings_saved', false, getMessage('ADMIN_NETWORK_NOTHING_REMOVED'));
+ }
+ } // END - if
+}
+
+// Add a network type if not yet found
+function doAdminNetworkProcessAddnetworktypeForm () {
+ // Is the network type handle already used with given network?
+ if (isNetworkTypeHandleValid(postRequestElement('network_type_handle'), getRequestElement('network'))) {
+ // Already added
+ loadTemplate('admin_settings_saved', false, getMaskedMessage('ADMIN_NETWORK_TYPE_HANDLE_ALREADY_ADDED', postRequestElement('network_type_handle')));
+
+ // ... so abort here
+ return false;
+ } // END - if
+
+ // Remove the 'ok' part
+ unsetPostRequestElement('ok');
+
+ // Add id
+ setPostRequestElement('network_id', getRequestElement('network'));
+
+ // 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_saved', false, getMaskedMessage('ADMIN_NETWORK_TYPE_NOT_ADDED', postRequestElement('network_type_handle')));
+ }
+}
+