summaryrefslogtreecommitdiff
path: root/program/steps/addressbook/func.inc
diff options
context:
space:
mode:
authoralecpl <alec@alec.pl>2011-04-27 09:43:10 +0000
committeralecpl <alec@alec.pl>2011-04-27 09:43:10 +0000
commite505519d1a88687ef5272ba8b13476e9feeca203 (patch)
treef6515a29c005f31df092fdbb376b8d19ef9704f4 /program/steps/addressbook/func.inc
parent5852db96d7c19cf94d5088ec939132431893bac8 (diff)
- Improve photo actions handling (set name of upload-photo, disable delete-photo according to photo existance), code cleanup
Diffstat (limited to 'program/steps/addressbook/func.inc')
-rw-r--r--program/steps/addressbook/func.inc45
1 files changed, 24 insertions, 21 deletions
diff --git a/program/steps/addressbook/func.inc b/program/steps/addressbook/func.inc
index ed87cb150..837256f89 100644
--- a/program/steps/addressbook/func.inc
+++ b/program/steps/addressbook/func.inc
@@ -557,31 +557,34 @@ function rcmail_contact_form($form, $record, $attrib = null)
function rcmail_contact_photo($attrib)
{
global $CONTACTS, $CONTACT_COLTYPES, $RCMAIL, $CONFIG;
-
+
+ if (!$CONTACT_COLTYPES['photo'])
+ return '';
+
if ($result = $CONTACTS->get_result())
$record = $result->first();
-
+
$photo_img = $attrib['placeholder'] ? $CONFIG['skin_path'] . $attrib['placeholder'] : 'program/blank.gif';
+ $RCMAIL->output->set_env('photo_placeholder', $photo_img);
unset($attrib['placeholder']);
-
- if ($CONTACT_COLTYPES['photo']) {
- $RCMAIL->output->set_env('photo_placeholder', $photo_img);
-
- if (strpos($record['photo'], 'http:') === 0)
- $photo_img = $record['photo'];
- else if ($record['photo'])
- $photo_img = $RCMAIL->url(array('_action' => 'photo', '_cid' => $record['ID'], '_source' => $_REQUEST['_source']));
- $img = html::img(array('src' => $photo_img, 'border' => 1, 'alt' => ''));
- $content = html::div($attrib, $img);
-
- if ($RCMAIL->action == 'edit' || $RCMAIL->action == 'add') {
- $RCMAIL->output->add_gui_object('contactphoto', $attrib['id']);
- $hidden = new html_hiddenfield(array('name' => '_photo', 'id' => 'ff_photo'));
- $content .= $hidden->show();
- }
- }
-
- return $content;
+
+ if (strpos($record['photo'], 'http:') === 0)
+ $photo_img = $record['photo'];
+ else if ($record['photo'])
+ $photo_img = $RCMAIL->url(array('_action' => 'photo', '_cid' => $record['ID'], '_source' => $_REQUEST['_source']));
+ else
+ $ff_value = '-del-'; // will disable delete-photo action
+
+ $img = html::img(array('src' => $photo_img, 'border' => 1, 'alt' => ''));
+ $content = html::div($attrib, $img);
+
+ if ($RCMAIL->action == 'edit' || $RCMAIL->action == 'add') {
+ $RCMAIL->output->add_gui_object('contactphoto', $attrib['id']);
+ $hidden = new html_hiddenfield(array('name' => '_photo', 'id' => 'ff_photo', 'value' => $ff_value));
+ $content .= $hidden->show();
+ }
+
+ return $content;
}