alecpl
2010-10-28 a79417d4efda43e99fdc9210c8662890676bebd7
program/steps/addressbook/func.inc
@@ -55,6 +55,7 @@
  $OUTPUT->set_pagetitle(rcube_label('addressbook'));
}
function rcmail_directory_list($attrib)
{
  global $RCMAIL, $OUTPUT;
@@ -66,8 +67,10 @@
  $local_id = '0';
  $jsdata = array();
  $current = get_input_value('_source', RCUBE_INPUT_GPC);
  $line_templ = html::tag('li', array('id' => 'rcmli%s', 'class' => 'addressbook %s'),
    html::a(array('href' => '%s', 'onclick' => "return ".JS_OBJECT_NAME.".command('list','%s',this)"), '%s'));
    $line_templ = html::tag('li', array(
        'id' => 'rcmli%s', 'class' => 'addressbook %s'),
        html::a(array('href' => '%s',
            'onclick' => "return ".JS_OBJECT_NAME.".command('list','%s',this)"), '%s'));
  if (!$current && strtolower($RCMAIL->config->get('address_book_type', 'sql')) != 'ldap') {
    $current = '0';
@@ -83,7 +86,8 @@
    $js_id = JQ($id);
    $dom_id = preg_replace('/[^a-z0-9\-_]/i', '', $id);
    $out .= sprintf($line_templ, $dom_id, ($current == $id ? 'selected' : ''),
      Q(rcmail_url(null, array('_source' => $id))), $js_id, (!empty($source['name']) ? Q($source['name']) : Q($id)));
            Q(rcmail_url(null, array('_source' => $id))),
            $js_id, (!empty($source['name']) ? Q($source['name']) : Q($id)));
    $groupdata = rcmail_contact_groups(array('out' => $out, 'jsdata' => $jsdata, 'source' => $id));
    $jsdata = $groupdata['jsdata'];
    $out = $groupdata['out'];
@@ -103,14 +107,17 @@
  $groups = $RCMAIL->get_address_book($args['source'])->list_groups();
  if (!empty($groups)) {
    $line_templ = html::tag('li', array('id' => 'rcmliG%s%s', 'class' => 'contactgroup'),
      html::a(array('href' => '#', 'onclick' => "return ".JS_OBJECT_NAME.".command('listgroup',{'source':'%s','id':'%s'},this)"), '%s'));
        $line_templ = html::tag('li', array(
            'id' => 'rcmliG%s%s', 'class' => 'contactgroup'),
            html::a(array('href' => '#',
                'onclick' => "return ".JS_OBJECT_NAME.".command('listgroup',{'source':'%s','id':'%s'},this)"), '%s'));
    $jsdata = array();
    foreach ($groups as $group) {
      $args['out'] .= sprintf($line_templ, $args['source'], $group['ID'], $args['source'], $group['ID'], Q($group['name']));
      $args['jsdata']['G'.$args['source'].$group['ID']] = array(
        'source' => $args['source'], 'id' => $group['ID'], 'name' => $group['name'], 'type' => 'group');
                'source' => $args['source'], 'id' => $group['ID'],
                'name' => $group['name'], 'type' => 'group');
    }
  }
@@ -159,8 +166,7 @@
  // define list of cols to be displayed
  $a_show_cols = array('name');
  
  while ($row = $result->next())
    {
    while ($row = $result->next()) {
    $a_row_cols = array();
    
    // format each col
@@ -202,15 +208,15 @@
  }
function rcmail_get_rowcount_text()
  {
  global $CONTACTS;
  
  // read nr of contacts
  $result = $CONTACTS->get_result();
  if (!$result)
    if (!$result) {
    $result = $CONTACTS->count();
    }
  
  if ($result->count == 0)
    $out = rcube_label('nocontactsfound');
@@ -226,6 +232,58 @@
  return $out;
  }
  
function rcmail_contact_form($form, $record)
{
    global $RCMAIL;
    // Allow plugins to modify contact form content
    $plugin = $RCMAIL->plugins->exec_hook('contact_form', array(
        'form' => $form, 'record' => $record));
    $form = $plugin['form'];
    $record = $plugin['record'];
    $out = '';
    foreach ($form as $fieldset) {
        if (empty($fieldset['content']))
            continue;
        $content = '';
        if (is_array($fieldset['content'])) {
            $table = new html_table(array('cols' => 2));
            foreach ($fieldset['content'] as $col => $colprop) {
                $colprop['id'] = 'rcmfd_'.$col;
                $label = !empty($colprop['label']) ? $colprop['label'] : rcube_label($col);
                if (!empty($colprop['value'])) {
                    $value = $colprop['value'];
                }
                else if ($RCMAIL->action == 'show') {
                    $value = $record[$col];
                }
                else {
                    $value = rcmail_get_edit_field($col, $record[$col], $colprop, $colprop['type']);
                }
                $table->add('title', sprintf('<label for="%s">%s</label>', $colprop['id'], Q($label)));
                $table->add(null, $value);
            }
            $content = $table->show();
        }
        else {
            $content = $fieldset['content'];
        }
        $out .= html::tag('fieldset', null, html::tag('legend', null, Q($fieldset['name'])) . $content) ."\n";
    }
    return $out;
}
// register UI objects
$OUTPUT->add_handlers(array(
  'directorylist' => 'rcmail_directory_list',
@@ -235,4 +293,3 @@
  'recordscountdisplay' => 'rcmail_rowcount_display',
  'searchform' => array($OUTPUT, 'search_form')
));