]> git.mxchange.org Git - mailer.git/commitdiff
Extension ext-network continued:
authorRoland Häder <roland@mxchange.org>
Tue, 30 Aug 2011 22:46:09 +0000 (22:46 +0000)
committerRoland Häder <roland@mxchange.org>
Tue, 30 Aug 2011 22:46:09 +0000 (22:46 +0000)
- Added ability to set configuration for all network type handlers
- Also data in 'cache_request' needs to be unset

inc/language/network_de.php
inc/libs/network_functions.php
inc/modules/admin/what-config_network_types.php
inc/request-functions.php
templates/de/html/admin/admin_add_config_network_type_form.tpl
templates/de/html/admin/admin_edit_config_network_type_form.tpl

index 534fa0dfbb4efffe5007a778adbae8eaf4859b63..0ed7ddaf290e68458ffc049409076a53a377957f 100644 (file)
@@ -243,9 +243,12 @@ addMessages(array(
        'ADMIN_CONFIG_NETWORK_HANDLER_TYPE_MIN_PAYMENT' => "Mindestverg&uuml;tung (maximal f&uuml;nf Stellen hinterm Komma):",
        'ADMIN_CONFIG_NETWORK_HANDLER_TYPE_ALLOW_EROTIC' => "Wert f&uuml;r das Zulassen von Erotikkampagnen:",
        'ADMIN_CONFIG_NETWORK_HANDLER_TYPE_HANDLER_SAVED' => "Werbeart-Handler wurde gespeichert und ist sofort g&uuml;ltig.",
-       'ADMIN_CONFIG_NETWORK_HANDLER_TYPE_HANDLER_NOT_SAVED' => "Werbeart-Handler wurde NICHT gespeichert.",
+       'ADMIN_CONFIG_NETWORK_HANDLER_TYPE_HANDLER_NOT_SAVED' => "Werbeart-Handler wurde(n) NICHT gespeichert.",
        'ADMIN_NETWORK_HANDLER_TYPE_HANDLER_NOT_CONFIGURED' => "Werart-Handler wurde noch nicht eingerichtet. Bitte verwenden Sie dazu das passende Formular.",
-       'ADMIN_CONFIG_NETWORK_HANDLER_TYPE_HANDLER_NOT_CHANGED' => "Werbeart-Handler wurde NICHT ge&auml;ndert.",
+       'ADMIN_CONFIG_NETWORK_HANDLER_TYPE_HANDLER_NOT_CHANGED' => "Werbeart-Handler wurde(n) NICHT ge&auml;ndert.",
+       'ADMIN_CONFIG_NETWORK_HANDLER_SET_ALL' => "Diese Einstellungen f&uuml;r alle Werbeart-Handler konfigurieren:",
+       'ADMIN_CONFIG_NETWORK_HANDLER_SET_ALL_404' => "Es wurde beim &Uuml;bertragen der Einstellungen keine Werbeart-Handler gefunden.",
+       'ADMIN_CONFIG_NETWORK_HANDLER_TYPE_ALL_HANDLER_SAVED' => "<strong>%s</strong> Werbeart-Handler wurden gespeichert.",
        // SQL export for all network tables
        'ADMIN_EXPORT_NETWORK_NOTE' => "Verwenden Sie diesen SQL-Befehl nicht in phpMyAdmin oder anderen SQL-Clients, dieser SQL-Befehl ist zum Einf&uuml;gen in das Script <strong>ext-network.php</strong> konzipiert.",
        'ADMIN_EXPORT_ALL_NETWORK_DATA_LINK' => "Gesamte Tabelle <strong>network_data</strong> zum Einf&uuml;gen in ext-network.php exportieren",
index 90ad1a0efd843cd81169cf92f7402c6de65bd588..92174639cab7979bfe389342f1e06ff738b10145 100644 (file)
@@ -1464,7 +1464,7 @@ function doAdminNetworkProcessNetworkApiConfig () {
 }
 
 // Only adds network type configuration if not yet present
-function doAdminNetworkProcessAddHandlerTypesConfig () {
+function doAdminNetworkProcessAddHandlerTypesConfig ($displayMessage = true) {
        // Remove the 'ok' part
        unsetPostRequestElement('ok');
 
@@ -1488,6 +1488,8 @@ function doAdminNetworkProcessAddHandlerTypesConfig () {
        $content = array();
        $id = 'network_max_reload_time_ye';
        $skip = false;
+
+       // Get all POST data
        $postData = postRequestArray();
 
        // Convert "reload time selections"
@@ -1503,31 +1505,75 @@ function doAdminNetworkProcessAddHandlerTypesConfig () {
                return;
        } // END - if
 
-       // Get SQL query for new entry
-       $SQL = getInsertSqlFromArray(postRequestArray(), 'network_types_config');
+       // Copy 'set all' and remove it from POST data
+       $setAll = (postRequestElement('set_all') === 'Y');
+       unsetPostRequestElement('set_all');
 
-       // Run the query
-       SQL_QUERY($SQL, __FUNCTION__, __LINE__);
+       // Shall we set for all?
+       if ($setAll === true) {
+               // Get all handlers
+               $result = SQL_QUERY_ESC('SELECT `network_type_id` FROM `{?_MYSQL_PREFIX?}_network_types` WHERE `network_id`=%s ORDER BY `network_type_id` ASC',
+                       array(bigintval(getRequestElement('network_id'))), __FUNCTION__, __LINE__);
 
-       // Output message
-       if (!SQL_HASZEROAFFECTED()) {
-               // Successfully added
-               displayMessage('{--ADMIN_CONFIG_NETWORK_HANDLER_TYPE_HANDLER_SAVED--}');
+               // Do we have entries?
+               if (SQL_HASZERONUMS($result)) {
+                       // No, then abort here
+                       displayMessage('{--ADMIN_CONFIG_NETWORK_HANDLER_SET_ALL_404--}');
+                       return;
+               } // END - if
+
+               // Init number of rows
+               $numRows = 0;
+
+               // Fetch all ids
+               while (list($typeId) = SQL_FETCHROW($result)) {
+                       // Set it in GET data
+                       setGetRequestElement('network_type_id', $typeId);
+
+                       // Call this function again
+                       $numRows += doAdminNetworkProcessAddHandlerTypesConfig(false);
+               } // END - while
+
+               // Free result
+               SQL_FREERESULT($result);
+
+               // Output message
+               if ($numRows > 0) {
+                       // Something has been updated
+                       displayMessage('{%message,ADMIN_CONFIG_NETWORK_HANDLER_TYPE_ALL_HANDLER_SAVED=' . bigintval($numRows) . '%}');
+               } else {
+                       // Nothing has been saved
+                       loadTemplate('admin_settings_unsaved', false, '{--ADMIN_CONFIG_NETWORK_HANDLER_TYPE_HANDLER_NOT_CHANGED--}');
+               }
        } else {
-               // Not added
-               loadTemplate('admin_settings_unsaved', false, '{--ADMIN_CONFIG_NETWORK_HANDLER_TYPE_HANDLER_NOT_SAVED--}');
+               // Get SQL query for new entry
+               $SQL = getInsertSqlFromArray(postRequestArray(), 'network_types_config');
+
+               // Run the query
+               SQL_QUERY($SQL, __FUNCTION__, __LINE__);
+
+               // Shall we display the message?
+               if ($displayMessage === true) {
+                       // Output message
+                       if (!SQL_HASZEROAFFECTED()) {
+                               // Successfully added
+                               displayMessage('{--ADMIN_CONFIG_NETWORK_HANDLER_TYPE_HANDLER_SAVED--}');
+                       } else {
+                               // Not added
+                               loadTemplate('admin_settings_unsaved', false, '{--ADMIN_CONFIG_NETWORK_HANDLER_TYPE_HANDLER_NOT_SAVED--}');
+                       }
+               } else {
+                       // Return amount of affected rows (1 or 2)
+                       return SQL_AFFECTEDROWS();
+               }
        }
 }
 
 // Only changes network type configuration if not yet present
-function doAdminNetworkProcessEditHandlerTypesConfig () {
+function doAdminNetworkProcessEditHandlerTypesConfig ($displayMessage = true) {
        // Remove the 'ok' part
        unsetPostRequestElement('ok');
 
-       // Add both ids
-       setPostRequestElement('network_id', bigintval(getRequestElement('network_id')));
-       setPostRequestElement('network_type_id', bigintval(getRequestElement('network_type_id')));
-
        /*
         * Some parameters are optional, at least one must be given so check a bunch
         * of parameters.
@@ -1559,19 +1605,67 @@ function doAdminNetworkProcessEditHandlerTypesConfig () {
                return;
        } // END - if
 
-       // Get SQL query for new entry
-       $SQL = getUpdateSqlFromArray(postRequestArray(), 'network_types_config', 'network_data_id', postRequestElement('network_data_id'), array('network_data_id'));
+       // Copy 'set all' and remove it from POST data
+       $setAll = (postRequestElement('set_all') === 'Y');
+       unsetPostRequestElement('set_all');
 
-       // Run the query
-       SQL_QUERY($SQL, __FUNCTION__, __LINE__);
+       // Shall we set for all?
+       if ($setAll === true) {
+               // Get all data entries
+               $result = SQL_QUERY_ESC('SELECT `network_data_id` FROM `{?_MYSQL_PREFIX?}_network_types_config` WHERE `network_id`=%s ORDER BY `network_type_id` ASC',
+                       array(bigintval(getRequestElement('network_id'))), __FUNCTION__, __LINE__);
 
-       // Output message
-       if (!SQL_HASZEROAFFECTED()) {
-               // Successfully added
-               displayMessage('{--ADMIN_CONFIG_NETWORK_HANDLER_TYPE_HANDLER_SAVED--}');
+               // Do we have entries?
+               if (SQL_HASZERONUMS($result)) {
+                       // No, then abort here
+                       displayMessage('{--ADMIN_CONFIG_NETWORK_HANDLER_SET_ALL_404--}');
+                       return;
+               } // END - if
+
+               // Init number of rows
+               $numRows = 0;
+
+               // Fetch all ids
+               while (list($dataId) = SQL_FETCHROW($result)) {
+                       // Set it in GET data
+                       setPostRequestElement('network_data_id', $dataId);
+
+                       // Call this function again
+                       $numRows += doAdminNetworkProcessEditHandlerTypesConfig(false);
+               } // END - while
+
+               // Free result
+               SQL_FREERESULT($result);
+
+               // Output message
+               if ($numRows > 0) {
+                       // Something has been updated
+                       displayMessage('{%message,ADMIN_CONFIG_NETWORK_HANDLER_TYPE_ALL_HANDLER_SAVED=' . bigintval($numRows) . '%}');
+               } else {
+                       // Nothing has been saved
+                       loadTemplate('admin_settings_unsaved', false, '{--ADMIN_CONFIG_NETWORK_HANDLER_TYPE_HANDLER_NOT_CHANGED--}');
+               }
        } else {
-               // Not added
-               loadTemplate('admin_settings_unsaved', false, '{--ADMIN_CONFIG_NETWORK_HANDLER_TYPE_HANDLER_NOT_CHANGED--}');
+               // Get SQL query for new entry
+               $SQL = getUpdateSqlFromArray(postRequestArray(), 'network_types_config', 'network_data_id', postRequestElement('network_data_id'), array('network_data_id'));
+
+               // Run the query
+               SQL_QUERY($SQL, __FUNCTION__, __LINE__);
+
+               // Shall we display the message?
+               if ($displayMessage === true) {
+                       // Output message
+                       if (!SQL_HASZEROAFFECTED()) {
+                               // Successfully added
+                               displayMessage('{--ADMIN_CONFIG_NETWORK_HANDLER_TYPE_HANDLER_SAVED--}');
+                       } else {
+                               // Not added
+                               loadTemplate('admin_settings_unsaved', false, '{--ADMIN_CONFIG_NETWORK_HANDLER_TYPE_HANDLER_NOT_CHANGED--}');
+                       }
+               } else {
+                       // Return amount of affected rows (1 or 2)
+                       return SQL_AFFECTEDROWS();
+               }
        }
 }
 
index a18ae387c745456a99a51515b0c19067eedf0e04..fd4efcfe2ca03f6fbd71774c24e51243ad623eb5 100644 (file)
@@ -64,11 +64,11 @@ if (isGetRequestElementSet('network_id')) {
        if (isGetRequestElementSet('network_type_id')) {
                // Load data for given network
                $result = SQL_QUERY_ESC('SELECT
-       `network_id`,
-       `network_type_id`,
-       `network_type_handler`,
-       `network_type_reload_time_unit`,
-       `network_active`,
+       t.`network_id`,
+       t.`network_type_id`,
+       t.`network_type_handler`,
+       t.`network_type_reload_time_unit`,
+       d.`network_active`,
        NULL AS `network_data_id`,
        NULL AS `network_max_reload_time`,
        NULL AS `network_min_waiting_time`,
@@ -76,10 +76,14 @@ if (isGetRequestElementSet('network_id')) {
        NULL AS `network_min_payment`,
        NULL AS `network_allow_erotic`
 FROM
-       `{?_MYSQL_PREFIX?}_network_types`
+       `{?_MYSQL_PREFIX?}_network_types` AS t
+INNER JOIN
+       `{?_MYSQL_PREFIX?}_network_data` AS d
+ON
+       d.network_id=t.network_id
 WHERE
-       `network_id`=%s AND
-       `network_type_id`=%s
+       t.`network_id`=%s AND
+       t.`network_type_id`=%s
 LIMIT 1',
                        array(
                                bigintval(getRequestElement('network_id')),
@@ -142,7 +146,7 @@ LIMIT 1',
                        return;
                } else {
                        // No entry found
-                       displayMessage('{%message,ADMIN_ADD_CONFIG_NETWORK_HANDLER_TYPE_404', bigintval(getRequestElement('network_id')) . '/' . bigintval(getRequestElement('network_type_id')));
+                       displayMessage('{%message,ADMIN_ADD_CONFIG_NETWORK_HANDLER_TYPE_404=' . bigintval(getRequestElement('network_id')) . '/' . bigintval(getRequestElement('network_type_id')) . '%}');
                } // END - if
 
                // Free result
index 8c49e180d4ba5d67c54279c777ee780c59c659aa..4f48971f94dbda7e71f580bc701732a54a6268fb 100644 (file)
@@ -78,6 +78,7 @@ function isGetRequestElementSet ($element, $subElement = '') {
 
 // Removes an element from $_GET
 function unsetGetRequestElement ($element) {
+       unset($GLOBALS['cache_request']['get'][$element]);
        unset($GLOBALS['raw_request']['get'][$element]);
 }
 
@@ -163,6 +164,7 @@ function isPostRequestElementSet ($element, $subElement = NULL) {
 // Removes an element from $_POST
 function unsetPostRequestElement ($element) {
        unset($GLOBALS['raw_request']['post'][$element]);
+       unset($GLOBALS['cache_request']['post'][$element]);
 }
 
 // Getter for whole $_POST array
index 2d491931727c4f30622dce3f80e141a7106b9921..0cb2bb926c06c56a76320badd20731c37937c6a2 100644 (file)
@@ -9,6 +9,10 @@
                        (<a href="{%network,getNetworkDataById,network_reflink=%network_id%%}" target="_blank" title="{%network,getNetworkDataById,network_title=%network_id%%}">{%network,getNetworkDataById,network_title=%network_id%%}</a>)
                </div>
        </div>
+       <div class="bottom" style="padding-top:3px;padding-bottom:3px">
+               {--ADMIN_CONFIG_NETWORK_HANDLER_SET_ALL--}
+               {%template,YesNoSelectionBox=set_all%}
+       </div>
        <div class="bottom" style="padding-top:3px;padding-bottom:3px">
                {--ADMIN_CONFIG_NETWORK_HANDLER_TYPE_MAX_RELOAD_TIME--} ({--TIME_UNIT--})<br />
                $content[network_max_reload_time] ({%pipe,translateTimeUnit=$content[network_type_reload_time_unit]%})
@@ -23,7 +27,7 @@
        </div>
        <div class="bottom" style="padding-top:3px;padding-bottom:3px">
                {--ADMIN_CONFIG_NETWORK_HANDLER_TYPE_MIN_PAYMENT--}<br />
-               <input type="text" class="form_normal" name="network_min_payment" size="5" maxlength="20" value="$content[network_min_payment]" />
+               <input type="text" class="form_normal" name="network_min_payment" size="7" maxlength="20" value="$content[network_min_payment]" />
        </div>
        <div class="bottom" style="padding-top:3px;padding-bottom:3px">
                {--ADMIN_CONFIG_NETWORK_HANDLER_TYPE_ALLOW_EROTIC--}<br />
index 4994768c18c798a300a1839071025a929b3c47b6..3987a5bcf032c679142a11a1c57badc2b6426e65 100644 (file)
@@ -9,6 +9,10 @@
                        (<a href="{%network,getNetworkDataById,network_reflink=%network_id%%}" target="_blank" title="{%network,getNetworkDataById,network_title=%network_id%%}">{%network,getNetworkDataById,network_title=%network_id%%}</a>)
                </div>
        </div>
+       <div class="bottom" style="padding-top:3px;padding-bottom:3px">
+               {--ADMIN_CONFIG_NETWORK_HANDLER_SET_ALL--}
+               {%template,NoYesSelectionBox=set_all%}
+       </div>
        <div class="bottom" style="padding-top:3px;padding-bottom:3px">
                {--ADMIN_CONFIG_NETWORK_HANDLER_TYPE_MAX_RELOAD_TIME--} ({--TIME_UNIT--})<br />
                $content[network_max_reload_time] ({%pipe,translateTimeUnit=$content[network_type_reload_time_unit]%})
@@ -23,7 +27,7 @@
        </div>
        <div class="bottom" style="padding-top:3px;padding-bottom:3px">
                {--ADMIN_CONFIG_NETWORK_HANDLER_TYPE_MIN_PAYMENT--}<br />
-               <input type="text" class="form_normal" name="network_min_payment" size="5" maxlength="20" value="$content[network_min_payment]" />
+               <input type="text" class="form_normal" name="network_min_payment" size="7" maxlength="20" value="$content[network_min_payment]" />
        </div>
        <div class="bottom" style="padding-top:3px;padding-bottom:3px">
                {--ADMIN_CONFIG_NETWORK_HANDLER_TYPE_ALLOW_EROTIC--}<br />