ModuleACL

Package application.modules.acl
Inheritance class ModuleACL » Module » LsObject
Since 1.0
Source Code /application/classes/modules/acl/ACL.class.php
ACL(Access Control List) Модуль для разруливания ограничений по карме/рейтингу юзера

Protected Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
_aBehaviors Список поведений в виде готовых объектов, формируется автоматически LsObject
aBehaviors array Список поведений LsObject
bIsInit bool Указывает на то, была ли проведенна инициализация модуля Module

Public Methods

Hide inherited methods

MethodDescriptionDefined By
AddBehaviorHook() Добавляет хук поведения LsObject
AttachBehavior() Присоединяет поведение к объекту LsObject
CanAddTalk() Проверяет возможность отправки личного сообщения ModuleACL
CanAddTopic() Проверяет может ли пользователь создавать топики ModuleACL
CanAddWallTime() Проверка на ограничение по времени на постинг на стене ModuleACL
CanCreateBlog() Проверяет может ли пользователь создавать блоги ModuleACL
CanDeleteComment() Проверяет может ли пользователь удалить комментарий ModuleACL
CanPostComment() Проверяет может ли пользователь создавать комментарии ModuleACL
CanPostTalkComment() Проверяет может ли пользователь создавать комментарии к личным сообщениям ModuleACL
CanPostTopicTime() Проверяет может ли пользователь создавать топик по времени ModuleACL
CanSendInvite() Проверяет можно ли юзеру слать инвайты ModuleACL
CanSendTalkTime() Проверяет может ли пользователь отправить инбокс по времени ModuleACL
CanVoteBlog() Проверяет может ли пользователь голосовать за конкретный блог ModuleACL
CanVoteComment() Проверяет может ли пользователь голосовать за конкретный комментарий ModuleACL
CanVoteTopic() Проверяет может ли пользователь голосовать за конкретный топик ModuleACL
CanVoteUser() Проверяет может ли пользователь голосовать за конкретного пользователя ModuleACL
DetachBehavior() Отсоединяет поведение от объекта LsObject
GetBehavior() Возвращает объект поведения по его имени LsObject
GetBehaviors() Возвращает все объекты поведения LsObject
Init() Инициализация модуля ModuleACL
IsAllowAdminBlog() Проверяет можно или нет пользователю управлять пользователями блога ModuleACL
IsAllowBlog() Проверяет можно или нет юзеру постить в данный блог ModuleACL
IsAllowDeleteBlog() Проверяет можно или нет пользователю удалять данный блог ModuleACL
IsAllowDeleteComment() Проверка на удаление комментария ModuleACL
IsAllowDeleteTopic() Проверяет можно или нет пользователю удалять данный топик ModuleACL
IsAllowEditBlog() Проверяет можно или нет пользователю редактировать данный блог ModuleACL
IsAllowEditComment() Проверка на редактирование комментария ModuleACL
IsAllowEditTopic() Проверяет можно или нет пользователю редактировать данный топик ModuleACL
IsAllowFavouriteComment() Проверка на возможность добавления комментария в избранное ModuleACL
IsAllowPublishIndex() Проверяет может ли пользователь публиковать на главной ModuleACL
IsAllowShowBlog() Проверяет можно или нет юзеру просматривать блог ModuleACL
IsAllowShowTopic() Проверка на возможность просмотра топика ModuleACL
RemoveBehaviorHook() Удаляет хук поведения LsObject
RunBehaviorHook() Запускает хук поведения на выполнение LsObject
SetInit() Помечает модуль как инициализированный Module
Shutdown() Метод срабатывает при завершении работы ядра Module
__call() Ставим хук на вызов неизвестного метода и считаем что хотели вызвать метод какого либо модуля LsObject
__clone() Блокируем копирование/клонирование объекта Module
__construct() Конструктор, запускается автоматически при создании объекта LsObject
__get() Обработка доступа к объекты поведения LsObject
isInit() Возвращает значение флага инициализации модуля Module

Protected Methods

Hide inherited methods

MethodDescriptionDefined By
PrepareBehaviors() Инициализация поведений LsObject

Method Details

CanAddTalk() method
public bool CanAddTalk(ModuleUser_EntityUser $oUser)
$oUser ModuleUser_EntityUser Пользователь
{return} bool
Source Code: /application/classes/modules/acl/ACL.class.php#185 (show)
public function CanAddTalk($oUser)
{
    
$that $this// fix for PHP < 5.4
    
return $this->Rbac_IsAllowUser($oUser'create_talk', array(
        
'callback' => function ($oUser$aParams) use ($that) {
            if (!
$oUser) {
                return 
false;
            }
            if (
$oUser->isAdministrator()) {
                return 
true;
            }
            if (!
$that->CanSendTalkTime($oUser)) {
                return 
$that->Lang_Get('talk.notices.time_limit');
            }
            return 
true;
        }
    ));
}

Проверяет возможность отправки личного сообщения

CanAddTopic() method
public bool CanAddTopic(ModuleUser_EntityUser $oUser, ModuleTopic_EntityTopicType $oTopicType)
$oUser ModuleUser_EntityUser Пользователь
$oTopicType ModuleTopic_EntityTopicType Объект типа топика
{return} bool
Source Code: /application/classes/modules/acl/ACL.class.php#81 (show)
public function CanAddTopic($oUser$oTopicType)
{
    
$that $this// fix for PHP < 5.4
    
return $this->Rbac_IsAllowUser($oUser'create_topic', array(
        
'callback' => function ($oUser$aParams) use ($that) {
            if (!
$oUser) {
                return 
false;
            }
            if (
$oUser->isAdministrator()) {
                return 
true;
            }
            
/**
             * Проверяем хватает ли рейтинга юзеру чтоб создать топик
             */
            
if ($oUser->getRating() <= Config::Get('acl.create.topic.limit_rating')) {
                return 
$that->Lang_Get('topic.add.notices.rating_limit');
            }
            
/**
             * Проверяем лимит по времени
             */
            
if (!$that->CanPostTopicTime($oUser)) {
                return 
$that->Lang_Get('topic.add.notices.time_limit');
            }
            return 
true;
        }
    ));
}

Проверяет может ли пользователь создавать топики

CanAddWallTime() method
public bool CanAddWallTime(ModuleUser_EntityUser $oUser, ModuleWall_EntityWall $oWall)
$oUser ModuleUser_EntityUser Пользователь
$oWall ModuleWall_EntityWall Объект сообщения на стене
{return} bool
Source Code: /application/classes/modules/acl/ACL.class.php#837 (show)
public function CanAddWallTime($oUser$oWall)
{
    
/**
     * Для администраторов ограничение по времени не действует
     */
    
if ($oUser->isAdministrator()
        or 
Config::Get('acl.create.wall.limit_time') == 0
        
or $oUser->getRating() >= Config::Get('acl.create.wall.limit_time_rating')
    ) {
        return 
true;
    }
    if (
$oWall->getUserId() == $oWall->getWallUserId()) {
        return 
true;
    }
    
/**
     * Получаем последнее сообщение
     */
    
$aWall $this->Wall_GetWall(array('user_id' => $oWall->getUserId()), array('id' => 'desc'), 11, array());
    
/**
     * Если сообщений нет
     */
    
if ($aWall['count'] == 0) {
        return 
true;
    }

    
$oWallLast array_shift($aWall['collection']);
    
$sDate strtotime($oWallLast->getDateAdd());
    if (
$sDate and ((time() - $sDate) < Config::Get('acl.create.wall.limit_time'))) {
        return 
false;
    }
    return 
true;
}

Проверка на ограничение по времени на постинг на стене

CanCreateBlog() method
public bool CanCreateBlog(ModuleUser_EntityUser $oUser)
$oUser ModuleUser_EntityUser Пользователь
{return} bool
Source Code: /application/classes/modules/acl/ACL.class.php#52 (show)
public function CanCreateBlog($oUser)
{
    
$that $this// fix for PHP < 5.4
    
return $this->Rbac_IsAllowUser($oUser'create_blog', array(
        
'callback' => function ($oUser$aParams) use ($that) {
            if (!
$oUser) {
                return 
false;
            }
            if (
$oUser->isAdministrator()) {
                return 
true;
            }
            
/**
             * Проверяем хватает ли рейтинга юзеру чтоб создать блог
             */
            
if ($oUser->getRating() < Config::Get('acl.create.blog.rating')) {
                return 
$that->Lang_Get('blog.add.alerts.acl');
            }
            return 
true;
        }
    ));
}

Проверяет может ли пользователь создавать блоги

CanDeleteComment() method
public bool CanDeleteComment(ModuleUser_EntityUser $oUser)
$oUser ModuleUser_EntityUser Пользователь
{return} bool
Source Code: /application/classes/modules/acl/ACL.class.php#751 (show)
public function CanDeleteComment($oUser)
{
    if (!
$oUser || !$oUser->isAdministrator()) {
        return 
false;
    }
    return 
true;
}

Проверяет может ли пользователь удалить комментарий

CanPostComment() method
public bool CanPostComment(ModuleUser_EntityUser $oUser, ModuleTopic_EntityTopic|null $oTopic=NULL)
$oUser ModuleUser_EntityUser Пользователь
$oTopic ModuleTopic_EntityTopic|null Топик
{return} bool
Source Code: /application/classes/modules/acl/ACL.class.php#116 (show)
public function CanPostComment($oUser$oTopic null)
{
    
$that $this// fix for PHP < 5.4
    
return $this->Rbac_IsAllowUser($oUser'create_topic_comment', array(
        
'callback' => function ($oUser$aParams) use ($that$oTopic) {
            if (!
$oUser) {
                return 
false;
            }
            if (
$oUser->isAdministrator()) {
                return 
true;
            }
            
/**
             * Проверяем на закрытый блог
             */
            
if ($oTopic and !$that->IsAllowShowBlog($oTopic->getBlog(), $oUser)) {
                return 
$that->Lang_Get('topic.comments.notices.acl');
            }
            
/**
             * Ограничение на рейтинг
             */
            
if ($oUser->getRating() < Config::Get('acl.create.comment.rating')) {
                return 
$that->Lang_Get('topic.comments.notices.acl');
            }
            
/**
             * Ограничение по времени
             */
            
if (Config::Get('acl.create.comment.limit_time') > and $oUser->getDateCommentLast()) {
                
$sDateCommentLast strtotime($oUser->getDateCommentLast());
                if (
$oUser->getRating() < Config::Get('acl.create.comment.limit_time_rating') and ((time() - $sDateCommentLast) < Config::Get('acl.create.comment.limit_time'))) {
                    return 
$that->Lang_Get('topic.comments.notices.limit');
                }
            }
            return 
true;
        }
    ));
}

Проверяет может ли пользователь создавать комментарии

CanPostTalkComment() method
public bool CanPostTalkComment(ModuleUser_EntityUser $oUser)
$oUser ModuleUser_EntityUser Пользователь
{return} bool
Source Code: /application/classes/modules/acl/ACL.class.php#236 (show)
public function CanPostTalkComment($oUser)
{
    
$that $this// fix for PHP < 5.4
    
return $this->Rbac_IsAllowUser($oUser'create_talk_comment', array(
        
'callback' => function ($oUser$aParams) use ($that) {
            if (!
$oUser) {
                return 
false;
            }
            if (
$oUser->isAdministrator()) {
                return 
true;
            }
            
$aTalkComments $that->Comment_GetCommentsByUserId($oUser->getId(), 'talk'11);
            
/**
             * Если комментариев не было
             */
            
if (!is_array($aTalkComments) or $aTalkComments['count'] == 0) {
                return 
true;
            }
            
/**
             * Достаем последний комментарий
             */
            
$oComment array_shift($aTalkComments['collection']);
            
$sDate strtotime($oComment->getDate());

            if (
$sDate and ((time() - $sDate) < Config::Get('acl.create.talk_comment.limit_time'))) {
                return 
$that->Lang_Get('talk.add.notices.time_limit');
            }
            return 
true;
        }
    ));
}

Проверяет может ли пользователь создавать комментарии к личным сообщениям

CanPostTopicTime() method
public bool CanPostTopicTime(ModuleUser_EntityUser $oUser)
$oUser ModuleUser_EntityUser Пользователь
{return} bool
Source Code: /application/classes/modules/acl/ACL.class.php#159 (show)
public function CanPostTopicTime($oUser)
{
    
// Для администраторов ограничение по времени не действует
    
if ($oUser->isAdministrator()
        or 
Config::Get('acl.create.topic.limit_time') == 0
        
or $oUser->getRating() >= Config::Get('acl.create.topic.limit_time_rating')
    ) {
        return 
true;
    }

    
/**
     * Проверяем, если топик опубликованный меньше чем acl.create.topic.limit_time секунд назад
     */
    
$aTopics $this->Topic_GetLastTopicsByUserId($oUser->getId(), Config::Get('acl.create.topic.limit_time'));
    if (isset(
$aTopics['count']) and $aTopics['count'] > 0) {
        return 
false;
    }
    return 
true;
}

Проверяет может ли пользователь создавать топик по времени

CanSendInvite() method
public bool CanSendInvite(ModuleUser_EntityUser $oUser)
$oUser ModuleUser_EntityUser Пользователь
{return} bool
Source Code: /application/classes/modules/acl/ACL.class.php#447 (show)
public function CanSendInvite($oUser)
{
    
$that $this// fix for PHP < 5.4
    
return $this->Rbac_IsAllowUser($oUser'vote_user', array(
        
'callback' => function ($oUser$aParams) use ($that) {
            if (!
$oUser) {
                return 
false;
            }
            if (
$oUser->isAdministrator()) {
                return 
true;
            }
            if (
$that->User_GetCountInviteAvailable($oUser) == 0) {
                return 
$that->Lang_Get('user.settings.invites.available_no');
            }
            return 
true;
        }
    ));
}

Проверяет можно ли юзеру слать инвайты

CanSendTalkTime() method
public bool CanSendTalkTime(ModuleUser_EntityUser $oUser)
$oUser ModuleUser_EntityUser Пользователь
{return} bool
Source Code: /application/classes/modules/acl/ACL.class.php#210 (show)
public function CanSendTalkTime($oUser)
{
    
// Для администраторов ограничение по времени не действует
    
if ($oUser->isAdministrator()
        or 
Config::Get('acl.create.talk.limit_time') == 0
        
or $oUser->getRating() >= Config::Get('acl.create.talk.limit_time_rating')
    ) {
        return 
true;
    }

    
/**
     * Проверяем, если топик опубликованный меньше чем acl.create.topic.limit_time секунд назад
     */
    
$aTalks $this->Talk_GetLastTalksByUserId($oUser->getId(), Config::Get('acl.create.talk.limit_time'));
    if (isset(
$aTalks['count']) and $aTalks['count'] > 0) {
        return 
false;
    }
    return 
true;
}

Проверяет может ли пользователь отправить инбокс по времени

CanVoteBlog() method
public bool CanVoteBlog(ModuleUser_EntityUser $oUser, ModuleBlog_EntityBlog $oBlog)
$oUser ModuleUser_EntityUser Пользователь
$oBlog ModuleBlog_EntityBlog Блог
{return} bool
Source Code: /application/classes/modules/acl/ACL.class.php#319 (show)
public function CanVoteBlog($oUser$oBlog)
{
    
$that $this// fix for PHP < 5.4
    
return $this->Rbac_IsAllowUser($oUser'vote_blog', array(
        
'callback' => function ($oUser$aParams) use ($that$oBlog) {
            if (!
$oUser) {
                return 
false;
            }
            
/**
             * Голосует за свой блог?
             */
            
if ($oBlog->getOwnerId() == $oUser->getId()) {
                return 
$that->Lang_Get('vote.notices.error_self');
            }
            
/**
             * Уже голосовал?
             */
            
if ($oBlogVote $that->Vote_GetVote($oBlog->getId(), 'blog'$oUser->getId())) {
                return 
$that->Lang_Get('vote.notices.error_already_voted');
            }
            
/**
             * Если блог закрытый, проверяем является ли пользователь его читателем
             */
            
if ($oBlog->getType() == 'close') {
                
$oBlogUser $that->Blog_GetBlogUserByBlogIdAndUserId($oBlog->getId(), $oUser->getId());
                if (!
$oBlogUser || $oBlogUser->getUserRole() < ModuleBlog::BLOG_USER_ROLE_GUEST) {
                    return 
$that->Lang_Get('blog.vote.notices.error_close');
                }
            } elseif (
$oBlog->getType() == 'personal') {
                return 
$that->Lang_Get('vote.notices.error_acl');
            }
            if (
$oUser->getRating() < Config::Get('acl.vote.blog.rating')) {
                return 
$that->Lang_Get('vote.notices.error_acl');
            }
            return 
true;
        }
    ));
}

Проверяет может ли пользователь голосовать за конкретный блог

CanVoteComment() method
public bool CanVoteComment(ModuleUser_EntityUser $oUser, ModuleComment_EntityComment $oComment)
$oUser ModuleUser_EntityUser Пользователь
$oComment ModuleComment_EntityComment Комментарий
{return} bool
Source Code: /application/classes/modules/acl/ACL.class.php#275 (show)
public function CanVoteComment($oUser$oComment)
{
    
$that $this// fix for PHP < 5.4
    
return $this->Rbac_IsAllowUser($oUser'vote_comment', array(
        
'callback' => function ($oUser$aParams) use ($that$oComment) {
            if (!
$oUser) {
                return 
false;
            }
            
/**
             * Голосует автор комментария?
             */
            
if ($oComment->getUserId() == $oUser->getId()) {
                return 
$that->Lang_Get('vote.notices.error_self');
            }
            
/**
             * Пользователь уже голосовал?
             */
            
if ($oTopicCommentVote $that->Vote_GetVote($oComment->getId(), 'comment'$oUser->getId())) {
                return 
$that->Lang_Get('vote.notices.error_already_voted');
            }
            
/**
             * Ограничение по рейтингу
             */
            
if ($oUser->getRating() < Config::Get('acl.vote.comment.rating')) {
                return 
$that->Lang_Get('vote.notices.error_acl');
            }
            
/**
             * Время голосования истекло?
             */
            
if (strtotime($oComment->getDate()) <= time() - Config::Get('acl.vote.comment.limit_time')) {
                return 
$that->Lang_Get('vote.notices.error_time');
            }
            return 
true;
        }
    ));
}

Проверяет может ли пользователь голосовать за конкретный комментарий

CanVoteTopic() method
public bool CanVoteTopic(ModuleUser_EntityUser $oUser, ModuleTopic_EntityTopic $oTopic, int $iValue)
$oUser ModuleUser_EntityUser Пользователь
$oTopic ModuleTopic_EntityTopic Топик
$iValue int Направление голосования
{return} bool
Source Code: /application/classes/modules/acl/ACL.class.php#366 (show)
public function CanVoteTopic($oUser$oTopic$iValue)
{
    
$that $this// fix for PHP < 5.4
    
return $this->Rbac_IsAllowUser($oUser'vote_topic', array(
        
'callback' => function ($oUser$aParams) use ($that$oTopic$iValue) {
            if (!
$oUser) {
                return 
false;
            }
            
/**
             * Голосует автор топика?
             */
            
if ($oTopic->getUserId() == $oUser->getId()) {
                return 
$that->Lang_Get('vote.notices.error_self');
            }
            
/**
             * Пользователь уже голосовал?
             */
            
if ($oTopicVote $that->Vote_GetVote($oTopic->getId(), 'topic'$oUser->getId())) {
                return 
$that->Lang_Get('vote.notices.error_already_voted');
            }
            
/**
             * Время голосования истекло?
             */
            
if (strtotime($oTopic->getDateAdd()) <= time() - Config::Get('acl.vote.topic.limit_time')) {
                return 
$that->Lang_Get('vote.notices.error_time');
            }
            
/**
             * Ограничение по рейтингу
             */
            
if ($iValue != and $oUser->getRating() < Config::Get('acl.vote.topic.rating')) {
                return 
$that->Lang_Get('vote.notices.error_acl');
            }
            return 
true;
        }
    ));
}

Проверяет может ли пользователь голосовать за конкретный топик

CanVoteUser() method
public bool CanVoteUser(ModuleUser_EntityUser $oUser, ModuleUser_EntityUser $oUserTarget)
$oUser ModuleUser_EntityUser Пользователь
$oUserTarget ModuleUser_EntityUser Пользователь за которого голосуем
{return} bool
Source Code: /application/classes/modules/acl/ACL.class.php#410 (show)
public function CanVoteUser($oUser$oUserTarget)
{
    
$that $this// fix for PHP < 5.4
    
return $this->Rbac_IsAllowUser($oUser'vote_user', array(
        
'callback' => function ($oUser$aParams) use ($that$oUserTarget) {
            if (!
$oUser) {
                return 
false;
            }
            
/**
             * Голосует за себя?
             */
            
if ($oUserTarget->getId() == $oUser->getId()) {
                return 
$that->Lang_Get('vote.notices.error_self');
            }
            
/**
             * Уже голосовал?
             */
            
if ($oUserVote $that->Vote_GetVote($oUserTarget->getId(), 'user'$oUser->getId())) {
                return 
$that->Lang_Get('vote.notices.error_already_voted');
            }
            
/**
             * Ограничение по рейтингу
             */
            
if ($oUser->getRating() < Config::Get('acl.vote.user.rating')) {
                return 
$that->Lang_Get('vote.notices.error_acl');
            }
            return 
true;
        }
    ));
}

Проверяет может ли пользователь голосовать за конкретного пользователя

Init() method
public void Init()
Source Code: /application/classes/modules/acl/ACL.class.php#41 (show)
public function Init()
{

}

Инициализация модуля

IsAllowAdminBlog() method
public bool IsAllowAdminBlog(ModuleBlog_EntityBlog $oBlog, ModuleUser_EntityUser $oUser)
$oBlog ModuleBlog_EntityBlog Блог
$oUser ModuleUser_EntityUser Пользователь
{return} bool
Source Code: /application/classes/modules/acl/ACL.class.php#809 (show)
public function IsAllowAdminBlog($oBlog$oUser)
{
    if (
$oUser->isAdministrator()) {
        return 
true;
    }
    
/**
     * Разрешаем если это создатель блога
     */
    
if ($oBlog->getOwnerId() == $oUser->getId()) {
        return 
true;
    }
    
/**
     * Явлется ли авторизованный пользователь администратором блога
     */
    
$oBlogUser $this->Blog_GetBlogUserByBlogIdAndUserId($oBlog->getId(), $oUser->getId());
    if (
$oBlogUser && $oBlogUser->getIsAdministrator()) {
        return 
true;
    }
    return 
false;
}

Проверяет можно или нет пользователю управлять пользователями блога

IsAllowBlog() method
public bool IsAllowBlog(ModuleBlog_EntityBlog $oBlog, ModuleUser_EntityUser $oUser)
$oBlog ModuleBlog_EntityBlog Блог
$oUser ModuleUser_EntityUser Пользователь
{return} bool
Source Code: /application/classes/modules/acl/ACL.class.php#473 (show)
public function IsAllowBlog($oBlog$oUser)
{
    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()) {
            return 
true;
        }
    }
    return 
false;
}

Проверяет можно или нет юзеру постить в данный блог

IsAllowDeleteBlog() method
public bool IsAllowDeleteBlog(ModuleBlog_EntityBlog $oBlog, ModuleUser_EntityUser $oUser)
$oBlog ModuleBlog_EntityBlog Блог
$oUser ModuleUser_EntityUser Пользователь
{return} bool
Source Code: /application/classes/modules/acl/ACL.class.php#723 (show)
public function IsAllowDeleteBlog($oBlog$oUser)
{
    
/**
     * Разрешаем если это админ сайта или автор блога
     */
    
if ($oUser->isAdministrator()) {
        return 
self::CAN_DELETE_BLOG_WITH_TOPICS;
    }
    
/**
     * Разрешаем удалять администраторам блога и автору, но только пустой
     */
    
if ($oBlog->getOwnerId() == $oUser->getId()) {
        return 
self::CAN_DELETE_BLOG_EMPTY_ONLY;
    }

    
$oBlogUser $this->Blog_GetBlogUserByBlogIdAndUserId($oBlog->getId(), $oUser->getId());
    if (
$oBlogUser and $oBlogUser->getIsAdministrator()) {
        return 
self::CAN_DELETE_BLOG_EMPTY_ONLY;
    }
    return 
false;
}

Проверяет можно или нет пользователю удалять данный блог

IsAllowDeleteComment() method
public bool IsAllowDeleteComment(ModuleComment_EntityComment $oComment, ModuleUser_EntityUser $oUser)
$oComment ModuleComment_EntityComment
$oUser ModuleUser_EntityUser
{return} bool
Source Code: /application/classes/modules/acl/ACL.class.php#629 (show)
public function IsAllowDeleteComment($oComment$oUser)
{
    
/**
     * Разрешаем если это админ сайта
     */
    
if ($oUser and $oUser->isAdministrator()) {
        return 
true;
    }
    return 
false;
}

Проверка на удаление комментария

IsAllowDeleteTopic() method
public bool IsAllowDeleteTopic(ModuleTopic_EntityTopic $oTopic, ModuleUser_EntityUser $oUser)
$oTopic ModuleTopic_EntityTopic Топик
$oUser ModuleUser_EntityUser Пользователь
{return} bool
Source Code: /application/classes/modules/acl/ACL.class.php#647 (show)
public function IsAllowDeleteTopic($oTopic$oUser)
{
    
$that $this// fix for PHP < 5.4
    
return $this->Rbac_IsAllowUser($oUser'remove_topic', array(
        
'callback' => function ($oUser$aParams) use ($that$oTopic) {
            if (!
$oUser) {
                return 
false;
            }
            
/**
             * Разрешаем если это админ сайта или автор топика
             */
            
if ($oTopic->getUserId() == $oUser->getId() or $oUser->isAdministrator()) {
                return 
true;
            }
            
/**
             * Если автор(смотритель) блога
             */
            
if ($oTopic->getBlog()->getOwnerId() == $oUser->getId()) {
                return 
true;
            }
            
/**
             * Если модер или админ блога
             */
            
if ($that->User_GetUserCurrent() and $that->User_GetUserCurrent()->getId() == $oUser->getId()) {
                
/**
                 * Для авторизованного пользователя данный код будет работать быстрее
                 */
                
if ($oTopic->getBlog()->getUserIsAdministrator() or $oTopic->getBlog()->getUserIsModerator()) {
                    return 
true;
                }
            } else {
                
$oBlogUser $that->Blog_GetBlogUserByBlogIdAndUserId($oTopic->getBlogId(), $oUser->getId());
                if (
$oBlogUser and ($oBlogUser->getIsModerator() or $oBlogUser->getIsAdministrator())) {
                    return 
true;
                }
            }
            return 
false;
        }
    ));
}

Проверяет можно или нет пользователю удалять данный топик

IsAllowEditBlog() method
public bool IsAllowEditBlog(ModuleBlog_EntityBlog $oBlog, ModuleUser_EntityUser $oUser)
$oBlog ModuleBlog_EntityBlog Блог
$oUser ModuleUser_EntityUser Пользователь
{return} bool
Source Code: /application/classes/modules/acl/ACL.class.php#780 (show)
public function IsAllowEditBlog($oBlog$oUser)
{
    if (
$oUser->isAdministrator()) {
        return 
true;
    }
    
/**
     * Разрешаем если это создатель блога
     */
    
if ($oBlog->getOwnerId() == $oUser->getId()) {
        return 
true;
    }
    
/**
     * Явлется ли авторизованный пользователь администратором блога
     */
    
$oBlogUser $this->Blog_GetBlogUserByBlogIdAndUserId($oBlog->getId(), $oUser->getId());

    if (
$oBlogUser && $oBlogUser->getIsAdministrator()) {
        return 
true;
    }
    return 
false;
}

Проверяет можно или нет пользователю редактировать данный блог

IsAllowEditComment() method
public bool IsAllowEditComment(ModuleComment_EntityComment $oComment, ModuleUser_EntityUser $oUser)
$oComment ModuleComment_EntityComment
$oUser ModuleUser_EntityUser
{return} bool
Source Code: /application/classes/modules/acl/ACL.class.php#564 (show)
public function IsAllowEditComment($oComment$oUser)
{
    if (!
$oUser) {
        return 
false;
    }
    if (!
in_array($oComment->getTargetType(), (array)Config::Get('module.comment.edit_target_allow'))) {
        return 
false;
    }
    if (
$oUser->isAdministrator()) {
        return 
true;
    }
    if (
$oComment->getUserId() == $oUser->getId() and $oUser->getRating() >= Config::Get('acl.update.comment.rating')) {
        
/**
         * Проверяем на лимит времени
         */
        
if (!Config::Get('acl.update.comment.limit_time') or (time() - strtotime($oComment->getDate()) <= Config::Get('acl.update.comment.limit_time'))) {
            return 
true;
        }
    }
    return 
false;
}

Проверка на редактирование комментария

IsAllowEditTopic() method
public bool IsAllowEditTopic(ModuleTopic_EntityTopic $oTopic, ModuleUser_EntityUser $oUser)
$oTopic ModuleTopic_EntityTopic Топик
$oUser ModuleUser_EntityUser Пользователь
{return} bool
Source Code: /application/classes/modules/acl/ACL.class.php#522 (show)
public function IsAllowEditTopic($oTopic$oUser)
{
    
/**
     * Разрешаем если это админ сайта или автор топика
     */
    
if ($oTopic->getUserId() == $oUser->getId() or $oUser->isAdministrator()) {
        return 
true;
    }
    
/**
     * Если автор(смотритель) блога
     */
    
if ($oTopic->getBlog()->getOwnerId() == $oUser->getId()) {
        return 
true;
    }
    
/**
     * Если модер или админ блога
     */
    
if ($this->User_GetUserCurrent() and $this->User_GetUserCurrent()->getId() == $oUser->getId()) {
        
/**
         * Для авторизованного пользователя данный код будет работать быстрее
         */
        
if ($oTopic->getBlog()->getUserIsAdministrator() or $oTopic->getBlog()->getUserIsModerator()) {
            return 
true;
        }
    } else {
        
$oBlogUser $this->Blog_GetBlogUserByBlogIdAndUserId($oTopic->getBlogId(), $oUser->getId());
        if (
$oBlogUser and ($oBlogUser->getIsModerator() or $oBlogUser->getIsAdministrator())) {
            return 
true;
        }
    }

    return 
false;
}

Проверяет можно или нет пользователю редактировать данный топик

IsAllowFavouriteComment() method
public bool IsAllowFavouriteComment($oComment $oComment, $oUser $oUser)
$oComment $oComment
$oUser $oUser
{return} bool
Source Code: /application/classes/modules/acl/ACL.class.php#594 (show)
public function IsAllowFavouriteComment($oComment$oUser)
{
    
$that $this// fix for PHP < 5.4
    
return $this->Rbac_IsAllowUser($oUser'create_comment_favourite', array(
        
'callback' => function ($oUser$aParams) use ($that$oComment) {
            if (!
$oUser) {
                return 
false;
            }
            if (!
in_array($oComment->getTargetType(), array('topic'))) {
                return 
false;
            }
            if (!
$oTarget $oComment->getTarget()) {
                return 
false;
            }
            if (
$oComment->getTargetType() == 'topic') {
                
/**
                 * Проверяем права на просмотр топика
                 */
                
if (!$that->IsAllowShowTopic($oTarget$oUser)) {
                    return 
false;
                }
            }
            return 
true;
        }
    ));
}

Проверка на возможность добавления комментария в избранное

IsAllowPublishIndex() method
public bool IsAllowPublishIndex(ModuleUser_EntityUser $oUser)
$oUser ModuleUser_EntityUser Пользователь
{return} bool
Source Code: /application/classes/modules/acl/ACL.class.php#765 (show)
public function IsAllowPublishIndex(ModuleUser_EntityUser $oUser)
{
    if (
$oUser->isAdministrator()) {
        return 
true;
    }
    return 
false;
}

Проверяет может ли пользователь публиковать на главной

IsAllowShowBlog() method
public bool IsAllowShowBlog(ModuleBlog_EntityBlog $oBlog, ModuleUser_EntityUser $oUser)
$oBlog ModuleBlog_EntityBlog Блог
$oUser ModuleUser_EntityUser Пользователь
{return} bool
Source Code: /application/classes/modules/acl/ACL.class.php#496 (show)
public function IsAllowShowBlog($oBlog$oUser)
{
    if (
$oBlog->getType() != 'close') {
        return 
true;
    }
    if (
$oUser->isAdministrator()) {
        return 
true;
    }
    if (
$oBlog->getOwnerId() == $oUser->getId()) {
        return 
true;
    }
    if (
$oBlogUser $this->Blog_GetBlogUserByBlogIdAndUserId($oBlog->getId(),
            
$oUser->getId()) and $oBlogUser->getUserRole() > ModuleBlog::BLOG_USER_ROLE_GUEST
    
) {
        return 
true;
    }
    return 
false;
}

Проверяет можно или нет юзеру просматривать блог

IsAllowShowTopic() method
public bool IsAllowShowTopic($oTopic $oTopic, $oUser $oUser)
$oTopic $oTopic
$oUser $oUser
{return} bool
Source Code: /application/classes/modules/acl/ACL.class.php#696 (show)
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;
}

Проверка на возможность просмотра топика