<?php
// +---------------------------------------------+
// |     Copyright 2007 - 2008 weenCompany       |
// |     http://www.weentech.com                 |
// |     This file may not be redistributed.     |
// +---------------------------------------------+

if(!defined('TABLE_PREFIX'))
  define('TABLE_PREFIX', "");

if(!defined('IN_WEENCOMPANY'))
  die('File not found!');


// ############################### MODULE DETAILS ##############################

$uniqueid       = 4;
$modulename     = '留言簿';
$version        = '2.0';
$modulepath     = 'm4_guestbook/guestbook.php';
$settingspath   = 'm4_guestbook/m4_settings.php';
$authorname     = 'weencompany';
$authorlink     = 1;
$modulesettings = '19';


// ############################### INSTALL MODULE ##############################

if($installtype == 'install')
{
  $DB->query("CREATE TABLE " . TABLE_PREFIX . "m4_guestbook (
  messageid   INT(10)      UNSIGNED NOT NULL AUTO_INCREMENT,
  noactivated   TINYINT(1)            NOT NULL DEFAULT 0,
  username    VARCHAR(64)           NOT NULL DEFAULT '',
  websitename VARCHAR(128)          NOT NULL DEFAULT '',
  website     VARCHAR(128)          NOT NULL DEFAULT '',
  message     TEXT                  NOT NULL,
  datecreated INT(10)               NOT NULL DEFAULT 0,
  KEY messageid (messageid)
  ) TYPE=MyISAM;" );

  $DB->query("INSERT INTO " . TABLE_PREFIX . "modulesettings VALUES (NULL, $uniqueid, '模块设置', '审核发布',    '用户提交的留言是否经过审核后才能发布?', 'yesno', '0', 1) ");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "modulesettings VALUES (NULL, $uniqueid, '模块设置', '允许表情符号',    '允许表情符号可以使输入的表情代码字符组合转换成表情符号.', 'yesno', '1', 2) ");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "modulesettings VALUES (NULL, $uniqueid, '模块设置', '显示条目数', '模块内显示的每页内容条目数量:', 'text', '10', 3) ");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "modulesettings VALUES (NULL, $uniqueid, '模块设置', '内容字符长度',    '内容中可输入的最大字符数量:', 'text', '200', 4) ");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "modulesettings VALUES (NULL, $uniqueid, '模块设置', '换行字符数',         '插入换行符的字符数量(\"0\"表示不插入换行):', 'text', '0', 5) ");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "modulesettings VALUES (NULL, $uniqueid,  '模块设置',                  '显示发表日期',                       '是否显示用户发表留言的日期?', 'yesno', '1', 6) ");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "modulesettings VALUES (NULL, $uniqueid,  '模块设置',                  '验证码',                     '用户发表留言时, 是否需要填写验证码?', 'yesno', '1', 7) ");

if($sitedefaultlang == 'en') //Insert English phrase.
{
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'website_url',              'Website:', '', '', '', '', 1, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'name',                     'Name:', '', '', '', '', 1, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'date',                     'Date:', '', '', '', '', 1, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'website_name',             'Company:', '', '', '', '', 1, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'message',                  'Message:', '', '', '', '', 1, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'submit_message',           'Submit Message', '', '', '', '', 0, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'reset',                    'Reset', '', '', '', '', 0, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'no_username',              'Please fill out the username field!', '', '', '', '', 1, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'no_message',               'Please fill out the message field!', '', '', '', '', 1, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'message_too_long',         'Message length must be less than', '', '', '', '', 1, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'url_invalid',              'Website URL is invalid!', '', '', '', '', 1, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'no_site_name',             'Please enter the site name of the url specified!', '', '', '', '', 1, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'repeat_comment',           'Repeat comment not posted!', '', '', '', '', 1, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'website',                  'Company:', '', '', '', '', 1, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'previous',                 '&laquo; Previous', '', '', '', '', 0, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'next',                     'Next &raquo;', '', '', '', '', 0, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'sign_guestbook',           'Click here to leave a message!', '', '', '', '', 0, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'characters',               'characters', '', '', '', '', 0, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'message_checking',                    'This message is being verified...', '', '', '', '', 0, 0, 0)");

}
else  //Insert Chinese phrase.
{
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'website_url',              '网址:', '', '', '', '', 1, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'name',                     '姓名:', '', '', '', '', 1, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'date',                     '日期:', '', '', '', '', 1, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'website_name',             '单位:', '', '', '', '', 1, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'message',                  '留言内容:', '', '', '', '', 1, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'submit_message',           '提交留言', '', '', '', '', 0, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'reset',                    '重置', '', '', '', '', 0, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'no_username',              '请输入您的姓名!', '', '', '', '', 1, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'no_message',               '请输入留言内容!', '', '', '', '', 1, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'message_too_long',         '留言内容的字符数不能超过', '', '', '', '', 1, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'url_invalid',              '无效的网站URL!', '', '', '', '', 1, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'no_site_name',             '请输入网站名称!', '', '', '', '', 1, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'repeat_comment',           '请勿重复提交内容相同的留言!', '', '', '', '', 1, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'website',                  '单位:', '', '', '', '', 1, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'previous',                 '&laquo; 上一页', '', '', '', '', 0, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'next',                     '下一页 &raquo;', '', '', '', '', 0, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'sign_guestbook',           '点击这里发表留言!', '', '', '', '', 0, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'characters',                    '字节!', '', '', '', '', 0, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'message_checking',                    '留言内容等待审核中...', '', '', '', '', 0, 0, 0)");

}

}


// ############################### UPGRADE MODULE ##############################

if($installtype == 'upgrade')
{
  if($currentversion == '2.0')
  {
    // example:
    // UpdateModuleVersion(4, 2.1);
    // $currentversion = 2.1;
  }
}


// ############################## UNINSTALL MODULE #############################

if($installtype == 'uninstall')
{
  $DB->query("DROP TABLE IF EXISTS " . TABLE_PREFIX . "m4_guestbook");
}

?>