1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @author Christoph Wurst <[email protected]> |
5
|
|
|
* @author Thomas Müller <[email protected]> |
6
|
|
|
* |
7
|
|
|
* ownCloud - Mail |
8
|
|
|
* |
9
|
|
|
* This code is free software: you can redistribute it and/or modify |
10
|
|
|
* it under the terms of the GNU Affero General Public License, version 3, |
11
|
|
|
* as published by the Free Software Foundation. |
12
|
|
|
* |
13
|
|
|
* This program is distributed in the hope that it will be useful, |
14
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
15
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16
|
|
|
* GNU Affero General Public License for more details. |
17
|
|
|
* |
18
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3, |
19
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/> |
20
|
|
|
* |
21
|
|
|
*/ |
22
|
|
|
|
23
|
|
|
namespace OCA\Mail\AppInfo; |
24
|
|
|
|
25
|
|
|
use OC; |
26
|
|
|
use OCP\AppFramework\App; |
27
|
|
|
use OCP\Util; |
28
|
|
|
|
29
|
|
|
class Application extends App { |
30
|
|
|
|
31
|
1 |
|
public function __construct(array $urlParams = []) { |
32
|
1 |
|
parent::__construct('mail', $urlParams); |
33
|
|
|
|
34
|
1 |
|
$this->initializeAppContainer(); |
35
|
1 |
|
$this->registerHooks(); |
36
|
1 |
|
} |
37
|
|
|
|
38
|
1 |
|
public function initializeAppContainer() { |
39
|
1 |
|
$container = $this->getContainer(); |
40
|
|
|
|
41
|
1 |
|
$transport = $container->getServer()->getConfig()->getSystemValue('app.mail.transport', 'smtp'); |
42
|
1 |
|
$testSmtp = $transport === 'smtp'; |
43
|
|
|
|
44
|
1 |
|
$container->registerService('OCP\ISession', function ($c) { |
45
|
|
|
return $c->getServer()->getSession(); |
46
|
1 |
|
}); |
47
|
|
|
|
48
|
1 |
|
$user = $container->query("UserId"); |
49
|
1 |
|
$container->registerParameter("appName", "mail"); |
50
|
1 |
|
$container->registerParameter("userFolder", $container->getServer()->getUserFolder($user)); |
51
|
1 |
|
$container->registerParameter("testSmtp", $testSmtp); |
52
|
1 |
|
$container->registerParameter("referrer", isset($_SERVER['HTTP_REFERER']) ? : null); |
53
|
1 |
|
$container->registerParameter("hostname", Util::getServerHostName()); |
54
|
1 |
|
} |
55
|
|
|
|
56
|
1 |
|
public function registerHooks() { |
57
|
1 |
|
Util::connectHook('OC_User', 'post_login', $this, 'handleLoginHook'); |
58
|
1 |
|
} |
59
|
|
|
|
60
|
|
|
public function handleLoginHook($params) { |
61
|
|
|
if (!isset($params['password'])) { |
62
|
|
|
return; |
63
|
|
|
} |
64
|
|
|
$password = $params['password']; |
65
|
|
|
|
66
|
|
|
$container = $this->getContainer(); |
67
|
|
|
/* @var $defaultAccountManager \OCA\Mail\Service\DefaultAccount\DefaultAccountManager */ |
68
|
|
|
$defaultAccountManager = $container->query('\OCA\Mail\Service\DefaultAccount\DefaultAccountManager'); |
69
|
|
|
|
70
|
|
|
$defaultAccountManager->saveLoginPassword($password); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
} |
74
|
|
|
|