- Plugin API: added 'contact_form' hook
- Re-designed contact frame using Tabs
| | |
| | | - Add support for selection options from LIST-EXTENDED extension (RFC 5258) |
| | | - Don't list subscribed but non-existent folders (#1486225) |
| | | - Fix handling of URLs with tilde (~) or semicolon (;) character (#1487087, #1487088) |
| | | - Plugin API: added 'contact_form' hook |
| | | |
| | | RELEASE 0.4.2 |
| | | ------------- |
| | |
| | | $OUTPUT->set_env('cid', $record['ID']); |
| | | |
| | | // adding not allowed here |
| | | if ($CONTACTS->readonly) |
| | | { |
| | | if ($CONTACTS->readonly) { |
| | | $OUTPUT->show_message('sourceisreadonly'); |
| | | rcmail_overwrite_action('show'); |
| | | return; |
| | | } |
| | | |
| | | |
| | | function rcmail_contact_editform($attrib) |
| | | { |
| | | global $RCMAIL, $CONTACTS, $OUTPUT; |
| | | |
| | | // check if we have a valid result |
| | | if ($RCMAIL->action != 'add' && !(($result = $CONTACTS->get_result()) && ($record = $result->first()))) |
| | | { |
| | | if ($RCMAIL->action != 'add' |
| | | && !(($result = $CONTACTS->get_result()) && ($record = $result->first())) |
| | | ) { |
| | | $OUTPUT->show_message('contactnotfound'); |
| | | return false; |
| | | } |
| | |
| | | // add some labels to client |
| | | $OUTPUT->add_label('noemailwarning', 'nonamewarning'); |
| | | |
| | | $i_size = !empty($attrib['size']) ? $attrib['size'] : 40; |
| | | $t_rows = !empty($attrib['textarearows']) ? $attrib['textarearows'] : 6; |
| | | $t_cols = !empty($attrib['textareacols']) ? $attrib['textareacols'] : 40; |
| | | |
| | | $form = array( |
| | | 'info' => array( |
| | | 'name' => rcube_label('contactproperties'), |
| | | 'content' => array( |
| | | 'name' => array('type' => 'text', 'size' => $i_size), |
| | | 'firstname' => array('type' => 'text', 'size' => $i_size), |
| | | 'surname' => array('type' => 'text', 'size' => $i_size), |
| | | 'email' => array('type' => 'text', 'size' => $i_size), |
| | | ), |
| | | ), |
| | | ); |
| | | |
| | | |
| | | list($form_start, $form_end) = get_form_tags($attrib); |
| | | unset($attrib['form']); |
| | | |
| | | // a specific part is requested |
| | | if ($attrib['part']) |
| | | { |
| | | $out = $form_start; |
| | | $out .= rcmail_get_edit_field($attrib['part'], $record[$attrib['part']], $attrib); |
| | | return $out; |
| | | } |
| | | |
| | | |
| | | // return the complete address edit form as table |
| | | $out = "$form_start<table>\n\n"; |
| | | $out = rcmail_contact_form($form, $record); |
| | | |
| | | $a_show_cols = array('name', 'firstname', 'surname', 'email'); |
| | | foreach ($a_show_cols as $col) |
| | | { |
| | | $attrib['id'] = 'rcmfd_'.$col; |
| | | $value = rcmail_get_edit_field($col, $record[$col], $attrib); |
| | | $out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n", |
| | | $attrib['id'], |
| | | Q(rcube_label($col)), |
| | | $value); |
| | | return $form_start . $out . $form_end; |
| | | } |
| | | |
| | | $out .= "\n</table>$form_end"; |
| | | |
| | | return $out; |
| | | } |
| | | |
| | | $OUTPUT->add_handler('contacteditform', 'rcmail_contact_editform'); |
| | | |
| | | |
| | | // similar function as in /steps/settings/edit_identity.inc |
| | |
| | | $form_start = $form_end = ''; |
| | | |
| | | if (empty($EDIT_FORM)) { |
| | | $hiddenfields = new html_hiddenfield(array('name' => '_source', 'value' => get_input_value('_source', RCUBE_INPUT_GPC))); |
| | | $hiddenfields = new html_hiddenfield(array( |
| | | 'name' => '_source', 'value' => get_input_value('_source', RCUBE_INPUT_GPC))); |
| | | $hiddenfields->add(array('name' => '_gid', 'value' => $CONTACTS->group_id)); |
| | | |
| | | if (($result = $CONTACTS->get_result()) && ($record = $result->first())) |
| | | $hiddenfields->add(array('name' => '_cid', 'value' => $record['ID'])); |
| | | |
| | | $form_start = $RCMAIL->output->request_form(array('name' => "form", 'method' => "post", 'task' => $RCMAIL->task, 'action' => 'save', 'request' => 'save.'.intval($record['ID']), 'noclose' => true) + $attrib, $hiddenfields->show()); |
| | | $form_start = $RCMAIL->output->request_form(array( |
| | | 'name' => "form", 'method' => "post", |
| | | 'task' => $RCMAIL->task, 'action' => 'save', |
| | | 'request' => 'save.'.intval($record['ID']), |
| | | 'noclose' => true) + $attrib, $hiddenfields->show()); |
| | | $form_end = !strlen($attrib['form']) ? '</form>' : ''; |
| | | |
| | | $EDIT_FORM = !empty($attrib['form']) ? $attrib['form'] : 'form'; |
| | |
| | | } |
| | | |
| | | |
| | | $OUTPUT->add_handler('contacteditform', 'rcmail_contact_editform'); |
| | | |
| | | if (!$CONTACTS->get_result() && $OUTPUT->template_exists('addcontact')) |
| | | $OUTPUT->send('addcontact'); |
| | | |
| | | // this will be executed if no template for addcontact exists |
| | | $OUTPUT->send('editcontact'); |
| | | |
| | |
| | | $OUTPUT->set_pagetitle(rcube_label('addressbook')); |
| | | } |
| | | |
| | | |
| | | function rcmail_directory_list($attrib) |
| | | { |
| | | global $RCMAIL, $OUTPUT; |
| | |
| | | $local_id = '0'; |
| | | $jsdata = array(); |
| | | $current = get_input_value('_source', RCUBE_INPUT_GPC); |
| | | $line_templ = html::tag('li', array('id' => 'rcmli%s', 'class' => 'addressbook %s'), |
| | | html::a(array('href' => '%s', 'onclick' => "return ".JS_OBJECT_NAME.".command('list','%s',this)"), '%s')); |
| | | $line_templ = html::tag('li', array( |
| | | 'id' => 'rcmli%s', 'class' => 'addressbook %s'), |
| | | html::a(array('href' => '%s', |
| | | 'onclick' => "return ".JS_OBJECT_NAME.".command('list','%s',this)"), '%s')); |
| | | |
| | | if (!$current && strtolower($RCMAIL->config->get('address_book_type', 'sql')) != 'ldap') { |
| | | $current = '0'; |
| | |
| | | $js_id = JQ($id); |
| | | $dom_id = preg_replace('/[^a-z0-9\-_]/i', '', $id); |
| | | $out .= sprintf($line_templ, $dom_id, ($current == $id ? 'selected' : ''), |
| | | Q(rcmail_url(null, array('_source' => $id))), $js_id, (!empty($source['name']) ? Q($source['name']) : Q($id))); |
| | | Q(rcmail_url(null, array('_source' => $id))), |
| | | $js_id, (!empty($source['name']) ? Q($source['name']) : Q($id))); |
| | | $groupdata = rcmail_contact_groups(array('out' => $out, 'jsdata' => $jsdata, 'source' => $id)); |
| | | $jsdata = $groupdata['jsdata']; |
| | | $out = $groupdata['out']; |
| | |
| | | $groups = $RCMAIL->get_address_book($args['source'])->list_groups(); |
| | | |
| | | if (!empty($groups)) { |
| | | $line_templ = html::tag('li', array('id' => 'rcmliG%s%s', 'class' => 'contactgroup'), |
| | | html::a(array('href' => '#', 'onclick' => "return ".JS_OBJECT_NAME.".command('listgroup',{'source':'%s','id':'%s'},this)"), '%s')); |
| | | $line_templ = html::tag('li', array( |
| | | 'id' => 'rcmliG%s%s', 'class' => 'contactgroup'), |
| | | html::a(array('href' => '#', |
| | | 'onclick' => "return ".JS_OBJECT_NAME.".command('listgroup',{'source':'%s','id':'%s'},this)"), '%s')); |
| | | |
| | | $jsdata = array(); |
| | | foreach ($groups as $group) { |
| | | $args['out'] .= sprintf($line_templ, $args['source'], $group['ID'], $args['source'], $group['ID'], Q($group['name'])); |
| | | $args['jsdata']['G'.$args['source'].$group['ID']] = array( |
| | | 'source' => $args['source'], 'id' => $group['ID'], 'name' => $group['name'], 'type' => 'group'); |
| | | 'source' => $args['source'], 'id' => $group['ID'], |
| | | 'name' => $group['name'], 'type' => 'group'); |
| | | } |
| | | } |
| | | |
| | |
| | | // define list of cols to be displayed |
| | | $a_show_cols = array('name'); |
| | | |
| | | while ($row = $result->next()) |
| | | { |
| | | while ($row = $result->next()) { |
| | | $a_row_cols = array(); |
| | | |
| | | // format each col |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | function rcmail_get_rowcount_text() |
| | | { |
| | | global $CONTACTS; |
| | | |
| | | // read nr of contacts |
| | | $result = $CONTACTS->get_result(); |
| | | if (!$result) |
| | | if (!$result) { |
| | | $result = $CONTACTS->count(); |
| | | } |
| | | |
| | | if ($result->count == 0) |
| | | $out = rcube_label('nocontactsfound'); |
| | |
| | | return $out; |
| | | } |
| | | |
| | | |
| | | function rcmail_contact_form($form, $record) |
| | | { |
| | | global $RCMAIL; |
| | | |
| | | // Allow plugins to modify contact form content |
| | | $plugin = $RCMAIL->plugins->exec_hook('contact_form', array( |
| | | 'form' => $form, 'record' => $record)); |
| | | |
| | | $form = $plugin['form']; |
| | | $record = $plugin['record']; |
| | | $out = ''; |
| | | |
| | | foreach ($form as $fieldset) { |
| | | if (empty($fieldset['content'])) |
| | | continue; |
| | | |
| | | $content = ''; |
| | | if (is_array($fieldset['content'])) { |
| | | $table = new html_table(array('cols' => 2)); |
| | | |
| | | foreach ($fieldset['content'] as $col => $colprop) { |
| | | $colprop['id'] = 'rcmfd_'.$col; |
| | | |
| | | $label = !empty($colprop['label']) ? $colprop['label'] : rcube_label($col); |
| | | |
| | | if (!empty($colprop['value'])) { |
| | | $value = $colprop['value']; |
| | | } |
| | | else if ($RCMAIL->action == 'show') { |
| | | $value = $record[$col]; |
| | | } |
| | | else { |
| | | $value = rcmail_get_edit_field($col, $record[$col], $colprop, $colprop['type']); |
| | | } |
| | | |
| | | $table->add('title', sprintf('<label for="%s">%s</label>', $colprop['id'], Q($label))); |
| | | $table->add(null, $value); |
| | | } |
| | | $content = $table->show(); |
| | | } |
| | | else { |
| | | $content = $fieldset['content']; |
| | | } |
| | | |
| | | $out .= html::tag('fieldset', null, html::tag('legend', null, Q($fieldset['name'])) . $content) ."\n"; |
| | | } |
| | | |
| | | return $out; |
| | | } |
| | | |
| | | |
| | | // register UI objects |
| | | $OUTPUT->add_handlers(array( |
| | | 'directorylist' => 'rcmail_directory_list', |
| | |
| | | 'recordscountdisplay' => 'rcmail_rowcount_display', |
| | | 'searchform' => array($OUTPUT, 'search_form') |
| | | )); |
| | | |
| | |
| | | $OUTPUT->set_env('cid', $record['ID']); |
| | | } |
| | | |
| | | $GROUPS = $CONTACTS->list_groups(); |
| | | $OUTPUT->set_env('groups', !empty($GROUPS)); |
| | | |
| | | |
| | | function rcmail_contact_details($attrib) |
| | | { |
| | | global $CONTACTS, $OUTPUT; |
| | | global $CONTACTS, $RCMAIL; |
| | | |
| | | // check if we have a valid result |
| | | if (!(($result = $CONTACTS->get_result()) && ($record = $result->first()))) { |
| | | $OUTPUT->show_message('contactnotfound'); |
| | | $RCMAIL->output->show_message('contactnotfound'); |
| | | return false; |
| | | } |
| | | |
| | | // a specific part is requested |
| | | if ($attrib['part']) { |
| | | return Q($record[$attrib['part']]); |
| | | } |
| | | $i_size = !empty($attrib['size']) ? $attrib['size'] : 40; |
| | | $t_rows = !empty($attrib['textarearows']) ? $attrib['textarearows'] : 6; |
| | | $t_cols = !empty($attrib['textareacols']) ? $attrib['textareacols'] : 40; |
| | | |
| | | // return the complete address record as table |
| | | $table = new html_table(array('cols' => 2)); |
| | | |
| | | $a_show_cols = array('name', 'firstname', 'surname', 'email'); |
| | | $microformats = array('name' => 'fn', 'email' => 'email'); |
| | | |
| | | foreach ($a_show_cols as $col) { |
| | | if ($col == 'email' && !empty($record[$col])) { |
| | | $value = html::a(array( |
| | | 'href' => 'mailto:' . $record[$col], |
| | | 'onclick' => sprintf("return %s.command('compose','%s',this)", JS_OBJECT_NAME, JQ($record[$col])), |
| | | $form = array( |
| | | 'info' => array( |
| | | 'name' => rcube_label('contactproperties'), |
| | | 'content' => array( |
| | | 'name' => array('type' => 'text', 'size' => $i_size), |
| | | 'firstname' => array('type' => 'text', 'size' => $i_size), |
| | | 'surname' => array('type' => 'text', 'size' => $i_size), |
| | | 'email' => array('type' => 'text', 'size' => $i_size), |
| | | ), |
| | | ), |
| | | 'groups' => array( |
| | | 'name' => rcube_label('groups'), |
| | | 'content' => '', |
| | | ), |
| | | ); |
| | | |
| | | // Get content of groups fieldset |
| | | if ($groups = rcmail_contact_record_groups($record['ID'])) { |
| | | $form['groups']['content'] = $groups; |
| | | } |
| | | else { |
| | | unset($form['groups']); |
| | | } |
| | | |
| | | if (!empty($record['email'])) { |
| | | $form['info']['content']['email']['value'] = html::a(array( |
| | | 'href' => 'mailto:' . $record['email'], |
| | | 'onclick' => sprintf("return %s.command('compose','%s',this)", JS_OBJECT_NAME, JQ($record['email'])), |
| | | 'title' => rcube_label('composeto'), |
| | | 'class' => $microformats[$col], |
| | | ), Q($record[$col])); |
| | | 'class' => $microformats['email'], |
| | | ), Q($record['email'])); |
| | | } |
| | | else if (!empty($record[$col])) { |
| | | $value = html::span($microformats[$col], Q($record[$col])); |
| | | foreach (array('name', 'firstname', 'surname') as $col) { |
| | | if ($record[$col]) { |
| | | $form['info']['content'][$col]['value'] = html::span($microformats[$col], Q($record[$col])); |
| | | } |
| | | else |
| | | $value = ''; |
| | | |
| | | $table->add('title', Q(rcube_label($col))); |
| | | $table->add(null, $value); |
| | | } |
| | | |
| | | return $table->show($attrib + array('class' => 'vcard')); |
| | | return rcmail_contact_form($form, $record); |
| | | } |
| | | |
| | | |
| | | function rcmail_contact_record_groups($attrib) |
| | | function rcmail_contact_record_groups($contact_id) |
| | | { |
| | | global $RCMAIL, $CONTACTS, $GROUPS; |
| | | |
| | | // check if we have a valid result |
| | | if (!(($result = $CONTACTS->get_result()) && ($record = $result->first()))) |
| | | return false; |
| | | $GROUPS = $CONTACTS->list_groups(); |
| | | |
| | | if (empty($GROUPS)) { |
| | | return ''; |
| | | } |
| | | |
| | | $table = new html_table(array('cols' => 2, 'cellspacing' => 0, 'border' => 0)); |
| | | |
| | | $members = $CONTACTS->get_record_groups($record['ID']); |
| | | $checkbox = new html_checkbox(array('name' => '_gid[]', 'class' => 'groupmember', 'disabled' => $CONTACTS->readonly)); |
| | | $members = $CONTACTS->get_record_groups($contact_id); |
| | | $checkbox = new html_checkbox(array('name' => '_gid[]', |
| | | 'class' => 'groupmember', 'disabled' => $CONTACTS->readonly)); |
| | | |
| | | foreach ($GROUPS as $group) { |
| | | $gid = $group['ID']; |
| | | $table->add(null, $checkbox->show($members[$gid] ? $gid : null, array('value' => $gid, 'id' => 'ff_gid' . $gid))); |
| | | $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'])); |
| | | |
| | | $form_start = $RCMAIL->output->request_form(array('name' => "form", 'method' => "post", 'task' => $RCMAIL->task, 'action' => 'save', 'request' => 'save.'.intval($record['ID']), 'noclose' => true) + $attrib, $hiddenfields->show()); |
| | | $form_end = !strlen($attrib['form']) ? '</form>' : ''; |
| | | $form_start = $RCMAIL->output->request_form(array( |
| | | 'name' => "form", 'method' => "post", |
| | | 'task' => $RCMAIL->task, 'action' => 'save', |
| | | 'request' => 'save.'.intval($contact_id), |
| | | 'noclose' => true), $hiddenfields->show()); |
| | | $form_end = '</form>'; |
| | | |
| | | $RCMAIL->output->add_gui_object('editform', !empty($attrib['form']) ? $attrib['form'] : 'form'); |
| | | $RCMAIL->output->add_gui_object('editform', 'form'); |
| | | |
| | | return $form_start . $table->show($attrib) . $form_end; |
| | | return $form_start . $table->show() . $form_end; |
| | | } |
| | | |
| | | |
| | | //$OUTPUT->framed = $_framed; |
| | | $OUTPUT->add_handler('contactdetails', 'rcmail_contact_details'); |
| | | $OUTPUT->add_handler('contactgroups', 'rcmail_contact_record_groups'); |
| | | |
| | | $OUTPUT->send('showcontact'); |
| | |
| | | <head> |
| | | <title><roundcube:object name="pagetitle" /></title> |
| | | <roundcube:include file="/includes/links.html" /> |
| | | <script type="text/javascript" src="/functions.js"></script> |
| | | </head> |
| | | <body class="iframe"> |
| | | |
| | | <div id="contact-title" class="boxtitle"><roundcube:label name="addcontact" /></div> |
| | | |
| | | <div id="contact-details" class="boxcontent"> |
| | | <roundcube:object name="contacteditform" size="40" /> |
| | | |
| | | <p><br /> |
| | | <p> |
| | | <input type="button" value="<roundcube:label name="cancel" />" class="button" onclick="history.back()" /> |
| | | <roundcube:button command="save" type="input" class="button mainaction" label="save" /> |
| | | </p> |
| | | |
| | | </form> |
| | | </div> |
| | | <script type="text/javascript">rcube_init_tabs('contact-details')</script> |
| | | |
| | | </body> |
| | | </html> |
| | |
| | | <head> |
| | | <title><roundcube:object name="pagetitle" /></title> |
| | | <roundcube:include file="/includes/links.html" /> |
| | | <script type="text/javascript" src="/functions.js"></script> |
| | | </head> |
| | | <body class="iframe"> |
| | | |
| | | <div id="contact-title" class="boxtitle"><roundcube:label name="editcontact" /></div> |
| | | |
| | | <div id="contact-details" class="boxcontent"> |
| | | <roundcube:object name="contacteditform" size="40" /> |
| | | |
| | | <p><br /> |
| | | <p> |
| | | <roundcube:button command="show" type="input" class="button" label="cancel" /> |
| | | <roundcube:button command="save" type="input" class="button mainaction" label="save" /> |
| | | </p> |
| | | |
| | | </form> |
| | | </div> |
| | | <script type="text/javascript">rcube_init_tabs('contact-details')</script> |
| | | |
| | | </body> |
| | | </html> |
| | |
| | | <head> |
| | | <title><roundcube:object name="pagetitle" /></title> |
| | | <roundcube:include file="/includes/links.html" /> |
| | | <script type="text/javascript" src="/functions.js"></script> |
| | | </head> |
| | | <body class="iframe"> |
| | | |
| | | <div id="contact-title" class="boxtitle"><roundcube:object name="contactdetails" part="name" /></div> |
| | | |
| | | <div id="contact-title" class="boxtitle"><roundcube:label name="contactproperties" /></div> |
| | | <div id="contact-details" class="boxcontent"> |
| | | <fieldset> |
| | | <legend><roundcube:label name="contactproperties" /></legend> |
| | | <roundcube:object name="contactdetails" /> |
| | | |
| | | <p><br /><roundcube:button command="edit" type="input" class="button" label="editcontact" condition="!ENV:readonly" /></p> |
| | | </fieldset> |
| | | |
| | | <roundcube:if condition="ENV:groups" /> |
| | | <fieldset> |
| | | <legend><roundcube:label name="groups" /></legend> |
| | | <roundcube:object name="contactgroups" /> |
| | | </fieldset> |
| | | <roundcube:endif /> |
| | | |
| | | <p> |
| | | <roundcube:button command="edit" type="input" class="button" label="editcontact" condition="!ENV:readonly" /> |
| | | </p> |
| | | </div> |
| | | <script type="text/javascript">rcube_init_tabs('contact-details')</script> |
| | | |
| | | </body> |
| | | </html> |