/** * Adds new topic * * @param $oTopic * * @return bool|ModuleTopic_EntityTopic */ protected function _addTopic($oTopic) { if (!E::IsAdminOrModerator()) { $xUserRatingOut = C::Val('plugin.sandbox.user_rating_out', false); if ($xUserRatingOut === false || E::User()->getUserRating() < $xUserRatingOut) { $oTopic->setTopicStatus(TOPIC_STATUS_SANDBOX); } } return parent::_addTopic($oTopic); }
/** * Проверяет доступность того или иного целевого объекта, переопределяется * плагинами. По умолчанию всё грузить запрещено. * Если всё нормально и пользователю разрешено сюда загружать картинки, * то метод возвращает целевой объект, иначе значение FALSE. * * @param string $sTarget * @param int $iTargetId * * @return bool */ public function CheckAccessAndGetTarget($sTarget, $iTargetId = null) { // Проверяем право пользователя на прикрепление картинок к топику if (mb_strpos($sTarget, 'single-image-uploader') === 0 || $sTarget == 'photoset') { // Проверям, авторизован ли пользователь if (!E::IsUser()) { return FALSE; } // Топик редактируется if ($oTopic = E::ModuleTopic()->GetTopicById($iTargetId)) { if (!E::ModuleACL()->IsAllowEditTopic($oTopic, E::User())) { return FALSE; } return $oTopic; } return TRUE; } // Загружать аватарки можно только в свой профиль if ($sTarget == 'profile_avatar') { if ($iTargetId && E::IsUser() && $iTargetId == E::UserId()) { return E::User(); } return FALSE; } // Загружать аватарки можно только в свой профиль if ($sTarget == 'profile_photo') { if ($iTargetId && E::IsUser() && $iTargetId == E::UserId()) { return E::User(); } return FALSE; } if ($sTarget == 'blog_avatar') { /** @var ModuleBlog_EntityBlog $oBlog */ $oBlog = E::ModuleBlog()->GetBlogById($iTargetId); if (!E::IsUser()) { return false; } if (!$oBlog) { // Блог еще не создан return E::ModuleACL()->CanCreateBlog(E::User()) || E::IsAdminOrModerator(); } if ($oBlog && (E::ModuleACL()->CheckBlogEditBlog($oBlog, E::User()) || E::IsAdminOrModerator())) { return $oBlog; } return ''; } if ($sTarget == 'topic') { if (!E::IsUser()) { return false; } /** @var ModuleTopic_EntityTopic $oTopic */ $oTopic = E::ModuleTopic()->GetTopicById($iTargetId); if (!$oTopic) { // Топик еще не создан return TRUE; } if ($oTopic && (E::ModuleACL()->IsAllowEditTopic($oTopic, E::User()) || E::IsAdminOrModerator())) { return $oTopic; } return ''; } if ($sTarget == 'topic_comment') { if (!E::IsUser()) { return false; } /** @var ModuleComment_EntityComment $oComment */ $oComment = E::ModuleComment()->GetCommentById($iTargetId); if (!$oComment) { // Комментарий еще не создан return TRUE; } if ($oComment && (E::ModuleACL()->CanPostComment(E::User(), $oComment->getTarget()) && E::ModuleAcl()->CanPostCommentTime(E::User()) || E::IsAdminOrModerator())) { return $oComment; } return ''; } if ($sTarget == 'talk_comment') { if (!E::IsUser()) { return false; } /** @var ModuleComment_EntityComment $oComment */ $oComment = E::ModuleComment()->GetCommentById($iTargetId); if (!$oComment) { // Комментарий еще не создан return TRUE; } if ($oComment && (E::ModuleAcl()->CanPostTalkCommentTime(E::User()) || E::IsAdminOrModerator())) { return $oComment; } return ''; } if ($sTarget == 'talk') { if (!E::IsUser()) { return false; } /** @var ModuleComment_EntityComment $oTalk */ $oTalk = E::ModuleTalk()->GetTalkById($iTargetId); if (!$oTalk) { // Комментарий еще не создан return TRUE; } if ($oTalk && (E::ModuleAcl()->CanSendTalkTime(E::User()) || E::IsAdminOrModerator())) { return $oTalk; } return ''; } return FALSE; }