source: github/program/steps/addressbook/edit.inc @ 8e3a603

HEADcourier-fixdev-browser-capabilitiespdorelease-0.6release-0.7release-0.8
Last change on this file since 8e3a603 was 8e3a603, checked in by thomascube <thomas@…>, 3 years ago

Assign newly created contacts to the active group (#1486626) and fix group selection display (#1486619)

  • Property mode set to 100644
File size: 3.7 KB
Line 
1<?php
2
3/*
4 +-----------------------------------------------------------------------+
5 | program/steps/addressbook/edit.inc                                    |
6 |                                                                       |
7 | This file is part of the RoundCube Webmail client                     |
8 | Copyright (C) 2005-2007, RoundCube Dev. - Switzerland                 |
9 | Licensed under the GNU GPL                                            |
10 |                                                                       |
11 | PURPOSE:                                                              |
12 |   Show edit form for a contact entry or to add a new one              |
13 |                                                                       |
14 +-----------------------------------------------------------------------+
15 | Author: Thomas Bruederli <roundcube@gmail.com>                        |
16 +-----------------------------------------------------------------------+
17
18 $Id$
19
20*/
21
22
23if (($cid = get_input_value('_cid', RCUBE_INPUT_GPC)) && ($record = $CONTACTS->get_record($cid, true)))
24  $OUTPUT->set_env('cid', $record['ID']);
25
26// adding not allowed here
27if ($CONTACTS->readonly)
28{
29  $OUTPUT->show_message('sourceisreadonly');
30  rcmail_overwrite_action('show');
31  return;
32}
33
34function rcmail_contact_editform($attrib)
35{
36  global $RCMAIL, $CONTACTS, $OUTPUT;
37
38  // check if we have a valid result
39  if ($RCMAIL->action != 'add' && !(($result = $CONTACTS->get_result()) && ($record = $result->first())))
40  {
41    $OUTPUT->show_message('contactnotfound');
42    return false;
43  }
44
45  // add some labels to client
46  $OUTPUT->add_label('noemailwarning', 'nonamewarning');
47
48  list($form_start, $form_end) = get_form_tags($attrib);
49  unset($attrib['form']);
50
51  // a specific part is requested
52  if ($attrib['part'])
53  {
54    $out = $form_start;
55    $out .= rcmail_get_edit_field($attrib['part'], $record[$attrib['part']], $attrib);
56    return $out;
57  }
58
59
60  // return the complete address edit form as table
61  $out = "$form_start<table>\n\n";
62
63  $a_show_cols = array('name', 'firstname', 'surname', 'email');
64  foreach ($a_show_cols as $col)
65  {
66    $attrib['id'] = 'rcmfd_'.$col;
67    $value = rcmail_get_edit_field($col, $record[$col], $attrib);
68    $out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n",
69                    $attrib['id'],
70                    Q(rcube_label($col)),
71                    $value);
72  }
73
74  $out .= "\n</table>$form_end";
75
76  return $out; 
77}
78
79$OUTPUT->add_handler('contacteditform', 'rcmail_contact_editform');
80
81
82// similar function as in /steps/settings/edit_identity.inc
83function get_form_tags($attrib)
84{
85  global $CONTACTS, $EDIT_FORM, $RCMAIL;
86
87  $form_start = $form_end = '';
88 
89  if (empty($EDIT_FORM)) {
90    $hiddenfields = new html_hiddenfield(array('name' => '_source', 'value' => get_input_value('_source', RCUBE_INPUT_GPC)));
91    $hiddenfields->add(array('name' => '_gid', 'value' => $CONTACTS->group_id));
92   
93    if (($result = $CONTACTS->get_result()) && ($record = $result->first()))
94      $hiddenfields->add(array('name' => '_cid', 'value' => $record['ID']));
95   
96    $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());
97    $form_end = !strlen($attrib['form']) ? '</form>' : '';
98
99    $EDIT_FORM = !empty($attrib['form']) ? $attrib['form'] : 'form';
100    $RCMAIL->output->add_gui_object('editform', $EDIT_FORM);
101  }
102
103  return array($form_start, $form_end);
104}
105
106
107
108if (!$CONTACTS->get_result() && $OUTPUT->template_exists('addcontact'))
109  $OUTPUT->send('addcontact');
110
111// this will be executed if no template for addcontact exists
112$OUTPUT->send('editcontact');
113?>
Note: See TracBrowser for help on using the repository browser.