1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Copyright (c) 2014, Tobia De Koninck hey--at--ledfan.be |
4
|
|
|
* This file is licensed under the AGPL version 3 or later. |
5
|
|
|
* See the COPYING file. |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
namespace OCA\Chat\OCH\Db; |
9
|
|
|
|
10
|
|
|
use OCP\AppFramework\Db\DoesNotExistException; |
11
|
|
|
use OCA\Chat\OCH\Commands\AttachFile; |
12
|
|
|
use \OCP\AppFramework\Db\Mapper; |
13
|
|
|
use \OCP\IDb; |
14
|
|
|
|
15
|
|
|
class AttachmentMapper extends Mapper { |
16
|
|
|
|
17
|
|
|
public function __construct(IDb $api, $app) { |
18
|
|
|
parent::__construct($api, 'chat_attachments'); |
19
|
|
|
$this->app = $app; |
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
public function insertUnique(Attachment $entity){ |
23
|
|
|
try { |
24
|
|
|
$sql = <<<SQL |
25
|
|
|
SELECT |
26
|
|
|
* |
27
|
|
|
FROM |
28
|
|
|
`*PREFIX*chat_attachments` |
29
|
|
|
WHERE |
30
|
|
|
`owner` = ? |
31
|
|
|
AND |
32
|
|
|
`file_id` = ? |
33
|
|
|
AND |
34
|
|
|
`conv_id` = ? |
35
|
|
|
SQL; |
36
|
|
|
$this->findEntity($sql, array($entity->getOwner(), $entity->getFileId(), $entity->getConvId())); |
37
|
|
|
} catch (DoesNotExistException $e){ |
|
|
|
|
38
|
|
|
$this->insert($entity); |
39
|
|
|
} |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
public function findRawByConv($convId){ |
43
|
|
|
$sql = <<<SQL |
44
|
|
|
SELECT |
45
|
|
|
* |
46
|
|
|
FROM |
47
|
|
|
`*PREFIX*chat_attachments` |
48
|
|
|
WHERE |
49
|
|
|
`conv_id` = ? |
50
|
|
|
SQL; |
51
|
|
|
$files = array(); |
52
|
|
|
$result = $this->findEntities($sql, array($convId)); |
53
|
|
|
foreach ($result as $r) { |
54
|
|
|
$files[] = array( |
55
|
|
|
"path" => $r->getPath(), |
56
|
|
|
"user" => $this->app->getUserasContact($r->getOwner()), |
57
|
|
|
"timestamp" => $r->getTimestamp(), |
58
|
|
|
); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
return $files; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
public function deleteByConvAndFileID(Attachment $file){ |
65
|
|
|
$sql = <<<SQL |
66
|
|
|
DELETE |
67
|
|
|
FROM |
68
|
|
|
`*PREFIX*chat_attachments` |
69
|
|
|
WHERE |
70
|
|
|
`conv_id` = ? |
71
|
|
|
AND |
72
|
|
|
`file_id`= ? |
73
|
|
|
SQL; |
74
|
|
|
|
75
|
|
|
$this->execute($sql, array($file->getConvId(), $file->getFileId())); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
public function findByPathAndConvId($path, $convId){ |
79
|
|
|
$sql = <<<SQL |
80
|
|
|
SELECT |
81
|
|
|
* |
82
|
|
|
FROM |
83
|
|
|
`*PREFIX*chat_attachments` |
84
|
|
|
WHERE |
85
|
|
|
`conv_id` = ? |
86
|
|
|
AND |
87
|
|
|
`path`= ? |
88
|
|
|
SQL; |
89
|
|
|
|
90
|
|
|
return $this->findEntity($sql, array($convId, $path)); |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
} |
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.