]> git.mxchange.org Git - mailer.git/blobdiff - inc/modules/admin/what-config_network_types.php
Project continued:
[mailer.git] / inc / modules / admin / what-config_network_types.php
index 15d85b9f3588a58abf834e9fa370b30617d9a757..671e5599a91222c30bbea532d0fb331173c4316b 100644 (file)
@@ -16,7 +16,7 @@
  * $Author::                                                          $ *
  * -------------------------------------------------------------------- *
  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
- * Copyright (c) 2009 - 2011 by Mailer Developer Team                   *
+ * Copyright (c) 2009 - 2012 by Mailer Developer Team                   *
  * For more information visit: http://mxchange.org                      *
  *                                                                      *
  * This program is free software; you can redistribute it and/or modify *
@@ -44,29 +44,31 @@ if ((!defined('__SECURITY')) || (!isAdmin())) {
 addYouAreHereLink('admin', __FILE__);
 
 // By default we should display list/add new forms
-$GLOBALS['network_display'] = true;
+$GLOBALS['network_display'] = TRUE;
 
 // Handle form here
 doNetworkHandleForm();
 
 // Display forms?
-if ($GLOBALS['network_display'] === false) {
+if ($GLOBALS['network_display'] === FALSE) {
        // Abort here
        return;
 } // END - if
 
-// Do we have a network selected?
+// Is there a network selected?
 if (isGetRequestElementSet('network_id')) {
+       // Set current network id
+       setCurrentNetworkId(getRequestElement('network_id'));
+
        // Is a network type handler selected?
        if (isGetRequestElementSet('network_type_id')) {
                // Load data for given network
                $result = SQL_QUERY_ESC('SELECT
-       `network_id`,
-       `network_type_id`,
-       `network_type_handle`,
-       `network_type_api_url`,
-       `network_type_click_url`,
-       `network_type_banner_url`,
+       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`,
@@ -74,26 +76,37 @@ 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')),
                                bigintval(getRequestElement('network_type_id'))
                        ), __FUNCTION__, __LINE__);
 
-               // Do we have a record?
+               // Is there a record?
                if (SQL_NUMROWS($result) == 1) {
                        // Load it
                        $content = SQL_FETCHARRAY($result);
 
+                       // Is the network active?
+                       if ($content['network_active'] == 'N') {
+                               // Not active
+                               displayMessage('{--ADMIN_NETWORK_NOT_ACTIVE--}');
+                               return;
+                       } // END - if
+
                        // Check for network type configuration
                        $result_config = SQL_QUERY_ESC('SELECT
        `network_data_id`,
        `network_max_reload_time`,
-       `network_min_waiting_time`
+       `network_min_waiting_time`,
        `network_min_remain_clicks`,
        `network_min_payment`,
        `network_allow_erotic`
@@ -108,23 +121,32 @@ LIMIT 1',
                                        bigintval($content['network_type_id'])
                                ), __FUNCTION__, __LINE__);
 
+                       // Use template for adding
+                       $templateName = 'admin_add_config_network_type_form';
+
                        // Do we also have configuration?
                        if (SQL_NUMROWS($result_config) == 1) {
                                // Load as well and merge it
                                $content = merge_array($content, SQL_FETCHARRAY($result_config));
+
+                               // Use template for editing
+                               $templateName = 'admin_edit_config_network_type_form';
                        } // END - if
 
                        // Free result
                        SQL_FREERESULT($result_config);
 
+                       // "Translate" some values
+                       $content['network_max_reload_time']  = createTimeSelections($content['network_max_reload_time'], 'network_max_reload_time', 'WDhms');
+
                        // Load template
-                       loadTemplate('admin_add_config_network_type_form', false, $content);
+                       loadTemplate($templateName, FALSE, $content);
 
                        // Abort here
                        return;
                } else {
                        // No entry found
-                       displayMessage('{%message,ADMIN_ADD_CONFIG_NETWORK_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
@@ -135,21 +157,19 @@ LIMIT 1',
        $result = SQL_QUERY_ESC('SELECT
        `network_id`,
        `network_type_id`,
-       `network_type_handle`,
-       `network_type_api_url`,
-       `network_type_click_url`,
-       `network_type_banner_url`
+       `network_type_handler`,
+       `network_type_reload_time_unit`
 FROM
        `{?_MYSQL_PREFIX?}_network_types`
 WHERE
        `network_id`=%s
 ORDER BY
-       `network_type_handle` ASC',
+       `network_type_handler` ASC',
                array(
                        bigintval(getRequestElement('network_id'))
                ), __FUNCTION__, __LINE__);
 
-       // Do we have entries left?
+       // Are there entries left?
        if (!SQL_HASZERONUMS($result)) {
                // Init row output
                $OUT = '';
@@ -175,30 +195,36 @@ LIMIT 1',
                                        bigintval($content['network_type_id'])
                                ), __FUNCTION__, __LINE__);
 
-                       // Do we have an entry?
+                       // Is there an entry?
                        if (SQL_NUMROWS($result_config) == 1) {
                                // Load this data as well
-                               $contentConfig = SQL_FETCHARRAY($result_config);
+                               $content = merge_array($content, SQL_FETCHARRAY($result_config));
 
                                // Add it with extra template
-                               $content['network_types_config_content'] = loadTemplate('admin_show_config_network_type', true, $contentConfig);
+                               $content['network_type_config_content'] = loadTemplate('admin_show_config_network_type', TRUE, $content);
                        } else {
                                // No configuration found, so display form
-                               $content['network_types_config_content'] = loadTemplate('admin_add_config_network_type', true, $content);
+                               $content['network_type_config_content'] = loadTemplate('admin_add_config_network_type', TRUE, $content);
                        }
 
                        // Free result
                        SQL_FREERESULT($result_config);
 
                        // Load row template
-                       $OUT .= loadTemplate('admin_config_network_types_row', true, $content);
+                       $OUT .= loadTemplate('admin_config_network_types_row', TRUE, $content);
                } // END - while
 
+               // Prepare array for main template
+               $content = array(
+                       'network_id' => bigintval(getRequestElement('network_id')),
+                       'rows'       => $OUT
+               );
+
                // Load main template
-               loadTemplate('admin_config_network_types', false, $OUT);
+               loadTemplate('admin_config_network_types', FALSE, $content);
        } else {
                // No entries found
-               displayMessage('{%message,ADMIN_CONFIG_NETWORK_TYPES_404=' . bigintval(getRequestElement('network_id')) . '%}');
+               displayMessage('{%message,ADMIN_CONFIG_NETWORK_HANDLER_TYPES_404=' . bigintval(getRequestElement('network_id')) . '%}');
        }
 
        // Free result