diff --git a/public/include/autoloader.inc.php b/public/include/autoloader.inc.php
index 23ab4556..51b9b815 100644
--- a/public/include/autoloader.inc.php
+++ b/public/include/autoloader.inc.php
@@ -8,7 +8,6 @@ require_once(INCLUDE_DIR . '/database.inc.php');
require_once(INCLUDE_DIR . '/smarty.inc.php');
// Load classes that need the above as dependencies
require_once(CLASS_DIR . '/base.class.php');
-require_once(CLASS_DIR . '/news.class.php');
require_once(CLASS_DIR . '/block.class.php');
require_once(CLASS_DIR . '/user.class.php');
require_once(CLASS_DIR . '/share.class.php');
@@ -18,4 +17,5 @@ require_once(CLASS_DIR . '/transaction.class.php');
require_once(CLASS_DIR . '/setting.class.php');
require_once(CLASS_DIR . '/mail.class.php');
require_once(CLASS_DIR . '/notification.class.php');
+require_once(CLASS_DIR . '/news.class.php');
require_once(INCLUDE_DIR . '/lib/Michelf/Markdown.php');
diff --git a/public/include/classes/news.class.php b/public/include/classes/news.class.php
index 5e90ad84..61762a27 100644
--- a/public/include/classes/news.class.php
+++ b/public/include/classes/news.class.php
@@ -23,7 +23,7 @@ class News extends Base {
**/
public function getAllActive() {
$this->debug->append("STA " . __METHOD__, 4);
- $stmt = $this->mysqli->prepare("SELECT * FROM $this->table WHERE active = 1");
+ $stmt = $this->mysqli->prepare("SELECT n.*, a.username AS author FROM $this->table AS n LEFT JOIN " . $this->user->getTableName() . " AS a ON a.id = n.account_id WHERE active = 1");
if ($stmt && $stmt->execute() && $result = $stmt->get_result())
return $result->fetch_all(MYSQLI_ASSOC);
// Catchall
@@ -35,7 +35,7 @@ class News extends Base {
**/
public function getAll() {
$this->debug->append("STA " . __METHOD__, 4);
- $stmt = $this->mysqli->prepare("SELECT * FROM $this->table");
+ $stmt = $this->mysqli->prepare("SELECT n.*, a.username AS author FROM $this->table AS n LEFT JOIN " . $this->user->getTableName() . " AS a ON a.id = n.account_id");
if ($stmt && $stmt->execute() && $result = $stmt->get_result())
return $result->fetch_all(MYSQLI_ASSOC);
// Catchall
@@ -98,5 +98,5 @@ class News extends Base {
$news = new News();
$news->setDebug($debug);
$news->setMysql($mysqli);
-
+$news->setUser($user);
?>
diff --git a/public/templates/mmcFE/admin/news/default.tpl b/public/templates/mmcFE/admin/news/default.tpl
index fb3f3ced..7bd8c198 100644
--- a/public/templates/mmcFE/admin/news/default.tpl
+++ b/public/templates/mmcFE/admin/news/default.tpl
@@ -20,7 +20,7 @@
{section name=news loop=$NEWS}
{include
file="global/block_header.tpl"
- BLOCK_HEADER="{$NEWS[news].header}"
+ BLOCK_HEADER="{$NEWS[news].header} posted {$NEWS[news].time} by {$NEWS[news].author}"
BUTTONS="
Edit
Delete
diff --git a/public/templates/mmcFE/news/default.tpl b/public/templates/mmcFE/news/default.tpl
index d4c65d27..a54859db 100644
--- a/public/templates/mmcFE/news/default.tpl
+++ b/public/templates/mmcFE/news/default.tpl
@@ -1,5 +1,5 @@
{section name=news loop=$NEWS}
- {include file="global/block_header.tpl" BLOCK_HEADER="{$NEWS[news].header}"}
+ {include file="global/block_header.tpl" BLOCK_HEADER="{$NEWS[news].header} posted {$NEWS[news].time} by {$NEWS[news].author}"}
{$NEWS[news].content}
{include file="global/block_footer.tpl"}
{/section}
diff --git a/sql/issue_226_news_upgrade.sql b/sql/issue_226_news_upgrade.sql
new file mode 100644
index 00000000..dabc48bb
--- /dev/null
+++ b/sql/issue_226_news_upgrade.sql
@@ -0,0 +1 @@
+ALTER TABLE `news` ADD `time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP AFTER `content` ;
diff --git a/sql/mmcfe_ng_structure.sql b/sql/mmcfe_ng_structure.sql
index b8ab2c22..cb39ed51 100644
--- a/sql/mmcfe_ng_structure.sql
+++ b/sql/mmcfe_ng_structure.sql
@@ -51,6 +51,7 @@ CREATE TABLE IF NOT EXISTS `news` (
`account_id` int(10) unsigned NOT NULL,
`header` varchar(255) NOT NULL,
`content` text NOT NULL,
+ `time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`active` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;