<?php
// +---------------------------------------------+
// |     Copyright  2003-2005 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       = 16;
$modulename     = '链接模块';
$version        = '2.0';
$modulepath     = 'm16_linkdirectory/linkdirectory.php';
$settingspath   = 'm16_linkdirectory/m16_settings.php';
$authorname     = 'weencompany';
$authorlink     = 1;
$modulesettings = '19';


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

if($installtype == 'install')
{
  $DB->query("CREATE TABLE " . TABLE_PREFIX . "m16_links (
  linkid       INT(10)      UNSIGNED NOT NULL              AUTO_INCREMENT,
  sectionid    INT(10)      UNSIGNED NOT NULL DEFAULT 0,
  activated    TINYINT(1)            NOT NULL DEFAULT 0,
  allowsmilies TINYINT(1)            NOT NULL DEFAULT 0,
  showauthor   TINYINT(1)            NOT NULL DEFAULT 0,
  author       VARCHAR(64)           NOT NULL DEFAULT '',
  title        VARCHAR(128)          NOT NULL DEFAULT '',
  url          TEXT                  NOT NULL,
  description  TEXT                  NOT NULL,
  KEY linkid (linkid)
  ) TYPE=MyISAM;" );


  $DB->query("CREATE TABLE " . TABLE_PREFIX . "m16_sections (
  sectionid   INT(10)      UNSIGNED NOT NULL              AUTO_INCREMENT,
  parentid    INT(10)      UNSIGNED NOT NULL DEFAULT 0,
  activated   TINYINT(1)            NOT NULL DEFAULT 0,
  name        VARCHAR(128)          NOT NULL DEFAULT '',
  description TEXT                  NOT NULL,
  sorting     VARCHAR(32)           NOT NULL DEFAULT '',
  KEY sectionid (sectionid)
  ) TYPE=MyISAM;" );

if($sitedefaultlang == 'en') //Insert English section.
{
  $DB->query("INSERT INTO " . TABLE_PREFIX . "m" . $uniqueid . "_sections VALUES ('0', 0, 1, 'Links', '', '时间(降序)')");

}
else  //Insert Chinese section.
{
  $DB->query("INSERT INTO " . TABLE_PREFIX . "m" . $uniqueid . "_sections VALUES ('0', 0, 1, '链接', '', '时间(降序)')");

}

  $DB->query("INSERT INTO " . TABLE_PREFIX . "modulesettings VALUES (NULL, $uniqueid, '模块设置',              '每页链接数',                       '每页显示的链接数量:', 'text', '20', 1) ");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "modulesettings VALUES (NULL, $uniqueid, '模块设置',              '每行链接数',              '每行显示的链接数量:', 'text', '4', 2) ");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "modulesettings VALUES (NULL, $uniqueid, '模块设置',              '邮件通知',                    '会员提交链接后, 按此邮箱地址通知管理员:<br />\r\n多个信箱可用英文逗号隔开, 不希望收到通知, 请留空.', 'text', '', 3) ");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "modulesettings VALUES (NULL, $uniqueid, '模块设置',              '显示导航栏',                         '是否显示导航栏?', 'yesno', '1', 6) ");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "modulesettings VALUES (NULL, $uniqueid, '模块设置', 			  '自动发布', 				  '是否允许会员提交链接后不经审核自动发布?', 'yesno', '0', 7) ");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "modulesettings VALUES (NULL, $uniqueid, '模块设置', 			  '验证码', 				  '会员提交链接申请时, 是否需要填写验证码?', 'yesno', '1', 8) ");
  
if($sitedefaultlang == 'en') //Insert English phrase.
{
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'sections',                'Sections:', '', '', '', '', 1, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'submitting_link',         'Submitting Link', '', '', '', '', 0, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'your_name',               'Your Name:', '', '', '', '', 1, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'website_name',            'Website Name:', '', '', '', '', 1, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'website_url',             'Website URL:', '', '', '', '', 1, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'description',             'Description:', '', '', '', '', 1, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'submit_link',             'Submit Link', '', '', '', '', 0, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'submit_a_link',           'Click here to submit a link to this section!', '', '', '', '', 0, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'submitted_by',            'Submitted by:', '', '', '', '', 0, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'previous_links',          '&laquo; Previous Page', '', '', '', '', 0, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'more_links',              'Next Page &raquo;', '', '', '', '', 0, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'enter_name',              'Please enter your name!', '', '', '', '', 1, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'enter_site_name',         'Please enter the name of the site!', '', '', '', '', 1, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'enter_site_url',          'Please enter the url of the site!', '', '', '', '', 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, 'enter_description',       'Please enter the description!', '', '', '', '', 1, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'link_submitted',          'Thanks! Your link has been submitted.', '', '', '', '', 1, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'notify_email_from',                'Link Directory Module', '', '', '', '', 0, 0, 0) ");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'notify_email_subject',         'New link submitted to your website!','', '', '', '', 0, 0, 0) ");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'notify_email_message',         'A new link has been submitted to your link directory.',  '', '', '', '', 1, 0, 0) ");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'notify_email_author',     'Author', '', '', '', '', 0, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'notify_email_website',    'Website Name', '', '', '', '', 0, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'notify_email_url',            'Website URL', '', '', '', '', 0, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'notify_email_description','Description', '', '', '', '', 0, 0, 0)");

}
else  //Insert Chinese phrase.
{
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'sections',                '分类:', '', '', '', '', 1, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'submitting_link',         '申请链接', '', '', '', '', 0, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'your_name',               '您的姓名:', '', '', '', '', 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, 'website_url',             '网站URL:', '', '', '', '', 1, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'description',             '网站介绍:', '', '', '', '', 1, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'submit_link',             '提交申请', '', '', '', '', 0, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'submit_a_link',           '点击这里在此类中申请链接!', '', '', '', '', 0, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'submitted_by',            '来自:', '', '', '', '', 0, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'previous_links',          '&laquo; 上一页', '', '', '', '', 0, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'more_links',              '下一页 &raquo;', '', '', '', '', 0, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'enter_name',              '请输入您的姓名!', '', '', '', '', 1, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'enter_site_name',         '请输入网站名称!', '', '', '', '', 1, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'enter_site_url',          '请输入网站URL!', '', '', '', '', 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, 'enter_description',       '请输入网站介绍!', '', '', '', '', 1, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'link_submitted',          '申请链接提交成功! 如未发布, 请等待审核.', '', '', '', '', 1, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'notify_email_from',        '友情链接模块', '', '', '', '', 0, 0, 0) ");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'notify_email_subject',         '有新申请链接提交到您的网站!','', '', '', '', 0, 0, 0) ");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'notify_email_message',         '有新申请链接提交到您的网站, 如友情链接模块设置为审核发布, 请尽快到网站后台审核.',  '', '', '', '', 1, 0, 0) ");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'notify_email_author',     '申请人', '', '', '', '', 0, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'notify_email_website',    '网站名称', '', '', '', '', 0, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'notify_email_url',        '网站URL', '', '', '', '', 0, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'notify_email_description','网站介绍', '', '', '', '', 0, 0, 0)");

}

}


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

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


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

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

?>