Changeset a79417d in github
- Timestamp:
- Oct 28, 2010 3:10:11 AM (3 years ago)
- Branches:
- master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
- Children:
- 77327e2
- Parents:
- 022bcd1
- Files:
-
- 7 edited
-
CHANGELOG (modified) (1 diff)
-
program/steps/addressbook/edit.inc (modified) (2 diffs)
-
program/steps/addressbook/func.inc (modified) (4 diffs)
-
program/steps/addressbook/show.inc (modified) (2 diffs)
-
skins/default/templates/addcontact.html (modified) (1 diff)
-
skins/default/templates/editcontact.html (modified) (1 diff)
-
skins/default/templates/showcontact.html (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
CHANGELOG
rd21a05b ra79417d 53 53 - Don't list subscribed but non-existent folders (#1486225) 54 54 - Fix handling of URLs with tilde (~) or semicolon (;) character (#1487087, #1487088) 55 - Plugin API: added 'contact_form' hook 55 56 56 57 RELEASE 0.4.2 -
program/steps/addressbook/edit.inc
re019f2d ra79417d 22 22 23 23 if (($cid = get_input_value('_cid', RCUBE_INPUT_GPC)) && ($record = $CONTACTS->get_record($cid, true))) 24 $OUTPUT->set_env('cid', $record['ID']);24 $OUTPUT->set_env('cid', $record['ID']); 25 25 26 26 // adding not allowed here 27 if ($CONTACTS->readonly) 28 { 29 $OUTPUT->show_message('sourceisreadonly'); 30 rcmail_overwrite_action('show'); 31 return; 27 if ($CONTACTS->readonly) { 28 $OUTPUT->show_message('sourceisreadonly'); 29 rcmail_overwrite_action('show'); 30 return; 32 31 } 32 33 33 34 34 function rcmail_contact_editform($attrib) 35 35 { 36 global $RCMAIL, $CONTACTS, $OUTPUT;36 global $RCMAIL, $CONTACTS, $OUTPUT; 37 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 } 38 // check if we have a valid result 39 if ($RCMAIL->action != 'add' 40 && !(($result = $CONTACTS->get_result()) && ($record = $result->first())) 41 ) { 42 $OUTPUT->show_message('contactnotfound'); 43 return false; 44 } 44 45 45 // add some labels to client46 $OUTPUT->add_label('noemailwarning', 'nonamewarning');46 // add some labels to client 47 $OUTPUT->add_label('noemailwarning', 'nonamewarning'); 47 48 48 list($form_start, $form_end) = get_form_tags($attrib); 49 unset($attrib['form']); 49 $i_size = !empty($attrib['size']) ? $attrib['size'] : 40; 50 $t_rows = !empty($attrib['textarearows']) ? $attrib['textarearows'] : 6; 51 $t_cols = !empty($attrib['textareacols']) ? $attrib['textareacols'] : 40; 50 52 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 } 53 $form = array( 54 'info' => array( 55 'name' => rcube_label('contactproperties'), 56 'content' => array( 57 'name' => array('type' => 'text', 'size' => $i_size), 58 'firstname' => array('type' => 'text', 'size' => $i_size), 59 'surname' => array('type' => 'text', 'size' => $i_size), 60 'email' => array('type' => 'text', 'size' => $i_size), 61 ), 62 ), 63 ); 58 64 59 65 60 // return the complete address edit form as table61 $out = "$form_start<table>\n\n";66 list($form_start, $form_end) = get_form_tags($attrib); 67 unset($attrib['form']); 62 68 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 } 69 // return the complete address edit form as table 70 $out = rcmail_contact_form($form, $record); 73 71 74 $out .= "\n</table>$form_end"; 75 76 return $out; 72 return $form_start . $out . $form_end; 77 73 } 78 79 $OUTPUT->add_handler('contacteditform', 'rcmail_contact_editform');80 74 81 75 … … 83 77 function get_form_tags($attrib) 84 78 { 85 global $CONTACTS, $EDIT_FORM, $RCMAIL;79 global $CONTACTS, $EDIT_FORM, $RCMAIL; 86 80 87 $form_start = $form_end = '';81 $form_start = $form_end = ''; 88 82 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)); 83 if (empty($EDIT_FORM)) { 84 $hiddenfields = new html_hiddenfield(array( 85 'name' => '_source', 'value' => get_input_value('_source', RCUBE_INPUT_GPC))); 86 $hiddenfields->add(array('name' => '_gid', 'value' => $CONTACTS->group_id)); 92 87 93 if (($result = $CONTACTS->get_result()) && ($record = $result->first()))94 $hiddenfields->add(array('name' => '_cid', 'value' => $record['ID']));88 if (($result = $CONTACTS->get_result()) && ($record = $result->first())) 89 $hiddenfields->add(array('name' => '_cid', 'value' => $record['ID'])); 95 90 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>' : ''; 91 $form_start = $RCMAIL->output->request_form(array( 92 'name' => "form", 'method' => "post", 93 'task' => $RCMAIL->task, 'action' => 'save', 94 'request' => 'save.'.intval($record['ID']), 95 'noclose' => true) + $attrib, $hiddenfields->show()); 96 $form_end = !strlen($attrib['form']) ? '</form>' : ''; 98 97 99 $EDIT_FORM = !empty($attrib['form']) ? $attrib['form'] : 'form';100 $RCMAIL->output->add_gui_object('editform', $EDIT_FORM);101 }98 $EDIT_FORM = !empty($attrib['form']) ? $attrib['form'] : 'form'; 99 $RCMAIL->output->add_gui_object('editform', $EDIT_FORM); 100 } 102 101 103 return array($form_start, $form_end);102 return array($form_start, $form_end); 104 103 } 105 104 106 105 106 $OUTPUT->add_handler('contacteditform', 'rcmail_contact_editform'); 107 107 108 108 if (!$CONTACTS->get_result() && $OUTPUT->template_exists('addcontact')) 109 $OUTPUT->send('addcontact');109 $OUTPUT->send('addcontact'); 110 110 111 111 // this will be executed if no template for addcontact exists 112 112 $OUTPUT->send('editcontact'); 113 -
program/steps/addressbook/func.inc
re019f2d ra79417d 28 28 // if source is not set use first directory 29 29 if (empty($source)) 30 $source = $js_list[key($js_list)]['id'];30 $source = $js_list[key($js_list)]['id']; 31 31 32 32 // instantiate a contacts object according to the given source … … 37 37 // set list properties and session vars 38 38 if (!empty($_GET['_page'])) 39 $CONTACTS->set_page(($_SESSION['page'] = intval($_GET['_page'])));39 $CONTACTS->set_page(($_SESSION['page'] = intval($_GET['_page']))); 40 40 else 41 $CONTACTS->set_page(isset($_SESSION['page']) ?$_SESSION['page'] : 1);41 $CONTACTS->set_page(isset($_SESSION['page']) ?$_SESSION['page'] : 1); 42 42 43 43 if (!empty($_REQUEST['_gid'])) 44 $CONTACTS->set_group(get_input_value('_gid', RCUBE_INPUT_GPC));44 $CONTACTS->set_group(get_input_value('_gid', RCUBE_INPUT_GPC)); 45 45 46 46 // set message set for search result 47 47 if (!empty($_REQUEST['_search']) && isset($_SESSION['search'][$_REQUEST['_search']])) 48 $CONTACTS->set_search_set($_SESSION['search'][$_REQUEST['_search']]);48 $CONTACTS->set_search_set($_SESSION['search'][$_REQUEST['_search']]); 49 49 50 50 // set data source env 51 51 $OUTPUT->set_env('source', $source ? $source : '0'); 52 52 $OUTPUT->set_env('readonly', $CONTACTS->readonly, false); 53 if(! $OUTPUT->ajax_call) { 54 $OUTPUT->set_env('address_sources', $js_list); 55 $OUTPUT->set_pagetitle(rcube_label('addressbook')); 56 } 53 if (!$OUTPUT->ajax_call) { 54 $OUTPUT->set_env('address_sources', $js_list); 55 $OUTPUT->set_pagetitle(rcube_label('addressbook')); 56 } 57 57 58 58 59 function rcmail_directory_list($attrib) 59 60 { 60 global $RCMAIL, $OUTPUT; 61 62 if (!$attrib['id']) 63 $attrib['id'] = 'rcmdirectorylist'; 64 65 $out = ''; 66 $local_id = '0'; 67 $jsdata = array(); 68 $current = get_input_value('_source', RCUBE_INPUT_GPC); 69 $line_templ = html::tag('li', array('id' => 'rcmli%s', 'class' => 'addressbook %s'), 70 html::a(array('href' => '%s', 'onclick' => "return ".JS_OBJECT_NAME.".command('list','%s',this)"), '%s')); 71 72 if (!$current && strtolower($RCMAIL->config->get('address_book_type', 'sql')) != 'ldap') { 73 $current = '0'; 74 } 75 else if (!$current) { 76 // DB address book not used, see if a source is set, if not use the 77 // first LDAP directory. 78 $current = key((array)$RCMAIL->config->get('ldap_public', array())); 79 } 80 81 foreach ((array)$OUTPUT->env['address_sources'] as $j => $source) { 82 $id = $source['id'] ? $source['id'] : $j; 83 $js_id = JQ($id); 84 $dom_id = preg_replace('/[^a-z0-9\-_]/i', '', $id); 85 $out .= sprintf($line_templ, $dom_id, ($current == $id ? 'selected' : ''), 86 Q(rcmail_url(null, array('_source' => $id))), $js_id, (!empty($source['name']) ? Q($source['name']) : Q($id))); 87 $groupdata = rcmail_contact_groups(array('out' => $out, 'jsdata' => $jsdata, 'source' => $id)); 88 $jsdata = $groupdata['jsdata']; 89 $out = $groupdata['out']; 90 } 91 92 $OUTPUT->set_env('contactgroups', $jsdata); 93 $OUTPUT->add_gui_object('folderlist', $attrib['id']); 94 95 return html::tag('ul', $attrib, $out, html::$common_attrib); 61 global $RCMAIL, $OUTPUT; 62 63 if (!$attrib['id']) 64 $attrib['id'] = 'rcmdirectorylist'; 65 66 $out = ''; 67 $local_id = '0'; 68 $jsdata = array(); 69 $current = get_input_value('_source', RCUBE_INPUT_GPC); 70 $line_templ = html::tag('li', array( 71 'id' => 'rcmli%s', 'class' => 'addressbook %s'), 72 html::a(array('href' => '%s', 73 'onclick' => "return ".JS_OBJECT_NAME.".command('list','%s',this)"), '%s')); 74 75 if (!$current && strtolower($RCMAIL->config->get('address_book_type', 'sql')) != 'ldap') { 76 $current = '0'; 77 } 78 else if (!$current) { 79 // DB address book not used, see if a source is set, if not use the 80 // first LDAP directory. 81 $current = key((array)$RCMAIL->config->get('ldap_public', array())); 82 } 83 84 foreach ((array)$OUTPUT->env['address_sources'] as $j => $source) { 85 $id = $source['id'] ? $source['id'] : $j; 86 $js_id = JQ($id); 87 $dom_id = preg_replace('/[^a-z0-9\-_]/i', '', $id); 88 $out .= sprintf($line_templ, $dom_id, ($current == $id ? 'selected' : ''), 89 Q(rcmail_url(null, array('_source' => $id))), 90 $js_id, (!empty($source['name']) ? Q($source['name']) : Q($id))); 91 $groupdata = rcmail_contact_groups(array('out' => $out, 'jsdata' => $jsdata, 'source' => $id)); 92 $jsdata = $groupdata['jsdata']; 93 $out = $groupdata['out']; 94 } 95 96 $OUTPUT->set_env('contactgroups', $jsdata); 97 $OUTPUT->add_gui_object('folderlist', $attrib['id']); 98 99 return html::tag('ul', $attrib, $out, html::$common_attrib); 96 100 } 97 101 … … 99 103 function rcmail_contact_groups($args) 100 104 { 101 global $RCMAIL; 102 103 $groups = $RCMAIL->get_address_book($args['source'])->list_groups(); 104 105 if (!empty($groups)) { 106 $line_templ = html::tag('li', array('id' => 'rcmliG%s%s', 'class' => 'contactgroup'), 107 html::a(array('href' => '#', 'onclick' => "return ".JS_OBJECT_NAME.".command('listgroup',{'source':'%s','id':'%s'},this)"), '%s')); 108 109 $jsdata = array(); 110 foreach ($groups as $group) { 111 $args['out'] .= sprintf($line_templ, $args['source'], $group['ID'], $args['source'], $group['ID'], Q($group['name'])); 112 $args['jsdata']['G'.$args['source'].$group['ID']] = array( 113 'source' => $args['source'], 'id' => $group['ID'], 'name' => $group['name'], 'type' => 'group'); 114 } 115 } 116 117 return $args; 105 global $RCMAIL; 106 107 $groups = $RCMAIL->get_address_book($args['source'])->list_groups(); 108 109 if (!empty($groups)) { 110 $line_templ = html::tag('li', array( 111 'id' => 'rcmliG%s%s', 'class' => 'contactgroup'), 112 html::a(array('href' => '#', 113 'onclick' => "return ".JS_OBJECT_NAME.".command('listgroup',{'source':'%s','id':'%s'},this)"), '%s')); 114 115 $jsdata = array(); 116 foreach ($groups as $group) { 117 $args['out'] .= sprintf($line_templ, $args['source'], $group['ID'], $args['source'], $group['ID'], Q($group['name'])); 118 $args['jsdata']['G'.$args['source'].$group['ID']] = array( 119 'source' => $args['source'], 'id' => $group['ID'], 120 'name' => $group['name'], 'type' => 'group'); 121 } 122 } 123 124 return $args; 118 125 } 119 126 … … 121 128 // return the message list as HTML table 122 129 function rcmail_contacts_list($attrib) 123 {124 global $CONTACTS, $OUTPUT;125 126 // count contacts for this user127 $result = $CONTACTS->list_records();128 129 // add id to message list table if not specified130 if (!strlen($attrib['id']))131 $attrib['id'] = 'rcmAddressList';132 133 // define list of cols to be displayed134 $a_show_cols = array('name');135 136 // create XHTML table137 $out = rcube_table_output($attrib, $result->records, $a_show_cols, $CONTACTS->primary_key);138 139 // set client env140 $OUTPUT->add_gui_object('contactslist', $attrib['id']);141 $OUTPUT->set_env('current_page', (int)$CONTACTS->list_page);142 $OUTPUT->set_env('pagecount', ceil($result->count/$CONTACTS->page_size));143 $OUTPUT->include_script('list.js');144 145 // add some labels to client146 $OUTPUT->add_label('deletecontactconfirm');147 148 return $out;149 }130 { 131 global $CONTACTS, $OUTPUT; 132 133 // count contacts for this user 134 $result = $CONTACTS->list_records(); 135 136 // add id to message list table if not specified 137 if (!strlen($attrib['id'])) 138 $attrib['id'] = 'rcmAddressList'; 139 140 // define list of cols to be displayed 141 $a_show_cols = array('name'); 142 143 // create XHTML table 144 $out = rcube_table_output($attrib, $result->records, $a_show_cols, $CONTACTS->primary_key); 145 146 // set client env 147 $OUTPUT->add_gui_object('contactslist', $attrib['id']); 148 $OUTPUT->set_env('current_page', (int)$CONTACTS->list_page); 149 $OUTPUT->set_env('pagecount', ceil($result->count/$CONTACTS->page_size)); 150 $OUTPUT->include_script('list.js'); 151 152 // add some labels to client 153 $OUTPUT->add_label('deletecontactconfirm'); 154 155 return $out; 156 } 150 157 151 158 152 159 function rcmail_js_contacts_list($result, $prefix='') 153 { 154 global $OUTPUT; 155 156 if (empty($result) || $result->count == 0) 157 return; 158 159 // define list of cols to be displayed 160 $a_show_cols = array('name'); 161 162 while ($row = $result->next()) 163 { 164 $a_row_cols = array(); 160 { 161 global $OUTPUT; 162 163 if (empty($result) || $result->count == 0) 164 return; 165 166 // define list of cols to be displayed 167 $a_show_cols = array('name'); 168 169 while ($row = $result->next()) { 170 $a_row_cols = array(); 165 171 166 // format each col167 foreach ($a_show_cols as $col)168 $a_row_cols[$col] = Q($row[$col]);169 170 $OUTPUT->command($prefix.'add_contact_row', $row['ID'], $a_row_cols);171 } 172 }172 // format each col 173 foreach ($a_show_cols as $col) 174 $a_row_cols[$col] = Q($row[$col]); 175 176 $OUTPUT->command($prefix.'add_contact_row', $row['ID'], $a_row_cols); 177 } 178 } 173 179 174 180 175 181 // similar function as /steps/settings/identities.inc::rcmail_identity_frame() 176 182 function rcmail_contact_frame($attrib) 177 {178 global $OUTPUT;179 180 if (!$attrib['id'])181 $attrib['id'] = 'rcmcontactframe';183 { 184 global $OUTPUT; 185 186 if (!$attrib['id']) 187 $attrib['id'] = 'rcmcontactframe'; 182 188 183 $attrib['name'] = $attrib['id'];184 185 $OUTPUT->set_env('contentframe', $attrib['name']);186 $OUTPUT->set_env('blankpage', $attrib['src'] ? $OUTPUT->abs_url($attrib['src']) : 'program/blank.gif');187 188 return html::iframe($attrib);189 }189 $attrib['name'] = $attrib['id']; 190 191 $OUTPUT->set_env('contentframe', $attrib['name']); 192 $OUTPUT->set_env('blankpage', $attrib['src'] ? $OUTPUT->abs_url($attrib['src']) : 'program/blank.gif'); 193 194 return html::iframe($attrib); 195 } 190 196 191 197 192 198 function rcmail_rowcount_display($attrib) 193 { 194 global $OUTPUT; 195 196 if (!$attrib['id']) 197 $attrib['id'] = 'rcmcountdisplay'; 198 199 $OUTPUT->add_gui_object('countdisplay', $attrib['id']); 200 201 return html::span($attrib, rcmail_get_rowcount_text()); 202 } 203 199 { 200 global $OUTPUT; 201 202 if (!$attrib['id']) 203 $attrib['id'] = 'rcmcountdisplay'; 204 205 $OUTPUT->add_gui_object('countdisplay', $attrib['id']); 206 207 return html::span($attrib, rcmail_get_rowcount_text()); 208 } 204 209 205 210 206 211 function rcmail_get_rowcount_text() 207 { 208 global $CONTACTS; 209 210 // read nr of contacts 211 $result = $CONTACTS->get_result(); 212 if (!$result) 213 $result = $CONTACTS->count(); 214 215 if ($result->count == 0) 216 $out = rcube_label('nocontactsfound'); 217 else 218 $out = rcube_label(array( 219 'name' => 'contactsfromto', 220 'vars' => array( 221 'from' => $result->first + 1, 222 'to' => min($result->count, $result->first + $CONTACTS->page_size), 223 'count' => $result->count) 224 )); 225 226 return $out; 227 } 228 212 { 213 global $CONTACTS; 214 215 // read nr of contacts 216 $result = $CONTACTS->get_result(); 217 if (!$result) { 218 $result = $CONTACTS->count(); 219 } 220 221 if ($result->count == 0) 222 $out = rcube_label('nocontactsfound'); 223 else 224 $out = rcube_label(array( 225 'name' => 'contactsfromto', 226 'vars' => array( 227 'from' => $result->first + 1, 228 'to' => min($result->count, $result->first + $CONTACTS->page_size), 229 'count' => $result->count) 230 )); 231 232 return $out; 233 } 234 235 236 function rcmail_contact_form($form, $record) 237 { 238 global $RCMAIL; 239 240 // Allow plugins to modify contact form content 241 $plugin = $RCMAIL->plugins->exec_hook('contact_form', array( 242 'form' => $form, 'record' => $record)); 243 244 $form = $plugin['form']; 245 $record = $plugin['record']; 246 $out = ''; 247 248 foreach ($form as $fieldset) { 249 if (empty($fieldset['content'])) 250 continue; 251 252 $content = ''; 253 if (is_array($fieldset['content'])) { 254 $table = new html_table(array('cols' => 2)); 255 256 foreach ($fieldset['content'] as $col => $colprop) { 257 $colprop['id'] = 'rcmfd_'.$col; 258 259 $label = !empty($colprop['label']) ? $colprop['label'] : rcube_label($col); 260 261 if (!empty($colprop['value'])) { 262 $value = $colprop['value']; 263 } 264 else if ($RCMAIL->action == 'show') { 265 $value = $record[$col]; 266 } 267 else { 268 $value = rcmail_get_edit_field($col, $record[$col], $colprop, $colprop['type']); 269 } 270 271 $table->add('title', sprintf('<label for="%s">%s</label>', $colprop['id'], Q($label))); 272 $table->add(null, $value); 273 } 274 $content = $table->show(); 275 } 276 else { 277 $content = $fieldset['content']; 278 } 279 280 $out .= html::tag('fieldset', null, html::tag('legend', null, Q($fieldset['name'])) . $content) ."\n"; 281 } 282 283 return $out; 284 } 285 286 229 287 // register UI objects 230 288 $OUTPUT->add_handlers(array( 231 'directorylist' => 'rcmail_directory_list',289 'directorylist' => 'rcmail_directory_list', 232 290 // 'groupslist' => 'rcmail_contact_groups', 233 'addresslist' => 'rcmail_contacts_list',234 'addressframe' => 'rcmail_contact_frame',235 'recordscountdisplay' => 'rcmail_rowcount_display',236 'searchform' => array($OUTPUT, 'search_form')291 'addresslist' => 'rcmail_contacts_list', 292 'addressframe' => 'rcmail_contact_frame', 293 'recordscountdisplay' => 'rcmail_rowcount_display', 294 'searchform' => array($OUTPUT, 'search_form') 237 295 )); 238 -
program/steps/addressbook/show.inc
rcb7d32e ra79417d 23 23 // read contact record 24 24 if (($cid = get_input_value('_cid', RCUBE_INPUT_GPC)) && ($record = $CONTACTS->get_record($cid, true))) { 25 $OUTPUT->set_env('cid', $record['ID']);25 $OUTPUT->set_env('cid', $record['ID']); 26 26 } 27 28 $GROUPS = $CONTACTS->list_groups();29 $OUTPUT->set_env('groups', !empty($GROUPS));30 27 31 28 32 29 function rcmail_contact_details($attrib) 33 30 { 34 global $CONTACTS, $OUTPUT;31 global $CONTACTS, $RCMAIL; 35 32 36 // check if we have a valid result 37 if (!(($result = $CONTACTS->get_result()) && ($record = $result->first()))) { 38 $OUTPUT->show_message('contactnotfound'); 39 return false; 40 } 41 42 // a specific part is requested 43 if ($attrib['part']) { 44 return Q($record[$attrib['part']]); 45 } 33 // check if we have a valid result 34 if (!(($result = $CONTACTS->get_result()) && ($record = $result->first()))) { 35 $RCMAIL->output->show_message('contactnotfound'); 36 return false; 37 } 46 38 47 // return the complete address record as table 48 $table = new html_table(array('cols' => 2)); 39 $i_size = !empty($attrib['size']) ? $attrib['size'] : 40; 40 $t_rows = !empty($attrib['textarearows']) ? $attrib['textarearows'] : 6; 41 $t_cols = !empty($attrib['textareacols']) ? $attrib['textareacols'] : 40; 49 42 50 $a_show_cols = array('name', 'firstname', 'surname', 'email'); 51 $microformats = array('name' => 'fn', 'email' => 'email'); 43 $microformats = array('name' => 'fn', 'email' => 'email'); 52 44 53 foreach ($a_show_cols as $col) { 54 if ($col == 'email' && !empty($record[$col])) { 55 $value = html::a(array( 56 'href' => 'mailto:' . $record[$col], 57 'onclick' => sprintf("return %s.command('compose','%s',this)", JS_OBJECT_NAME, JQ($record[$col])), 58 'title' => rcube_label('composeto'), 59 'class' => $microformats[$col], 60 ), Q($record[$col])); 45 $form = array( 46 'info' => array( 47 'name' => rcube_label('contactproperties'), 48 'content' => array( 49 'name' => array('type' => 'text', 'size' => $i_size), 50 'firstname' => array('type' => 'text', 'size' => $i_size), 51 'surname' => array('type' => 'text', 'size' => $i_size), 52 'email' => array('type' => 'text', 'size' => $i_size), 53 ), 54 ), 55 'groups' => array( 56 'name' => rcube_label('groups'), 57 'content' => '', 58 ), 59 ); 60 61 // Get content of groups fieldset 62 if ($groups = rcmail_contact_record_groups($record['ID'])) { 63 $form['groups']['content'] = $groups; 61 64 } 62 else if (!empty($record[$col])){63 $value = html::span($microformats[$col], Q($record[$col]));65 else { 66 unset($form['groups']); 64 67 } 65 else 66 $value = ''; 67 68 $table->add('title', Q(rcube_label($col))); 69 $table->add(null, $value); 70 } 71 72 return $table->show($attrib + array('class' => 'vcard')); 68 69 if (!empty($record['email'])) { 70 $form['info']['content']['email']['value'] = html::a(array( 71 'href' => 'mailto:' . $record['email'], 72 'onclick' => sprintf("return %s.command('compose','%s',this)", JS_OBJECT_NAME, JQ($record['email'])), 73 'title' => rcube_label('composeto'), 74 'class' => $microformats['email'], 75 ), Q($record['email'])); 76 } 77 foreach (array('name', 'firstname', 'surname') as $col) { 78 if ($record[$col]) { 79 $form['info']['content'][$col]['value'] = html::span($microformats[$col], Q($record[$col])); 80 } 81 } 82 83 return rcmail_contact_form($form, $record); 73 84 } 74 85 75 86 76 function rcmail_contact_record_groups($ attrib)87 function rcmail_contact_record_groups($contact_id) 77 88 { 78 global $RCMAIL, $CONTACTS, $GROUPS; 89 global $RCMAIL, $CONTACTS, $GROUPS; 90 91 $GROUPS = $CONTACTS->list_groups(); 92 93 if (empty($GROUPS)) { 94 return ''; 95 } 96 97 $table = new html_table(array('cols' => 2, 'cellspacing' => 0, 'border' => 0)); 98 99 $members = $CONTACTS->get_record_groups($contact_id); 100 $checkbox = new html_checkbox(array('name' => '_gid[]', 101 'class' => 'groupmember', 'disabled' => $CONTACTS->readonly)); 102 103 foreach ($GROUPS as $group) { 104 $gid = $group['ID']; 105 $table->add(null, $checkbox->show($members[$gid] ? $gid : null, 106 array('value' => $gid, 'id' => 'ff_gid' . $gid))); 107 $table->add(null, html::label('ff_gid' . $gid, Q($group['name']))); 108 } 109 110 $hiddenfields = new html_hiddenfield(array('name' => '_source', 'value' => get_input_value('_source', RCUBE_INPUT_GPC))); 111 $hiddenfields->add(array('name' => '_cid', 'value' => $record['ID'])); 112 113 $form_start = $RCMAIL->output->request_form(array( 114 'name' => "form", 'method' => "post", 115 'task' => $RCMAIL->task, 'action' => 'save', 116 'request' => 'save.'.intval($contact_id), 117 'noclose' => true), $hiddenfields->show()); 118 $form_end = '</form>'; 119 120 $RCMAIL->output->add_gui_object('editform', 'form'); 79 121 80 // check if we have a valid result 81 if (!(($result = $CONTACTS->get_result()) && ($record = $result->first()))) 82 return false; 83 84 $table = new html_table(array('cols' => 2, 'cellspacing' => 0, 'border' => 0)); 85 86 $members = $CONTACTS->get_record_groups($record['ID']); 87 $checkbox = new html_checkbox(array('name' => '_gid[]', 'class' => 'groupmember', 'disabled' => $CONTACTS->readonly)); 88 foreach ($GROUPS as $group) { 89 $gid = $group['ID']; 90 $table->add(null, $checkbox->show($members[$gid] ? $gid : null, array('value' => $gid, 'id' => 'ff_gid' . $gid))); 91 $table->add(null, html::label('ff_gid' . $gid, Q($group['name']))); 92 } 93 94 $hiddenfields = new html_hiddenfield(array('name' => '_source', 'value' => get_input_value('_source', RCUBE_INPUT_GPC))); 95 $hiddenfields->add(array('name' => '_cid', 'value' => $record['ID'])); 96 97 $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()); 98 $form_end = !strlen($attrib['form']) ? '</form>' : ''; 99 100 $RCMAIL->output->add_gui_object('editform', !empty($attrib['form']) ? $attrib['form'] : 'form'); 101 102 return $form_start . $table->show($attrib) . $form_end; 122 return $form_start . $table->show() . $form_end; 103 123 } 104 124 … … 106 126 //$OUTPUT->framed = $_framed; 107 127 $OUTPUT->add_handler('contactdetails', 'rcmail_contact_details'); 108 $OUTPUT->add_handler('contactgroups', 'rcmail_contact_record_groups'); 128 109 129 $OUTPUT->send('showcontact'); -
skins/default/templates/addcontact.html
r6fff3c8 ra79417d 4 4 <title><roundcube:object name="pagetitle" /></title> 5 5 <roundcube:include file="/includes/links.html" /> 6 <script type="text/javascript" src="/functions.js"></script> 6 7 </head> 7 8 <body class="iframe"> 8 9 9 10 <div id="contact-title" class="boxtitle"><roundcube:label name="addcontact" /></div> 10 11 11 <div id="contact-details" class="boxcontent"> 12 <roundcube:object name="contacteditform" size="40" /> 13 14 <p><br /> 15 <input type="button" value="<roundcube:label name="cancel" />" class="button" onclick="history.back()" /> 16 <roundcube:button command="save" type="input" class="button mainaction" label="save" /> 17 </p> 18 12 <roundcube:object name="contacteditform" size="40" /> 13 <p> 14 <input type="button" value="<roundcube:label name="cancel" />" class="button" onclick="history.back()" /> 15 <roundcube:button command="save" type="input" class="button mainaction" label="save" /> 16 </p> 19 17 </form> 20 18 </div> 19 <script type="text/javascript">rcube_init_tabs('contact-details')</script> 21 20 22 21 </body> -
skins/default/templates/editcontact.html
r6fff3c8 ra79417d 4 4 <title><roundcube:object name="pagetitle" /></title> 5 5 <roundcube:include file="/includes/links.html" /> 6 <script type="text/javascript" src="/functions.js"></script> 6 7 </head> 7 8 <body class="iframe"> 8 9 9 10 <div id="contact-title" class="boxtitle"><roundcube:label name="editcontact" /></div> 10 11 11 <div id="contact-details" class="boxcontent"> 12 <roundcube:object name="contacteditform" size="40" /> 13 14 <p><br /> 15 <roundcube:button command="show" type="input" class="button" label="cancel" /> 16 <roundcube:button command="save" type="input" class="button mainaction" label="save" /> 17 </p> 18 12 <roundcube:object name="contacteditform" size="40" /> 13 <p> 14 <roundcube:button command="show" type="input" class="button" label="cancel" /> 15 <roundcube:button command="save" type="input" class="button mainaction" label="save" /> 16 </p> 19 17 </form> 20 18 </div> 19 <script type="text/javascript">rcube_init_tabs('contact-details')</script> 21 20 22 21 </body> -
skins/default/templates/showcontact.html
rcb7d32e ra79417d 4 4 <title><roundcube:object name="pagetitle" /></title> 5 5 <roundcube:include file="/includes/links.html" /> 6 <script type="text/javascript" src="/functions.js"></script> 6 7 </head> 7 8 <body class="iframe"> 8 9 9 <div id="contact-title" class="boxtitle"><roundcube:object name="contactdetails" part="name" /></div> 10 10 <div id="contact-title" class="boxtitle"><roundcube:label name="contactproperties" /></div> 11 11 <div id="contact-details" class="boxcontent"> 12 <fieldset>13 <legend><roundcube:label name="contactproperties" /></legend>14 12 <roundcube:object name="contactdetails" /> 15 16 <p><br /><roundcube:button command="edit" type="input" class="button" label="editcontact" condition="!ENV:readonly" /></p> 17 </fieldset> 18 19 <roundcube:if condition="ENV:groups" /> 20 <fieldset> 21 <legend><roundcube:label name="groups" /></legend> 22 <roundcube:object name="contactgroups" /> 23 </fieldset> 24 <roundcube:endif /> 25 13 <p> 14 <roundcube:button command="edit" type="input" class="button" label="editcontact" condition="!ENV:readonly" /> 15 </p> 26 16 </div> 17 <script type="text/javascript">rcube_init_tabs('contact-details')</script> 27 18 28 19 </body>
Note: See TracChangeset
for help on using the changeset viewer.
