thomascube
2008-09-18 7dfb1fba5001299300736e6b5d95d9400575e3e7
program/steps/addressbook/show.inc
@@ -5,7 +5,7 @@
 | program/steps/addressbook/show.inc                                    |
 |                                                                       |
 | This file is part of the RoundCube Webmail client                     |
 | Copyright (C) 2005, RoundCube Dev. - Switzerland                      |
 | Copyright (C) 2005-2008, RoundCube Dev. - Switzerland                 |
 | Licensed under the GNU GPL                                            |
 |                                                                       |
 | PURPOSE:                                                              |
@@ -20,61 +20,56 @@
*/
if ($_GET['_cid'] || $_POST['_cid'])
  {
  $cid = $_POST['_cid'] ? $_POST['_cid'] : $_GET['_cid'];
  $DB->query("SELECT * FROM ".get_table_name('contacts')."
              WHERE  contact_id=?
              AND    user_id=?
              AND    del<>1",
              $cid,
              $_SESSION['user_id']);
  $CONTACT_RECORD = $DB->fetch_assoc();
  if (is_array($CONTACT_RECORD))
    $OUTPUT->add_script(sprintf("%s.set_env('cid', '%s');", $JS_OBJECT_NAME, $CONTACT_RECORD['contact_id']));
  }
// read contact record
if (($cid = get_input_value('_cid', RCUBE_INPUT_GPC)) && ($record = $CONTACTS->get_record($cid, true))) {
  $OUTPUT->set_env('cid', $record['ID']);
}
function rcmail_contact_details($attrib)
  {
  global $CONTACT_RECORD, $JS_OBJECT_NAME;
{
  global $CONTACTS, $OUTPUT;
  if (!$CONTACT_RECORD)
    return show_message('contactnotfound');
  // check if we have a valid result
  if (!(($result = $CONTACTS->get_result()) && ($record = $result->first()))) {
    $OUTPUT->show_message('contactnotfound');
    return false;
  }
  
  // a specific part is requested
  if ($attrib['part'])
    return rep_specialchars_output($CONTACT_RECORD[$attrib['part']]);
  // return the complete address record as table
  $out = "<table>\n\n";
  $a_show_cols = array('name', 'firstname', 'surname', 'email');
  foreach ($a_show_cols as $col)
    {
    if ($col=='email' && $CONTACT_RECORD[$col])
      $value = sprintf('<a href="#compose" onclick="%s.command(\'compose\', %d)" title="%s">%s</a>',
                       $JS_OBJECT_NAME,
                       $CONTACT_RECORD['contact_id'],
                       rcube_label('composeto'),
                       $CONTACT_RECORD[$col]);
    else
      $value = rep_specialchars_output($CONTACT_RECORD[$col]);
    $title = rcube_label($col);
    $out .= sprintf("<tr><td class=\"title\">%s</td><td>%s</td></tr>\n", $title, $value);
    }
  $out .= "\n</table>";
  return $out;
  if ($attrib['part']) {
    return Q($record[$attrib['part']]);
  }
  // return the complete address record as table
  $table = new html_table(array('cols' => 2));
parse_template('showcontact');
  $a_show_cols = array('name', 'firstname', 'surname', 'email');
  $microformats = array('name' => 'fn', 'email' => 'email');
  foreach ($a_show_cols as $col) {
    if ($col == 'email' && !empty($record[$col])) {
      $value = html::a(array(
        'href' => 'mailto:' . $record[$col],
        'onclick' => sprintf("return %s.command('compose','%s',this)", JS_OBJECT_NAME, JQ($record[$col])),
        'title' => rcube_label('composeto'),
        'class' => $microformats[$col],
      ), Q($record[$col]));
    }
    else if (!empty($record[$col])) {
      $value = html::span($microformats[$col], Q($record[$col]));
    }
    else
      $value = '';
    $table->add('title', Q(rcube_label($col)));
    $table->add(null, $value);
  }
  return $table->show($attrib + array('class' => 'vcard'));
}
//$OUTPUT->framed = $_framed;
$OUTPUT->add_handler('contactdetails', 'rcmail_contact_details');
$OUTPUT->send('showcontact');
?>