Commit 0ed88e13 authored by Reinhold Kainhofer's avatar Reinhold Kainhofer
Browse files

Make saving work. Password needs to be asked if neccessary (not yet...

Make saving work. Password needs to be asked if neccessary (not yet implemented using OC.PasswordConfirmation.requiresPasswordConfirmation)
parent 24366b9c
......@@ -8,12 +8,8 @@
* it's instantiated in there
*/
return [
'ocs' => [
['name' => 'secondarymail#setProperty', 'url' => '/settings', 'verb' => 'POST'],
['name' => 'secondarymail#getAddress', 'url' => '/getAddress/{id}', 'verb' => 'GET'],
],
'routes' => [
['name' => 'secondarymail#setProperty', 'url' => '/settings', 'verb' => 'POST'],
['name' => 'secondarymail#getAddress', 'url' => '/getAddress/{id}', 'verb' => 'GET'],
['name' => 'SecondaryMail#setProperty', 'url' => '/settings', 'verb' => 'POST'],
['name' => 'SecondaryMail#getAddress', 'url' => '/getAddress/{id}', 'verb' => 'GET'],
]
];
......@@ -23,29 +23,29 @@
namespace OCA\SecondaryMail\Controller;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\OCSController;
use OCP\IRequest;
use OCP\IConfig;
use OCP\IUserManager;
use OCP\IUserSession;
class SecondarymailController extends OCSController {
class SecondaryMailController extends OCSController {
private $config;
private $userManager;
protected $user;
public function __construct(
$appName,
IRequest $request,
$corsMethods = 'PUT, POST, GET, DELETE, PATCH',
$corsAllowedHeaders = 'Authorization, Content-Type, Accept',
$corsMaxAge = 1728000,
IConfig $config,
IUserManager $userManager
IUserManager $userManager,
IUserSession $userSession
) {
parent::__construct($appName, $request, $corsMethods, $corsAllowedHeaders, $corsMaxAge);
parent::__construct($appName, $request);
$this->config = $config;
$this->userManager = $userManager;
$this->user = $userSession->getUser()->getUID();
error_log('MailsSecondaryController::_construct');
}
......@@ -53,11 +53,15 @@ error_log('MailsSecondaryController::_construct');
* @NoAdminRequired
* @PasswordConfirmationRequired
*/
public function setProperty($id, $key, $value) {
error_log("MailsSecondaryController::setProperty: id=$id, key=$key, value=$value, ");
public function setProperty($key, $value) {
if (in_array($key, array('emailUsePrimary', 'emailUseSecondary', 'email2'))) {
$this->config->setUserValue($id, 'settings', $key, $value);
if ($key === 'email2' && $value == "") {
$this->config->deleteUserValue($this->user, 'settings', $key);
} else {
$this->config->setUserValue($this->user, 'settings', $key, $value);
}
}
return new DataResponse(true);
}
/**
......
......@@ -30,7 +30,7 @@ script('secondarymail', 'script');
<form id="secondarymailform" class="section">
<h3><label for="secondarymail"><?php p($l->t('Secondary E-Mail Address')); ?></label></h3>
<p>
<input type="text" id="secondarymail" name="secondarymail" data-setting="secondaryMail"
<input type="text" id="secondarymail" name="secondarymail" data-setting="email2"
value="<?php p($_['secondaryMail']) ?>"
autocomplete="on" autocapitalize="none" autocorrect="off" />
</p>
......@@ -39,11 +39,11 @@ script('secondarymail', 'script');
<p/>
<p>
<?php p($l->t('Preferred E-Mail for external communication:')); ?>
<input type="checkbox" name="secondarymail_use1" id="secondaryMailUse1" data-setting="usePrimary" class="checkbox"
<?php ($_['use_primary_mail'] === 1) ? print_unescaped('checked="checked"') : null ?>/>
<input type="checkbox" name="secondarymail_use1" id="secondaryMailUse1" data-setting="emailUsePrimary" class="checkbox"
<?php ($_['use_primary_mail'] === "true") ? print_unescaped('checked="checked"') : null ?>/>
<label for="secondaryMailUse1"><?php p($l->t('Primary')); ?></label>&nbsp;
<input type="checkbox" name="secondarymail_use2" id="secondaryMailUse2" data-setting="useSecondary" class="checkbox"
<?php ($_['use_secondary_mail'] === 1) ? print_unescaped('checked="checked"') : null ?>/>
<input type="checkbox" name="secondarymail_use2" id="secondaryMailUse2" data-setting="emailUseSecondary" class="checkbox"
<?php ($_['use_secondary_mail'] === "true") ? print_unescaped('checked="checked"') : null ?>/>
<label for="secondaryMailUse2"><?php p($l->t('Secondary')); ?></label>
</p>
</form>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment