42
43
object factory = get_factory(CLASS_LINK);
43
44
object link, calendar, ulink;
45
47
DEBUG_CALENDAR("Creating links for date %O", date);
46
48
foreach(creator->get_members(), object member) {
47
DEBUG_CALENDAR("Link created for %O", member);
48
calendar = member->query_attribute(USER_CALENDAR);
49
link = factory->execute(([ "name": date->get_identifier(),
50
"attributes": date->query_attributes(),
51
"link_to": date, ]) );
49
if ( member->get_object_class() & CLASS_USER )
50
calendar = member->query_attribute(USER_CALENDAR);
51
else if ( member->get_object_class() & CLASS_GROUP )
52
calendar = member->query_attribute(GROUP_CALENDAR);
54
DEBUG_CALENDAR("Checking link for %O", member);
55
if ( !objectp(calendar) ) {
56
werror( "Calendar: invalid calendar of member %O\n", member );
59
if ( search( haves, calendar ) < 0 ) {
60
DEBUG_CALENDAR("Creating link for %O", member);
61
link = factory->execute(([ "name": date->get_identifier(),
62
"attributes": date->query_attributes(),
63
"link_to": date, ]) );
64
if ( link->move(calendar) ) haves += ({ calendar });
55
68
foreach(groups, object grp) {
56
69
calendar = grp->query_attribute(GROUP_CALENDAR);
57
link = factory->execute(([ "name": date->get_identifier(),
58
"attributes": date->query_attributes(),
59
"link_to": date, ]) );
70
if ( search( haves, calendar ) < 0 ) {
71
DEBUG_CALENDAR("Creating link for group %O", grp);
72
link = factory->execute(([ "name": date->get_identifier(),
73
"attributes": date->query_attributes(),
74
"link_to": date, ]) );
75
if ( link->move(calendar) ) haves += ({ calendar });
61
77
foreach(grp->get_members(), object member) {
62
if ( creator->is_member(member) )
63
continue; // they have original date!
64
calendar = member->query_attribute(USER_CALENDAR);
65
ulink = factory->execute(([ "name": date->get_identifier(),
66
"attributes": date->query_attributes(),
67
"link_to": link, ]) );
68
ulink->move(calendar);
78
if ( member->get_object_class() & CLASS_USER )
79
calendar = member->query_attribute(USER_CALENDAR);
80
else if ( member->get_object_class() & CLASS_GROUP )
81
calendar = member->query_attribute(GROUP_CALENDAR);
83
if ( !objectp(calendar) ) {
84
werror( "Calendar: invalid calendar of member %O\n", member );
87
if ( search( haves, calendar ) < 0 ) {
88
DEBUG_CALENDAR("Creating sub link for group member %O", member);
89
ulink = factory->execute(([ "name": date->get_identifier(),
90
"attributes": date->query_attributes(),
91
"link_to": link, ]) );
92
if ( ulink->move(calendar) ) haves += ({ calendar });
99
object filter_datelinks(object link)
101
object linkobj = link->get_link_object();
102
if ( !objectp(linkobj) ) return 0;
104
if ( linkobj->get_object_class() & CLASS_DATE )
124
object filter_datelinks ( object link ) {
125
object linkobj = link;
127
if ( !objectp(linkobj) ) return UNDEFINED;
128
if ( linkobj->get_object_class() & CLASS_LINK )
129
linkobj = linkobj->get_link_object();
130
else if ( linkobj->get_object_class() & CLASS_DATE )
132
else return UNDEFINED;
136
array get_all_entries_day ( void|int offset, void|int type )
138
object start = Calendar.Day() + offset;
139
object end = start + offset + 1;
140
return get_all_entries( start->unix_time(), end->unix_time()-1, type );
143
array get_all_entries_week ( void|int offset, void|int type )
145
object start = Calendar.Week() + offset;
146
object end = start + offset + 1;
147
return get_all_entries( start->unix_time(), end->unix_time()-1, type );
150
array get_all_entries_month ( void|int offset, void|int type )
152
object start = Calendar.Month() + offset;
153
object end = start + offset + 1;
154
return get_all_entries( start->unix_time(), end->unix_time()-1, type );
157
array get_all_entries_year ( void|int offset, void|int type )
159
object start = Calendar.Year() + offset;
160
object end = start + offset + 1;
161
return get_all_entries( start->unix_time(), end->unix_time()-1, type );
109
164
array get_all_entries(void|int start, void|int end, void|int type)
111
array dates = get_inventory_by_class(CLASS_DATE);
112
array dlinks = get_inventory_by_class(CLASS_LINK);
113
dlinks = filter(dlinks, filter_datelinks);
169
array dates = get_inventory_by_class( CLASS_DATE );
170
array dlinks = get_inventory_by_class( CLASS_LINK );
171
dlinks = filter( dlinks, filter_datelinks );
114
172
if ( start > 0 ) {
115
173
array matches = ({ });
116
174
foreach(dates, object date) {
117
if ( date->match(start, end) )
175
err = catch( result = date->match(start, end) );
177
FATAL("While getting entries: %s\n%O", err[0], err[1]);
118
180
matches += ({ date });
120
182
foreach(dlinks, object link) {
121
object linkobj = link->get_link_object();
122
if ( linkobj->match(start, end) )
183
object linkobj = filter_datelinks( link );
184
err = catch( result = linkobj->match(start, end) );
186
FATAL("While getting entries: %s\n%O", err[0], err[1]);
123
189
matches += ({ link });
125
191
if ( intp(type) && type > 0 ) {