<?php
/*
MailBeez Automatic Trigger Email Campaigns
http://www.mailbeez.com
Copyright (c) 2010 MailBeez
inspired and in parts based on
Copyright (c) 2003 osCommerce
Released under the GNU General Public License
*/
// make path work from admin
require_once(DIR_FS_CATALOG. 'mailhive/common/classes/mailbeez.php');
// could be in language-file
// just easier to define it in the mailbee
define('MAILBEEZ_MAILHIVE_TEXT_TITLE', 'MailHive - Basic Configuration');
if (MAILBEEZ_INSTALLED == 'config.php' || MAILBEEZ_INSTALLED == '') {
define('MAILBEEZ_MAILHIVE_TEXT_DESCRIPTION', 'Basic Configuration for MailHive.');
} else {
define('MAILBEEZ_MAILHIVE_TEXT_DESCRIPTION', 'Basic Configuration for MailHive. <br>
<br>
To remove this module please uninstall all MailBeez first.');
}
class config {
// class constructor
function config() {
$this->code = 'config';
$this->version = '1.7'; // float value
$this->title = MAILBEEZ_MAILHIVE_TEXT_TITLE;
$this->description = MAILBEEZ_MAILHIVE_TEXT_DESCRIPTION;
$this->sort_order = 0.0000001;
$this->enabled = ((MAILBEEZ_MAILHIVE_STATUS == 'True') ? true : false);
$this->status_key = 'MAILBEEZ_MAILHIVE_STATUS';
$this->documentation_key = 'config'; // leave empty if no documentation available
$this->documentation_root = 'http://www.mailbeez.com/documentation/installation/';
// update version if necessary
if (defined('MAILBEEZ_VERSION') && ( MAILBEEZ_VERSION < $this->version) ) {
mh_db_query("update " . TABLE_CONFIGURATION . " set configuration_value = '" . $this->version . "', last_modified = now() where configuration_key = 'MAILBEEZ_VERSION'");
}
}
// class methods
function getAudience() {
}
function check() {
if (!isset($this->_check)) {
$check_query = mh_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = '" . $this->status_key . "'");
$this->_check = mh_db_num_rows($check_query);
}
return $this->_check;
}
function remove() {
$remove_keys = $this->keys();
if (MH_PLATFORM == 'xtc') {
// remove additional fields
$xtc_text_keys = array();
$keys = $this->keys();
$keys[] = 'MAILBEEZ_VERSION';
$keys[] = 'MAILBEEZ_INSTALLED';
$keys[] = 'MAILBEEZ_INSTALLED_VERSIONS';
while (list(, $key_name) = each($keys)) {
$xtc_text_keys[] = $key_name . '_TITLE';
$xtc_text_keys[] = $key_name . '_DESC';
}
$remove_keys = array_merge($xtc_text_keys,$this->keys());
}
return mh_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('MAILBEEZ_VERSION', '" . implode("', '", $remove_keys) . "')");
}
// installation methods
function keys() {
return array('MAILBEEZ_MAILHIVE_STATUS', 'MAILBEEZ_MAILHIVE_MODE', 'MAILBEEZ_MAILHIVE_COPY', 'MAILBEEZ_MAILHIVE_EMAIL_COPY', 'MAILBEEZ_MAILHIVE_EMAIL_COPY_MAX_COUNT', 'MAILBEEZ_INSTALLED', 'MAILBEEZ_INSTALLED_VERSIONS', 'MAILBEEZ_MAILHIVE_TOKEN', 'MAILBEEZ_MAILHIVE_GA_ENABLED', 'MAILBEEZ_MAILHIVE_GA_REWRITE_MODE', 'MAILBEEZ_MAILHIVE_POPUP_MODE', 'MAILBEEZ_MAILHIVE_UPDATE_REMINDER');
}
function install() {
mh_insert_config_value(array('configuration_title' => 'Let the MailBeez work for you',
'configuration_key' => 'MAILBEEZ_MAILHIVE_STATUS',
'configuration_value' => 'True',
'configuration_description' => 'Choose False to deactivated MailHive and MailBeez',
'set_function' => 'mh_cfg_select_option(array(\'True\', \'False\'), '
));
mh_insert_config_value(array('configuration_title' => 'Mode',
'configuration_key' => 'MAILBEEZ_MAILHIVE_MODE',
'configuration_value' => 'simulate',
'configuration_description' => 'production: emails are send out, tracking active<br>simulate: emails to copy-address only, tracking inactive',
'set_function' => 'mh_cfg_select_option(array(\'production\', \'simulate\'), '
));
mh_insert_config_value(array('configuration_title' => 'Send copy',
'configuration_key' => 'MAILBEEZ_MAILHIVE_COPY',
'configuration_value' => 'True',
'configuration_description' => 'send a copy of each email to copy-address',
'set_function' => 'mh_cfg_select_option(array(\'True\', \'False\'), '
));
mh_insert_config_value(array('configuration_title' => 'Sent copy to',
'configuration_key' => 'MAILBEEZ_MAILHIVE_EMAIL_COPY',
'configuration_value' => 'copy@localhost',
'configuration_description' => 'Send a copy of each email to this address<br>(be careful - configure number below)',
'set_function' => ''
));
mh_insert_config_value(array('configuration_title' => 'Max. number of copy-emails sent per MailBee',
'configuration_key' => 'MAILBEEZ_MAILHIVE_EMAIL_COPY_MAX_COUNT',
'configuration_value' => '10',
'configuration_description' => 'controll the number of copy-emails',
'set_function' => ''
));
mh_insert_config_value(array('configuration_title' => 'Security Token - for internal use only',
'configuration_key' => 'MAILBEEZ_MAILHIVE_TOKEN',
'configuration_value' => md5(time()),
'configuration_description' => 'Security Token to protect public mailhive, leave default value or set to what you like',
'set_function' => ''
));
mh_insert_config_value(array('configuration_title' => 'Google Analytics Integration',
'configuration_key' => 'MAILBEEZ_MAILHIVE_GA_ENABLED',
'configuration_value' => 'True',
'configuration_description' => 'Globally enable Google Analytics Integration',
'set_function' => 'mh_cfg_select_option(array(\'True\', \'False\'), '
));
mh_insert_config_value(array('configuration_title' => 'Google Analytics URL Rewrite Mode',
'configuration_key' => 'MAILBEEZ_MAILHIVE_GA_REWRITE_MODE',
'configuration_value' => 'all',
'configuration_description' => 'Globally set Google Analytics URL Rewrite Mode',
'set_function' => 'mh_cfg_select_option(array(\'all\', \'shop\'), '
));
mh_insert_config_value(array('configuration_title' => 'Popup mode',
'configuration_key' => 'MAILBEEZ_MAILHIVE_POPUP_MODE',
'configuration_value' => 'CeeBox',
'configuration_description' => 'Popup-Mode, please change if you are having compatibility issues with opening the nice CeeBox AJAX Popups.',
'set_function' => 'mh_cfg_select_option(array(\'off\', \'CeeBox\'), '
));
mh_insert_config_value(array('configuration_title' => 'Remind to run update check',
'configuration_key' => 'MAILBEEZ_MAILHIVE_UPDATE_REMINDER',
'configuration_value' => 'True',
'configuration_description' => 'Do you want to get reminder to check for updates?',
'set_function' => 'mh_cfg_select_option(array(\'True\', \'False\'), '
));
$check_query = mh_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MAILBEEZ_VERSION'");
if (mh_db_num_rows($check_query)) {
$check = mh_db_fetch_array($check_query);
if ($check['configuration_value'] != $this->version) {
mh_db_query("update " . TABLE_CONFIGURATION . " set configuration_value = '" . $this->version . "', last_modified = now() where configuration_key = 'MAILBEEZ_VERSION'");
}
} else {
mh_insert_config_value(array('configuration_title' => 'MailBeez Version',
'configuration_key' => 'MAILBEEZ_VERSION',
'configuration_value' => $this->version,
'configuration_description' => 'This is automatically updated. No need to edit.',
'set_function' => ''
));
}
mh_db_query("CREATE TABLE IF NOT EXISTS " . DB_PREFIX . "mailbeez_tracking (
autoemail_id int NOT NULL auto_increment,
module varchar(255) NOT NULL,
iteration INT( 11 ) NOT NULL ,
customers_id INT( 11 ) NOT NULL ,
customers_email VARCHAR( 96 ) NOT NULL,
orders_id INT NOT NULL,
date_sent DATETIME NOT NULL ,
PRIMARY KEY ( autoemail_id ),
INDEX ( customers_id ) );");
mh_db_query("CREATE TABLE IF NOT EXISTS " . DB_PREFIX . "mailbeez_block (
autoemail_id int NOT NULL auto_increment,
module varchar(255) NOT NULL,
customers_id INT( 11 ) NOT NULL ,
date_block DATETIME NOT NULL,
PRIMARY KEY ( autoemail_id ),
INDEX ( customers_id, module ) );");
}
}
?>