mirror of
https://github.com/Oreolek/ifhub.club.git
synced 2024-06-16 23:00:51 +03:00
Доработка различных проверок прав доступа
This commit is contained in:
parent
03bde7e614
commit
023e868896
|
@ -1013,6 +1013,14 @@ class ActionAjax extends Action {
|
|||
if (!in_array($oComment->getTargetType(),(array)Config::Get('module.comment.vote_target_allow'))) {
|
||||
return $this->EventErrorDebug();
|
||||
}
|
||||
if ($oComment->getTargetType()=='topic') {
|
||||
/**
|
||||
* Проверяем права на просмотр топика
|
||||
*/
|
||||
if (!$this->ACL_IsAllowShowTopic($oComment->getTarget(),$this->oUserCurrent)) {
|
||||
return parent::EventNotFound();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Голосует автор комментария?
|
||||
*/
|
||||
|
@ -1092,6 +1100,12 @@ class ActionAjax extends Action {
|
|||
if (!($oTopic=$this->Topic_GetTopicById(getRequestStr('iTargetId',null,'post')))) {
|
||||
return $this->EventErrorDebug();
|
||||
}
|
||||
/**
|
||||
* Проверяем права на просмотр топика
|
||||
*/
|
||||
if (!$this->ACL_IsAllowShowTopic($oTopic,$this->oUserCurrent)) {
|
||||
return parent::EventNotFound();
|
||||
}
|
||||
/**
|
||||
* Голосует автор топика?
|
||||
*/
|
||||
|
@ -1395,6 +1409,12 @@ class ActionAjax extends Action {
|
|||
if (!($oTopic=$this->Topic_GetTopicById(getRequestStr('iTargetId',null,'post')))) {
|
||||
return $this->EventErrorDebug();
|
||||
}
|
||||
/**
|
||||
* Есть доступ к комментариям этого топика? Закрытый блог?
|
||||
*/
|
||||
if (!$this->ACL_IsAllowShowBlog($oTopic->getBlog(),$this->oUserCurrent)) {
|
||||
return $this->EventErrorDebug();
|
||||
}
|
||||
/**
|
||||
* Пропускаем топик из черновиков
|
||||
*/
|
||||
|
@ -1468,6 +1488,12 @@ class ActionAjax extends Action {
|
|||
if (!($oComment=$this->Comment_GetCommentById(getRequestStr('iTargetId',null,'post')))) {
|
||||
return $this->EventErrorDebug();
|
||||
}
|
||||
/**
|
||||
* Есть доступ к комментарию?
|
||||
*/
|
||||
if (!$this->ACL_IsAllowFavouriteComment($oComment,$this->oUserCurrent)) {
|
||||
return $this->EventErrorDebug();
|
||||
}
|
||||
/**
|
||||
* Комментарий уже в избранном?
|
||||
*/
|
||||
|
@ -1532,6 +1558,12 @@ class ActionAjax extends Action {
|
|||
if (!($oTalk=$this->Talk_GetTalkById(getRequestStr('iTargetId',null,'post')))) {
|
||||
return $this->EventErrorDebug();
|
||||
}
|
||||
/**
|
||||
* Есть доступ?
|
||||
*/
|
||||
if (!($oTalkUser=$this->Talk_GetTalkUser($oTalk->getId(),$this->oUserCurrent->getId()))) {
|
||||
return $this->EventErrorDebug();
|
||||
}
|
||||
/**
|
||||
* Сообщение уже в избранном?
|
||||
*/
|
||||
|
|
|
@ -705,23 +705,9 @@ class ActionBlog extends Action {
|
|||
/**
|
||||
* Проверяем права на просмотр топика
|
||||
*/
|
||||
if (!$oTopic->getPublish() and (!$this->oUserCurrent or ($this->oUserCurrent->getId()!=$oTopic->getUserId() and !$this->oUserCurrent->isAdministrator()))) {
|
||||
if (!$this->ACL_IsAllowShowTopic($oTopic,$this->oUserCurrent)) {
|
||||
return parent::EventNotFound();
|
||||
}
|
||||
/**
|
||||
* Определяем права на отображение записи из закрытого блога
|
||||
*/
|
||||
if($oTopic->getBlog()->getType()=='close'
|
||||
and (!$this->oUserCurrent
|
||||
|| !in_array(
|
||||
$oTopic->getBlog()->getId(),
|
||||
$this->Blog_GetAccessibleBlogsByUser($this->oUserCurrent)
|
||||
)
|
||||
)
|
||||
) {
|
||||
$this->Message_AddErrorSingle($this->Lang_Get('blog_close_show'),$this->Lang_Get('not_access'));
|
||||
return Router::Action('error');
|
||||
}
|
||||
/**
|
||||
* Если запросили топик из персонального блога то перенаправляем на страницу вывода коллективного топика
|
||||
*/
|
||||
|
@ -1015,13 +1001,13 @@ class ActionBlog extends Action {
|
|||
$this->Message_AddErrorSingle($this->Lang_Get('system_error'),$this->Lang_Get('error'));
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Возможность постить коммент в топик в черновиках
|
||||
*/
|
||||
if (!$oTopic->getPublish() and $this->oUserCurrent->getId()!=$oTopic->getUserId() and !$this->oUserCurrent->isAdministrator()) {
|
||||
$this->Message_AddErrorSingle($this->Lang_Get('system_error'),$this->Lang_Get('error'));
|
||||
$bOk = false;
|
||||
}
|
||||
/**
|
||||
* Права на просмотр топика
|
||||
*/
|
||||
if (!$this->ACL_IsAllowShowTopic($oTopic,$this->oUserCurrent)) {
|
||||
$this->Message_AddErrorSingle($this->Lang_Get('system_error'),$this->Lang_Get('error'));
|
||||
$bOk = false;
|
||||
}
|
||||
/**
|
||||
* Проверяем разрешено ли постить комменты
|
||||
*/
|
||||
|
@ -1138,14 +1124,14 @@ class ActionBlog extends Action {
|
|||
}
|
||||
|
||||
/**
|
||||
* Проверка на соответсвие коментария требованиям безопасности
|
||||
* Проверка на соответсвие комментария требованиям безопасности
|
||||
*/
|
||||
if (!$this->CheckComment($oTopic, $sText)) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Проверка на соответсвие коментария родительскому коментарию
|
||||
* Проверка на соответсвие комментария родительскому коментарию
|
||||
*/
|
||||
if (!$this->CheckParentComment($oTopic, $sText, $oCommentParent)) {
|
||||
return;
|
||||
|
@ -1333,6 +1319,12 @@ class ActionBlog extends Action {
|
|||
if(!$oBlog=$this->Blog_GetBlogById($sBlogId) or !is_array($aUsers)) {
|
||||
return $this->EventErrorDebug();
|
||||
}
|
||||
/**
|
||||
* Проверяем тип блога
|
||||
*/
|
||||
if ($oBlog->getType()!='close') {
|
||||
return $this->EventErrorDebug();
|
||||
}
|
||||
/**
|
||||
* Проверяем, имеет ли право текущий пользователь добавлять invite в blog
|
||||
*/
|
||||
|
@ -1343,7 +1335,7 @@ class ActionBlog extends Action {
|
|||
}
|
||||
/**
|
||||
* Получаем список пользователей блога (любого статуса)
|
||||
* Это полный АХТУНГ - исправить!
|
||||
* todo: Это полный АХТУНГ - исправить!
|
||||
*/
|
||||
$aBlogUsersResult = $this->Blog_GetBlogUsersByBlogId(
|
||||
$oBlog->getId(),
|
||||
|
|
|
@ -558,6 +558,9 @@ class ActionTalk extends Action {
|
|||
if (!($oTalk=$this->Talk_GetTalkById(getRequestStr('idTarget')))) {
|
||||
return $this->EventErrorDebug();
|
||||
}
|
||||
/**
|
||||
* Доступен?
|
||||
*/
|
||||
if (!($oTalkUser=$this->Talk_GetTalkUser($oTalk->getId(),$this->oUserCurrent->getId()))) {
|
||||
return $this->EventErrorDebug();
|
||||
}
|
||||
|
|
|
@ -218,6 +218,8 @@ class ModuleACL extends Module {
|
|||
if(!$oBlogUser || $oBlogUser->getUserRole()<ModuleBlog::BLOG_USER_ROLE_GUEST) {
|
||||
return self::CAN_VOTE_BLOG_ERROR_CLOSE;
|
||||
}
|
||||
} elseif($oBlog->getType()=='personal') {
|
||||
return self::CAN_VOTE_BLOG_FALSE;
|
||||
}
|
||||
if ($oUser->getRating()>=Config::Get('acl.vote.blog.rating')) {
|
||||
return self::CAN_VOTE_BLOG_TRUE;
|
||||
|
@ -375,6 +377,31 @@ class ModuleACL extends Module {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Проверка на возможность добавления комментария в избранное
|
||||
*
|
||||
* @param $oComment
|
||||
* @param $oUser
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function IsAllowFavouriteComment($oComment,$oUser) {
|
||||
if (!in_array($oComment->getTargetType(),array('topic'))) {
|
||||
return false;
|
||||
}
|
||||
if (!$oTarget=$oComment->getTarget()) {
|
||||
return false;
|
||||
}
|
||||
if ($oComment->getTargetType()=='topic') {
|
||||
/**
|
||||
* Проверяем права на просмотр топика
|
||||
*/
|
||||
if (!$this->IsAllowShowTopic($oTarget,$oUser)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Проверка на удаление комментария
|
||||
*
|
||||
|
@ -430,6 +457,32 @@ class ModuleACL extends Module {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Проверка на возможность просмотра топика
|
||||
*
|
||||
* @param $oTopic
|
||||
* @param $oUser
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function IsAllowShowTopic($oTopic,$oUser) {
|
||||
if (!$oTopic) {
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Проверяем права на просмотр топика
|
||||
*/
|
||||
if (!$oTopic->getPublish() and (!$oUser or ($oUser->getId()!=$oTopic->getUserId() and !$oUser->isAdministrator()))) {
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Определяем права на отображение записи из закрытого блога
|
||||
*/
|
||||
if (!$this->IsAllowShowBlog($oTopic->getBlog(),$oUser)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Проверяет можно или нет пользователю удалять данный блог
|
||||
*
|
||||
|
|
|
@ -630,6 +630,7 @@ class ModuleComment extends Module {
|
|||
$aCmt=array();
|
||||
foreach ($aCmts as $oComment) {
|
||||
$oViewerLocal->Assign('oComment',$oComment,true);
|
||||
$oViewerLocal->Assign('bIsHidden',$oComment->getDelete(),true);
|
||||
$sText=$oViewerLocal->Fetch($this->GetTemplateCommentByTarget($sId,$sTargetType));
|
||||
$aCmt[]=array(
|
||||
'html' => $sText,
|
||||
|
|
|
@ -174,14 +174,14 @@ jQuery(document).ready(function($){
|
|||
urls: {
|
||||
add: aRouter['blog'] + 'ajaxaddcomment/',
|
||||
load: aRouter['blog'] + 'ajaxresponsecomment/'
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
$('.js-comments-talk').lsComments({
|
||||
urls: {
|
||||
add: aRouter['talk'] + 'ajaxaddcomment/',
|
||||
load: aRouter['talk'] + 'ajaxresponsecomment/'
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
{extends 'components/user_list_small/user_list_small_item.tpl'}
|
||||
|
||||
{block 'components/user_list_small/user_list_small_item_actions'}
|
||||
<li class="icon-repeat js-blog-invite-user-repeat" title="{$aLang.common.remove}" data-user-id="{$iUserId}"></li>
|
||||
<li class="icon-repeat js-blog-invite-user-repeat" title="{$aLang.blog.invite.repeat}" data-user-id="{$iUserId}"></li>
|
||||
|
||||
{$smarty.block.parent}
|
||||
{/block}
|
|
@ -1 +1 @@
|
|||
Subproject commit 2a9e9c2199fbf5d392666813102b42bfe284ff5b
|
||||
Subproject commit 466bc844b776fc3ab761f113036c2c2d75f6f081
|
Loading…
Reference in a new issue