Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F117758776
delegation.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
5 KB
Referenced Files
None
Subscribers
None
delegation.js
View Options
/**
* Client scripts for the Kolab Delegation
*
* @author Aleksander Machniak <machniak@kolabsys.com>
* @author Thomas Bruederli <bruederli@kolabsys.com>
*
* @licstart The following is the entire license notice for the
* JavaScript code in this file.
*
* Copyright (C) Apheleia IT AG <contact@apheleia-it.ch>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @licend The above is the entire license notice
* for the JavaScript code in this file.
*/
window
.
rcmail
&&
rcmail
.
addEventListener
(
'init'
,
function
(
evt
)
{
if
(
rcmail
.
env
.
task
==
'mail'
||
rcmail
.
env
.
task
==
'calendar'
||
rcmail
.
env
.
task
==
'tasks'
)
{
// set delegator context for calendar/tasklist requests on invitation message
rcmail
.
addEventListener
(
'requestcalendar/event'
,
function
(
o
)
{
rcmail
.
event_delegator_request
(
o
);
})
.
addEventListener
(
'requestcalendar/mailimportitip'
,
function
(
o
)
{
rcmail
.
event_delegator_request
(
o
);
})
.
addEventListener
(
'requestcalendar/itip-status'
,
function
(
o
)
{
rcmail
.
event_delegator_request
(
o
);
})
.
addEventListener
(
'requestcalendar/itip-remove'
,
function
(
o
)
{
rcmail
.
event_delegator_request
(
o
);
})
.
addEventListener
(
'requesttasks/task'
,
function
(
o
)
{
rcmail
.
event_delegator_request
(
o
);
})
.
addEventListener
(
'requesttasks/mailimportitip'
,
function
(
o
)
{
rcmail
.
event_delegator_request
(
o
);
})
.
addEventListener
(
'requesttasks/itip-status'
,
function
(
o
)
{
rcmail
.
event_delegator_request
(
o
);
})
.
addEventListener
(
'requesttasks/itip-remove'
,
function
(
o
)
{
rcmail
.
event_delegator_request
(
o
);
});
// Calendar UI
if
(
rcmail
.
env
.
delegators
&&
window
.
rcube_calendar_ui
)
{
rcmail
.
calendar_identity_init
(
'calendar'
);
// delegator context for calendar event form
rcmail
.
addEventListener
(
'calendar-event-init'
,
function
(
o
)
{
return
rcmail
.
calendar_event_init
(
o
,
'calendar'
);
});
// change organizer identity on calendar folder change
$
(
'#edit-calendar'
).
change
(
function
()
{
rcmail
.
calendar_folder_change
(
this
);
});
}
// Tasks UI
else
if
(
rcmail
.
env
.
delegators
&&
window
.
rcube_tasklist_ui
)
{
rcmail
.
calendar_identity_init
(
'tasklist'
);
// delegator context for task form
rcmail
.
addEventListener
(
'tasklist-task-init'
,
function
(
o
)
{
return
rcmail
.
calendar_event_init
(
o
,
'tasklist'
);
});
// change organizer identity on tasks folder change
$
(
'#taskedit-tasklist'
).
change
(
function
()
{
rcmail
.
calendar_folder_change
(
this
);
});
}
}
});
rcube_webmail
.
prototype
.
event_delegator_request
=
function
(
data
)
{
if
(
!
this
.
env
.
delegator_context
)
{
return
;
}
if
(
typeof
data
===
'object'
)
{
data
.
_context
=
this
.
env
.
delegator_context
;
}
else
{
data
+=
'&_context='
+
this
.
env
.
delegator_context
;
}
return
data
;
};
// callback for calendar event/task form initialization
rcube_webmail
.
prototype
.
calendar_event_init
=
function
(
data
,
type
)
{
var
folder
=
data
.
o
[
type
==
'calendar'
?
'calendar'
:
'list'
];
// set identity for delegator context
this
.
env
[
type
+
'_settings'
].
identity
=
this
.
calendar_folder_delegator
(
folder
,
type
);
};
// returns delegator's identity data according to selected calendar/tasks folder
rcube_webmail
.
prototype
.
calendar_folder_delegator
=
function
(
folder
,
type
)
{
var
d
,
delegator
,
settings
=
this
.
env
[
type
+
'_settings'
],
list
=
this
.
env
[
type
==
'calendar'
?
'calendars'
:
'tasklists'
];
// derive delegator from the calendar owner property
if
(
list
[
folder
]
&&
list
[
folder
].
owner
)
{
delegator
=
list
[
folder
].
owner
;
}
if
(
delegator
&&
(
d
=
this
.
env
.
delegators
[
delegator
]))
{
// find delegator's identity id
if
(
!
d
.
identity_id
)
{
$
.
each
(
settings
.
identities
,
function
(
i
,
v
)
{
if
(
d
.
email
==
v
)
{
d
.
identity_id
=
i
;
return
false
;
}
});
}
d
.
uid
=
delegator
;
}
else
{
d
=
this
.
env
.
original_identity
;
}
this
.
env
.
delegator_context
=
d
.
uid
;
return
d
;
};
// handler for calendar/tasklist folder change
rcube_webmail
.
prototype
.
calendar_folder_change
=
function
(
element
)
{
var
folder
=
$
(
element
).
val
(),
type
=
element
.
id
.
indexOf
(
'task'
)
>
-
1
?
'tasklist'
:
'calendar'
,
sname
=
type
+
'_settings'
,
select
=
$
(
'#edit-identities-list'
),
old
=
this
.
env
[
sname
].
identity
;
this
.
env
[
sname
].
identity
=
this
.
calendar_folder_delegator
(
folder
,
type
);
// change organizer identity in identity selector
if
(
select
.
length
&&
old
!=
this
.
env
[
sname
].
identity
)
{
var
id
=
this
.
env
[
sname
].
identity
.
identity_id
||
select
.
find
(
'option'
).
first
().
val
();
select
.
val
(
id
).
change
();
}
};
// modify default identity of the user
rcube_webmail
.
prototype
.
calendar_identity_init
=
function
(
type
)
{
var
identity
=
this
.
env
[
type
+
'_settings'
].
identity
,
emails
=
identity
.
emails
.
split
(
';'
);
// remove delegators' emails from list of emails of the current user
emails
=
$
.
map
(
emails
,
function
(
v
)
{
for
(
var
n
in
rcmail
.
env
.
delegators
)
{
if
(
rcmail
.
env
.
delegators
[
n
].
emails
.
indexOf
(
';'
+
v
)
>
-
1
)
{
return
null
;
}
}
return
v
;
});
identity
.
emails
=
emails
.
join
(
';'
);
this
.
env
.
original_identity
=
identity
;
};
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Apr 4 2026, 9:57 AM (4 w, 2 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
4b/cf/9f930d6c0961be2f0ec3e6eba172
Default Alt Text
delegation.js (5 KB)
Attached To
Mode
rRPK roundcubemail-plugins-kolab
Attached
Detach File
Event Timeline