+ // Return message id
+ return '{--' . $messageId . '--}';
+}
+
+// Translates API index
+function translateNetworkApiIndex ($index) {
+ // Is there cache?
+ if (!isset($GLOBALS['network_array_index'])) {
+ // Get an array of all API array indexes
+ $GLOBALS['network_array_index'] = array();
+
+ // Get all entries
+ $result = SQL_QUERY('SELECT
+ `network_array_id`,
+ `network_array_index`,
+ `network_translation_name`
+FROM
+ `{?_MYSQL_PREFIX?}_network_array_translation`
+INNER JOIN
+ `{?_MYSQL_PREFIX?}_network_translations`
+ON
+ `network_array_index`=`network_translation_id`
+ORDER BY
+ `network_array_sort` ASC', __FUNCTION__, __LINE__);
+
+ // Are there entries?
+ if (!SQL_HASZERONUMS($result)) {
+ // Get all entries
+ while ($row = SQL_FETCHARRAY($result)) {
+ // Add it to our global array
+ $GLOBALS['network_array_index'][$row['network_array_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_array_index'][$index])) {
+ // Then get the name
+ $name = $GLOBALS['network_array_index'][$index]['network_translation_name'];
+ } // END - if
+
+ // Return translation
+ return translateNetworkTranslationName($name);
+}
+
+// Translates network API configuration status (see function isNetworkApiConfigured()) by given id
+function translateNetworkApiConfiguredStatusById ($networkId) {
+ // Is there 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 (!isNetworkActiveById($networkId)) {
+ // Network is not active
+ $GLOBALS[__FUNCTION__][$networkId] = '{--ADMIN_NETWORK_API_NOT_ACTIVE--}';
+ } elseif (isNetworkApiConfigured($networkId)) {
+ // Yes, it is
+ $GLOBALS[__FUNCTION__][$networkId] = '{--ADMIN_NETWORK_API_CONFIGURED--}';
+ } // END - if
+ } // END - if
+
+ // Return cache
+ return $GLOBALS[__FUNCTION__][$networkId];
+}
+
+/**
+ * "Translates" given amount of queries; 0 = unlimited
+ *
+ * @param $amount Amount of free queries
+ * @return $translated "Translated" value; 0 = unlimited
+ */
+function translateNetworkQueryAmount ($amount) {
+ // Default is unlimited (good! ;-) )
+ $translated = '{--UNLIMITED--}';
+
+ // Is the amount larger zero?
+ if ($amount > 0) {
+ // Then translate it
+ $translated = translateComma($amount);
+ } // END - if
+
+ // Return translated value
+ return $translated;
+}
+
+/**
+ * "Translates given status (Y/N) to "de-/activated" but only if expert and
+ * debug mode are enabled.
+ *
+ * @param $status Can be one of Y/N
+ * @return $translated "Translated" status
+ */
+function translateNetworkActivationStatus ($status) {
+ // Is there cache?
+ if (!isset($GLOBALS[__FUNCTION__][$status])) {
+ // Default is not enabled
+ $GLOBALS[__FUNCTION__][$status] = '';
+
+ // Is expert + debug mode enabled?
+ if ((isAdminsExpertSettingEnabled()) && (isDebugModeEnabled())) {
+ // Then "translate" it
+ $GLOBALS[__FUNCTION__][$status] = translateActivationStatus($status);
+ } // END - if
+ } // END - if
+
+ // Return "translation"
+ return $GLOBALS[__FUNCTION__][$status];
+}
+
+//------------------------------------------------------------------------------
+// Wrapper functions to save data to network tables
+//------------------------------------------------------------------------------
+
+// Updates given network (id) with data from array
+function doNetworkUpdateDataByArray ($networkId, $networkData) {
+ // Ids lower one are not accepted
+ if (!isValidId($networkId)) {
+ // Not good, should be fixed
+ reportBug(__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($networkId)), array(), FALSE, FALSE);
+}
+
+// Updates given network type handler (id) with data from array
+function doNetworkUpdateTypeByArray ($networkTypeId, $networkTypeData) {
+ // Ids lower one are not accepted
+ if (!isValidId($networkTypeId)) {
+ // Not good, should be fixed
+ reportBug(__FUNCTION__, __LINE__, 'Network type handler id ' . $networkTypeId . ' is smaller than 1.');
+ } // END - if
+
+ // Just call our inner method
+ return adminSaveSettings($networkTypeData, '_network_types', sprintf("`network_type_id`=%s", bigintval($networkTypeId)), array(), FALSE, FALSE);
+}
+
+// Updates given network request parameters (id) with data from array
+function doNetworkUpdateParamsByArray ($networkParamsId, $networkParamsData) {
+ // Ids lower one are not accepted
+ if (!isValidId($networkParamsId)) {
+ // Not good, should be fixed
+ reportBug(__FUNCTION__, __LINE__, 'Network request parameter id ' . $networkParamsId . ' is smaller than 1.');
+ } // END - if
+
+ // Just call our inner method
+ return adminSaveSettings($networkParamsData, '_network_request_params', sprintf("`network_request_param_id`=%s", bigintval($networkParamsId)), array(), FALSE, FALSE);
+}
+
+// Updates given network array translations (id) with data from array
+function doNetworkUpdateArrayTranslationsByArray ($networkTranslationsId, $networkTranslationsData) {
+ // Ids lower one are not accepted
+ if (!isValidId($networkTranslationsId)) {
+ // Not good, should be fixed
+ reportBug(__FUNCTION__, __LINE__, 'Network request parameter id ' . $networkTranslationsId . ' is smaller than 1.');
+ } // END - if
+
+ // Just call our inner method
+ return adminSaveSettings($networkTranslationsData, '_network_array_translation', sprintf("`network_array_id`=%s", bigintval($networkTranslationsId)), array(), FALSE, FALSE);
+}
+
+//------------------------------------------------------------------------------
+// Call-back functions for request parameter keys
+//------------------------------------------------------------------------------
+
+// ----------------------- Table: network_api_config -----------------------
+
+// Handles affiliate id
+function doHandleNetworkRequestAffiliateIdKey ($networkTypeId) {
+ // It is assumed that the network + type handler are both configured
+ // Load full config data (this will be "cached"!)
+ $configData = getFullNetworkConfigurationByTypeId($networkTypeId);
+
+ // Is the network activated?
+ if (!isset($configData['network_api_active'])) {
+ // Configuration could not be loaded
+ reportBug(__FUNCTION__, __LINE__, 'Configuration for networkTypeId=' . $networkTypeId . ' could not be loaded.');
+ } elseif (($configData['network_api_active'] == 'N') && (!isDebugModeEnabled())) {
+ // Is not activated, so don't handle it in non-debug mode
+ reportBug(__FUNCTION__, __LINE__, 'Configuration for network_id ' . $configData['network_id'] .',networkTypeId=' . $networkTypeId . ' is not activated.');
+ } elseif (empty($configData['network_api_affiliate_id'])) {
+ // Required element is not set
+ reportBug(__FUNCTION__, __LINE__, 'network_api_affiliate_id for network_id=' . $configData['network_id'] . ',networkTypeId=' . $networkTypeId . ' is not set.');
+ }
+
+ // Return configured value
+ return $configData['network_api_affiliate_id'];
+}
+
+// Handles site id
+function doHandleNetworkRequestSiteIdKey ($networkTypeId) {
+ // It is assumed that the network + type handler are both configured
+ // Load full config data (this will be "cached"!)
+ $configData = getFullNetworkConfigurationByTypeId($networkTypeId);
+
+ // Is the network activated?
+ if (!isset($configData['network_api_active'])) {
+ // Configuration could not be loaded
+ reportBug(__FUNCTION__, __LINE__, 'Configuration for networkTypeId=' . $networkTypeId . ' could not be loaded.');
+ } elseif (($configData['network_api_active'] == 'N') && (!isDebugModeEnabled())) {
+ // Is not activated, so don't handle it in non-debug mode
+ reportBug(__FUNCTION__, __LINE__, 'Configuration for network_id ' . $configData['network_id'] .',networkTypeId=' . $networkTypeId . ' is not activated.');
+ } elseif (empty($configData['network_api_site_id'])) {
+ // Required element is not set
+ reportBug(__FUNCTION__, __LINE__, 'network_api_site_id for network_id=' . $configData['network_id'] . ',networkTypeId=' . $networkTypeId . ' is not set.');
+ }
+
+ // Return configured value
+ return $configData['network_api_site_id'];
+}
+
+// Handles interface password
+function doHandleNetworkRequestPasswordKey ($networkTypeId) {
+ // It is assumed that the network + type handler are both configured
+ // Load full config data (this will be "cached"!)
+ $configData = getFullNetworkConfigurationByTypeId($networkTypeId);
+
+ // Is the network activated?
+ if (!isset($configData['network_api_active'])) {
+ // Configuration could not be loaded
+ reportBug(__FUNCTION__, __LINE__, 'Configuration for networkTypeId=' . $networkTypeId . ' could not be loaded.');
+ } elseif (($configData['network_api_active'] == 'N') && (!isDebugModeEnabled())) {
+ // Is not activated, so don't handle it in non-debug mode
+ reportBug(__FUNCTION__, __LINE__, 'Configuration for network_id ' . $configData['network_id'] .',networkTypeId=' . $networkTypeId . ' is not activated.');
+ } elseif (empty($configData['network_api_password'])) {
+ // Required element is not set
+ reportBug(__FUNCTION__, __LINE__, 'network_api_password for network_id=' . $configData['network_id'] . ',networkTypeId=' . $networkTypeId . ' is not set.');
+ }
+
+ // Return configured value
+ return $configData['network_api_password'];
+}
+
+// ----------------------- Table: network_handler_config -----------------------
+
+// Handles reload lock
+function doHandleNetworkRequestReloadKey ($networkTypeId) {
+ // It is assumed that the network + type handler are both configured
+ // Load full config data (this will be "cached"!)
+ $configData = getFullNetworkConfigurationByTypeId($networkTypeId);
+
+ // Is the network activated?
+ if (!isset($configData['network_api_active'])) {
+ // Configuration could not be loaded
+ reportBug(__FUNCTION__, __LINE__, 'Configuration for networkTypeId=' . $networkTypeId . ' could not be loaded.');
+ } elseif (($configData['network_api_active'] == 'N') && (!isDebugModeEnabled())) {
+ // Is not activated, so don't handle it in non-debug mode
+ reportBug(__FUNCTION__, __LINE__, 'Configuration for network_id ' . $configData['network_id'] .',networkTypeId=' . $networkTypeId . ' is not activated.');
+ }
+
+ // Return configured value
+ return caluculateTimeUnitValue($configData['network_max_reload_time'], $configData['network_type_reload_time_unit']);