diff --git a/plugins/kolab_addressbook/kolab_addressbook.php b/plugins/kolab_addressbook/kolab_addressbook.php --- a/plugins/kolab_addressbook/kolab_addressbook.php +++ b/plugins/kolab_addressbook/kolab_addressbook.php @@ -227,36 +227,38 @@ public function folder_tree_html($node, $data, &$jsdata) { $out = ''; - foreach ($node->children as $folder) { - $id = $folder->id; - $source = $data[$id]; - $is_collapsed = strpos($this->rc->config->get('collapsed_abooks',''), '&'.rawurlencode($id).'&') !== false; - - if ($folder->virtual) { - $source = $this->abook_prop($folder->id, $folder); - } - else if (empty($source)) { - $this->sources[$id] = new rcube_kolab_contacts($folder->name); - $source = $this->abook_prop($id, $this->sources[$id]); - } + if (!empty($node->children)) { + foreach ($node->children as $folder) { + $id = $folder->id; + $source = $data[$id]; + $is_collapsed = strpos($this->rc->config->get('collapsed_abooks',''), '&'.rawurlencode($id).'&') !== false; + + if ($folder->virtual) { + $source = $this->abook_prop($folder->id, $folder); + } + else if (empty($source)) { + $this->sources[$id] = new rcube_kolab_contacts($folder->name); + $source = $this->abook_prop($id, $this->sources[$id]); + } - $content = $this->addressbook_list_item($id, $source, $jsdata); + $content = $this->addressbook_list_item($id, $source, $jsdata); - if (!empty($folder->children)) { - $child_html = $this->folder_tree_html($folder, $data, $jsdata); + if (!empty($folder->children)) { + $child_html = $this->folder_tree_html($folder, $data, $jsdata); - // copy group items... - if (preg_match('!]*>(.*)\n*$!Ums', $content, $m)) { - $child_html = $m[1] . $child_html; - $content = substr($content, 0, -strlen($m[0]) - 1); - } - // ... and re-create the subtree - if (!empty($child_html)) { - $content .= html::tag('ul', array('class' => 'groups', 'style' => ($is_collapsed ? "display:none;" : null)), $child_html); + // copy group items... + if (preg_match('!]*>(.*)\n*$!Ums', $content, $m)) { + $child_html = $m[1] . $child_html; + $content = substr($content, 0, -strlen($m[0]) - 1); + } + // ... and re-create the subtree + if (!empty($child_html)) { + $content .= html::tag('ul', array('class' => 'groups', 'style' => ($is_collapsed ? "display:none;" : null)), $child_html); + } } - } - $out .= $content . ''; + $out .= $content . ''; + } } return $out;