1
0
Fork 0
mirror of https://github.com/Oreolek/ifhub.club.git synced 2024-05-21 18:28:17 +03:00

Функционал публикации топиков в несколько блогов #587

This commit is contained in:
Mzhelskiy Maxim 2014-12-30 23:38:04 +07:00
parent 3d0ad06488
commit ef52ae918e
25 changed files with 2058 additions and 177 deletions

View file

@ -1782,11 +1782,10 @@ class ActionBlog extends Action
if (!$bAccess = $this->ACL_IsAllowDeleteBlog($oBlog, $this->oUserCurrent)) {
return parent::EventNotFound();
}
$aTopics = $this->Topic_GetTopicsByBlogId($sBlogId, 1,
100000); // нужно переделать функционал переноса топиков в дргугой блог
$aTopics = $this->Topic_GetTopicsByBlogId($sBlogId, 1,1,array(),false); // нужно переделать функционал переноса топиков в дргугой блог
switch ($bAccess) {
case ModuleACL::CAN_DELETE_BLOG_EMPTY_ONLY :
if (is_array($aTopics) and count($aTopics)) {
if ($aTopics['count']) {
$this->Message_AddErrorSingle($this->Lang_Get('blog.remove.alerts.not_empty'),
$this->Lang_Get('error'), true);
Router::Location($oBlog->getUrlFull());
@ -1799,7 +1798,7 @@ class ActionBlog extends Action
*
* (-1) - выбран пункт меню "удалить топики".
*/
if ($sBlogIdNew = getRequestStr('topic_move_to') and ($sBlogIdNew != -1) and is_array($aTopics) and count($aTopics)) {
if ($sBlogIdNew = getRequestStr('topic_move_to') and ($sBlogIdNew != -1) and $aTopics['count']) {
if (!$oBlogNew = $this->Blog_GetBlogById($sBlogIdNew)) {
$this->Message_AddErrorSingle($this->Lang_Get('blog.remove.alerts.move_error'),
$this->Lang_Get('error'), true);

View file

@ -182,10 +182,21 @@ class ActionContent extends Action
if (!$this->ACL_IsAllowEditTopic($oTopic, $this->oUserCurrent)) {
return parent::EventNotFound();
}
/**
* Получаем доступные блоги по типам
*/
$aBlogs = array();
$aBlogs['open'] = $this->Blog_GetBlogsByType('open');
if ($this->oUserCurrent->isAdministrator()) {
$aBlogs['close'] = $this->Blog_GetBlogsByType('close');
} else {
$aBlogs['close'] = $this->Blog_GetBlogsByTypeAndUserId('close', $this->oUserCurrent->getId());
}
/**
* Вызов хуков
*/
$this->Hook_Run('topic_edit_show', array('oTopic' => $oTopic));
$this->Hook_Run('topic_edit_show', array('oTopic' => $oTopic, 'aBlogs' => &$aBlogs));
/**
* Дополнительно загружам превью
@ -198,10 +209,21 @@ class ActionContent extends Action
$aTargetItems = $this->Media_GetTargetItemsByFilter($aFilter);
$this->Viewer_Assign('imagePreviewItems', $aTargetItems);
/**
* Проверяем на отсутствие блогов
*/
$bSkipBlogs = true;
foreach ($aBlogs as $aBlogsType) {
if ($aBlogsType) {
$bSkipBlogs = false;
}
}
/**
* Загружаем переменные в шаблон
*/
$this->Viewer_Assign('blogsAllow', $this->Blog_GetBlogsAllowByUser($this->oUserCurrent));
$this->Viewer_Assign('blogsAllow', $aBlogs);
$this->Viewer_Assign('skipBlogs', $bSkipBlogs);
$this->Viewer_Assign('topicType', $oTopicType);
$this->Viewer_AddHtmlTitle($this->Lang_Get('topic.add.title.edit'));
@ -229,15 +251,35 @@ class ActionContent extends Action
return Router::Action('error');
}
$this->sMenuSubItemSelect = $sTopicType;
/**
* Получаем доступные блоги по типам
*/
$aBlogs = array();
$aBlogs['open'] = $this->Blog_GetBlogsByType('open');
if ($this->oUserCurrent->isAdministrator()) {
$aBlogs['close'] = $this->Blog_GetBlogsByType('close');
} else {
$aBlogs['close'] = $this->Blog_GetBlogsByTypeAndUserId('close', $this->oUserCurrent->getId());
}
/**
* Вызов хуков
*/
$this->Hook_Run('topic_add_show');
$this->Hook_Run('topic_add_show', array('aBlogs' => &$aBlogs));
/**
* Проверяем на отсутствие блогов
*/
$bSkipBlogs = true;
foreach ($aBlogs as $aBlogsType) {
if ($aBlogsType) {
$bSkipBlogs = false;
}
}
/**
* Загружаем переменные в шаблон
*/
$this->Viewer_Assign('topicType', $oTopicType);
$this->Viewer_Assign('blogsAllow', $this->Blog_GetBlogsAllowByUser($this->oUserCurrent));
$this->Viewer_Assign('blogsAllow', $aBlogs);
$this->Viewer_Assign('skipBlogs', $bSkipBlogs);
$this->Viewer_Assign('blogId', $iBlogId);
$this->Viewer_AddHtmlTitle($this->Lang_Get('topic.add.title.add'));
$this->SetTemplateAction('add');
@ -275,6 +317,7 @@ class ActionContent extends Action
$oTopic->_setDataSafe(getRequest('topic'));
$oTopic->setProperties(getRequest('property'));
$oTopic->setUserCreator($this->oUserCurrent);
$oTopic->setUserIp(func_getIp());
if (!$oTopic->getTags() or !$oTopic->getTypeObject()->getParam('allow_tags')) {
$oTopic->setTags('');
@ -325,17 +368,9 @@ class ActionContent extends Action
*/
$oTopic->setDateEditContent(date('Y-m-d H:i:s'));
$this->Hook_Run('topic_edit_validate_before', array('oTopic'=>$oTopic));
$this->Hook_Run('topic_edit_validate_before', array('oTopic' => $oTopic));
if ($oTopic->_Validate()) {
$oBlog = $oTopic->getBlog();
/**
* Проверяем права на постинг в блог
*/
if (!$this->ACL_IsAllowBlog($oBlog, $this->oUserCurrent)) {
$this->Message_AddErrorSingle($this->Lang_Get('topic.add.notices.error_blog_not_allowed'),
$this->Lang_Get('error'));
return false;
}
/**
* Получаемый и устанавливаем разрезанный текст по тегу <cut>
*/
@ -355,7 +390,7 @@ class ActionContent extends Action
$oTopic->setTextShort('');
$oTopic->setTextSource('');
}
$this->Hook_Run('topic_edit_before', array('oTopic'=>$oTopic,'oBlog'=>$oBlog));
$this->Hook_Run('topic_edit_before', array('oTopic' => $oTopic, 'oBlog' => $oBlog));
/**
* Сохраняем топик
*/
@ -427,6 +462,7 @@ class ActionContent extends Action
$oTopic->_setDataSafe(getRequest('topic'));
$oTopic->setProperties(getRequest('property'));
$oTopic->setUserCreator($this->oUserCurrent);
$oTopic->setUserId($this->oUserCurrent->getId());
$oTopic->setDateAdd(date("Y-m-d H:i:s"));
$oTopic->setUserIp(func_getIp());
@ -470,17 +506,9 @@ class ActionContent extends Action
$oTopic->setForbidComment(1);
}
$this->Hook_Run('topic_add_validate_before', array('oTopic'=>$oTopic));
$this->Hook_Run('topic_add_validate_before', array('oTopic' => $oTopic));
if ($oTopic->_Validate()) {
$oBlog = $oTopic->getBlog();
/**
* Проверяем права на постинг в блог
*/
if (!$this->ACL_IsAllowBlog($oBlog, $this->oUserCurrent)) {
$this->Message_AddErrorSingle($this->Lang_Get('topic.add.notices.error_blog_not_allowed'),
$this->Lang_Get('error'));
return false;
}
/**
* Получаем и устанавливаем разрезанный текст по тегу <cut>
*/

View file

@ -388,14 +388,29 @@ class ModuleACL extends Module
*/
public function IsAllowBlog($oBlog, $oUser)
{
if (!$oBlog || !$oUser) {
return false;
}
if ($oUser->isAdministrator()) {
return true;
}
if ($oBlog->getOwnerId() == $oUser->getId()) {
return true;
}
if ($oBlogUser = $this->Blog_GetBlogUserByBlogIdAndUserId($oBlog->getId(), $oUser->getId())) {
if ($oUser->getRating() >= $oBlog->getLimitRatingTopic() or $oBlogUser->getIsAdministrator() or $oBlogUser->getIsModerator()) {
if ($oBlog->getType() == 'close') {
/**
* Для закрытых блогов проверяем среди подписчиков
*/
if ($oBlogUser = $this->Blog_GetBlogUserByBlogIdAndUserId($oBlog->getId(), $oUser->getId())) {
if ($oUser->getRating() >= $oBlog->getLimitRatingTopic() or $oBlogUser->getIsAdministrator() or $oBlogUser->getIsModerator()) {
return true;
}
}
} else {
/**
* Иначе смотрим ограничение на рейтинг
*/
if ($oUser->getRating() >= $oBlog->getLimitRatingTopic()) {
return true;
}
}

View file

@ -493,6 +493,49 @@ class ModuleBlog extends Module
return $data;
}
public function GetBlogsByType($sType)
{
$aBlogs=$this->GetBlogsByFilter(array('type' => $sType), array('blog_title'=>'asc'), 1, 100);
return $aBlogs['collection'];
}
public function GetBlogsByTypeAndUserId($sType, $iUserId)
{
$aResult = array();
/**
* Получаем созданные юзером блоги
*/
$aBlogs = $this->GetBlogsByFilter(array('user_owner_id' => $iUserId, 'type' => $sType), array(), 1, 100);
foreach ($aBlogs['collection'] as $oBlog) {
$aResult[$oBlog->getId()] = $oBlog;
}
/**
* Блоги в которых состоит
*/
$aBlogs = $this->GetBlogsByFilter(array(
'type' => $sType,
'roles_user_id' => $iUserId,
'roles' => array(
self::BLOG_USER_ROLE_USER,
self::BLOG_USER_ROLE_MODERATOR,
self::BLOG_USER_ROLE_ADMINISTRATOR
)
), array(), 1, 100);
foreach ($aBlogs['collection'] as $oBlog) {
$aResult[$oBlog->getId()] = $oBlog;
}
/**
* Сотируем по названию
*/
uasort($aResult, function ($a, $b) {
if ($a->getTitle() == $b->getTitle()) {
return 0;
}
return ($a->getTitle() < $b->getTitle()) ? -1 : 1;
});
return $aResult;
}
/**
* Получает список пользователей блога.
* Если роль не указана, то считаем что поиск производиться по положительным значениям (статусом выше GUEST).

View file

@ -578,10 +578,11 @@ class ModuleBlog_MapperBlog extends Mapper
$aFilter['id'] = array($aFilter['id']);
}
if ($oUserCurrent=$this->User_GetUserCurrent()) {
$iUserCurrentId=0;
if (isset($aFilter['roles_user_id'])) {
$iUserCurrentId=$aFilter['roles_user_id'];
} elseif ($oUserCurrent=$this->User_GetUserCurrent()) {
$iUserCurrentId=$oUserCurrent->getId();
} else {
$iUserCurrentId=0;
}
$sql = "SELECT

View file

@ -136,7 +136,7 @@ class ModuleTopic extends Module
$aUserId[] = $oTopic->getUserId();
}
if (isset($aAllowData['blog'])) {
$aBlogId[] = $oTopic->getBlogId();
$aBlogId = array_merge($aBlogId, $oTopic->getBlogIds());
}
}
/**
@ -167,11 +167,13 @@ class ModuleTopic extends Module
} else {
$oTopic->setUser(null); // или $oTopic->setUser(new ModuleUser_EntityUser());
}
if (isset($aBlogs[$oTopic->getBlogId()])) {
$oTopic->setBlog($aBlogs[$oTopic->getBlogId()]);
} else {
$oTopic->setBlog(null); // или $oTopic->setBlog(new ModuleBlog_EntityBlog());
$aBlogsTopic=array();
foreach($oTopic->getBlogIds() as $iBlogId) {
if (isset($aBlogs[$iBlogId])) {
$aBlogsTopic[]=$aBlogs[$iBlogId];
}
}
$oTopic->setBlogs($aBlogsTopic);
if (isset($aTopicsVote[$oTopic->getId()])) {
$oTopic->setVote($aTopicsVote[$oTopic->getId()]);
} else {
@ -1644,6 +1646,7 @@ class ModuleTopic extends Module
/**
* Перемещает топики в другой блог
* TODO: пофиксить перенос для функционала мультиблогов
*
* @param int $sBlogId ID старого блога
* @param int $sBlogIdNew ID нового блога

View file

@ -77,7 +77,7 @@ class ModuleTopic_EntityTopic extends Entity
'allowEmpty' => Config::Get('module.topic.allow_empty_tags')
);
$this->aValidateRules[] = array('blog_id', 'blog_id');
$this->aValidateRules[] = array('blogs_id_raw', 'blogs');
$this->aValidateRules[] = array('topic_text_source', 'topic_unique');
}
@ -146,25 +146,60 @@ class ModuleTopic_EntityTopic extends Entity
}
/**
* Валидация ID блога
* Валидация ID блогов
*
* @param string $sValue Проверяемое значение
* @param array $aParams Параметры
* @return bool|string
*/
public function ValidateBlogId($sValue, $aParams)
public function ValidateBlogs($sValue, $aParams)
{
if ($sValue == 0 and $oBlog = $this->Blog_GetPersonalBlogByUserId($this->getUserId())) {
$this->setBlog($oBlog);
$this->setBlogId($oBlog->getId());
return true; // персональный блог
if (!$sValue or !is_array($sValue)) {
if ($oBlog = $this->Blog_GetPersonalBlogByUserId($this->getUserId())) {
$this->setBlogs(array($oBlog));
$this->setBlogId($oBlog->getId());
$this->setBlogId2(null);
$this->setBlogId3(null);
$this->setBlogId4(null);
$this->setBlogId5(null);
return true; // персональный блог
} else {
return $this->Lang_Get('topic.add.notices.error_blog_not_found');
}
}
if ($oBlog = $this->Blog_GetBlogById((int)$sValue)) {
$this->setBlog($oBlog);
$this->setBlogId($oBlog->getId());
return true;
/**
* Проверяем список блогов
*/
$aBlogs = array();
foreach ($sValue as $iKey => $iBlogId) {
if (is_numeric($iBlogId) and $oBlog = $this->Blog_GetBlogById($iBlogId)) {
/**
* Проверяем права на постинг в блог
*/
if ($this->ACL_IsAllowBlog($oBlog, $this->getUserCreator())) {
$aBlogs[] = $oBlog;
} else {
return $this->Lang_Get('topic.add.notices.error_blog_not_allowed');
}
}
}
return $this->Lang_Get('topic.add.notices.error_blog_not_found');
if (count($aBlogs) == 0) {
return $this->Lang_Get('topic.add.notices.error_blog_not_found');
}
if (count($sValue) > Config::Get('module.topic.max_blog_count')) {
return $this->Lang_Get('topic.add.notices.error_blog_max_count',
array('count' => Config::Get('module.topic.max_blog_count')));
}
/**
* Заполняем поля с ID
*/
$this->setBlogId($aBlogs[0]->getId());
$this->setBlogId2(isset($aBlogs[1]) ? $aBlogs[1]->getId() : null);
$this->setBlogId3(isset($aBlogs[2]) ? $aBlogs[2]->getId() : null);
$this->setBlogId4(isset($aBlogs[3]) ? $aBlogs[3]->getId() : null);
$this->setBlogId5(isset($aBlogs[4]) ? $aBlogs[4]->getId() : null);
$this->setBlogs($aBlogs);
return true;
}
/**
@ -187,6 +222,46 @@ class ModuleTopic_EntityTopic extends Entity
return $this->_getDataOne('blog_id');
}
/**
* Возвращает ID блога 2
*
* @return int|null
*/
public function getBlogId2()
{
return $this->_getDataOne('blog_id2');
}
/**
* Возвращает ID блога 3
*
* @return int|null
*/
public function getBlogId3()
{
return $this->_getDataOne('blog_id3');
}
/**
* Возвращает ID блога 4
*
* @return int|null
*/
public function getBlogId4()
{
return $this->_getDataOne('blog_id4');
}
/**
* Возвращает ID блога 5
*
* @return int|null
*/
public function getBlogId5()
{
return $this->_getDataOne('blog_id5');
}
/**
* Возвращает ID пользователя
*
@ -500,7 +575,36 @@ class ModuleTopic_EntityTopic extends Entity
*/
public function getBlog()
{
return $this->_getDataOne('blog');
if ($aBlogs = $this->getBlogs() and is_array($aBlogs)) {
return reset($aBlogs);
}
return null;
}
/**
* Возвращает список блогов
*
* @return mixed|null
*/
public function getBlogs()
{
return $this->_getDataOne('blogs');
}
/**
* Возвращает список ID блогов
*
* @return array
*/
public function getBlogsId()
{
$aResult = array();
if ($aBlogs = $this->getBlogs()) {
foreach ($aBlogs as $oBlog) {
$aResult[] = $oBlog->getId();
}
}
return $aResult;
}
/**
@ -667,6 +771,32 @@ class ModuleTopic_EntityTopic extends Entity
return $this->_getDataOne('polls');
}
/**
* Возвращает список ID всех блогов
*
* @return array
*/
public function getBlogIds()
{
$aResult = array();
if ($this->getBlogId()) {
$aResult[] = $this->getBlogId();
}
if ($this->getBlogId2()) {
$aResult[] = $this->getBlogId2();
}
if ($this->getBlogId3()) {
$aResult[] = $this->getBlogId3();
}
if ($this->getBlogId4()) {
$aResult[] = $this->getBlogId4();
}
if ($this->getBlogId5()) {
$aResult[] = $this->getBlogId5();
}
return $aResult;
}
/***************************************************************************************************************************************************
* методы расширения типов топика
***************************************************************************************************************************************************
@ -760,6 +890,46 @@ class ModuleTopic_EntityTopic extends Entity
$this->_aData['blog_id'] = $data;
}
/**
* Устанавливает ID блога 2
*
* @param int $data
*/
public function setBlogId2($data)
{
$this->_aData['blog_id2'] = $data;
}
/**
* Устанавливает ID блога 3
*
* @param int $data
*/
public function setBlogId3($data)
{
$this->_aData['blog_id3'] = $data;
}
/**
* Устанавливает ID блога 4
*
* @param int $data
*/
public function setBlogId4($data)
{
$this->_aData['blog_id4'] = $data;
}
/**
* Устанавливает ID блога 5
*
* @param int $data
*/
public function setBlogId5($data)
{
$this->_aData['blog_id5'] = $data;
}
/**
* Устанавливает ID пользователя
*

View file

@ -37,6 +37,10 @@ class ModuleTopic_MapperTopic extends Mapper
{
$sql = "INSERT INTO " . Config::Get('db.table.topic') . "
(blog_id,
blog_id2,
blog_id3,
blog_id4,
blog_id5,
user_id,
topic_type,
topic_title,
@ -51,10 +55,10 @@ class ModuleTopic_MapperTopic extends Mapper
topic_forbid_comment,
topic_text_hash
)
VALUES(?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->getUserId(), $oTopic->getType(),
$oTopic->getTitle(),
if ($iId = $this->oDb->query($sql, $oTopic->getBlogId(), $oTopic->getBlogId2(), $oTopic->getBlogId3(),
$oTopic->getBlogId4(), $oTopic->getBlogId5(), $oTopic->getUserId(), $oTopic->getType(), $oTopic->getTitle(),
$oTopic->getTags(), $oTopic->getDateAdd(), $oTopic->getUserIp(), $oTopic->getPublish(),
$oTopic->getPublishDraft(), $oTopic->getPublishIndex(), $oTopic->getSkipIndex(), $oTopic->getCutText(),
$oTopic->getForbidComment(), $oTopic->getTextHash())
@ -509,7 +513,11 @@ class ModuleTopic_MapperTopic extends Mapper
$sql = "UPDATE " . Config::Get('db.table.topic') . "
SET
blog_id= ?d,
topic_title= ?,
blog_id2= ?d,
blog_id3= ?d,
blog_id4= ?d,
blog_id5= ?d,
topic_title= ?,
topic_tags= ?,
topic_date_add = ?,
topic_date_edit = ?,
@ -533,10 +541,11 @@ class ModuleTopic_MapperTopic extends Mapper
WHERE
topic_id = ?d
";
$res = $this->oDb->query($sql, $oTopic->getBlogId(), $oTopic->getTitle(), $oTopic->getTags(),
$res = $this->oDb->query($sql, $oTopic->getBlogId(), $oTopic->getBlogId2(), $oTopic->getBlogId3(),
$oTopic->getBlogId4(), $oTopic->getBlogId5(), $oTopic->getTitle(), $oTopic->getTags(),
$oTopic->getDateAdd(), $oTopic->getDateEdit(), $oTopic->getDateEditContent(), $oTopic->getUserIp(),
$oTopic->getPublish(), $oTopic->getPublishDraft(), $oTopic->getPublishIndex(), $oTopic->getSkipIndex(), $oTopic->getRating(),
$oTopic->getCountVote(), $oTopic->getCountVoteUp(), $oTopic->getCountVoteDown(),
$oTopic->getPublish(), $oTopic->getPublishDraft(), $oTopic->getPublishIndex(), $oTopic->getSkipIndex(),
$oTopic->getRating(), $oTopic->getCountVote(), $oTopic->getCountVoteUp(), $oTopic->getCountVoteDown(),
$oTopic->getCountVoteAbstain(), $oTopic->getCountRead(), $oTopic->getCountComment(),
$oTopic->getCountFavourite(), $oTopic->getCutText(), $oTopic->getForbidComment(), $oTopic->getTextHash(),
$oTopic->getId());
@ -607,7 +616,12 @@ class ModuleTopic_MapperTopic extends Mapper
if (!is_array($aFilter['blog_id'])) {
$aFilter['blog_id'] = array($aFilter['blog_id']);
}
$sWhere .= " AND t.blog_id IN ('" . join("','", $aFilter['blog_id']) . "')";
$sBlogList = join("','", $aFilter['blog_id']);
$sWhere .= " AND ( t.blog_id IN ('{$sBlogList}') ";
$sWhere .= " OR t.blog_id2 IN ('{$sBlogList}') ";
$sWhere .= " OR t.blog_id3 IN ('{$sBlogList}') ";
$sWhere .= " OR t.blog_id4 IN ('{$sBlogList}') ";
$sWhere .= " OR t.blog_id5 IN ('{$sBlogList}') ) ";
}
if (isset($aFilter['blog_type']) and is_array($aFilter['blog_type'])) {
$aBlogTypes = array();

View file

@ -140,6 +140,7 @@ $config['module']['topic']['title_allow_empty'] = false; // Разреша
$config['module']['topic']['allow_empty_tags'] = false; // Разрешать или нет не заполнять теги
$config['module']['topic']['default_period_top'] = 1; // Дефолтный период (количество дней) для отображения ТОП топиков. Значения: 1,7,30,'all'
$config['module']['topic']['default_period_discussed'] = 1; // Дефолтный период (количество дней) для отображения обсуждаемых топиков. Значения: 1,7,30,'all'
$config['module']['topic']['max_blog_count'] = 3; // Количество блогов, которые можно задать топику. Максимальное значение 5.
// Модуль User
$config['module']['user']['per_page'] = 15; // Число юзеров на страницу на странице статистики и в профиле пользователя
$config['module']['user']['friend_on_profile'] = 15; // Ограничение на вывод числа друзей пользователя на странице его профиля
@ -407,7 +408,7 @@ $config['block']['rule_topic_type'] = array(
'action' => array(
'content' => array('add', 'edit'),
),
'blocks' => array('right' => array('components/blog/blocks/block.blog-info.tpl', 'components/blog/blocks/block.blog-info-note.tpl')),
'blocks' => array('right' => array('components/blog/blocks/block.blog-info-note.tpl')),
);
$config['block']['rule_personal_blog'] = array(
'action' => array('personal_blog'),

View file

@ -390,6 +390,11 @@ return array(
),
),
),
'types' => array(
'personal' => 'Персональные блоги',
'open' => 'Открытые блоги',
'close' => 'Закрытые блоги',
),
),
/**
* Личные сообщения
@ -1108,6 +1113,7 @@ return array(
// Сообщения
'notices' => array(
'error_blog_not_found' => 'Выбранный вами блог не существует',
'error_blog_max_count' => 'Превышено максимальное число блогов: %%count%%',
'error_blog_not_allowed' => 'Вы не можете писать в этот блог',
'error_text_unique' => 'Вы уже писали топик с таким содержанием',
'error_type' => 'Неверный тип топика', // TODO: Remove?

View file

@ -24,5 +24,5 @@
{/block}
{block 'layout_content'}
{include 'components/topic/topic-add.tpl' topic=$topicEdit type=$topicType blogs=$blogsAllow blogId=$blogId}
{include 'components/topic/topic-add.tpl' topic=$topicEdit type=$topicType blogs=$blogsAllow blogId=$blogId skipBlogs=$skipBlogs}
{/block}

View file

@ -389,16 +389,6 @@ jQuery(document).ready(function($){
// Приглашение пользователей в блог
$('.js-user-list-add-blog-invite').lsBlogInvites();
// Информация о блоге
$('.js-blog-info').lsBlogInfo({
urls: {
load: aRouter.blog + 'ajaxbloginfo'
},
selectors: {
select: '.js-topic-add-title'
}
});
// Вступить/покинуть блог
$( '.js-blog-join' ).livequery(function() {
$( this ).lsBlogJoin({

View file

@ -1,17 +0,0 @@
{**
* Информация о блоге показываемая при создании топика
*}
{extends 'components/block/block.tpl'}
{block 'block_title'}
{lang 'blog.blocks.info.title'}
{/block}
{block 'block_options' append}
{$mods = "{$mods} blog-info"}
{/block}
{block 'block_content'}
<p class="text js-blog-info"></p>
{/block}

View file

@ -13,7 +13,6 @@
"block.add": "blocks/block.blog-add.tpl",
"block.admins": "blocks/block.blog-admins.tpl",
"block.info-note": "blocks/block.blog-info-note.tpl",
"block.info": "blocks/block.blog-info.tpl",
"block.invite": "blocks/block.blog-invite.tpl",
"block.photo": "blocks/block.blog-photo.tpl",
"block.users": "blocks/block.blog-users.tpl",
@ -28,7 +27,6 @@
},
"scripts": {
"blog-add": "js/blog-add.js",
"blog-info": "js/blog-info.js",
"blog-invites": "js/blog-invites.js",
"blog-join": "js/blog-join.js"
},

View file

@ -1,66 +0,0 @@
/**
* Информация о блоге
*
* @module ls/blog/info
*
* @license GNU General Public License, version 2
* @copyright 2013 OOO "ЛС-СОФТ" {@link http://livestreetcms.com}
* @author Denis Shakhov <denis.shakhov@gmail.com>
*/
(function($) {
"use strict";
$.widget( "livestreet.lsBlogInfo", {
/**
* Дефолтные опции
*/
options: {
// Ссылки
urls: {
load: null
},
// Селекторы
selectors: {
select: null
}
},
/**
* Конструктор
*
* @constructor
* @private
*/
_create: function () {
var _this = this;
this.elements = {
select: $( this.option( 'selectors.select' ) )
};
this.elements.select.on( 'change' + this.eventNamespace, function () {
_this.load( _this.elements.select.val() );
});
this.load( this.elements.select.val() );
},
/**
*
*/
load: function( blogId ) {
if ( ! blogId ) return;
this.element.empty().addClass( ls.options.classes.states.loading );
ls.ajax.load( this.option( 'urls.load' ), { blog_id: blogId }, function( response ) {
if ( response.bStateError ) {
ls.msg.error( null, response.sMsg );
} else {
this.element.removeClass( ls.options.classes.states.loading ).html( response.text );
}
}.bind( this ));
}
});
})(jQuery);

Binary file not shown.

After

Width:  |  Height:  |  Size: 538 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 738 B

View file

@ -0,0 +1,437 @@
/*!
Chosen, a Select Box Enhancer for jQuery and Prototype
by Patrick Filler for Harvest, http://getharvest.com
Version 1.3.0
Full source at https://github.com/harvesthq/chosen
Copyright (c) 2011-2014 Harvest http://getharvest.com
MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md
This file is generated by `grunt build`, do not edit it by hand.
*/
/* @group Base */
.chosen-container {
position: relative;
display: inline-block;
vertical-align: middle;
font-size: 13px;
zoom: 1;
*display: inline;
-webkit-user-select: none;
-moz-user-select: none;
user-select: none;
}
.chosen-container * {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.chosen-container .chosen-drop {
position: absolute;
top: 100%;
left: -9999px;
z-index: 1010;
width: 100%;
border: 1px solid #aaa;
border-top: 0;
background: #fff;
box-shadow: 0 4px 5px rgba(0, 0, 0, 0.15);
}
.chosen-container.chosen-with-drop .chosen-drop {
left: 0;
}
.chosen-container a {
cursor: pointer;
}
/* @end */
/* @group Single Chosen */
.chosen-container-single .chosen-single {
position: relative;
display: block;
overflow: hidden;
padding: 0 0 0 8px;
height: 25px;
border: 1px solid #aaa;
border-radius: 5px;
background-color: #fff;
background: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(20%, #ffffff), color-stop(50%, #f6f6f6), color-stop(52%, #eeeeee), color-stop(100%, #f4f4f4));
background: -webkit-linear-gradient(top, #ffffff 20%, #f6f6f6 50%, #eeeeee 52%, #f4f4f4 100%);
background: -moz-linear-gradient(top, #ffffff 20%, #f6f6f6 50%, #eeeeee 52%, #f4f4f4 100%);
background: -o-linear-gradient(top, #ffffff 20%, #f6f6f6 50%, #eeeeee 52%, #f4f4f4 100%);
background: linear-gradient(top, #ffffff 20%, #f6f6f6 50%, #eeeeee 52%, #f4f4f4 100%);
background-clip: padding-box;
box-shadow: 0 0 3px white inset, 0 1px 1px rgba(0, 0, 0, 0.1);
color: #444;
text-decoration: none;
white-space: nowrap;
line-height: 24px;
}
.chosen-container-single .chosen-default {
color: #999;
}
.chosen-container-single .chosen-single span {
display: block;
overflow: hidden;
margin-right: 26px;
text-overflow: ellipsis;
white-space: nowrap;
}
.chosen-container-single .chosen-single-with-deselect span {
margin-right: 38px;
}
.chosen-container-single .chosen-single abbr {
position: absolute;
top: 6px;
right: 26px;
display: block;
width: 12px;
height: 12px;
background: url('chosen-sprite.png') -42px 1px no-repeat;
font-size: 1px;
}
.chosen-container-single .chosen-single abbr:hover {
background-position: -42px -10px;
}
.chosen-container-single.chosen-disabled .chosen-single abbr:hover {
background-position: -42px -10px;
}
.chosen-container-single .chosen-single div {
position: absolute;
top: 0;
right: 0;
display: block;
width: 18px;
height: 100%;
}
.chosen-container-single .chosen-single div b {
display: block;
width: 100%;
height: 100%;
background: url('chosen-sprite.png') no-repeat 0px 2px;
}
.chosen-container-single .chosen-search {
position: relative;
z-index: 1010;
margin: 0;
padding: 3px 4px;
white-space: nowrap;
}
.chosen-container-single .chosen-search input[type="text"] {
margin: 1px 0;
padding: 4px 20px 4px 5px;
width: 100%;
height: auto;
outline: 0;
border: 1px solid #aaa;
background: white url('chosen-sprite.png') no-repeat 100% -20px;
background: url('chosen-sprite.png') no-repeat 100% -20px;
font-size: 1em;
font-family: sans-serif;
line-height: normal;
border-radius: 0;
}
.chosen-container-single .chosen-drop {
margin-top: -1px;
border-radius: 0 0 4px 4px;
background-clip: padding-box;
}
.chosen-container-single.chosen-container-single-nosearch .chosen-search {
position: absolute;
left: -9999px;
}
/* @end */
/* @group Results */
.chosen-container .chosen-results {
color: #444;
position: relative;
overflow-x: hidden;
overflow-y: auto;
margin: 0 4px 4px 0;
padding: 0 0 0 4px;
max-height: 240px;
-webkit-overflow-scrolling: touch;
}
.chosen-container .chosen-results li {
display: none;
margin: 0;
padding: 5px 6px;
list-style: none;
line-height: 15px;
word-wrap: break-word;
-webkit-touch-callout: none;
}
.chosen-container .chosen-results li.active-result {
display: list-item;
cursor: pointer;
}
.chosen-container .chosen-results li.disabled-result {
display: list-item;
color: #ccc;
cursor: default;
}
.chosen-container .chosen-results li.highlighted {
background-color: #3875d7;
background-image: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(20%, #3875d7), color-stop(90%, #2a62bc));
background-image: -webkit-linear-gradient(#3875d7 20%, #2a62bc 90%);
background-image: -moz-linear-gradient(#3875d7 20%, #2a62bc 90%);
background-image: -o-linear-gradient(#3875d7 20%, #2a62bc 90%);
background-image: linear-gradient(#3875d7 20%, #2a62bc 90%);
color: #fff;
}
.chosen-container .chosen-results li.no-results {
color: #777;
display: list-item;
background: #f4f4f4;
}
.chosen-container .chosen-results li.group-result {
display: list-item;
font-weight: bold;
cursor: default;
}
.chosen-container .chosen-results li.group-option {
padding-left: 15px;
}
.chosen-container .chosen-results li em {
font-style: normal;
text-decoration: underline;
}
/* @end */
/* @group Multi Chosen */
.chosen-container-multi .chosen-choices {
position: relative;
overflow: hidden;
margin: 0;
padding: 0 5px;
width: 100%;
height: auto !important;
height: 1%;
border: 1px solid #aaa;
background-color: #fff;
background-image: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(1%, #eeeeee), color-stop(15%, #ffffff));
background-image: -webkit-linear-gradient(#eeeeee 1%, #ffffff 15%);
background-image: -moz-linear-gradient(#eeeeee 1%, #ffffff 15%);
background-image: -o-linear-gradient(#eeeeee 1%, #ffffff 15%);
background-image: linear-gradient(#eeeeee 1%, #ffffff 15%);
cursor: text;
}
.chosen-container-multi .chosen-choices li {
float: left;
list-style: none;
}
.chosen-container-multi .chosen-choices li.search-field {
margin: 0;
padding: 0;
white-space: nowrap;
}
.chosen-container-multi .chosen-choices li.search-field input[type="text"] {
margin: 1px 0;
padding: 0;
height: 25px;
outline: 0;
border: 0 !important;
background: transparent !important;
box-shadow: none;
color: #999;
font-size: 100%;
font-family: sans-serif;
line-height: normal;
border-radius: 0;
}
.chosen-container-multi .chosen-choices li.search-choice {
position: relative;
margin: 3px 5px 3px 0;
padding: 3px 20px 3px 5px;
border: 1px solid #aaa;
max-width: 100%;
border-radius: 3px;
background-color: #eeeeee;
background-image: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(20%, #f4f4f4), color-stop(50%, #f0f0f0), color-stop(52%, #e8e8e8), color-stop(100%, #eeeeee));
background-image: -webkit-linear-gradient(#f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%);
background-image: -moz-linear-gradient(#f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%);
background-image: -o-linear-gradient(#f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%);
background-image: linear-gradient(#f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%);
background-size: 100% 19px;
background-repeat: repeat-x;
background-clip: padding-box;
box-shadow: 0 0 2px white inset, 0 1px 0 rgba(0, 0, 0, 0.05);
color: #333;
line-height: 13px;
cursor: default;
}
.chosen-container-multi .chosen-choices li.search-choice span {
word-wrap: break-word;
}
.chosen-container-multi .chosen-choices li.search-choice .search-choice-close {
position: absolute;
top: 4px;
right: 3px;
display: block;
width: 12px;
height: 12px;
background: url('chosen-sprite.png') -42px 1px no-repeat;
font-size: 1px;
}
.chosen-container-multi .chosen-choices li.search-choice .search-choice-close:hover {
background-position: -42px -10px;
}
.chosen-container-multi .chosen-choices li.search-choice-disabled {
padding-right: 5px;
border: 1px solid #ccc;
background-color: #e4e4e4;
background-image: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(20%, #f4f4f4), color-stop(50%, #f0f0f0), color-stop(52%, #e8e8e8), color-stop(100%, #eeeeee));
background-image: -webkit-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%);
background-image: -moz-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%);
background-image: -o-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%);
background-image: linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%);
color: #666;
}
.chosen-container-multi .chosen-choices li.search-choice-focus {
background: #d4d4d4;
}
.chosen-container-multi .chosen-choices li.search-choice-focus .search-choice-close {
background-position: -42px -10px;
}
.chosen-container-multi .chosen-results {
margin: 0;
padding: 0;
}
.chosen-container-multi .chosen-drop .result-selected {
display: list-item;
color: #ccc;
cursor: default;
}
/* @end */
/* @group Active */
.chosen-container-active .chosen-single {
border: 1px solid #5897fb;
box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
}
.chosen-container-active.chosen-with-drop .chosen-single {
border: 1px solid #aaa;
-moz-border-radius-bottomright: 0;
border-bottom-right-radius: 0;
-moz-border-radius-bottomleft: 0;
border-bottom-left-radius: 0;
background-image: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(20%, #eeeeee), color-stop(80%, #ffffff));
background-image: -webkit-linear-gradient(#eeeeee 20%, #ffffff 80%);
background-image: -moz-linear-gradient(#eeeeee 20%, #ffffff 80%);
background-image: -o-linear-gradient(#eeeeee 20%, #ffffff 80%);
background-image: linear-gradient(#eeeeee 20%, #ffffff 80%);
box-shadow: 0 1px 0 #fff inset;
}
.chosen-container-active.chosen-with-drop .chosen-single div {
border-left: none;
background: transparent;
}
.chosen-container-active.chosen-with-drop .chosen-single div b {
background-position: -18px 2px;
}
.chosen-container-active .chosen-choices {
border: 1px solid #5897fb;
box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
}
.chosen-container-active .chosen-choices li.search-field input[type="text"] {
color: #222 !important;
}
/* @end */
/* @group Disabled Support */
.chosen-disabled {
opacity: 0.5 !important;
cursor: default;
}
.chosen-disabled .chosen-single {
cursor: default;
}
.chosen-disabled .chosen-choices .search-choice .search-choice-close {
cursor: default;
}
/* @end */
/* @group Right to Left */
.chosen-rtl {
text-align: right;
}
.chosen-rtl .chosen-single {
overflow: visible;
padding: 0 8px 0 0;
}
.chosen-rtl .chosen-single span {
margin-right: 0;
margin-left: 26px;
direction: rtl;
}
.chosen-rtl .chosen-single-with-deselect span {
margin-left: 38px;
}
.chosen-rtl .chosen-single div {
right: auto;
left: 3px;
}
.chosen-rtl .chosen-single abbr {
right: auto;
left: 26px;
}
.chosen-rtl .chosen-choices li {
float: right;
}
.chosen-rtl .chosen-choices li.search-field input[type="text"] {
direction: rtl;
}
.chosen-rtl .chosen-choices li.search-choice {
margin: 3px 5px 3px 0;
padding: 3px 5px 3px 19px;
}
.chosen-rtl .chosen-choices li.search-choice .search-choice-close {
right: auto;
left: 4px;
}
.chosen-rtl.chosen-container-single-nosearch .chosen-search,
.chosen-rtl .chosen-drop {
left: 9999px;
}
.chosen-rtl.chosen-container-single .chosen-results {
margin: 0 0 4px 4px;
padding: 0 4px 0 0;
}
.chosen-rtl .chosen-results li.group-option {
padding-right: 15px;
padding-left: 0;
}
.chosen-rtl.chosen-container-active.chosen-with-drop .chosen-single div {
border-right: none;
}
.chosen-rtl .chosen-search input[type="text"] {
padding: 4px 5px 4px 20px;
background: white url('chosen-sprite.png') no-repeat -30px -20px;
background: url('chosen-sprite.png') no-repeat -30px -20px;
direction: rtl;
}
.chosen-rtl.chosen-container-single .chosen-single div b {
background-position: 6px 2px;
}
.chosen-rtl.chosen-container-single.chosen-with-drop .chosen-single div b {
background-position: -12px 2px;
}
/* @end */
/* @group Retina compatibility */
@media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and (min-resolution: 144dpi) {
.chosen-rtl .chosen-search input[type="text"],
.chosen-container-single .chosen-single abbr,
.chosen-container-single .chosen-single div b,
.chosen-container-single .chosen-search input[type="text"],
.chosen-container-multi .chosen-choices .search-choice .search-choice-close,
.chosen-container .chosen-results-scroll-down span,
.chosen-container .chosen-results-scroll-up span {
background-image: url('chosen-sprite@2x.png') !important;
background-size: 52px 37px !important;
background-repeat: no-repeat !important;
}
}
/* @end */

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -20,6 +20,7 @@
"jquery.Jcrop": "jcrop/jquery.Jcrop.js",
"jquery.notifier": "notifier/jquery.notifier.js",
"jquery.colorbox": "colorbox/jquery.colorbox.js",
"jquery.chosen": "chosen/chosen.jquery.min.js",
"nprogress": "nprogress/nprogress.js",
"fotorama": "fotorama/fotorama.js",
@ -34,6 +35,7 @@
"jquery.notifier": "notifier/jquery.notifier.css",
"fotorama": "fotorama/fotorama.css",
"nprogress": "nprogress/nprogress.css",
"colorbox": "colorbox/colorbox.css"
"colorbox": "colorbox/colorbox.css",
"chosen": "chosen/chosen.min.css"
}
}

View file

@ -22,25 +22,27 @@
{* Выбор блога *}
{$items = [[
'value' => 0,
'text' => $aLang.topic.add.fields.blog.option_personal
]]}
{if !$smarty.local.skipBlogs}
<script type="text/javascript">
jQuery(function($){
$(".chosen-select").chosen({ max_selected_options: {Config::Get('module.topic.max_blog_count')} });
});
</script>
{foreach $smarty.local.blogs as $blog}
{$items[] = [
'value' => $blog->getId(),
'text' => $blog->getTitle()
]}
{/foreach}
{$blogsId=(( $topic ) ? $topic->getBlogsId() : [])}
{include 'components/field/field.select.tpl'
name = 'topic[blog_id]'
label = $aLang.topic.add.fields.blog.label
note = $aLang.topic.add.fields.blog.note
inputClasses = 'js-topic-add-title'
items = $items
selectedValue = {( $topic ) ? $topic->getBlogId() : $smarty.local.blogId}}
{$aLang.topic.add.fields.blog.label}
<select name="topic[blogs_id_raw][]" data-placeholder="Выберите блог для публикации" style="width:100%;" class="chosen-select" multiple>
<option value=""></option>
{foreach $smarty.local.blogs as $blogType => $blogs}
<optgroup label="{lang "blog.types.{$blogType}"}">
{foreach $blogs as $blog}
<option {if in_array($blog->getId(),$blogsId)}selected="selected"{/if} value="{$blog->getId()}">{$blog->getTitle()|escape}</option>
{/foreach}
</optgroup>
{/foreach}
</select>
{/if}
{* Заголовок топика *}

View file

@ -32,12 +32,16 @@
{* Название блога *}
{block 'article_header_info' prepend}
{$blog = $topic->getBlog()}
{$blogs = $topic->getBlogs()}
{if ! $isPreview}
<li class="{$component}-info-item {$component}-info-item--blog">
<a href="{$blog->getUrlFull()}">{$blog->getTitle()|escape}</a>
</li>
{foreach $blogs as $blog}
{if $blog->getType()!='personal'}
<li class="{$component}-info-item {$component}-info-item--blog">
<a href="{$blog->getUrlFull()}">{$blog->getTitle()|escape}</a>
</li>
{/if}
{/foreach}
{/if}
{/block}

View file

@ -823,3 +823,10 @@ ALTER TABLE `prefix_vote` CHANGE `vote_ip` `vote_ip` VARCHAR(40) CHARACTER SET u
ALTER TABLE `prefix_wall` CHANGE `ip` `ip` VARCHAR(40) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;
ALTER TABLE `prefix_topic` ADD `topic_skip_index` TINYINT(1) NOT NULL DEFAULT '0' AFTER `topic_publish_index`, ADD INDEX (`topic_skip_index`) ;
-- 30.12.2014
ALTER TABLE `prefix_topic` ADD `blog_id2` INT UNSIGNED NULL DEFAULT NULL AFTER `blog_id`, ADD `blog_id3` INT UNSIGNED NULL DEFAULT NULL AFTER `blog_id2`, ADD `blog_id4` INT UNSIGNED NULL DEFAULT NULL AFTER `blog_id3`, ADD `blog_id5` INT UNSIGNED NULL DEFAULT NULL AFTER `blog_id4`;
ALTER TABLE `prefix_topic` ADD INDEX(`blog_id2`);
ALTER TABLE `prefix_topic` ADD INDEX(`blog_id3`);
ALTER TABLE `prefix_topic` ADD INDEX(`blog_id4`);
ALTER TABLE `prefix_topic` ADD INDEX(`blog_id5`);