X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Flibs%2Fnetwork_functions.php;h=b19a5ede3de1353633e91e275f02c0c4b0afdde6;hp=7b982e3ab72d8e10a2b7cacdea1263d9dd7df8fc;hb=225103a2af4ebe180823d48913eac14825381134;hpb=65ed873eefdacdcea3331773b6458a06a5adff82 diff --git a/inc/libs/network_functions.php b/inc/libs/network_functions.php index 7b982e3ab7..b19a5ede3d 100644 --- a/inc/libs/network_functions.php +++ b/inc/libs/network_functions.php @@ -148,6 +148,40 @@ LIMIT 1", return $networkData; } +// "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.'); + } // END - if + + // By default we have no data + $networkTypeData = array(); + + // Query for the network data + $result = SQL_QUERY_ESC("SELECT + `network_type_id`, `network_id`, `network_type_handle`, `network_type_api_url`, `network_type_click_url`, `network_type_banner_url` +FROM + `{?_MYSQL_PREFIX?}_network_types` +WHERE + `network_type_id`=%s +LIMIT 1", + array(bigintval($id)), __FUNCTION__, __LINE__); + + // Do we have an entry? + if (SQL_NUMROWS($result) == 1) { + // Then get it + $networkTypeData = SQL_FETCHARRAY($result); + } // END - if + + // Free result + SQL_FREERESULT($result); + + // Return result + return $networkTypeData; +} + // Updates given network (id) with data from array function doNetworkUpdateDataByArray ($id, $networkData) { // Ids lower one are not accepted @@ -313,6 +347,70 @@ function doAdminNetworkProcessHandlenetworkForm () { } // END - if } +// 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?