Allow to list contact groups in (paged) list (yet incomplete)
| | |
| | | 'object_classes' => array("top", "groupOfNames"), |
| | | 'member_attr' => 'member', // name of the member attribute, e.g. uniqueMember |
| | | 'name_attr' => 'cn', // attribute to be used as group name |
| | | 'member_filter' => '(objectclass=*)', // optional filter to use when querying for group members |
| | | ), |
| | | ); |
| | | */ |
| | |
| | | this.env.contactfolders = $.extend($.extend({}, this.env.address_sources), this.env.contactgroups); |
| | | |
| | | this.enable_command('add', 'import', this.env.writable_source); |
| | | this.enable_command('list', 'listgroup', 'listsearch', 'advanced-search', true); |
| | | this.enable_command('list', 'listgroup', 'pushgroup', 'listsearch', 'advanced-search', true); |
| | | |
| | | if (this.gui_objects.contactslist) { |
| | | this.contact_list = new rcube_list_widget(this.gui_objects.contactslist, |
| | |
| | | } |
| | | break; |
| | | |
| | | case 'pushgroup': |
| | | // TODO: so some magic stuff here |
| | | case 'listgroup': |
| | | this.reset_qsearch(); |
| | | this.list_contacts(props.source, props.id); |
| | |
| | | |
| | | this.list_contacts_clear = function() |
| | | { |
| | | this.contact_list.data = {}; |
| | | this.contact_list.clear(true); |
| | | this.show_contentframe(false); |
| | | this.enable_command('delete', false); |
| | |
| | | // load contact record |
| | | this.load_contact = function(cid, action, framed) |
| | | { |
| | | var win, url = {}, target = window; |
| | | var win, url = {}, target = window, |
| | | rec = this.contact_list.data[cid]; |
| | | |
| | | if (rec && rec.type == 'group') { |
| | | alert('group ' + cid) |
| | | } |
| | | |
| | | if (win = this.get_frame_window(this.env.contentframe)) { |
| | | url._framed = 1; |
| | |
| | | }; |
| | | |
| | | // add row to contacts list |
| | | this.add_contact_row = function(cid, cols, classes) |
| | | this.add_contact_row = function(cid, cols, classes, data) |
| | | { |
| | | if (!this.gui_objects.contactslist) |
| | | return false; |
| | |
| | | row.appendChild(col); |
| | | } |
| | | |
| | | // store data in list member |
| | | list.data[cid] = data; |
| | | list.insert_row(row); |
| | | |
| | | this.enable_command('export', list.rowcount > 0); |
| | |
| | | if (empty($entry[$attr])) |
| | | return $group_members; |
| | | |
| | | // add group record to cache if it isn't yet there |
| | | $group_id = self::dn_encode($dn); |
| | | $group_cache = $this->cache->get('groups'); |
| | | if (!$group_cache[$group_id]) { |
| | | $name_attr = $this->prop['groups']['name_attr']; |
| | | $group_name = is_array($ldap_data[$i][$name_attr]) ? $ldap_data[$i][$name_attr][0] : $ldap_data[$i][$name_attr]; |
| | | |
| | | $group_cache[$group_id]['ID'] = $group_id; |
| | | $group_cache[$group_id]['dn'] = $dn; |
| | | $group_cache[$group_id]['name'] = $group_name; |
| | | $group_cache[$group_id]['member_attr'] = $this->get_group_member_attr($entry[$i]['objectclass']); |
| | | |
| | | $this->cache->set('groups', $group_cache); |
| | | } |
| | | |
| | | // read these attributes for all members |
| | | $attrib = $count ? array('dn') : array_values($this->fieldmap); |
| | | $attrib[] = 'objectClass'; |
| | |
| | | $attrib[] = 'uniqueMember'; |
| | | $attrib[] = 'memberURL'; |
| | | |
| | | $filter = $this->prop['groups']['member_filter'] ? $this->prop['groups']['member_filter'] : '(objectclass=*)'; |
| | | |
| | | for ($i=0; $i < $entry[$attr]['count']; $i++) |
| | | { |
| | | if (empty($entry[$attr][$i])) |
| | | continue; |
| | | |
| | | $result = @ldap_read($this->conn, $entry[$attr][$i], '(objectclass=*)', |
| | | $result = @ldap_read($this->conn, $entry[$attr][$i], $filter, |
| | | $attrib, 0, (int)$this->prop['sizelimit'], (int)$this->prop['timelimit']); |
| | | |
| | | $members = @ldap_get_entries($this->conn, $result); |
| | |
| | | */ |
| | | private function _ldap2result($rec) |
| | | { |
| | | $out = array(); |
| | | $out = array('_type' => 'person'); |
| | | |
| | | if ($rec['dn']) |
| | | $out[$this->primary_key] = self::dn_encode($rec['dn']); |
| | | |
| | | // determine record type |
| | | if (array_intersect(array('groupofuniquenames','kolabgroupofuniquenames'), (array)$rec['objectclass'])) { |
| | | $out['_type'] = 'group'; |
| | | $out['readonly'] = true; |
| | | if ($this->fieldmap['groupname']) { |
| | | $this->fieldmap['name'] = $this->fieldmap['groupname']; |
| | | } |
| | | } |
| | | |
| | | foreach ($this->fieldmap as $rf => $lf) |
| | | { |
| | |
| | | for ($i=0; $i < $group_count; $i++) |
| | | { |
| | | $group_name = is_array($ldap_data[$i][$name_attr]) ? $ldap_data[$i][$name_attr][0] : $ldap_data[$i][$name_attr]; |
| | | $group_id = self::dn_encode($group_name); |
| | | $group_id = self::dn_encode($ldap_data[$i]['dn']); |
| | | $groups[$group_id]['ID'] = $group_id; |
| | | $groups[$group_id]['dn'] = $ldap_data[$i]['dn']; |
| | | $groups[$group_id]['name'] = $group_name; |
| | |
| | | |
| | | $labels['group'] = 'Group'; |
| | | $labels['groups'] = 'Groups'; |
| | | $labels['listgroup'] = 'List group members'; |
| | | $labels['personaladrbook'] = 'Personal Addresses'; |
| | | |
| | | $labels['searchsave'] = 'Save search'; |
| | |
| | | global $CONTACTS, $OUTPUT; |
| | | |
| | | // define list of cols to be displayed |
| | | $a_show_cols = array('name'); |
| | | $a_show_cols = array('name','action'); |
| | | |
| | | // add id to message list table if not specified |
| | | if (!strlen($attrib['id'])) |
| | |
| | | return; |
| | | |
| | | // define list of cols to be displayed |
| | | $a_show_cols = array('name'); |
| | | $a_show_cols = array('name','action'); |
| | | |
| | | while ($row = $result->next()) { |
| | | $row['CID'] = $row['ID']; |
| | | $source_id = $OUTPUT->get_env('source'); |
| | | $a_row_cols = array(); |
| | | $classes = array('person'); // org records will follow some day |
| | | $classes = array($row['_type'] ? $row['_type'] : 'person'); |
| | | |
| | | // build contact ID with source ID |
| | | if (isset($row['sourceid'])) { |
| | | $row['ID'] = $row['ID'].'-'.$row['sourceid']; |
| | | $source_id = $row['sourceid']; |
| | | } |
| | | |
| | | // format each col |
| | | foreach ($a_show_cols as $col) { |
| | | $val = $col == 'name' ? rcube_addressbook::compose_list_name($row) : $row[$col]; |
| | | $a_row_cols[$col] = Q($val); |
| | | $val = ''; |
| | | switch ($col) { |
| | | case 'name': |
| | | $val = Q(rcube_addressbook::compose_list_name($row)); |
| | | break; |
| | | |
| | | case 'action': |
| | | if ($row['_type'] == 'group') { |
| | | $val = html::a(array( |
| | | 'href' => '#list', |
| | | 'rel' => $row['ID'], |
| | | 'title' => rcube_label('listgroup'), |
| | | 'onclick' => sprintf("return %s.command('pushgroup',{'source':'%s','id':'%s'},this)", JS_OBJECT_NAME, $source_id, $row['CID']), |
| | | ), '»'); |
| | | } |
| | | break; |
| | | |
| | | default: |
| | | $val = Q($row[$col]); |
| | | break; |
| | | } |
| | | |
| | | $a_row_cols[$col] = $val; |
| | | } |
| | | |
| | | if ($row['readonly']) |
| | | $classes[] = 'readonly'; |
| | | |
| | | $OUTPUT->command($prefix.'add_contact_row', $row['ID'], $a_row_cols, join(' ', $classes)); |
| | | $OUTPUT->command($prefix.'add_contact_row', $row['ID'], $a_row_cols, join(' ', $classes), $row); |
| | | } |
| | | } |
| | | |
| | |
| | | font-weight: bold; |
| | | } |
| | | |
| | | #contacts-table .group td.name { |
| | | background-position: 6px -1555px; |
| | | } |
| | | |
| | | #contacts-table .group.selected td.name, |
| | | #contacts-table .group.unfocused td.name { |
| | | background-position: 6px -1579px; |
| | | font-weight: bold; |
| | | } |
| | | |
| | | |
| | | #contact-frame { |
| | | position: absolute; |
| | | top: 0; |