blob: 22170d5e2dc1f0df4dc6f6d83a83409ef944ac7f (
plain)
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
|
<?php
/**
* OutboxFolder.class.php
*
* This is a FolderType implementation for file attachments of messages
* that were sent by a user. It is a read-only folder.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* @author Moritz Strohm <strohm@data-quest.de>
* @copyright 2016 data-quest
* @license http://www.gnu.org/licenses/gpl-2.0.html GPL version 2
* @category Stud.IP
*/
class OutboxFolder extends InboxOutboxFolder
{
/**
* Returns a localised name of the OutboxFolder type.
*
* @return string The localised name of this folder type.
*/
public static function getTypeName()
{
return _('Alle Anhänge gesendeter Nachrichten');
}
/**
* Returns the Icon object for the OutboxFolder type.
*
* @return Icon An icon object with the icon for this folder type.
*/
public function getIcon($role = Icon::DEFAULT_ROLE)
{
return Icon::create(
count($this->getFiles())
? 'folder-inbox-full'
: 'folder-inbox-empty',
$role
);
}
/**
* Gets all attachments of sent messages of a specific user
* and places the attachments inside this folder.
*
* @return FileRef[] Array of FileRef objects representing the message
* attachments.
*/
public function getFiles()
{
//get all folders of the user that belongs to a received message:
$message_folders = Folder::findBySql(
"INNER JOIN message_user
ON folders.range_id = message_user.message_id
WHERE
folders.range_type = 'message'
AND
message_user.user_id = :user_id
AND
message_user.snd_rec = 'snd'
AND
message_user.deleted = '0'",
[
'user_id' => $this->user->id
]
);
$files = [];
foreach ($message_folders as $folder) {
$files = array_merge($files, $folder->getTypedFolder()->getFiles());
}
return $files;
}
/**
* The magic get method is overwritten to be able to set a
* custom value for the name attribute.
*/
public function __get($attribute)
{
if ($attribute == 'name') {
return _('Ausgehende Dateianhänge');
} else {
return parent::__get($attribute);
}
}
}
|