/**
 * Добавляет новую настройку плагина.
 * @param string         $Group       Идентификатор группы настроек.
 * @param string         $Name        Имя (для доступа из кода).
 * @param string         $Title       Заголовок.
 * @param string         $Value       Начальное значение.
 * @param string         $Description Описание.
 * @param bool           $Visible     Видимая.
 * @param string         $KindControl Элемент управления для изменения значения.
 * @param string         $Type        Тип данных (длина(255),тип(string - PHP Type),вырезать теги(true, false)).
 * @param string         $Values      Заполнение значений для элементов выбора. (optval:title,optval:title) или функция (function:Callback), см. плагины форм.
 * @param string         $SaveHandler Имя функции вызываемой при сохранении параметра. См. плагины форм.
 * @param bool           $Autoload    Загружать в $config.
 */
function AddPluginConfig($Group, $Name, $Title, $Value, $Description = '', $Visible = false, $KindControl = '', $Type = '255,string,false', $Values = '', $SaveHandler = '', $Autoload = true)
{
    AddConfig($Group, $Name, $Title, $Value, $Description, $Visible, $KindControl, $Type, $Values, $SaveHandler, $Autoload, 'plugins_config', 'plugins_config_groups');
}
$table_forum_posts = 'a:6:{s:7:"counter";i:0;s:8:"num_rows";i:0;s:4:"name";s:11:"forum_posts";s:4:"size";i:1581;s:4:"cols";a:12:{i:0;a:7:{s:4:"name";s:2:"id";s:4:"type";s:3:"int";s:6:"length";s:2:"11";s:10:"attributes";s:8:"unsigned";s:7:"notnull";s:1:"1";s:14:"auto_increment";s:1:"1";s:7:"primary";s:1:"1";}i:1;a:6:{s:4:"name";s:6:"object";s:4:"type";s:3:"int";s:6:"length";s:2:"11";s:10:"attributes";s:8:"unsigned";s:7:"notnull";s:1:"1";s:5:"index";s:1:"1";}i:2;a:6:{s:4:"name";s:7:"user_id";s:4:"type";s:3:"int";s:6:"length";s:2:"11";s:10:"attributes";s:8:"unsigned";s:7:"notnull";s:1:"1";s:5:"index";s:1:"1";}i:3;a:5:{s:4:"name";s:6:"public";s:4:"type";s:3:"int";s:6:"length";s:2:"11";s:7:"notnull";s:1:"1";s:5:"index";s:1:"1";}i:4;a:5:{s:4:"name";s:4:"name";s:4:"type";s:7:"varchar";s:6:"length";s:2:"50";s:7:"default";s:0:"";s:7:"notnull";s:1:"1";}i:5;a:5:{s:4:"name";s:8:"homepage";s:4:"type";s:7:"varchar";s:6:"length";s:3:"250";s:7:"default";s:0:"";s:7:"notnull";s:1:"1";}i:6;a:5:{s:4:"name";s:5:"email";s:4:"type";s:7:"varchar";s:6:"length";s:2:"50";s:7:"default";s:0:"";s:7:"notnull";s:1:"1";}i:7;a:5:{s:4:"name";s:10:"hide_email";s:4:"type";s:3:"int";s:6:"length";s:1:"1";s:10:"attributes";s:8:"unsigned";s:7:"notnull";s:1:"1";}i:8;a:5:{s:4:"name";s:3:"icq";s:4:"type";s:7:"varchar";s:6:"length";s:2:"15";s:7:"default";s:0:"";s:7:"notnull";s:1:"1";}i:9;a:3:{s:4:"name";s:7:"message";s:4:"type";s:4:"text";s:7:"notnull";s:1:"1";}i:10;a:5:{s:4:"name";s:7:"user_ip";s:4:"type";s:7:"varchar";s:6:"length";s:2:"19";s:7:"default";s:0:"";s:7:"notnull";s:1:"1";}i:11;a:5:{s:4:"name";s:6:"delete";s:4:"type";s:3:"int";s:6:"length";s:1:"1";s:7:"default";s:1:"0";s:7:"notnull";b:1;}}s:4:"type";s:6:"MyISAM";}';
$table_forum_subscription = 'a:6:{s:4:"name";s:18:"forum_subscription";s:4:"size";i:530;s:4:"type";s:6:"MyISAM";s:4:"cols";a:3:{i:0;a:6:{s:4:"name";s:2:"id";s:4:"type";s:3:"int";s:6:"length";i:11;s:7:"notnull";b:1;s:14:"auto_increment";b:1;s:7:"primary";b:1;}i:1;a:5:{s:4:"name";s:5:"topic";s:4:"type";s:3:"int";s:6:"length";i:11;s:7:"notnull";b:1;s:5:"index";b:1;}i:2;a:5:{s:4:"name";s:4:"user";s:4:"type";s:3:"int";s:6:"length";i:11;s:7:"notnull";b:1;s:5:"index";b:1;}}s:8:"num_rows";i:0;s:7:"counter";i:0;}';
$table_forum_topics_read = 'a:6:{s:7:"counter";i:0;s:8:"num_rows";i:0;s:4:"name";s:17:"forum_topics_read";s:4:"size";s:3:"626";s:4:"type";s:6:"MyISAM";s:4:"cols";a:3:{i:0;a:4:{s:4:"name";s:3:"mid";s:4:"type";s:3:"int";s:6:"length";s:2:"11";s:7:"notnull";s:1:"1";}i:1;a:4:{s:4:"name";s:3:"tid";s:4:"type";s:3:"int";s:6:"length";s:2:"11";s:7:"notnull";s:1:"1";}i:2;a:4:{s:4:"name";s:4:"date";s:4:"type";s:3:"int";s:6:"length";s:2:"11";s:7:"notnull";s:1:"1";}}}';
$table_forum_topics = 'a:6:{s:7:"counter";i:0;s:8:"num_rows";i:0;s:4:"name";s:12:"forum_topics";s:4:"size";i:2013;s:4:"type";s:6:"MyISAM";s:4:"cols";a:16:{i:0;a:6:{s:4:"name";s:2:"id";s:4:"type";s:3:"int";s:6:"length";s:2:"11";s:7:"notnull";s:1:"1";s:14:"auto_increment";s:1:"1";s:7:"primary";s:1:"1";}i:1;a:5:{s:4:"name";s:8:"forum_id";s:4:"type";s:3:"int";s:6:"length";s:2:"11";s:7:"notnull";s:1:"1";s:5:"index";s:1:"1";}i:2;a:5:{s:4:"name";s:5:"title";s:4:"type";s:7:"varchar";s:6:"length";s:3:"255";s:7:"default";s:0:"";s:7:"notnull";s:1:"1";}i:3;a:4:{s:4:"name";s:5:"state";s:4:"type";s:3:"int";s:6:"length";s:1:"1";s:7:"notnull";s:1:"1";}i:4;a:4:{s:4:"name";s:5:"posts";s:4:"type";s:3:"int";s:6:"length";s:2:"11";s:7:"notnull";s:1:"1";}i:5;a:4:{s:4:"name";s:4:"hits";s:4:"type";s:3:"int";s:6:"length";s:2:"11";s:7:"notnull";s:1:"1";}i:6;a:4:{s:4:"name";s:10:"start_date";s:4:"type";s:3:"int";s:6:"length";s:2:"11";s:7:"notnull";s:1:"1";}i:7;a:5:{s:4:"name";s:10:"starter_id";s:4:"type";s:3:"int";s:6:"length";s:2:"11";s:7:"notnull";s:1:"1";s:5:"index";s:1:"1";}i:8;a:5:{s:4:"name";s:12:"starter_name";s:4:"type";s:7:"varchar";s:6:"length";s:3:"255";s:7:"default";s:0:"";s:7:"notnull";s:1:"1";}i:9;a:4:{s:4:"name";s:9:"last_post";s:4:"type";s:3:"int";s:6:"length";s:2:"11";s:7:"notnull";s:1:"1";}i:10;a:4:{s:4:"name";s:14:"last_poster_id";s:4:"type";s:3:"int";s:6:"length";s:2:"11";s:7:"notnull";s:1:"1";}i:11;a:5:{s:4:"name";s:16:"last_poster_name";s:4:"type";s:7:"varchar";s:6:"length";s:3:"255";s:7:"default";s:0:"";s:7:"notnull";s:1:"1";}i:12;a:5:{s:4:"name";s:9:"uniq_code";s:4:"type";s:4:"char";s:6:"length";s:2:"12";s:7:"notnull";s:1:"1";s:5:"index";s:1:"1";}i:13;a:5:{s:4:"name";s:12:"close_topics";s:4:"type";s:3:"int";s:6:"length";s:1:"1";s:7:"default";s:1:"0";s:7:"notnull";b:1;}i:14;a:5:{s:4:"name";s:5:"stick";s:4:"type";s:3:"int";s:6:"length";s:1:"1";s:7:"default";s:1:"0";s:7:"notnull";b:1;}i:15;a:5:{s:4:"name";s:6:"delete";s:4:"type";s:3:"int";s:6:"length";s:1:"1";s:7:"default";s:1:"0";s:7:"notnull";b:1;}}}';
$table_forums = 'a:6:{s:7:"counter";i:5;s:8:"num_rows";i:3;s:4:"name";s:6:"forums";s:4:"size";i:3159;s:4:"cols";a:21:{i:0;a:6:{s:4:"name";s:2:"id";s:4:"type";s:3:"int";s:6:"length";s:2:"11";s:7:"notnull";s:1:"1";s:14:"auto_increment";s:1:"1";s:7:"primary";s:1:"1";}i:1;a:5:{s:4:"name";s:9:"parent_id";s:4:"type";s:3:"int";s:6:"length";s:2:"11";s:7:"notnull";s:1:"1";s:5:"index";s:1:"1";}i:2;a:5:{s:4:"name";s:5:"title";s:4:"type";s:7:"varchar";s:6:"length";s:3:"255";s:7:"default";s:0:"";s:7:"notnull";s:1:"1";}i:3;a:3:{s:4:"name";s:11:"description";s:4:"type";s:4:"text";s:7:"notnull";s:1:"1";}i:4;a:4:{s:4:"name";s:6:"topics";s:4:"type";s:3:"int";s:6:"length";s:2:"11";s:7:"notnull";s:1:"1";}i:5;a:4:{s:4:"name";s:5:"posts";s:4:"type";s:3:"int";s:6:"length";s:2:"11";s:7:"notnull";s:1:"1";}i:6;a:4:{s:4:"name";s:9:"last_post";s:4:"type";s:3:"int";s:6:"length";s:2:"11";s:7:"notnull";s:1:"1";}i:7;a:4:{s:4:"name";s:14:"last_poster_id";s:4:"type";s:3:"int";s:6:"length";s:2:"11";s:7:"notnull";s:1:"1";}i:8;a:5:{s:4:"name";s:16:"last_poster_name";s:4:"type";s:7:"varchar";s:6:"length";s:3:"255";s:7:"default";s:0:"";s:7:"notnull";s:1:"1";}i:9;a:5:{s:4:"name";s:10:"last_title";s:4:"type";s:7:"varchar";s:6:"length";s:3:"255";s:7:"default";s:0:"";s:7:"notnull";s:1:"1";}i:10;a:4:{s:4:"name";s:7:"last_id";s:4:"type";s:3:"int";s:6:"length";s:2:"11";s:7:"notnull";s:1:"1";}i:11;a:5:{s:4:"name";s:5:"order";s:4:"type";s:3:"int";s:6:"length";s:2:"11";s:7:"notnull";s:1:"1";s:5:"index";s:1:"1";}i:12;a:5:{s:4:"name";s:6:"status";s:4:"type";s:3:"int";s:6:"length";s:1:"1";s:7:"notnull";s:1:"1";s:5:"index";s:1:"1";}i:13;a:4:{s:4:"name";s:4:"view";s:4:"type";s:3:"int";s:6:"length";s:1:"1";s:7:"notnull";s:1:"1";}i:14;a:5:{s:4:"name";s:15:"admin_theme_add";s:4:"type";s:3:"int";s:6:"length";s:1:"1";s:7:"default";s:1:"0";s:7:"notnull";b:1;}i:15;a:5:{s:4:"name";s:13:"no_link_guest";s:4:"type";s:3:"int";s:6:"length";s:1:"1";s:7:"default";s:1:"0";s:7:"notnull";b:1;}i:16;a:5:{s:4:"name";s:17:"new_message_email";s:4:"type";s:3:"int";s:6:"length";s:1:"1";s:7:"default";s:1:"0";s:7:"notnull";b:1;}i:17;a:5:{s:4:"name";s:11:"rang_access";s:4:"type";s:3:"int";s:6:"length";s:2:"11";s:7:"default";s:1:"0";s:7:"notnull";b:1;}i:18;a:5:{s:4:"name";s:12:"rang_message";s:4:"type";s:3:"int";s:6:"length";s:2:"11";s:7:"default";s:1:"0";s:7:"notnull";b:1;}i:19;a:5:{s:4:"name";s:14:"rang_add_theme";s:4:"type";s:3:"int";s:6:"length";s:2:"11";s:7:"default";s:1:"0";s:7:"notnull";b:1;}i:20;a:5:{s:4:"name";s:11:"close_topic";s:4:"type";s:3:"int";s:6:"length";s:1:"1";s:7:"default";s:1:"0";s:7:"notnull";b:1;}}s:4:"type";s:6:"MyISAM";}';
$table_forum_online = 'a:7:{s:7:"counter";i:1338127624;s:8:"num_rows";i:1;s:4:"cols";a:7:{i:0;a:6:{s:4:"name";s:4:"time";s:4:"type";s:3:"int";s:6:"length";i:11;s:7:"notnull";b:1;s:14:"auto_increment";b:1;s:7:"primary";b:1;}i:1;a:4:{s:4:"name";s:7:"user_id";s:4:"type";s:3:"int";s:6:"length";i:11;s:7:"notnull";b:1;}i:2;a:5:{s:4:"name";s:9:"user_name";s:4:"type";s:7:"varchar";s:6:"length";i:255;s:7:"default";s:0:"";s:7:"notnull";b:1;}i:3;a:4:{s:4:"name";s:10:"user_level";s:4:"type";s:3:"int";s:6:"length";i:11;s:7:"notnull";b:1;}i:4;a:4:{s:4:"name";s:7:"user_ip";s:4:"type";s:7:"varchar";s:6:"length";i:255;s:7:"notnull";b:1;}i:5;a:3:{s:4:"name";s:9:"forum_cat";s:4:"type";s:4:"text";s:7:"notnull";b:1;}i:6;a:4:{s:4:"name";s:11:"forum_topic";s:4:"type";s:3:"int";s:6:"length";i:11;s:7:"notnull";b:1;}}s:7:"comment";s:0:"";s:4:"type";s:6:"MYISAM";s:4:"size";i:1001;s:4:"name";s:12:"forum_online";}';
$db = System::database();
$db->CreateTable('forum_basket_post', unserialize($table_forum_basket_post));
$db->CreateTable('forum_basket_topics', unserialize($table_forum_basket_topics));
$db->CreateTable('forum_posts', unserialize($table_forum_posts));
$db->CreateTable('forum_subscription', unserialize($table_forum_subscription));
$db->CreateTable('forum_topics_read', unserialize($table_forum_topics_read));
$db->CreateTable('forum_topics', unserialize($table_forum_topics));
$db->CreateTable('forums', unserialize($table_forums));
$db->CreateTable('forum_online', unserialize($table_forum_online));
// Конфигурация
$group = AddConfigGroup('forum', 'Форум');
AddConfig($group, 'topics_on_page', 'Количество тем на страницу', '10', '', true, 'edit:w60px', '3,int,false');
AddConfig($group, 'posts_on_page', 'Количество сообщений на страницу', '10', '', true, 'edit:w60px', '3,int,false');
AddConfig($group, 'basket', 'Использовать удаление через "корзину"', '1', 'Если Да - то удаляемые темы и сообщения будут перемещаться в "корзину" и только после указанного в настройках кол-ва дней будут удаляться без возможности восстановления.', true, 'combo', '1,bool,false', '1:Да,0:Нет');
AddConfig($group, 'clear_basket_day', 'Автоочистка корзины', '7', 'Через сколько дней удалять без возможности восстановления темы и сообщения из "корзины".', true, 'edit:w60px', '11,int,false');
AddConfig($group, 'max_word_length', 'Максимальная длина слова', '80', 'При превышении - слово будет разделено тегом BR. 0 - длина слова не ограничена.', true, 'edit:w60px', '11,int,false');
AddConfig($group, 'del_auto_time', 'Последний запуск чистки корзины форума', '0');
// Пункты за сообщения на форуме
AddPointsConfig('forum_post', 'Сообщение на форуме', '', '5');
// Доступ
AddAccessRestriction('forum', 'forum', 'Форум');
// Модуль
ExtAddModule('Форум', 'forum');
// Добавляем пункт меню
AdminMenuAddModule('Форум', 'forum');