} // END - if
// Private setter for current network id
-function setCurrentNetworkId ($id) {
- $GLOBALS['current_network_id'] = bigintval($id);
+function setCurrentNetworkId ($networkId) {
+ $GLOBALS['current_network_id'] = bigintval($networkId);
}
// Private getter for current network id
}
// "Getter" for a network's data by provided id number
-function getNetworkDataById ($id, $column = '') {
+function getNetworkDataById ($networkId, $column = '') {
// Ids lower one are not accepted
- if ($id < 1) {
+ if ($networkId < 1) {
// Not good, should be fixed
- debug_report_bug(__FUNCTION__, __LINE__, 'Network id ' . $id . ' is smaller than 1.');
+ debug_report_bug(__FUNCTION__, __LINE__, 'Network id ' . $networkId . ' is smaller than 1.');
} // END - if
// Set current network id
- setCurrentNetworkId($id);
+ setCurrentNetworkId($networkId);
// Is it cached?
- if (!isset($GLOBALS['network_data'][$id])) {
+ if (!isset($GLOBALS['network_data'][$networkId])) {
// By default we have no data
- $GLOBALS['network_data'][$id] = array();
+ $GLOBALS['network_data'][$networkId] = array();
// Query for the network data
$result = SQL_QUERY_ESC("SELECT
WHERE
`network_id`=%s
LIMIT 1",
- array(bigintval($id)), __FUNCTION__, __LINE__);
+ array(bigintval($networkId)), __FUNCTION__, __LINE__);
// Do we have an entry?
if (SQL_NUMROWS($result) == 1) {
// Then get it
- $GLOBALS['network_data'][$id] = SQL_FETCHARRAY($result);
+ $GLOBALS['network_data'][$networkId] = SQL_FETCHARRAY($result);
} // END - if
// Free result
// Return result
if (empty($column)) {
// Return array
- return $GLOBALS['network_data'][$id];
+ return $GLOBALS['network_data'][$networkId];
} else {
// Return column
- return $GLOBALS['network_data'][$id][$column];
+ return $GLOBALS['network_data'][$networkId][$column];
}
}
// "Getter" for a network's data by provided type id number
-function getNetworkDataByTypeId ($id, $column = '') {
+function getNetworkDataByTypeId ($networkId, $column = '') {
// Ids lower one are not accepted
- if ($id < 1) {
+ if ($networkId < 1) {
// Not good, should be fixed
- debug_report_bug(__FUNCTION__, __LINE__, 'Network type id ' . $id . ' is smaller than 1.');
+ debug_report_bug(__FUNCTION__, __LINE__, 'Network type id ' . $networkId . ' is smaller than 1.');
} // END - if
// Set current network id
- setCurrentNetworkId($id);
+ setCurrentNetworkId($networkId);
// Is it cached?
- if (!isset($GLOBALS['network_data'][$id])) {
+ if (!isset($GLOBALS['network_data'][$networkId])) {
// By default we have no data
- $GLOBALS['network_data'][$id] = array();
+ $GLOBALS['network_data'][$networkId] = array();
// Query for the network data
$result = SQL_QUERY_ESC("SELECT
WHERE
t.`network_type_id`=%s
LIMIT 1",
- array(bigintval($id)), __FUNCTION__, __LINE__);
+ array(bigintval($networkId)), __FUNCTION__, __LINE__);
// Do we have an entry?
if (SQL_NUMROWS($result) == 1) {
// Then get it
- $GLOBALS['network_data'][$id] = SQL_FETCHARRAY($result);
+ $GLOBALS['network_data'][$networkId] = SQL_FETCHARRAY($result);
} // END - if
// Free result
// Return result
if (empty($column)) {
// Return array
- return $GLOBALS['network_data'][$id];
+ return $GLOBALS['network_data'][$networkId];
} else {
// Return column
- return $GLOBALS['network_data'][$id][$column];
+ return $GLOBALS['network_data'][$networkId][$column];
}
}
// "Getter" for a network type data by provided id number
-function getNetworkTypeDataById ($id) {
+function getNetworkTypeDataById ($networkId) {
// Ids lower one are not accepted
- if ($id < 1) {
+ if ($networkId < 1) {
// Not good, should be fixed
- debug_report_bug(__FUNCTION__, __LINE__, 'Network type id ' . $id . ' is smaller than 1.');
+ debug_report_bug(__FUNCTION__, __LINE__, 'Network type id ' . $networkId . ' is smaller than 1.');
} // END - if
// By default we have no data
- $GLOBALS['network_type_data'][$id] = array();
+ $GLOBALS['network_type_data'][$networkId] = array();
// Query for the network data
$result = SQL_QUERY_ESC("SELECT
WHERE
`network_type_id`=%s
LIMIT 1",
- array(bigintval($id)), __FUNCTION__, __LINE__);
+ array(bigintval($networkId)), __FUNCTION__, __LINE__);
// Do we have an entry?
if (SQL_NUMROWS($result) == 1) {
// Then get it
- $GLOBALS['network_type_data'][$id] = SQL_FETCHARRAY($result);
+ $GLOBALS['network_type_data'][$networkId] = SQL_FETCHARRAY($result);
} // END - if
// Free result
SQL_FREERESULT($result);
// Return result
- return $GLOBALS['network_type_data'][$id];
+ return $GLOBALS['network_type_data'][$networkId];
}
// "Getter" for a network request parameter data by provided id number
-function getNetworkRequestParamsDataById ($id) {
+function getNetworkRequestParamsDataById ($networkId) {
// Ids lower one are not accepted
- if ($id < 1) {
+ if ($networkId < 1) {
// Not good, should be fixed
- debug_report_bug(__FUNCTION__, __LINE__, 'Network request parameter id ' . $id . ' is smaller than 1.');
+ debug_report_bug(__FUNCTION__, __LINE__, 'Network request parameter id ' . $networkId . ' is smaller than 1.');
} // END - if
// By default we have no data
WHERE
`network_param_id`=%s
LIMIT 1",
- array(bigintval($id)), __FUNCTION__, __LINE__);
+ array(bigintval($networkId)), __FUNCTION__, __LINE__);
// Do we have an entry?
if (SQL_NUMROWS($result) == 1) {
}
// Updates given network (id) with data from array
-function doNetworkUpdateDataByArray ($id, $networkData) {
+function doNetworkUpdateDataByArray ($networkId, $networkData) {
// Ids lower one are not accepted
- if ($id < 1) {
+ if ($networkId < 1) {
// Not good, should be fixed
- debug_report_bug(__FUNCTION__, __LINE__, 'Network id ' . $id . ' is smaller than 1.');
+ debug_report_bug(__FUNCTION__, __LINE__, 'Network id ' . $networkId . ' is smaller than 1.');
} // END - if
// Just call our inner method
- return adminSaveSettings($networkData, '_network_data', sprintf("`network_id`=%s", bigintval($id)), array(), false, false);
+ return adminSaveSettings($networkData, '_network_data', sprintf("`network_id`=%s", bigintval($networkId)), array(), false, false);
}
// Updates given network type handler (id) with data from array
-function doNetworkUpdateTypeByArray ($id, $networkTypeData) {
+function doNetworkUpdateTypeByArray ($networkId, $networkTypeData) {
// Ids lower one are not accepted
- if ($id < 1) {
+ if ($networkId < 1) {
// Not good, should be fixed
- debug_report_bug(__FUNCTION__, __LINE__, 'Network type handler id ' . $id . ' is smaller than 1.');
+ debug_report_bug(__FUNCTION__, __LINE__, 'Network type handler id ' . $networkId . ' 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);
+ return adminSaveSettings($networkTypeData, '_network_types', sprintf("`network_type_id`=%s", bigintval($networkId)), array(), false, false);
}
// Updates given network request parameters (id) with data from array
-function doNetworkUpdateParamsByArray ($id, $networkParamData) {
+function doNetworkUpdateParamsByArray ($networkId, $networkParamData) {
// Ids lower one are not accepted
- if ($id < 1) {
+ if ($networkId < 1) {
// Not good, should be fixed
- debug_report_bug(__FUNCTION__, __LINE__, 'Network request parameter id ' . $id . ' is smaller than 1.');
+ debug_report_bug(__FUNCTION__, __LINE__, 'Network request parameter id ' . $networkId . ' 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);
+ return adminSaveSettings($networkParamData, '_network_request_params', sprintf("`network_param_id`=%s", bigintval($networkId)), array(), false, false);
}
// Removes given network entry
-function doAdminRemoveNetworkEntry ($table, $column, $id, $limit = 1) {
+function doAdminRemoveNetworkEntry ($table, $column, $networkId, $limit = 1) {
// Remove the entry
SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_network_%s` WHERE `%s`=%s LIMIT %s",
- array($table, $column, $id, $limit), __FUNCTION__, __LINE__);
+ array($table, $column, $networkId, $limit), __FUNCTION__, __LINE__);
// Return affected rows
return SQL_AFFECTEDROWS();
}
// Generator (somewhat getter) for network type options
-function generateNetworkTypeOptions ($id) {
+function generateNetworkTypeOptions ($networkId) {
// Is this an array, then we just came back from edit/delete actions
- if (is_array($id)) {
- $id = '';
+ if (is_array($networkId)) {
+ $networkId = '';
} // END - if
// Is this cached?
- if (!isset($GLOBALS[__FUNCTION__][$id])) {
+ if (!isset($GLOBALS[__FUNCTION__][$networkId])) {
// Generate output and cache it
- $GLOBALS[__FUNCTION__][$id] = generateOptionList(
+ $GLOBALS[__FUNCTION__][$networkId] = generateOptionList(
'network_types',
'network_type_id',
'network_type_handle',
- $id,
+ $networkId,
'',
sprintf(
"WHERE `network_id`=%s",
} // END - if
// Return content
- return $GLOBALS[__FUNCTION__][$id];
+ return $GLOBALS[__FUNCTION__][$networkId];
}
// Generates an options list of all available (hard-coded) handlers
return translateNetworkTranslationName($name);
}
+// Translates network API configuration status (see function isNetworkApiConfigured()) by given id
+function translateNetworkApiConfiguredStatusById ($networkId) {
+ // Do we have cache?
+ if (!isset($GLOBALS[__FUNCTION__][$networkId])) {
+ // By default it is not configured
+ $GLOBALS[__FUNCTION__][$networkId] = '{--ADMIN_NETWORK_API_NOT_CONFIGURED--}';
+
+ // So is it configured?
+ if (isNetworkApiConfigured($networkId)) {
+ // Yes, it is
+ $GLOBALS[__FUNCTION__][$networkId] = '{--ADMIN_NETWORK_API_CONFIGURED--}';
+ } // END - if
+ } // END - if
+
+ // Return cache
+ return $GLOBALS[__FUNCTION__][$networkId];
+}
+
+// Checks if the given network is configured by looking its API configuration entry up
+function isNetworkApiConfigured ($networkId) {
+ // Do we have cache?
+ if (!isset($GLOBALS[__FUNCTION__][$networkId])) {
+ // Check for an entry in network_api_config
+ $GLOBALS[__FUNCTION__][$networkId] = (countSumTotalData(
+ bigintval($networkId),
+ 'network_api_config',
+ 'network_id',
+ 'network_id',
+ true
+ ) == 1);
+ } // END - if
+
+ // Return cache
+ return $GLOBALS[__FUNCTION__][$networkId];
+}
+
//------------------------------------------------------------------------------
// Call-back functions
//------------------------------------------------------------------------------
if (ifPostContainsSelections()) {
// Something has been selected, so start displaying one by one
$OUT = '';
- foreach (postRequestElement('sel') as $id => $sel) {
+ foreach (postRequestElement('sel') as $networkId => $sel) {
// Is this selected?
if ($sel == 1) {
// Load this network's data
- $networkData = getNetworkDataById($id);
+ $networkData = getNetworkDataById($networkId);
// Do we have found the network?
if (count($networkData) > 0) {
// Something has been selected, so start displaying one by one
$OUT = '';
- foreach (postRequestElement('sel') as $id => $sel) {
+ foreach (postRequestElement('sel') as $networkId => $sel) {
// Is this selected?
if ($sel == 1) {
// Load this network's data
- $networkTypeData = getNetworkTypeDataById($id);
+ $networkTypeData = getNetworkTypeDataById($networkId);
// Do we have found the network?
if (count($networkTypeData) > 0) {
// Something has been selected, so start displaying one by one
$OUT = '';
- foreach (postRequestElement('sel') as $id => $sel) {
+ foreach (postRequestElement('sel') as $networkId => $sel) {
// Is this selected?
if ($sel == 1) {
// Load this network's data
- $networkRequestData = getNetworkRequestParamsDataById($id);
+ $networkRequestData = getNetworkRequestParamsDataById($networkId);
// Do we have found the network?
if (count($networkRequestData) > 0) {
$updated = 0;
// Something has been selected, so start updating them
- foreach (postRequestElement('sel') as $id => $sel) {
+ foreach (postRequestElement('sel') as $networkId => $sel) {
// Update this entry?
if ($sel == 1) {
// Init data array
} // END - if
// Do we have this enty?
- if (!isset($entry[$id])) {
+ if (!isset($entry[$networkId])) {
// Not found, needs fixing
- debug_report_bug(__FUNCTION__, __LINE__, 'No entry in key=' . $key . ', id=' . $id . ' found.');
+ debug_report_bug(__FUNCTION__, __LINE__, 'No entry in key=' . $key . ', id=' . $networkId . ' found.');
} // END - if
// Add this entry
- $networkData[$key] = $entry[$id];
+ $networkData[$key] = $entry[$networkId];
} // END - foreach
// Update the network data
- $updated += doNetworkUpdateDataByArray($id, $networkData);
+ $updated += doNetworkUpdateDataByArray($networkId, $networkData);
} // END - if
} // END - foreach
$removed = 0;
// Something has been selected, so start updating them
- foreach (postRequestElement('sel') as $id => $sel) {
+ foreach (postRequestElement('sel') as $networkId => $sel) {
// Update this entry?
if ($sel == 1) {
// Remove this entry
- $removed += doAdminRemoveNetworkEntry('data', 'network_id', $id);
+ $removed += doAdminRemoveNetworkEntry('data', 'network_id', $networkId);
} // END - if
} // END - foreach
$updated = 0;
// Something has been selected, so start updating them
- foreach (postRequestElement('sel') as $id => $sel) {
+ foreach (postRequestElement('sel') as $networkId => $sel) {
// Update this entry?
if ($sel == 1) {
// Init data array
} // END - if
// Do we have this enty?
- if (!isset($entry[$id])) {
+ if (!isset($entry[$networkId])) {
// Not found, needs fixing
- debug_report_bug(__FUNCTION__, __LINE__, 'No entry in key=' . $key . ', id=' . $id . ' found.');
+ debug_report_bug(__FUNCTION__, __LINE__, 'No entry in key=' . $key . ', id=' . $networkId . ' found.');
} // END - if
// Fix empty network_type_banner_url to NULL
- if (($key == 'network_type_banner_url') && (trim($entry[$id]) == '')) {
+ if (($key == 'network_type_banner_url') && (trim($entry[$networkId]) == '')) {
// Set it to NULL
- $entry[$id] = NULL;
+ $entry[$networkId] = NULL;
} // END - if
// Add this entry
- $networkTypeData[$key] = $entry[$id];
+ $networkTypeData[$key] = $entry[$networkId];
} // END - foreach
// Update the network data
- $updated += doNetworkUpdateTypeByArray($id, $networkTypeData);
+ $updated += doNetworkUpdateTypeByArray($networkId, $networkTypeData);
} // END - if
} // END - foreach
$updated = 0;
// Something has been selected, so start updating them
- foreach (postRequestElement('sel') as $id => $sel) {
+ foreach (postRequestElement('sel') as $networkId => $sel) {
// Update this entry?
if ($sel == 1) {
// Init data array
} // END - if
// Do we have this enty?
- if (!isset($entry[$id])) {
+ if (!isset($entry[$networkId])) {
// Not found, needs fixing
- debug_report_bug(__FUNCTION__, __LINE__, 'No entry in key=' . $key . ', id=' . $id . ' found.');
+ debug_report_bug(__FUNCTION__, __LINE__, 'No entry in key=' . $key . ', id=' . $networkId . ' found.');
} // END - if
// Fix empty request_param_default to NULL
- if (($key == 'request_param_default') && (trim($entry[$id]) == '')) {
+ if (($key == 'request_param_default') && (trim($entry[$networkId]) == '')) {
// Set it to NULL
- $entry[$id] = NULL;
+ $entry[$networkId] = NULL;
} // END - if
// Add this entry
- $networkParamsData[$key] = $entry[$id];
+ $networkParamsData[$key] = $entry[$networkId];
} // END - foreach
// Update the network data
- $updated += doNetworkUpdateParamsByArray($id, $networkParamsData);
+ $updated += doNetworkUpdateParamsByArray($networkId, $networkParamsData);
} // END - if
} // END - foreach
$removed = 0;
// Something has been selected, so start updating them
- foreach (postRequestElement('sel') as $id => $sel) {
+ foreach (postRequestElement('sel') as $networkId => $sel) {
// Update this entry?
if ($sel == 1) {
// Remove this entry
- $removed += doAdminRemoveNetworkEntry('types', 'network_type_id', $id);
+ $removed += doAdminRemoveNetworkEntry('types', 'network_type_id', $networkId);
} // END - if
} // END - foreach
$removed = 0;
// Something has been selected, so start updating them
- foreach (postRequestElement('sel') as $id => $sel) {
+ foreach (postRequestElement('sel') as $networkId => $sel) {
// Update this entry?
if ($sel == 1) {
// Remove this entry
- $removed += doAdminRemoveNetworkEntry('request_params', 'network_param_id', $id);
+ $removed += doAdminRemoveNetworkEntry('request_params', 'network_param_id', $networkId);
} // END - if
} // END - foreach
// Adds/update network API configuration
function doAdminNetworkProcessNetworkApiConfig () {
- // Check for an entry in network_api_config
- $entryCount = countSumTotalData(
- bigintval(getRequestElement('network')),
- 'network_api_config',
- 'network_id',
- 'network_id',
- true
- );
-
// Remove the 'ok' part
unsetPostRequestElement('ok');
setPostRequestElement('network_id', bigintval(getRequestElement('network')));
// Is there already an entry?
- if ($entryCount == 1) {
+ if (isNetworkApiConfigured(getRequestElement('network'))) {
// Generate SQL query
$SQL = getUpdateSqlFromArray(postRequestArray(), 'network_api_config', 'network_id', postRequestElement('network_id'), array('network_id'));
} else {
// Output message
if (!SQL_HASZEROAFFECTED()) {
// Successfully added
- displayMessage('{--ADMIN_NETWORK_API_CONFIG_SAVED--}');
+ displayMessage('{--ADMIN_CONFIG_NETWORK_API_SAVED--}');
} else {
// Not added
- loadTemplate('admin_settings_unsaved', false, '{--ADMIN_NETWORK_API_CONFIG_NOT_SAVED--}');
+ loadTemplate('admin_settings_unsaved', false, '{--ADMIN_CONFIG_NETWORK_API_NOT_SAVED--}');
}
}