Zitat geschrieben von
Outi77Ich hatte Dir ja auch keine Absicht unterstellt...
Hatte ich auch nicht als Unterstellung verstanden. Sorry wenn ich etwas forsch rüber gekommen bin.
Zitat geschrieben von
Nex4TBitte einmal die Config.php und als weiteren test die Topic.php im mappers ordner vom Forum Posten.
Hier bitte...
<?php
$config = [
"dbEngine" => "Mysql",
"dbHost" => "localhost",
"dbUser" => "DBUser",
"dbPassword" => "DBPass",
"dbName" => "c1ilchrs",
"dbPrefix" => "rs_"
];
<?php
/**
* @copyright Ilch 2.0
* @package ilch
*/
namespace Modules\Forum\Config;
class Config extends \Ilch\Config\Install
{
const EVENT_SAVETOPIC_BEFORE = 'forum_saveTopic_before';
const EVENT_SAVETOPIC_AFTER = 'forum_saveTopic_after';
const EVENT_ADDTOPIC_AFTER = 'forum_addTopic_after';
const EVENT_SAVEPOST_BEFORE = 'forum_savePost_before';
const EVENT_SAVEPOST_AFTER = 'forum_savePost_after';
const EVENT_ADDPOST_AFTER = 'forum_addPost_after';
const EVENT_DELETEPOST_BEFORE = 'forum_deletePost_before';
const EVENT_DELETEPOST_AFTER = 'forum_deletePost_after';
const EVENT_DELETETOPIC_BEFORE = 'forum_deleteTopic_before';
const EVENT_DELETETOPIC_AFTER = 'forum_deleteTopic_after';
public $config = [
'key' => 'forum',
'version' => '1.15.0',
'icon_small' => 'fa-list',
'author' => 'Stantin Thomas',
'link' => 'http://ilch.de',
'official' => true,
'languages' => [
'de_DE' => [
'name' => 'Forum',
'description' => 'Hier kann das Forum verwaltet werden.',
],
'en_EN' => [
'name' => 'Forum',
'description' => 'Here you can manage the forum.',
],
],
'boxes' => [
'forum' => [
'de_DE' => [
'name' => 'Forum'
],
'en_EN' => [
'name' => 'Forum'
]
]
],
'ilchCore' => '2.1.20',
'phpVersion' => '5.6'
];
public function install()
{
$this->db()->queryMulti($this->getInstallSql());
$databaseConfig = new \Ilch\Config\Database($this->db());
$databaseConfig->set('forum_floodInterval', '0');
$databaseConfig->set('forum_excludeFloodProtection', '1');
$databaseConfig->set('forum_postVoting', '0');
}
public function uninstall()
{
$this->db()->queryMulti('DROP TABLE `[prefix]_forum_topics`;
DROP TABLE `[prefix]_forum_items`;
DROP TABLE `[prefix]_forum_posts`;
DROP TABLE `[prefix]_forum_ranks`');
}
public function getInstallSql()
{
return 'CREATE TABLE IF NOT EXISTS `[prefix]_forum_items` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`sort` INT(11) NOT NULL DEFAULT 0,
`parent_id` INT(11) NOT NULL DEFAULT 0,
`type` TINYINT(1) NOT NULL,
`title` VARCHAR(255) NOT NULL,
`description` VARCHAR(255) NOT NULL,
`prefix` VARCHAR(255) NOT NULL,
`read_access` VARCHAR(255) NOT NULL,
`replay_access` VARCHAR(255) NOT NULL,
`create_access` VARCHAR(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci AUTO_INCREMENT=1;
CREATE TABLE IF NOT EXISTS `[prefix]_forum_topics` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`topic_id` INT(11) NOT NULL,
`topic_prefix` INT(11) NOT NULL DEFAULT 0,
`topic_title` VARCHAR(255) NOT NULL,
`visits` INT(11) NOT NULL DEFAULT 0,
`creator_id` INT(10) NOT NULL,
`date_created` DATETIME NOT NULL,
`forum_id` INT(11) NOT NULL,
`type` TINYINT(1) NOT NULL DEFAULT 0,
`status` TINYINT(1) NOT NULL DEFAULT 0,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci AUTO_INCREMENT=1;
CREATE TABLE IF NOT EXISTS `[prefix]_forum_posts` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`topic_id` VARCHAR(150) NOT NULL,
`text` TEXT NOT NULL,
`visits` INT(11) NOT NULL DEFAULT 0,
`votes` LONGTEXT NOT NULL,
`user_id` INT(10) NOT NULL,
`date_created` DATETIME NOT NULL,
`forum_id` INT(11) NOT NULL DEFAULT 0,
`read` VARCHAR(255) NOT NULL DEFAULT \'\',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci AUTO_INCREMENT=1;
CREATE TABLE IF NOT EXISTS `[prefix]_forum_ranks` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`title` TEXT NOT NULL,
`posts` INT(11) NOT NULL DEFAULT 0,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci AUTO_INCREMENT=1;
INSERT INTO `[prefix]_forum_items` (`id`, `sort`, `parent_id`, `type`, `title`, `description`, `read_access`, `replay_access`, `create_access`) VALUES
(1, 0, 0, 0, "Meine Kategorie", "Meine erste Kategorie", "", "", ""),
(2, 10, 1, 1, "Mein Forum", "Mein erstes Forum", "2,3", 2, 2);
INSERT INTO `[prefix]_forum_topics` (`id`, `topic_id`, `topic_title`, `creator_id`, `date_created`, `forum_id`) VALUES
(1, 2, "Willkommen bei Ilch!", 0, NOW(), 2);
INSERT INTO `[prefix]_forum_posts` (`id`, `topic_id`, `text`, `user_id`, `date_created`, `forum_id`) VALUES
(1, 1, "Willkommen im Ilch 2.0 Forum!\n\nBei Fragen oder Probleme im [url=http://www.ilch.de/forum.html]Ilch Forum[/url] melden.<br /><br />Viel Erfolg<br />Ilch", 0, NOW(), 2);
INSERT INTO `[prefix]_forum_ranks` (`id`, `title`, `posts`) VALUES
(1, "Grünschnabel", 0),
(2, "Jungspund", 25),
(3, "Mitglied", 50),
(4, "Eroberer", 75),
(5, "Doppel-As", 150),
(6, "Tripel-As", 250),
(7, "Haudegen", 500),
(8, "Routinier", 1000),
(9, "König", 2000),
(10, "Kaiser", 5000),
(11, "Legende", 7000),
(12, "Foren Gott", 10000);';
}
public function getUpdate($installedVersion)
{
//Workaround to fix 1.1 and 1.10 being considered equal.
if ($installedVersion == "1.10") {
$installedVersion = "1.10.0";
}
switch ($installedVersion) {
case "1.0":
case "1.1":
case "1.2":
case "1.3":
$this->db()->query('ALTER TABLE `[prefix]_forum_items` DROP COLUMN `forum_id`;');
$this->db()->queryMulti('CREATE TABLE IF NOT EXISTS `[prefix]_forum_ranks` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`title` TEXT NOT NULL,
`posts` INT(11) NOT NULL DEFAULT 0,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
INSERT INTO `[prefix]_forum_ranks` (`id`, `title`, `posts`) VALUES
(1, "Grünschnabel", 0),
(2, "Jungspund", 25),
(3, "Mitglied", 50),
(4, "Eroberer", 75),
(5, "Doppel-As", 150),
(6, "Tripel-As", 250),
(7, "Haudegen", 500),
(8, "Routinier", 1000),
(9, "König", 2000),
(10, "Kaiser", 5000),
(11, "Legende", 7000),
(12, "Foren Gott", 10000);');
case "1.4":
case "1.5":
case "1.6":
case "1.7":
$databaseConfig = new \Ilch\Config\Database($this->db());
$databaseConfig->set('forum_postVoting', '0');
$this->db()->query('ALTER TABLE `[prefix]_forum_posts` ADD COLUMN `votes` LONGTEXT NOT NULL AFTER `visits`;');
case "1.8":
if (!$this->db()->ifColumnExists('[prefix]_forum_posts', 'votes')) {
$this->db()->query('ALTER TABLE `[prefix]_forum_posts` ADD COLUMN `votes` LONGTEXT NOT NULL AFTER `visits`;');
}
case "1.9":
$databaseConfig = new \Ilch\Config\Database($this->db());
$databaseConfig->set('forum_floodInterval', '0');
$databaseConfig->set('forum_excludeFloodProtection', '1');
case "1.10.0":
// Convert tables to new character set and collate
$this->db()->query('ALTER TABLE `[prefix]_forum_items` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
$this->db()->query('ALTER TABLE `[prefix]_forum_topics` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
$this->db()->query('ALTER TABLE `[prefix]_forum_posts` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
$this->db()->query('ALTER TABLE `[prefix]_forum_ranks` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
// Delete no longer needed file.
unlink(ROOT_PATH.'/application/modules/forum/controllers/admin/Base.php');
}
}
}
<?php
/**
* @copyright Ilch 2.0
* @package ilch
*/
namespace Modules\Forum\Mappers;
use Modules\Forum\Models\ForumTopic as TopicModel;
use Modules\User\Mappers\User as UserMapper;
use Modules\Forum\Models\ForumPost as PostModel;
use Modules\Forum\Mappers\Post as PostMapper;
use Modules\Forum\Config\Config as ForumConfig;
class Topic extends \Ilch\Mapper
{
public function getTopicsByForumId($id, $pagination = NULL)
{
$sql = 'SELECT SQL_CALC_FOUND_ROWS *
FROM `[prefix]_forum_topics`
WHERE forum_id = '.$id.'
GROUP by type, `id`, `topic_id`, `topic_prefix`, `topic_title`, `visits`, `creator_id`, `date_created`, `forum_id`, `status`
ORDER by type DESC, id DESC';
if (!empty($pagination)) {
$sql .= ' LIMIT '.implode(',',$pagination->getLimit());
$fileArray = $this->db()->queryArray($sql);
$pagination->setRows($this->db()->querycell('SELECT FOUND_ROWS()'));
} else {
$fileArray = $this->db()->queryArray($sql);
}
$entry = [];
$user = null;
$dummyUser = null;
$userCache = [];
foreach ($fileArray as $entries) {
$entryModel = new TopicModel();
$userMapper = new UserMapper();
$entryModel->setId($entries['id']);
$entryModel->setTopicId($id);
$entryModel->setVisits($entries['visits']);
$entryModel->setType($entries['type']);
$entryModel->setStatus($entries['status']);
if (!array_key_exists($entries['creator_id'], $userCache)) {
$user = $userMapper->getUserById($entries['creator_id']);
if ($user) {
$userCache[$entries['creator_id']] = $user;
$entryModel->setAuthor($user);
} else {
if (!$dummyUser) {
$dummyUser = $userMapper->getDummyUser();
}
$entryModel->setAuthor($dummyUser);
}
} else {
$entryModel->setAuthor($userCache[$entries['creator_id']]);
}
$entryModel->setTopicPrefix($entries['topic_prefix']);
$entryModel->setTopicTitle($entries['topic_title']);
$entryModel->setDateCreated($entries['date_created']);
$entry[] = $entryModel;
}
return $entry;
}
public function getTopics($pagination = NULL, $limit = NULL)
{
$sql = 'SELECT SQL_CALC_FOUND_ROWS *
FROM `[prefix]_forum_topics`
GROUP by type, `id`, `topic_id`, `topic_prefix`, `topic_title`, `visits`, `creator_id`, `date_created`, `forum_id`, `status`
ORDER by type DESC, id DESC';
if ($pagination != null) {
$sql .= ' LIMIT '.implode(',',$pagination->getLimit());
} elseif ($limit != null) {
$sql .= ' LIMIT '.$limit;
}
$fileArray = $this->db()->queryArray($sql);
if ($pagination != null) {
$pagination->setRows($this->db()->querycell('SELECT FOUND_ROWS()'));
}
$entry = [];
$user = null;
$dummyUser = null;
$userCache = [];
foreach ($fileArray as $entries) {
$entryModel = new TopicModel();
$userMapper = new UserMapper();
$entryModel->setId($entries['id']);
$entryModel->setForumId($entries['forum_id']);
$entryModel->setTopicId($entries['topic_id']);
$entryModel->setVisits($entries['visits']);
$entryModel->setType($entries['type']);
$entryModel->setStatus($entries['status']);
if (!array_key_exists($entries['creator_id'], $userCache)) {
$user = $userMapper->getUserById($entries['creator_id']);
if ($user) {
$userCache[$entries['creator_id']] = $user;
$entryModel->setAuthor($user);
} else {
if (!$dummyUser) {
$dummyUser = $userMapper->getDummyUser();
}
$entryModel->setAuthor($dummyUser);
}
} else {
$entryModel->setAuthor($userCache[$entries['creator_id']]);
}
$entryModel->setTopicPrefix($entries['topic_prefix']);
$entryModel->setTopicTitle($entries['topic_title']);
$entryModel->setDateCreated($entries['date_created']);
$entry[] = $entryModel;
}
return $entry;
}
public function getPostById($id)
{
$sql = 'SELECT *
FROM `[prefix]_forum_topics`
WHERE id = '.$id;
$fileRow = $this->db()->queryRow($sql);
$entryModel = new TopicModel();
$userMapper = new UserMapper();
$entryModel->setId($fileRow['id']);
$entryModel->setTopicPrefix($fileRow['topic_prefix']);
$entryModel->setTopicTitle($fileRow['topic_title']);
$entryModel->setCreatorId($fileRow['creator_id']);
$entryModel->setVisits($fileRow['visits']);
$user = $userMapper->getUserById($fileRow['creator_id']);
if ($user) {
$entryModel->setAuthor($user);
} else {
$entryModel->setAuthor($userMapper->getDummyUser());
}
$entryModel->setDateCreated($fileRow['date_created']);
$entryModel->setStatus($fileRow['status']);
return $entryModel;
}
public function getLastPostByTopicId($id)
{
$sql = 'SELECT p.id, p.topic_id, p.date_created, p.user_id, p.read
FROM [prefix]_forum_posts as p
WHERE p.topic_id = '.$id.'
ORDER BY p.date_created DESC';
$fileRow = $this->db()->queryRow($sql);
if (empty($fileRow)) {
return null;
}
$entryModel = new PostModel();
$userMapper = new UserMapper();
$entryModel->setId($fileRow['id']);
$user = $userMapper->getUserById($fileRow['user_id']);
if ($user) {
$entryModel->setAutor($user);
} else {
$entryModel->setAutor($userMapper->getDummyUser());
}
$entryModel->setDateCreated($fileRow['date_created']);
$entryModel->setTopicId($fileRow['topic_id']);
$entryModel->setRead($fileRow['read']);
return $entryModel;
}
/**
* Inserts or updates File entry.
*
* @param TopicModel $model
*/
public function save(TopicModel $model)
{
if ($model->getId()) {
$this->db()->update('forum_topics')
->values(['topic_id' => $model->getTopicId(), 'forum_id' => $model->getForumId()])
->where(['id' => $model->getId()])
->execute();
} else {
$this->db()->insert('forum_topics')
->values([
'topic_prefix' => $model->getTopicPrefix(),
'topic_title' => $model->getTopicTitle(),
'topic_id' => $model->getTopicId(),
'forum_id' => $model->getForumId(),
'creator_id' => $model->getCreatorId(),
'type' => $model->getType(),
'date_created' => $model->getDateCreated()
])
->execute();
$this->last_insert_id = $this->db()->getLastInsertId();
}
}
/**
* Updates topic status with given id.
*
* @param integer $id
*/
public function updateStatus($id)
{
$status = (int) $this->db()->select('status')
->from('forum_topics')
->where(['id' => $id])
->execute()
->fetchCell();
$this->db()->update('forum_topics')
->values(['status' => !$status])
->where(['id' => $id])
->execute();
}
/**
* Updates topic type with given id.
*
* @param integer $id
*/
public function updateType($id)
{
$type = (int) $this->db()->select('type')
->from('forum_topics')
->where(['id' => $id])
->execute()
->fetchCell();
$this->db()->update('forum_topics')
->values(['type' => !$type])
->where(['id' => $id])
->execute();
}
/**
* Update specific column of a topic
*
* @param $id
* @param $column
* @param $value
*/
public function update($id, $column, $value) {
$this->db()->update('forum_topics')
->values([$column => $value])
->where(['id' => $id])
->execute();
}
public function getLastInsertId()
{
return $this->last_insert_id;
}
public function getPostByTopicId($id, $pagination = NULL)
{
$sql = 'SELECT SQL_CALC_FOUND_ROWS *
FROM `[prefix]_forum_topics`
WHERE topic_id = '.$id.'
LIMIT '.implode(',',$pagination->getLimit());
$fileArray = $this->db()->queryArray($sql);
$pagination->setRows($this->db()->querycell('SELECT FOUND_ROWS()'));
$entry = [];
foreach ($fileArray as $entries) {
$entryModel = new TopicModel();
$entryModel->setId($entries['id']);
$entryModel->setTopicId($id);
$entryModel->setTopicTitle($entries['topic_title']);
$entry[] = $entryModel;
}
return $entry;
}
/**
* Get x topics with latest activity where x is specifified by the limit.
*
* @param null|integer $limit
* @return array[]
*/
public function getLastActiveTopics($limit = null)
{
$select = $this->db()->select('DISTINCT(p.topic_id)', ['p' => 'forum_posts'])
->join(['t' => 'forum_topics'], 'p.topic_id = t.id', 'LEFT', ['topic_title' => 't.topic_title', 'forum_id' => 't.forum_id'])
->order(['p.id' => 'DESC']);
if ($limit !== null) {
$select->limit($limit);
}
$result = $select->execute();
return $result->fetchRows();
}
public function deleteById($id)
{
$this->trigger(ForumConfig::EVENT_DELETETOPIC_BEFORE, ['id' => $id]);
$postMapper = new PostMapper();
$posts = $postMapper->getPostsByTopicId($id);
foreach ($posts as $post) {
$postMapper->deleteById($post->getId());
}
$this->db()->delete('forum_topics')
->where(['id' => $id])
->execute();
$this->trigger(ForumConfig::EVENT_DELETETOPIC_AFTER, ['id' => $id]);
}
/**
* Updates visits.
*
* @param TopicModel $model
*/
public function saveVisits(TopicModel $model)
{
if ($model->getVisits()) {
$this->db()->update('forum_topics')
->values(['visits' => $model->getVisits()])
->where(['id' => $model->getId()])
->execute();
}
}
}
Diese Dateien wurden von mir nicht editiert. Sollten eigentlich noch immer im Originalzustand sein. Alles andere wie bspw. Gästebuch, Benutzer usw. funktioniert tadellos. Nur das Forum spinnt rum.
Zuletzt modifiziert von X00LA am 31.03.2019 - 14:48:23
Ich mache keine Schreibfehler, das ist ein Feature meiner Tastatur!