<?php
/*
  MailBeez Automatic Trigger Email Campaigns
  http://www.mailbeez.com

  Copyright (c) 2010, 2011 MailBeez

  inspired and in parts based on
  Copyright (c) 2003 osCommerce

  Released under the GNU General Public License

  v2.7
 */

///////////////////////////////////////////////////////////////////////////////
///																			 //
///                 MailBeez Core file - do not edit                         //
///                                                                          //
///////////////////////////////////////////////////////////////////////////////

echo $MAILBEEZ_TABS;
echo $MAILBEEZ_TABS_MODE;
?>
<link rel="stylesheet" type="text/css" media="print, projection, screen"
      href="<?php echo mh_cfg('MH_CATALOG_SERVER') . mh_cfg('MH_DIR_WS_CATALOG') . mh_cfg('MH_ROOT_PATH'); ?>common/admin_application_plugins/main_mailbeez.css?ver=<?php echo mh_cfg('MAILBEEZ_VERSION'); ?>">
<?php
if (isset($_SESSION['mailbeez_new'][$tab])) {
    ?>
    <div class="mb_inline_msg msg">
        <div class="mb_inline_msg img">
            <img src="<?php echo mh_cfg('MH_CATALOG_SERVER') . mh_cfg('MH_DIR_WS_CATALOG') . mh_cfg('MH_ROOT_PATH'); ?>common/images/mb_icon.png"
                 width="32"
                 height="32">
        </div>
        <div class="mb_inline_msg text">
            <strong><?php echo mh_lng('MAILBEEZ_VERSION_CHECK_MSG_INTRO'); ?></strong>
            <br/>
            <?php echo $_SESSION['mailbeez_upd_msg']; ?>
        </div>
    </div>

    <div class="mb_inline_msg new_modules">
        <table border="0" cellpadding="0" cellspacing="0" width="100%">
            <td class="mb_inline_msg_td">
                <?php echo sprintf(mh_lng('MH_VERSIONCHECK_INFO_NEW'), $_SESSION['mailbeez_new_cnt'][$tab]); ?><br/>

                <?php

                $toggle_premium = true;
                foreach ($_SESSION['mailbeez_new'][$tab] as $key => $module_info_array) {
                    if ($toggle_premium && !$module_info_array['price']) {
                        echo '<br style="clear: left"><hr size="1" noshade style="color: #70b0e0">';
                        $toggle_premium = false;
                    }
                    ?>
                    <div class="mb_inline_msg_inner item">
                        <div
                                class="mb_inline_msg_inner item_content <?php echo ($module_info_array['price']) ? 'premium'
                                    : '' ?> <?php echo ($module_info_array['is_promo']) ? 'promo' : '' ?>">
                            <div
                                    class="mb_inline_msg_inner item_img <?php echo ($module_info_array['price']) ? 'premium'
                                        : '' ?>">
                                <?php echo mh_image($module_info_array['image'], '', '32', '32', 'align="absmiddle"'); ?>
                            </div>
                            <div
                                    class="mb_inline_msg_inner item_text <?php echo ($module_info_array['price']) ? 'premium'
                                        : '' ?>">
                                <a href="<?php echo mh_language_documentation_url('https://www.mailbeez.com/documentation/'); ?><?php echo $tab . '/' . $key . '/' . mh_cfg('MH_LINKID_1'); ?>"
                                   target="_blank">
                                    <h1><?php echo $module_info_array['title'] ?></h1>
                                    <?php echo ($module_info_array['price']) ? $module_info_array['teaser'] : ''; ?>
                                    <div style="font-weight: bold;"><?php echo ($module_info_array['price'])
                                            ? 'Download: ' . $module_info_array['price'] : ''; ?></div>
                                </a>
                            </div>
                        </div>
                    </div>
                <?php } ?>
            </td>
        </table>
    </div>

    <?php

}
?>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
    <tr>
        <td valign="top">
            <table border="0" width="100%" cellspacing="0" cellpadding="2">
                <?php if (mh_cfg('MAILBEEZ_MAILHIVE_STATUS')) { ?>
                    <tr class="dataTableHeadingRow">
                        <td class="dataTableHeadingContent"><?php echo mh_lng('MH_TABLE_HEADING_MODULES'); ?></td>
                        <td class="dataTableHeadingContent"
                            align="right"><?php echo mh_lng('MH_TABLE_HEADING_SORT_ORDER'); ?></td>
                        <td class="dataTableHeadingContent"><?php echo '&nbsp;'; ?></td>
                        <td class="dataTableHeadingContent" align="right"><?php echo (MH_PLATFORM == 'gambio') ? ''
                                : mh_lng('MH_TABLE_HEADING_ACTION'); ?>&nbsp;
                        </td>
                    </tr>
                <?php } ?>
                <?php

                $request_profiler->restart('---main_mailbeez_before_read_module_dir---');

                $directory_array = mh_read_module_directory(mh_cfg('MH_MODULE_DIRECTORY_CURRENT'));
                sort($directory_array);
                $installed_modules = array();
                $installed_modules_versions = array();
                $all_modules = array();
                for ($i = 0, $n = sizeof($directory_array); $i < $n; $i++) {
                    $offset = 0;
                    $file = $directory_array[$i];
                    $class = substr($file, 0, strrpos($file, '.'));

                    $request_profiler->restart('main_mailbeez_before_load: ' . $class);

                    mh_load_modules_language_files(mh_cfg('MH_MODULE_DIRECTORY_CURRENT'), $class, mh_cfg('MH_FILE_EXTENSION'));

                    // include class
                    if (file_exists(mh_cfg('MH_MODULE_DIRECTORY_CURRENT') . $file)) {
                        include_once(mh_cfg('MH_MODULE_DIRECTORY_CURRENT') . $file);
                    }
                    if (mh_class_exists($class)) {
                        if (!isset($GLOBALS[$class]) || !is_object($GLOBALS[$class])) {
                            $GLOBALS[$class] = new $class; // new object
                            if (!mh_check_admin_rights($class)) {
                                unset($GLOBALS[$class]);
                                continue;
                            }
                        }
                        $module = $GLOBALS[$class];

                        $directory_submodules_array = array();
                        $all_submodules = array();

                        if ($module->check() < 1) {
                            // not installed, push to end
                            $offset = 9999999999;
                        }
                        if ($module->sort_order > 0) {
                            $all_modules_sortorder = $offset + ($module->sort_order * 100000);
                            $all_modules_sortorder += (ord($class)) * 100; // add offset by character
                        } else {
                            $all_modules_sortorder = $offset;
                        }

                        if ($module->check() > 0 && !(isset($module->stealth) ? $module->stealth : false)) {
                            // load submodules

                            // show submodules when main module or submodule selected
//                            $show_submodules = preg_match('#' . $module->code . '#', $_GET['module']);

                            //if ($module->has_submodules == true && $show_submodules) {
                            if ($module->has_submodules == true) {
                                list($all_submodules, $installed_modules) = mh_load_submodules(mh_cfg('MH_MODULE_DIRECTORY_CURRENT'), $class, $all_modules_sortorder, $installed_modules);
                            } elseif ($module->display_as_submodule_of != '') {
                                $all_modules_sortorder += 900;
                            } else {
                                $all_modules_sortorder += 1000;
                            }
                            $installed_modules[$all_modules_sortorder . $class] = $file; // make key unique but sortable as integer
                        }
                        $all_modules[$all_modules_sortorder . $class] = $file;

                        if (is_array($all_submodules)) {
                            $all_modules = array_merge($all_submodules, $all_modules); // insert submodules
                        }

                        if (!(isset($module->stealth) ? $module->stealth : false)) {
                            $installed_modules_versions[$class] = $module->code . '|' . $module->version . '|' . $module->check() . '|' . $module->enabled;
                        }
                    } // if exists
                } // for
                // sort all_modules

                uksort($all_modules, "sortbyintvalue");
                uksort($installed_modules, "sortbyintvalue");
                $request_profiler->restart('---main_mailbeez_before_module_list---');
                $section_not_installed = false;

                foreach ($all_modules as $sort_order_key => $file) {

                    $class = substr($file, 0, strrpos($file, '.'));
                    $request_profiler->restart('main_mailbeez_before_display: ' . $class);

                    if (is_object($GLOBALS[$class])) {
                        $module = $GLOBALS[$class];
                        if (!$module->checkModulePermission()) {
                            continue;
                        }

                        $module->versioncheck_info = null;
                        if (isset($_SESSION['mailbeez_upd'])) {
                            $module->versioncheck_info = (($_SESSION['mailbeez_upd'][$module->code] > 0)
                                ? '<span class="upd_cnt list"><a style="color: #fff" href="' . mh_language_documentation_url($module->documentation_root) . $module->documentation_key . '?update=true' . mh_cfg('MH_LINKID_2') . '" target="_blank">' . mh_lng('MH_VERSIONCHECK_INFO_NEWVERSION') . ' ' . $_SESSION['mailbeez_upd'][$module->code] . '</a></span>'
                                : null); // experimental
                        }

                        if (mh_get('module')) {
                            $module->show_submodules = preg_match('#' . $module->module . '#', mh_get('module'));
                        }

                        if ($module->hidden != false) {
                            continue;
                        }
                        if ($module->is_submodule_of != false && !$module->show_submodules) {
                            continue;
                        }
                        // for the first module make sure $_GET['module'] is set
                        if (!mh_get('module')) {
                            $_GET['module'] = $module->get_module_id();
                        }

                        if ((!mh_get('module') || (mh_get('module') == $class)) && !isset($mInfo)) {
                            $module_info = array('code' => $module->get_module_id(),
                                'module' => $module->module,
                                'title' => $module->title,
                                'version' => $module->version,
                                'required_mb_version' => $module->required_mb_version,
                                'removable' => isset($module->removable) ? $module->removable : 'true',
                                'common_admin_action_plugins' => $module->common_admin_action_plugins,
                                'admin_action_plugins_path' => $module->admin_action_plugins_path,
                                'admin_action_plugins' => $module->admin_action_plugins,
                                'description' => $module->description,
                                'description_image_src' => $module->description_image,
                                'documentation_root' => $module->documentation_root,
                                'documentation_key' => $module->documentation_key,
                                'icon' => (isset($module->icon) ? $module->icon : null),
                                'has_submodules' => $module->has_submodules,
                                'cert_check' => $module->cert_check,
                                'subscription' => $module->subscription,
                                'enabled' => $module->enabled,
                                'status_key' => $module->status_key,
                                'status' => $module->check(),
                                'is_editable' => $module->is_editable,
                                'is_configurable' => $module->is_configurable,
                                'signature' => (isset($module->signature) ? $module->signature : null));
                            $module_keys = $module->keys();
                            $keys_extra = array();
                            if (is_array($module_keys)) {
                                for ($j = 0, $k = sizeof($module_keys); $j < $k; $j++) {
                                    $configItem = mh_read_config_item($module_keys[$j]);

                                    $keys_extra[$module_keys[$j]]['title'] = mh_cfg(strtoupper($module_keys[$j]) . '_TITLE', isset($configItem['configuration_title']) ? $configItem['configuration_title'] : '');
                                    $keys_extra[$module_keys[$j]]['description'] = mh_cfg(strtoupper($module_keys[$j]) . '_DESC', isset($configItem['configuration_description']) ? $configItem['configuration_description'] : '');
                                    $keys_extra[$module_keys[$j]]['value'] = $configItem['value'];
                                    $keys_extra[$module_keys[$j]]['use_function'] = $configItem['use_function'];
                                    $keys_extra[$module_keys[$j]]['set_function'] = $configItem['set_function'];
                                }

                            }

                            $module_info['keys'] = $keys_extra;

                            $module_info['keysMeta'] = $module->getKeyMetaData();

                            // add filter group field
                            if ($module->allow_group_filter_check && !(preg_match('/^config/', get_class($module)) || preg_match('/^service/', get_class($module)))) {

                                if (in_array(get_parent_class($module), array('mailbeez', 'mailbeez_pro', 'mb_newsletter_base'))) {
                                    if ($module->modeSaas()) {
                                        $module_info['keysMeta']['FILTER_CHECK_GROUP_LINK'] = array(
                                            'saas_user' => true,
                                            'saas_superuser' => true,
                                            'saas_admin' => true,
                                            'core_user' => true,
                                            'core_admin' => true,
                                        );
                                    }

                                    if (!in_array('FILTER_CHECK_GROUP_LINK', $module_info['keys'])) {
                                        $after_key = $module_info['status_key'];
                                        $moduleKeysInserted = mh_array_insert_after($after_key, $module_info['keys'], 'FILTER_CHECK_GROUP_LINK', 1);
                                        $module_info['keys'] = ($moduleKeysInserted) ? $moduleKeysInserted : $module_info['keys'];
                                    }
                                }
                            }
                            $mInfo = new mh_objectInfo($module_info);
                        }


                        // insert line when not installed starts
                        if ($module->check() < 1 && !$section_not_installed) {
                            $section_not_installed = true;
                            echo '<tr class="dataTableHeadingRow"><td colspan="4" class="dataTableHeadingContent">' . mh_lng('MH_NOT_INSTALLED_MODULES') . '</td></tr>';
                        }

                        if (isset($mInfo) && is_object($mInfo) && ($class == $mInfo->code)) {
                            if ($module->check() > 0 && $mInfo->is_configurable == true) {
                                echo '              <tr id="module_' . $class . '_active" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . mh_href_link(FILENAME_MAILBEEZ, 'module=' . $class . '&action=edit') . '\'">' . "\n";
                            } else {
                                echo '              <tr id="module_' . $class . '_selected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)">' . "\n";
                            }
                        } else {
                            if (($module->is_submodule_of != false) && ($module->check() < 1)) {
                                continue;
                            } // don't show submodules when main module is not installed
                            echo '              <tr id="module_' . $class . '"  class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . mh_href_link(FILENAME_MAILBEEZ, 'module=' . $class) . '\'">' . "\n";
                        }
                        ?>
                        <td class="dataTableContent">

                            <?php
                            if ($module->check() < 1) {
                                echo mh_image(mh_cfg('MH_ADMIN_DIR_WS_IMAGES') . 'install_bee.png', '', '', '', 'align="absmiddle" ');
                            }
                            ?>
                            <?php
                            if ($module->check() > 0 && ($module->is_submodule_of != false || $module->display_as_submodule_of != false)) {
                                echo ($module->icon != '') ? '<span style="display: block; float: left; width: 17px">&nbsp;</span>' : ' - ';
                            } else {
                                echo '';
                            };
                            ?>
                            <?php
                            if ($module->has_submodules && $module->show_submodules && $module->check() > 0) {
                                echo mh_image(mh_cfg('MH_ADMIN_DIR_WS_IMAGES') . 'arrow_open.png', '', '', '', 'align="absmiddle" style="margin-left: 4px;"');
                            } elseif ($module->has_submodules && $module->check() > 0) {
                                echo mh_image(mh_cfg('MH_ADMIN_DIR_WS_IMAGES') . 'arrow_closed.png', '', '', '', 'align="absmiddle" style="margin-left: 4px;"');
                            } elseif (isset($module->cert_check) && !$module->cert_check) {
                                //echo '<span style="display: block; float: left; width: 17px">&nbsp;</span>';
                                echo mh_image(mh_cfg('MH_ADMIN_DIR_WS_IMAGES') . 'lock.png', '', '13', '13', 'align="absmiddle" style="margin-left: 0px;"');
                            } elseif ($module->check() > 0) {
                                echo '<span style="display: block; float: left; width: 17px">&nbsp;</span>';
                            }
                            ?>

                            <?php
                            if ($module->icon != '') {
                                echo mh_image(mh_cfg('MH_ADMIN_DIR_WS_PRE') . mh_cfg('MH_MODULE_DIRECTORY_CURRENT_WS') . $module->module . '/' . $module->icon, '', '13', '13', 'align="absmiddle"');
                            }
                            ?>
                            <?php echo $module->title; ?>

                            <?php
                            echo $module->hiddenHint($module->getModulePermission());
                            ?>
                            <?php echo $module->versioncheck_info; // experimental
                            ?>

                        </td>
                        <td class="dataTableContent" align="right">
                            &nbsp;<?php if (is_numeric($module->sort_order) && (int)$module->sort_order > 0 && ($module->is_submodule_of == false && $module->display_as_submodule_of == false))
                                echo $module->sort_order; ?></td>
                        <td class="dataTableContent" align="right">&nbsp;<?php
                            if ($module->check() < 1 || ($module->is_submodule_of != false && !$module->show_submodule_status)) {
                                echo '&nbsp;';
                            } else {
                                if ($module->enabled) {
                                    echo (mh_cfg('MAILBEEZ_MAILHIVE_STATUS') == 'False')
                                        ? mh_admin_icon('status_green_light')
                                        : mh_admin_icon('status_green');
                                } else {
                                    echo (mh_cfg('MAILBEEZ_MAILHIVE_STATUS') == 'False')
                                        ? mh_admin_icon('status_red_light')
                                        : mh_admin_icon('status_red');
                                }
                            }
                            ?></td>
                        <td class="dataTableContent" align="right"><?php
                            if (isset($mInfo) && is_object($mInfo) && ($class == $mInfo->code)) {
                                echo mh_admin_icon('arrow_right');
                            } else {
                                echo '<a href="' . mh_href_link(mh_fn('FILENAME_MAILBEEZ'), 'module=' . $class) . '">' . mh_admin_icon('info') . '</a>';
                            }
                            ?>&nbsp;
                        </td>
                        </tr>
                        <?php

                    }
                }

                ?>
                <?php
                if (sizeof($all_modules) == 0) {
                    ?>
                    <tr class="dataTableRow">
                        <td class="dataTableContent" align="center"
                            colspan="4"><?php echo mh_lng('MH_NO_MODULE'); ?></td>
                    </tr>

                    <?php

                }
                ?>

                <?php


                //                if ($tab == 'mailbeez' && mh_cfg('MH_SHOWMORELINK')) {

                if (false) {
                    ?>
                    <tr class="dataTableRow">
                        <td class="dataTableContent">

                            <a href="<?php echo mh_lng('MH_MORELINK'); ?>/<?php echo mh_lng('MH_LINKID_1'); ?>"
                               target="_blank"><?php echo mh_image(mh_cfg('MH_ADMIN_DIR_WS_IMAGES') . 'more_beez.png', '', '', '', 'align="absmiddle"'); ?>
                                &nbsp;<?php echo mh_lng('MH_DOWNLOAD_LINK_LIST'); ?></a>
                        </td>
                        <td class="dataTableContent" align="right">&nbsp;</td>
                        <td class="dataTableContent" align="right">&nbsp;</td>
                        <td class="dataTableContent" align="right">&nbsp;</td>
                    </tr>
                <?php } ?>



                <?php
                // update some settings
                // installed modules
                mh_insert_or_update_config_value($appRequest['MH_MODULE_KEY_CURRENT'], implode(';', $installed_modules));
                mh_insert_or_update_config_value($appRequest['MH_MODULE_VERSION_KEY_CURRENT'], implode(';', $installed_modules_versions));
                ?>
                <tr>
                    <td colspan="3"
                        class="smallText">


                        <?php

                        if (!getenv('SAAS_ENV')) {
                            echo mh_lng('MH_TEXT_MODULE_DIRECTORY') . ' ' . mh_cfg('MH_MODULE_DIRECTORY_CURRENT');
                        }
                        ?>


                        <br/>
                        <br/>
                        <?php
                        if (isset($mInfo) && !is_null($mInfo) && $mInfo->code == 'config_queen' && !getenv('SAAS_ENV')) {
                            ?>
                            <br/>
                            <br/>
                            <?php
                            if (!mh_cfg('MAILBEEZ_CRON_INSTALLED')) {
//                                echo mh_lng('MAILBEEZ_CONFIG_AUTOMATIC_TEXT_DESCRIPTION_LONG');
                            }
                            ?>
                            <hr size="1" noshade>
                            <?php echo mh_cfg('MH_SECURE_URL') ?>:<br/>
                            <div
                                    style="border: 1px dotted #909090; padding: 10px; margin-top: 10px; background-color: #e9e9e9">
                                <?php
                                echo mh_cfg('MAILBEEZ_MAILHIVE_URL') . 'run<br>';
                                echo 'Silent-Mode: ' . mh_cfg('MAILBEEZ_MAILHIVE_URL') . 'run&silent=1';
                                ?>
                            </div>
                        <?php } ?>
                        <br/>
                        <br/>
                        <?php
                        if (!getenv('SAAS_ENV')) {
                            echo $MAILBEEZ_FOOTER;
                        }
                        ?>
                    </td>
                </tr>
            </table>
        </td>
        <?php
        $heading = array();
        $contents = array();

        $module_icon = '';
        if (isset($mInfo) && $mInfo->icon != '') {
            $module_icon = mh_image(mh_cfg('MH_ADMIN_DIR_WS_PRE') . mh_cfg('MH_MODULE_DIRECTORY_CURRENT_WS') . $mInfo->module . '/' . $mInfo->icon, '', '', '', 'align="right"') . ' ';
        }

        switch ($app_action) {
            case 'edit':
                $keys = '';
                if (!is_array($mInfo->keys)) {
                    break;
                }
                reset($mInfo->keys);


                foreach ($mInfo->keys as $key => $value) {
                    if (is_array($module_info['keysMeta']) && !array_key_exists($key, $module_info['keysMeta'])) {
                        continue;
                    }

                    if ($key == mh_cfg('MH_MODULE_KEY') || $key == mh_cfg('MH_CONFIG_MODULE_KEY') || $key == mh_cfg('MH_FILTER_MODULE_KEY') ||
                        $key == mh_cfg('MH_MODULE_VERSION_KEY') || $key == mh_cfg('MH_CONFIG_MODULE_VERSION_KEY') || $key == mh_cfg('MH_FILTER_MODULE_VERSION_KEY')
                    ) {
                        // hide module-key value
                        continue;
                    }

                    if (stristr($key, '_CERT')) {
                        continue;
                    }
                    // hide layout control when visual editor installed
                    if ((mh_cfg('MH_RESPONSIVE') == 'True') && stristr($key, '_LAYOUT') && mh_cfg('MAILBEEZ_CONFIG_EDITOR_STATUS') == 'True') {
                        continue;
                    }

                    if ($module->is_submodule_of == false) {
                        if ($key == 'FILTER_CHECK_GROUP_LINK') {
                            if (mh_cfg('MAILBEEZ_FILTER_GROUP_STATUS') == 'True') {

                                include_once(MH_DIR_FILTER . 'filter_check_group.php');
                                mh_load_modules_language_files(MH_DIR_FILTER, 'filter_check_group');

                                $filter_check_group_obj = new filter_check_group();
                                $filter_check_group_obj->get_configuration();

                                $data = $filter_check_group_obj->module_cfg_set;
                                $hasNoGroup = !isset($data[$mInfo->module]) || !in_array('1', array_values($data[$mInfo->module]));


                                $keys .= '<span class="options-title"><b>' . mh_lng('FILTER_CHECK_GROUP_LINK_TITLE', 'Customer Groups') . '</b></span><br />' . mh_lng('FILTER_CHECK_GROUP_LINK_DESCRIPTION', 'Configure for which Customer Groups this Module should be active') . '<br />';

                                $keys .= $hasNoGroup ? '<b>' . mh_lng('FILTER_CHECK_GROUP_HINT', 'configure at least one group') . '</b>' : '';

                                $keys .= '<br /><br />';
                                $keys .= '<div style="text-align: center;">';
                                $keys .= mb_admin_button(mh_href_link(mh_fn('FILENAME_MAILBEEZ'), 'app=load_app&app_path=filterbeez/filter_check_group/admin_application_plugins/config_groups.php&module=filter_check_group&popup=true&m=' . mh_urlencode($mInfo->code)), mh_lng('BUTTON_CONFIG_GROUPS', 'Configure Customer Groups'), $id = '', 'popup', 'button', '', 'document', 'iframe');
                                $keys .= '</div>';
                            }
                            continue;
                        }
                    }


                    $keys .= '<span class="options-title"><b>' . $value['title'] . '</b></span><br />' . $value['description'] . '<br />';

                    if (is_array($module_info['keysMeta'])) {
                        $permission_hint = $module->hiddenHint($module_info['keysMeta'][$key]);
                        $keys .= '<div>' . $permission_hint . '</div>';
                    }

                    if ($value['set_function'] && !in_array($value['set_function'], ['cfg_email_required_input('])) {
                        //eval('$keys .= ' . $value['set_function'] . "'" . $value['value'] . "', '" . $key . "');");

                        $set_function = $value['set_function'];
                        if (preg_match('/->/', $set_function)) {

                            // e.g. 'mailbeez->mymodule->mySetMethod'
                            $class_method = explode('->', $set_function);
                            if (!is_object(${$class_method[1]})) {
                                include_once(mh_cfg('MH_DIR_FS_CATALOG') . mh_cfg('MH_ROOT_PATH') . '' . $class_method[0] . '/' . $class_method[1] . '.php');
                                ${$class_method[1]} = new $class_method[1]();
                            }
                            $keys .= mh_call_function($class_method[2], array($value['value'], $key), ${$class_method[1]});
                        } else {
                            eval('$keys .= ' . $value['set_function'] . "'" . $value['value'] . "', '" . $key . "');");
                        }
                    } else {
                        $keys .= mh_draw_input_field('configuration[' . $key . ']', $value['value'], 'style="width:85%"');
                    }
                    $keys .= '<br /><br />';
                }
                $keys = substr($keys, 0, strrpos($keys, '<br /><br />'));
                $heading[] = array('text' => '<b>' . $module_icon . $mInfo->title . '</b>');
                $contents = array('form' => mh_draw_form('modules', mh_fn('FILENAME_MAILBEEZ'), 'module=' . mh_get('module') . '&action=save'));
                $contents[] = array('text' => $keys);


                if (mh_cfg('MH_PLATFORM_OSC_23')) {
                    $contents[] = array('align' => 'center', 'text' => '<br />' . tep_draw_button(mh_lng('IMAGE_SAVE'), 'disk', null, 'primary') . tep_draw_button(mh_lng('IMAGE_CANCEL'), 'close', tep_href_link(mh_fn('FILENAME_MAILBEEZ'), 'module=' . mh_get('module'))));
                } else {
                    $contents[] = array('align' => 'center', 'text' => '<br /><div align="center">' . mh_image_submit('button_update.gif', mh_lng('IMAGE_UPDATE')) . ' <a class="button" onClick="this.blur();" href="' . mh_href_link(mh_fn('FILENAME_MAILBEEZ'), 'module=' . mh_get('module')) . '">' . mh_image_button('button_cancel.gif', mh_lng('IMAGE_CANCEL')) . '</a></div>');
                }
                break;
            default:
                if (!isset($mInfo)) {
                    break;
                }
                if (is_null($mInfo)) {
                    $heading[] = array('text' => '<b>' . mh_lng('TEXT_HINT') . '</b>');
                } else {
                    $heading[] = array('text' => '<b>' . $module_icon . $mInfo->title . ' V' . $mInfo->version . '</b>');
                }


                if ($mInfo->status == '1') {
                    $keys = '';
                    $certification_status = false;
                    $certification_check_status = false;
                    reset($mInfo->keys);

                    foreach ($mInfo->keys as $key => $value) {

                        if (is_array($module_info['keysMeta']) && !array_key_exists($key, $module_info['keysMeta'])) {
                            continue;
                        }

                        if ($key == mh_cfg('MH_MODULE_KEY') || $key == mh_cfg('MH_CONFIG_MODULE_KEY') || $key == mh_cfg('MH_FILTER_MODULE_KEY') ||
                            $key == mh_cfg('MH_MODULE_VERSION_KEY') || $key == mh_cfg('MH_CONFIG_MODULE_VERSION_KEY') || $key == mh_cfg('MH_FILTER_MODULE_VERSION_KEY')
                        ) {
                            // hide module-key value
                            continue;
                        }


                        // hide layout control when visual editor installed
                        if (stristr($key, '_LAYOUT') && mh_cfg('MAILBEEZ_CONFIG_EDITOR_STATUS') == 'True') {
                            continue;
                        }

                        if ($module->is_submodule_of == false) {
                            if ($key == 'FILTER_CHECK_GROUP_LINK') {
                                if (mh_cfg('MAILBEEZ_FILTER_GROUP_STATUS') == 'True') {

                                    include_once(MH_DIR_FILTER . 'filter_check_group.php');
                                    mh_load_modules_language_files(MH_DIR_FILTER, 'filter_check_group');

                                    $filter_check_group_obj = new filter_check_group();
                                    $filter_check_group_obj->get_configuration();

                                    $data = $filter_check_group_obj->module_cfg_set;
                                    $hasNoGroup = !isset($data[$mInfo->module]) || !in_array('1', array_values($data[$mInfo->module]));

                                    $keys .= '<b id="' . $key . '">' . mh_lng('FILTER_CHECK_GROUP_LINK_TITLE', 'Customer Groups') . '</b><br />';

                                    $keys .= mb_admin_button(mh_href_link(mh_fn('FILENAME_MAILBEEZ'), 'app=load_app&app_path=filterbeez/filter_check_group/admin_application_plugins/config_groups.php&module=filter_check_group&popup=true&m=' . mh_urlencode($mInfo->code)), mh_lng('BUTTON_CONFIG_GROUPS', 'Configure Customer Groups'), $id = '', 'popup', 'link', '', 'document', 'iframe');

                                    $keys .= $hasNoGroup ?
                                        mailbeez::formatStatusMsg(mh_lng('FILTER_CHECK_GROUP_NO_GROUP_WARNING', 'Please configure at least one group')) :
//                                        mh_lng('FILTER_CHECK_GROUP_NO_GROUP_OK', 'Groups are configured')
                                        '';
                                    $keys .= '<br /><br />';

                                }
                                continue;
                            }
                        }


                        if (stristr($key, '_CERT') && $mInfo->required_mb_version > 2.5) {
                            $cert_module = $mInfo->code;
                            $cert_key = $key;
                            $certification_check_status = $mInfo->cert_check;
                            $subscription_status = $mInfo->subscription;
                            if (file_exists(mh_cfg('MH_DIR_CONFIG') . 'config_queen/admin_action_plugins/certificate_status.php')) {
                                require_once(mh_cfg('MH_DIR_CONFIG') . 'config_queen/admin_action_plugins/certificate_status.php');
                            }
                            if ($certification_check_status !== true) {
                                if (file_exists(mh_cfg('MH_DIR_CONFIG') . 'config_queen/admin_action_plugins/certificate.php')) {
                                    require_once(mh_cfg('MH_DIR_CONFIG') . 'config_queen/admin_action_plugins/certificate.php');
                                }
                                $keys .= '<div class="mb_action_box"></div>' . $certificate_plugin;
                                $certification_status = $certificate_status_plugin;
                            } else {
                                $keys .= '<div class="mb_action_box"></div>' . $certificate_status_plugin;

                            }

                        } elseif (stristr($key, '_CERT')) {
                            $cert_module = $mInfo->code;
                            $cert_key = $key;
                            if (file_exists(mh_cfg('MH_DIR_CONFIG') . 'config_queen/admin_action_plugins/certificate.php')) {
                                require_once(mh_cfg('MH_DIR_CONFIG') . 'config_queen/admin_action_plugins/certificate.php');
                            }
                            $keys .= '<div class="mb_action_box"></div>' . $certificate_plugin;
                        } else {
                            $keys .= '<b id="' . $key . '">' . $value['title'] . '</b><br />';

                            $permission_hint = false;
                            if (is_array($module_info['keysMeta'])) {
                                $permission_hint = $module->hiddenHint($module_info['keysMeta'][$key]);
                            }


                            if ($permission_hint) {
                                $keys .= '<div style="color: red">' . $permission_hint . '</div>';
                            }
                            if ($value['use_function']) {
                                $use_function = $value['use_function'];
                                if (preg_match('/->/', $use_function)) {
                                    // e.g. 'mailbeez->mymodule->myUseMethod'
                                    $class_method = explode('->', $use_function);
                                    if (!is_object(${$class_method[1]})) {
                                        include_once(mh_cfg('MH_DIR_FS_CATALOG') . mh_cfg('MH_ROOT_PATH') . '' . $class_method[0] . '/' . $class_method[1] . '.php');
                                        ${$class_method[1]} = new $class_method[1]();
                                    }

                                    $keys .= mh_call_function($class_method[2], $value['value'], ${$class_method[1]});
                                } else {
                                    $keys .= mh_call_function($use_function, $value['value']);
                                }
                            } else {
                                $keys .= wordwrap($value['value'], 30, "<br />", true);
                            }
                        }
                        $keys .= '<br /><br />';
                    }
                    $keys = substr($keys, 0, strrpos($keys, '<br /><br />'));

                    if (mh_cfg('MH_PLATFORM_OSC_23')) {
                        $remove_button = tep_draw_button(mh_lng('IMAGE_MODULE_REMOVE'), 'minus', tep_href_link(mh_fn('FILENAME_MAILBEEZ'), 'module=' . $mInfo->code . '&action=remove'));
                        $edit_button = tep_draw_button(mh_lng('IMAGE_EDIT'), 'document', tep_href_link(mh_fn('FILENAME_MAILBEEZ'), 'module=' . $mInfo->code . '&action=edit'));
                    } else {
                        $remove_button = '<a class="button" onClick="this.blur();" href="' . mh_href_link(mh_fn('FILENAME_MAILBEEZ'), 'module=' . $mInfo->code . '&action=remove') . '">' . mh_image_button('button_module_remove.gif', mh_lng('IMAGE_MODULE_REMOVE')) . '</a> ';
                        $edit_button = '<a class="button" onClick="this.blur();" href="' . mh_href_link(mh_fn('FILENAME_MAILBEEZ'), 'module=' . $mInfo->code . '&action=edit') . '">' . mh_image_button('button_edit.gif', mh_lng('IMAGE_EDIT')) . '</a>';
                    }

                    if ($mInfo->removable == false) {
                        $remove_button = '';
                    }

                    if ($mInfo->code == 'config' && !(mh_cfg('MAILBEEZ_INSTALLED') == 'config_queen.php' || mh_cfg('MAILBEEZ_INSTALLED') == '')) {
                        $remove_button = '';
                    }

                    if ($mInfo->is_configurable == false) {
                        $edit_button = '';
                    }


                    $doc_item = '';
                    if (isset($mInfo->documentation_key) && $mInfo->documentation_key != '') {

                        // old
                        //$contents[] = array('text' => '<br />' . mh_admin_icon('info') . '&nbsp;<b>' . mh_lng('TEXT_DOCUMENTATION') . '</b> ' . $sversion . ' (<a href="' . mh_language_documentation_url($mInfo->documentation_root . $mInfo->documentation_key . MH_LINKID_1) . '" target="_blank">' . mh_lng('TEXT_VIEW_ONLINE') . '</a>)');


                        // new
                        $doc_item = mb_admin_button(mh_language_documentation_url($mInfo->documentation_root . $mInfo->documentation_key . mh_cfg('MH_LINKID_1')), mh_lng('MH_TEXT_VIEW_ONLINE'), 'mh_docs_link', 'popup', 'link', '', 'document', 'iframe width:750');
                    }
                    $contents[] = array('align' => 'center', 'text' => '<div class="mh_buttons_align_center">' . $edit_button . ' ' . $remove_button . '<br clear="all">' . $doc_item . '</div>');
                    /*
                     if (isset($mInfo->signature) && (list($scode, $smodule, $sversion, $soscversion) = explode('|', $mInfo->signature))) {
                     $contents[] = array('text' => '<br />' . mh_admin_icon('info') . '&nbsp;<b>' . mh_lng('TEXT_INFO_VERSION') . '</b> ' . $sversion . ' (<a href="http://sig.oscommerce.com/' . $mInfo->signature . '" target="_blank">' . mh_lng('TEXT_INFO_ONLINE_STATUS') . '</a>)');
                     }
                    */
                    $description_image = '';

                    if ($mInfo->description_image_src != '') {
                        $description_image = mh_image(mh_cfg('MH_MODULE_DIRECTORY_CURRENT_WS') . $mInfo->code . '/' . $mInfo->description_image_src, '', '64', '64', 'align="right" style="margin-bottom: 10px; margin-left: 5px; margin-right: 10px;"') . ' ';
                    }

                    $contents[] = array('text' => '<br />' . $description_image . $mInfo->description . '<br /><br />');

                    $contents[] = array('text' => '<div class="mb_action_box"></div>');

                    if ($certification_status) {
                        $contents[] = array('text' => $certification_status);
                    }


                    if ($mInfo->code != 'config' && $mInfo->common_admin_action_plugins != '') {
                        // load common admin GUI plugins
                        if (is_string($mInfo->common_admin_action_plugins)) {
                            $common_admin_action_plugins_includes = explode(';', $mInfo->common_admin_action_plugins);
                            foreach ($common_admin_action_plugins_includes as $common_admin_action_plugins_inc) {
                                require_once(mh_cfg('MH_DIR_FS_CATALOG') . mh_cfg('MH_ROOT_PATH') . 'common/admin_action_plugins/' . $common_admin_action_plugins_inc);
                            }
                        }
                    }
                    // load module admin gui plugins
                    if ($mInfo->admin_action_plugins != '') {
                        if (is_string($mInfo->admin_action_plugins)) {
                            $admin_action_plugins_includes = explode(';', $mInfo->admin_action_plugins);
                            foreach ($admin_action_plugins_includes as $admin_action_plugins_item) {
                                require_once($mInfo->admin_action_plugins_path . $mInfo->module . '/admin_action_plugins/' . $admin_action_plugins_item);
                            }
                        }
                    }

                    if (mh_cfg('MAILBEEZ_CONFIG_TMPLMNGR_STATUS') || mh_cfg('MAILBEEZ_CONFIG_TMPLMNGR_LNG_STATUS')) {
                        mhpi('module_edit_content', $mInfo);
                    } elseif (file_exists(mh_cfg('MH_DIR_CONFIG') . 'config_tmplmngr_lng.php')) {
                        // auto install
                        require_once(mh_cfg('MH_DIR_CONFIG') . 'config_tmplmngr_lng.php');
                        $cfg = new config_tmplmngr_lng();
                    } elseif (file_exists(mh_cfg('MH_DIR_CONFIG') . 'config_tmplmngr.php')) {
                        // auto install
                        require_once(mh_cfg('MH_DIR_CONFIG') . 'config_tmplmngr.php');
                        $cfg = new config_tmplmngr();
                    } else {
                        if ($mInfo->is_editable == true) {
                            require_once(mh_cfg('MH_DIR_CONFIG') . 'config_edit_promo/admin_action_plugins/edit.php');
                        }
                    }

                    $contents[] = array('text' => '<br />' . $keys);
                } elseif (!is_null($mInfo)) {

                    if ($mInfo->required_mb_version > mh_cfg('MAILBEEZ_VERSION')) {
                        $contents[] = array('text' => sprintf(mh_lng('TEXT_UPGRADE_MAILBEEZ'), $mInfo->required_mb_version));
                    } else {
                        if (mh_cfg('MH_PLATFORM_OSC_23')) {
                            $contents[] = array('align' => 'center', 'text' => tep_draw_button(mh_lng('IMAGE_MODULE_INSTALL'), 'plus', tep_href_link(mh_fn('FILENAME_MAILBEEZ'), 'module=' . $mInfo->code . '&action=install')));
                        } else {

                            if ($mInfo->code == '') {

                                $contents[] = array('align' => 'center', 'text' => '<div align="center">' . mh_lng('TEXT_HINT_SELECT_MODULE', 'Please select a module') . '</div>');
                            } else {


                                $contents[] = array('align' => 'center', 'text' => '<div align="center"><a class="button" onClick="this.blur();" href="' . mh_href_link(mh_fn('FILENAME_MAILBEEZ'), 'module=' . $mInfo->code . '&action=install') . '">' . mh_image_button('button_module_install.gif', mh_lng('IMAGE_MODULE_INSTALL')) . '</a></div>');
                            }
                        }
                    }
                    $contents[] = array('text' => '<br />' . $mInfo->description);
                }
                break;
        }


        if ((sizeof($all_modules) > 0) && mh_cfg('MAILBEEZ_MAILHIVE_STATUS') && (mh_not_null($heading)) && (mh_not_null($contents))) {
            echo '            <td width="25%" valign="top" id="cfg_column" class="gx-container" style="min-width: 330px">' . "\n";

            $box = new box;
            echo $box->infoBox($heading, $contents);
            if (!mh_cfg('MH_DISABLE_ABOUT_TAB', false)) {
                ?>
                <div class="smallText" style="float: right; border: 0px solid #c0c0c0; padding: 5px;">
                    <div style="float: left; padding-right: 10px; padding-top: 10px;"><a
                                href="<?php echo mh_href_link(mh_fn('FILENAME_MAILBEEZ'), 'tab=about'); ?>"><?php echo mh_cfg('MH_MAILBEEZ_LOVE'); ?></a>
                    </div>
                    <div style="float: left; padding-top: 2px;">
                        <img
                                src="<?php echo mh_cfg('MH_CATALOG_SERVER') . mh_cfg('MH_DIR_WS_CATALOG') . mh_cfg('MH_ROOT_PATH'); ?>common/images/been_tiny_love.png"
                                width="49"
                                height="31" alt="" border="0" align="left" hspace="1" style=""></div>
                </div>
                <?php
            }
            echo '            </td>' . "\n";
        }
        ?>
    </tr>
</table>