Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
7 / 7 |
|
100.00% |
5 / 5 |
CRAP | |
100.00% |
1 / 1 |
manager | |
100.00% |
7 / 7 |
|
100.00% |
5 / 5 |
5 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
delete | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
unlink | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
resync | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
upload | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | /** |
3 | * |
4 | * This file is part of the phpBB Forum Software package. |
5 | * |
6 | * @copyright (c) phpBB Limited <https://www.phpbb.com> |
7 | * @license GNU General Public License, version 2 (GPL-2.0) |
8 | * |
9 | * For full copyright and license information, please see |
10 | * the docs/CREDITS.txt file. |
11 | * |
12 | */ |
13 | |
14 | namespace phpbb\attachment; |
15 | |
16 | /** |
17 | * Attachment manager |
18 | */ |
19 | class manager |
20 | { |
21 | /** @var delete Attachment delete class */ |
22 | protected $delete; |
23 | |
24 | /** @var resync Attachment resync class */ |
25 | protected $resync; |
26 | |
27 | /** @var upload Attachment upload class */ |
28 | protected $upload; |
29 | |
30 | /** |
31 | * Constructor for attachment manager |
32 | * |
33 | * @param delete $delete Attachment delete class |
34 | * @param resync $resync Attachment resync class |
35 | * @param upload $upload Attachment upload class |
36 | */ |
37 | public function __construct(delete $delete, resync $resync, upload $upload) |
38 | { |
39 | $this->delete = $delete; |
40 | $this->resync = $resync; |
41 | $this->upload = $upload; |
42 | } |
43 | |
44 | /** |
45 | * Wrapper method for deleting attachments |
46 | * |
47 | * @param string $mode can be: post|message|topic|attach|user |
48 | * @param mixed $ids can be: post_ids, message_ids, topic_ids, attach_ids, user_ids |
49 | * @param bool $resync set this to false if you are deleting posts or topics |
50 | * |
51 | * @return int|bool Number of deleted attachments or false if something |
52 | * went wrong during attachment deletion |
53 | */ |
54 | public function delete($mode, $ids, $resync = true) |
55 | { |
56 | return $this->delete->delete($mode, $ids, $resync); |
57 | } |
58 | |
59 | /** |
60 | * Wrapper method for deleting attachments from filesystem |
61 | * |
62 | * @param string $filename Filename of attachment |
63 | * @param string $mode Delete mode |
64 | * @param bool $entry_removed Whether entry was removed. Defaults to false |
65 | * @return bool True if file was removed, false if not |
66 | */ |
67 | public function unlink($filename, $mode = 'file', $entry_removed = false) |
68 | { |
69 | return $this->delete->unlink_attachment($filename, $mode, $entry_removed); |
70 | } |
71 | |
72 | /** |
73 | * Wrapper method for resyncing specified type |
74 | * |
75 | * @param string $type Type of resync |
76 | * @param array $ids IDs to resync |
77 | */ |
78 | public function resync($type, $ids) |
79 | { |
80 | $this->resync->resync($type, $ids); |
81 | } |
82 | |
83 | /** |
84 | * Wrapper method for uploading attachment |
85 | * |
86 | * @param string $form_name The form name of the file upload input |
87 | * @param int $forum_id The id of the forum |
88 | * @param bool $local Whether the file is local or not |
89 | * @param string $local_storage The path to the local file |
90 | * @param bool $is_message Whether it is a PM or not |
91 | * @param array $local_filedata An file data object created for the local file |
92 | * |
93 | * @return array File data array |
94 | */ |
95 | public function upload($form_name, $forum_id, $local = false, $local_storage = '', $is_message = false, $local_filedata = []) |
96 | { |
97 | return $this->upload->upload($form_name, $forum_id, $local, $local_storage, $is_message, $local_filedata); |
98 | } |
99 | } |