summaryrefslogtreecommitdiffstats
path: root/settings
diff options
context:
space:
mode:
Diffstat (limited to 'settings')
-rw-r--r--settings/ajax/changedisplayname.php5
-rw-r--r--settings/css/settings.css2
-rw-r--r--settings/js/personal.js27
-rw-r--r--settings/personal.php2
-rw-r--r--settings/templates/personal.php17
5 files changed, 51 insertions, 2 deletions
diff --git a/settings/ajax/changedisplayname.php b/settings/ajax/changedisplayname.php
index f80ecb7a0c9..766f1459aec 100644
--- a/settings/ajax/changedisplayname.php
+++ b/settings/ajax/changedisplayname.php
@@ -1,5 +1,6 @@
<?php
// Check if we are a user
+
OCP\JSON::callCheck();
OC_JSON::checkLoggedIn();
@@ -21,8 +22,8 @@ if(is_null($userstatus)) {
// Return Success story
if( OC_User::setDisplayName( $username, $displayName )) {
- OC_JSON::success(array("data" => array( "username" => $username )));
+ OC_JSON::success(array("data" => array( "username" => $username, 'displayName' => $displayName )));
}
else{
- OC_JSON::error(array("data" => array( "message" => "Unable to change display name" )));
+ OC_JSON::error(array("data" => array( "message" => "Unable to change display name", displayName => OC_User::getDisplayName($username) )));
} \ No newline at end of file
diff --git a/settings/css/settings.css b/settings/css/settings.css
index 5a3ab2c6e97..e722cca91ee 100644
--- a/settings/css/settings.css
+++ b/settings/css/settings.css
@@ -8,6 +8,8 @@ input#openid, input#webdav { width:20em; }
/* PERSONAL */
#passworderror { display:none; }
#passwordchanged { display:none; }
+#displaynameerror { display:none; }
+#displaynamechanged { display:none; }
input#identity { width:20em; }
#email { width: 17em; }
diff --git a/settings/js/personal.js b/settings/js/personal.js
index a866e321ad6..d9455b3786b 100644
--- a/settings/js/personal.js
+++ b/settings/js/personal.js
@@ -31,6 +31,33 @@ $(document).ready(function(){
}
});
+
+ $("#displaynamebutton").click( function(){
+ if ($('#displayName').val() != '' ) {
+ // Serialize the data
+ var post = $( "#displaynameform" ).serialize();
+ $('#displaynamechanged').hide();
+ $('#displaynemerror').hide();
+ // Ajax foo
+ $.post( 'ajax/changedisplayname.php', post, function(data){
+ if( data.status == "success" ){
+ $('#displaynamechanged').show();
+ }
+ else{
+ $('#newdisplayname').val(data.data.displayName)
+ $('#displaynameerror').html( data.data.message );
+ $('#displaynameerror').show();
+ }
+ });
+ return false;
+ } else {
+ $('#displayName').val($('#oldDisplayName').val());
+ $('#displaynamechanged').hide();
+ $('#displaynameerror').show();
+ return false;
+ }
+
+ });
$('#lostpassword #email').blur(function(event){
if ($(this).val() == this.defaultValue){
diff --git a/settings/personal.php b/settings/personal.php
index a2e510a6d3c..ac2c4704edb 100644
--- a/settings/personal.php
+++ b/settings/personal.php
@@ -48,6 +48,8 @@ $tmpl->assign('usage_relative', $storageInfo['relative']);
$tmpl->assign('email', $email);
$tmpl->assign('languages', $languages);
$tmpl->assign('passwordChangeSupported', OC_User::canUserChangePassword(OC_User::getUser()));
+$tmpl->assign('displayNameChangeSupported', OC_User::canUserChangeDisplayName(OC_User::getUser()));
+$tmpl->assign('displayName', OC_User::getDisplayName());
$forms=OC_App::getForms('personal');
$tmpl->assign('forms', array());
diff --git a/settings/templates/personal.php b/settings/templates/personal.php
index b1cc6713923..0f195d86d3d 100644
--- a/settings/templates/personal.php
+++ b/settings/templates/personal.php
@@ -33,6 +33,23 @@ if($_['passwordChangeSupported']) {
}
?>
+<?php
+if($_['displayNameChangeSupported']) {
+?>
+<form id="displaynameform">
+ <fieldset class="personalblock">
+ <legend><strong><?php echo $l->t('Display Name');?></strong></legend>
+ <div id="displaynamechanged"><?php echo $l->t('Your display name was changed');?></div>
+ <div id="displaynameerror"><?php echo $l->t('Unable to change your display name');?></div>
+ <input type="text" id="displayName" name="displayName" value="<?php echo $_['displayName']?>" />
+ <input type="hidden" id="oldDisplayName" name="oldDisplayName" value="<?php echo $_['displayName']?>" />
+ <input id="displaynamebutton" type="submit" value="<?php echo $l->t('Change display name');?>" />
+ </fieldset>
+</form>
+<?php
+}
+?>
+
<form id="lostpassword">
<fieldset class="personalblock">
<legend><strong><?php echo $l->t('Email');?></strong></legend>