mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-07-08 01:45:08 +00:00
Monotone-Parent: 3539ecd8be9d6a343ed36dd75849ea9713497066
Monotone-Revision: 1b12beb00e557f3ecfec3bb87a586b501981fced Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2006-12-19T17:06:07 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
@@ -12,11 +12,13 @@
|
||||
a SOPE clientObject (which usually is an SOGoAppointmentFolder).
|
||||
*/
|
||||
|
||||
@class NSString, NSArray, NSDictionary, NSCalendarDate, SOGoAptFormatter;
|
||||
@class NSString, NSArray, NSDictionary, NSMutableDictionary, NSCalendarDate, SOGoAptFormatter;
|
||||
@class SOGoAppointmentFolder;
|
||||
|
||||
@interface UIxCalView : UIxComponent
|
||||
{
|
||||
NSArray *appointments;
|
||||
NSMutableDictionary *componentsData;
|
||||
NSArray *tasks;
|
||||
NSArray *allDayApts;
|
||||
id appointment;
|
||||
@@ -100,6 +102,7 @@
|
||||
/* calendarUIDs */
|
||||
|
||||
- (NSString *)formattedCalendarUIDs;
|
||||
- (SOGoAppointmentFolder *) calendarFolderForUID: (NSString *) uid;
|
||||
|
||||
/* CSS related */
|
||||
|
||||
|
||||
@@ -1,15 +1,22 @@
|
||||
// $Id: UIxCalView.m 885 2005-07-21 16:41:34Z znek $
|
||||
|
||||
#import "UIxCalView.h"
|
||||
#import "common.h"
|
||||
//#import <OGoContentStore/OCSFolder.h>
|
||||
#import "SoObjects/Appointments/SOGoAppointmentFolder.h"
|
||||
|
||||
#import <NGObjWeb/SoSecurityManager.h>
|
||||
#import <NGObjWeb/SoUser.h>
|
||||
#import <SOGoUI/SOGoAptFormatter.h>
|
||||
#import <NGExtensions/NGCalendarDateRange.h>
|
||||
#import <NGCards/NGCards.h>
|
||||
|
||||
#import <SOGoUI/SOGoAptFormatter.h>
|
||||
#import "UIxComponent+Agenor.h"
|
||||
|
||||
#import "SoObjects/Appointments/SOGoAppointmentFolder.h"
|
||||
#import <SOGo/SOGoUser.h>
|
||||
#import <SOGo/SOGoObject.h>
|
||||
|
||||
#import "UIxCalView.h"
|
||||
|
||||
@interface UIxCalView (PrivateAPI)
|
||||
- (NSString *) _userFolderURI;
|
||||
@end
|
||||
@@ -47,12 +54,14 @@ static BOOL shouldDisplayWeekend = NO;
|
||||
privateAptTooltipFormatter
|
||||
= [[SOGoAptFormatter alloc] initWithDisplayTimeZone: tz];
|
||||
[self configureFormatters];
|
||||
componentsData = [NSMutableDictionary new];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
[componentsData release];
|
||||
[appointments release];
|
||||
[allDayApts release];
|
||||
[appointment release];
|
||||
@@ -431,11 +440,85 @@ static BOOL shouldDisplayWeekend = NO;
|
||||
return [[self startDate] tomorrow];
|
||||
}
|
||||
|
||||
- (SOGoAppointmentFolder *) calendarFolderForUID: (NSString *) uid
|
||||
{
|
||||
SOGoFolder *upperContainer;
|
||||
SOGoUserFolder *userFolder;
|
||||
SOGoAppointmentFolder *calendarFolder;
|
||||
SoSecurityManager *securityManager;
|
||||
|
||||
upperContainer = [[[self clientObject] container] container];
|
||||
userFolder = [SOGoUserFolder objectWithName: uid
|
||||
inContainer: upperContainer];
|
||||
calendarFolder = [SOGoAppointmentFolder objectWithName: @"Calendar"
|
||||
inContainer: userFolder];
|
||||
[calendarFolder
|
||||
setOCSPath: [NSString stringWithFormat: @"/Users/%@/Calendar", uid]];
|
||||
[calendarFolder setOwner: uid];
|
||||
|
||||
securityManager = [SoSecurityManager sharedSecurityManager];
|
||||
|
||||
return (([securityManager validatePermission: SoPerm_AccessContentsInformation
|
||||
onObject: calendarFolder
|
||||
inContext: context] == nil)
|
||||
? calendarFolder : nil);
|
||||
}
|
||||
|
||||
- (NSArray *) activeCalendarFolders
|
||||
{
|
||||
NSUserDefaults *ud;
|
||||
NSEnumerator *calendarUIDs;
|
||||
SOGoAppointmentFolder *currentFolder;
|
||||
NSMutableArray *folders;
|
||||
NSString *currentUID;
|
||||
|
||||
folders = [NSMutableArray array];
|
||||
ud = [[context activeUser] userDefaults];
|
||||
calendarUIDs = [[[ud stringForKey: @"calendaruids"]
|
||||
componentsSeparatedByString: @","] objectEnumerator];
|
||||
currentUID = [calendarUIDs nextObject];
|
||||
while (currentUID)
|
||||
{
|
||||
if (![currentUID hasPrefix: @"-"])
|
||||
{
|
||||
currentFolder = [self calendarFolderForUID: currentUID];
|
||||
if (currentFolder)
|
||||
[folders addObject: currentFolder];
|
||||
}
|
||||
currentUID = [calendarUIDs nextObject];
|
||||
}
|
||||
|
||||
return folders;
|
||||
}
|
||||
|
||||
- (NSArray *) _fetchCoreInfosForComponent: (NSString *) component
|
||||
{
|
||||
return [[self clientObject] fetchCoreInfosFrom: [[self startDate] beginOfDay]
|
||||
to: [[self endDate] endOfDay]
|
||||
component: component];
|
||||
NSArray *currentInfos;
|
||||
NSMutableArray *infos;
|
||||
NSEnumerator *folders;
|
||||
SOGoAppointmentFolder *currentFolder;
|
||||
|
||||
infos = [componentsData objectForKey: component];
|
||||
if (!infos)
|
||||
{
|
||||
infos = [NSMutableArray array];
|
||||
folders = [[self activeCalendarFolders] objectEnumerator];
|
||||
currentFolder = [folders nextObject];
|
||||
while (currentFolder)
|
||||
{
|
||||
currentInfos = [currentFolder fetchCoreInfosFrom: [[self startDate] beginOfDay]
|
||||
to: [[self endDate] endOfDay]
|
||||
component: component];
|
||||
[currentInfos makeObjectsPerform: @selector (setObject:forKey:)
|
||||
withObject: [currentFolder ownerInContext: nil]
|
||||
withObject: @"owner"];
|
||||
[infos addObjectsFromArray: currentInfos];
|
||||
currentFolder = [folders nextObject];
|
||||
}
|
||||
[componentsData setObject: infos forKey: component];
|
||||
}
|
||||
|
||||
return infos;
|
||||
}
|
||||
|
||||
- (NSArray *) fetchCoreAppointmentsInfos
|
||||
|
||||
@@ -597,12 +597,10 @@
|
||||
- (NSCalendarDate *) newStartDate
|
||||
{
|
||||
NSCalendarDate *newStartDate, *now;
|
||||
BOOL hmSpecified;
|
||||
int hour;
|
||||
|
||||
newStartDate = [self selectedDate];
|
||||
hmSpecified = ([[self queryParameterForKey: @"hm"] length] > 0);
|
||||
if (!hmSpecified)
|
||||
if ([[self queryParameterForKey: @"hm"] length] == 0)
|
||||
{
|
||||
now = [NSCalendarDate calendarDate];
|
||||
[now setTimeZone: [[self clientObject] userTimeZone]];
|
||||
|
||||
@@ -96,7 +96,12 @@
|
||||
updateCalendars = {
|
||||
protectedBy = "View";
|
||||
pageName = "UIxCalMainView";
|
||||
actionName = "updateCalendars";
|
||||
actionName = "updateCalendars";
|
||||
};
|
||||
checkRights = {
|
||||
protectedBy = "View";
|
||||
pageName = "UIxCalMainView";
|
||||
actionName = "checkRights";
|
||||
};
|
||||
freeBusyTable = {
|
||||
protectedBy = "View";
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
<var:component className="UIxContactSelector"
|
||||
const:selectorId="calendarsList"
|
||||
const:hasCheckBoxes="YES"
|
||||
const:checkBoxOnChange="return updateCalendarStatus(this);"
|
||||
colors="colors"
|
||||
contacts="contacts"
|
||||
checkedBoxes="checkedContacts"
|
||||
|
||||
@@ -82,6 +82,7 @@
|
||||
<var:foreach list="currentRangeOf7Days" item="currentTableDay"
|
||||
><td var:class="dayCellClasses"
|
||||
var:day="currentTableDay.shortDateString"
|
||||
const:hour="0800"
|
||||
><div class="dayContent"><span class="dayCellLabel"
|
||||
><var:string value="labelForCurrentDayCell" /></span
|
||||
><br /><var:foreach
|
||||
|
||||
@@ -56,6 +56,14 @@ UL#tasksList, UL#uixselector-calendarsList-display
|
||||
list-style-type: none;
|
||||
list-style-image: none; }
|
||||
|
||||
UL#uixselector-calendarsList-display
|
||||
{ height: 10.5em;
|
||||
margin: 0px; }
|
||||
|
||||
UL#uixselector-calendarsList-display LI.denied
|
||||
{ background: #f00;
|
||||
color: #000; }
|
||||
|
||||
UL#tasksList
|
||||
{ position: absolute;
|
||||
width: 100%;
|
||||
@@ -64,10 +72,6 @@ UL#tasksList
|
||||
right: .25em;
|
||||
bottom: .25em; }
|
||||
|
||||
UL#uixselector-calendarsList-display
|
||||
{ height: 10.5em;
|
||||
margin: 0px; }
|
||||
|
||||
UL#tasksList LI
|
||||
{ white-space: nowrap; }
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ var sortOrder = '';
|
||||
var sortKey = '';
|
||||
var listFilter = 'view_today';
|
||||
|
||||
var CalendarBaseURL = ApplicationBaseURL;
|
||||
var listOfSelection = null;
|
||||
|
||||
var hideCompletedTasks = 0;
|
||||
@@ -305,19 +304,6 @@ function tasksListCallback(http)
|
||||
log ("ajax fuckage");
|
||||
}
|
||||
|
||||
function calendarsListCallback(http)
|
||||
{
|
||||
// var div = $("calendarSelectorView");
|
||||
|
||||
if (http.readyState == 4
|
||||
&& http.status == 200) {
|
||||
// document.calendarsListAjaxRequest = null;
|
||||
// div.innerHTML = http.responseText;
|
||||
}
|
||||
else
|
||||
log ("ajax fuckage");
|
||||
}
|
||||
|
||||
function restoreCurrentDaySelection(div)
|
||||
{
|
||||
var elements = div.getElementsByTagName("a");
|
||||
@@ -375,7 +361,7 @@ function changeDateSelectorDisplay(day, keepCurrentDay)
|
||||
|
||||
function changeCalendarDisplay(time, newView)
|
||||
{
|
||||
var url = CalendarBaseURL + ((newView) ? newView : currentView);
|
||||
var url = ApplicationBaseURL + ((newView) ? newView : currentView);
|
||||
|
||||
var day = null;
|
||||
var hour = null;
|
||||
@@ -533,15 +519,15 @@ function popupCalendar(node)
|
||||
|
||||
function onAppointmentContextMenu(event, element)
|
||||
{
|
||||
var topNode = $('appointmentsList');
|
||||
var topNode = $("appointmentsList");
|
||||
// log(topNode);
|
||||
|
||||
var menu = $('appointmentsListMenu');
|
||||
var menu = $("appointmentsListMenu");
|
||||
|
||||
menu.addEventListener("hideMenu", onAppointmentContextMenuHide, false);
|
||||
onMenuClick(event, 'appointmentsListMenu');
|
||||
onMenuClick(event, "appointmentsListMenu");
|
||||
|
||||
var topNode = $('appointmentsList');
|
||||
var topNode = $("appointmentsList");
|
||||
var selectedNodes = topNode.getSelectedRows();
|
||||
topNode.menuSelectedRows = selectedNodes;
|
||||
for (var i = 0; i < selectedNodes.length; i++)
|
||||
@@ -553,7 +539,7 @@ function onAppointmentContextMenu(event, element)
|
||||
|
||||
function onAppointmentContextMenuHide(event)
|
||||
{
|
||||
var topNode = $('appointmentsList');
|
||||
var topNode = $("appointmentsList");
|
||||
|
||||
if (topNode.menuSelectedEntry) {
|
||||
deselectNode(topNode.menuSelectedEntry);
|
||||
@@ -586,7 +572,7 @@ function _loadAppointmentHref(href) {
|
||||
document.appointmentsListAjaxRequest.aborted = true;
|
||||
document.appointmentsListAjaxRequest.abort();
|
||||
}
|
||||
var url = CalendarBaseURL + href;
|
||||
var url = ApplicationBaseURL + href;
|
||||
document.appointmentsListAjaxRequest
|
||||
= triggerAjaxRequest(url, appointmentsListCallback, href);
|
||||
|
||||
@@ -598,7 +584,7 @@ function _loadTasksHref(href) {
|
||||
document.tasksListAjaxRequest.aborted = true;
|
||||
document.tasksListAjaxRequest.abort();
|
||||
}
|
||||
url = CalendarBaseURL + href;
|
||||
url = ApplicationBaseURL + href;
|
||||
|
||||
var selectedIds = $("tasksList").getSelectedNodesId();
|
||||
document.tasksListAjaxRequest
|
||||
@@ -864,13 +850,13 @@ function updateCalendarStatus()
|
||||
list.push(nodes[0].getAttribute("uid"));
|
||||
nodes[0].childNodesWithTag("input")[0].checked = true;
|
||||
}
|
||||
CalendarBaseURL = (UserFolderURL + "Groups/_custom_"
|
||||
+ list.join(",") + "/Calendar/");
|
||||
// ApplicationBaseURL = (UserFolderURL + "Groups/_custom_"
|
||||
// + list.join(",") + "/Calendar/");
|
||||
|
||||
updateCalendarsList();
|
||||
refreshAppointments();
|
||||
refreshTasks();
|
||||
changeCalendarDisplay();
|
||||
updateCalendarsList();
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -939,15 +925,20 @@ function updateCalendarsList(method)
|
||||
document.calendarsListAjaxRequest.aborted = true;
|
||||
document.calendarsListAjaxRequest.abort();
|
||||
}
|
||||
document.calendarsListAjaxRequest
|
||||
= triggerAjaxRequest(url, calendarsListCallback);
|
||||
if (method == "removal")
|
||||
updateCalendarStatus();
|
||||
var http = createHTTPClient();
|
||||
if (http) {
|
||||
http.url = url;
|
||||
http.open("GET", url, false);
|
||||
http.send("");
|
||||
|
||||
if (method == "removal")
|
||||
updateCalendarStatus();
|
||||
}
|
||||
}
|
||||
|
||||
function addContact(tag, fullContactName, contactId, contactName, contactEmail)
|
||||
{
|
||||
var uids = $('uixselector-calendarsList-uidList');
|
||||
var uids = $("uixselector-calendarsList-uidList");
|
||||
// log("addContact");
|
||||
if (contactId)
|
||||
{
|
||||
@@ -960,22 +951,22 @@ function addContact(tag, fullContactName, contactId, contactName, contactEmail)
|
||||
else
|
||||
uids.value = contactId;
|
||||
var names = $('uixselector-calendarsList-display');
|
||||
var listElems = names.childNodesWithTag("li");
|
||||
var colorDef = indexColor(listElems.length);
|
||||
names.innerHTML += ('<li onmousedown="return false;"'
|
||||
+ ' uid="' + contactId + '"'
|
||||
+ ' onclick="onRowClick(event);">'
|
||||
+ ' <span class="colorBox"'
|
||||
+ ' style="background-color: '
|
||||
+ colorDef + ';"></span>'
|
||||
+ ' <input class="checkBox" type="checkbox"'
|
||||
+ ' onchange="return updateCalendarStatus(this);"'
|
||||
+ ' />'
|
||||
+ ' <input class="checkBox" type="checkbox" />'
|
||||
+ contactName + '</li>');
|
||||
var listElems = names.childNodesWithTag("li");
|
||||
var input = listElems.childNodesWithTag("input")[0];
|
||||
input.addEventListener("change", updateCalendarStatus, false);
|
||||
|
||||
var styles = document.getElementsByTagName("style");
|
||||
styles[0].innerHTML += ('.ownerIs' + contactId + ' {'
|
||||
+ ' background-color: ' + colorDef
|
||||
+ ' background-color: '
|
||||
+ indexColor(listElems.length - 1)
|
||||
+ ' !important; }');
|
||||
}
|
||||
}
|
||||
@@ -1060,6 +1051,37 @@ function initCalendarContactsSelector() {
|
||||
inhibitMyCalendarEntry();
|
||||
updateCalendarStatus();
|
||||
selector.changeNotification = updateCalendarsList;
|
||||
|
||||
var rights;
|
||||
var http = createHTTPClient();
|
||||
if (http) {
|
||||
// log ("url: " + url);
|
||||
// TODO: add parameter to signal that we are only interested in OK
|
||||
http.url = ApplicationBaseURL + "checkRights";
|
||||
http.open("GET", http.url, false /* not async */);
|
||||
http.send("");
|
||||
if (http.status == 200
|
||||
&& http.responseText.length > 0)
|
||||
rights = http.responseText.split(",");
|
||||
}
|
||||
|
||||
var list = $("uixselector-calendarsList-display").childNodesWithTag("li");
|
||||
for (var i = 0; i < list.length; i++) {
|
||||
var input = list[i].childNodesWithTag("input")[0];
|
||||
if (rights) {
|
||||
if (rights[i] == "1") {
|
||||
input.addEventListener("change", updateCalendarStatus, false);
|
||||
list[i].removeClassName("denied");
|
||||
}
|
||||
else {
|
||||
input.checked = false;
|
||||
input.disabled = true;
|
||||
list[i].addClassName("denied");
|
||||
}
|
||||
} else {
|
||||
input.addEventListener("change", updateCalendarStatus, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function initCalendars() {
|
||||
|
||||
Reference in New Issue
Block a user