No more barrier to enter for guests. Closes #200
This commit is contained in:
parent
09e0f2cc60
commit
f26e107504
@ -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
|
||||
|
@ -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')
|
||||
|
@ -232,6 +232,10 @@
|
||||
border: 0 none !important;
|
||||
}
|
||||
|
||||
.memberListButton input{
|
||||
width:46px;
|
||||
}
|
||||
|
||||
#toolbar {
|
||||
top:30px !important;
|
||||
border-bottom: none !important;
|
||||
|
1
js/3rdparty/webodf/editor/MemberListView.js
vendored
1
js/3rdparty/webodf/editor/MemberListView.js
vendored
@ -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();
|
||||
|
@ -25,7 +25,7 @@ var documentsMain = {
|
||||
t('documents', 'Share') +
|
||||
' </button>' +
|
||||
' <button id="odf-close">' +
|
||||
t('documents', 'Close') +
|
||||
t('documents', 'Close') +
|
||||
' </button>' +
|
||||
' <img id="saving-document" alt=""' +
|
||||
' src="' + OC.imagePath('core', 'loading.gif') + '"' +
|
||||
@ -138,6 +138,17 @@ var documentsMain = {
|
||||
if (!OC.currentUser){
|
||||
documentsMain.isGuest = true;
|
||||
|
||||
|
||||
if ($("[name='document']").val()){
|
||||
// !Login page mess wih WebODF toolbars
|
||||
$(document.body).attr('id', 'body-user');
|
||||
$('header,footer').hide();
|
||||
documentsMain.prepareSession();
|
||||
documentsMain.joinSession(
|
||||
$("[name='document']").val()
|
||||
);
|
||||
}
|
||||
|
||||
} else {
|
||||
// Does anything indicate that we need to autostart a session?
|
||||
fileId = parent.location.hash.replace(/\W*/g, '');
|
||||
@ -208,6 +219,9 @@ var documentsMain = {
|
||||
documentsMain.fileName || response.title,
|
||||
response.permissions & OC.PERMISSION_SHARE && !documentsMain.isGuest
|
||||
);
|
||||
if (documentsMain.isGuest){
|
||||
$('#odf-close').text(t('documents', 'Save') );
|
||||
}
|
||||
var serverFactory = new ServerFactory();
|
||||
documentsMain.esId = response.es_id;
|
||||
documentsMain.memberId = response.member_id;
|
||||
@ -300,6 +314,78 @@ var documentsMain = {
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
changeNick: function(memberId, name, node){
|
||||
var url = OC.generateUrl('apps/documents/ajax/user/rename/{member_id}', {member_id: memberId});
|
||||
$.post(
|
||||
url,
|
||||
{ name : name },
|
||||
function(result) {
|
||||
if (result && result.status === 'error') {
|
||||
if (result.message){
|
||||
OC.Notification.show(result.message);
|
||||
setTimeout(function() {
|
||||
OC.Notification.hide();
|
||||
}, 10000);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
);
|
||||
},
|
||||
|
||||
onNickChange: function(memberId, fullNameNode){
|
||||
if (!documentsMain.isGuest || memberId !== documentsMain.memberId){
|
||||
return;
|
||||
}
|
||||
if ($(fullNameNode.parentNode).children('input').length !== 0){
|
||||
return;
|
||||
}
|
||||
|
||||
var input = $('<input type="text"/>').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);
|
||||
|
||||
|
||||
|
@ -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,
|
||||
|
@ -12,11 +12,7 @@
|
||||
<input type="submit" name="submit" value="<?php p($l->t('OK')) ?>" />
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
<?php if (isset($_['document'])): ?>
|
||||
<form>
|
||||
<input type="text" name="memberName" placeholder="<?php p($l->t('Please enter your nickname')) ?>" />
|
||||
<button id="odf-join"><?php p($l->t('Join')) ?></button>
|
||||
</form>
|
||||
<?php if (isset($_['document']) && !isset($_['wrongpw'])): ?>
|
||||
<input type="hidden" name="document" value ="<?php p($_['document']) ?>" />
|
||||
<?php endif; ?>
|
||||
<?php if (isset($_['notFound'])): ?>
|
||||
|
Loading…
x
Reference in New Issue
Block a user