interface and API to change display names
This commit is contained in:
parent
022a7b13b8
commit
e0f2ed2757
19
lib/user.php
19
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
|
||||
|
|
|
@ -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',
|
||||
);
|
||||
|
||||
/**
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue