./inc/language/rallye_de.php:13: * @TODO Naming convention not applied for language strings *
./inc/language/refback_de.php:53: // @TODO Rewrite these constants to one
./inc/language/sponsor_de.php:117:// @TODO Rewrite these four constants to one and use sprintf()
-./inc/libs/admins_functions.php:508: // @TODO This can be, somehow, rewritten
+./inc/libs/admins_functions.php:486: // @TODO This can be, somehow, rewritten
./inc/libs/bonus_functions.php:194: // @TODO Move this HTML to a template
./inc/libs/doubler_functions.php:44:// @TODO Lame description
./inc/libs/doubler_functions.php:93: // @TODO Can't this be moved into EL?
'ADMIN_CONFIG_NETWORK_TITLE' => "Einrichtung des API-Zugangs zum Werbenetzwerk <span class=\"data\">%s</span>:",
'ADMIN_CONFIG_NETWORK_SAVE_BUTTON' => "API-Konfiguration speichern",
'ADMIN_CONFIG_NETWORK_NOTE' => "Tragen Sie hier Ihre Interface-Zugangsdaten zum angzeigten Werbenetzwerk ein.",
+ 'ADMIN_NETWORK_API_CONFIG_SAVED' => "API-Konfiguration gespeichert.",
+ 'ADMIN_NETWORK_API_CONFIG_NOT_SAVED' => "API-Konfiguration NICHT gespeichert (keine Änderungen).",
// Error codes
'ADMIN_NETWORK_AFF_ID_PASS_WRONG_ERROR_CODE' => "Affiliate-Id oder -Passwort falsch",
'ADMIN_NETWORK_SITE_ID_NOT_ASSIGNED_ERROR_CODE' => "Seiten-Id nicht zugewiesen/ungültig",
}
} else {
// Update whole array
- $SQL = 'UPDATE `{?_MYSQL_PREFIX?}_admins` SET ';
- foreach ($postData as $entry => $value) {
- // Skip login/id entry
- if (in_array($entry, array('login', 'id'))) {
- continue;
- } // END - if
-
- // Do we have a non-string (e.g. number, NULL, NOW() or back-tick at the beginning?
- if (is_null($value[$id])) {
- // NULL detected
- $SQL .= '`' . $entry . '`=NULL, ';
- } elseif ((bigintval($value[$id], true, false) === $value[$id]) || ($value[$id] == 'NOW()') || (substr($value[$id], 0, 1) == '`')) {
- // No need for ticks (')
- $SQL .= '`' . $entry . '`=' . $value[$id] . ', ';
- } else {
- // Strings need ticks (') around them
- $SQL .= '`' . $entry . "`='" . SQL_ESCAPE($value[$id]) . "', ";
- }
- } // END - foreach
-
- // Remove last 2 chars and finish query
- $SQL = substr($SQL, 0, -2) . ' WHERE `id`=%s LIMIT 1';
+ $SQL = getUpdateSqlFromArray($postData, 'admins', 'id', '%s', array('login', 'id'), $id);
// Run it
SQL_QUERY_ESC($SQL, array(bigintval($id)), __FUNCTION__, __LINE__);
}
} // END - foreach
- // Display message
- if (!empty($message)) {
- if ($displayMessage === true) {
- displayMessage($message);
- } // END - if
+ // Display message if not empty and allowed
+ if ((!empty($message)) && ($displayMessage === true)) {
+ // Display it
+ displayMessage($message);
} // END - if
// Remove cache file
// Add sorting
setPostRequestElement('sort', (countSumTotalData(
- postRequestElement('network_id'),
+ bigintval(postRequestElement('network_id')),
'network_api_translation',
'network_api_id',
'network_id',
}
}
+// Adds/update network API configuration
+function doAdminNetworkProcessConfigNetwork () {
+ // Check for an entry in network_config
+ $entryCount = countSumTotalData(
+ bigintval(getRequestElement('network')),
+ 'network_config',
+ 'network_id',
+ 'network_id',
+ true
+ );
+
+ // Remove the 'ok' part
+ unsetPostRequestElement('ok');
+
+ // Add id
+ setPostRequestElement('network_id', bigintval(getRequestElement('network')));
+
+ // Is there already an entry?
+ if ($entryCount == 1) {
+ // Generate SQL query
+ $SQL = getUpdateSqlFromArray(postRequestArray(), 'network_config', 'network_id', postRequestElement('network_id'), array('network_id'));
+ } else {
+ // Insert new entry
+ $SQL = 'INSERT INTO
+ `{?_MYSQL_PREFIX?}_network_config`
+(
+ `' . implode('`,`', array_keys(postRequestArray())) . "`
+) VALUES (
+ '" . implode("','", array_values(postRequestArray())) . "'
+)";
+ }
+
+ // Run the query
+ SQL_QUERY($SQL, __FUNCTION__, __LINE__);
+
+ // Output message
+ if (!SQL_HASZEROAFFECTED()) {
+ // Successfully added
+ displayMessage('{--ADMIN_NETWORK_API_CONFIG_SAVED--}');
+ } else {
+ // Not added
+ loadTemplate('admin_settings_unsaved', false, '{--ADMIN_NETWORK_API_CONFIG_NOT_SAVED--}');
+ }
+}
+
// Do expression code for this extension
function doExpressionNetwork ($data) {
// Construct replacer
// Count or sum whole table?
if ($countRows === true) {
// Count whole table
- $result = SQL_QUERY_ESC("SELECT COUNT(`%s`) AS `res` FROM `{?_MYSQL_PREFIX?}_%s`".$add,
+ $result = SQL_QUERY_ESC("SELECT COUNT(`%s`) AS `res` FROM `{?_MYSQL_PREFIX?}_%s`" . $add . ' LIMIT 1',
array(
$lookFor,
$tableName
), __FUNCTION__, __LINE__);
} else {
// Sum whole table
- $result = SQL_QUERY_ESC("SELECT SUM(`%s`) AS `res` FROM `{?_MYSQL_PREFIX?}_%s`".$add,
+ $result = SQL_QUERY_ESC("SELECT SUM(`%s`) AS `res` FROM `{?_MYSQL_PREFIX?}_%s`" . $add . ' LIMIT 1',
array(
$lookFor,
$tableName
} elseif (($countRows === true) || ($lookFor == 'userid')) {
// Count rows
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'COUNT!');
- $result = SQL_QUERY_ESC("SELECT COUNT(`%s`) AS `res` FROM `{?_MYSQL_PREFIX?}_%s` WHERE `%s`%s'%s'".$add,
+ $result = SQL_QUERY_ESC("SELECT COUNT(`%s`) AS `res` FROM `{?_MYSQL_PREFIX?}_%s` WHERE `%s`%s'%s'" . $add . ' LIMIT 1',
array(
$lookFor,
$tableName,
} else {
// Add all rows
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'SUM!');
- $result = SQL_QUERY_ESC("SELECT SUM(`%s`) AS `res` FROM `{?_MYSQL_PREFIX?}_%s` WHERE `%s`%s'%s'".$add,
+ $result = SQL_QUERY_ESC("SELECT SUM(`%s`) AS `res` FROM `{?_MYSQL_PREFIX?}_%s` WHERE `%s`%s'%s'" . $add . ' LIMIT 1',
array(
$lookFor,
$tableName,
);
}
+// Generates an updating SQL query from given array
+function getUpdateSqlFromArray ($array, $tableName, $whereColumn, $whereData, $excludedFields, $multiDimId = NULL) {
+ // Begin SQL query
+ $SQL = 'UPDATE `{?_MYSQL_PREFIX?}_' . $tableName . '` SET ';
+
+ // Insert all data
+ foreach ($array as $entry => $value) {
+ // Skip login/id entry
+ if (in_array($entry, $excludedFields)) {
+ continue;
+ } // END - if
+
+ // Do we have a non-string (e.g. number, NULL, NOW() or back-tick at the beginning?
+ if (is_null($multiDimId)) {
+ // Handle one-dimensional data
+ if (is_null($value)) {
+ // NULL detected
+ $SQL .= '`' . $entry . '`=NULL, ';
+ } elseif ((bigintval($value, true, false) === $value) || ($value == 'NOW()') || (substr($value, 0, 1) == '`')) {
+ // No need for ticks (')
+ $SQL .= '`' . $entry . '`=' . $value . ', ';
+ } else {
+ // Strings need ticks (') around them
+ $SQL .= '`' . $entry . "`='" . SQL_ESCAPE($value) . "', ";
+ }
+ } else {
+ // Handle multi-dimensional data
+ if (is_null($value[$multiDimId])) {
+ // NULL detected
+ $SQL .= '`' . $entry . '`=NULL, ';
+ } elseif ((bigintval($value[$multiDimId], true, false) === $value[$multiDimId]) || ($value[$multiDimId] == 'NOW()') || (substr($value[$multiDimId], 0, 1) == '`')) {
+ // No need for ticks (')
+ $SQL .= '`' . $entry . '`=' . $value[$multiDimId] . ', ';
+ } else {
+ // Strings need ticks (') around them
+ $SQL .= '`' . $entry . "`='" . SQL_ESCAPE($value[$multiDimId]) . "', ";
+ }
+ }
+ } // END - foreach
+
+ // Remove last 2 chars and finish query
+ $SQL = substr($SQL, 0, -2) . ' WHERE `' . $whereColumn . '`=' . $whereData . ' LIMIT 1';
+
+ // Return SQL query
+ return $SQL;
+}
+
// [EOF]
?>
<div align="center">
-<form accept-charset="UTF-8" action="{%url=modules.php?module=admin&what=config_networks&do=config_network%}" method="post">
+<form accept-charset="UTF-8" action="{%url=modules.php?module=admin&what=config_networks&do=config_network&network=$content[network_id]%}" method="post">
<table border="0" cellspacing="0" cellpadding="0" class="table dashed">
<tr>
<td class="table_header bottom" colspan="2" align="center">