2 namespace wcf\system\attachment
;
3 use wcf\system\attachment\IAttachmentObjectType
;
5 use wcf\util\ArrayUtil
;
8 * Provides a default implementation for attachment object types.
11 * @copyright 2001-2015 WoltLab GmbH
12 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
13 * @package com.woltlab.wcf
14 * @subpackage system.attachment
15 * @category Community Framework
17 abstract class AbstractAttachmentObjectType
implements IAttachmentObjectType
{
20 * @var array<\wcf\data\DatabaseObject>
22 protected $cachedObjects = array();
25 * @see \wcf\system\attachment\IAttachmentObjectType::getMaxSize()
27 public function getMaxSize() {
28 return WCF
::getSession()->getPermission('user.attachment.maxSize');
32 * @see \wcf\system\attachment\IAttachmentObjectType::getAllowedExtensions()
34 public function getAllowedExtensions() {
35 return ArrayUtil
::trim(explode("\n", WCF
::getSession()->getPermission('user.attachment.allowedExtensions')));
39 * @see \wcf\system\attachment\IAttachmentObjectType::getMaxCount()
41 public function getMaxCount() {
42 return WCF
::getSession()->getPermission('user.attachment.maxCount');
46 * @see \wcf\system\attachment\IAttachmentObjectType::canViewPreview()
48 public function canViewPreview($objectID) {
49 return $this->canDownload($objectID);
53 * @see \wcf\system\attachment\IAttachmentObjectType::getObject()
55 public function getObject($objectID) {
56 if (isset($this->cachedObjects
[$objectID])) return $this->cachedObjects
[$objectID];
62 * @see \wcf\system\attachment\IAttachmentObjectType::setCachedObjects()
64 public function setCachedObjects(array $objects) {
65 foreach ($objects as $id => $object) {
66 $this->cachedObjects
[$id] = $object;
71 * @see \wcf\system\attachment\IAttachmentObjectType::getObject()
73 public function cacheObjects(array $objectIDs) {}
76 * @see \wcf\system\attachment\IAttachmentObjectType::setPermissions()
78 public function setPermissions(array $attachments) {
79 foreach ($attachments as $attachment) {
80 $attachment->setPermissions(array(
81 'canDownload' => $this->canDownload($attachment->objectID
),
82 'canViewPreview' => $this->canViewPreview($attachment->objectID
)