Bug 1432142 - Move acl related functions into calACLUtils.jsm - automatic changes. r=MakeMyDay
MozReview-Commit-ID: GfoM7HtJvQc --HG-- extra : rebase_source : 9a97203be29cd62d847be8186b727563eeb762f5
This commit is contained in:
Родитель
b9a338cf60
Коммит
a45f3490b7
|
@ -18,13 +18,13 @@ Components.utils.import("resource://calendar/modules/calUtils.jsm");
|
|||
function canPaste() {
|
||||
if (Preferences.get("calendar.paste.intoSelectedCalendar", false)) {
|
||||
let selectedCal = getSelectedCalendar();
|
||||
if (!selectedCal || !cal.isCalendarWritable(selectedCal)) {
|
||||
if (!selectedCal || !cal.acl.isCalendarWritable(selectedCal)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
let calendars = cal.getCalendarManager().getCalendars({})
|
||||
.filter(cal.isCalendarWritable)
|
||||
.filter(cal.userCanAddItemsToCalendar);
|
||||
.filter(cal.acl.isCalendarWritable)
|
||||
.filter(cal.acl.userCanAddItemsToCalendar);
|
||||
if (!calendars.length) {
|
||||
return false;
|
||||
}
|
||||
|
@ -142,8 +142,8 @@ function pasteFromClipboard() {
|
|||
destCal = getSelectedCalendar();
|
||||
} else {
|
||||
let calendars = cal.getCalendarManager().getCalendars({})
|
||||
.filter(cal.isCalendarWritable)
|
||||
.filter(cal.userCanAddItemsToCalendar);
|
||||
.filter(cal.acl.isCalendarWritable)
|
||||
.filter(cal.acl.userCanAddItemsToCalendar);
|
||||
if (calendars.length > 1) {
|
||||
let args = {};
|
||||
args.calendars = calendars;
|
||||
|
|
|
@ -522,7 +522,7 @@ var calendarController = {
|
|||
* calendar.
|
||||
*/
|
||||
get writable() {
|
||||
return cal.getCalendarManager().getCalendars({}).some(cal.isCalendarWritable);
|
||||
return cal.getCalendarManager().getCalendars({}).some(cal.acl.isCalendarWritable);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -588,7 +588,7 @@ var calendarController = {
|
|||
let calendars = cal.getCalendarManager().getCalendars({});
|
||||
let count = calendars.length;
|
||||
for (let calendar of calendars) {
|
||||
if (!cal.isCalendarWritable(calendar)) {
|
||||
if (!cal.acl.isCalendarWritable(calendar)) {
|
||||
count--;
|
||||
}
|
||||
}
|
||||
|
@ -642,7 +642,7 @@ var calendarController = {
|
|||
get todo_items_writable() {
|
||||
let selectedTasks = getSelectedTasks();
|
||||
for (let task of selectedTasks) {
|
||||
if (cal.isCalendarWritable(task.calendar)) {
|
||||
if (cal.acl.isCalendarWritable(task.calendar)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -910,7 +910,7 @@ function calendarUpdateNewItemsCommand() {
|
|||
// re-calculate command status
|
||||
CalendarNewEventsCommandEnabled = false;
|
||||
CalendarNewTasksCommandEnabled = false;
|
||||
let calendars = cal.getCalendarManager().getCalendars({}).filter(cal.isCalendarWritable).filter(cal.userCanAddItemsToCalendar);
|
||||
let calendars = cal.getCalendarManager().getCalendars({}).filter(cal.acl.isCalendarWritable).filter(cal.acl.userCanAddItemsToCalendar);
|
||||
if (calendars.some(cal.isEventCalendar)) {
|
||||
CalendarNewEventsCommandEnabled = true;
|
||||
}
|
||||
|
@ -933,7 +933,7 @@ function calendarUpdateDeleteCommand(selectedItems) {
|
|||
|
||||
/* we must disable "delete" when at least one item cannot be deleted */
|
||||
for (let item of selectedItems) {
|
||||
if (!cal.userCanDeleteItemsFromCalendar(item.calendar)) {
|
||||
if (!cal.acl.userCanDeleteItemsFromCalendar(item.calendar)) {
|
||||
CalendarDeleteCommandEnabled = false;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -191,7 +191,7 @@ InvitationsManager.prototype = {
|
|||
};
|
||||
|
||||
for (let calendar of cals) {
|
||||
if (!cal.isCalendarWritable(calendar) || calendar.getProperty("disabled")) {
|
||||
if (!cal.acl.isCalendarWritable(calendar) || calendar.getProperty("disabled")) {
|
||||
opListener.onOperationComplete();
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -390,7 +390,7 @@ function openEventDialog(calendarItem, calendar, mode, callback, job=null, initi
|
|||
mode = mode || "new";
|
||||
calendar = calendar || getSelectedCalendar();
|
||||
let calendars = cal.getCalendarManager().getCalendars({});
|
||||
calendars = calendars.filter(cal.isCalendarWritable);
|
||||
calendars = calendars.filter(cal.acl.isCalendarWritable);
|
||||
|
||||
let isItemSupported;
|
||||
if (cal.isToDo(calendarItem)) {
|
||||
|
@ -408,7 +408,7 @@ function openEventDialog(calendarItem, calendar, mode, callback, job=null, initi
|
|||
|
||||
// Filter out calendar/items that we cannot write to/modify
|
||||
if (mode == "new") {
|
||||
calendars = calendars.filter(cal.userCanAddItemsToCalendar);
|
||||
calendars = calendars.filter(cal.acl.userCanAddItemsToCalendar);
|
||||
} else { /* modify */
|
||||
calendars = calendars.filter((aCalendar) => {
|
||||
/* If the calendar is the item calendar, we check that the item
|
||||
|
@ -417,17 +417,17 @@ function openEventDialog(calendarItem, calendar, mode, callback, job=null, initi
|
|||
* add items to the current one.
|
||||
*/
|
||||
let isSameCalendar = calendarItem.calendar == aCalendar;
|
||||
let canModify = cal.userCanModifyItem(calendarItem);
|
||||
let canMoveItems = cal.userCanDeleteItemsFromCalendar(calendarItem.calendar) &&
|
||||
cal.userCanAddItemsToCalendar(aCalendar);
|
||||
let canModify = cal.acl.userCanModifyItem(calendarItem);
|
||||
let canMoveItems = cal.acl.userCanDeleteItemsFromCalendar(calendarItem.calendar) &&
|
||||
cal.acl.userCanAddItemsToCalendar(aCalendar);
|
||||
|
||||
return isSameCalendar ? canModify : canMoveItems;
|
||||
});
|
||||
}
|
||||
|
||||
if (mode == "new" &&
|
||||
(!cal.isCalendarWritable(calendar) ||
|
||||
!cal.userCanAddItemsToCalendar(calendar) ||
|
||||
(!cal.acl.isCalendarWritable(calendar) ||
|
||||
!cal.acl.userCanAddItemsToCalendar(calendar) ||
|
||||
!isItemSupported(calendar))) {
|
||||
if (calendars.length < 1) {
|
||||
// There are no writable calendars or no calendar supports the given
|
||||
|
@ -477,8 +477,8 @@ function openEventDialog(calendarItem, calendar, mode, callback, job=null, initi
|
|||
|
||||
// open the dialog modeless
|
||||
let url;
|
||||
let isEditable = mode == "modify" && !isInvitation && cal.userCanModifyItem(calendarItem);
|
||||
if (cal.isCalendarWritable(calendar) && (mode == "new" || isEditable)) {
|
||||
let isEditable = mode == "modify" && !isInvitation && cal.acl.userCanModifyItem(calendarItem);
|
||||
if (cal.acl.isCalendarWritable(calendar) && (mode == "new" || isEditable)) {
|
||||
if (args.inTab) {
|
||||
url = args.useNewItemUI ? "chrome://lightning/content/html-item-editing/lightning-item-iframe.html"
|
||||
: "chrome://lightning/content/lightning-item-iframe.xul";
|
||||
|
|
|
@ -1799,8 +1799,8 @@
|
|||
<parameter name="aMouseY"/>
|
||||
<parameter name="aSnapInt"/>
|
||||
<body><![CDATA[
|
||||
if (!cal.isCalendarWritable(aOccurrence.calendar) ||
|
||||
!cal.userCanModifyItem(aOccurrence) ||
|
||||
if (!cal.acl.isCalendarWritable(aOccurrence.calendar) ||
|
||||
!cal.acl.userCanModifyItem(aOccurrence) ||
|
||||
(aOccurrence.calendar instanceof Components.interfaces.calISchedulingSupport && aOccurrence.calendar.isInvitation(aOccurrence)) ||
|
||||
aOccurrence.calendar.getProperty("capabilities.events.supported") === false) {
|
||||
return;
|
||||
|
@ -2047,7 +2047,7 @@
|
|||
|
||||
// If the selected calendar is readOnly, we don't want any sweeping.
|
||||
let calendar = getSelectedCalendar();
|
||||
if (!cal.isCalendarWritable(calendar) ||
|
||||
if (!cal.acl.isCalendarWritable(calendar) ||
|
||||
calendar.getProperty("capabilities.events.supported") === false) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ var taskEdit = {
|
|||
taskEdit.setupTaskField(edit,
|
||||
true,
|
||||
cal.calGetString("calendar", "taskEditInstructionsCapability"));
|
||||
} else if (cal.isCalendarWritable(calendar)) {
|
||||
} else if (cal.acl.isCalendarWritable(calendar)) {
|
||||
edit.showsInstructions = false;
|
||||
taskEdit.setupTaskField(edit, false, edit.savedValue || "");
|
||||
} else {
|
||||
|
@ -108,7 +108,7 @@ var taskEdit = {
|
|||
taskEdit.setupTaskField(edit,
|
||||
true,
|
||||
cal.calGetString("calendar", "taskEditInstructionsCapability"));
|
||||
} else if (cal.isCalendarWritable(calendar)) {
|
||||
} else if (cal.acl.isCalendarWritable(calendar)) {
|
||||
if (!edit.showsInstructions) {
|
||||
edit.savedValue = edit.value || "";
|
||||
}
|
||||
|
|
|
@ -292,9 +292,9 @@ function appendCalendarItems(aItem, aCalendarMenuParent, aCalendarToUse, aOnComm
|
|||
let calendar = calendars[i];
|
||||
if (calendar.id == calendarToUse.id ||
|
||||
(calendar &&
|
||||
cal.isCalendarWritable(calendar) &&
|
||||
(cal.userCanAddItemsToCalendar(calendar) ||
|
||||
(calendar == aItem.calendar && cal.userCanModifyItem(aItem))) &&
|
||||
cal.acl.isCalendarWritable(calendar) &&
|
||||
(cal.acl.userCanAddItemsToCalendar(calendar) ||
|
||||
(calendar == aItem.calendar && cal.acl.userCanModifyItem(aItem))) &&
|
||||
cal.isItemSupported(aItem, calendar))) {
|
||||
let menuitem = addMenuItem(aCalendarMenuParent, calendar.name, calendar.name);
|
||||
menuitem.calendar = calendar;
|
||||
|
|
|
@ -237,7 +237,7 @@
|
|||
if (cal.isInvitation(item)) {
|
||||
this.setAttribute("invitation-status", cal.getInvitedAttendee(item).participationStatus);
|
||||
this.setAttribute("readonly", "true");
|
||||
} else if (!cal.isCalendarWritable(item.calendar)) {
|
||||
} else if (!cal.acl.isCalendarWritable(item.calendar)) {
|
||||
this.setAttribute("readonly", "true");
|
||||
}
|
||||
]]></body>
|
||||
|
@ -321,7 +321,7 @@
|
|||
// Also, check if the calendar is readOnly or we are offline.
|
||||
|
||||
if (this.selected && !(event.ctrlKey || event.metaKey) &&
|
||||
cal.isCalendarWritable(this.mOccurrence.calendar)) {
|
||||
cal.acl.isCalendarWritable(this.mOccurrence.calendar)) {
|
||||
if (this.editingTimer) {
|
||||
clearTimeout(this.editingTimer);
|
||||
}
|
||||
|
@ -358,7 +358,7 @@
|
|||
}
|
||||
let item = this.occurrence;
|
||||
let isInvitation = item.calendar instanceof Components.interfaces.calISchedulingSupport && item.calendar.isInvitation(item);
|
||||
if (!cal.isCalendarWritable(item.calendar) || !cal.userCanModifyItem(item) || isInvitation) {
|
||||
if (!cal.acl.isCalendarWritable(item.calendar) || !cal.acl.userCanModifyItem(item) || isInvitation) {
|
||||
return;
|
||||
}
|
||||
if (!this.selected) {
|
||||
|
|
|
@ -120,7 +120,7 @@ var calendarViewController = {
|
|||
// it, filter out any items that have readonly calendars, so that
|
||||
// checking for one total item below also works out if all but one item
|
||||
// are readonly.
|
||||
let occurrences = aOccurrences.filter(item => cal.isCalendarWritable(item.calendar));
|
||||
let occurrences = aOccurrences.filter(item => cal.acl.isCalendarWritable(item.calendar));
|
||||
|
||||
for (let itemToDelete of occurrences) {
|
||||
if (aUseParentItems) {
|
||||
|
|
|
@ -176,8 +176,8 @@ function snoozeAllItems(aDurationMinutes) {
|
|||
for (let node of alarmRichlist.childNodes) {
|
||||
// Check if the node is a valid alarm and is still part of DOM
|
||||
if (node.parentNode && node.item && node.alarm &&
|
||||
cal.isCalendarWritable(node.item.calendar) &&
|
||||
cal.userCanModifyItem(node.item) &&
|
||||
cal.acl.isCalendarWritable(node.item.calendar) &&
|
||||
cal.acl.userCanModifyItem(node.item) &&
|
||||
!(node.item.parentItem.hashId in parentItems)) {
|
||||
// We only need to acknowledge one occurrence for repeating items
|
||||
parentItems[node.item.parentItem.hashId] = node.item.parentItem;
|
||||
|
@ -346,8 +346,8 @@ function doReadOnlyChecks() {
|
|||
let countRO = 0;
|
||||
let alarmRichlist = document.getElementById("alarm-richlist");
|
||||
for (let node of alarmRichlist.childNodes) {
|
||||
if (!cal.isCalendarWritable(node.item.calendar) ||
|
||||
!cal.userCanModifyItem(node.item)) {
|
||||
if (!cal.acl.isCalendarWritable(node.item.calendar) ||
|
||||
!cal.acl.userCanModifyItem(node.item)) {
|
||||
countRO++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,8 +52,8 @@ function onLoad() {
|
|||
window.attendees = item.getAttendees({});
|
||||
|
||||
let calendar = cal.wrapInstance(item.calendar, Components.interfaces.calISchedulingSupport);
|
||||
window.readOnly = !(cal.isCalendarWritable(calendar) &&
|
||||
(cal.userCanModifyItem(item) ||
|
||||
window.readOnly = !(cal.acl.isCalendarWritable(calendar) &&
|
||||
(cal.acl.userCanModifyItem(item) ||
|
||||
(calendar &&
|
||||
item.calendar.isInvitation(item) &&
|
||||
cal.userCanRespondToInvitation(item))));
|
||||
|
|
|
@ -111,7 +111,7 @@ function loadEventsFromFile(aCalendar) {
|
|||
}
|
||||
|
||||
let calendars = cal.getCalendarManager().getCalendars({});
|
||||
calendars = calendars.filter(cal.isCalendarWritable);
|
||||
calendars = calendars.filter(cal.acl.isCalendarWritable);
|
||||
|
||||
if (calendars.length == 1) {
|
||||
// There's only one calendar, so it's silly to ask what calendar
|
||||
|
|
|
@ -120,8 +120,8 @@
|
|||
"anonid",
|
||||
"alarm-snooze-button"
|
||||
);
|
||||
if (!cal.isCalendarWritable(this.mItem.calendar) ||
|
||||
!cal.userCanModifyItem(this.mItem)) {
|
||||
if (!cal.acl.isCalendarWritable(this.mItem.calendar) ||
|
||||
!cal.acl.userCanModifyItem(this.mItem)) {
|
||||
let tooltip = "reminderDisabledSnoozeButtonTooltip";
|
||||
snoozeButton.disabled = true;
|
||||
snoozeButton.setAttribute("tooltiptext",
|
||||
|
|
|
@ -142,7 +142,7 @@ cal.itip = {
|
|||
* @return True, if its a scheduling calendar.
|
||||
*/
|
||||
isSchedulingCalendar: function(calendar) {
|
||||
return cal.isCalendarWritable(calendar) &&
|
||||
return cal.acl.isCalendarWritable(calendar) &&
|
||||
calendar.getProperty("organizerId") &&
|
||||
calendar.getProperty("itip.transport");
|
||||
},
|
||||
|
@ -181,7 +181,7 @@ cal.itip = {
|
|||
let isWritableCalendar = function(aCalendar) {
|
||||
/* TODO: missing ACL check for existing items (require callback API) */
|
||||
return cal.itip.isSchedulingCalendar(aCalendar) &&
|
||||
cal.userCanAddItemsToCalendar(aCalendar);
|
||||
cal.acl.userCanAddItemsToCalendar(aCalendar);
|
||||
};
|
||||
|
||||
let writableCalendars = cal.getCalendarManager().getCalendars({}).filter(isWritableCalendar);
|
||||
|
|
|
@ -182,8 +182,8 @@ calAlarmService.prototype = {
|
|||
|
||||
dismissAlarm: function(aItem, aAlarm) {
|
||||
let rv;
|
||||
if (cal.isCalendarWritable(aItem.calendar) &&
|
||||
cal.userCanModifyItem(aItem)) {
|
||||
if (cal.acl.isCalendarWritable(aItem.calendar) &&
|
||||
cal.acl.userCanModifyItem(aItem)) {
|
||||
let now = nowUTC();
|
||||
// We want the parent item, otherwise we're going to accidentally
|
||||
// create an exception. We've relnoted (for 0.1) the slightly odd
|
||||
|
@ -383,8 +383,8 @@ calAlarmService.prototype = {
|
|||
|
||||
this.addTimer(aItem, alarm, timeout);
|
||||
} else if (showMissed &&
|
||||
cal.isCalendarWritable(aItem.calendar) &&
|
||||
cal.userCanModifyItem(aItem)) {
|
||||
cal.acl.isCalendarWritable(aItem.calendar) &&
|
||||
cal.acl.userCanModifyItem(aItem)) {
|
||||
// This alarm is in the past and the calendar is writable, so we
|
||||
// could snooze or dismiss alarms. See if it has been previously
|
||||
// ack'd.
|
||||
|
|
|
@ -50,8 +50,8 @@ calTransactionManager.prototype = {
|
|||
checkWritable: function(transaction) {
|
||||
function checkItem(item) {
|
||||
return item && item.calendar &&
|
||||
cal.isCalendarWritable(item.calendar) &&
|
||||
cal.userCanAddItemsToCalendar(item.calendar);
|
||||
cal.acl.isCalendarWritable(item.calendar) &&
|
||||
cal.acl.userCanAddItemsToCalendar(item.calendar);
|
||||
}
|
||||
|
||||
let trans = transaction && transaction.wrappedJSObject;
|
||||
|
|
|
@ -569,9 +569,9 @@ function loadDialog(aItem) {
|
|||
let calendarList = unfilteredList.filter((calendar) =>
|
||||
(calendar.id == calendarToUse.id ||
|
||||
(calendar &&
|
||||
cal.isCalendarWritable(calendar) &&
|
||||
(cal.userCanAddItemsToCalendar(calendar) ||
|
||||
(calendar == aItem.calendar && cal.userCanModifyItem(aItem))) &&
|
||||
cal.acl.isCalendarWritable(calendar) &&
|
||||
(cal.acl.userCanAddItemsToCalendar(calendar) ||
|
||||
(calendar == aItem.calendar && cal.acl.userCanModifyItem(aItem))) &&
|
||||
cal.isItemSupported(aItem, calendar))));
|
||||
|
||||
itemProps.calendarList = calendarList.map(calendar => [calendar.id, calendar.name]);
|
||||
|
|
Загрузка…
Ссылка в новой задаче