1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* ownCloud - Mail app |
5
|
|
|
* |
6
|
|
|
* @author Sebastian Schmid |
7
|
|
|
* @copyright 2013 Sebastian Schmid [email protected] |
8
|
|
|
* |
9
|
|
|
* This library is free software; you can redistribute it and/or |
10
|
|
|
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE |
11
|
|
|
* License as published by the Free Software Foundation; either |
12
|
|
|
* version 3 of the License, or any later version. |
13
|
|
|
* |
14
|
|
|
* This library is distributed in the hope that it will be useful, |
15
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
16
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17
|
|
|
* GNU AFFERO GENERAL PUBLIC LICENSE for more details. |
18
|
|
|
* |
19
|
|
|
* You should have received a copy of the GNU Lesser General Public |
20
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>. |
21
|
|
|
* |
22
|
|
|
*/ |
23
|
|
|
|
24
|
|
|
namespace OCA\Mail\Controller; |
25
|
|
|
|
26
|
|
|
use OCP\AppFramework\Controller; |
27
|
|
|
use OCP\AppFramework\Http\RedirectResponse; |
28
|
|
|
use OCP\AppFramework\Http\TemplateResponse; |
29
|
|
|
use OCP\IRequest; |
30
|
|
|
use OCP\IURLGenerator; |
31
|
|
|
use OCA\Mail\Db\MailAccountMapper; |
32
|
|
|
|
33
|
|
|
class PageController extends Controller { |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @var \OCA\Mail\Db\MailAccountMapper |
37
|
|
|
*/ |
38
|
|
|
private $mailAccountMapper; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @var IURLGenerator |
42
|
|
|
*/ |
43
|
|
|
private $urlGenerator; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @var string |
47
|
|
|
*/ |
48
|
|
|
private $currentUserId; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @param string $appName |
52
|
|
|
* @param \OCP\IRequest $request |
53
|
|
|
* @param $mailAccountMapper |
54
|
|
|
* @param $currentUserId |
55
|
|
|
*/ |
56
|
6 |
|
public function __construct($appName, IRequest $request, |
57
|
|
|
MailAccountMapper $mailAccountMapper, IURLGenerator $urlGenerator, |
58
|
|
|
$currentUserId) { |
59
|
6 |
|
parent::__construct($appName, $request); |
60
|
6 |
|
$this->mailAccountMapper = $mailAccountMapper; |
61
|
6 |
|
$this->urlGenerator = $urlGenerator; |
62
|
6 |
|
$this->currentUserId = $currentUserId; |
63
|
6 |
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @NoAdminRequired |
67
|
|
|
* @NoCSRFRequired |
68
|
|
|
* |
69
|
|
|
* @return TemplateResponse renders the index page |
70
|
|
|
*/ |
71
|
1 |
|
public function index() { |
72
|
1 |
|
$response = new TemplateResponse($this->appName, 'index', []); |
73
|
|
|
// set csp rules for ownCloud 8.1 |
74
|
1 |
|
if (class_exists('OCP\AppFramework\Http\ContentSecurityPolicy')) { |
75
|
|
|
$csp = new \OCP\AppFramework\Http\ContentSecurityPolicy(); |
76
|
|
|
$csp->addAllowedFrameDomain('\'self\''); |
77
|
|
|
$response->setContentSecurityPolicy($csp); |
78
|
|
|
} |
79
|
|
|
|
80
|
1 |
|
return $response; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @NoAdminRequired |
85
|
|
|
* @NoCSRFRequired |
86
|
|
|
* |
87
|
|
|
* @param string $uri |
88
|
|
|
* @return TemplateResponse renders the compose page |
89
|
|
|
*/ |
90
|
5 |
|
public function compose($uri) { |
91
|
5 |
|
$parts = parse_url($uri); |
92
|
5 |
|
$params = ['mailto' => $parts['path']]; |
93
|
5 |
|
if (isset($parts['query'])) { |
94
|
4 |
|
$parts = explode('&', $parts['query']); |
95
|
4 |
|
foreach ($parts as $part) { |
96
|
4 |
|
$pair = explode('=', $part, 2); |
97
|
4 |
|
$params[strtolower($pair[0])] = urldecode($pair[1]); |
98
|
4 |
|
} |
99
|
4 |
|
} |
100
|
|
|
|
101
|
5 |
|
array_walk($params, function (&$value, $key) { |
102
|
5 |
|
$value = "$key=" . urlencode($value); |
103
|
5 |
|
}); |
104
|
|
|
|
105
|
5 |
|
$hashParams = '#' . implode('&', $params); |
106
|
|
|
|
107
|
5 |
|
$baseUrl = $this->urlGenerator->linkToRoute("mail.page.index"); |
108
|
5 |
|
return new RedirectResponse($baseUrl . $hashParams); |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
} |
112
|
|
|
|