Aleksander Machniak
2013-08-08 8799df8ccdb09114b14742e0493a8ba401688fdf
program/steps/addressbook/show.inc
@@ -38,58 +38,6 @@
// get address book name (for display)
rcmail_set_sourcename($CONTACTS);
// return raw photo of the given contact
if ($RCMAIL->action == 'photo') {
    // search for contact first
    if (!$record && ($email = get_input_value('_email', RCUBE_INPUT_GPC))) {
        foreach ($RCMAIL->get_address_sources() as $s) {
            $abook = $RCMAIL->get_address_book($s['id']);
            $result = $abook->search(array('email'), $email, 1, true, true, 'photo');
            while ($result && ($record = $result->iterate())) {
                if ($record['photo'])
                    break 2;
            }
        }
    }
    // read the referenced file
    if (($file_id = get_input_value('_photo', RCUBE_INPUT_GPC)) && ($tempfile = $_SESSION['contacts']['files'][$file_id])) {
        $tempfile = $RCMAIL->plugins->exec_hook('attachment_display', $tempfile);
        if ($tempfile['status']) {
            if ($tempfile['data'])
                $data = $tempfile['data'];
            else if ($tempfile['path'])
                $data = file_get_contents($tempfile['path']);
        }
    }
    else if ($record['photo']) {
        $data = is_array($record['photo']) ? $record['photo'][0] : $record['photo'];
        if (!preg_match('![^a-z0-9/=+-]!i', $data))
            $data = base64_decode($data, true);
    }
    // let plugins do fancy things with contact photos
    $plugin = $RCMAIL->plugins->exec_hook('contact_photo', array('record' => $record, 'email' => $email, 'data' => $data));
    // redirect to url provided by a plugin
    if ($plugin['url'])
        $RCMAIL->output->redirect($plugin['url']);
    else
        $data = $plugin['data'];
    // deliver alt image
    if (!$data && ($alt_img = get_input_value('_alt', RCUBE_INPUT_GPC)) && is_file($alt_img))
        $data = file_get_contents($alt_img);
    // cache for one day if requested by email
    if (!$cid && $email)
        $RCMAIL->output->future_expire_header(86400);
    header('Content-Type: ' . rc_image_content_type($data));
    echo $data ? $data : file_get_contents('program/resources/blank.gif');
    exit;
}
function rcmail_contact_head($attrib)
{
@@ -100,8 +48,6 @@
        $RCMAIL->output->show_message('contactnotfound');
        return false;
    }
    $microformats = array('name' => 'fn', 'email' => 'email');
    $form = array(
        'head' => array(  // section 'head' is magic!
@@ -177,7 +123,7 @@
}
function rcmail_render_email_value($email, $col)
function rcmail_render_email_value($email)
{
    return html::a(array(
        'href' => 'mailto:' . $email,
@@ -188,7 +134,7 @@
}
function rcmail_render_url_value($url, $col)
function rcmail_render_url_value($url)
{
    $prefix = preg_match('!^(http|ftp)s?://!', $url) ? '' : 'http://';
    return html::a(array(
@@ -209,24 +155,20 @@
        return '';
    }
    $table = new html_table(array('cols' => 2, 'cellspacing' => 0, 'border' => 0));
    $members = $CONTACTS->get_record_groups($contact_id);
    $members  = $CONTACTS->get_record_groups($contact_id);
    $table    = new html_table(array('cols' => 2, 'cellspacing' => 0, 'border' => 0));
    $checkbox = new html_checkbox(array('name' => '_gid[]',
        'class' => 'groupmember', 'disabled' => $CONTACTS->readonly));
    foreach (array_merge($GROUPS, $members) as $group) {
    foreach ($GROUPS as $group) {
        $gid = $group['ID'];
        if ($seen[$gid]++)
            continue;
        $table->add(null, $checkbox->show($members[$gid] ? $gid : null,
            array('value' => $gid, 'id' => 'ff_gid' . $gid)));
        $table->add(null, html::label('ff_gid' . $gid, Q($group['name'])));
    }
    $hiddenfields = new html_hiddenfield(array('name' => '_source', 'value' => get_input_value('_source', RCUBE_INPUT_GPC)));
    $hiddenfields->add(array('name' => '_cid', 'value' => $record['ID']));
    $hiddenfields->add(array('name' => '_cid', 'value' => $contact_id));
    $form_start = $RCMAIL->output->request_form(array(
        'name' => "form", 'method' => "post",