From f14930389505eda61ec4cbcdf59a54e63513802b Mon Sep 17 00:00:00 2001 From: Bart Visscher <bartv@thisnet.nl> Date: Mon, 26 Sep 2011 21:10:56 +0200 Subject: [PATCH] Add email field to personal preferences --- settings/ajax/lostpassword.php | 19 +++++++++++++++++++ settings/js/personal.js | 9 +++++++++ settings/personal.php | 3 +++ settings/templates/personal.php | 8 ++++++++ 4 files changed, 39 insertions(+) create mode 100644 settings/ajax/lostpassword.php diff --git a/settings/ajax/lostpassword.php b/settings/ajax/lostpassword.php new file mode 100644 index 0000000000..a2dfc03320 --- /dev/null +++ b/settings/ajax/lostpassword.php @@ -0,0 +1,19 @@ +<?php + +// Init owncloud +require_once('../../lib/base.php'); + +OC_JSON::checkLoggedIn(); + +$l=new OC_L10N('core'); + +// Get data +if( isset( $_POST['email'] ) ){ + $email=trim($_POST['email']); + OC_Preferences::setValue(OC_User::getUser(),'settings','email',$email); + OC_JSON::success(array("data" => array( "message" => $l->t("email Changed") ))); +}else{ + OC_JSON::error(array("data" => array( "message" => $l->t("Invalid request") ))); +} + +?> diff --git a/settings/js/personal.js b/settings/js/personal.js index 9578fb2c89..8108da433c 100644 --- a/settings/js/personal.js +++ b/settings/js/personal.js @@ -32,6 +32,15 @@ $(document).ready(function(){ }); + $('#lostpassword #email').blur(function(event){ + event.preventDefault(); + OC.msg.startSaving('#lostpassword .msg'); + var post = $( "#lostpassword" ).serialize(); + $.post( 'ajax/lostpassword.php', post, function(data){ + OC.msg.finishedSaving('#lostpassword .msg', data); + }); + }); + $("#languageinput").chosen(); $("#languageinput").change( function(){ diff --git a/settings/personal.php b/settings/personal.php index 05dbda473a..687b1a7aa3 100644 --- a/settings/personal.php +++ b/settings/personal.php @@ -19,6 +19,8 @@ $free=OC_Filesystem::free_space(); $total=$free+$used; $relative=round(($used/$total)*10000)/100; +$email=OC_Preferences::getValue(OC_User::getUser(), 'settings','email',''); + $lang=OC_Preferences::getValue( OC_User::getUser(), 'core', 'lang', 'en' ); $languageCodes=OC_L10N::findAvailableLanguages(); //put the current language in the front @@ -35,6 +37,7 @@ $tmpl = new OC_Template( "settings", "personal", "user"); $tmpl->assign('usage',OC_Helper::humanFileSize($used)); $tmpl->assign('total_space',OC_Helper::humanFileSize($total)); $tmpl->assign('usage_relative',$relative); +$tmpl->assign('email',$email); $tmpl->assign('languages',$languages); $forms=OC_App::getForms('personal'); diff --git a/settings/templates/personal.php b/settings/templates/personal.php index eee5f3979c..61ee0354b1 100644 --- a/settings/templates/personal.php +++ b/settings/templates/personal.php @@ -19,6 +19,14 @@ </fieldset> </form> +<form id="lostpassword"> + <fieldset class="personalblock"> + <label for="email"><strong><?php echo $l->t('Email');?></strong></label> + <input type="text" name="email" id="email" value="<?php echo $_['email']; ?>" placeholder="<?php echo $l->t('Your email address');?>" /><span class="msg"></span><br /> + <em><?php echo $l->t('Fill in an email address to enable password recovery');?></em> + </fieldset> +</form> + <form> <fieldset class="personalblock"> <label for="languageinput"><strong><?php echo $l->t('Language');?></strong></label> -- GitLab