summaryrefslogtreecommitdiff
path: root/plugins/libcalendaring/libcalendaring.php
diff options
context:
space:
mode:
authorThomas Bruederli <bruederli@kolabsys.com>2014-08-19 08:37:31 (GMT)
committerThomas Bruederli <bruederli@kolabsys.com>2014-08-19 08:37:40 (GMT)
commitff9f87a037687a62dbd0070a6d2582fb9ec14d3b (patch)
treeccef9aeb84be644d7bcbbc40207a37c826a22f02 /plugins/libcalendaring/libcalendaring.php
parent0747f9f95dbe245f63b85f55328377d2565b6839 (diff)
downloadroundcubemail-plugins-kolab-ff9f87a037687a62dbd0070a6d2582fb9ec14d3b.tar.gz
Add button to expand members of a group attendee (#3376); prefix edit-attendees-table styles to avoid unintended style overrides
Diffstat (limited to 'plugins/libcalendaring/libcalendaring.php')
-rw-r--r--plugins/libcalendaring/libcalendaring.php56
1 files changed, 56 insertions, 0 deletions
diff --git a/plugins/libcalendaring/libcalendaring.php b/plugins/libcalendaring/libcalendaring.php
index 6ca548e..52a8134 100644
--- a/plugins/libcalendaring/libcalendaring.php
+++ b/plugins/libcalendaring/libcalendaring.php
@@ -106,6 +106,7 @@ class libcalendaring extends rcube_plugin
// add hook to display alarms
$this->add_hook('refresh', array($this, 'refresh'));
$this->register_action('plugin.alarms', array($this, 'alarms_action'));
+ $this->register_action('plugin.expand_attendee_group', array($this, 'expand_attendee_group'));
}
// proceed initialization in startup hook
@@ -1359,6 +1360,61 @@ class libcalendaring extends rcube_plugin
}
+ /********* Attendee handling functions *********/
+
+ /**
+ * Handler for attendee group expansion requests
+ */
+ public function expand_attendee_group()
+ {
+ $id = rcube_utils::get_input_value('id', rcube_utils::INPUT_POST);
+ $data = rcube_utils::get_input_value('data', rcube_utils::INPUT_POST, true);
+ $result = array('id' => $id, 'members' => array());
+ $maxnum = 500;
+
+ // iterate over all autocomplete address books (we don't know the source of the group)
+ foreach ((array)$this->rc->config->get('autocomplete_addressbooks', 'sql') as $abook_id) {
+ if (($abook = $this->rc->get_address_book($abook_id)) && $abook->groups) {
+ foreach ($abook->list_groups($data['name'], 1) as $group) {
+ // this is the matching group to expand
+ if (in_array($data['email'], (array)$group['email'])) {
+ $abook->set_pagesize($maxnum);
+ $abook->set_group($group['ID']);
+
+ // get all members
+ $res = $abook->list_records($this->rc->config->get('contactlist_fields'));
+
+ // handle errors (e.g. sizelimit, timelimit)
+ if ($abook->get_error()) {
+ $result['error'] = $this->rc->gettext('expandattendeegrouperror', 'libcalendaring');
+ $res = false;
+ }
+ // check for maximum number of members (we don't wanna bloat the UI too much)
+ else if ($res->count > $maxnum) {
+ $result['error'] = $this->rc->gettext('expandattendeegroupsizelimit', 'libcalendaring');
+ $res = false;
+ }
+
+ while ($res && ($member = $res->iterate())) {
+ $emails = (array)$abook->get_col_values('email', $member, true);
+ if (!empty($emails) && ($email = array_shift($emails))) {
+ $result['members'][] = array(
+ 'email' => $email,
+ 'name' => rcube_addressbook::compose_list_name($member),
+ );
+ }
+ }
+
+ break 2;
+ }
+ }
+ }
+ }
+
+ $this->rc->output->command('plugin.expand_attendee_callback', $result);
+ }
+
+
/********* Static utility functions *********/
/**