public function install() { load_textdomain('private_messages', dirname(__FILE__) . '/lang/' . $this->feather->forum_settings['o_default_lang'] . '/private-messages.mo'); $database_scheme = array('pms_data' => "CREATE TABLE IF NOT EXISTS %t% (\n `conversation_id` int(10) unsigned NOT NULL,\n `user_id` int(10) unsigned NOT NULL DEFAULT '0',\n `deleted` tinyint(1) unsigned NOT NULL DEFAULT '0',\n `viewed` tinyint(1) unsigned NOT NULL DEFAULT '0',\n `folder_id` int(10) unsigned NOT NULL DEFAULT '2',\n PRIMARY KEY (`conversation_id`, `user_id`),\n KEY `folder_idx` (`folder_id`)\n ) ENGINE=InnoDB DEFAULT CHARSET=utf8;", 'pms_folders' => "CREATE TABLE IF NOT EXISTS %t% (\n `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n `name` varchar(80) NOT NULL DEFAULT 'New Folder',\n `user_id` int(10) unsigned NOT NULL DEFAULT '0',\n PRIMARY KEY (`id`),\n KEY `user_idx` (`user_id`)\n ) ENGINE=InnoDB DEFAULT CHARSET=utf8;", 'pms_messages' => "CREATE TABLE IF NOT EXISTS %t% (\n `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n `poster` varchar(200) NOT NULL DEFAULT '',\n `poster_id` int(10) unsigned NOT NULL DEFAULT '1',\n `poster_ip` varchar(39) DEFAULT NULL,\n `message` mediumtext,\n `hide_smilies` tinyint(1) NOT NULL DEFAULT '0',\n `sent` int(10) unsigned NOT NULL DEFAULT '0',\n `edited` int(10) unsigned DEFAULT NULL,\n `edited_by` varchar(200) DEFAULT NULL,\n `conversation_id` int(10) unsigned NOT NULL DEFAULT '0',\n PRIMARY KEY (`id`),\n KEY `conversation_idx` (`conversation_id`)\n ) ENGINE=InnoDB DEFAULT CHARSET=utf8;", 'pms_conversations' => "CREATE TABLE IF NOT EXISTS %t% (\n `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n `poster` varchar(200) NOT NULL DEFAULT '',\n `poster_id` int(10) unsigned NOT NULL DEFAULT '0',\n `subject` varchar(255) NOT NULL DEFAULT '',\n `first_post_id` int(10) unsigned NOT NULL DEFAULT '0',\n `last_post_id` int(10) unsigned NOT NULL DEFAULT '0',\n `last_post` int(10) unsigned NOT NULL DEFAULT '0',\n `last_poster` varchar(200) DEFAULT NULL,\n `num_replies` mediumint(8) unsigned NOT NULL DEFAULT '0',\n PRIMARY KEY (`id`)\n ) ENGINE=InnoDB DEFAULT CHARSET=utf8;", 'pms_blocks' => "CREATE TABLE `%t%` (\n `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n `user_id` int(10) NOT NULL DEFAULT '0',\n `block_id` int(10) NOT NULL DEFAULT '0',\n PRIMARY KEY (`id`)\n ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"); // Create tables $installer = new \FeatherBB\Model\Install(); foreach ($database_scheme as $table => $sql) { $installer->create_table($this->feather->forum_settings['db_prefix'] . $table, $sql); } // Create default inboxes $folders = array(__('New', 'private_messages'), __('Inbox', 'private_messages'), __('Archived', 'private_messages')); foreach ($folders as $folder) { $insert = array('name' => $folder, 'user_id' => 1); $installer->add_data('pms_folders', $insert); } }
public function install() { translate('private_messages', 'private-messages', ForumSettings::get('o_default_lang')); $database_scheme = array('pms_data' => "CREATE TABLE IF NOT EXISTS %t% (\n `conversation_id` int(10) unsigned NOT NULL,\n `user_id` int(10) unsigned NOT NULL DEFAULT '0',\n `deleted` tinyint(1) unsigned NOT NULL DEFAULT '0',\n `viewed` tinyint(1) unsigned NOT NULL DEFAULT '0',\n `folder_id` int(10) unsigned NOT NULL DEFAULT '2',\n PRIMARY KEY (`conversation_id`, `user_id`),\n KEY `folder_idx` (`folder_id`)\n ) ENGINE=InnoDB DEFAULT CHARSET=utf8;", 'pms_folders' => "CREATE TABLE IF NOT EXISTS %t% (\n `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n `name` varchar(80) NOT NULL DEFAULT 'New Folder',\n `user_id` int(10) unsigned NOT NULL DEFAULT '0',\n PRIMARY KEY (`id`),\n KEY `user_idx` (`user_id`)\n ) ENGINE=InnoDB DEFAULT CHARSET=utf8;", 'pms_messages' => "CREATE TABLE IF NOT EXISTS %t% (\n `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n `poster` varchar(200) NOT NULL DEFAULT '',\n `poster_id` int(10) unsigned NOT NULL DEFAULT '1',\n `poster_ip` varchar(39) DEFAULT NULL,\n `message` mediumtext,\n `hide_smilies` tinyint(1) NOT NULL DEFAULT '0',\n `sent` int(10) unsigned NOT NULL DEFAULT '0',\n `edited` int(10) unsigned DEFAULT NULL,\n `edited_by` varchar(200) DEFAULT NULL,\n `conversation_id` int(10) unsigned NOT NULL DEFAULT '0',\n PRIMARY KEY (`id`),\n KEY `conversation_idx` (`conversation_id`)\n ) ENGINE=InnoDB DEFAULT CHARSET=utf8;", 'pms_conversations' => "CREATE TABLE IF NOT EXISTS %t% (\n `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n `poster` varchar(200) NOT NULL DEFAULT '',\n `poster_id` int(10) unsigned NOT NULL DEFAULT '0',\n `subject` varchar(255) NOT NULL DEFAULT '',\n `first_post_id` int(10) unsigned NOT NULL DEFAULT '0',\n `last_post_id` int(10) unsigned NOT NULL DEFAULT '0',\n `last_post` int(10) unsigned NOT NULL DEFAULT '0',\n `last_poster` varchar(200) DEFAULT NULL,\n `num_replies` mediumint(8) unsigned NOT NULL DEFAULT '0',\n PRIMARY KEY (`id`)\n ) ENGINE=InnoDB DEFAULT CHARSET=utf8;", 'pms_blocks' => "CREATE TABLE IF NOT EXISTS %t% (\n `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n `user_id` int(10) NOT NULL DEFAULT '0',\n `block_id` int(10) NOT NULL DEFAULT '0',\n PRIMARY KEY (`id`)\n ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"); // Create tables $installer = new \FeatherBB\Model\Install(); foreach ($database_scheme as $table => $sql) { $installer->create_table(ForumSettings::get('db_prefix') . $table, $sql); } DB::for_table('groups')->raw_execute('ALTER TABLE ' . ForumSettings::get('db_prefix') . 'groups ADD `g_pm_limit` smallint(3) NOT NULL DEFAULT \'0\''); DB::for_table('groups')->raw_execute('ALTER TABLE ' . ForumSettings::get('db_prefix') . 'groups ADD `g_use_pm` tinyint(1) NOT NULL DEFAULT \'0\''); DB::for_table('groups')->raw_execute('ALTER TABLE ' . ForumSettings::get('db_prefix') . 'groups ADD `g_pm_folder_limit` int(3) NOT NULL DEFAULT \'0\''); // Create default inboxes $folders = array(__('New', 'private_messages'), __('Inbox', 'private_messages'), __('Archived', 'private_messages')); foreach ($folders as $folder) { $insert = array('name' => $folder, 'user_id' => 1); $installer->add_data('pms_folders', $insert); } }