1
0
Fork 0
mirror of https://github.com/Oreolek/ifhub.club.git synced 2024-06-26 03:30:48 +03:00

Новое поле у топиков date_publish - дата публикации

This commit is contained in:
Mzhelskiy Maxim 2015-03-27 18:45:43 +07:00
parent e9fbb2db33
commit b41c503d83
12 changed files with 55 additions and 23 deletions

View file

@ -1006,7 +1006,7 @@ class ActionAjax extends Action
return $this->EventErrorDebug();
}
if (!$oTopic->getVote() && ($this->oUserCurrent && $oTopic->getUserId() != $this->oUserCurrent->getId()) && (strtotime($oTopic->getDateAdd()) + Config::Get('acl.vote.topic.limit_time') > time())) {
if (!$oTopic->getVote() && ($this->oUserCurrent && $oTopic->getUserId() != $this->oUserCurrent->getId()) && (strtotime($oTopic->getDatePublish()) + Config::Get('acl.vote.topic.limit_time') > time())) {
return $this->EventErrorDebug();
}

View file

@ -860,7 +860,7 @@ class ActionBlog extends Action
$this->Viewer_SetOpenGraphProperty('og:description', $this->Viewer_GetHtmlDescription());
$this->Viewer_SetOpenGraphProperty('og:url', $oTopic->getUrl());
$this->Viewer_SetOpenGraphProperty('article:author', $oTopic->getUser()->getUserWebPath());
$this->Viewer_SetOpenGraphProperty('article:published_time', date('c', strtotime($oTopic->getDateAdd())));
$this->Viewer_SetOpenGraphProperty('article:published_time', date('c', strtotime($oTopic->getDatePublish())));
if ($sImage = $oTopic->getPreviewImageWebPath(Config::Get('module.topic.default_preview_size'))) {
$this->Viewer_SetOpenGraphProperty('og:image', $sImage);
}

View file

@ -331,7 +331,7 @@ class ActionContent extends Action
$oTopic->setPublish(1);
if ($oTopic->getPublishDraft() == 0) {
$oTopic->setPublishDraft(1);
$oTopic->setDateAdd(date("Y-m-d H:i:s"));
$oTopic->setDatePublish(date("Y-m-d H:i:s"));
$bSendNotify = true;
}
} else {
@ -618,6 +618,7 @@ class ActionContent extends Action
$oTopic->setTextSource(isset($aTopicRequest['topic_text_source']) ? $aTopicRequest['topic_text_source'] : '');
$oTopic->setTags(isset($aTopicRequest['topic_tags']) ? $aTopicRequest['topic_tags'] : '');
$oTopic->setDateAdd(date("Y-m-d H:i:s"));
$oTopic->setDatePublish(date("Y-m-d H:i:s"));
$oTopic->setUserId($this->oUserCurrent->getId());
$oTopic->setType($sType);
$oTopic->setPublish(1);

View file

@ -87,7 +87,7 @@ class ActionRss extends Action
$item['guid'] = $oTopic->getUrl();
$item['link'] = $oTopic->getUrl();
$item['description'] = $this->getTopicText($oTopic);
$item['pubDate'] = $oTopic->getDateAdd();
$item['pubDate'] = $oTopic->getDatePublish();
$item['author'] = $oTopic->getUser()->getLogin();
$item['category'] = htmlspecialchars($oTopic->getTags());
$topics[] = $item;
@ -129,7 +129,7 @@ class ActionRss extends Action
$item['guid'] = $oTopic->getUrl();
$item['link'] = $oTopic->getUrl();
$item['description'] = $this->getTopicText($oTopic);
$item['pubDate'] = $oTopic->getDateAdd();
$item['pubDate'] = $oTopic->getDatePublish();
$item['author'] = $oTopic->getUser()->getLogin();
$item['category'] = htmlspecialchars($oTopic->getTags());
$topics[] = $item;
@ -271,7 +271,7 @@ class ActionRss extends Action
$item['guid'] = $oTopic->getUrl();
$item['link'] = $oTopic->getUrl();
$item['description'] = $this->getTopicText($oTopic);
$item['pubDate'] = $oTopic->getDateAdd();
$item['pubDate'] = $oTopic->getDatePublish();
$item['author'] = $oTopic->getUser()->getLogin();
$item['category'] = htmlspecialchars($oTopic->getTags());
$topics[] = $item;
@ -318,7 +318,7 @@ class ActionRss extends Action
$item['guid'] = $oTopic->getUrl();
$item['link'] = $oTopic->getUrl();
$item['description'] = $this->getTopicText($oTopic);
$item['pubDate'] = $oTopic->getDateAdd();
$item['pubDate'] = $oTopic->getDatePublish();
$item['author'] = $oTopic->getUser()->getLogin();
$item['category'] = htmlspecialchars($oTopic->getTags());
$topics[] = $item;
@ -373,7 +373,7 @@ class ActionRss extends Action
$item['guid'] = $oTopic->getUrl();
$item['link'] = $oTopic->getUrl();
$item['description'] = $this->getTopicText($oTopic);
$item['pubDate'] = $oTopic->getDateAdd();
$item['pubDate'] = $oTopic->getDatePublish();
$item['author'] = $oTopic->getUser()->getLogin();
$item['category'] = htmlspecialchars($oTopic->getTags());
$topics[] = $item;

View file

@ -340,7 +340,7 @@ class ModuleACL extends Module
/**
* Время голосования истекло?
*/
if (strtotime($oTopic->getDateAdd()) <= time() - Config::Get('acl.vote.topic.limit_time')) {
if (strtotime($oTopic->getDatePublish()) <= time() - Config::Get('acl.vote.topic.limit_time')) {
return $that->Lang_Get('vote.notices.error_time');
}
/**
@ -636,7 +636,8 @@ class ModuleACL extends Module
/**
* Проверяем права на просмотр топика
*/
if (!$oTopic->getPublish() and (!$oUser or ($oUser->getId() != $oTopic->getUserId() and !$oUser->isAdministrator()))) {
if ((!$oTopic->getPublish() or $oTopic->getDatePublish() > date('Y-m-d H:i:s'))
and (!$oUser or ($oUser->getId() != $oTopic->getUserId() and !$oUser->isAdministrator()))) {
return false;
}
/**

View file

@ -220,6 +220,9 @@ class ModuleTopic extends Module
*/
public function AddTopic(ModuleTopic_EntityTopic $oTopic)
{
if (!$oTopic->getDatePublish()) {
$oTopic->setDatePublish($oTopic->getDateAdd());
}
if ($sId = $this->oMapperTopic->AddTopic($oTopic)) {
$oTopic->setId($sId);
if ($oTopic->getPublish() and $oTopic->getTags()) {
@ -1858,7 +1861,7 @@ class ModuleTopic extends Module
public function BuildUrlForTopic($oTopic, $bAbsolute = true)
{
$sUrlMask = Config::Get('module.topic.url');
$iDateCreate = strtotime($oTopic->getDateAdd());
$iDateCreate = strtotime($oTopic->getDatePublish());
$aReplace = array(
'%year%' => date("Y", $iDateCreate),
'%month%' => date("m", $iDateCreate),

View file

@ -146,7 +146,7 @@ class ModuleTopic_EntityTopic extends Entity
* Причем не прямую смену url, а через транлитерацию заголовка топика
*/
if ($this->getId()) {
if (strtotime($this->getDateAdd()) < time() - 60 * 60 * 1) {
if (strtotime($this->getDatePublish()) < time() - 60 * 60 * 1) {
/**
* Не меняем url
*/
@ -435,6 +435,16 @@ class ModuleTopic_EntityTopic extends Entity
return $this->_getDataOne('topic_date_edit_content');
}
/**
* Возвращает дату публикации топика
*
* @return string|null
*/
public function getDatePublish()
{
return $this->_getDataOne('topic_date_publish');
}
/**
* Возвращает IP пользователя
*
@ -1110,6 +1120,16 @@ class ModuleTopic_EntityTopic extends Entity
$this->_aData['topic_date_edit_content'] = $data;
}
/**
* Устанавливает дату публикации топика
*
* @param string $data
*/
public function setDatePublish($data)
{
$this->_aData['topic_date_publish'] = $data;
}
/**
* Устанавливает IP пользователя
*

View file

@ -47,6 +47,7 @@ class ModuleTopic_MapperTopic extends Mapper
topic_slug,
topic_tags,
topic_date_add,
topic_date_publish,
topic_user_ip,
topic_publish,
topic_publish_draft,
@ -56,11 +57,11 @@ class ModuleTopic_MapperTopic extends Mapper
topic_forbid_comment,
topic_text_hash
)
VALUES(?d, ?d, ?d, ?d, ?d, ?d, ?, ?, ?, ?, ?, ?, ?d, ?d, ?d, ?d, ?, ?, ?)
VALUES(?d, ?d, ?d, ?d, ?d, ?d, ?, ?, ?, ?, ?, ?, ?, ?d, ?d, ?d, ?d, ?, ?, ?)
";
if ($iId = $this->oDb->query($sql, $oTopic->getBlogId(), $oTopic->getBlogId2(), $oTopic->getBlogId3(),
$oTopic->getBlogId4(), $oTopic->getBlogId5(), $oTopic->getUserId(), $oTopic->getType(), $oTopic->getTitle(), $oTopic->getSlug(),
$oTopic->getTags(), $oTopic->getDateAdd(), $oTopic->getUserIp(), $oTopic->getPublish(),
$oTopic->getTags(), $oTopic->getDateAdd(), $oTopic->getDatePublish(), $oTopic->getUserIp(), $oTopic->getPublish(),
$oTopic->getPublishDraft(), $oTopic->getPublishIndex(), $oTopic->getSkipIndex(), $oTopic->getCutText(),
$oTopic->getForbidComment(), $oTopic->getTextHash())
) {
@ -232,7 +233,7 @@ class ModuleTopic_MapperTopic extends Mapper
$sWhere = $this->buildFilter($aFilter);
if (!isset($aFilter['order'])) {
$aFilter['order'] = 't.topic_date_add desc';
$aFilter['order'] = 't.topic_date_publish desc';
}
if (!is_array($aFilter['order'])) {
$aFilter['order'] = array($aFilter['order']);
@ -380,7 +381,7 @@ class ModuleTopic_MapperTopic extends Mapper
WHERE
t.topic_publish = 1
AND
t.topic_date_add >= ?
t.topic_date_publish >= ?
AND
t.topic_rating >= 0
{ AND t.blog_id NOT IN(?a) }
@ -524,6 +525,7 @@ class ModuleTopic_MapperTopic extends Mapper
topic_date_add = ?,
topic_date_edit = ?,
topic_date_edit_content = ?,
topic_date_publish = ?,
topic_user_ip= ?,
topic_publish= ?d ,
topic_publish_draft= ?d ,
@ -545,7 +547,7 @@ class ModuleTopic_MapperTopic extends Mapper
";
$res = $this->oDb->query($sql, $oTopic->getBlogId(), $oTopic->getBlogId2(), $oTopic->getBlogId3(),
$oTopic->getBlogId4(), $oTopic->getBlogId5(), $oTopic->getTitle(), $oTopic->getSlug(), $oTopic->getTags(),
$oTopic->getDateAdd(), $oTopic->getDateEdit(), $oTopic->getDateEditContent(), $oTopic->getUserIp(),
$oTopic->getDateAdd(), $oTopic->getDateEdit(), $oTopic->getDateEditContent(), $oTopic->getDatePublish(), $oTopic->getUserIp(),
$oTopic->getPublish(), $oTopic->getPublishDraft(), $oTopic->getPublishIndex(), $oTopic->getSkipIndex(),
$oTopic->getRating(), $oTopic->getCountVote(), $oTopic->getCountVoteUp(), $oTopic->getCountVoteDown(),
$oTopic->getCountVoteAbstain(), $oTopic->getCountRead(), $oTopic->getCountComment(),
@ -588,15 +590,16 @@ class ModuleTopic_MapperTopic extends Mapper
*/
protected function buildFilter($aFilter)
{
$sDateNow=date('Y-m-d H:i:s');
$sWhere = '';
if (isset($aFilter['topic_date_more'])) {
$sWhere .= " AND t.topic_date_add > " . $this->oDb->escape($aFilter['topic_date_more']);
$sWhere .= " AND t.topic_date_publish > " . $this->oDb->escape($aFilter['topic_date_more']);
}
if (isset($aFilter['topic_slug'])) {
$sWhere .= " AND t.topic_slug = " . $this->oDb->escape($aFilter['topic_slug']);
}
if (isset($aFilter['topic_publish'])) {
$sWhere .= " AND t.topic_publish = " . (int)$aFilter['topic_publish'];
$sWhere .= " AND t.topic_publish = " . (int)$aFilter['topic_publish'] . " AND t.topic_date_publish <= '{$sDateNow}' ";
}
if (isset($aFilter['topic_rating']) and is_array($aFilter['topic_rating'])) {
$sPublishIndex = '';
@ -610,7 +613,7 @@ class ModuleTopic_MapperTopic extends Mapper
}
}
if (isset($aFilter['topic_new'])) {
$sWhere .= " AND t.topic_date_add >= '" . $aFilter['topic_new'] . "'";
$sWhere .= " AND t.topic_date_publish >= '" . $aFilter['topic_new'] . "'";
}
if (isset($aFilter['user_id'])) {
$sWhere .= is_array($aFilter['user_id'])

View file

@ -9,7 +9,7 @@
user = $topic->getUser()
topic = $topic
blog = $topic->getBlog()
date = $topic->getDateAdd()
date = $topic->getDatePublish()
topicUrl = $topic->getUrl()}
{foreachelse}
{component 'alert' mods='empty' text={lang 'common.empty'}}

View file

@ -111,7 +111,7 @@
{* Голосование *}
{if ! $isPreview}
<li class="{$component}-info-item {$component}-info-item--vote">
{$isExpired = strtotime($topic->getDateAdd()) < $smarty.now - Config::Get('acl.vote.topic.limit_time')}
{$isExpired = strtotime($topic->getDatePublish()) < $smarty.now - Config::Get('acl.vote.topic.limit_time')}
{component 'vote'
target = $topic

View file

@ -875,3 +875,7 @@ ALTER TABLE `prefix_user` CHANGE `user_referal_code` `user_referral_code` VARCHA
-- 17.03.2015
ALTER TABLE `prefix_topic` ADD `topic_slug` VARCHAR(500) NOT NULL DEFAULT '' AFTER `topic_title`, ADD INDEX (`topic_slug`) ;
-- 27.03.2015
ALTER TABLE `prefix_topic` ADD `topic_date_publish` DATETIME NOT NULL AFTER `topic_date_edit_content`, ADD INDEX (`topic_date_publish`) ;
UPDATE `prefix_topic` SET `topic_date_publish` = `topic_date_add`;

@ -1 +1 @@
Subproject commit 3c5d2b051b5380d58ff83c1b392cd8f22f1e84c0
Subproject commit a660b9a056f7e6cd8f437ec71f324ee5ed6988e9