if (SQL_NUMROWS($result) == 1) {
// Then get it
$networkData = SQL_FETCHARRAY($result);
+
+ // Solve disabled
} // END - if
// Free result
return $networkTypeData;
}
+// "Getter" for a network request parameter data by provided id number
+function getNetworkRequestParamsDataById ($id) {
+ // Ids lower one are not accepted
+ if ($id < 1) {
+ // Not good, should be fixed
+ debug_report_bug('Network request parameter id ' . $id . ' is smaller than 1.');
+ } // END - if
+
+ // By default we have no data
+ $networkRequestData = array();
+
+ // Query for the network data
+ $result = SQL_QUERY_ESC("SELECT
+ `network_param_id`, `network_id`, `network_type_id`, `request_param_key`, `request_param_value`, `request_param_default`
+FROM
+ `{?_MYSQL_PREFIX?}_network_request_params`
+WHERE
+ `network_param_id`=%s
+LIMIT 1",
+ array(bigintval($id)), __FUNCTION__, __LINE__);
+
+ // Do we have an entry?
+ if (SQL_NUMROWS($result) == 1) {
+ // Then get it
+ $networkRequestData = SQL_FETCHARRAY($result);
+ } // END - if
+
+ // Free result
+ SQL_FREERESULT($result);
+
+ // Return result
+ return $networkRequestData;
+}
+
// Updates given network (id) with data from array
function doNetworkUpdateDataByArray ($id, $networkData) {
// Ids lower one are not accepted
return adminSaveSettings($networkTypeData, '_network_types', sprintf("`network_type_id`=%s", bigintval($id)), array(), false, false);
}
+// Updates given network request parameters (id) with data from array
+function doNetworkUpdateParamsByArray ($id, $networkParamData) {
+ // Ids lower one are not accepted
+ if ($id < 1) {
+ // Not good, should be fixed
+ debug_report_bug('Network request parameter id ' . $id . ' is smaller than 1.');
+ } // END - if
+
+ // Just call our inner method
+ return adminSaveSettings($networkParamData, '_network_request_params', sprintf("`network_param_id`=%s", bigintval($id)), array(), false, false);
+}
+
// Removes given network entry
function doAdminRemoveNetworkEntry ($table, $column, $id, $limit = 1) {
// Remove the entry
return $content;
}
+// Generator (somewhat getter) for network type options
+function generateNetworkTypeOptions ($id) {
+ // Is this an array, then we just came back from edit/delete actions
+ if (is_array($id)) $id = '';
+
+ // Is this cached?
+ if (!isset($GLOBALS['network_type_options'][$id])) {
+ // Generate output and cache it
+ $GLOBALS['network_type_options'][$id] = generateOptionList(
+ 'network_types',
+ 'network_type_id',
+ 'network_type_handle',
+ $id,
+ '',
+ sprintf("WHERE `network_id`=%s", getRequestParameter('network'))
+ );
+ } // END - if
+
+ // Return content
+ return $GLOBALS['network_type_options'][$id];
+}
+
+// Generator (somewhat getter) for request key options
+function generateNetworkRequestKeyOptions ($key) {
+ // Is it cached?
+ if (!isset($GLOBALS['network_request_param_key'][$key])) {
+ // Generate and cache it
+ $GLOBALS['network_request_param_key'][$key] = generateOptionList(
+ '/ARRAY/',
+ array(
+ 'id',
+ 'sid',
+ 'hash',
+ 'password',
+ 'reload',
+ 'max_stay',
+ 'min_stay',
+ 'currency',
+ 'type',
+ 'remain',
+ 'reward',
+ 'size',
+ 'erotic',
+ 'extra'
+ ),
+ array(
+ '{--ADMIN_NETWORK_REQUEST_PARAMS_ID--}',
+ '{--ADMIN_NETWORK_REQUEST_PARAMS_SID--}',
+ '{--ADMIN_NETWORK_REQUEST_PARAMS_HASH--}',
+ '{--ADMIN_NETWORK_REQUEST_PARAMS_PASSWORD--}',
+ '{--ADMIN_NETWORK_REQUEST_PARAMS_RELOAD--}',
+ '{--ADMIN_NETWORK_REQUEST_PARAMS_MAXIMUM_STAY--}',
+ '{--ADMIN_NETWORK_REQUEST_PARAMS_MINIMUM_STAY--}',
+ '{--ADMIN_NETWORK_REQUEST_PARAMS_CURRENCY--}',
+ '{--ADMIN_NETWORK_REQUEST_PARAMS_TYPE--}',
+ '{--ADMIN_NETWORK_REQUEST_PARAMS_REMAIN--}',
+ '{--ADMIN_NETWORK_REQUEST_PARAMS_REWARD--}',
+ '{--ADMIN_NETWORK_REQUEST_PARAMS_SIZE--}',
+ '{--ADMIN_NETWORK_REQUEST_PARAMS_EROTIC--}',
+ '{--ADMIN_NETWORK_REQUEST_PARAMS_EXTRA--}'
+ ),
+ $key,
+ '', '',
+ $GLOBALS['network_params_disabled']
+ );
+ } // END - if
+
+ // Return content
+ return $GLOBALS['network_request_param_key'][$key];
+}
+
//------------------------------------------------------------------------------
// Call-back functions
//------------------------------------------------------------------------------
if (!empty($OUT)) {
// Prepare content for template
$content = array(
- 'rows' => $OUT,
+ 'rows' => $OUT,
'network_data' => getNetworkDataById(getRequestParameter('network'))
);
} // END - if
}
+// Handle network request parameter form
+function doAdminNetworkProcessHandlerequestparamsForm () {
+ // Do we have selections?
+ if (countPostSelection() > 0) {
+ // Init cache array
+ $GLOBALS['network_params_disabled'] = array();
+
+ // Load network data
+ $networkData = getNetworkDataById(getRequestParameter('network'));
+
+ // Something has been selected, so start displaying one by one
+ $SW = 2; $OUT = '';
+ foreach (postRequestParameter('sel') as $id => $sel) {
+ // Is this selected?
+ if ($sel == 1) {
+ // Load this network's data
+ $networkRequestData = getNetworkRequestParamsDataById($id);
+
+ // Do we have found the network?
+ if (count($networkRequestData) > 0) {
+ // Add color
+ $networkRequestData['sw'] = $SW;
+
+ if (isPostRequestParameterSet('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 (isPostRequestParameterSet('del')) {
+ // Fix empty banner URL
+ if (trim($networkRequestData['request_param_default']) == '') $networkRequestData['request_param_default'] = '---';
+
+ // 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);
+ } 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(getRequestParameter('network'))
+ );
+
+ // Output main template
+ if (isPostRequestParameterSet('edit')) {
+ loadTemplate('admin_edit_network_params', false, $content);
+ } elseif (isPostRequestParameterSet('del')) {
+ loadTemplate('admin_del_network_params', 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_unsaved', false, getMessage('ADMIN_NETWORK_REQUEST_PARAMS_NOTHING_FOUND'));
+ }
+ } // END - if
+}
+
// Changes given networks
function doAdminNetworkProcessChangenetworkForm () {
// Do we have selections?
debug_report_bug('No entry in key=' . $key . ', id=' . $id . ' found.');
} // END - if
+ // Fix empty network_type_banner_url to NULL
+ if (($key == 'network_type_banner_url') && (trim($entry[$id]) == '')) {
+ // Set it to NULL
+ $entry[$id] = null;
+ } // END - if
+
// Add this entry
$networkTypeData[$key] = $entry[$id];
} // END - foreach
} // END - if
}
+// Changes given network request parameters
+function doAdminNetworkProcessChangenetworkparamForm () {
+ // 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
+ $networkParamsData = 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
+
+ // Fix empty request_param_default to NULL
+ if (($key == 'request_param_default') && (trim($entry[$id]) == '')) {
+ // Set it to NULL
+ $entry[$id] = null;
+ } // END - if
+
+ // Add this entry
+ $networkParamsData[$key] = $entry[$id];
+ } // END - foreach
+
+ // Update the network data
+ $updated += doNetworkUpdateParamsByArray($id, $networkParamsData);
+ } // END - if
+ } // END - foreach
+
+ // Do we have updates?
+ if ($updated > 0) {
+ // Updates done
+ loadTemplate('admin_settings_saved', false, getMaskedMessage('ADMIN_NETWORK_REQUEST_PARAMS_UPDATED', $updated));
+ } else {
+ // Nothing changed
+ loadTemplate('admin_settings_unsaved', false, getMessage('ADMIN_NETWORK_REQUEST_PARAMS_NOTHING_CHANGED'));
+ }
+ } // END - if
+}
+
// Removes given network type handlers
function doAdminNetworkProcessRemovenetworktypeForm () {
// Do we have selections?
} // END - if
}
+// Removes given network request parameters
+function doAdminNetworkProcessRemovenetworkparamForm () {
+ // 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('request_params', 'network_param_id', $id);
+ } // END - if
+ } // END - foreach
+
+ // Do we have removes?
+ if ($removed > 0) {
+ // Removals done
+ loadTemplate('admin_settings_saved', false, getMaskedMessage('ADMIN_NETWORK_REQUEST_PARAMS_REMOVED', $removed));
+ } else {
+ // Nothing removed
+ loadTemplate('admin_settings_unsaved', false, getMessage('ADMIN_NETWORK_REQUEST_PARAMS_NOTHING_REMOVED'));
+ }
+ } // END - if
+}
+
// Adds a request parameter to given network and type
function doAdminNetworkProcessAddnetworkparamForm () {
// Is the request parameter already used with given network?