mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-29 12:09:20 +03:00
50 lines
1.3 KiB
PHP
50 lines
1.3 KiB
PHP
<?php
|
|
namespace OCA\SnappyMail\Settings;
|
|
|
|
use OCP\AppFramework\Http\TemplateResponse;
|
|
use OCP\IConfig;
|
|
use OCP\Settings\ISettings;
|
|
|
|
class PersonalSettings implements ISettings
|
|
{
|
|
private $config;
|
|
|
|
public function __construct(IConfig $config)
|
|
{
|
|
$this->config = $config;
|
|
}
|
|
|
|
public function getForm()
|
|
{
|
|
$uid = \OC::$server->getUserSession()->getUser()->getUID();
|
|
$sEmail = $this->config->getUserValue($uid, 'snappymail', 'snappymail-email');
|
|
if (!$sEmail) {
|
|
$aRainLoop = \OCA\SnappyMail\Util\RainLoop::getLoginCredentials($uid, $this->config);
|
|
if ($aRainLoop) {
|
|
$sEmail = $aRainLoop[0];
|
|
$this->config->setUserValue($uid, 'snappymail', 'snappymail-email', $sEmail);
|
|
if ($aRainLoop[1]) {
|
|
$this->config->setUserValue($uid, 'snappymail', 'snappymail-password',
|
|
\OCA\SnappyMail\Util\SnappyMailHelper::encodePassword($aRainLoop[1], \md5($sEmail))
|
|
);
|
|
}
|
|
}
|
|
}
|
|
$parameters = [
|
|
'snappymail-email' => $sEmail,
|
|
'snappymail-password' => $this->config->getUserValue($uid, 'snappymail', 'snappymail-password') ? '******' : ''
|
|
];
|
|
\OCP\Util::addScript('snappymail', 'snappymail');
|
|
return new TemplateResponse('snappymail', 'personal_settings', $parameters, '');
|
|
}
|
|
|
|
public function getSection()
|
|
{
|
|
return 'additional';
|
|
}
|
|
|
|
public function getPriority()
|
|
{
|
|
return 50;
|
|
}
|
|
}
|