X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=inc%2Flibs%2Fnetwork_functions.php;h=b3800e9a69310d549ea39c5e1fca4d6c7ee27e1f;hb=62d8f6d89c35bebe15b8f716a5629f14d95f3078;hp=001d5b26be213cdd4f12b02829fa863ed8d957cc;hpb=80c4d572aeea86286b6e1db8b845f46813b478c5;p=mailer.git diff --git a/inc/libs/network_functions.php b/inc/libs/network_functions.php index 001d5b26be..b3800e9a69 100644 --- a/inc/libs/network_functions.php +++ b/inc/libs/network_functions.php @@ -14,8 +14,6 @@ * $Date:: $ * * $Tag:: 0.2.1-FINAL $ * * $Author:: $ * - * Needs to be in all Files and every File needs "svn propset * - * svn:keywords Date Revision" (autoprobset!) at least!!!!!! * * -------------------------------------------------------------------- * * Copyright (c) 2003 - 2009 by Roland Haeder * * Copyright (c) 2009, 2010 by Mailer Developer Team * @@ -55,14 +53,14 @@ function getCurrentNetworkId () { // Handle a (maybe) sent form here function doNetworkHandleForm () { // Was the form sent? - if ((isFormSent()) || (isFormSent('edit')) || (isFormSent('del')) || (isFormSent('change')) || (isFormSent('remove'))) { + if ((isFormSent()) || (isFormSent('edit')) || (isFormSent('delete')) || (isFormSent('change')) || (isFormSent('remove'))) { // Do we have a 'do'? if (isGetRequestParameterSet('do')) { // Process the request 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 } @@ -70,18 +68,18 @@ function doNetworkHandleForm () { // Processes an admin form function doAdminNetworkProcessForm () { // Form really sent? - if ((!isFormSent()) && (!isFormSent('edit')) && (!isFormSent('del')) && (!isFormSent('change')) && (!isFormSent('remove'))) { + if ((!isFormSent()) && (!isFormSent('edit')) && (!isFormSent('delete')) && (!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; } // Create function name - $functionName = sprintf("doAdminNetworkProcess%sForm", ucfirst(strtolower(getRequestParameter('do')))); + $functionName = sprintf("doAdminNetworkProcess%s", capitalizeUnderscoreString(getRequestParameter('do'))); // Is the function valid? if (!function_exists($functionName)) { @@ -141,6 +139,22 @@ function isNetworkRequestParameterValid ($key, $type, $networkId) { return $isValid; } +// Checks wether the given network API array translation +function isNetworkApiTranslationValid ($key, $type, $networkId) { + // Query for it + $result = SQL_QUERY_ESC("SELECT `network_api_id` FROM `{?_MYSQL_PREFIX?}_network_api_translation` WHERE `network_id`=%s AND `network_type_id`=%s AND `network_api_index`='%s' LIMIT 1", + array($networkId, $type, $key), __FUNCTION__, __LINE__); + + // Does it exist? + $isValid = (SQL_NUMROWS($result) == 1); + + // Free result + SQL_FREERESULT($result); + + // Return result + return $isValid; +} + // "Getter" for a network's data by provided id number function getNetworkDataById ($id, $column = '') { // Ids lower one are not accepted @@ -358,15 +372,15 @@ function generateAdminNetworkList () { $content = ''; // Query for all networks - $result = SQL_QUERY("SELECT + $result = SQL_QUERY('SELECT `network_id`, `network_short_name`, `network_title` FROM `{?_MYSQL_PREFIX?}_network_data` ORDER BY - `network_short_name` ASC", __FUNCTION__, __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)) { @@ -381,7 +395,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 @@ -410,7 +424,7 @@ ORDER BY ), __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)) { @@ -425,7 +439,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 @@ -441,7 +455,7 @@ function generateAdminDistinctNetworkTypeList () { $content = ''; // Query all types of this network - $result = SQL_QUERY("SELECT + $result = SQL_QUERY('SELECT t.`network_type_id`, t.`network_type_handle`, d.`network_title` FROM `{?_MYSQL_PREFIX?}_network_types` AS t @@ -451,10 +465,10 @@ ON t.`network_id`=d.`network_id` ORDER BY d.`network_short_name` ASC, - t.`network_type_handle` ASC", __FUNCTION__, __LINE__); + t.`network_type_handle` 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)) { @@ -469,12 +483,12 @@ ORDER BY $content = generateSelectionBoxFromArray($rows, 'network_type', 'network_type_id', '', '_title'); } 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 SQL_FREERESULT($result); - //* DEBUG: */ die('
'.htmlentities($content).''); + //* DEBUG: */ die('
'.encodeEntities($content).''); // Return content return $content; @@ -486,9 +500,9 @@ function generateNetworkTypeOptions ($id) { if (is_array($id)) $id = ''; // Is this cached? - if (!isset($GLOBALS['network_type_options'][$id])) { + if (!isset($GLOBALS[__FUNCTION__][$id])) { // Generate output and cache it - $GLOBALS['network_type_options'][$id] = generateOptionList( + $GLOBALS[__FUNCTION__][$id] = generateOptionList( 'network_types', 'network_type_id', 'network_type_handle', @@ -497,20 +511,72 @@ function generateNetworkTypeOptions ($id) { sprintf( "WHERE `network_id`=%s", bigintval(getRequestParameter('network')) - ) + ), + '', + 'translateNetworkTypeHandler' ); } // END - if // Return content - return $GLOBALS['network_type_options'][$id]; + return $GLOBALS[__FUNCTION__][$id]; } -// Generator (somewhat getter) for request key options -function generateNetworkRequestKeyOptions ($key) { +// Generates an options list of all available (hard-coded) handlers +function generateNetworkTypesAvailableOptions () { // Is it cached? - if (!isset($GLOBALS['network_request_param_key'][$key])) { + if (!isset($GLOBALS[__FUNCTION__])) { + // Generate list + $GLOBALS[__FUNCTION__] = generateOptionList( + '/ARRAY/', + array( + 'banner', + 'banner_click', + 'banner_view', + 'button', + 'button_click', + 'button_view', + 'surfbar', + 'surfbar_click', + 'surfbar_view', + 'forcedbanner', + 'forcedtextlink', + 'textlink', + 'textlink_click', + 'textlink_view', + 'skybanner', + 'skybanner_click', + 'skybanner_view', + 'layer', + 'layer_click', + 'layer_view', + 'popup', + 'popdown', + 'textmail', + 'htmlmail', + 'lead', + 'sale', + 'payperactive', + 'pagepeel', + 'traffic' + ), + array(), + '', + '', '', + $GLOBALS['network_types_disabled'], + 'translateNetworkTypeHandler' + ); + } // END - if + + // Return content + return $GLOBALS[__FUNCTION__]; +} + +// Generates an options list (somewhat getter) ofr request keys +function generateNetworkRequestKeyOptions () { + // Is it cached? + if (!isset($GLOBALS[__FUNCTION__])) { // Generate and cache it - $GLOBALS['network_request_param_key'][$key] = generateOptionList( + $GLOBALS[__FUNCTION__] = generateOptionList( '/ARRAY/', array( 'id', @@ -526,55 +592,155 @@ function generateNetworkRequestKeyOptions ($key) { 'reward', 'size', 'erotic', - 'extra' + 'extra', + 'country' ), - array( - '{--ADMIN_NETWORK_REQUEST_PARAMETER_ID--}', - '{--ADMIN_NETWORK_REQUEST_PARAMETER_SID--}', - '{--ADMIN_NETWORK_REQUEST_PARAMETER_HASH--}', - '{--ADMIN_NETWORK_REQUEST_PARAMETER_PASSWORD--}', - '{--ADMIN_NETWORK_REQUEST_PARAMETER_RELOAD--}', - '{--ADMIN_NETWORK_REQUEST_PARAMETER_MAXIMUM_STAY--}', - '{--ADMIN_NETWORK_REQUEST_PARAMETER_MINIMUM_STAY--}', - '{--ADMIN_NETWORK_REQUEST_PARAMETER_CURRENCY--}', - '{--ADMIN_NETWORK_REQUEST_PARAMETER_TYPE--}', - '{--ADMIN_NETWORK_REQUEST_PARAMETER_REMAIN--}', - '{--ADMIN_NETWORK_REQUEST_PARAMETER_REWARD--}', - '{--ADMIN_NETWORK_REQUEST_PARAMETER_SIZE--}', - '{--ADMIN_NETWORK_REQUEST_PARAMETER_EROTIC--}', - '{--ADMIN_NETWORK_REQUEST_PARAMETER_EXTRA--}' - ), - $key, + array(), + '', '', '', - $GLOBALS['network_params_disabled'] + $GLOBALS['network_params_disabled'], + 'translateNetworkRequestParameter' ); } // END - if // Return content - return $GLOBALS['network_request_param_key'][$key]; + return $GLOBALS[__FUNCTION__]; } // Generator (somewhat getter) for (return) array translation -function generateNetworkArrayTranslationOptions ($default) { +function generateNetworkTranslationOptions ($default = '') { // Is it cached? - if (!isset($GLOBALS['network_array_translation'][$default])) { + if (!isset($GLOBALS[__FUNCTION__][$default])) { // Generate and cache it - $GLOBALS['network_array_translation'][$default] = generateOptionList( + $GLOBALS[__FUNCTION__][$default] = generateOptionList( 'network_translations', - 'network_translation', - 'network_translation', + 'network_translation_id', + 'network_translation_name', $default, '', - sprintf("WHERE `network_type_id`=%s", - bigintval(getRequestParameter('network_type')) - ), - $GLOBALS['network_array_translation_disabled'], - 'ADMIN_NETWORK_ARRAY_TRANSLATION_' + '', + $GLOBALS['network_translation_disabled'], + 'translateNetworkTranslationName' ); } // END - if // Return content - return $GLOBALS['network_array_translation'][$default]; + return $GLOBALS[__FUNCTION__][$default]; +} + +// Generates an option list of request types +function generateNetworkRequestTypeOptions ($default = '') { + // Do we have cache? + if (!isset($GLOBALS[__FUNCTION__][$default])) { + // Generate the list + $GLOBALS[__FUNCTION__][$default] = generateOptionList( + '/ARRAY/', + array( + 'GET', + 'POST' + ), + array( + '{--ADMIN_NETWORK_REQUEST_TYPE_GET--}', + '{--ADMIN_NETWORK_REQUEST_TYPE_POST--}' + ), + $default + ); + } // END - if + + // Return cache + return $GLOBALS[__FUNCTION__][$default]; +} + +// Generates an option list of network_active +function generateNetworkActiveOptions ($default = '') { + // Do we have cache? + if (!isset($GLOBALS[__FUNCTION__][$default])) { + // Generate the list + $GLOBALS[__FUNCTION__][$default] = generateOptionList( + '/ARRAY/', + array( + 'Y', + 'N' + ), + array( + '{--YES--}', + '{--NO--}' + ), + $default + ); + } // END - if + + // Return cache + return $GLOBALS[__FUNCTION__][$default]; +} + +// Translates 'translate_name' for e.g. templates +function translateNetworkTranslationName ($name) { + // Get the message id + return getMessage('ADMIN_NETWORK_TRANSLATE_' . strtoupper($name) . '_NAME'); +} + +// Translates the network type handler (e.g. banner, paidmail) for templates +function translateNetworkTypeHandler ($type) { + // Get the message id + return getMessage('ADMIN_NETWORK_TYPES_' . strtoupper($type) . ''); +} + +// Translates request type +function translateNetworkRequestType ($type) { + // Get the message id + return getMessage('ADMIN_NETWORK_REQUEST_TYPE_' . strtoupper($type) . ''); +} + +// Translates request parameter +function translateNetworkRequestParameter ($param) { + // Get the message id + return getMessage('ADMIN_NETWORK_REQUEST_PARAMETER_' . strtoupper($param) . ''); +} + +// Translates API index +function translateNetworkApiIndex ($index) { + // Do we have cache? + if (!isset($GLOBALS['network_api_index'])) { + // Get an array of all API array indexes + $GLOBALS['network_api_index'] = array(); + + // Get all entries + $result = SQL_QUERY('SELECT + `network_api_id`, `network_api_index`, `network_translation_name` +FROM + `{?_MYSQL_PREFIX?}_network_api_translation` +INNER JOIN + `{?_MYSQL_PREFIX?}_network_translations` +ON + `network_api_index`=`network_translation_id` +ORDER BY + `sort` ASC', __FUNCTION__, __LINE__); + + // Do we have entries? + if (SQL_NUMROWS($result) > 0) { + // Get all entries + while ($row = SQL_FETCHARRAY($result)) { + // Add it to our global array + $GLOBALS['network_api_index'][$row['network_api_index']] = $row; + } // END - while + } // END - if + + // Free result + SQL_FREERESULT($result); + } // END - if + + // Default name is unknown + $name = 'unknown'; + + // Is the entry there? + if (isset($GLOBALS['network_api_index'][$index])) { + // Then get the name + $name = $GLOBALS['network_api_index'][$index]['network_translation_name']; + } // END - if + + // Return translation + return translateNetworkTranslationName($name); } //------------------------------------------------------------------------------ @@ -582,7 +748,7 @@ function generateNetworkArrayTranslationOptions ($default) { //------------------------------------------------------------------------------ // Callback function to add new network -function doAdminNetworkProcessAddnetworkForm () { +function doAdminNetworkProcessAddNetwork () { // We can say here, the form is sent, so check if the network is already added if (isNetworkNameValid(postRequestParameter('network_short_name'))) { // Already there @@ -594,10 +760,10 @@ function doAdminNetworkProcessAddnetworkForm () { unsetPostRequestParameter('ok'); // Add the whole request to database - SQL_QUERY("INSERT INTO + SQL_QUERY('INSERT INTO `{?_MYSQL_PREFIX?}_network_data` ( - `" . implode('`,`', array_keys(postRequestArray())) . "` + `' . implode('`,`', array_keys(postRequestArray())) . "` ) VALUES ( '" . implode("','", array_values(postRequestArray())) . "' )", __FUNCTION__, __LINE__); @@ -606,7 +772,7 @@ function doAdminNetworkProcessAddnetworkForm () { setPostRequestParameter('network_id', SQL_INSERTID()); // Output message - if (SQL_AFFECTEDROWS() == 1) { + if (!SQL_HASZEROAFFECTED()) { // Successfully added loadTemplate('admin_network_added', false, postRequestArray()); } else { @@ -616,11 +782,11 @@ function doAdminNetworkProcessAddnetworkForm () { } // Displays selected networks for editing -function doAdminNetworkProcessHandlenetworkForm () { +function doAdminNetworkProcessHandleNetwork () { // 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) { @@ -629,39 +795,16 @@ 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( - '/ARRAY/', - array( - 'GET', - 'POST' - ), - array( - getMessage('ADMIN_NETWORK_REQUEST_TYPE_GET'), - getMessage('ADMIN_NETWORK_REQUEST_TYPE_POST') - ), - $networkData['network_request_type'] - ); - // Add row template for editing $OUT .= loadTemplate('admin_edit_networks_row', true, $networkData); - } elseif (isFormSent('del')) { - // Translate the request type - $networkData['network_request_type'] = '{--ADMIN_NETWORK_REQUEST_TYPE_' . $networkData['network_request_type'] . '--}'; - + } elseif (isFormSent('delete')) { // Add row template for deleting - $OUT .= loadTemplate('admin_del_networks_row', true, $networkData); + $OUT .= loadTemplate('admin_delete_networks_row', true, $networkData); } else { // Problem! debug_report_bug(__FUNCTION__, __LINE__, 'Cannot detect edit/del.'); } - - // Switch colors - $SW = 3 - $SW; } // END - if } // END - if } // END - foreach @@ -671,8 +814,8 @@ function doAdminNetworkProcessHandlenetworkForm () { // Output main template if (isFormSent('edit')) { loadTemplate('admin_edit_networks', false, $OUT); - } elseif (isFormSent('del')) { - loadTemplate('admin_del_networks', false, $OUT); + } elseif (isFormSent('delete')) { + loadTemplate('admin_delete_networks', false, $OUT); } else { // Problem! debug_report_bug(__FUNCTION__, __LINE__, 'Cannot detect edit/del.'); @@ -682,20 +825,20 @@ function doAdminNetworkProcessHandlenetworkForm () { $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 } // Handle network type form -function doAdminNetworkProcessHandlenetworktypeForm () { +function doAdminNetworkProcessHandleNetworkType () { // 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) { @@ -704,42 +847,27 @@ 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'] = '---'; - + } elseif (isFormSent('delete')) { // Add row template for deleting - $OUT .= loadTemplate('admin_del_network_types_row', true, $networkTypeData); + $OUT .= loadTemplate('admin_delete_network_types_row', true, $networkTypeData); } else { // Problem! debug_report_bug(__FUNCTION__, __LINE__, '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(getRequestParameter('network')) - ); - // Output main template if (isFormSent('edit')) { - loadTemplate('admin_edit_network_types', false, $content); - } elseif (isFormSent('del')) { - loadTemplate('admin_del_network_types', false, $content); + loadTemplate('admin_edit_network_types', false, $OUT); + } elseif (isFormSent('delete')) { + loadTemplate('admin_delete_network_types', false, $OUT); } else { // Problem! debug_report_bug(__FUNCTION__, __LINE__, 'Cannot detect edit/del.'); @@ -749,15 +877,15 @@ function doAdminNetworkProcessHandlenetworktypeForm () { $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 } // Handle network request parameter form -function doAdminNetworkProcessHandlerequestparamsForm () { +function doAdminNetworkProcessHandleRequestParams () { // Do we have selections? - if (countPostSelection() > 0) { + if (ifPostContainsSelections()) { // Init cache array $GLOBALS['network_params_disabled'] = array(); @@ -765,7 +893,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) { @@ -774,51 +902,30 @@ 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']); - - // Add options list for request key - $networkRequestData['key_options'] = generateNetworkRequestKeyOptions($networkRequestData['request_param_key']); - // 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'] = '---'; - + } elseif (isFormSent('delete')) { // Get type data $networkRequestData['network_type_data'] = getNetworkTypeDataById($networkRequestData['network_type_id']); // Add row template for deleting - $OUT .= loadTemplate('admin_del_network_params_row', true, $networkRequestData); + $OUT .= loadTemplate('admin_delete_network_params_row', true, $networkRequestData); } else { // Problem! debug_report_bug(__FUNCTION__, __LINE__, '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(getRequestParameter('network')) - ); - // Output main template if (isFormSent('edit')) { - loadTemplate('admin_edit_network_params', false, $content); - } elseif (isFormSent('del')) { - loadTemplate('admin_del_network_params', false, $content); + loadTemplate('admin_edit_network_params', false, $OUT); + } elseif (isFormSent('delete')) { + loadTemplate('admin_delete_network_params', false, $OUT); } else { // Problem! debug_report_bug(__FUNCTION__, __LINE__, 'Cannot detect edit/del.'); @@ -828,15 +935,15 @@ function doAdminNetworkProcessHandlerequestparamsForm () { $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 } // Changes given networks -function doAdminNetworkProcessChangenetworkForm () { +function doAdminNetworkProcessChangeNetwork () { // Do we have selections? - if (countPostSelection() > 0) { + if (ifPostContainsSelections()) { // By default nothing is updated $updated = 0; @@ -873,15 +980,15 @@ 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 } // Removes given networks -function doAdminNetworkProcessRemovenetworkForm () { +function doAdminNetworkProcessRemoveNetwork () { // Do we have selections? - if (countPostSelection() > 0) { + if (ifPostContainsSelections()) { // By default nothing is removed $removed = 0; @@ -900,13 +1007,13 @@ 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 } // Add a network type handler if not yet found -function doAdminNetworkProcessAddnetworktypeForm () { +function doAdminNetworkProcessAddNetworkType () { // Is the network type handle already used with given network? if (isNetworkTypeHandleValid(postRequestParameter('network_type_handle'), getRequestParameter('network'))) { // Already added @@ -929,16 +1036,16 @@ function doAdminNetworkProcessAddnetworktypeForm () { } // END - if // Add the whole request to database - SQL_QUERY("INSERT INTO + SQL_QUERY('INSERT INTO `{?_MYSQL_PREFIX?}_network_types` ( - `" . implode('`,`', array_keys(postRequestArray())) . "` + `' . implode('`,`', array_keys(postRequestArray())) . "` ) VALUES ( '" . implode("','", array_values(postRequestArray())) . "' )", __FUNCTION__, __LINE__); // Output message - if (SQL_AFFECTEDROWS() == 1) { + if (!SQL_HASZEROAFFECTED()) { // Successfully added loadTemplate('admin_network_type_added', false, postRequestArray()); } else { @@ -948,9 +1055,9 @@ function doAdminNetworkProcessAddnetworktypeForm () { } // Changes given network type handlers -function doAdminNetworkProcessChangenetworktypeForm () { +function doAdminNetworkProcessChangeNetworkType () { // Do we have selections? - if (countPostSelection() > 0) { + if (ifPostContainsSelections()) { // By default nothing is updated $updated = 0; @@ -993,15 +1100,15 @@ 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 } // Changes given network request parameters -function doAdminNetworkProcessChangenetworkparamForm () { +function doAdminNetworkProcessChangeNetworkParam () { // Do we have selections? - if (countPostSelection() > 0) { + if (ifPostContainsSelections()) { // By default nothing is updated $updated = 0; @@ -1044,15 +1151,15 @@ 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 } // Removes given network type handlers -function doAdminNetworkProcessRemovenetworktypeForm () { +function doAdminNetworkProcessRemoveNetworkType () { // Do we have selections? - if (countPostSelection() > 0) { + if (ifPostContainsSelections()) { // By default nothing is removed $removed = 0; @@ -1071,15 +1178,15 @@ 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 } // Removes given network request parameters -function doAdminNetworkProcessRemovenetworkparamForm () { +function doAdminNetworkProcessRemoveNetworkParam () { // Do we have selections? - if (countPostSelection() > 0) { + if (ifPostContainsSelections()) { // By default nothing is removed $removed = 0; @@ -1098,13 +1205,13 @@ 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 } // Adds a request parameter to given network and type -function doAdminNetworkProcessAddnetworkparamForm () { +function doAdminNetworkProcessAddNetworkParam () { // Is the request parameter already used with given network? if (isNetworkRequestParameterValid(postRequestParameter('request_param_key'), postRequestParameter('network_type_id'), getRequestParameter('network'))) { // Already added @@ -1127,16 +1234,16 @@ function doAdminNetworkProcessAddnetworkparamForm () { } // END - if // Add the whole request to database - SQL_QUERY("INSERT INTO + SQL_QUERY('INSERT INTO `{?_MYSQL_PREFIX?}_network_request_params` ( - `" . implode('`,`', array_keys(postRequestArray())) . "` + `' . implode('`,`', array_keys(postRequestArray())) . "` ) VALUES ( '" . implode("','", array_values(postRequestArray())) . "' )", __FUNCTION__, __LINE__); // Output message - if (SQL_AFFECTEDROWS() == 1) { + if (!SQL_HASZEROAFFECTED()) { // Successfully added loadTemplate('admin_network_request_param_added', false, postRequestArray()); } else { @@ -1145,6 +1252,52 @@ function doAdminNetworkProcessAddnetworkparamForm () { } } +// Adds a API response array entry +function doAdminNetworkProcessAddNetworkApiTranslation () { + // Is the request parameter already used with given network? + if (isNetworkApiTranslationValid(postRequestParameter('network_api_index'), postRequestParameter('network_type_id'), getRequestParameter('network'))) { + // Already added + loadTemplate('admin_settings_unsaved', false, getMaskedMessage('ADMIN_NETWORK_API_TRANSLATION_ALREADY_ADDED', postRequestParameter('network_api_index'))); + + // ... so abort here + return false; + } // END - if + + // Remove the 'ok' part + unsetPostRequestParameter('ok'); + + // Add id + setPostRequestParameter('network_id', bigintval(getRequestParameter('network'))); + + // Add sorting + setPostRequestParameter('sort', (countSumTotalData( + postRequestParameter('network_id'), + 'network_api_translation', + 'network_api_id', + 'network_id', + true, + sprintf(" AND `network_type_id`=%s", bigintval(postRequestParameter('network_type_id'))) + ) + 1)); + + // Add the whole request to database + SQL_QUERY('INSERT INTO + `{?_MYSQL_PREFIX?}_network_api_translation` +( + `' . implode('`,`', array_keys(postRequestArray())) . "` +) VALUES ( + '" . implode("','", array_values(postRequestArray())) . "' +)", __FUNCTION__, __LINE__); + + // Output message + if (!SQL_HASZEROAFFECTED()) { + // Successfully added + loadTemplate('admin_network_api_translation_added', false, postRequestArray()); + } else { + // Not added + loadTemplate('admin_settings_unsaved', false, getMaskedMessage('ADMIN_NETWORK_API_TRANSLATION_NOT_ADDED', postRequestParameter('network_api_index'))); + } +} + // Do expression code for this extension function doExpressionNetwork ($data) { // Construct replacer @@ -1167,4 +1320,3 @@ function doExpressionNetwork ($data) { // [EOF] ?> -