Files
poll/sql.php
2026-03-29 18:38:12 +05:00

98 lines
3.3 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
/**
* AVE.cms - Модуль Опросы.
*
* @package AVE.cms
* @subpackage mod_poll
* @since 3.31
* @filesource
*/
/**
* mySQL-запросы для установки, обновления и удаления модуля
*/
$module_sql_install = array();
$module_sql_deinstall = array();
$module_sql_update = array();
// --- 1. УДАЛЕНИЕ МОДУЛЯ ---
$module_sql_deinstall[] = "DROP TABLE IF EXISTS `%%PRFX%%_module_poll`;";
$module_sql_deinstall[] = "DROP TABLE IF EXISTS `%%PRFX%%_module_poll_comments`;";
$module_sql_deinstall[] = "DROP TABLE IF EXISTS `%%PRFX%%_module_poll_items`;";
// При удалении модуля чистим ВСЕ алиасы, связанные с ним
$module_sql_deinstall[] = "DELETE FROM `%%PRFX%%_modules_aliases` WHERE module_name = 'poll';";
// --- 2. УСТАНОВКА МОДУЛЯ ---
$module_sql_install[] = "
CREATE TABLE IF NOT EXISTS `%%PRFX%%_module_poll` (
`id` int(10) unsigned NOT NULL auto_increment,
`poll_title` varchar(255) NOT NULL default '',
`poll_status` enum('1','0') NOT NULL default '1',
`poll_can_comment` enum('0','1') NOT NULL default '0',
`poll_anti_spam` enum('0','1') NOT NULL default '0',
`poll_groups_id` tinytext,
`poll_start` int(10) unsigned NOT NULL default '0',
`poll_end` int(10) unsigned NOT NULL default '0',
`poll_users_id` text NOT NULL default '',
`poll_users_ip` text NOT NULL default '',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
";
$module_sql_install[] = "
CREATE TABLE IF NOT EXISTS `%%PRFX%%_module_poll_comments` (
`id` int(10) unsigned NOT NULL auto_increment,
`poll_id` int(10) NOT NULL,
`poll_comment_author_id` int(10) NOT NULL,
`poll_comment_author_ip` text NOT NULL default '',
`poll_comment_time` int(10) unsigned NOT NULL default '0',
`poll_comment_title` varchar(250) NOT NULL default '',
`poll_comment_text` text NOT NULL default '',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
";
$module_sql_install[] = "
CREATE TABLE IF NOT EXISTS `%%PRFX%%_module_poll_items` (
`id` int(10) unsigned NOT NULL auto_increment,
`poll_id` int(10) NOT NULL,
`poll_item_title` varchar(250) NOT NULL default '',
`poll_item_hits` int(10) NOT NULL default '0',
`poll_item_color` varchar(10) NOT NULL default '',
`poll_item_position` int(2) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
";
// ШТАТНОЕ ЧПУ
$module_sql_install[] = "
INSERT INTO `%%PRFX%%_modules_aliases`
SET module_name = 'poll',
module_action = 'archive',
module_link = 'index.php?module=poll&action=archive',
module_url = 'poll-archive',
module_admin = '0';
";
// --- 3. ОБНОВЛЕНИЕ МОДУЛЯ ---
$module_sql_update[] = "
UPDATE
`%%PRFX%%_module`
SET
ModuleAveTag = '" . (isset($module['ModuleAveTag']) ? $module['ModuleAveTag'] : '') . "',
ModulePHPTag = '" . (isset($module['ModulePHPTag']) ? $module['ModulePHPTag'] : '') . "',
ModuleVersion = '" . (isset($module['ModuleVersion']) ? $module['ModuleVersion'] : '') . "'
WHERE
ModuleSysName = 'poll'
LIMIT 1;
";
// Добавляем поле poll_anti_spam, если его еще нет
$module_sql_update[] = "ALTER TABLE `%%PRFX%%_module_poll` ADD IF NOT EXISTS `poll_anti_spam` enum('0','1') NOT NULL DEFAULT '0' AFTER `poll_can_comment`";
?>