summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--program/js/app.js72
-rw-r--r--program/steps/addressbook/func.inc45
2 files changed, 67 insertions, 50 deletions
diff --git a/program/js/app.js b/program/js/app.js
index ec683e46a..263355643 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -324,22 +324,9 @@ function rcube_webmail()
}
}
- if ((this.env.action=='add' || this.env.action=='edit') && this.gui_objects.editform) {
+ if ((this.env.action == 'add' || this.env.action == 'edit') && this.gui_objects.editform) {
this.enable_command('save', true);
- this.enable_command('upload-photo', this.env.coltypes.photo ? true : false);
- this.enable_command('delete-photo', this.env.coltypes.photo && this.env.action == 'edit');
-
- for (var col in this.env.coltypes)
- this.init_edit_field(col, null);
-
- $('.contactfieldgroup .row a.deletebutton').click(function(){ ref.delete_edit_field(this); return false });
-
- $('select.addfieldmenu').change(function(e){
- ref.insert_edit_field($(this).val(), $(this).attr('rel'), this);
- this.selectedIndex = 0;
- });
-
- $("input[type='text']:visible").first().focus();
+ this.init_contact_form();
}
else if (this.gui_objects.qsearchbox) {
this.enable_command('search', 'reset-search', 'moveto', true);
@@ -356,14 +343,14 @@ function rcube_webmail()
case 'settings':
this.enable_command('preferences', 'identities', 'save', 'folders', true);
- if (this.env.action=='identities') {
+ if (this.env.action == 'identities') {
this.enable_command('add', this.env.identities_level < 2);
}
- else if (this.env.action=='edit-identity' || this.env.action=='add-identity') {
+ else if (this.env.action == 'edit-identity' || this.env.action == 'add-identity') {
this.enable_command('add', this.env.identities_level < 2);
this.enable_command('save', 'delete', 'edit', 'toggle-editor', true);
}
- else if (this.env.action=='folders') {
+ else if (this.env.action == 'folders') {
this.enable_command('subscribe', 'unsubscribe', 'create-folder', 'rename-folder', true);
}
else if (this.env.action == 'edit-folder' && this.gui_objects.editform) {
@@ -3598,7 +3585,7 @@ function rcube_webmail()
if (this.ksearch_pane)
this.ksearch_pane.hide();
- };
+ };
/*********************************************************/
@@ -3840,6 +3827,28 @@ function rcube_webmail()
this.enable_command('export', (this.contact_list.rowcount > 0));
};
+ this.init_contact_form = function()
+ {
+ var ref = this, col;
+
+ this.set_photo_actions($('#ff_photo').val());
+
+ for (col in this.env.coltypes)
+ this.init_edit_field(col, null);
+
+ $('.contactfieldgroup .row a.deletebutton').click(function() {
+ ref.delete_edit_field(this);
+ return false;
+ });
+
+ $('select.addfieldmenu').change(function(e) {
+ ref.insert_edit_field($(this).val(), $(this).attr('rel'), this);
+ this.selectedIndex = 0;
+ });
+
+ $("input[type='text']:visible").first().focus();
+ };
+
this.group_create = function()
{
if (!this.gui_objects.folderlist || !this.env.address_sources[this.env.source].groups)
@@ -4136,28 +4145,33 @@ function rcube_webmail()
this.photo_upload_id = this.set_busy(true, 'uploading');
}
};
-
+
this.replace_contact_photo = function(id)
{
- $('#ff_photo').val(id);
-
- var buttons = this.buttons['upload-photo'];
- for (var n=0; n < buttons.length; n++)
- $('#'+buttons[n].id).html(this.get_label(id == '-del-' ? 'addphoto' : 'replacephoto'));
-
var img_src = id == '-del-' ? this.env.photo_placeholder :
this.env.comm_path + '&_action=photo&_source=' + this.env.source + '&_cid=' + this.env.cid + '&_photo=' + id;
+
+ this.set_photo_actions(id);
$(this.gui_objects.contactphoto).children('img').attr('src', img_src);
-
- this.enable_command('delete-photo', id != '-del-');
};
-
+
this.photo_upload_end = function()
{
this.set_busy(false, null, this.photo_upload_id);
delete this.photo_upload_id;
};
+ this.set_photo_actions = function(id)
+ {
+ var n, buttons = this.buttons['upload-photo'];
+ for (n=0; n < buttons.length; n++)
+ $('#'+buttons[n].id).html(this.get_label(id == '-del-' ? 'addphoto' : 'replacephoto'));
+
+ $('#ff_photo').val(id);
+ this.enable_command('upload-photo', this.env.coltypes.photo ? true : false);
+ this.enable_command('delete-photo', this.env.coltypes.photo && id != '-del-');
+ };
+
/*********************************************************/
/********* user settings methods *********/
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;
}