mirror of
https://github.com/Oreolek/ifhub.club.git
synced 2024-04-29 23:49:21 +03:00
Merge branch 'master' of https://github.com/livestreet/livestreet
This commit is contained in:
commit
cfad5756cd
|
@ -87,6 +87,7 @@ class ActionContent extends Action
|
||||||
|
|
||||||
$this->AddEventPreg('/^published$/i', '/^(page([1-9]\d{0,5}))?$/i', 'EventShowTopics');
|
$this->AddEventPreg('/^published$/i', '/^(page([1-9]\d{0,5}))?$/i', 'EventShowTopics');
|
||||||
$this->AddEventPreg('/^drafts$/i', '/^(page([1-9]\d{0,5}))?$/i', 'EventShowTopics');
|
$this->AddEventPreg('/^drafts$/i', '/^(page([1-9]\d{0,5}))?$/i', 'EventShowTopics');
|
||||||
|
$this->AddEventPreg('/^deferred$/i', '/^(page([1-9]\d{0,5}))?$/i', 'EventShowTopics');
|
||||||
|
|
||||||
$this->AddEventPreg('/^ajax$/i', '/^add$/i', '/^$/i', 'EventAjaxAdd');
|
$this->AddEventPreg('/^ajax$/i', '/^add$/i', '/^$/i', 'EventAjaxAdd');
|
||||||
$this->AddEventPreg('/^ajax$/i', '/^edit$/i', '/^$/i', 'EventAjaxEdit');
|
$this->AddEventPreg('/^ajax$/i', '/^edit$/i', '/^$/i', 'EventAjaxEdit');
|
||||||
|
@ -116,8 +117,13 @@ class ActionContent extends Action
|
||||||
/**
|
/**
|
||||||
* Получаем список топиков
|
* Получаем список топиков
|
||||||
*/
|
*/
|
||||||
$aResult = $this->Topic_GetTopicsPersonalByUser($this->oUserCurrent->getId(),
|
if ($this->sCurrentEvent == 'deferred') {
|
||||||
$this->sCurrentEvent == 'published' ? 1 : 0, $iPage, Config::Get('module.topic.per_page'));
|
$aResult = $this->Topic_GetTopicsPersonalDeferredByUser($this->oUserCurrent->getId(), $iPage, Config::Get('module.topic.per_page'));
|
||||||
|
$this->SetTemplateAction('drafts');
|
||||||
|
} else {
|
||||||
|
$aResult = $this->Topic_GetTopicsPersonalByUser($this->oUserCurrent->getId(),
|
||||||
|
$this->sCurrentEvent == 'published' ? 1 : 0, $iPage, Config::Get('module.topic.per_page'));
|
||||||
|
}
|
||||||
$aTopics = $aResult['collection'];
|
$aTopics = $aResult['collection'];
|
||||||
/**
|
/**
|
||||||
* Формируем постраничность
|
* Формируем постраничность
|
||||||
|
@ -340,20 +346,6 @@ class ActionContent extends Action
|
||||||
if (!$oTopic->getTags() or !$oTopic->getTypeObject()->getParam('allow_tags')) {
|
if (!$oTopic->getTags() or !$oTopic->getTypeObject()->getParam('allow_tags')) {
|
||||||
$oTopic->setTags('');
|
$oTopic->setTags('');
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Публикуем или сохраняем в черновиках
|
|
||||||
*/
|
|
||||||
$bSendNotify = false;
|
|
||||||
if (!isset($_REQUEST['is_draft'])) {
|
|
||||||
$oTopic->setPublish(1);
|
|
||||||
if ($oTopic->getPublishDraft() == 0) {
|
|
||||||
$oTopic->setPublishDraft(1);
|
|
||||||
$oTopic->setDatePublish(date("Y-m-d H:i:s"));
|
|
||||||
$bSendNotify = true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$oTopic->setPublish(0);
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* Принудительный вывод на главную
|
* Принудительный вывод на главную
|
||||||
*/
|
*/
|
||||||
|
@ -388,6 +380,27 @@ class ActionContent extends Action
|
||||||
|
|
||||||
$this->Hook_Run('topic_edit_validate_before', array('oTopic' => $oTopic));
|
$this->Hook_Run('topic_edit_validate_before', array('oTopic' => $oTopic));
|
||||||
if ($oTopic->_Validate()) {
|
if ($oTopic->_Validate()) {
|
||||||
|
/**
|
||||||
|
* Публикуем или сохраняем в черновиках
|
||||||
|
*/
|
||||||
|
$bSendNotify = false;
|
||||||
|
if (!isset($_REQUEST['is_draft'])) {
|
||||||
|
$oTopic->setPublish(1);
|
||||||
|
if ($oTopic->getPublishDraft() == 0) {
|
||||||
|
$oTopic->setPublishDraft(1);
|
||||||
|
$oTopic->setDatePublish(date("Y-m-d H:i:s"));
|
||||||
|
$bSendNotify = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$oTopic->setPublish(0);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Отложенная публикация
|
||||||
|
*/
|
||||||
|
if ($oTopic->getPublishDateRaw()) {
|
||||||
|
$oTopic->setDatePublish(date("Y-m-d H:i:s", $oTopic->getPublishDateRaw()));
|
||||||
|
$bSendNotify = false;
|
||||||
|
}
|
||||||
$oBlog = $oTopic->getBlog();
|
$oBlog = $oTopic->getBlog();
|
||||||
/**
|
/**
|
||||||
* Получаемый и устанавливаем разрезанный текст по тегу <cut>
|
* Получаемый и устанавливаем разрезанный текст по тегу <cut>
|
||||||
|
@ -433,7 +446,7 @@ class ActionContent extends Action
|
||||||
* Добавляем событие в ленту
|
* Добавляем событие в ленту
|
||||||
*/
|
*/
|
||||||
$this->Stream_write($oTopic->getUserId(), 'add_topic', $oTopic->getId(),
|
$this->Stream_write($oTopic->getUserId(), 'add_topic', $oTopic->getId(),
|
||||||
$oTopic->getPublish() && $oBlog->getType() != 'close');
|
$oTopic->getPublish() && $oBlog->getType() != 'close', $oTopic->getDatePublish());
|
||||||
/**
|
/**
|
||||||
* Рассылаем о новом топике подписчикам блога
|
* Рассылаем о новом топике подписчикам блога
|
||||||
*/
|
*/
|
||||||
|
@ -526,6 +539,9 @@ class ActionContent extends Action
|
||||||
|
|
||||||
$this->Hook_Run('topic_add_validate_before', array('oTopic' => $oTopic));
|
$this->Hook_Run('topic_add_validate_before', array('oTopic' => $oTopic));
|
||||||
if ($oTopic->_Validate()) {
|
if ($oTopic->_Validate()) {
|
||||||
|
if ($oTopic->getPublishDateRaw()) {
|
||||||
|
$oTopic->setDatePublish(date("Y-m-d H:i:s", $oTopic->getPublishDateRaw()));
|
||||||
|
}
|
||||||
$oBlog = $oTopic->getBlog();
|
$oBlog = $oTopic->getBlog();
|
||||||
/**
|
/**
|
||||||
* Получаем и устанавливаем разрезанный текст по тегу <cut>
|
* Получаем и устанавливаем разрезанный текст по тегу <cut>
|
||||||
|
@ -578,15 +594,14 @@ class ActionContent extends Action
|
||||||
/**
|
/**
|
||||||
* Делаем рассылку спама всем, кто состоит в этом блоге
|
* Делаем рассылку спама всем, кто состоит в этом блоге
|
||||||
*/
|
*/
|
||||||
if ($oTopic->getPublish() == 1 and $oBlog->getType() != 'personal') {
|
if ($oTopic->getPublish() == 1 and $oBlog->getType() != 'personal' and strtotime($oTopic->getDatePublish()) <= time()) {
|
||||||
$this->Topic_SendNotifyTopicNew($oTopic, $oUser);
|
$this->Topic_SendNotifyTopicNew($oTopic, $oUser);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Добавляем событие в ленту
|
* Добавляем событие в ленту
|
||||||
*/
|
*/
|
||||||
$this->Stream_write($oTopic->getUserId(), 'add_topic', $oTopic->getId(),
|
$this->Stream_write($oTopic->getUserId(), 'add_topic', $oTopic->getId(),
|
||||||
$oTopic->getPublish() && $oBlog->getType() != 'close');
|
$oTopic->getPublish() && $oBlog->getType() != 'close', $oTopic->getDatePublish());
|
||||||
|
|
||||||
|
|
||||||
$this->Viewer_AssignAjax('sUrlRedirect', $oTopic->getUrl());
|
$this->Viewer_AssignAjax('sUrlRedirect', $oTopic->getUrl());
|
||||||
$this->Message_AddNotice($this->Lang_Get('topic.add.notices.create_complete'), $this->Lang_Get('common.attention'));
|
$this->Message_AddNotice($this->Lang_Get('topic.add.notices.create_complete'), $this->Lang_Get('common.attention'));
|
||||||
|
|
|
@ -177,9 +177,10 @@ class ModuleStream extends Module
|
||||||
* @param string $sEventType Тип события
|
* @param string $sEventType Тип события
|
||||||
* @param int $iTargetId ID владельца
|
* @param int $iTargetId ID владельца
|
||||||
* @param int $iPublish Статус
|
* @param int $iPublish Статус
|
||||||
|
* @param string|int|null $sDateCreate Дата создания события
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function Write($iUserId, $sEventType, $iTargetId, $iPublish = 1)
|
public function Write($iUserId, $sEventType, $iTargetId, $iPublish = 1, $sDateCreate = null)
|
||||||
{
|
{
|
||||||
$iPublish = (int)$iPublish;
|
$iPublish = (int)$iPublish;
|
||||||
if (!$this->IsAllowEventType($sEventType)) {
|
if (!$this->IsAllowEventType($sEventType)) {
|
||||||
|
@ -218,6 +219,11 @@ class ModuleStream extends Module
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($iPublish) {
|
if ($iPublish) {
|
||||||
|
if (is_null($sDateCreate)) {
|
||||||
|
$sDateCreate = date("Y-m-d H:i:s");
|
||||||
|
} elseif (is_numeric($sDateCreate)) {
|
||||||
|
$sDateCreate = date("Y-m-d H:i:s", $sDateCreate);
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Создаем новое событие
|
* Создаем новое событие
|
||||||
*/
|
*/
|
||||||
|
@ -225,7 +231,7 @@ class ModuleStream extends Module
|
||||||
$oEvent->setEventType($sEventType);
|
$oEvent->setEventType($sEventType);
|
||||||
$oEvent->setUserId($iUserId);
|
$oEvent->setUserId($iUserId);
|
||||||
$oEvent->setTargetId($iTargetId);
|
$oEvent->setTargetId($iTargetId);
|
||||||
$oEvent->setDateAdded(date("Y-m-d H:i:s"));
|
$oEvent->setDateAdded($sDateCreate);
|
||||||
$oEvent->setPublish($iPublish);
|
$oEvent->setPublish($iPublish);
|
||||||
$this->AddEvent($oEvent);
|
$this->AddEvent($oEvent);
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,13 +116,14 @@ class ModuleStream_MapperStream extends Mapper
|
||||||
event_type IN (?a)
|
event_type IN (?a)
|
||||||
{ AND user_id IN (?a) }
|
{ AND user_id IN (?a) }
|
||||||
AND publish = 1
|
AND publish = 1
|
||||||
|
AND date_added <= ?
|
||||||
{ AND id < ?d }
|
{ AND id < ?d }
|
||||||
ORDER BY id DESC
|
ORDER BY id DESC
|
||||||
{ LIMIT 0,?d }';
|
{ LIMIT 0,?d }';
|
||||||
|
|
||||||
$aReturn = array();
|
$aReturn = array();
|
||||||
if ($aRows = $this->oDb->select($sql, $aEventTypes,
|
if ($aRows = $this->oDb->select($sql, $aEventTypes,
|
||||||
(!is_null($aUsersList) and count($aUsersList)) ? $aUsersList : DBSIMPLE_SKIP,
|
(!is_null($aUsersList) and count($aUsersList)) ? $aUsersList : DBSIMPLE_SKIP, date('Y-m-d H:i:s'),
|
||||||
!is_null($iFromId) ? $iFromId : DBSIMPLE_SKIP, !is_null($iCount) ? $iCount : DBSIMPLE_SKIP)
|
!is_null($iFromId) ? $iFromId : DBSIMPLE_SKIP, !is_null($iCount) ? $iCount : DBSIMPLE_SKIP)
|
||||||
) {
|
) {
|
||||||
foreach ($aRows as $aRow) {
|
foreach ($aRows as $aRow) {
|
||||||
|
@ -148,9 +149,9 @@ class ModuleStream_MapperStream extends Mapper
|
||||||
WHERE
|
WHERE
|
||||||
event_type IN (?a)
|
event_type IN (?a)
|
||||||
{ AND user_id IN (?a) }
|
{ AND user_id IN (?a) }
|
||||||
AND publish = 1 ';
|
AND publish = 1 AND date_added <= ? ';
|
||||||
if ($aRow = $this->oDb->selectRow($sql, $aEventTypes,
|
if ($aRow = $this->oDb->selectRow($sql, $aEventTypes,
|
||||||
(!is_null($aUserId) and count($aUserId)) ? $aUserId : DBSIMPLE_SKIP)
|
(!is_null($aUserId) and count($aUserId)) ? $aUserId : DBSIMPLE_SKIP, date('Y-m-d H:i:s'))
|
||||||
) {
|
) {
|
||||||
return $aRow['c'];
|
return $aRow['c'];
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,7 @@ class ModuleTopic extends Module
|
||||||
|
|
||||||
const TOPIC_TYPE_STATE_ACTIVE = 1;
|
const TOPIC_TYPE_STATE_ACTIVE = 1;
|
||||||
const TOPIC_TYPE_STATE_NOT_ACTIVE = 0;
|
const TOPIC_TYPE_STATE_NOT_ACTIVE = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Объект маппера
|
* Объект маппера
|
||||||
*
|
*
|
||||||
|
@ -631,6 +632,14 @@ class ModuleTopic extends Module
|
||||||
: $this->Favourite_GetCountFavouriteOpenTopicsByUserId($sUserId);
|
: $this->Favourite_GetCountFavouriteOpenTopicsByUserId($sUserId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function GetTimelifeCacheForTopics()
|
||||||
|
{
|
||||||
|
if ($sDate = $this->oMapperTopic->GetNextTopicDatePublish()) {
|
||||||
|
return abs(strtotime($sDate) - time());
|
||||||
|
}
|
||||||
|
return 60 * 60 * 24 * 1;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Список топиков по фильтру
|
* Список топиков по фильтру
|
||||||
*
|
*
|
||||||
|
@ -652,7 +661,7 @@ class ModuleTopic extends Module
|
||||||
'count' => $iCount
|
'count' => $iCount
|
||||||
);
|
);
|
||||||
$this->Cache_Set($data, "topic_filter_{$s}_{$iPage}_{$iPerPage}", array('topic_update', 'topic_new'),
|
$this->Cache_Set($data, "topic_filter_{$s}_{$iPage}_{$iPerPage}", array('topic_update', 'topic_new'),
|
||||||
60 * 60 * 24 * 3);
|
$this->GetTimelifeCacheForTopics());
|
||||||
}
|
}
|
||||||
$data['collection'] = $this->GetTopicsAdditionalData($data['collection'], $aAllowData);
|
$data['collection'] = $this->GetTopicsAdditionalData($data['collection'], $aAllowData);
|
||||||
return $data;
|
return $data;
|
||||||
|
@ -669,7 +678,7 @@ class ModuleTopic extends Module
|
||||||
$s = serialize($aFilter);
|
$s = serialize($aFilter);
|
||||||
if (false === ($data = $this->Cache_Get("topic_count_{$s}"))) {
|
if (false === ($data = $this->Cache_Get("topic_count_{$s}"))) {
|
||||||
$data = $this->oMapperTopic->GetCountTopics($aFilter);
|
$data = $this->oMapperTopic->GetCountTopics($aFilter);
|
||||||
$this->Cache_Set($data, "topic_count_{$s}", array('topic_update', 'topic_new'), 60 * 60 * 24 * 1);
|
$this->Cache_Set($data, "topic_count_{$s}", array('topic_update', 'topic_new'), $this->GetTimelifeCacheForTopics());
|
||||||
}
|
}
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
@ -688,6 +697,21 @@ class ModuleTopic extends Module
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Количество отложенных у пользователя
|
||||||
|
*
|
||||||
|
* @param int $iUserId ID пользователя
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function GetCountDeferredTopicsByUserId($iUserId)
|
||||||
|
{
|
||||||
|
return $this->GetCountTopicsByFilter(array(
|
||||||
|
'user_id' => $iUserId,
|
||||||
|
'topic_publish_only' => 1,
|
||||||
|
'topic_new' => date('Y-m-d H:i:s', time() + 1)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Получает список хороших топиков для вывода на главную страницу(из всех блогов, как коллективных так и персональных)
|
* Получает список хороших топиков для вывода на главную страницу(из всех блогов, как коллективных так и персональных)
|
||||||
*
|
*
|
||||||
|
@ -1028,6 +1052,34 @@ class ModuleTopic extends Module
|
||||||
return $this->GetTopicsByFilter($aFilter, $iPage, $iPerPage);
|
return $this->GetTopicsByFilter($aFilter, $iPage, $iPerPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Получает список отложенных топиков по юзеру
|
||||||
|
*
|
||||||
|
* @param int $sUserId ID пользователя
|
||||||
|
* @param int $iPage Номер страницы
|
||||||
|
* @param int $iPerPage Количество элементов на страницу
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function GetTopicsPersonalDeferredByUser($sUserId, $iPage, $iPerPage)
|
||||||
|
{
|
||||||
|
$aFilter = array(
|
||||||
|
'topic_publish_only' => 1,
|
||||||
|
'topic_new' => date('Y-m-d H:i:s', time() + 1),
|
||||||
|
'user_id' => $sUserId,
|
||||||
|
'blog_type' => array('open', 'personal'),
|
||||||
|
);
|
||||||
|
/**
|
||||||
|
* Если пользователь смотрит свой профиль, то добавляем в выдачу
|
||||||
|
* закрытые блоги в которых он состоит
|
||||||
|
*/
|
||||||
|
if ($this->oUserCurrent && $this->oUserCurrent->getId() == $sUserId) {
|
||||||
|
$aFilter['blog_type'][] = 'close';
|
||||||
|
}
|
||||||
|
$this->Hook_Run('get_topics_by_custom_filter',
|
||||||
|
array('aFilter' => &$aFilter, 'iPage' => $iPage, 'iPerPage' => $iPerPage, 'sMethod' => __FUNCTION__));
|
||||||
|
return $this->GetTopicsByFilter($aFilter, $iPage, $iPerPage);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Возвращает количество топиков которые создал юзер
|
* Возвращает количество топиков которые создал юзер
|
||||||
*
|
*
|
||||||
|
|
|
@ -87,6 +87,7 @@ class ModuleTopic_EntityTopic extends Entity
|
||||||
$this->aValidateRules[] = array('blogs_id_raw', 'blogs');
|
$this->aValidateRules[] = array('blogs_id_raw', 'blogs');
|
||||||
$this->aValidateRules[] = array('topic_text_source', 'topic_unique');
|
$this->aValidateRules[] = array('topic_text_source', 'topic_unique');
|
||||||
$this->aValidateRules[] = array('topic_slug_raw', 'slug_check');
|
$this->aValidateRules[] = array('topic_slug_raw', 'slug_check');
|
||||||
|
$this->aValidateRules[] = array('publish_date_raw', 'publish_date_check');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -132,6 +133,46 @@ class ModuleTopic_EntityTopic extends Entity
|
||||||
return $this->Lang_Get('topic.add.notices.error_type');
|
return $this->Lang_Get('topic.add.notices.error_type');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Проверка даты отложенной публикации
|
||||||
|
*
|
||||||
|
* @param array $aValue Проверяемое значение
|
||||||
|
* @param array $aParams Параметры
|
||||||
|
* @return bool|string
|
||||||
|
*/
|
||||||
|
public function ValidatePublishDateCheck($aValue, $aParams)
|
||||||
|
{
|
||||||
|
$oTopicType = $this->getTypeObject();
|
||||||
|
$oUser = $this->getUserCreator();
|
||||||
|
if ($oTopicType and $oTopicType->isAllowCreateDeferredTopic($oUser)) {
|
||||||
|
if ((!$this->getId() or !$this->getPublishDraft() or ($this->getDatePublish() and strtotime($this->getDatePublish()) > time())) and isset($aValue['date']) and is_string($aValue['date']) and isset($aValue['time']) and is_string($aValue['time'])) {
|
||||||
|
$sDateFull = $aValue['date'] . ' ' . $aValue['time'];
|
||||||
|
if ($this->Validate_Validate('date', $sDateFull, array('format' => 'dd.MM.yyyy HH:mm', 'allowEmpty' => true))) {
|
||||||
|
$sDateFull = strtotime($sDateFull); // для охвата всей минуты
|
||||||
|
/**
|
||||||
|
* Переводим дату к серверному часовому поясу
|
||||||
|
*/
|
||||||
|
if ($oUser = $this->getUserCreator() and $sTz = $oUser->getSettingsTimezone()) {
|
||||||
|
$oNow = new DateTime(null, new DateTimeZone($sTz));
|
||||||
|
$iTz = $oNow->getOffset() / 3600;
|
||||||
|
$iDiff = (date('I') + $iTz - (strtotime(date("Y-m-d H:i:s")) - strtotime(gmdate("Y-m-d H:i:s"))) / 3600) * 3600;
|
||||||
|
$sDateFull = $sDateFull - $iDiff;
|
||||||
|
}
|
||||||
|
if ($sDateFull >= strtotime(date('Y-m-d H:i:00'))) {
|
||||||
|
$this->setPublishDateRaw($sDateFull);
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return $this->Lang_Get('topic.add.notices.error_publish_date');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return $this->Lang_Get('topic.add.notices.error_publish_date');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$this->setPublishDateRaw(null);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Проверка URL топика
|
* Проверка URL топика
|
||||||
*
|
*
|
||||||
|
|
|
@ -47,6 +47,8 @@ class ModuleTopic_EntityTopicType extends Entity
|
||||||
$aParamsResult['allow_preview'] = (isset($aParams['allow_preview']) and $aParams['allow_preview']) ? true : false;
|
$aParamsResult['allow_preview'] = (isset($aParams['allow_preview']) and $aParams['allow_preview']) ? true : false;
|
||||||
$aParamsResult['allow_text'] = (isset($aParams['allow_text']) and $aParams['allow_text']) ? true : false;
|
$aParamsResult['allow_text'] = (isset($aParams['allow_text']) and $aParams['allow_text']) ? true : false;
|
||||||
$aParamsResult['allow_tags'] = (isset($aParams['allow_tags']) and $aParams['allow_tags']) ? true : false;
|
$aParamsResult['allow_tags'] = (isset($aParams['allow_tags']) and $aParams['allow_tags']) ? true : false;
|
||||||
|
$aParamsResult['allow_deferred_all'] = (isset($aParams['allow_deferred_all']) and $aParams['allow_deferred_all']) ? true : false;
|
||||||
|
$aParamsResult['allow_deferred_admin'] = (isset($aParams['allow_deferred_admin']) and $aParams['allow_deferred_admin']) ? true : false;
|
||||||
$aParamsResult['css_icon'] = (isset($aParams['css_icon']) and is_string($aParams['css_icon']) and $aParams['css_icon']) ? htmlspecialchars($aParams['css_icon']) : null;
|
$aParamsResult['css_icon'] = (isset($aParams['css_icon']) and is_string($aParams['css_icon']) and $aParams['css_icon']) ? htmlspecialchars($aParams['css_icon']) : null;
|
||||||
|
|
||||||
$this->setParams($aParamsResult);
|
$this->setParams($aParamsResult);
|
||||||
|
@ -133,4 +135,12 @@ class ModuleTopic_EntityTopicType extends Entity
|
||||||
{
|
{
|
||||||
return 'topic_' . $this->getCode();
|
return 'topic_' . $this->getCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function isAllowCreateDeferredTopic($oUser)
|
||||||
|
{
|
||||||
|
if (!$oUser) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return $this->getParam('allow_deferred_all') or ($this->getParam('allow_deferred_admin') and $oUser->isAdministrator());
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -341,18 +341,20 @@ class ModuleTopic_MapperTopic extends Mapper
|
||||||
{
|
{
|
||||||
$sql = "
|
$sql = "
|
||||||
SELECT
|
SELECT
|
||||||
topic_id
|
tt.topic_id
|
||||||
FROM
|
FROM
|
||||||
" . Config::Get('db.table.topic_tag') . "
|
" . Config::Get('db.table.topic_tag') . " as tt,
|
||||||
WHERE
|
" . Config::Get('db.table.topic') . " as t
|
||||||
topic_tag_text = ?
|
WHERE
|
||||||
{ AND blog_id NOT IN (?a) }
|
tt.topic_tag_text = ?
|
||||||
ORDER BY topic_id DESC
|
AND tt.topic_id = t.topic_id AND t.topic_publish = 1 AND t.topic_date_publish <= ?
|
||||||
|
{ AND tt.blog_id NOT IN (?a) }
|
||||||
|
ORDER BY tt.topic_id DESC
|
||||||
LIMIT ?d, ?d ";
|
LIMIT ?d, ?d ";
|
||||||
|
|
||||||
$aTopics = array();
|
$aTopics = array();
|
||||||
if ($aRows = $this->oDb->selectPage(
|
if ($aRows = $this->oDb->selectPage(
|
||||||
$iCount, $sql, $sTag,
|
$iCount, $sql, $sTag, date('Y-m-d H:i:s'),
|
||||||
(is_array($aExcludeBlog) && count($aExcludeBlog)) ? $aExcludeBlog : DBSIMPLE_SKIP,
|
(is_array($aExcludeBlog) && count($aExcludeBlog)) ? $aExcludeBlog : DBSIMPLE_SKIP,
|
||||||
($iCurrPage - 1) * $iPerPage, $iPerPage
|
($iCurrPage - 1) * $iPerPage, $iPerPage
|
||||||
)
|
)
|
||||||
|
@ -414,9 +416,10 @@ class ModuleTopic_MapperTopic extends Mapper
|
||||||
tt.topic_tag_text,
|
tt.topic_tag_text,
|
||||||
count(tt.topic_tag_text) as count
|
count(tt.topic_tag_text) as count
|
||||||
FROM
|
FROM
|
||||||
" . Config::Get('db.table.topic_tag') . " as tt
|
" . Config::Get('db.table.topic_tag') . " as tt,
|
||||||
|
" . Config::Get('db.table.topic') . " as t
|
||||||
WHERE
|
WHERE
|
||||||
1=1
|
tt.topic_id = t.topic_id AND t.topic_publish = 1 AND t.topic_date_publish <= ?
|
||||||
{AND tt.topic_id NOT IN(?a) }
|
{AND tt.topic_id NOT IN(?a) }
|
||||||
GROUP BY
|
GROUP BY
|
||||||
tt.topic_tag_text
|
tt.topic_tag_text
|
||||||
|
@ -427,7 +430,7 @@ class ModuleTopic_MapperTopic extends Mapper
|
||||||
$aReturn = array();
|
$aReturn = array();
|
||||||
$aReturnSort = array();
|
$aReturnSort = array();
|
||||||
if ($aRows = $this->oDb->select(
|
if ($aRows = $this->oDb->select(
|
||||||
$sql,
|
$sql, date('Y-m-d H:i:s'),
|
||||||
(is_array($aExcludeTopic) && count($aExcludeTopic)) ? $aExcludeTopic : DBSIMPLE_SKIP,
|
(is_array($aExcludeTopic) && count($aExcludeTopic)) ? $aExcludeTopic : DBSIMPLE_SKIP,
|
||||||
$iLimit
|
$iLimit
|
||||||
)
|
)
|
||||||
|
@ -458,7 +461,8 @@ class ModuleTopic_MapperTopic extends Mapper
|
||||||
count(tt.topic_tag_text) as count
|
count(tt.topic_tag_text) as count
|
||||||
FROM
|
FROM
|
||||||
" . Config::Get('db.table.topic_tag') . " as tt,
|
" . Config::Get('db.table.topic_tag') . " as tt,
|
||||||
" . Config::Get('db.table.blog') . " as b
|
" . Config::Get('db.table.blog') . " as b,
|
||||||
|
" . Config::Get('db.table.topic') . " as t
|
||||||
WHERE
|
WHERE
|
||||||
1 = 1
|
1 = 1
|
||||||
{ AND tt.user_id = ?d }
|
{ AND tt.user_id = ?d }
|
||||||
|
@ -466,6 +470,8 @@ class ModuleTopic_MapperTopic extends Mapper
|
||||||
tt.blog_id = b.blog_id
|
tt.blog_id = b.blog_id
|
||||||
AND
|
AND
|
||||||
b.blog_type <> 'close'
|
b.blog_type <> 'close'
|
||||||
|
AND
|
||||||
|
tt.topic_id = t.topic_id AND t.topic_publish = 1 AND t.topic_date_publish <= ?
|
||||||
GROUP BY
|
GROUP BY
|
||||||
tt.topic_tag_text
|
tt.topic_tag_text
|
||||||
ORDER BY
|
ORDER BY
|
||||||
|
@ -474,7 +480,7 @@ class ModuleTopic_MapperTopic extends Mapper
|
||||||
";
|
";
|
||||||
$aReturn = array();
|
$aReturn = array();
|
||||||
$aReturnSort = array();
|
$aReturnSort = array();
|
||||||
if ($aRows = $this->oDb->select($sql, is_null($iUserId) ? DBSIMPLE_SKIP : $iUserId, $iLimit)) {
|
if ($aRows = $this->oDb->select($sql, is_null($iUserId) ? DBSIMPLE_SKIP : $iUserId, date('Y-m-d H:i:s'), $iLimit)) {
|
||||||
foreach ($aRows as $aRow) {
|
foreach ($aRows as $aRow) {
|
||||||
$aReturn[mb_strtolower($aRow['topic_tag_text'], 'UTF-8')] = $aRow;
|
$aReturn[mb_strtolower($aRow['topic_tag_text'], 'UTF-8')] = $aRow;
|
||||||
}
|
}
|
||||||
|
@ -590,7 +596,7 @@ class ModuleTopic_MapperTopic extends Mapper
|
||||||
*/
|
*/
|
||||||
protected function buildFilter($aFilter)
|
protected function buildFilter($aFilter)
|
||||||
{
|
{
|
||||||
$sDateNow=date('Y-m-d H:i:s');
|
$sDateNow = date('Y-m-d H:i:s');
|
||||||
$sWhere = '';
|
$sWhere = '';
|
||||||
if (isset($aFilter['topic_date_more'])) {
|
if (isset($aFilter['topic_date_more'])) {
|
||||||
$sWhere .= " AND t.topic_date_publish > " . $this->oDb->escape($aFilter['topic_date_more']);
|
$sWhere .= " AND t.topic_date_publish > " . $this->oDb->escape($aFilter['topic_date_more']);
|
||||||
|
@ -601,6 +607,9 @@ class ModuleTopic_MapperTopic extends Mapper
|
||||||
if (isset($aFilter['topic_publish'])) {
|
if (isset($aFilter['topic_publish'])) {
|
||||||
$sWhere .= " AND t.topic_publish = " . (int)$aFilter['topic_publish'] . " AND t.topic_date_publish <= '{$sDateNow}' ";
|
$sWhere .= " AND t.topic_publish = " . (int)$aFilter['topic_publish'] . " AND t.topic_date_publish <= '{$sDateNow}' ";
|
||||||
}
|
}
|
||||||
|
if (isset($aFilter['topic_publish_only'])) {
|
||||||
|
$sWhere .= " AND t.topic_publish = " . (int)$aFilter['topic_publish_only'] . " ";
|
||||||
|
}
|
||||||
if (isset($aFilter['topic_rating']) and is_array($aFilter['topic_rating'])) {
|
if (isset($aFilter['topic_rating']) and is_array($aFilter['topic_rating'])) {
|
||||||
$sPublishIndex = '';
|
$sPublishIndex = '';
|
||||||
if (isset($aFilter['topic_rating']['publish_index']) and $aFilter['topic_rating']['publish_index'] == 1) {
|
if (isset($aFilter['topic_rating']['publish_index']) and $aFilter['topic_rating']['publish_index'] == 1) {
|
||||||
|
@ -793,8 +802,8 @@ class ModuleTopic_MapperTopic extends Mapper
|
||||||
*/
|
*/
|
||||||
public function MoveTopics($sBlogId, $sBlogIdNew)
|
public function MoveTopics($sBlogId, $sBlogIdNew)
|
||||||
{
|
{
|
||||||
$aFields=array('blog_id','blog_id2','blog_id3','blog_id4','blog_id5');
|
$aFields = array('blog_id', 'blog_id2', 'blog_id3', 'blog_id4', 'blog_id5');
|
||||||
foreach($aFields as $sField) {
|
foreach ($aFields as $sField) {
|
||||||
$sql = "UPDATE " . Config::Get('db.table.topic') . "
|
$sql = "UPDATE " . Config::Get('db.table.topic') . "
|
||||||
SET
|
SET
|
||||||
{$sField} = ?d
|
{$sField} = ?d
|
||||||
|
@ -1003,4 +1012,13 @@ class ModuleTopic_MapperTopic extends Mapper
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function GetNextTopicDatePublish()
|
||||||
|
{
|
||||||
|
$sql = 'SELECT min(topic_date_publish) FROM ' . Config::Get('db.table.topic') . ' WHERE topic_date_publish > ? and topic_publish = 1';
|
||||||
|
if ($sDate = $this->oDb->selectCell($sql, date('Y-m-d H:i:s'))) {
|
||||||
|
return $sDate;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -453,6 +453,7 @@ class ModuleUser extends Module
|
||||||
if ($this->oUserCurrent) {
|
if ($this->oUserCurrent) {
|
||||||
$this->Viewer_Assign('iUserCurrentCountTalkNew', $this->Talk_GetCountTalkNew($this->oUserCurrent->getId()));
|
$this->Viewer_Assign('iUserCurrentCountTalkNew', $this->Talk_GetCountTalkNew($this->oUserCurrent->getId()));
|
||||||
$this->Viewer_Assign('iUserCurrentCountTopicDraft', $this->Topic_GetCountDraftTopicsByUserId($this->oUserCurrent->getId()));
|
$this->Viewer_Assign('iUserCurrentCountTopicDraft', $this->Topic_GetCountDraftTopicsByUserId($this->oUserCurrent->getId()));
|
||||||
|
$this->Viewer_Assign('iUserCurrentCountTopicDeferred', $this->Topic_GetCountDeferredTopicsByUserId($this->oUserCurrent->getId()));
|
||||||
$this->Viewer_Assign('iUserCurrentCountWall', $this->Wall_GetCountWall(array('wall_user_id' => $this->oUserCurrent->getId(), 'pid' => null)));
|
$this->Viewer_Assign('iUserCurrentCountWall', $this->Wall_GetCountWall(array('wall_user_id' => $this->oUserCurrent->getId(), 'pid' => null)));
|
||||||
$this->Viewer_Assign('iUserCurrentCountFriends', $this->User_GetCountUsersFriend($this->oUserCurrent->getId()));
|
$this->Viewer_Assign('iUserCurrentCountFriends', $this->User_GetCountUsersFriend($this->oUserCurrent->getId()));
|
||||||
|
|
||||||
|
|
|
@ -106,6 +106,10 @@
|
||||||
padding: 0;
|
padding: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.ls-topic-info-item.ls-topic-info-item--date--deferred {
|
||||||
|
color: #ff0000;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Responsive styles
|
* Responsive styles
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -132,6 +132,33 @@
|
||||||
targetId = ( $topic ) ? $topic->getId() : ''}
|
targetId = ( $topic ) ? $topic->getId() : ''}
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
{if $type->isAllowCreateDeferredTopic($oUserCurrent)}
|
||||||
|
{if !$topic or !$topic->getPublishDraft() or ($topic->getDatePublish() and strtotime($topic->getDatePublish()) > time())}
|
||||||
|
{$iDatePublish = null}
|
||||||
|
{if $topic}
|
||||||
|
{$iDatePublish = strtotime($topic->getDatePublish())}
|
||||||
|
{if $iDatePublish < time()}
|
||||||
|
{$iDatePublish = null}
|
||||||
|
{/if}
|
||||||
|
{/if}
|
||||||
|
<div>
|
||||||
|
<div>{lang 'topic.add.fields.publish_date.label'}:</div>
|
||||||
|
{component 'field.date' mods = 'inline'
|
||||||
|
name = "topic[publish_date_raw][date]"
|
||||||
|
inputAttributes=[ "data-lsdate-format" => 'DD.MM.YYYY' ]
|
||||||
|
inputClasses = "js-field-date-default"
|
||||||
|
placeholder = {lang 'topic.add.fields.publish_date.label_date'}
|
||||||
|
value = ($iDatePublish) ? {date_format date=$iDatePublish format='d.m.Y'} : ''}
|
||||||
|
|
||||||
|
{component 'field.time' mods = 'inline'
|
||||||
|
name = "topic[publish_date_raw][time]"
|
||||||
|
inputAttributes=[ "data-lstime-time-format" => 'H:i' ]
|
||||||
|
inputClasses = "js-field-time-default"
|
||||||
|
placeholder = {lang 'topic.add.fields.publish_date.label_time'}
|
||||||
|
value = ($iDatePublish) ? {date_format date=$iDatePublish format='H:i'} : ''}
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
{/if}
|
||||||
|
|
||||||
{* Запретить комментарии *}
|
{* Запретить комментарии *}
|
||||||
{component 'field' template='checkbox'
|
{component 'field' template='checkbox'
|
||||||
|
|
|
@ -57,8 +57,9 @@
|
||||||
{/foreach}
|
{/foreach}
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<li class="{$component}-info-item {$component}-info-item--date">
|
{$isDeferred = (strtotime($topic->getDatePublish())>time()) ? true : false}
|
||||||
<time datetime="{date_format date=$topic->getDatePublish() format='c'}" title="{date_format date=$topic->getDatePublish() format='j F Y, H:i'}">
|
<li class="{$component}-info-item {$component}-info-item--date{if $isDeferred}--deferred{/if}">
|
||||||
|
<time datetime="{date_format date=$topic->getDatePublish() format='c'}" title="{if $isDeferred}{lang 'topic.is_deferred'}{else}{date_format date=$topic->getDatePublish() format='j F Y, H:i'}{/if}">
|
||||||
{date_format date=$topic->getDatePublish() format="j F Y, H:i"}
|
{date_format date=$topic->getDatePublish() format="j F Y, H:i"}
|
||||||
</time>
|
</time>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -1048,6 +1048,8 @@ return array(
|
||||||
'topics' => 'Топики',
|
'topics' => 'Топики',
|
||||||
'topic_plural' => 'топик;топика;топиков',
|
'topic_plural' => 'топик;топика;топиков',
|
||||||
'drafts' => 'Черновики',
|
'drafts' => 'Черновики',
|
||||||
|
'deferred' => 'Отложенные',
|
||||||
|
'is_deferred' => 'Это отложенная публикация',
|
||||||
'read_more' => 'Читать дальше',
|
'read_more' => 'Читать дальше',
|
||||||
'author' => 'Автор топика',
|
'author' => 'Автор топика',
|
||||||
'tags' => '___tags.tags___',
|
'tags' => '___tags.tags___',
|
||||||
|
@ -1108,6 +1110,11 @@ return array(
|
||||||
'label' => 'Принудительно пропустить вывод на главную',
|
'label' => 'Принудительно пропустить вывод на главную',
|
||||||
'note' => 'Если отметить эту галку, то топик никогда не будет выведен на главную страницу (опция доступна только администраторам)'
|
'note' => 'Если отметить эту галку, то топик никогда не будет выведен на главную страницу (опция доступна только администраторам)'
|
||||||
),
|
),
|
||||||
|
'publish_date' => array(
|
||||||
|
'label' => 'Дата отложенной публикации',
|
||||||
|
'label_date' => 'Дата',
|
||||||
|
'label_time' => 'Время',
|
||||||
|
),
|
||||||
),
|
),
|
||||||
// Кнопки
|
// Кнопки
|
||||||
'button' => array(
|
'button' => array(
|
||||||
|
@ -1125,6 +1132,7 @@ return array(
|
||||||
'error_type' => 'Неверный тип топика', // TODO: Remove?
|
'error_type' => 'Неверный тип топика', // TODO: Remove?
|
||||||
'error_slug' => 'Необходимо указать URL топика',
|
'error_slug' => 'Необходимо указать URL топика',
|
||||||
'error_favourite_draft' => 'Топик из черновиков нельзя добавить в избранное',
|
'error_favourite_draft' => 'Топик из черновиков нельзя добавить в избранное',
|
||||||
|
'error_publish_date' => 'Необходимо указать корректную дату публикации в будущем',
|
||||||
'time_limit' => 'Вам нельзя создавать топики слишком часто',
|
'time_limit' => 'Вам нельзя создавать топики слишком часто',
|
||||||
'rating_limit' => 'Вам не хватает рейтинга для создания топика',
|
'rating_limit' => 'Вам не хватает рейтинга для создания топика',
|
||||||
'update_complete' => 'Обновление прошло успешно',
|
'update_complete' => 'Обновление прошло успешно',
|
||||||
|
|
|
@ -23,6 +23,14 @@
|
||||||
'count' => $iUserCurrentCountTopicDraft
|
'count' => $iUserCurrentCountTopicDraft
|
||||||
]}
|
]}
|
||||||
|
|
||||||
|
{* Пункт "Отложенные" *}
|
||||||
|
{$_items[] = [
|
||||||
|
'name' => 'deferred',
|
||||||
|
'url' => "{router page='content'}deferred/",
|
||||||
|
'text' => $aLang.topic.deferred,
|
||||||
|
'count' => $iUserCurrentCountTopicDeferred
|
||||||
|
]}
|
||||||
|
|
||||||
{$layoutNav = [[
|
{$layoutNav = [[
|
||||||
name => 'content_form',
|
name => 'content_form',
|
||||||
activeItem => $sMenuSubItemSelect,
|
activeItem => $sMenuSubItemSelect,
|
||||||
|
|
|
@ -120,6 +120,10 @@
|
||||||
top: -2px;
|
top: -2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.ls-topic-info-item.ls-topic-info-item--date--deferred {
|
||||||
|
color: #ff0000;
|
||||||
|
}
|
||||||
|
|
||||||
/* Ссылка на комментарии */
|
/* Ссылка на комментарии */
|
||||||
.ls-topic-info-item.ls-topic-info-item--comments a {
|
.ls-topic-info-item.ls-topic-info-item--comments a {
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
|
|
|
@ -169,8 +169,9 @@
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
{* Дата *}
|
{* Дата *}
|
||||||
<li class="{$component}-info-item {$component}-info-item--date">
|
{$isDeferred = (strtotime($topic->getDatePublish())>time()) ? true : false}
|
||||||
<time datetime="{date_format date=$topic->getDatePublish() format='c'}" title="{date_format date=$topic->getDatePublish() format='j F Y, H:i'}">
|
<li class="{$component}-info-item {$component}-info-item--date{if $isDeferred}--deferred{/if}">
|
||||||
|
<time datetime="{date_format date=$topic->getDatePublish() format='c'}" title="{if $isDeferred}{lang 'topic.is_deferred'}{else}{date_format date=$topic->getDatePublish() format='j F Y, H:i'}{/if}">
|
||||||
{date_format date=$topic->getDatePublish() format="j F Y, H:i"}
|
{date_format date=$topic->getDatePublish() format="j F Y, H:i"}
|
||||||
</time>
|
</time>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -23,6 +23,14 @@
|
||||||
'count' => $iUserCurrentCountTopicDraft
|
'count' => $iUserCurrentCountTopicDraft
|
||||||
]}
|
]}
|
||||||
|
|
||||||
|
{* Пункт "Отложенные" *}
|
||||||
|
{$_items[] = [
|
||||||
|
'name' => 'deferred',
|
||||||
|
'url' => "{router page='content'}deferred/",
|
||||||
|
'text' => $aLang.topic.deferred,
|
||||||
|
'count' => $iUserCurrentCountTopicDeferred
|
||||||
|
]}
|
||||||
|
|
||||||
{$layoutNav = [[
|
{$layoutNav = [[
|
||||||
name => 'content_form',
|
name => 'content_form',
|
||||||
activeItem => $sMenuSubItemSelect,
|
activeItem => $sMenuSubItemSelect,
|
||||||
|
|
Loading…
Reference in a new issue