X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Flibs%2Fnetwork_functions.php;h=f0ccb45981a82c9ffd4b93dd8559082729d0b478;hb=1cf53b85ecf223f806bcf2cf0c3d696be180c254;hp=d8fbacec8ce99412d202b9083ce45e655847bd12;hpb=95e7ebcc079858e287ea182a03cd372df0d0934f;p=mailer.git diff --git a/inc/libs/network_functions.php b/inc/libs/network_functions.php index d8fbacec8c..f0ccb45981 100644 --- a/inc/libs/network_functions.php +++ b/inc/libs/network_functions.php @@ -81,7 +81,7 @@ function doAdminNetworkProcessForm () { } // Create function name - $functionName = sprintf("doAdminNetworkProcess%sForm", capitalizeUnderscoreString(getRequestParameter('do'))); + $functionName = sprintf("doAdminNetworkProcess%s", capitalizeUnderscoreString(getRequestParameter('do'))); // Is the function valid? if (!function_exists($functionName)) { @@ -141,6 +141,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 @@ -618,12 +634,57 @@ function translateNetworkRequestType ($name) { return getMessage('ADMIN_NETWORK_REQUEST_TYPE_' . strtoupper($name) . ''); } +// 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); +} + //------------------------------------------------------------------------------ // Call-back functions //------------------------------------------------------------------------------ // 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 @@ -657,7 +718,7 @@ function doAdminNetworkProcessAddNetworkForm () { } // Displays selected networks for editing -function doAdminNetworkProcessHandleNetworkForm () { +function doAdminNetworkProcessHandleNetwork () { // Do we have selections? if (ifPostContainsSelections()) { // Something has been selected, so start displaying one by one @@ -706,7 +767,7 @@ function doAdminNetworkProcessHandleNetworkForm () { } // Handle network type form -function doAdminNetworkProcessHandleNetworkTypeForm () { +function doAdminNetworkProcessHandleNetworkType () { // Do we have selections? if (ifPostContainsSelections()) { // Load network data @@ -758,7 +819,7 @@ function doAdminNetworkProcessHandleNetworkTypeForm () { } // Handle network request parameter form -function doAdminNetworkProcessHandleRequestParamsForm () { +function doAdminNetworkProcessHandleRequestParams () { // Do we have selections? if (ifPostContainsSelections()) { // Init cache array @@ -816,7 +877,7 @@ function doAdminNetworkProcessHandleRequestParamsForm () { } // Changes given networks -function doAdminNetworkProcessChangeNetworkForm () { +function doAdminNetworkProcessChangeNetwork () { // Do we have selections? if (ifPostContainsSelections()) { // By default nothing is updated @@ -861,7 +922,7 @@ function doAdminNetworkProcessChangeNetworkForm () { } // Removes given networks -function doAdminNetworkProcessRemoveNetworkForm () { +function doAdminNetworkProcessRemoveNetwork () { // Do we have selections? if (ifPostContainsSelections()) { // By default nothing is removed @@ -888,7 +949,7 @@ function doAdminNetworkProcessRemoveNetworkForm () { } // 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 @@ -911,10 +972,10 @@ 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__); @@ -930,7 +991,7 @@ function doAdminNetworkProcessAddNetworkTypeForm () { } // Changes given network type handlers -function doAdminNetworkProcessChangeNetworkTypeForm () { +function doAdminNetworkProcessChangeNetworkType () { // Do we have selections? if (ifPostContainsSelections()) { // By default nothing is updated @@ -981,7 +1042,7 @@ function doAdminNetworkProcessChangeNetworkTypeForm () { } // Changes given network request parameters -function doAdminNetworkProcessChangeNetworkParamForm () { +function doAdminNetworkProcessChangeNetworkParam () { // Do we have selections? if (ifPostContainsSelections()) { // By default nothing is updated @@ -1032,7 +1093,7 @@ function doAdminNetworkProcessChangeNetworkParamForm () { } // Removes given network type handlers -function doAdminNetworkProcessRemoveNetworkTypeForm () { +function doAdminNetworkProcessRemoveNetworkType () { // Do we have selections? if (ifPostContainsSelections()) { // By default nothing is removed @@ -1059,7 +1120,7 @@ function doAdminNetworkProcessRemoveNetworkTypeForm () { } // Removes given network request parameters -function doAdminNetworkProcessRemoveNetworkParamForm () { +function doAdminNetworkProcessRemoveNetworkParam () { // Do we have selections? if (ifPostContainsSelections()) { // By default nothing is removed @@ -1086,7 +1147,7 @@ function doAdminNetworkProcessRemoveNetworkParamForm () { } // 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,6 +1188,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_AFFECTEDROWS() == 1) { + // 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