/
ContactAttachmentObjectType.class.php
106 lines (92 loc) · 2.39 KB
/
ContactAttachmentObjectType.class.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<?php
namespace wcf\system\attachment;
use wcf\data\contact\attachment\ContactAttachment;
use wcf\data\contact\attachment\ContactAttachmentList;
use wcf\system\WCF;
use wcf\util\ArrayUtil;
/**
* Attachment object type implementation for messages sent through the contact form.
*
* @author Alexander Ebert
* @copyright 2001-2019 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @package WoltLabSuite\Core\System\Attachment
* @since 5.2
*
* @method ContactAttachment getObject($objectID)
*/
class ContactAttachmentObjectType extends AbstractAttachmentObjectType
{
/**
* @inheritDoc
*/
public function getMaxSize()
{
return WCF::getSession()->getPermission('user.contactForm.attachment.maxSize');
}
/**
* @inheritDoc
*/
public function getAllowedExtensions()
{
return ArrayUtil::trim(\explode(
"\n",
WCF::getSession()->getPermission('user.contactForm.attachment.allowedExtensions')
));
}
/**
* @inheritDoc
*/
public function getMaxCount()
{
return WCF::getSession()->getPermission('user.contactForm.attachment.maxCount');
}
/**
* @inheritDoc
*/
public function canDownload($objectID)
{
if (!CONTACT_FORM_ENABLE_ATTACHMENTS) {
return false;
}
// The administrator does not require the access key in order to view the attachment.
if (!WCF::getSession()->getPermission('admin.contact.canManageContactForm')) {
return false;
}
return true;
}
/**
* @inheritDoc
*/
public function canViewPreview($objectID)
{
return $this->canDownload($objectID);
}
/**
* @inheritDoc
*/
public function canUpload($objectID, $parentObjectID = 0)
{
if (!CONTACT_FORM_ENABLE_ATTACHMENTS) {
return false;
}
return true;
}
/**
* @inheritDoc
*/
public function canDelete($objectID)
{
return $this->canUpload($objectID);
}
/**
* @inheritDoc
*/
public function cacheObjects(array $objectIDs)
{
$objectList = new ContactAttachmentList();
$objectList->setObjectIDs($objectIDs);
$objectList->readObjects();
$this->setCachedObjects($objectList->getObjects());
}
}