/** * @param KunenaUser $user * * @return null|string */ protected function authoriseUnlocked(KunenaUser $user) { // Check that topic is not locked or user is a moderator if ($this->locked && !$user->isModerator($this->getCategory())) { return new KunenaExceptionAuthorise(JText::_('COM_KUNENA_POST_ERROR_TOPIC_LOCKED'), 403); } return null; }
/** * @param KunenaUser $user * * @return KunenaExceptionAuthorise|null * * @since K4.0 */ protected function authoriseOwn(KunenaUser $user) { // Checks if attachment is users own or user is moderator in the category (or global) if ($user->userid && $this->userid != $user->userid && !$user->isModerator($this->getMessage()->getCategory())) { return new KunenaExceptionAuthorise(JText::_('COM_KUNENA_ATTACHMENT_NO_ACCESS'), 403); } return null; }
/** * Check if user has the right to upload file attachment * * @param KunenaUser $user * @return KunenaExceptionAuthorise|NULL */ protected function authoriseAttachmentsFile(KunenaUser $user) { if (empty(KunenaFactory::getConfig()->file_upload)) { return new KunenaExceptionAuthorise(JText::_('COM_KUNENA_POST_ATTACHMENTS_NOT_ALLOWED'), 403); } if (KunenaFactory::getConfig()->file_upload == 'admin') { if (!$user->isAdmin()) { return new KunenaExceptionAuthorise(JText::_('COM_KUNENA_POST_ATTACHMENTS_FILE_ONLY_FOR_ADMINISTRATORS'), 403); } } if (KunenaFactory::getConfig()->file_upload == 'registered') { if (!$user->userid) { return new KunenaExceptionAuthorise(JText::_('COM_KUNENA_POST_ATTACHMENTS_FILE_ONLY_FOR_REGISTERED_USERS'), 403); } } if (KunenaFactory::getConfig()->file_upload == 'moderator') { if (!$user->isModerator()) { return new KunenaExceptionAuthorise(JText::_('COM_KUNENA_POST_ATTACHMENTS_FILE_ONLY_FOR_MODERATORS'), 403); } } return null; }
/** * @param KunenaUser $user * * @return KunenaExceptionAuthorise|null */ protected function authoriseGlobalModerate(KunenaUser $user) { // Check that user is a global moderator if (!$user->userid) { return new KunenaExceptionAuthorise(JText::_('COM_KUNENA_POST_NOT_GLOBAL_MODERATOR'), 401); } if (!$user->isModerator()) { return new KunenaExceptionAuthorise(JText::_('COM_KUNENA_POST_NOT_GLOBAL_MODERATOR'), 403); } return null; }
/** * @param KunenaUser $user * * @return null|string */ protected function authoriseWrite(KunenaUser $user) { // Check that user is global moderator if (!$user->userid || !$user->isModerator()) { return JText::_('COM_KUNENA_POST_NOT_MODERATOR'); } return null; }
/** * @param KunenaUser $user * * @return bool */ protected function authoriseDelete(KunenaUser $user) { $config = KunenaFactory::getConfig(); if (!$user->isModerator($this->getCategory()) && $config->userdeletetmessage != '2' && ($config->userdeletetmessage == '0' || $this->getTopic()->last_post_id != $this->id)) { $this->setError (JText::_ ( 'COM_KUNENA_POST_ERROR_DELETE_REPLY_AFTER' ) ); return false; } return true; }
protected function authoriseOwn(KunenaUser $user) { // Checks if attachment is users own or user is moderator in the category (or global) if ($user->userid && $this->userid != $user->userid && !$user->isModerator($this->getMessage()->getCategory())) { $this->setError(JText::_('COM_KUNENA_NO_ACCESS')); return false; } return true; }