Move more common methods used by tasklist and calendar to libcalendaring
This commit is contained in:
parent
e5739f7c11
commit
2ad0d6651d
3 changed files with 97 additions and 132 deletions
|
@ -283,49 +283,6 @@ function rcube_calendar_ui(settings)
|
||||||
else
|
else
|
||||||
return date.getHours() >= settings['work_start'] && date.getHours() < settings['work_end'];
|
return date.getHours() >= settings['work_start'] && date.getHours() < settings['work_end'];
|
||||||
};
|
};
|
||||||
|
|
||||||
// check if the event has 'real' attendees, excluding the current user
|
|
||||||
var has_attendees = function(event)
|
|
||||||
{
|
|
||||||
return (event.attendees && event.attendees.length && (event.attendees.length > 1 || String(event.attendees[0].email).toLowerCase() != settings.identity.email));
|
|
||||||
};
|
|
||||||
|
|
||||||
// check if the current user is an attendee of this event
|
|
||||||
var is_attendee = function(event, role, email)
|
|
||||||
{
|
|
||||||
var emails = email ? ';'+email.toLowerCase() : settings.identity.emails;
|
|
||||||
for (var i=0; event.attendees && i < event.attendees.length; i++) {
|
|
||||||
if ((!role || event.attendees[i].role == role) && event.attendees[i].email && emails.indexOf(';'+event.attendees[i].email.toLowerCase()) >= 0)
|
|
||||||
return event.attendees[i];
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
|
|
||||||
// check if the current user is the organizer
|
|
||||||
var is_organizer = function(event, email)
|
|
||||||
{
|
|
||||||
return is_attendee(event, 'ORGANIZER', email) || !event.id;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check permissions on the given calendar object
|
|
||||||
*/
|
|
||||||
var has_permission = function(cal, perm)
|
|
||||||
{
|
|
||||||
// multiple chars means "either of"
|
|
||||||
if (String(perm).length > 1) {
|
|
||||||
for (var i=0; i < perm.length; i++) {
|
|
||||||
if (has_permission(cal, perm[i]))
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cal.rights && String(cal.rights).indexOf(perm) >= 0) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (perm == 'i' && cal.editable) || (perm == 'v' && cal.editable);
|
|
||||||
}
|
|
||||||
|
|
||||||
var load_attachment = function(event, att)
|
var load_attachment = function(event, att)
|
||||||
{
|
{
|
||||||
|
@ -514,7 +471,7 @@ function rcube_calendar_ui(settings)
|
||||||
});
|
});
|
||||||
|
|
||||||
var data, mystatus = null, rsvp, line, morelink, html = '', overflow = '',
|
var data, mystatus = null, rsvp, line, morelink, html = '', overflow = '',
|
||||||
organizer = is_organizer(event);
|
organizer = me.is_organizer(event);
|
||||||
|
|
||||||
for (var j=0; j < event.attendees.length; j++) {
|
for (var j=0; j < event.attendees.length; j++) {
|
||||||
data = event.attendees[j];
|
data = event.attendees[j];
|
||||||
|
@ -568,7 +525,7 @@ function rcube_calendar_ui(settings)
|
||||||
.text(rcmail.gettext('status' + mystatus, 'libcalendaring'));
|
.text(rcmail.gettext('status' + mystatus, 'libcalendaring'));
|
||||||
}
|
}
|
||||||
|
|
||||||
var show_rsvp = rsvp && !organizer && event.status != 'CANCELLED' && has_permission(calendar, 'v');
|
var show_rsvp = rsvp && !organizer && event.status != 'CANCELLED' && me.has_permission(calendar, 'v');
|
||||||
$('#event-rsvp')[(show_rsvp ? 'show' : 'hide')]();
|
$('#event-rsvp')[(show_rsvp ? 'show' : 'hide')]();
|
||||||
$('#event-rsvp .rsvp-buttons input').prop('disabled', false).filter('input[rel='+mystatus+']').prop('disabled', true);
|
$('#event-rsvp .rsvp-buttons input').prop('disabled', false).filter('input[rel='+mystatus+']').prop('disabled', true);
|
||||||
|
|
||||||
|
@ -596,7 +553,7 @@ function rcube_calendar_ui(settings)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (!temp && has_permission(calendar, 'td') && event.editable !== false) {
|
if (!temp && me.has_permission(calendar, 'td') && event.editable !== false) {
|
||||||
buttons.push({
|
buttons.push({
|
||||||
text: rcmail.gettext('delete', 'calendar'),
|
text: rcmail.gettext('delete', 'calendar'),
|
||||||
'class': 'delete',
|
'class': 'delete',
|
||||||
|
@ -737,7 +694,7 @@ function rcube_calendar_ui(settings)
|
||||||
calendars.val($('option:first', calendars).attr('value'));
|
calendars.val($('option:first', calendars).attr('value'));
|
||||||
|
|
||||||
invite.checked = settings.itip_notify & 1 > 0;
|
invite.checked = settings.itip_notify & 1 > 0;
|
||||||
notify.checked = has_attendees(event) && invite.checked;
|
notify.checked = me.has_attendees(event) && invite.checked;
|
||||||
|
|
||||||
if (event.allDay) {
|
if (event.allDay) {
|
||||||
starttime.val("12:00").hide();
|
starttime.val("12:00").hide();
|
||||||
|
@ -751,7 +708,7 @@ function rcube_calendar_ui(settings)
|
||||||
// set calendar selection according to permissions
|
// set calendar selection according to permissions
|
||||||
calendars.find('option').each(function(i, opt) {
|
calendars.find('option').each(function(i, opt) {
|
||||||
var cal = me.calendars[opt.value] || {};
|
var cal = me.calendars[opt.value] || {};
|
||||||
$(opt).prop('disabled', !(cal.editable || (action == 'new' && has_permission(cal, 'i'))))
|
$(opt).prop('disabled', !(cal.editable || (action == 'new' && me.has_permission(cal, 'i'))))
|
||||||
});
|
});
|
||||||
|
|
||||||
// set alarm(s)
|
// set alarm(s)
|
||||||
|
@ -783,13 +740,13 @@ function rcube_calendar_ui(settings)
|
||||||
$('#edit-recurring-warning').hide();
|
$('#edit-recurring-warning').hide();
|
||||||
|
|
||||||
// init attendees tab
|
// init attendees tab
|
||||||
var organizer = !event.attendees || is_organizer(event),
|
var organizer = !event.attendees || me.is_organizer(event),
|
||||||
allow_invitations = organizer || (calendar.owner && calendar.owner == 'anonymous') || settings.invite_shared;
|
allow_invitations = organizer || (calendar.owner && calendar.owner == 'anonymous') || settings.invite_shared;
|
||||||
event_attendees = [];
|
event_attendees = [];
|
||||||
attendees_list = $('#edit-attendees-table > tbody').html('');
|
attendees_list = $('#edit-attendees-table > tbody').html('');
|
||||||
resources_list = $('#edit-resources-table > tbody').html('');
|
resources_list = $('#edit-resources-table > tbody').html('');
|
||||||
$('#edit-attendees-notify')[(action != 'new' && allow_invitations && has_attendees(event) && (settings.itip_notify & 2) ? 'show' : 'hide')]();
|
$('#edit-attendees-notify')[(action != 'new' && allow_invitations && me.has_attendees(event) && (settings.itip_notify & 2) ? 'show' : 'hide')]();
|
||||||
$('#edit-localchanges-warning')[(action != 'new' && has_attendees(event) && !(allow_invitations || (calendar.owner && is_organizer(event, calendar.owner))) ? 'show' : 'hide')]();
|
$('#edit-localchanges-warning')[(action != 'new' && me.has_attendees(event) && !(allow_invitations || (calendar.owner && me.is_organizer(event, calendar.owner))) ? 'show' : 'hide')]();
|
||||||
|
|
||||||
var load_attendees_tab = function()
|
var load_attendees_tab = function()
|
||||||
{
|
{
|
||||||
|
@ -2554,13 +2511,13 @@ function rcube_calendar_ui(settings)
|
||||||
|
|
||||||
if (!data) data = event;
|
if (!data) data = event;
|
||||||
var decline = false, notify = false, html = '', cal = me.calendars[event.calendar],
|
var decline = false, notify = false, html = '', cal = me.calendars[event.calendar],
|
||||||
_has_attendees = has_attendees(event), _is_organizer = is_organizer(event);
|
_has_attendees = me.has_attendees(event), _is_organizer = me.is_organizer(event);
|
||||||
|
|
||||||
// event has attendees, ask whether to notify them
|
// event has attendees, ask whether to notify them
|
||||||
if (_has_attendees) {
|
if (_has_attendees) {
|
||||||
var checked = (settings.itip_notify & 1 ? ' checked="checked"' : '');
|
var checked = (settings.itip_notify & 1 ? ' checked="checked"' : '');
|
||||||
|
|
||||||
if (action == 'remove' && cal.group != 'shared' && !_is_organizer && is_attendee(event)) {
|
if (action == 'remove' && cal.group != 'shared' && !_is_organizer && me.is_attendee(event)) {
|
||||||
decline = true;
|
decline = true;
|
||||||
checked = event.status != 'CANCELLED' ? checked : '';
|
checked = event.status != 'CANCELLED' ? checked : '';
|
||||||
html += '<div class="message">' +
|
html += '<div class="message">' +
|
||||||
|
@ -2588,7 +2545,7 @@ function rcube_calendar_ui(settings)
|
||||||
|
|
||||||
// disable the 'future' savemode if I'm an attendee
|
// disable the 'future' savemode if I'm an attendee
|
||||||
// reason: no calendaring system supports the thisandfuture range parameter in iTip REPLY
|
// reason: no calendaring system supports the thisandfuture range parameter in iTip REPLY
|
||||||
if (action == 'remove' && _has_attendees && !_is_organizer && is_attendee(event)) {
|
if (action == 'remove' && _has_attendees && !_is_organizer && me.is_attendee(event)) {
|
||||||
future_disabled = ' disabled';
|
future_disabled = ' disabled';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3529,13 +3486,6 @@ function rcube_calendar_ui(settings)
|
||||||
this.fisheye_view(this.fisheye_date);
|
this.fisheye_view(this.fisheye_date);
|
||||||
};
|
};
|
||||||
|
|
||||||
// resize and reposition (center) the dialog window
|
|
||||||
this.dialog_resize = function(id, height, width)
|
|
||||||
{
|
|
||||||
var win = $(window), w = win.width(), h = win.height();
|
|
||||||
$(id).dialog('option', { height: Math.min(h-20, height+130), width: Math.min(w-20, width+50) });
|
|
||||||
};
|
|
||||||
|
|
||||||
// adjust calendar view size
|
// adjust calendar view size
|
||||||
this.view_resize = function()
|
this.view_resize = function()
|
||||||
{
|
{
|
||||||
|
@ -3593,7 +3543,7 @@ function rcube_calendar_ui(settings)
|
||||||
|
|
||||||
// insert to #calendar-select options if writeable
|
// insert to #calendar-select options if writeable
|
||||||
select = $('#edit-calendar');
|
select = $('#edit-calendar');
|
||||||
if (fc && has_permission(cal, 'i') && select.length && !select.find('option[value="'+id+'"]').length) {
|
if (fc && me.has_permission(cal, 'i') && select.length && !select.find('option[value="'+id+'"]').length) {
|
||||||
$('<option>').attr('value', id).html(cal.name).appendTo(select);
|
$('<option>').attr('value', id).html(cal.name).appendTo(select);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,6 +94,59 @@ function rcube_libcalendaring(settings)
|
||||||
return fromto;
|
return fromto;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the event/task has 'real' attendees, excluding the current user
|
||||||
|
*/
|
||||||
|
this.has_attendees = function(event)
|
||||||
|
{
|
||||||
|
return !!(event.attendees && event.attendees.length && (event.attendees.length > 1 || String(event.attendees[0].email).toLowerCase() != settings.identity.email));
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the current user is an attendee of this event/task
|
||||||
|
*/
|
||||||
|
this.is_attendee = function(event, role, email)
|
||||||
|
{
|
||||||
|
var i, emails = email ? ';' + email.toLowerCase() : settings.identity.emails;
|
||||||
|
|
||||||
|
for (i=0; event.attendees && i < event.attendees.length; i++) {
|
||||||
|
if ((!role || event.attendees[i].role == role) && event.attendees[i].email && emails.indexOf(';'+event.attendees[i].email.toLowerCase()) >= 0) {
|
||||||
|
return event.attendees[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the current user is the organizer of the event/task
|
||||||
|
*/
|
||||||
|
this.is_organizer = function(event, email)
|
||||||
|
{
|
||||||
|
return this.is_attendee(event, 'ORGANIZER', email) || !event.id;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check permissions on the given folder object
|
||||||
|
*/
|
||||||
|
this.has_permission = function(folder, perm)
|
||||||
|
{
|
||||||
|
// multiple chars means "either of"
|
||||||
|
if (String(perm).length > 1) {
|
||||||
|
for (var i=0; i < perm.length; i++) {
|
||||||
|
if (this.has_permission(folder, perm[i])) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (folder.rights && String(folder.rights).indexOf(perm) >= 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (perm == 'i' && folder.editable) || (perm == 'v' && folder.editable);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* From time and date strings to a real date object
|
* From time and date strings to a real date object
|
||||||
|
@ -1000,6 +1053,17 @@ function rcube_libcalendaring(settings)
|
||||||
|
|
||||||
container.empty().append(ul);
|
container.empty().append(ul);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// resize and reposition (center) the dialog window
|
||||||
|
this.dialog_resize = function(id, height, width)
|
||||||
|
{
|
||||||
|
var win = $(window), w = win.width(), h = win.height();
|
||||||
|
|
||||||
|
$(id).dialog('option', {
|
||||||
|
height: Math.min(h-20, height+130),
|
||||||
|
width: Math.min(w-20, width+50)
|
||||||
|
});
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
////// static methods
|
////// static methods
|
||||||
|
|
|
@ -173,9 +173,9 @@ function rcube_tasklist_ui(settings)
|
||||||
});
|
});
|
||||||
tasklists_widget.addEventListener('select', function(node) {
|
tasklists_widget.addEventListener('select', function(node) {
|
||||||
var id = $(this).data('id');
|
var id = $(this).data('id');
|
||||||
rcmail.enable_command('list-edit', has_permission(me.tasklists[node.id], 'wa'));
|
rcmail.enable_command('list-edit', me.has_permission(me.tasklists[node.id], 'wa'));
|
||||||
rcmail.enable_command('list-delete', has_permission(me.tasklists[node.id], 'xa'));
|
rcmail.enable_command('list-delete', me.has_permission(me.tasklists[node.id], 'xa'));
|
||||||
rcmail.enable_command('list-import', has_permission(me.tasklists[node.id], 'i'));
|
rcmail.enable_command('list-import', me.has_permission(me.tasklists[node.id], 'i'));
|
||||||
rcmail.enable_command('list-remove', me.tasklists[node.id] && me.tasklists[node.id].removable);
|
rcmail.enable_command('list-remove', me.tasklists[node.id] && me.tasklists[node.id].removable);
|
||||||
rcmail.enable_command('list-showurl', me.tasklists[node.id] && !!me.tasklists[node.id].caldavurl);
|
rcmail.enable_command('list-showurl', me.tasklists[node.id] && !!me.tasklists[node.id].caldavurl);
|
||||||
me.selected_list = node.id;
|
me.selected_list = node.id;
|
||||||
|
@ -738,27 +738,6 @@ function rcube_tasklist_ui(settings)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Check permissions on the given list object
|
|
||||||
*/
|
|
||||||
function has_permission(list, perm)
|
|
||||||
{
|
|
||||||
// multiple chars means "either of"
|
|
||||||
if (String(perm).length > 1) {
|
|
||||||
for (var i=0; i < perm.length; i++) {
|
|
||||||
if (has_permission(list, perm[i])) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (list.rights && String(list.rights).indexOf(perm) >= 0) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (perm == 'i' && list.editable);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Request counts from the server
|
* Request counts from the server
|
||||||
*/
|
*/
|
||||||
|
@ -1247,7 +1226,7 @@ function rcube_tasklist_ui(settings)
|
||||||
list = drop_rec && me.tasklists[drop_rec.list] ? me.tasklists[drop_rec.list] : { editable:true };
|
list = drop_rec && me.tasklists[drop_rec.list] ? me.tasklists[drop_rec.list] : { editable:true };
|
||||||
|
|
||||||
// target is not editable or already has this tag assigned
|
// target is not editable or already has this tag assigned
|
||||||
if (!drop_rec || drop_rec.readonly || !has_permission(list, 'i') || (drop_rec.tags && $.inArray(tag, drop_rec.tags) >= 0)) {
|
if (!drop_rec || drop_rec.readonly || !me.has_permission(list, 'i') || (drop_rec.tags && $.inArray(tag, drop_rec.tags) >= 0)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1370,7 +1349,7 @@ function rcube_tasklist_ui(settings)
|
||||||
function save_task(rec, action)
|
function save_task(rec, action)
|
||||||
{
|
{
|
||||||
// show confirmation dialog when status of an assigned task has changed
|
// show confirmation dialog when status of an assigned task has changed
|
||||||
if (rec._status_before !== undefined && is_attendee(rec))
|
if (rec._status_before !== undefined && me.is_attendee(rec))
|
||||||
return save_task_confirm(rec, action);
|
return save_task_confirm(rec, action);
|
||||||
|
|
||||||
if (!rcmail.busy) {
|
if (!rcmail.busy) {
|
||||||
|
@ -1393,7 +1372,7 @@ function rcube_tasklist_ui(settings)
|
||||||
do_confirm = settings.itip_notify & 2;
|
do_confirm = settings.itip_notify & 2;
|
||||||
|
|
||||||
// task has attendees, ask whether to notify them
|
// task has attendees, ask whether to notify them
|
||||||
if (has_attendees(rec) && is_organizer(rec)) {
|
if (me.has_attendees(rec) && me.is_organizer(rec)) {
|
||||||
notify = true;
|
notify = true;
|
||||||
if (do_confirm) {
|
if (do_confirm) {
|
||||||
html = rcmail.gettext('changeconfirmnotifications', 'tasklist');
|
html = rcmail.gettext('changeconfirmnotifications', 'tasklist');
|
||||||
|
@ -1403,7 +1382,7 @@ function rcube_tasklist_ui(settings)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ask whether to change my partstat and notify organizer
|
// ask whether to change my partstat and notify organizer
|
||||||
else if (data._status_before !== undefined && data.status && data._status_before != data.status && is_attendee(rec)) {
|
else if (data._status_before !== undefined && data.status && data._status_before != data.status && me.is_attendee(rec)) {
|
||||||
partstat = true;
|
partstat = true;
|
||||||
if (do_confirm) {
|
if (do_confirm) {
|
||||||
html = rcmail.gettext('partstatupdatenotification', 'tasklist');
|
html = rcmail.gettext('partstatupdatenotification', 'tasklist');
|
||||||
|
@ -1885,29 +1864,8 @@ function rcube_tasklist_ui(settings)
|
||||||
scroll_timer = window.setTimeout(function(){ tasklist_drag_scroll(container, dir); }, scroll_speed);
|
scroll_timer = window.setTimeout(function(){ tasklist_drag_scroll(container, dir); }, scroll_speed);
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if the task has 'real' attendees, excluding the current user
|
|
||||||
var has_attendees = function(task)
|
|
||||||
{
|
|
||||||
return !!(task.attendees && task.attendees.length && (task.attendees.length > 1 || String(task.attendees[0].email).toLowerCase() != settings.identity.email));
|
|
||||||
};
|
|
||||||
|
|
||||||
// check if the current user is an attendee of this task
|
|
||||||
var is_attendee = function(task, email, role)
|
|
||||||
{
|
|
||||||
var i, attendee, emails = email ? ';' + email.toLowerCase() : settings.identity.emails;
|
|
||||||
|
|
||||||
for (i=0; task.attendees && i < task.attendees.length; i++) {
|
|
||||||
attendee = task.attendees[i];
|
|
||||||
if ((!role || attendee.role == role) && attendee.email && emails.indexOf(';'+attendee.email.toLowerCase()) >= 0) {
|
|
||||||
return attendee;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
|
|
||||||
// check if the current user is the organizer
|
// check if the current user is the organizer
|
||||||
var is_organizer = function(task, email)
|
this.is_organizer = function(task, email)
|
||||||
{
|
{
|
||||||
if (!email) email = task.organizer ? task.organizer.email : null;
|
if (!email) email = task.organizer ? task.organizer.email : null;
|
||||||
if (email)
|
if (email)
|
||||||
|
@ -2140,7 +2098,7 @@ function rcube_tasklist_ui(settings)
|
||||||
});
|
});
|
||||||
*/
|
*/
|
||||||
var j, data, rsvp = false, mystatus = null, line, morelink, html = '', overflow = '',
|
var j, data, rsvp = false, mystatus = null, line, morelink, html = '', overflow = '',
|
||||||
organizer = is_organizer(rec);
|
organizer = me.is_organizer(rec);
|
||||||
|
|
||||||
for (j=0; j < rec.attendees.length; j++) {
|
for (j=0; j < rec.attendees.length; j++) {
|
||||||
data = rec.attendees[j];
|
data = rec.attendees[j];
|
||||||
|
@ -2194,7 +2152,7 @@ function rcube_tasklist_ui(settings)
|
||||||
.html(rcmail.gettext('status' + mystatus, 'libcalendaring'));
|
.html(rcmail.gettext('status' + mystatus, 'libcalendaring'));
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
var show_rsvp = !temp && rsvp && list.editable && !is_organizer(rec) && rec.status != 'CANCELLED';
|
var show_rsvp = !temp && rsvp && list.editable && !me.is_organizer(rec) && rec.status != 'CANCELLED';
|
||||||
$('#task-rsvp')[(show_rsvp ? 'show' : 'hide')]();
|
$('#task-rsvp')[(show_rsvp ? 'show' : 'hide')]();
|
||||||
$('#task-rsvp .rsvp-buttons input').prop('disabled', false).filter('input[rel='+mystatus+']').prop('disabled', true);
|
$('#task-rsvp .rsvp-buttons input').prop('disabled', false).filter('input[rel='+mystatus+']').prop('disabled', true);
|
||||||
|
|
||||||
|
@ -2221,7 +2179,7 @@ function rcube_tasklist_ui(settings)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (has_permission(list, 'td') && !rec.readonly) {
|
if (me.has_permission(list, 'td') && !rec.readonly) {
|
||||||
buttons.push({
|
buttons.push({
|
||||||
text: rcmail.gettext('delete','tasklist'),
|
text: rcmail.gettext('delete','tasklist'),
|
||||||
'class': 'delete',
|
'class': 'delete',
|
||||||
|
@ -2456,7 +2414,7 @@ function rcube_tasklist_ui(settings)
|
||||||
list = rec.list && me.tasklists[rec.list] ? me.tasklists[rec.list] :
|
list = rec.list && me.tasklists[rec.list] ? me.tasklists[rec.list] :
|
||||||
(me.selected_list ? me.tasklists[me.selected_list] : { editable: action == 'new', rights: action == 'new' ? 'rwitd' : 'r' });
|
(me.selected_list ? me.tasklists[me.selected_list] : { editable: action == 'new', rights: action == 'new' ? 'rwitd' : 'r' });
|
||||||
|
|
||||||
if (rcmail.busy || !has_permission(list, 'i') || (action == 'edit' && (!rec || rec.readonly)))
|
if (rcmail.busy || !me.has_permission(list, 'i') || (action == 'edit' && (!rec || rec.readonly)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
me.selected_task = $.extend({ valarms:[] }, rec); // clone task object
|
me.selected_task = $.extend({ valarms:[] }, rec); // clone task object
|
||||||
|
@ -2488,12 +2446,12 @@ function rcube_tasklist_ui(settings)
|
||||||
var comment = $('#edit-attendees-comment');
|
var comment = $('#edit-attendees-comment');
|
||||||
|
|
||||||
invite.checked = settings.itip_notify & 1 > 0;
|
invite.checked = settings.itip_notify & 1 > 0;
|
||||||
notify.checked = has_attendees(rec) && invite.checked;
|
notify.checked = me.has_attendees(rec) && invite.checked;
|
||||||
|
|
||||||
// set tasklist selection according to permissions
|
// set tasklist selection according to permissions
|
||||||
tasklist.find('option').each(function(i, opt) {
|
tasklist.find('option').each(function(i, opt) {
|
||||||
var l = me.tasklists[opt.value] || {},
|
var l = me.tasklists[opt.value] || {},
|
||||||
writable = l.editable || (action == 'new' && has_permission(l, 'i'));
|
writable = l.editable || (action == 'new' && me.has_permission(l, 'i'));
|
||||||
$(opt).prop('disabled', !writable);
|
$(opt).prop('disabled', !writable);
|
||||||
|
|
||||||
if (!selected_list && writable)
|
if (!selected_list && writable)
|
||||||
|
@ -2536,13 +2494,13 @@ function rcube_tasklist_ui(settings)
|
||||||
me.set_recurrence_edit(rec);
|
me.set_recurrence_edit(rec);
|
||||||
|
|
||||||
// init attendees tab
|
// init attendees tab
|
||||||
var organizer = !rec.attendees || is_organizer(rec),
|
var organizer = !rec.attendees || me.is_organizer(rec),
|
||||||
allow_invitations = organizer || (rec.owner && rec.owner == 'anonymous') || settings.invite_shared;
|
allow_invitations = organizer || (rec.owner && rec.owner == 'anonymous') || settings.invite_shared;
|
||||||
|
|
||||||
task_attendees = [];
|
task_attendees = [];
|
||||||
attendees_list = $('#edit-attendees-table > tbody').html('');
|
attendees_list = $('#edit-attendees-table > tbody').html('');
|
||||||
$('#edit-attendees-notify')[(allow_invitations && has_attendees(rec) && (settings.itip_notify & 2) ? 'show' : 'hide')]();
|
$('#edit-attendees-notify')[(allow_invitations && me.has_attendees(rec) && (settings.itip_notify & 2) ? 'show' : 'hide')]();
|
||||||
$('#edit-localchanges-warning')[(has_attendees(rec) && !(allow_invitations || (rec.owner && is_organizer(rec, rec.owner))) ? 'show' : 'hide')]();
|
$('#edit-localchanges-warning')[(me.has_attendees(rec) && !(allow_invitations || (rec.owner && me.is_organizer(rec, rec.owner))) ? 'show' : 'hide')]();
|
||||||
|
|
||||||
// attendees (aka assignees)
|
// attendees (aka assignees)
|
||||||
if (list.attendees) {
|
if (list.attendees) {
|
||||||
|
@ -2697,7 +2655,7 @@ function rcube_tasklist_ui(settings)
|
||||||
}
|
}
|
||||||
|
|
||||||
// tell server to send notifications
|
// tell server to send notifications
|
||||||
if ((has_attendees(data) || (rec.id && has_attendees(rec))) && allow_invitations && (notify.checked || invite.checked || need_invitation)) {
|
if ((me.has_attendees(data) || (rec.id && me.has_attendees(rec))) && allow_invitations && (notify.checked || invite.checked || need_invitation)) {
|
||||||
data._notify = settings.itip_notify;
|
data._notify = settings.itip_notify;
|
||||||
data._comment = comment.val();
|
data._comment = comment.val();
|
||||||
}
|
}
|
||||||
|
@ -2935,13 +2893,13 @@ function rcube_tasklist_ui(settings)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_attendee(rec)) {
|
if (me.is_attendee(rec)) {
|
||||||
html += '<div class="task-dialog-message">' +
|
html += '<div class="task-dialog-message">' +
|
||||||
'<label><input class="confirm-attendees-decline" type="checkbox" checked="checked" value="1" name="_decline" /> ' +
|
'<label><input class="confirm-attendees-decline" type="checkbox" checked="checked" value="1" name="_decline" /> ' +
|
||||||
rcmail.gettext('itipdeclinetask', 'tasklist') +
|
rcmail.gettext('itipdeclinetask', 'tasklist') +
|
||||||
'</label></div>';
|
'</label></div>';
|
||||||
}
|
}
|
||||||
else if (has_attendees(rec) && is_organizer(rec)) {
|
else if (me.has_attendees(rec) && me.is_organizer(rec)) {
|
||||||
html += '<div class="task-dialog-message">' +
|
html += '<div class="task-dialog-message">' +
|
||||||
'<label><input class="confirm-attendees-notify" type="checkbox" checked="checked" value="1" name="_notify" /> ' +
|
'<label><input class="confirm-attendees-notify" type="checkbox" checked="checked" value="1" name="_notify" /> ' +
|
||||||
rcmail.gettext('sendcancellation', 'tasklist') +
|
rcmail.gettext('sendcancellation', 'tasklist') +
|
||||||
|
@ -3107,7 +3065,7 @@ function rcube_tasklist_ui(settings)
|
||||||
editform = $('#tasklisteditform');
|
editform = $('#tasklisteditform');
|
||||||
me.dialog_resize(rcmail.gui_containers.tasklistform, editform.height(), editform.width());
|
me.dialog_resize(rcmail.gui_containers.tasklistform, editform.height(), editform.width());
|
||||||
|
|
||||||
name = $('#taskedit-tasklistame').prop('disabled', !has_permission(list, 'a')||list.norename).val(list.editname || list.name);
|
name = $('#taskedit-tasklistame').prop('disabled', !me.has_permission(list, 'a')||list.norename).val(list.editname || list.name);
|
||||||
alarms = $('#taskedit-showalarms').prop('checked', list.showalarms).get(0);
|
alarms = $('#taskedit-showalarms').prop('checked', list.showalarms).get(0);
|
||||||
name.select();
|
name.select();
|
||||||
|
|
||||||
|
@ -3427,13 +3385,6 @@ function rcube_tasklist_ui(settings)
|
||||||
return active;
|
return active;
|
||||||
}
|
}
|
||||||
|
|
||||||
// resize and reposition (center) the dialog window
|
|
||||||
this.dialog_resize = function(id, height, width)
|
|
||||||
{
|
|
||||||
var win = $(window), w = win.width(), h = win.height();
|
|
||||||
$(id).dialog('option', { height: Math.min(h-20, height+130), width: Math.min(w-20, width+50) });
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable/disable focusview mode for the given list
|
* Enable/disable focusview mode for the given list
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Reference in a new issue