summaryrefslogtreecommitdiffstats
path: root/settings
diff options
context:
space:
mode:
authorLukas Reschke <lukas@statuscode.ch>2013-01-29 14:05:54 -0800
committerLukas Reschke <lukas@statuscode.ch>2013-01-29 14:05:54 -0800
commit250c565d2be9ebd7033c43c3362a44c58964c79b (patch)
treef8354bf6b5d6a8a37b46d4685f09342d41dd2695 /settings
parent472491955ae7e8172b113bd564ec242cc8bc4577 (diff)
parent665979819766bd23cddc18a3e1666f303ac25932 (diff)
downloadnextcloud-server-250c565d2be9ebd7033c43c3362a44c58964c79b.tar.gz
nextcloud-server-250c565d2be9ebd7033c43c3362a44c58964c79b.zip
Merge pull request #1360 from owncloud/display_name
introduction of display names
Diffstat (limited to 'settings')
-rw-r--r--settings/ajax/changedisplayname.php28
-rw-r--r--settings/js/users.js36
-rw-r--r--settings/routes.php2
-rw-r--r--settings/templates/users.php12
-rw-r--r--settings/users.php20
5 files changed, 88 insertions, 10 deletions
diff --git a/settings/ajax/changedisplayname.php b/settings/ajax/changedisplayname.php
new file mode 100644
index 00000000000..f80ecb7a0c9
--- /dev/null
+++ b/settings/ajax/changedisplayname.php
@@ -0,0 +1,28 @@
+<?php
+// Check if we are a user
+OCP\JSON::callCheck();
+OC_JSON::checkLoggedIn();
+
+$username = isset($_POST["username"]) ? $_POST["username"] : OC_User::getUser();
+$displayName = $_POST["displayName"];
+
+$userstatus = null;
+if(OC_User::isAdminUser(OC_User::getUser())) {
+ $userstatus = 'admin';
+}
+if(OC_SubAdmin::isUserAccessible(OC_User::getUser(), $username)) {
+ $userstatus = 'subadmin';
+}
+
+if(is_null($userstatus)) {
+ OC_JSON::error( array( "data" => array( "message" => "Authentication error" )));
+ exit();
+}
+
+// Return Success story
+if( OC_User::setDisplayName( $username, $displayName )) {
+ OC_JSON::success(array("data" => array( "username" => $username )));
+}
+else{
+ OC_JSON::error(array("data" => array( "message" => "Unable to change display name" )));
+} \ No newline at end of file
diff --git a/settings/js/users.js b/settings/js/users.js
index 9f0c1ffd111..424d00b51a7 100644
--- a/settings/js/users.js
+++ b/settings/js/users.js
@@ -69,7 +69,9 @@ var UserList = {
add:function (username, groups, subadmin, quota, sort) {
var tr = $('tbody tr').first().clone();
tr.attr('data-uid', username);
+ tr.attr('data-displayName', username);
tr.find('td.name').text(username);
+ tr.find('td.displayName').text(username);
var groupsSelect = $('<select multiple="multiple" class="groupsselect" data-placehoder="Groups" title="' + t('settings', 'Groups') + '"></select>').attr('data-username', username).attr('data-user-groups', groups);
tr.find('td.groups').empty();
if (tr.find('td.subadmins').length > 0) {
@@ -299,6 +301,40 @@ $(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 displayName = img.parent().parent().attr('data-displayName');
+ var input = $('<input type="text" value="'+displayName+'">');
+ img.css('display', 'none');
+ img.parent().children('span').replaceWith(input);
+ input.focus();
+ input.keypress(function (event) {
+ if (event.keyCode == 13) {
+ if ($(this).val().length > 0) {
+ $.post(
+ OC.filePath('settings', 'ajax', 'changedisplayname.php'),
+ {username:uid, displayName:$(this).val()},
+ function (result) {
+ }
+ );
+ 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 1c766837dd1..0a5b2fbfd38 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 c88966f7137..f30c21efaef 100644
--- a/settings/templates/users.php
+++ b/settings/templates/users.php
@@ -18,7 +18,7 @@ $_['subadmingroups'] = array_flip($items);
<div id="controls">
<form id="newuser" autocomplete="off">
- <input id="newusername" type="text" placeholder="<?php echo $l->t('Name')?>" /> <input
+ <input id="newusername" type="text" placeholder="<?php echo $l->t('Login Name')?>" /> <input
type="password" id="newuserpassword"
placeholder="<?php echo $l->t('Password')?>" /> <select
class="groupsselect"
@@ -76,7 +76,8 @@ $_['subadmingroups'] = array_flip($items);
<table data-groups="<?php echo implode(', ', $allGroups);?>">
<thead>
<tr>
- <th id='headerName'><?php echo $l->t('Name')?></th>
+ <th id='headerName'><?php echo $l->t('Login Name')?></th>
+ <th id="headerDisplayName"><?php echo $l->t( 'Display Name' ); ?></th>
<th id="headerPassword"><?php echo $l->t( 'Password' ); ?></th>
<th id="headerGroups"><?php echo $l->t( 'Groups' ); ?></th>
<?php if(is_array($_['subadmins']) || $_['subadmins']): ?>
@@ -88,8 +89,13 @@ $_['subadmingroups'] = array_flip($items);
</thead>
<tbody>
<?php foreach($_["users"] as $user): ?>
- <tr data-uid="<?php echo $user["name"] ?>">
+ <tr data-uid="<?php echo $user["name"] ?>"
+ data-displayName="<?php echo $user["displayName"] ?>">
<td class="name"><?php echo $user["name"]; ?></td>
+ <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>
<td class="password"><span>●●●●●●●</span> <img class="svg action"
src="<?php echo image_path('core', 'actions/rename.svg')?>"
alt="set new password" title="set new password"/>
diff --git a/settings/users.php b/settings/users.php
index 668d974693a..ab7a7aed734 100644
--- a/settings/users.php
+++ b/settings/users.php
@@ -22,11 +22,11 @@ $isadmin = OC_User::isAdminUser(OC_User::getUser());
if($isadmin) {
$accessiblegroups = OC_Group::getGroups();
- $accessibleusers = OC_User::getUsers('', 30);
+ $accessibleusers = OC_User::getDisplayNames('', 30);
$subadmins = OC_SubAdmin::getAllSubAdmins();
}else{
$accessiblegroups = OC_SubAdmin::getSubAdminsGroups(OC_User::getUser());
- $accessibleusers = OC_Group::usersInGroups($accessiblegroups, '', 30);
+ $accessibleusers = OC_Group::displayNamesInGroups($accessiblegroups, '', 30);
$subadmins = false;
}
@@ -42,16 +42,22 @@ $defaultQuota=OC_Appconfig::getValue('files', 'default_quota', 'none');
$defaultQuotaIsUserDefined=array_search($defaultQuota, $quotaPreset)===false && array_search($defaultQuota, array('none', 'default'))===false;
// load users and quota
-foreach($accessibleusers as $i) {
- $quota=OC_Preferences::getValue($i, 'files', 'quota', 'default');
+foreach($accessibleusers as $uid => $displayName) {
+ $quota=OC_Preferences::getValue($uid, 'files', 'quota', 'default');
$isQuotaUserDefined=array_search($quota, $quotaPreset)===false && array_search($quota, array('none', 'default'))===false;
+ $name = $displayName;
+ if ( $displayName != $uid ) {
+ $name = $name . ' ('.$uid.')';
+ }
+
$users[] = array(
- "name" => $i,
- "groups" => join( ", ", /*array_intersect(*/OC_Group::getUserGroups($i)/*, OC_SubAdmin::getSubAdminsGroups(OC_User::getUser()))*/),
+ "name" => $uid,
+ "displayName" => $displayName,
+ "groups" => join( ", ", /*array_intersect(*/OC_Group::getUserGroups($uid)/*, OC_SubAdmin::getSubAdminsGroups(OC_User::getUser()))*/),
'quota'=>$quota,
'isQuotaUserDefined'=>$isQuotaUserDefined,
- 'subadmin'=>implode(', ', OC_SubAdmin::getSubAdminsGroups($i)));
+ 'subadmin'=>implode(', ', OC_SubAdmin::getSubAdminsGroups($uid)));
}
foreach( $accessiblegroups as $i ) {