Subscribe to ACL plugin hooks and adjust the permission items for groupware folders (#4839)

This commit is contained in:
Thomas Bruederli 2015-03-12 14:55:04 +01:00
parent a5436ece25
commit e187d0880b

View file

@ -68,6 +68,10 @@ class kolab_folders extends rcube_plugin
// Special folders setting // Special folders setting
$this->add_hook('preferences_save', array($this, 'prefs_save')); $this->add_hook('preferences_save', array($this, 'prefs_save'));
// ACL plugin hooks
$this->add_hook('acl_rights_simple', array($this, 'acl_rights_simple'));
$this->add_hook('acl_rights_supported', array($this, 'acl_rights_supported'));
} }
/** /**
@ -442,6 +446,68 @@ class kolab_folders extends rcube_plugin
return $args; return $args;
} }
/**
* Handler for ACL permissions listing (acl_rights_simple hook)
*
* This shall combine the write and delete permissions into one item for
* groupware folders as updating groupware objects is an insert + delete operation.
*
* @param array $args Hash array with hook parameters
*
* @return array Hash array with modified hook parameters
*/
public function acl_rights_simple($args)
{
if ($args['folder']) {
list($type,) = $this->get_folder_type($args['folder']);
// we're dealing with a groupware folder here...
if ($type && $type !== 'mail') {
if ($args['rights']['write'] && $args['rights']['delete']) {
$writeperms = $args['rights']['write'] . $args['rights']['delete'];
$items = array(
'read' => 'lr',
'write' => $writeperms,
'other' => preg_replace('/[lr'.$writeperms.']/', '', $args['rights']['other']),
);
$args['rights'] = $items;
// add localized labels and titles for the altered items
$args['labels'] = array(
'other' => $this->rc->gettext('shortacla','acl'),
);
$args['titles'] = array(
'other' => $this->rc->gettext('longaclother','acl'),
);
}
}
}
return $args;
}
/**
* Handler for ACL permissions listing (acl_rights_supported hook)
*
* @param array $args Hash array with hook parameters
*
* @return array Hash array with modified hook parameters
*/
public function acl_rights_supported($args)
{
if ($args['folder']) {
list($type,) = $this->get_folder_type($args['folder']);
// we're dealing with a groupware folder here...
if ($type && $type !== 'mail') {
// remove some irrelevant (for groupware objects) rights
$args['rights'] = str_split(preg_replace('/[sp]/', '', join('', $args['rights'])));
}
}
return $args;
}
/** /**
* Checks if IMAP server supports any of METADATA, ANNOTATEMORE, ANNOTATEMORE2 * Checks if IMAP server supports any of METADATA, ANNOTATEMORE, ANNOTATEMORE2
* *