Files
comment/sql.php
2025-12-15 07:48:07 +05:00

117 lines
4.5 KiB
PHP
Raw 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 - Модуль Комментарии
*
* Данный файл является частью модуля "Комментарии" и содержит mySQL-запросы
* к базе данных при операцих установки, обновления и удаления модуля через Панель управления.
*
* @package AVE.cms
* @subpackage module_Comment
* @since 1.4
* @filesource
*/
$module_sql_install = array();
$module_sql_deinstall = array();
$module_sql_update = array();
$module_sql_deinstall[] = "DROP TABLE IF EXISTS `%%PRFX%%_module_comments`;";
$module_sql_deinstall[] = "DROP TABLE IF EXISTS `%%PRFX%%_module_comment_info`;";
// =================================================================================
// 1. ИЗМЕНЕНИЯ ДЛЯ УСТАНОВКИ МОДУЛЯ
// =================================================================================
$module_sql_install[] = "CREATE TABLE `%%PRFX%%_module_comments` (
`Id` tinyint(1) unsigned NOT NULL auto_increment,
`comment_max_chars` smallint(3) unsigned NOT NULL default '1000',
`comment_user_groups` text NOT NULL,
`comment_user_groups_read` text NOT NULL, /* <-- НОВОЕ ПОЛЕ ДЛЯ ПРАВ НА ПРОСМОТР */
`comment_need_approve` enum('0','1') NOT NULL default '0',
`comment_active` enum('1','0') NOT NULL default '1',
`comment_use_antispam` enum('1','0') NOT NULL default '1',
`comment_use_page_nav` enum('1','0') NOT NULL default '1',
`comment_page_nav_count` varchar(5) NOT NULL,
PRIMARY KEY (`Id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
$module_sql_install[] = "CREATE TABLE `%%PRFX%%_module_comment_info` (
`Id` int(10) unsigned NOT NULL auto_increment,
`parent_id` int(10) unsigned NOT NULL default '0',
`document_id` int(10) unsigned NOT NULL default '0',
`comment_author_name` varchar(255) NOT NULL,
`comment_author_id` int(10) unsigned NOT NULL default '0',
`comment_author_email` varchar(255) NOT NULL,
`comment_author_city` varchar(255) NOT NULL,
`comment_author_website` varchar(255) NOT NULL,
`comment_author_ip` varchar(15) NOT NULL,
`comment_published` int(10) unsigned NOT NULL default '0',
`comment_changed` int(10) unsigned NOT NULL default '0',
`comment_text` text NOT NULL,
`comment_status` tinyint(1) unsigned NOT NULL default '1',
`comments_close` tinyint(1) unsigned NOT NULL default '0',
PRIMARY KEY (`Id`),
KEY `document_id` (`document_id`),
KEY `parent_id` (`parent_id`),
KEY `comment_status` (`comment_status`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 PACK_KEYS=0;";
// ИЗМЕНЕННАЯ СТРОКА: Устанавливаем права на просмотр по умолчанию для всех групп: 1, 2, 3, 4
$module_sql_install[] = "INSERT INTO `%%PRFX%%_module_comments` VALUES (1, 1000, '1,3', '1,2,3,4', '0', '1', '1' , '0', '');";
// ^ max chars, ^ write groups, ^ read groups (ИСПРАВЛЕНО), ^ need_approve ...
// =================================================================================
// 2. ИЗМЕНЕНИЯ ДЛЯ ОБНОВЛЕНИЯ МОДУЛЯ (Добавление нового поля)
// =================================================================================
// Обновление версии модуля (оставлено без изменений)
$module_sql_update[] = "
UPDATE
`%%PRFX%%_module`
SET
ModuleAveTag = '" . $modul['ModuleAveTag'] . "',
ModulePHPTag = '" . $modul['ModulePHPTag'] . "',
ModuleVersion = '" . $modul['ModuleVersion'] . "'
WHERE
ModuleSysName = '" . $modul['ModuleSysName'] . "'
LIMIT 1;
";
// Добавление нового столбца comment_user_groups_read в существующую таблицу
$module_sql_update[] = "
ALTER TABLE
`%%PRFX%%_module_comments`
ADD
`comment_user_groups_read` TEXT NOT NULL
AFTER
`comment_user_groups`;
";
// ИЗМЕНЕННАЯ СТРОКА: Заполнение нового столбца значением по умолчанию для всех групп: 1, 2, 3, 4
$module_sql_update[] = "
UPDATE
`%%PRFX%%_module_comments`
SET
`comment_user_groups_read` = '1,2,3,4'
WHERE
`Id` = 1;
";
$module_sql_update[] = "
ALTER TABLE
`%%PRFX%%_module_comments`
ADD
`comment_use_page_nav` ENUM('0','1') NOT NULL DEFAULT '1'
AFTER
`comment_use_antispam`;
";
$module_sql_update[] = "
ALTER TABLE
`%%PRFX%%_module_comments`
ADD
`comment_page_nav_count` VARCHAR(5) NOT NULL
AFTER
`comment_use_page_nav`;
";
?>