Removing session participants

This commit is contained in:
Aleksander Machniak 2015-11-20 17:49:56 +01:00
parent e212334454
commit 24c8ac7507
4 changed files with 69 additions and 15 deletions

View file

@ -1149,12 +1149,7 @@ rcube_webmail.prototype.document_export = function(type)
rcube_webmail.prototype.document_editors = function()
{
var info = rcmail.env.file_data;
if (!info || !info.session || !info.session.is_owner)
return;
kolab_files_editors_dialog(info.session);
kolab_files_editors_dialog();
};
// close editing session
@ -1171,13 +1166,19 @@ rcube_webmail.prototype.document_close = function()
function kolab_files_editors_dialog(session)
{
var ac_props, items = [], buttons = {},
info = rcmail.env.file_data,
dialog = $('#document-editors-dialog');
// always add the session organizer
items.push(kolab_files_attendee_record(session.owner, 'organizer'));
if (!info || !info.session || !info.session.is_owner)
return;
$.each(session.invitations || [], function() {
items.push(kolab_files_attendee_record(this.user, this.status));
// always add the session organizer
items.push(kolab_files_attendee_record(info.session.owner, 'organizer'));
$.each(info.session.invitations || [], function(i, u) {
var record = kolab_files_attendee_record(u.user, u.status);
items.push(record);
info.session.invitations[i].record = record;
});
$('table > tbody', dialog).html(items);
@ -1285,11 +1286,23 @@ function kolab_files_add_attendees(names)
function kolab_files_attendee_record(user, status)
{
var buttons = $('<td class="options">');
// @todo: accept invitation request button
// delete button
if (status != 'organizer') {
$('<a>').attr({'class': 'delete', href: '#', title: rcmail.gettext('kolab_files.removeparticipant')})
.click(function() {
file_api.document_remove(rcmail.env.file_data.session.id, [user]);
})
.appendTo(buttons);
}
return $('<tr>').attr('class', 'invitation' + (status ? ' ' + status : ''))
.append($('<td class="name">').text(user))
.append($('<td class="status">').text(rcmail.gettext('kolab_files.status' + status)))
.append($('<td class="options">'));
// @todo: delete and accept button
.append(buttons);
};
@ -3107,9 +3120,39 @@ function kolab_files_ui()
table = $('#document-editors-dialog table > tbody');
$.each(response.result.list || {}, function() {
table.append(kolab_files_attendee_record(this.user, this.status));
var record = kolab_files_attendee_record(this.user, this.status);
table.append(record);
if (info.session && info.session.invitations)
info.session.invitations.push($.extend({status: 'invited'}, this));
info.session.invitations.push($.extend({status: 'invited', record: record}, this));
});
};
// Remove document session participants
this.document_remove = function(id, attendees)
{
if (attendees.length) {
this.req = this.set_busy(true, 'kolab_files.documentremoving');
this.request('document_remove', {id: id, users: attendees}, 'document_remove_response');
}
};
// document remove response handler
this.document_remove_response = function(response)
{
if (!this.response(response) || !response.result)
return;
var info = rcmail.env.file_data;
$.each(response.result.list || {}, function(i, user) {
var invitations = [];
$.each(info.session.invitations, function(i, u) {
if (u.user == user && u.record)
u.record.remove();
else
invitations.push(u);
});
info.session.invitations = invitations;
});
};

View file

@ -950,7 +950,8 @@ class kolab_files_engine
*/
protected function action_edit()
{
$this->plugin->add_label('sessionterminating', 'unsavedchanges');
$this->plugin->add_label('sessionterminating', 'unsavedchanges', 'documentinviting',
'documentremoving', 'removeparticipant');
$this->file_opener(intval($_GET['_viewer']));
}

View file

@ -118,6 +118,9 @@ $labels['statusinvited'] = 'Invited';
$labels['statusaccepted'] = 'Accepted';
$labels['statusdeclined'] = 'Declined';
$labels['statusrequested'] = 'Requested';
$labels['documentinviting'] = 'Inviting participant(s)...';
$labels['documentremoving'] = 'Removing participant(s)...';
$labels['removeparticipant'] = 'Remove';
$labels['storepasswords'] = 'remember password';
$labels['storepasswordsdesc'] = 'Stored passwords will be encrypted. Enable this if you do not want to be asked for the password on every login or you want this storage to be available via WebDAV.';

View file

@ -596,3 +596,10 @@ table.propform td.source table.propform td {
#document-editors-dialog table tr.organizer td {
color: #888;
}
#document-editors-dialog table td.options a.delete {
background: url(../../../../skins/larry/images/buttons.png) -7px -379px no-repeat;
height: 16px;
width: 16px;
display: block;
}