Changeset d1d2c4f in github
- Timestamp:
- Jan 8, 2006 2:15:44 AM (7 years ago)
- Branches:
- master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
- Children:
- d4ab311
- Parents:
- 3baec23
- Files:
-
- 7 added
- 8 edited
-
config/main.inc.php.dist (modified) (1 diff)
-
index.php (modified) (2 diffs)
-
program/include/main.inc (modified) (5 diffs)
-
program/include/rcube_ldap.inc (added)
-
program/js/app.js (modified) (13 diffs)
-
program/localization/en/labels.inc (modified) (2 diffs)
-
program/localization/en/messages.inc (modified) (1 diff)
-
program/steps/addressbook/func.inc (modified) (1 diff)
-
program/steps/addressbook/ldapsearchform.inc (added)
-
program/steps/addressbook/save.inc (modified) (8 diffs)
-
skins/default/images/buttons/ldap_act.png (added)
-
skins/default/images/buttons/ldap_pas.png (added)
-
skins/default/includes/ldapscripts.html (added)
-
skins/default/ldapsearchform.css (added)
-
skins/default/templates/ldappublicsearch.html (added)
Legend:
- Unmodified
- Added
- Removed
-
config/main.inc.php.dist
r3baec23 rd1d2c4f 132 132 $rcmail_config['mail_header_delimiter'] = "\r\n"; 133 133 134 // public ldap servers to search for contacts 135 $rcmail_config['ldap_public'] = false; 136 137 /** example config for Verisign directory 138 $rcmail_config['ldap_public']['Verisign'] = array('hosts' => array('directory.verisign.com'), 139 'port' => 389, 140 'base_dn' => '', 141 'search_fields' => array('mail', 'cn'), 142 'name_field' => 'cn', 143 'mail_field' => 'mail', 144 'scope' => 'sub', 145 'fuzzy_search' => 0); 146 **/ 147 134 148 135 149 /***** these settings can be overwritten by user's preferences *****/ -
index.php
r15a9d1c rd1d2c4f 1 1 <?php 2 3 2 /* 4 3 +-----------------------------------------------------------------------+ … … 282 281 if ($_action=='list' && $_GET['_remote']) 283 282 include('program/steps/addressbook/list.inc'); 283 284 if ($_action=='ldappublicsearch') 285 include('program/steps/addressbook/ldapsearchform.inc'); 284 286 } 285 287 -
program/include/main.inc
r15a9d1c rd1d2c4f 925 925 'contactdetails' => 'rcmail_contact_details', 926 926 'contacteditform' => 'rcmail_contact_editform', 927 'ldappublicsearch' => 'rcmail_ldap_public_search_form', 928 'ldappublicaddresslist' => 'rcmail_ldap_public_list', 927 929 928 930 // USER SETTINGS … … 1111 1113 1112 1114 1113 function rcube_table_output($attrib, $ sql_result, $a_show_cols, $id_col)1115 function rcube_table_output($attrib, $table_data, $a_show_cols, $id_col) 1114 1116 { 1115 1117 global $DB; … … 1129 1131 1130 1132 $c = 0; 1131 while ($sql_result && ($sql_arr = $DB->fetch_assoc($sql_result))) 1132 { 1133 $zebra_class = $c%2 ? 'even' : 'odd'; 1134 1135 $table .= sprintf('<tr id="rcmrow%d" class="contact '.$zebra_class.'">'."\n", $sql_arr[$id_col]); 1136 1137 // format each col 1138 foreach ($a_show_cols as $col) 1133 1134 if (!is_array($table_data)) 1135 { 1136 while ($table_data && ($sql_arr = $DB->fetch_assoc($table_data))) 1139 1137 { 1140 $cont = rep_specialchars_output($sql_arr[$col]); 1141 $table .= '<td class="'.$col.'">' . $cont . "</td>\n"; 1138 $zebra_class = $c%2 ? 'even' : 'odd'; 1139 1140 $table .= sprintf('<tr id="rcmrow%d" class="contact '.$zebra_class.'">'."\n", $sql_arr[$id_col]); 1141 1142 // format each col 1143 foreach ($a_show_cols as $col) 1144 { 1145 $cont = rep_specialchars_output($sql_arr[$col]); 1146 $table .= '<td class="'.$col.'">' . $cont . "</td>\n"; 1147 } 1148 1149 $table .= "</tr>\n"; 1150 $c++; 1142 1151 } 1143 1144 $table .= "</tr>\n"; 1145 $c++; 1152 } 1153 else 1154 { 1155 foreach ($table_data as $row_data) 1156 { 1157 $zebra_class = $c%2 ? 'even' : 'odd'; 1158 1159 $table .= sprintf('<tr id="rcmrow%d" class="contact '.$zebra_class.'">'."\n", $row_data[$id_col]); 1160 1161 // format each col 1162 foreach ($a_show_cols as $col) 1163 { 1164 $cont = rep_specialchars_output($row_data[$col]); 1165 $table .= '<td class="'.$col.'">' . $cont . "</td>\n"; 1166 } 1167 1168 $table .= "</tr>\n"; 1169 $c++; 1170 } 1146 1171 } 1147 1172 … … 1421 1446 1422 1447 1423 1424 1448 function rcube_timer() 1425 1449 { … … 1443 1467 } 1444 1468 1445 1446 1469 ?> -
program/js/app.js
r15a9d1c rd1d2c4f 161 161 162 162 case 'addressbook': 163 var contacts_list = this.gui_objects.contactslist; 163 var contacts_list = this.gui_objects.contactslist; 164 var ldap_contacts_list = this.gui_objects.ldapcontactslist; 165 164 166 if (contacts_list) 165 167 this.init_contactslist(contacts_list); 166 168 169 if (ldap_contacts_list) 170 this.init_ldapsearchlist(ldap_contacts_list); 171 167 172 this.set_page_buttons(); 168 173 … … 173 178 this.enable_command('save', true); 174 179 175 this.enable_command('list', 'add', true);180 this.enable_command('list', 'add', 'ldappublicsearch', true); 176 181 break; 177 182 … … 373 378 374 379 380 // get all contact rows from HTML table and init each row 381 this.init_ldapsearchlist = function(ldap_contacts_list) 382 { 383 if (ldap_contacts_list && ldap_contacts_list.tBodies[0]) 384 { 385 this.ldap_contact_rows = new Array(); 386 387 var row; 388 for(var r=0; r<ldap_contacts_list.tBodies[0].childNodes.length; r++) 389 { 390 row = ldap_contacts_list.tBodies[0].childNodes[r]; 391 this.init_table_row(row, 'ldap_contact_rows'); 392 } 393 } 394 395 // alias to common rows array 396 this.list_rows = this.ldap_contact_rows; 397 }; 398 399 375 400 // make references in internal array and set event handlers 376 401 this.init_table_row = function(row, array_name) … … 549 574 case 'add': 550 575 if (this.task=='addressbook') 551 this.load_contact(0, 'add'); 576 if (!window.frames[this.env.contentframe].rcmail) 577 this.load_contact(0, 'add'); 578 else 579 { 580 if (window.frames[this.env.contentframe].rcmail.selection.length) 581 this.add_ldap_contacts(); 582 else 583 this.load_contact(0, 'add'); 584 } 552 585 else if (this.task=='settings') 553 586 { … … 683 716 //location.href = this.env.comm_path+'&_action=show&_uid='+this.env.prev_uid+'&_mbox='+this.env.mailbox; 684 717 break; 685 718 719 686 720 case 'compose': 687 721 var url = this.env.comm_path+'&_action=compose'; … … 700 734 else 701 735 { 702 for (var n=0; n<this.selection.length; n++) 703 a_cids[a_cids.length] = this.selection[n]; 736 if (!window.frames[this.env.contentframe].rcmail.selection.length) 737 { 738 for (var n=0; n<this.selection.length; n++) 739 a_cids[a_cids.length] = this.selection[n]; 740 } 741 else 742 { 743 var frameRcmail = window.frames[this.env.contentframe].rcmail; 744 // get the email address(es) 745 for (var n=0; n<frameRcmail.selection.length; n++) 746 a_cids[a_cids.length] = frameRcmail.ldap_contact_rows[frameRcmail.selection[n]].obj.cells[1].innerHTML; 747 } 704 748 } 705 706 749 if (a_cids.length) 707 750 url += '&_to='+a_cids.join(','); 708 751 else 709 752 break; 753 710 754 } 711 755 else if (props) 712 756 url += '&_to='+props; 757 758 // don't know if this is necessary... 759 url = url.replace(/&_framed=1/, ""); 713 760 714 761 this.set_busy(true); 715 location.href = url; 716 break; 762 763 // need parent in case we are coming from the contact frame 764 parent.window.location.href = url; 765 break; 717 766 718 767 case 'send': … … 778 827 this.add_contact(props); 779 828 break; 829 830 831 // ldap search 832 case 'ldappublicsearch': 833 if (this.gui_objects.ldappublicsearchform) 834 this.gui_objects.ldappublicsearchform.submit(); 835 else 836 this.ldappublicsearch(command); 837 break; 780 838 781 839 … … 955 1013 this.click_row = function(e, id) 956 1014 { 957 var ctrl = this.check_ctrlkey(e);1015 var shift = this.check_shiftkey(e); 958 1016 959 1017 // don't do anything (another action processed before) … … 965 1023 966 1024 if (!this.drag_active && this.in_selection_before==id) 967 this.select(id, (ctrl && this.task!='settings')); 1025 { 1026 this.select(id, (shift && this.task!='settings')); 1027 } 968 1028 969 1029 this.drag_start = false; … … 971 1031 972 1032 // row was double clicked 973 if (this.task=='mail' && this.list_rows && this.list_rows[id].clicked && ! ctrl)1033 if (this.task=='mail' && this.list_rows && this.list_rows[id].clicked && !shift) 974 1034 { 975 1035 this.show_message(id); … … 978 1038 else if (this.task=='addressbook') 979 1039 { 980 if (this.selection.length==1 && this.env.contentframe) 1040 if (this.contact_rows && this.selection.length==1) 1041 { 981 1042 this.load_contact(this.selection[0], 'show', true); 982 else if (this.task=='addressbook' && this.list_rows && this.list_rows[id].clicked) 1043 // change the text for the add contact button 1044 var links = parent.document.getElementById('abooktoolbar').getElementsByTagName('A'); 1045 for (i = 0; i < links.length; i++) 1046 { 1047 var onclickstring = new String(links[i].onclick); 1048 if (onclickstring.search('\"add\"') != -1) 1049 links[i].title = this.env.newcontact; 1050 } 1051 } 1052 else if (this.contact_rows && this.contact_rows[id].clicked) 983 1053 { 984 1054 this.load_contact(id, 'show'); 985 1055 return false; 986 1056 } 1057 else if (this.ldap_contact_rows && !this.ldap_contact_rows[id].clicked) 1058 { 1059 // clear selection 1060 parent.rcmail.clear_selection(); 1061 1062 // disable delete 1063 parent.rcmail.set_button('delete', 'pas'); 1064 1065 // change the text for the add contact button 1066 var links = parent.document.getElementById('abooktoolbar').getElementsByTagName('A'); 1067 for (i = 0; i < links.length; i++) 1068 { 1069 var onclickstring = new String(links[i].onclick); 1070 if (onclickstring.search('\"add\"') != -1) 1071 links[i].title = this.env.addcontact; 1072 } 1073 } 1074 // handle double click event 1075 else if (this.ldap_contact_rows && this.selection.length==1 && this.ldap_contact_rows[id].clicked) 1076 this.command('compose', this.ldap_contact_rows[id].obj.cells[1].innerHTML); 987 1077 else if (this.env.contentframe) 988 1078 { … … 1002 1092 return false; 1003 1093 }; 1004 1005 1094 1006 1095 … … 1920 2009 }; 1921 2010 2011 2012 // load ldap search form 2013 this.ldappublicsearch = function(action) 2014 { 2015 var add_url = ''; 2016 var target = window; 2017 if (this.env.contentframe && window.frames && window.frames[this.env.contentframe]) 2018 { 2019 add_url = '&_framed=1'; 2020 target = window.frames[this.env.contentframe]; 2021 document.getElementById(this.env.contentframe).style.visibility = 'inherit'; 2022 } 2023 else 2024 return false; 2025 2026 2027 if (action == 'ldappublicsearch') 2028 target.location.href = this.env.comm_path+'&_action='+action+add_url; 2029 }; 2030 2031 // add ldap contacts to address book 2032 this.add_ldap_contacts = function() 2033 { 2034 if (window.frames[this.env.contentframe].rcmail) 2035 { 2036 var frame = window.frames[this.env.contentframe]; 2037 2038 // build the url 2039 var url = '&_framed=1'; 2040 var emails = '&_emails='; 2041 var names = '&_names='; 2042 var end = ''; 2043 for (var n=0; n<frame.rcmail.selection.length; n++) 2044 { 2045 end = n < frame.rcmail.selection.length - 1 ? ',' : ''; 2046 emails += frame.rcmail.ldap_contact_rows[frame.rcmail.selection[n]].obj.cells[1].innerHTML + end; 2047 names += frame.rcmail.ldap_contact_rows[frame.rcmail.selection[n]].obj.cells[0].innerHTML + end; 2048 } 2049 2050 frame.location.href = this.env.comm_path + '&_action=save&_framed=1' + emails + names; 2051 } 2052 return false; 2053 } 2054 1922 2055 1923 2056 -
program/localization/en/labels.inc
r15a9d1c rd1d2c4f 144 144 145 145 $labels['newcontact'] = 'Create new contact card'; 146 $labels['addcontact'] = 'Add selected contact to your addressbook'; 146 147 $labels['deletecontact'] = 'Delete selected contacts'; 147 148 $labels['composeto'] = 'Compose mail to'; … … 150 151 $labels['export'] = 'Export'; 151 152 153 $labels['ldappublicsearchname'] = 'Contact name'; 154 $labels['ldappublicsearchtype'] = 'Exact match?'; 155 $labels['ldappublicserverselect'] = 'Select servers'; 156 $labels['ldappublicsearchfield'] = 'Search on'; 157 $labels['ldappublicsearchform'] = 'Look for a contact'; 158 $labels['ldappublicsearch'] = 'Search'; 152 159 153 160 // settings -
program/localization/en/messages.inc
r977a295e rd1d2c4f 79 79 $messages['notsentwarning'] = 'Message has not been sent. Do you want to discard your message?'; 80 80 81 $messages['notsentwarning'] = 'Message has not been sent. Do you want to discard your message?'; 82 83 $messages['noldapserver'] = 'Please select an ldap server to search'; 84 85 $messages['nocontactsreturned'] = 'No contacts were found'; 86 87 $messages['nosearchname'] = 'Please enter a contact name or email address'; 81 88 82 89 ?> -
program/steps/addressbook/func.inc
r1cded85 rd1d2c4f 82 82 $javascript .= sprintf("%s.set_env('current_page', %d);\n", $JS_OBJECT_NAME, $CONTACTS_LIST['page']); 83 83 $javascript .= sprintf("%s.set_env('pagecount', %d);\n", $JS_OBJECT_NAME, ceil($rowcount/$CONFIG['pagesize'])); 84 $javascript .= "rcmail.set_env('newcontact', '" . rcube_label('newcontact') . "');"; 84 85 //$javascript .= sprintf("%s.set_env('contacts', %s);", $JS_OBJECT_NAME, array2js($a_js_message_arr)); 85 86 -
program/steps/addressbook/save.inc
r1cded85 rd1d2c4f 20 20 */ 21 21 22 23 $a_save_cols = array('name', 'firstname', 'surname', 'email');24 25 26 22 // check input 27 if ( empty($_POST['_name']) || empty($_POST['_email']))23 if ((empty($_POST['_name']) || empty($_POST['_email'])) && empty($_GET['_framed'])) 28 24 { 29 25 show_message('formincomplete', 'warning'); … … 32 28 } 33 29 30 // setup some vars we need 31 $a_save_cols = array('name', 'firstname', 'surname', 'email'); 32 $contacts_table = get_table_name('contacts'); 34 33 35 34 // update an existing contact … … 49 48 if (sizeof($a_write_sql)) 50 49 { 51 $DB->query("UPDATE ".get_table_name('contacts')."50 $DB->query("UPDATE $contacts_table 52 51 SET changed=now(), ".join(', ', $a_write_sql)." 53 52 WHERE contact_id=? … … 71 70 $a_js_cols = array(); 72 71 73 $sql_result = $DB->query("SELECT * FROM ".get_table_name('contacts')."72 $sql_result = $DB->query("SELECT * FROM $contacts_table 74 73 WHERE contact_id=? 75 74 AND user_id=? … … 105 104 { 106 105 $a_insert_cols = $a_insert_values = array(); 107 106 108 107 // check for existing contacts 109 $sql_result = $DB->query("SELECT 1 FROM ".get_table_name('contacts')." 110 WHERE user_id=? 111 AND email=? 112 AND del<>1", 113 $_SESSION['user_id'], 114 $_POST['_email']); 108 $sql = "SELECT 1 FROM $contacts_table 109 WHERE user_id = {$_SESSION['user_id']} 110 AND del <> '1' "; 111 112 // get email and name, build sql for existing user check 113 if (isset($_GET['_emails']) && isset($_GET['_names'])) 114 { 115 $sql .= "AND email IN ("; 116 $emails = explode(',', $_GET['_emails']); 117 $names = explode(',', $_GET['_names']); 118 $count = count($emails); 119 $n = 0; 120 foreach ($emails as $email) 121 { 122 $end = (++$n == $count) ? '' : ','; 123 $sql .= $DB->quote(strip_tags($email)) . $end; 124 } 125 $sql .= ")"; 126 $ldap_form = true; 127 } 128 else if (isset($_POST['_email'])) 129 $sql .= "AND email = " . $DB->quote(strip_tags($_POST['_email'])); 130 131 $sql_result = $DB->query($sql); 115 132 116 133 // show warning message … … 118 135 { 119 136 show_message('contactexists', 'warning'); 120 $_action = 'add'; 137 138 if ($ldap_form) 139 rcmail_overwrite_action('ldappublicsearch'); 140 else 141 rcmail_overwrite_action('add'); 142 121 143 return; 122 144 } 123 145 124 foreach ($a_save_cols as $col) 125 { 126 $fname = '_'.$col; 127 if (!isset($_POST[$fname])) 128 continue; 129 130 $a_insert_cols[] = $col; 131 $a_insert_values[] = $DB->quote(strip_tags($_POST[$fname])); 132 } 133 134 if (sizeof($a_insert_cols)) 135 { 136 $DB->query("INSERT INTO ".get_table_name('contacts')." 146 if ($ldap_form) 147 { 148 $n = 0; 149 foreach ($emails as $email) 150 { 151 $DB->query("INSERT INTO $contacts_table 152 (user_id, name, email) 153 VALUES ({$_SESSION['user_id']}," . $DB->quote(strip_tags($names[$n++])) . "," . 154 $DB->quote(strip_tags($email)) . ")"); 155 $insert_id[] = $DB->insert_id(); 156 } 157 } 158 else 159 { 160 foreach ($a_save_cols as $col) 161 { 162 $fname = '_'.$col; 163 if (!isset($_POST[$fname])) 164 continue; 165 166 $a_insert_cols[] = $col; 167 $a_insert_values[] = $DB->quote(strip_tags($_POST[$fname])); 168 } 169 170 if (sizeof($a_insert_cols)) 171 { 172 $DB->query("INSERT INTO $contacts_table 137 173 (user_id, changed, del, ".join(', ', $a_insert_cols).") 138 174 VALUES (?, now(), 0, ".join(', ', $a_insert_values).")", 139 175 $_SESSION['user_id']); 140 176 141 $insert_id = $DB->insert_id(get_sequence_name('contacts')); 177 $insert_id = $DB->insert_id(get_sequence_name('contacts')); 178 } 142 179 } 143 180 144 181 if ($insert_id) 145 182 { 146 $_action = 'show'; 147 $_GET['_cid'] = $insert_id; 148 149 if ($_POST['_framed']) 183 if (!$ldap_form) 184 { 185 $_action = 'show'; 186 $_GET['_cid'] = $insert_id; 187 188 if ($_POST['_framed']) 189 { 190 // add contact row or jump to the page where it should appear 191 $commands = sprintf("if(parent.%s)parent.", $JS_OBJECT_NAME); 192 $sql_result = $DB->query("SELECT * FROM $contacts_table 193 WHERE contact_id=? 194 AND user_id=?", 195 $insert_id, 196 $_SESSION['user_id']); 197 $commands .= rcmail_js_contacts_list($sql_result, $JS_OBJECT_NAME); 198 199 $commands .= sprintf("if(parent.%s)parent.%s.select('%d');\n", 200 $JS_OBJECT_NAME, 201 $JS_OBJECT_NAME, 202 $insert_id); 203 204 // update record count display 205 $commands .= sprintf("if(parent.%s)parent.%s.set_rowcount('%s');\n", 206 $JS_OBJECT_NAME, 207 $JS_OBJECT_NAME, 208 rcmail_get_rowcount_text()); 209 210 $OUTPUT->add_script($commands); 211 } 212 213 // show confirmation 214 show_message('successfullysaved', 'confirmation'); 215 } 216 else 150 217 { 151 218 // add contact row or jump to the page where it should appear 152 $commands = sprintf("if(parent.%s)parent.", $JS_OBJECT_NAME); 153 $sql_result = $DB->query("SELECT * FROM ".get_table_name('contacts')." 154 WHERE contact_id=? 155 AND user_id=?", 156 $insert_id, 157 $_SESSION['user_id']); 158 $commands .= rcmail_js_contacts_list($sql_result, $JS_OBJECT_NAME); 159 219 $commands = ''; 220 foreach ($insert_id as $id) 221 { 222 $sql_result = $DB->query("SELECT * FROM $contacts_table 223 WHERE contact_id = $id 224 AND user_id = {$_SESSION['user_id']}"); 225 226 $commands .= sprintf("if(parent.%s)parent.", $JS_OBJECT_NAME); 227 $commands .= rcmail_js_contacts_list($sql_result, $JS_OBJECT_NAME); 228 $last_id = $id; 229 } 230 231 // display the last insert id 160 232 $commands .= sprintf("if(parent.%s)parent.%s.select('%d');\n", 161 $JS_OBJECT_NAME,162 $JS_OBJECT_NAME,163 $insert_id);164 233 $JS_OBJECT_NAME, 234 $JS_OBJECT_NAME, 235 $last_id); 236 165 237 // update record count display 166 238 $commands .= sprintf("if(parent.%s)parent.%s.set_rowcount('%s');\n", … … 170 242 171 243 $OUTPUT->add_script($commands); 172 173 // show confirmation 174 show_message('successfullysaved', 'confirmation'); 175 } 244 rcmail_overwrite_action('ldappublicsearch'); 245 } 246 247 // show confirmation 248 show_message('successfullysaved', 'confirmation'); 176 249 } 177 250 else … … 183 256 } 184 257 185 186 258 ?>
Note: See TracChangeset
for help on using the changeset viewer.
