Merge branch 'master' of ssh://git.kolab.org/diffusion/RPK/roundcubemail-plugins-kolab
This commit is contained in:
commit
872403fd2b
5 changed files with 16 additions and 67 deletions
|
@ -269,11 +269,15 @@ class calendar extends rcube_plugin
|
|||
/**
|
||||
* Get properties of the calendar this user has specified as default
|
||||
*/
|
||||
public function get_default_calendar($sensitivity = null)
|
||||
public function get_default_calendar($sensitivity = null, $calendars = null)
|
||||
{
|
||||
if ($calendars === null) {
|
||||
$calendars = $this->driver->list_calendars(calendar_driver::FILTER_PERSONAL | calendar_driver::FILTER_WRITEABLE);
|
||||
}
|
||||
|
||||
$default_id = $this->rc->config->get('calendar_default_calendar');
|
||||
$calendars = $this->driver->list_calendars(calendar_driver::FILTER_PERSONAL | calendar_driver::FILTER_WRITEABLE);
|
||||
$calendar = $calendars[$default_id] ?: null;
|
||||
$calendar = $calendars[$default_id] ?: null;
|
||||
|
||||
if (!$calendar || $sensitivity) {
|
||||
foreach ($calendars as $cal) {
|
||||
if ($sensitivity && $cal['subtype'] == $sensitivity) {
|
||||
|
@ -2522,16 +2526,7 @@ class calendar extends rcube_plugin
|
|||
$this->load_driver();
|
||||
|
||||
// We search for writeable calendars in personal namespace by default
|
||||
$result = $this->driver->get_event($event, calendar_driver::FILTER_WRITEABLE | calendar_driver::FILTER_PERSONAL);
|
||||
|
||||
// Some plugins may search in other users calendars, e.g. where delegation is involved
|
||||
$plugin = $this->rc->plugins->exec_hook('calendar_event_find', array(
|
||||
'search' => $event,
|
||||
'result' => $result,
|
||||
'calendar' => $this,
|
||||
));
|
||||
|
||||
return $plugin['result'];
|
||||
return $this->driver->get_event($event, calendar_driver::FILTER_WRITEABLE | calendar_driver::FILTER_PERSONAL);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2550,7 +2545,7 @@ class calendar extends rcube_plugin
|
|||
|
||||
// get a list of writeable calendars to save new events to
|
||||
if (!$existing && !$data['nosave'] && $response['action'] == 'rsvp' || $response['action'] == 'import') {
|
||||
$calendars = $this->driver->list_calendars(calendar_driver::FILTER_PERSONAL);
|
||||
$calendars = $this->driver->list_calendars(calendar_driver::FILTER_WRITEABLE | calendar_driver::FILTER_PERSONAL);
|
||||
$calendar_select = new html_select(array('name' => 'calendar', 'id' => 'itip-saveto', 'is_escaped' => true));
|
||||
$calendar_select->add('--', '');
|
||||
$numcals = 0;
|
||||
|
@ -2560,12 +2555,12 @@ class calendar extends rcube_plugin
|
|||
$numcals++;
|
||||
}
|
||||
}
|
||||
if ($numcals <= 1)
|
||||
if ($numcals < 1)
|
||||
$calendar_select = null;
|
||||
}
|
||||
|
||||
if ($calendar_select) {
|
||||
$default_calendar = $this->get_default_calendar($data['sensitivity']);
|
||||
$default_calendar = $this->get_default_calendar($data['sensitivity'], $calendars);
|
||||
$response['select'] = html::span('folder-select', $this->gettext('saveincalendar') . ' ' .
|
||||
$calendar_select->show($default_calendar['id']));
|
||||
}
|
||||
|
|
|
@ -31,6 +31,8 @@ window.rcmail && rcmail.addEventListener('init', function(evt) {
|
|||
// set delegator context for calendar requests on invitation message
|
||||
rcmail.addEventListener('requestcalendar/event', function(o) { rcmail.event_delegator_request(o); });
|
||||
rcmail.addEventListener('requestcalendar/mailimportevent', function(o) { rcmail.event_delegator_request(o); });
|
||||
rcmail.addEventListener('requestcalendar/mailimportitip', function(o) { rcmail.event_delegator_request(o); });
|
||||
rcmail.addEventListener('requestcalendar/itip-status', function(o) { rcmail.event_delegator_request(o); });
|
||||
|
||||
if (rcmail.env.delegators && window.rcube_calendar_ui) {
|
||||
rcmail.calendar_identity_init();
|
||||
|
|
|
@ -54,7 +54,6 @@ class kolab_delegation extends rcube_plugin
|
|||
$this->add_hook('calendar_user_emails', array($this, 'calendar_user_emails'));
|
||||
$this->add_hook('calendar_list_filter', array($this, 'calendar_list_filter'));
|
||||
$this->add_hook('calendar_load_itip', array($this, 'calendar_load_itip'));
|
||||
$this->add_hook('calendar_event_find', array($this, 'calendar_event_find'));
|
||||
|
||||
// delegation support in kolab_auth plugin
|
||||
$this->add_hook('kolab_auth_emails', array($this, 'kolab_auth_emails'));
|
||||
|
@ -260,22 +259,6 @@ class kolab_delegation extends rcube_plugin
|
|||
return $args;
|
||||
}
|
||||
|
||||
/**
|
||||
* calendar::find_event() handler
|
||||
*/
|
||||
public function calendar_event_find($args)
|
||||
{
|
||||
// If the event can't be found in user personal folders, we'll
|
||||
// look in delegators' folders (T1264)
|
||||
|
||||
if (!empty($_SESSION['delegators']) && empty($args['result'])) {
|
||||
$engine = $this->engine();
|
||||
$engine->delegator_find_event($args);
|
||||
}
|
||||
|
||||
return $args;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delegation support in Calendar plugin UI
|
||||
*/
|
||||
|
|
|
@ -801,7 +801,7 @@ class kolab_delegation_engine
|
|||
continue;
|
||||
}
|
||||
if ($args['personal']) {
|
||||
$ns = $cal->get_namespace();
|
||||
$ns = $cal->get_namespace();
|
||||
|
||||
if (empty($context)) {
|
||||
if ($ns != 'personal') {
|
||||
|
@ -863,39 +863,6 @@ class kolab_delegation_engine
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds an event in delegators' folders. Calendar looks only in
|
||||
* personal namespace, we "extend" this to delegators' folders.
|
||||
*
|
||||
* @param array $args Reference to plugin hook arguments
|
||||
*/
|
||||
public function delegator_find_event(&$args)
|
||||
{
|
||||
// The event wasn't found and current user has delegators
|
||||
if (!empty($_SESSION['delegators']) && empty($args['result'])) {
|
||||
$event = $args['search'];
|
||||
$ns_root = kolab_storage::namespace_root('other');
|
||||
$storage = $this->rc->get_storage();
|
||||
$delimiter = $storage->get_hierarchy_delimiter();
|
||||
$folders = $storage->list_folders_subscribed($ns_root, '*', 'event', 'w');
|
||||
|
||||
// search in all delegators' calendars
|
||||
foreach ($folders as $folder) {
|
||||
list($uid, $path) = explode($delimiter, substr($folder, strlen($ns_root)), 2);
|
||||
|
||||
if (!empty($_SESSION['delegators'][$uid])) {
|
||||
$event['calendar'] = kolab_storage::folder_id($folder, true);
|
||||
$result = $args['calendar']->driver->get_event($event, calendar_driver::FILTER_WRITEABLE);
|
||||
|
||||
if ($result) {
|
||||
$args['result'] = $result;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares two ACLs (according to supported rights)
|
||||
*
|
||||
|
|
|
@ -344,6 +344,8 @@ class kolab_storage
|
|||
*/
|
||||
public static function namespace_root($name)
|
||||
{
|
||||
self::setup();
|
||||
|
||||
foreach ((array)self::$imap->get_namespace($name) as $paths) {
|
||||
if (strlen($paths[0]) > 1) {
|
||||
return $paths[0];
|
||||
|
|
Loading…
Add table
Reference in a new issue