X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Flibs%2Fnetwork_functions.php;h=2f6fd916d37d5509378397588a9e7914ab63094d;hp=b97060e9d45387c3f771c52848e1861c5b6b6f07;hb=498867478820a2eecb1da991a682ad31fae90c55;hpb=05c5310de0991ba52c441670a315b89ee4f9db12 diff --git a/inc/libs/network_functions.php b/inc/libs/network_functions.php index b97060e9d4..2f6fd916d3 100644 --- a/inc/libs/network_functions.php +++ b/inc/libs/network_functions.php @@ -194,6 +194,18 @@ function doNetworkUpdateDataByArray ($id, $networkData) { return adminSaveSettings($networkData, '_network_data', sprintf("`network_id`=%s", bigintval($id)), array(), false, false); } +// Updates given network type handler (id) with data from array +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.'); + } // END - if + + // Just call our inner method + return adminSaveSettings($networkTypeData, '_network_types', sprintf("`network_type_id`=%s", bigintval($id)), array(), false, false); +} + // Removes given network entry function doAdminRemoveNetworkEntry ($table, $column, $id, $limit = 1) { // Remove the entry @@ -486,7 +498,7 @@ function doAdminNetworkProcessRemovenetworkForm () { } // END - if } -// Add a network type if not yet found +// Add a network type handler if not yet found function doAdminNetworkProcessAddnetworktypeForm () { // Is the network type handle already used with given network? if (isNetworkTypeHandleValid(postRequestElement('network_type_handle'), getRequestElement('network'))) { @@ -522,5 +534,77 @@ function doAdminNetworkProcessAddnetworktypeForm () { } } +// 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 (postRequestElement('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_TYPE_UPDATED', $updated)); + } else { + // Nothing changed + loadTemplate('admin_settings_saved', false, getMessage('ADMIN_NETWORK_TYPE_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 (postRequestElement('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_TYPE_REMOVED', $removed)); + } else { + // Nothing removed + loadTemplate('admin_settings_saved', false, getMessage('ADMIN_NETWORK_TYPE_NOTHING_REMOVED')); + } + } // END - if +} + // [EOF] ?>