summaryrefslogtreecommitdiff
path: root/program/steps/addressbook
diff options
context:
space:
mode:
Diffstat (limited to 'program/steps/addressbook')
-rw-r--r--program/steps/addressbook/delete.inc3
-rw-r--r--program/steps/addressbook/edit.inc15
-rw-r--r--program/steps/addressbook/func.inc17
-rw-r--r--program/steps/addressbook/list.inc6
-rw-r--r--program/steps/addressbook/search.inc3
-rw-r--r--program/steps/addressbook/show.inc34
6 files changed, 68 insertions, 10 deletions
diff --git a/program/steps/addressbook/delete.inc b/program/steps/addressbook/delete.inc
index a2f12495c..81b8a0970 100644
--- a/program/steps/addressbook/delete.inc
+++ b/program/steps/addressbook/delete.inc
@@ -70,6 +70,7 @@ $page = isset($_SESSION['page']) ? $_SESSION['page'] : 1;
// update saved search after data changed
if (($search_request = $_REQUEST['_search']) && isset($_SESSION['search'][$search_request])) {
$sort_col = $RCMAIL->config->get('addressbook_sort_col', 'name');
+ $afields = $RCMAIL->config->get('contactlist_fields');
$search = (array)$_SESSION['search'][$search_request];
$records = array();
@@ -83,7 +84,7 @@ if (($search_request = $_REQUEST['_search']) && isset($_SESSION['search'][$searc
$source->set_search_set($set);
// get records
- $result = $source->list_records(array('name', 'firstname', 'surname', 'email'));
+ $result = $source->list_records($afields);
if (!$result->count) {
unset($search[$s]);
diff --git a/program/steps/addressbook/edit.inc b/program/steps/addressbook/edit.inc
index f96ad6747..0f1fd6697 100644
--- a/program/steps/addressbook/edit.inc
+++ b/program/steps/addressbook/edit.inc
@@ -262,12 +262,27 @@ function rcmail_source_selector($attrib)
}
+/**
+ * Register container as active area to drop photos onto
+ */
+function rcmail_photo_drop_area($attrib)
+{
+ global $OUTPUT;
+
+ if ($attrib['id']) {
+ $OUTPUT->add_gui_object('filedrop', $attrib['id']);
+ $OUTPUT->set_env('filedrop', array('action' => 'upload-photo', 'fieldname' => '_photo', 'single' => 1, 'filter' => '^image/.+'));
+ }
+}
+
+
$OUTPUT->add_handlers(array(
'contactedithead' => 'rcmail_contact_edithead',
'contacteditform' => 'rcmail_contact_editform',
'contactphoto' => 'rcmail_contact_photo',
'photouploadform' => 'rcmail_upload_photo_form',
'sourceselector' => 'rcmail_source_selector',
+ 'filedroparea' => 'rcmail_photo_drop_area',
));
if ($RCMAIL->action == 'add' && $OUTPUT->template_exists('contactadd'))
diff --git a/program/steps/addressbook/func.inc b/program/steps/addressbook/func.inc
index 80d89b001..5f5fcc673 100644
--- a/program/steps/addressbook/func.inc
+++ b/program/steps/addressbook/func.inc
@@ -368,7 +368,7 @@ function rcmail_contact_frame($attrib)
$attrib['name'] = $attrib['id'];
$OUTPUT->set_env('contentframe', $attrib['name']);
- $OUTPUT->set_env('blankpage', $attrib['src'] ? $OUTPUT->abs_url($attrib['src']) : 'program/blank.gif');
+ $OUTPUT->set_env('blankpage', $attrib['src'] ? $OUTPUT->abs_url($attrib['src']) : 'program/resources/blank.gif');
return html::iframe($attrib);
}
@@ -580,8 +580,13 @@ function rcmail_contact_form($form, $record, $attrib = null)
if (empty($values) && $colprop['visible'])
$values[] = '';
+ if (!is_array($values)) {
+ // $values can be an object, don't use (array)$values syntax
+ $values = !empty($values) ? array($values) : array();
+ }
+
$rows = '';
- foreach ((array)$values as $i => $val) {
+ foreach ($values as $i => $val) {
if ($subtypes[$i])
$subtype = $subtypes[$i];
@@ -705,11 +710,15 @@ function rcmail_contact_photo($attrib)
if ($result = $CONTACTS->get_result())
$record = $result->first();
- $photo_img = $attrib['placeholder'] ? $CONFIG['skin_path'] . $attrib['placeholder'] : 'program/blank.gif';
+ $photo_img = $attrib['placeholder'] ? $CONFIG['skin_path'] . $attrib['placeholder'] : 'program/resources/blank.gif';
$RCMAIL->output->set_env('photo_placeholder', $photo_img);
unset($attrib['placeholder']);
- if (preg_match('!^https?://!i', $record['photo']))
+ $plugin = $RCMAIL->plugins->exec_hook('contact_photo', array('record' => $record, 'data' => $record['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));
diff --git a/program/steps/addressbook/list.inc b/program/steps/addressbook/list.inc
index a24fb9520..06a1e10a3 100644
--- a/program/steps/addressbook/list.inc
+++ b/program/steps/addressbook/list.inc
@@ -19,6 +19,8 @@
+-----------------------------------------------------------------------+
*/
+$afields = $RCMAIL->config->get('contactlist_fields');
+
// Use search result
if (!empty($_REQUEST['_search']) && isset($_SESSION['search'][$_REQUEST['_search']]))
{
@@ -43,7 +45,7 @@ if (!empty($_REQUEST['_search']) && isset($_SESSION['search'][$_REQUEST['_search
$source->set_search_set($set);
// get records
- $result = $source->list_records(array('name', 'firstname', 'surname', 'email'));
+ $result = $source->list_records($afields);
while ($row = $result->next()) {
$row['sourceid'] = $s;
@@ -73,7 +75,7 @@ else {
$CONTACTS = rcmail_contact_source(null, true);
// get contacts for this user
- $result = $CONTACTS->list_records(array('name', 'firstname', 'surname', 'email'));
+ $result = $CONTACTS->list_records($afields);
if (!$result->count && $result->searchonly) {
$OUTPUT->show_message('contactsearchonly', 'notice');
diff --git a/program/steps/addressbook/search.inc b/program/steps/addressbook/search.inc
index f83eb9fd6..d31e54b1a 100644
--- a/program/steps/addressbook/search.inc
+++ b/program/steps/addressbook/search.inc
@@ -145,6 +145,7 @@ function rcmail_contact_search()
$search_set = array();
$records = array();
$sort_col = $RCMAIL->config->get('addressbook_sort_col', 'name');
+ $afields = $RCMAIL->config->get('contactlist_fields');
foreach ($sources as $s) {
$source = $RCMAIL->get_address_book($s['id']);
@@ -179,7 +180,7 @@ function rcmail_contact_search()
}
// get records
- $result = $source->list_records(array('name', 'firstname', 'surname', 'email'));
+ $result = $source->list_records($afields);
while ($row = $result->next()) {
$row['sourceid'] = $s['id'];
diff --git a/program/steps/addressbook/show.inc b/program/steps/addressbook/show.inc
index e5ff0d73e..48e37256d 100644
--- a/program/steps/addressbook/show.inc
+++ b/program/steps/addressbook/show.inc
@@ -22,7 +22,7 @@
// Get contact ID and source ID from request
$cids = rcmail_get_cids();
$source = key($cids);
-$cid = array_shift($cids[$source]);
+$cid = $cids ? array_shift($cids[$source]) : null;
// Initialize addressbook source
$CONTACTS = rcmail_contact_source($source, true);
@@ -39,6 +39,19 @@ 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']) {
@@ -54,8 +67,25 @@ if ($RCMAIL->action == 'photo') {
$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/blank.gif');
+ echo $data ? $data : file_get_contents('program/resources/blank.gif');
exit;
}