Merge pull request #227 from TheSerapher/issue-226
Adding support for post time and author
This commit is contained in:
commit
ee427a2650
@ -8,7 +8,6 @@ require_once(INCLUDE_DIR . '/database.inc.php');
|
|||||||
require_once(INCLUDE_DIR . '/smarty.inc.php');
|
require_once(INCLUDE_DIR . '/smarty.inc.php');
|
||||||
// Load classes that need the above as dependencies
|
// Load classes that need the above as dependencies
|
||||||
require_once(CLASS_DIR . '/base.class.php');
|
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 . '/block.class.php');
|
||||||
require_once(CLASS_DIR . '/user.class.php');
|
require_once(CLASS_DIR . '/user.class.php');
|
||||||
require_once(CLASS_DIR . '/share.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 . '/setting.class.php');
|
||||||
require_once(CLASS_DIR . '/mail.class.php');
|
require_once(CLASS_DIR . '/mail.class.php');
|
||||||
require_once(CLASS_DIR . '/notification.class.php');
|
require_once(CLASS_DIR . '/notification.class.php');
|
||||||
|
require_once(CLASS_DIR . '/news.class.php');
|
||||||
require_once(INCLUDE_DIR . '/lib/Michelf/Markdown.php');
|
require_once(INCLUDE_DIR . '/lib/Michelf/Markdown.php');
|
||||||
|
|||||||
@ -23,7 +23,7 @@ class News extends Base {
|
|||||||
**/
|
**/
|
||||||
public function getAllActive() {
|
public function getAllActive() {
|
||||||
$this->debug->append("STA " . __METHOD__, 4);
|
$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())
|
if ($stmt && $stmt->execute() && $result = $stmt->get_result())
|
||||||
return $result->fetch_all(MYSQLI_ASSOC);
|
return $result->fetch_all(MYSQLI_ASSOC);
|
||||||
// Catchall
|
// Catchall
|
||||||
@ -35,7 +35,7 @@ class News extends Base {
|
|||||||
**/
|
**/
|
||||||
public function getAll() {
|
public function getAll() {
|
||||||
$this->debug->append("STA " . __METHOD__, 4);
|
$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())
|
if ($stmt && $stmt->execute() && $result = $stmt->get_result())
|
||||||
return $result->fetch_all(MYSQLI_ASSOC);
|
return $result->fetch_all(MYSQLI_ASSOC);
|
||||||
// Catchall
|
// Catchall
|
||||||
@ -98,5 +98,5 @@ class News extends Base {
|
|||||||
$news = new News();
|
$news = new News();
|
||||||
$news->setDebug($debug);
|
$news->setDebug($debug);
|
||||||
$news->setMysql($mysqli);
|
$news->setMysql($mysqli);
|
||||||
|
$news->setUser($user);
|
||||||
?>
|
?>
|
||||||
|
|||||||
@ -20,7 +20,7 @@
|
|||||||
{section name=news loop=$NEWS}
|
{section name=news loop=$NEWS}
|
||||||
{include
|
{include
|
||||||
file="global/block_header.tpl"
|
file="global/block_header.tpl"
|
||||||
BLOCK_HEADER="{$NEWS[news].header}"
|
BLOCK_HEADER="{$NEWS[news].header} posted {$NEWS[news].time} by {$NEWS[news].author}"
|
||||||
BUTTONS="
|
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=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>
|
<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}
|
{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}
|
{$NEWS[news].content}
|
||||||
{include file="global/block_footer.tpl"}
|
{include file="global/block_footer.tpl"}
|
||||||
{/section}
|
{/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,
|
`account_id` int(10) unsigned NOT NULL,
|
||||||
`header` varchar(255) NOT NULL,
|
`header` varchar(255) NOT NULL,
|
||||||
`content` text NOT NULL,
|
`content` text NOT NULL,
|
||||||
|
`time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
`active` tinyint(1) NOT NULL DEFAULT '0',
|
`active` tinyint(1) NOT NULL DEFAULT '0',
|
||||||
PRIMARY KEY (`id`)
|
PRIMARY KEY (`id`)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user