/**
  * create the fieldset that allows user to select the groups of the contact, and whether the contact is hidden or not
  * @return string html-content
  * @global DB used to query database for groups
  */
 function createGroupsFieldset()
 {
     global $db;
     $cont = '<fieldset class="edit-groups">';
     $cont .= '<legend>Groups</legend>';
     $gr = $this->contact->getValueGroup('groups');
     $groups = array();
     foreach ($gr as $g) {
         $groups[] = $g['groupname'];
     }
     $db->query('SELECT * FROM ' . TABLE_GROUPLIST . ' ORDER BY groupname ASC');
     $cont .= '<div class="edit-line">';
     while ($r = $db->next()) {
         $cont .= HTMLHelper::createCheckbox("groups[{$r['groupname']}]", $r['groupname'], in_array($r['groupname'], $groups), 'edit-input-checkbox');
     }
     $cont .= '</div>';
     $cont .= '<div class="edit-line">';
     $cont .= HTMLHelper::createTextField('newgroup', 'Add new group', '', 'edit-input');
     if ($_SESSION['user']->isAtLeast('admin')) {
         global $CONFIG_INSTALL_SUBDIR;
         // find .xls files without dash (type-edit.xsl)
         $func = create_function('$val', 'return strpos($val,"-")===FALSE;');
         $files = array_filter(FileHelper::scanDirectory($CONFIG_INSTALL_SUBDIR . 'lib/xslt', '.xsl'), $func);
         if (count($files) > 0) {
             FileHelper::removeExtensions($files);
             $files = array_merge(array(''), $files);
             $xs = isset($this->contact->contact['xsltDisplayType']) ? $this->contact->contact['xsltDisplayType'] : '';
             $cont .= HTMLHelper::createDropdownValuesAreKeys('contact[xsltDisplayType]', 'XSLT stylesheet', $files, $xs, 'edit-input', false);
         }
         $cont .= HTMLHelper::createCheckbox('contact[hidden]', 'Hide this entry', isset($this->contact->contact['hidden']) ? $this->contact->contact['hidden'] : 0, 'edit-input-checkbox-hide');
     }
     $cont .= '</div>';
     $cont .= '</fieldset>';
     return $cont;
 }