From 648224a213a9434b1a4b870fd2cfbf58082f344c Mon Sep 17 00:00:00 2001 From: Maximilian Mader Date: Fri, 13 Sep 2013 22:23:42 +0200 Subject: [PATCH] Add attachment object type and permissions --- .../MessageAttachmentObjectType.class.php | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 file/lib/system/attachment/MessageAttachmentObjectType.class.php diff --git a/file/lib/system/attachment/MessageAttachmentObjectType.class.php b/file/lib/system/attachment/MessageAttachmentObjectType.class.php new file mode 100644 index 0000000..a9553ec --- /dev/null +++ b/file/lib/system/attachment/MessageAttachmentObjectType.class.php @@ -0,0 +1,65 @@ + + * @package be.bastelstu.chat + * @subpackage system.attachment + */ +class MessageAttachmentObjectType extends AbstractAttachmentObjectType { + /** + * @see wcf\system\attachment\IAttachmentObjectType::getMaxSize() + */ + public function getMaxSize() { + return WCF::getSession()->getPermission('user.chat.maxAttachmentSize'); + } + + /** + * @see wcf\system\attachment\IAttachmentObjectType::getAllowedExtensions() + */ + public function getAllowedExtensions() { + return ArrayUtil::trim(explode("\n", WCF::getSession()->getPermission('user.chat.allowedAttachmentExtensions'))); + } + + /** + * @see wcf\system\attachment\IAttachmentObjectType::getMaxCount() + */ + public function getMaxCount() { + return 1; + } + + /** + * @see wcf\system\attachment\IAttachmentObjectType::canDownload() + */ + public function canDownload($objectID) { + if ($objectID) { + $room = \chat\data\room\RoomCache::getInstance()->getRoom($objectID); + if ($room && $room->canEnter()) return true; + } + + return false; + } + + /** + * @see wcf\system\attachment\IAttachmentObjectType::canUpload() + */ + public function canUpload($objectID, $parentObjectID = 0) { + if ($objectID) { + $room = \chat\data\room\RoomCache::getInstance()->getRoom($objectID); + if ($room && $room->canWrite()) return true; + } + + return WCF::getSession()->getPermission('user.chat.canUploadAttachment'); + } + + /** + * @see wcf\system\attachment\IAttachmentObjectType::canDelete() + */ + public function canDelete($objectID) { + return false; + } +}