]> git.mxchange.org Git - mailer.git/blobdiff - inc/libs/network_functions.php
Extension ext-network continued:
[mailer.git] / inc / libs / network_functions.php
index b0c9552f8672a227ca20e74e19dc681ed09a9eb5..90ad1a0efd843cd81169cf92f7402c6de65bd588 100644 (file)
@@ -106,6 +106,9 @@ function doAdminNetworkProcessForm () {
                debug_report_bug(__FUNCTION__, __LINE__, 'Invalid do ' . getRequestElement('do') . ', function ' . $functionName .' does not exist.', false);
        } // END - if
 
+       // Init global arrays
+       $GLOBALS['network_types_disabled'] = array();
+
        // Call-back the method handling our request
        call_user_func($functionName);
 }
@@ -202,7 +205,7 @@ function getNetworkDataById ($networkId, $column = '') {
                $GLOBALS['network_data'][$networkId] = array();
 
                // Query for the network data
-               $result = SQL_QUERY_ESC('SELECT
+               $result = SQL_QUERY_ESC("SELECT
        `network_id`,
        `network_short_name`,
        `network_title`,
@@ -217,7 +220,7 @@ FROM
        `{?_MYSQL_PREFIX?}_network_data`
 WHERE
        `network_id`=%s
-LIMIT 1',
+LIMIT 1",
                        array(bigintval($networkId)), __FUNCTION__, __LINE__);
 
                // Do we have an entry?
@@ -257,7 +260,7 @@ function getNetworkDataByTypeId ($networkId, $column = '') {
                $GLOBALS['network_data'][$networkId] = array();
 
                // Query for the network data
-               $result = SQL_QUERY_ESC('SELECT
+               $result = SQL_QUERY_ESC("SELECT
        d.`network_id`,
        d.`network_short_name`,
        d.`network_title`,
@@ -280,7 +283,7 @@ ON
        d.`network_id`=t.`network_id`
 WHERE
        t.`network_type_id`=%s
-LIMIT 1',
+LIMIT 1",
                        array(bigintval($networkId)), __FUNCTION__, __LINE__);
 
                // Do we have an entry?
@@ -438,14 +441,16 @@ function generateAdminNetworkList () {
        $content = '';
 
        // Query for all networks
-       $result = SQL_QUERY('SELECT
+       $result = SQL_QUERY("SELECT
        `network_id`,
        `network_short_name`,
        `network_title`
 FROM
        `{?_MYSQL_PREFIX?}_network_data`
+WHERE
+       `network_active`='Y'
 ORDER BY
-       `network_short_name` ASC', __FUNCTION__, __LINE__);
+       `network_short_name` ASC", __FUNCTION__, __LINE__);
 
        // Do we have entries?
        if (!SQL_HASZERONUMS($result)) {
@@ -524,17 +529,21 @@ function generateAdminDistinctNetworkTypeList () {
        $content = '';
 
        // Query all types of this network
-       $result = SQL_QUERY('SELECT
-       t.`network_type_id`, t.`network_type_handler`, d.`network_title`
+       $result = SQL_QUERY("SELECT
+       t.`network_type_id`,
+       t.`network_type_handler`,
+       d.`network_title`
 FROM
        `{?_MYSQL_PREFIX?}_network_types` AS t
 LEFT JOIN
        `{?_MYSQL_PREFIX?}_network_data` AS d
 ON
        t.`network_id`=d.`network_id`
+WHERE
+       d.`network_active`='Y'
 ORDER BY
        d.`network_short_name` ASC,
-       t.`network_type_handler` ASC', __FUNCTION__, __LINE__);
+       t.`network_type_handler` ASC", __FUNCTION__, __LINE__);
 
        // Do we have entries?
        if (!SQL_HASZERONUMS($result)) {
@@ -593,11 +602,11 @@ function generateNetworkTypeOptions ($networkId) {
 }
 
 // Generates an options list of all available (hard-coded) handlers
-function generateNetworkTypesAvailableOptions () {
+function generateNetworkTypesAvailableOptions ($defaultType = NULL) {
        // Is it cached?
-       if (!isset($GLOBALS[__FUNCTION__])) {
+       if (!isset($GLOBALS[__FUNCTION__][$defaultType])) {
                // Generate list
-               $GLOBALS[__FUNCTION__] = generateOptionList(
+               $GLOBALS[__FUNCTION__][$defaultType] = generateOptionList(
                        '/ARRAY/',
                        array(
                                'banner',
@@ -631,7 +640,7 @@ function generateNetworkTypesAvailableOptions () {
                                'traffic'
                        ),
                        array(),
-                       '',
+                       $defaultType,
                        '', '',
                        $GLOBALS['network_types_disabled'],
                        'translateNetworkTypeHandler'
@@ -639,7 +648,7 @@ function generateNetworkTypesAvailableOptions () {
        } // END - if
 
        // Return content
-       return $GLOBALS[__FUNCTION__];
+       return $GLOBALS[__FUNCTION__][$defaultType];
 }
 
 // Generates an options list (somewhat getter) ofr request keys
@@ -736,26 +745,62 @@ function generateNetworkApiActiveOptions ($default = '') {
 
 // Translates 'translate_name' for e.g. templates
 function translateNetworkTranslationName ($name) {
-       // Get the message id
-       return '{--ADMIN_NETWORK_TRANSLATE_' . strtoupper($name) . '_NAME--}';
+       // Generate id
+       $messageId = 'ADMIN_NETWORK_TRANSLATE_' . strtoupper($name) . '_NAME';
+
+       // Is the message id there?
+       if (!isMessageIdValid($messageId)) {
+               // Not valid type
+               debug_report_bug(__FUNCTION__, __LINE__, 'type=' . $type . ' is invalid.');
+       } // END - if
+
+       // Return message id
+       return '{--' . $messageId . '--}';
 }
 
 // Translates the network type handler (e.g. banner, paidmail) for templates
 function translateNetworkTypeHandler ($type) {
-       // Get the message id
-       return '{--ADMIN_NETWORK_TYPE_HANDLER_' . strtoupper($type) . '--}';
+       // Generate id
+       $messageId = 'ADMIN_NETWORK_TYPE_HANDLER_' . strtoupper($type);
+
+       // Is the message id there?
+       if (!isMessageIdValid($messageId)) {
+               // Not valid type
+               debug_report_bug(__FUNCTION__, __LINE__, 'type=' . $type . ' is invalid.');
+       } // END - if
+
+       // Return message id
+       return '{--' . $messageId . '--}';
 }
 
 // Translates request type
 function translateNetworkRequestType ($type) {
-       // Get the message id
-       return '{--ADMIN_NETWORK_REQUEST_TYPE_' . strtoupper($type) . '--}';
+       // Generate id
+       $messageId = 'ADMIN_NETWORK_REQUEST_TYPE_' . strtoupper($type) . '';
+
+       // Is the message id there?
+       if (!isMessageIdValid($messageId)) {
+               // Not valid type
+               debug_report_bug(__FUNCTION__, __LINE__, 'type=' . $type . ' is invalid.');
+       } // END - if
+
+       // Return message id
+       return '{--' . $messageId . '--}';
 }
 
 // Translates request parameter
 function translateNetworkRequestParamKey ($param) {
-       // Get the message id
-       return '{--ADMIN_NETWORK_REQUEST_PARAMETER_' . strtoupper($param) . '--}';
+       // Generate id
+       $messageId = 'ADMIN_NETWORK_REQUEST_PARAMETER_' . strtoupper($param) . '';
+
+       // Is the message id there?
+       if (!isMessageIdValid($messageId)) {
+               // Not valid param
+               debug_report_bug(__FUNCTION__, __LINE__, 'param=' . $param . ' is invalid.');
+       } // END - if
+
+       // Return message id
+       return '{--' . $messageId . '--}';
 }
 
 // Translates API index
@@ -1658,7 +1703,8 @@ function doAdminNetworkExportNetworkTypes () {
        `network_type_handler`,
        `network_type_api_url`,
        `network_type_click_url`,
-       `network_type_banner_url`
+       `network_type_banner_url`,
+       `network_type_reload_time_unit`
 FROM
        `{?_MYSQL_PREFIX?}_network_types`
 WHERE
@@ -1685,11 +1731,14 @@ ORDER BY
                // Is the column NULL?
                if (is_null($content['network_type_banner_url'])) {
                        // Column is NULL
-                       $SQL .= "NULL),\n";
+                       $SQL .= 'NULL';
                } else {
                        // Column is set
-                       $SQL .= $content['network_type_banner_url'] . "'),\n";
+                       $SQL .= "'" . $content['network_type_banner_url'] . "'";
                }
+
+               // Add more
+               $SQL .= $content['network_type_reload_time_unit'] . "')\n";
        } // END - while
 
        // Remove last commata and close braces
@@ -1738,7 +1787,7 @@ ORDER BY
                        $content['network_id'] . ', ' .
                        $content['network_type_id'] . ", '" .
                        $content['network_request_param_key'] . "', '" .
-                       $content['network_request_param_value'] . "', '";
+                       $content['network_request_param_value'] . "', ";
                
                // Is the column NULL?
                if (is_null($content['network_request_param_default'])) {
@@ -1746,7 +1795,7 @@ ORDER BY
                        $SQL .= "NULL),\n";
                } else {
                        // Column is set
-                       $SQL .= $content['network_request_param_default'] . "'),\n";
+                       $SQL .= "'" . $content['network_request_param_default'] . "'),\n";
                }
        } // END - while