diff --git a/ajax/userController.php b/ajax/userController.php
index fa4f0bd6..8ad1d74d 100644
--- a/ajax/userController.php
+++ b/ajax/userController.php
@@ -39,6 +39,24 @@ class UserController extends Controller{
\OCP\JSON::success();
}
+ public static function rename($args){
+ $memberId = @$args['member_id'];
+ $name = @$_POST['name'];
+ $member = new Db_Member();
+ $member->load($memberId);
+ $memberData = $member->getData();
+ if (count($memberData) && $memberData['status']==Db_Member::MEMBER_STATUS_ACTIVE
+ && preg_match('/.* \(guest\)$/', $memberData['uid'])
+ ){
+ if (!preg_match('/.* \(guest\)$/', $name)){
+ $name .= ' (guest)';
+ }
+ $op = new Db_Op();
+ $op->changeNick($memberData['es_id'], $memberId, $name);
+ }
+ \OCP\JSON::success();
+ }
+
/**
* Stub - sends a generic avatar
diff --git a/appinfo/routes.php b/appinfo/routes.php
index 3a41ffed..d8a81cc2 100644
--- a/appinfo/routes.php
+++ b/appinfo/routes.php
@@ -82,6 +82,11 @@ $this->create('documents_user_avatar', 'ajax/user/avatar')
->action('\OCA\Documents\UserController', 'sendAvatar')
;
+$this->create('documents_user_rename', 'ajax/user/rename/{member_id}')
+ ->post()
+ ->action('\OCA\Documents\UserController', 'rename')
+;
+
$this->create('documents_user_disconnect', 'ajax/user/disconnect/{member_id}')
->post()
->action('\OCA\Documents\UserController', 'disconnectUser')
diff --git a/css/style.css b/css/style.css
index 8bee07d7..34ea1952 100755
--- a/css/style.css
+++ b/css/style.css
@@ -232,6 +232,10 @@
border: 0 none !important;
}
+.memberListButton input{
+ width:46px;
+}
+
#toolbar {
top:30px !important;
border-bottom: none !important;
diff --git a/js/3rdparty/webodf/editor/MemberListView.js b/js/3rdparty/webodf/editor/MemberListView.js
index 9f604c7f..305f2c2c 100644
--- a/js/3rdparty/webodf/editor/MemberListView.js
+++ b/js/3rdparty/webodf/editor/MemberListView.js
@@ -116,6 +116,7 @@ define("webodf/editor/MemberListView",
//avatar.getCaret().hideHandle();
};
avatarDiv.onclick = function () {
+ documentsMain.onNickChange(memberId, fullnameNode);
var caret = editorSession.sessionView.getCaret(memberId);
if (caret) {
//caret.toggleHandleVisibility();
diff --git a/js/documents.js b/js/documents.js
index c6ba7acc..3c4f340b 100644
--- a/js/documents.js
+++ b/js/documents.js
@@ -25,7 +25,7 @@ var documentsMain = {
t('documents', 'Share') +
' ' +
' ' +
' ').val($(fullNameNode).attr('fullname'));
+ $(fullNameNode.parentNode).append(input);
+ $(fullNameNode).hide();
+
+ input.on('blur', function(){
+ var newName = input.val();
+ if (!newName || newName === name) {
+ input.tipsy('hide');
+ input.remove();
+ $(fullNameNode).show();
+ return;
+ }
+ else {
+ try {
+ input.tipsy('hide');
+ input.removeClass('error');
+ input.tipsy('hide');
+ input.remove();
+ $(fullNameNode).show();
+ documentsMain.changeNick(memberId, newName, fullNameNode);
+ }
+ catch (error) {
+ input.attr('title', error);
+ input.tipsy({gravity: 'n', trigger: 'manual'});
+ input.tipsy('show');
+ input.addClass('error');
+ }
+ }
+ });
+ input.on('keyup', function(event){
+ if (event.keyCode === 27) {
+ // cancel by putting in an empty value
+ $(this).val('');
+ $(this).blur();
+ event.preventDefault();
+ }
+ if (event.keyCode === 13) {
+ $(this).blur();
+ event.preventDefault();
+ }
+ });
+ input.focus();
+ input.selectRange(0, name.length);
+ },
renameDocument: function(name) {
var url = OC.generateUrl('apps/documents/ajax/documents/rename/{file_id}', {file_id: documentsMain.fileId});
@@ -583,17 +669,7 @@ $(document).ready(function() {
$(document.body).on('click', '#document-title>div', documentsMain.onRenamePrompt);
$(document.body).on('click', '#odf-close', documentsMain.onClose);
$(document.body).on('click', '#odf-invite', documentsMain.onInvite);
- $(document.body).on('click', '#odf-join', function(event){
- event.preventDefault();
- // !Login page mess wih WebODF toolbars
- $(document.body).attr('id', 'body-user');
- $('header,footer').hide();
- documentsMain.prepareSession();
- documentsMain.joinSession(
- $("[name='document']").val()
- );
- });
$('.add-document').on('click', '.add', documentsMain.onCreate);
diff --git a/lib/db/op.php b/lib/db/op.php
index 7dea6f26..31ca7d31 100644
--- a/lib/db/op.php
+++ b/lib/db/op.php
@@ -109,6 +109,12 @@ class Db_Op extends Db {
$this->insertOp($esId, $memberId, $op);
}
+ public function changeNick($esId, $memberId, $fullName){
+ $op = '{"optype":"UpdateMember","memberid":"'. $memberId .'", "setProperties":{"fullName":"'. $fullName .'"},"timestamp":'. time() .'}'
+ ;
+ $this->insertOp($esId, $memberId, $op);
+ }
+
protected function insertOp($esId, $memberId, $op){
$op = new Db_Op(array(
$esId,
diff --git a/templates/public.php b/templates/public.php
index cc9efbfe..8c28808f 100644
--- a/templates/public.php
+++ b/templates/public.php
@@ -12,11 +12,7 @@
-
-