Aleksander Machniak
2013-08-08 1391f17a521a19382c59ef9d4e93a8ced2f1a9e5
program/steps/addressbook/func.inc
@@ -322,7 +322,7 @@
    $OUTPUT->include_script('list.js');
    // add some labels to client
    $OUTPUT->add_label('deletecontactconfirm', 'copyingcontact', 'contactdeleting');
    $OUTPUT->add_label('deletecontactconfirm', 'copyingcontact', 'movingcontact', 'contactdeleting');
    return $out;
}
@@ -751,12 +751,28 @@
    $plugin = $RCMAIL->plugins->exec_hook('contact_photo', array('record' => $record, 'data' => $record['photo']));
    // check if we have photo data from contact form
    if ($GLOBALS['EDIT_RECORD']) {
        $rec = $GLOBALS['EDIT_RECORD'];
        if ($rec['photo'] == '-del-') {
            $record['photo'] = '';
        }
        else if ($_SESSION['contacts']['files'][$rec['photo']]) {
            $record['photo'] = $file_id = $rec['photo'];
        }
    }
    if ($plugin['url'])
        $photo_img = $plugin['url'];
    else if (preg_match('!^https?://!i', $record['photo']))
        $photo_img = $record['photo'];
    else if ($record['photo'])
        $photo_img = $RCMAIL->url(array('_action' => 'photo', '_cid' => $record['ID'], '_source' => $SOURCE_ID));
    else if ($record['photo']) {
        $url = array('_action' => 'photo', '_cid' => $record['ID'], '_source' => $SOURCE_ID);
        if ($file_id) {
            $url['_photo'] = $ff_value = $file_id;
        }
        $photo_img = $RCMAIL->url($url);
    }
    else
        $ff_value = '-del-'; // will disable delete-photo action
@@ -779,6 +795,54 @@
    return format_date($val, $RCMAIL->config->get('date_format', 'Y-m-d'), false);
}
/**
 * Updates saved search after data changed
 */
function rcmail_search_update($return = false)
{
    global $RCMAIL;
    if (($search_request = $_REQUEST['_search']) && isset($_SESSION['search'][$search_request])) {
        $search   = (array)$_SESSION['search'][$search_request];
        $sort_col = $RCMAIL->config->get('addressbook_sort_col', 'name');
        $afields  = $return ? $RCMAIL->config->get('contactlist_fields') : array('name', 'email');
        $records  = array();
        foreach ($search as $s => $set) {
            $source = $RCMAIL->get_address_book($s);
            // reset page
            $source->set_page(1);
            $source->set_pagesize(9999);
            $source->set_search_set($set);
            // get records
            $result = $source->list_records($afields);
            if (!$result->count) {
                unset($search[$s]);
                continue;
            }
            if ($return) {
                while ($row = $result->next()) {
                    $row['sourceid'] = $s;
                    $key = rcube_addressbook::compose_contact_key($row, $sort_col);
                    $records[$key] = $row;
                }
                unset($result);
            }
            $search[$s] = $source->get_search_set();
        }
        $_SESSION['search'][$search_request] = $search;
        return $records;
    }
    return false;
}
/**
 * Returns contact ID(s) and source(s) from GET/POST data
@@ -845,7 +909,6 @@
// register action aliases
$RCMAIL->register_action_map(array(
    'add' => 'edit.inc',
    'photo' => 'show.inc',
    'group-create' => 'groups.inc',
    'group-rename' => 'groups.inc',
    'group-delete' => 'groups.inc',