2014-06-03 23:59:00 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ownCloud - RainLoop mail plugin
|
|
|
|
*
|
|
|
|
* @author RainLoop Team
|
|
|
|
* @copyright 2014 RainLoop Team
|
|
|
|
*
|
|
|
|
* https://github.com/RainLoop/rainloop-webmail/tree/master/build/owncloud
|
|
|
|
*/
|
|
|
|
|
|
|
|
OCP\JSON::checkLoggedIn();
|
|
|
|
OCP\JSON::checkAppEnabled('rainloop');
|
|
|
|
OCP\JSON::callCheck();
|
|
|
|
|
|
|
|
$sEmail = '';
|
|
|
|
$sLogin = '';
|
|
|
|
if (isset($_POST['appname'], $_POST['rainloop-password'], $_POST['rainloop-email']) && 'rainloop' === $_POST['appname'])
|
|
|
|
{
|
|
|
|
$sUser = OCP\User::getUser();
|
|
|
|
|
|
|
|
$sPostEmail = $_POST['rainloop-email'];
|
|
|
|
|
|
|
|
OCP\Config::setUserValue($sUser, 'rainloop', 'rainloop-email', $sPostEmail);
|
|
|
|
|
|
|
|
$sPass = $_POST['rainloop-password'];
|
|
|
|
if ('******' !== $sPass && '' !== $sPass)
|
|
|
|
{
|
|
|
|
include_once OC_App::getAppPath('rainloop').'/lib/RainLoopHelper.php';
|
2014-06-27 00:11:49 +08:00
|
|
|
|
2014-06-03 23:59:00 +08:00
|
|
|
OCP\Config::setUserValue($sUser, 'rainloop', 'rainloop-password',
|
2014-06-27 00:11:49 +08:00
|
|
|
OC_RainLoop_Helper::encodePassword($sPass, md5($sPostEmail)));
|
2014-06-03 23:59:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
$sEmail = OCP\Config::getUserValue($sUser, 'rainloop', 'rainloop-email', '');
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-06-27 00:11:49 +08:00
|
|
|
OC_JSON::error(array('Message' => 'Invalid argument(s)', 'Email' => $sEmail));
|
2014-06-03 23:59:00 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-06-27 00:11:49 +08:00
|
|
|
OCP\JSON::success(array('Message' => 'Saved successfully', 'Email' => $sEmail));
|
2014-06-03 23:59:00 +08:00
|
|
|
return true;
|