Adding support for post time and author
* Added new SQL upgrade and structure * Added post time and author to admin panel * Added post time and author to news list Fixes #226
This commit is contained in:
parent
4d09b5e6a6
commit
84ababe9f7
@ -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');
|
||||
|
||||
@ -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);
|
||||
?>
|
||||
|
||||
@ -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="
|
||||
<a href='{$smarty.server.PHP_SELF}?page={$smarty.request.page}&action=news_edit&id={$NEWS[news].id}'>Edit</a>
|
||||
<a href='{$smarty.server.PHP_SELF}?page={$smarty.request.page}&action={$smarty.request.action}&do=delete&id={$NEWS[news].id}'>Delete</a>
|
||||
|
||||
@ -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}
|
||||
|
||||
1
sql/issue_226_news_upgrade.sql
Normal file
1
sql/issue_226_news_upgrade.sql
Normal file
@ -0,0 +1 @@
|
||||
ALTER TABLE `news` ADD `time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP AFTER `content` ;
|
||||
@ -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;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user