summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/user.php19
-rw-r--r--lib/user/backend.php2
-rw-r--r--settings/js/users.js37
-rw-r--r--settings/routes.php2
-rw-r--r--settings/templates/users.php2
5 files changed, 59 insertions, 3 deletions
diff --git a/lib/user.php b/lib/user.php
index 65f899aa27c..b91abd71fe6 100644
--- a/lib/user.php
+++ b/lib/user.php
@@ -269,10 +269,25 @@ class OC_User {
/**
* @brief Sets user display name for session
*/
- private static function setDisplayName($uid) {
- $_SESSION['display_name'] = self::determineDisplayName($uid);
+ public static function setDisplayName($uid, $displayName = null) {
+ $result = false;
+ if ($displayName ) {
+ foreach(self::$_usedBackends as $backend) {
+ if($backend->implementsActions(OC_USER_BACKEND_SET_DISPLAYNAME)) {
+ if($backend->userExists($uid)) {
+ $success |= $backend->setDisplayName($uid, $displayName);
+ }
+ }
+ }
+ } else {
+ $displayName = self::determineDisplayName($uid);
+ $result = true;
+ }
+ $_SESSION['display_name'] = $displayName;
+ return result;
}
+
/**
* @brief get display name
* @param $uid The username
diff --git a/lib/user/backend.php b/lib/user/backend.php
index fe37a64cc03..efea622e312 100644
--- a/lib/user/backend.php
+++ b/lib/user/backend.php
@@ -36,6 +36,7 @@ define('OC_USER_BACKEND_SET_PASSWORD', 0x000010);
define('OC_USER_BACKEND_CHECK_PASSWORD', 0x000100);
define('OC_USER_BACKEND_GET_HOME', 0x001000);
define('OC_USER_BACKEND_GET_DISPLAYNAME', 0x010000);
+define('OC_USER_BACKEND_SET_DISPLAYNAME', 0x010000);
/**
@@ -52,6 +53,7 @@ abstract class OC_User_Backend implements OC_User_Interface {
OC_USER_BACKEND_CHECK_PASSWORD => 'checkPassword',
OC_USER_BACKEND_GET_HOME => 'getHome',
OC_USER_BACKEND_GET_DISPLAYNAME => 'getDisplayName',
+ OC_USER_BACKEND_SET_DISPLAYNAME => 'setDisplayName',
);
/**
diff --git a/settings/js/users.js b/settings/js/users.js
index fa6f058d923..835f46f6ed3 100644
--- a/settings/js/users.js
+++ b/settings/js/users.js
@@ -300,6 +300,43 @@ $(document).ready(function () {
$('td.password').live('click', function (event) {
$(this).children('img').click();
});
+
+ $('td.displayName>img').live('click', function (event) {
+ event.stopPropagation();
+ var img = $(this);
+ var uid = img.parent().parent().attr('data-uid');
+ var input = $('<input type="text">');
+ img.css('display', 'none');
+ img.parent().children('span').replaceWith(input);
+ input.focus();
+ input.keypress(function (event) {
+ console.log("event!");
+ if (event.keyCode == 13) {
+ console.log("13");
+ if ($(this).val().length > 0) {
+ console.log("post");
+ $.post(
+ OC.filePath('settings', 'ajax', 'changedisplayname.php'),
+ {username:uid, displayName:$(this).val()},
+ function (result) {
+ console.log("come back!");
+ }
+ );
+ input.blur();
+ } else {
+ input.blur();
+ }
+ }
+ });
+ input.blur(function () {
+ $(this).replaceWith($(this).val());
+ img.css('display', '');
+ });
+ });
+ $('td.displayName').live('click', function (event) {
+ $(this).children('img').click();
+ });
+
$('select.quota, select.quota-user').live('change', function () {
var select = $(this);
diff --git a/settings/routes.php b/settings/routes.php
index 9b5bf809230..c9156f9a115 100644
--- a/settings/routes.php
+++ b/settings/routes.php
@@ -39,6 +39,8 @@ $this->create('settings_ajax_removegroup', '/settings/ajax/removegroup.php')
->actionInclude('settings/ajax/removegroup.php');
$this->create('settings_ajax_changepassword', '/settings/ajax/changepassword.php')
->actionInclude('settings/ajax/changepassword.php');
+$this->create('settings_ajax_changedisplayname', '/settings/ajax/changedisplayname.php')
+->actionInclude('settings/ajax/changedisplayname.php');
// personel
$this->create('settings_ajax_lostpassword', '/settings/ajax/lostpassword.php')
->actionInclude('settings/ajax/lostpassword.php');
diff --git a/settings/templates/users.php b/settings/templates/users.php
index 64dce38ba31..2ba57fb4a7c 100644
--- a/settings/templates/users.php
+++ b/settings/templates/users.php
@@ -93,7 +93,7 @@ var isadmin = <?php echo $_['isadmin']?'true':'false'; ?>;
<?php foreach($_["users"] as $user): ?>
<tr data-uid="<?php echo $user["name"] ?>">
<td class="name"><?php echo $user["name"]; ?></td>
- <td class="displayName"><?php echo $user["displayName"]; ?> <img class="svg action"
+ <td class="displayName"><span><?php echo $user["displayName"]; ?></span> <img class="svg action"
src="<?php echo image_path('core', 'actions/rename.svg')?>"
alt="change display name" title="change display name"/>
</td>