1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @author Christoph Wurst <[email protected]> |
5
|
|
|
* |
6
|
|
|
* ownCloud - Mail |
7
|
|
|
* |
8
|
|
|
* This code is free software: you can redistribute it and/or modify |
9
|
|
|
* it under the terms of the GNU Affero General Public License, version 3, |
10
|
|
|
* as published by the Free Software Foundation. |
11
|
|
|
* |
12
|
|
|
* This program is distributed in the hope that it will be useful, |
13
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15
|
|
|
* GNU Affero General Public License for more details. |
16
|
|
|
* |
17
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3, |
18
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/> |
19
|
|
|
* |
20
|
|
|
*/ |
21
|
|
|
|
22
|
|
|
namespace OCA\Mail\Service\Attachment; |
23
|
|
|
|
24
|
|
|
use OCA\Mail\Db\LocalAttachment; |
25
|
|
|
use OCA\Mail\Db\LocalattAchmentMapper; |
26
|
|
|
use OCP\AppFramework\Db\DoesNotExistException; |
27
|
|
|
use OCP\AppFramework\Utility\ITimeFactory; |
28
|
|
|
|
29
|
|
|
class AttachmentStore { |
30
|
|
|
|
31
|
|
|
/** @var LocalattAchmentMapper */ |
32
|
|
|
private $mapper; |
33
|
|
|
|
34
|
|
|
/** @var ITimeFactory */ |
35
|
|
|
private $time; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @param LocalattAchmentMapper $mapper |
39
|
|
|
*/ |
40
|
|
|
public function __construct(LocalattAchmentMapper $mapper, ITimeFactory $time) { |
41
|
|
|
$this->mapper = $mapper; |
42
|
|
|
$this->time = $time; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @param string $userId |
47
|
|
|
* @param UploadedFile $file |
48
|
|
|
* @return LocalAttachment |
49
|
|
|
*/ |
50
|
|
|
public function addFile($userId, UploadedFile $file) { |
51
|
|
|
$attachment = new LocalAttachment(); |
52
|
|
|
$attachment->setUserId($userId); |
53
|
|
|
$attachment->setFileName($file->getFileName()); |
54
|
|
|
$attachment->setFilePath($file->getPath()); |
55
|
|
|
|
56
|
|
|
$this->mapper->insert($attachment); |
57
|
|
|
|
58
|
|
|
return $attachment; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @param string $userId |
63
|
|
|
* @param int $id |
64
|
|
|
*/ |
65
|
|
|
public function getAttachment($userId, $id) { |
66
|
|
|
try { |
67
|
|
|
return $this->mapper->find($userId, $id); |
68
|
|
|
} catch (DoesNotExistException $ex) { |
|
|
|
|
69
|
|
|
throw new AttachmentNotFoundException(); |
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* @param string $userId |
75
|
|
|
* @param int $id |
76
|
|
|
*/ |
77
|
|
|
public function deleteAttachment($userId, $id) { |
78
|
|
|
try { |
79
|
|
|
$attachment = $this->mapper->find($userId, $id); |
80
|
|
|
$this->mapper->delete($attachment); |
81
|
|
|
} catch (DoesNotExistException $ex) { |
|
|
|
|
82
|
|
|
// Nothing to do then |
83
|
|
|
} |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
} |
87
|
|
|
|
Scrutinizer analyzes your
composer.json
/composer.lock
file if available to determine the classes, and functions that are defined by your dependencies.It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.