[2] | 1 | <?php |
---|
| 2 | /***************************************************************************\ |
---|
| 3 | * eGroupWare - Contacts Center * |
---|
| 4 | * http://www.egroupware.org * |
---|
| 5 | * Written by: * |
---|
| 6 | * - Raphael Derosso Pereira <raphaelpereira@users.sourceforge.net> * |
---|
| 7 | * - Jonas Goes <jqhcb@users.sourceforge.net> * |
---|
| 8 | * sponsored by Thyamad - http://www.thyamad.com * |
---|
| 9 | * ------------------------------------------------------------------------- * |
---|
| 10 | * This program is free software; you can redistribute it and/or modify it * |
---|
| 11 | * under the terms of the GNU General Public License as published by the * |
---|
| 12 | * Free Software Foundation; either version 2 of the License, or (at your * |
---|
| 13 | * option) any later version. * |
---|
| 14 | \***************************************************************************/ |
---|
| 15 | |
---|
[1599] | 16 | |
---|
[2] | 17 | class ui_data |
---|
| 18 | { |
---|
| 19 | var $public_functions = array( |
---|
| 20 | 'data_manager' => true, |
---|
| 21 | ); |
---|
[1599] | 22 | |
---|
[2] | 23 | var $bo; |
---|
[3334] | 24 | var $so_group; |
---|
[2] | 25 | var $typeContact; |
---|
[3795] | 26 | var $preferences; |
---|
[1599] | 27 | |
---|
[2] | 28 | var $page_info = array( |
---|
| 29 | 'n_cards' => 20, |
---|
| 30 | 'n_pages' => false, |
---|
| 31 | 'actual_letter' => 'A', |
---|
| 32 | 'actual_page' => 1, |
---|
| 33 | 'actual_entries' => false, |
---|
| 34 | 'changed' => false, |
---|
| 35 | 'catalogs' => false, |
---|
| 36 | 'actual_catalog' => false |
---|
| 37 | ); |
---|
[1599] | 38 | |
---|
[2] | 39 | /*! |
---|
[1599] | 40 | |
---|
[2] | 41 | @function ui_data |
---|
| 42 | @abstract The constructor. Sets the initial parameters and loads |
---|
| 43 | the data saved in the session |
---|
| 44 | @author Raphael Derosso Pereira |
---|
[1599] | 45 | |
---|
[2] | 46 | */ |
---|
| 47 | function ui_data() |
---|
| 48 | { |
---|
| 49 | $temp = $GLOBALS['phpgw']->session->appsession('ui_data.page_info','contactcenter'); |
---|
| 50 | $temp2 = $GLOBALS['phpgw']->session->appsession('ui_data.all_entries','contactcenter'); |
---|
[1599] | 51 | |
---|
[2] | 52 | $this->bo = CreateObject('contactcenter.bo_contactcenter'); |
---|
[1599] | 53 | |
---|
[2] | 54 | if ($temp) |
---|
| 55 | { |
---|
| 56 | $this->page_info = $temp; |
---|
| 57 | } |
---|
| 58 | |
---|
| 59 | if ($temp2) |
---|
| 60 | { |
---|
| 61 | $this->all_entries = $temp2; |
---|
| 62 | } |
---|
[1599] | 63 | |
---|
[2] | 64 | if (!$this->page_info['actual_catalog']) |
---|
| 65 | { |
---|
| 66 | $catalogs = $this->bo->get_catalog_tree(); |
---|
| 67 | $this->page_info['actual_catalog'] = $catalogs[0]; |
---|
| 68 | } |
---|
[1599] | 69 | |
---|
| 70 | $this->page_info['actual_catalog'] =& $this->bo->set_catalog($this->page_info['actual_catalog']); |
---|
| 71 | |
---|
| 72 | |
---|
[2] | 73 | if($this->page_info['actual_catalog']['class'] == 'bo_group_manager') |
---|
| 74 | $this -> typeContact = 'groups'; |
---|
[1599] | 75 | /**rev 104**/ |
---|
[752] | 76 | else if($this->page_info['actual_catalog']['class'] == 'bo_shared_group_manager') |
---|
| 77 | $this -> typeContact = 'shared_groups'; |
---|
| 78 | else if($this->page_info['actual_catalog']['class'] == 'bo_shared_people_manager') |
---|
| 79 | $this -> typeContact = 'shared_contacts'; |
---|
[1599] | 80 | /******/ |
---|
[2] | 81 | else |
---|
| 82 | $this -> typeContact = 'contacts'; |
---|
[3795] | 83 | $this->preferences = $_SESSION['phpgw_info']['user']['preferences']['contactcenter']; |
---|
[2] | 84 | } |
---|
| 85 | |
---|
| 86 | /*! |
---|
[1599] | 87 | |
---|
[2] | 88 | @function index |
---|
| 89 | @abstract Builds the Main Page |
---|
| 90 | @author Raphael Derosso Pereira |
---|
| 91 | @author Jonas Goes |
---|
[1599] | 92 | |
---|
| 93 | */ |
---|
[2] | 94 | function index() |
---|
[1599] | 95 | { |
---|
[2] | 96 | if(!@is_object($GLOBALS['phpgw']->js)) |
---|
| 97 | { |
---|
| 98 | $GLOBALS['phpgw']->js = CreateObject('phpgwapi.javascript'); |
---|
| 99 | } |
---|
| 100 | $GLOBALS['phpgw']->js->validate_file('venus','table'); |
---|
| 101 | $GLOBALS['phpgw']->js->validate_file('venus','shapes'); |
---|
| 102 | $GLOBALS['phpgw']->js->validate_file('venus','jsStructUtil'); |
---|
| 103 | $GLOBALS['phpgw']->js->validate_file('venus','cssUtil'); |
---|
[1599] | 104 | |
---|
[2] | 105 | // $GLOBALS['phpgw']->js->set_onload('setTimeout(\'updateCards()\',1000)'); |
---|
| 106 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
[1599] | 107 | |
---|
[2] | 108 | $GLOBALS['phpgw']->template->set_file(array('index' => 'index.tpl')); |
---|
| 109 | $GLOBALS['phpgw']->template->set_var('cc_root_dir', $GLOBALS['phpgw_info']['server']['webserver_url'].'/contactcenter/'); |
---|
[1599] | 110 | |
---|
[2] | 111 | /* Quick Add */ |
---|
| 112 | $GLOBALS['phpgw']->template->set_var('cc_qa_alias',lang('Alias').':'); |
---|
| 113 | $GLOBALS['phpgw']->template->set_var('cc_qa_given_names',lang('Given Names').':'); |
---|
| 114 | $GLOBALS['phpgw']->template->set_var('cc_qa_family_names',lang('Family Names').':'); |
---|
| 115 | $GLOBALS['phpgw']->template->set_var('cc_qa_phone',lang('Phone').':'); |
---|
| 116 | $GLOBALS['phpgw']->template->set_var('cc_qa_email',lang('Email').':'); |
---|
| 117 | $GLOBALS['phpgw']->template->set_var('cc_qa_save',lang('Save')); |
---|
| 118 | $GLOBALS['phpgw']->template->set_var('cc_qa_clear',lang('Clear')); |
---|
[285] | 119 | $GLOBALS['phpgw']->template->set_var('cc_qa_close',lang('Close')); |
---|
[2] | 120 | /* End Quick Add */ |
---|
[1599] | 121 | |
---|
[3282] | 122 | /* Advanced Search */ |
---|
| 123 | |
---|
| 124 | $GLOBALS['phpgw']->template->set_var('cc_corporate',lang('Corporate')); |
---|
| 125 | $GLOBALS['phpgw']->template->set_var('cc_cs_title',lang('Advanced Search')); |
---|
| 126 | $GLOBALS['phpgw']->template->set_var('cc_catalogues',lang('Catalogues')); |
---|
| 127 | |
---|
| 128 | |
---|
| 129 | |
---|
| 130 | /* End of Advanced Search*/ |
---|
| 131 | |
---|
[2] | 132 | $cc_css_file = $GLOBALS['phpgw_info']['server']['webserver_url'].'/contactcenter/styles/cc.css'; |
---|
| 133 | $cc_card_image_file = $GLOBALS['phpgw_info']['server']['webserver_url'].'/contactcenter/templates/default/images/card.png'; |
---|
| 134 | $GLOBALS['phpgw']->template->set_var('cc_css',$cc_css_file); |
---|
| 135 | $GLOBALS['phpgw']->template->set_var('cc_dtree_css', $cc_dtree_file); |
---|
| 136 | $GLOBALS['phpgw']->template->set_var('cc_card_image',$cc_card_image_file); |
---|
[1599] | 137 | |
---|
[2] | 138 | $GLOBALS['phpgw']->template->set_var('cc_personal',lang('Personal')); |
---|
[1599] | 139 | |
---|
| 140 | /***rev 104***/ |
---|
| 141 | //$GLOBALS['phpgw']->template->set_var('cc_full_add',lang('Full Add')); |
---|
[575] | 142 | $GLOBALS['phpgw']->template->set_var('cc_full_add_button',lang('Full Add')); |
---|
[1599] | 143 | /******/ |
---|
| 144 | $GLOBALS['phpgw']->template->set_var('cc_full_add_button_sh',lang('Full Add Shared')); |
---|
[2] | 145 | $GLOBALS['phpgw']->template->set_var('cc_reset',lang('Reset')); |
---|
[1599] | 146 | |
---|
[2] | 147 | $GLOBALS['phpgw']->template->set_var('cc_personal_data',lang('Personal Data')); |
---|
| 148 | $GLOBALS['phpgw']->template->set_var('cc_addresses',lang('Addresses')); |
---|
| 149 | $GLOBALS['phpgw']->template->set_var('cc_connections',lang('Connections')); |
---|
| 150 | $GLOBALS['phpgw']->template->set_var('cc_relations',lang('Relations')); |
---|
| 151 | |
---|
| 152 | $GLOBALS['phpgw']->template->set_var('cc_quick_add',lang('Quick Add')); |
---|
| 153 | $GLOBALS['phpgw']->template->set_var('cc_catalogs',lang('Catalogues')); |
---|
| 154 | $GLOBALS['phpgw']->template->set_var('cc_group_add',lang('Group Add')); |
---|
[1599] | 155 | |
---|
[2] | 156 | /* Panel */ |
---|
| 157 | $GLOBALS['phpgw']->template->set_var('cc_panel_new',lang('New').'...'); |
---|
| 158 | $GLOBALS['phpgw']->template->set_var('cc_panel_search',lang('Search').'...'); |
---|
| 159 | $GLOBALS['phpgw']->template->set_var('cc_panel_table',lang('Table View')); |
---|
| 160 | $GLOBALS['phpgw']->template->set_var('cc_panel_cards',lang('Cards View')); |
---|
[285] | 161 | $GLOBALS['phpgw']->template->set_var('cc_btn_import_export', lang('Import/Export')); |
---|
| 162 | $GLOBALS['phpgw']->template->set_var('cc_btn_new', lang("New...")); |
---|
[1599] | 163 | |
---|
[2] | 164 | $GLOBALS['phpgw']->template->set_var('cc_panel_search_found',lang('Showing found entries')); |
---|
| 165 | $GLOBALS['phpgw']->template->set_var('cc_panel_first_page',lang('First Page')); |
---|
| 166 | $GLOBALS['phpgw']->template->set_var('cc_panel_previous_page',lang('Previous Page')); |
---|
| 167 | $GLOBALS['phpgw']->template->set_var('cc_panel_next_page',lang('Next Page')); |
---|
| 168 | $GLOBALS['phpgw']->template->set_var('cc_panel_last_page',lang('Last Page')); |
---|
| 169 | $GLOBALS['phpgw']->template->set_var('cc_all',lang('all')); |
---|
| 170 | /* End Panel */ |
---|
[1599] | 171 | |
---|
[2] | 172 | /* Messages */ |
---|
[1599] | 173 | /**rev 104**/ |
---|
[503] | 174 | $GLOBALS['phpgw']->template->set_var('cc_msg_not_allowed',lang('Not Allowed')); |
---|
[1599] | 175 | $GLOBALS['phpgw']->template->set_var('cc_msg_unavailable',lang('Unavailable function')); |
---|
| 176 | /*****/ |
---|
[1682] | 177 | |
---|
| 178 | |
---|
| 179 | $GLOBALS['phpgw']->template->set_var('cc_msg_name_mandatory',lang('Name is mandatory')); |
---|
[1690] | 180 | $GLOBALS['phpgw']->template->set_var('cc_msg_err_invalid_serch',lang('The query should not have the characters {%,?}')); |
---|
[1682] | 181 | $GLOBALS['phpgw']->template->set_var('cc_msg_tel_or_mail_required',lang('Tel or email is required')); |
---|
| 182 | |
---|
[2] | 183 | $GLOBALS['phpgw']->template->set_var('cc_msg_no_cards',lang('No Cards')); |
---|
| 184 | $GLOBALS['phpgw']->template->set_var('cc_msg_err_no_room',lang('No Room for Cards! Increase your browser area.')); |
---|
| 185 | $GLOBALS['phpgw']->template->set_var('cc_msg_card_new',lang('New from same Company')); |
---|
| 186 | $GLOBALS['phpgw']->template->set_var('cc_msg_card_edit',lang('Edit Contact')); |
---|
| 187 | $GLOBALS['phpgw']->template->set_var('cc_msg_card_remove',lang('Remove Contact')); |
---|
| 188 | $GLOBALS['phpgw']->template->set_var('cc_send_mail',lang('Send Mail')); |
---|
| 189 | $GLOBALS['phpgw']->template->set_var('cc_msg_group_edit',lang('Edit Group')); |
---|
| 190 | $GLOBALS['phpgw']->template->set_var('cc_msg_group_remove',lang('Remove Group')); |
---|
| 191 | $GLOBALS['phpgw']->template->set_var('cc_msg_group_remove_confirm',lang('Confirm Removal of this Group?')); |
---|
| 192 | $GLOBALS['phpgw']->template->set_var('cc_msg_card_remove_confirm',lang('Confirm Removal of this Contact?')); |
---|
| 193 | $GLOBALS['phpgw']->template->set_var('cc_participants',lang('Participants')); |
---|
| 194 | $GLOBALS['phpgw']->template->set_var('cc_empty',lang('Empty')); |
---|
| 195 | /* End Messages */ |
---|
[1599] | 196 | |
---|
[2] | 197 | $GLOBALS['phpgw']->template->set_var('cc_results',lang('Results')); |
---|
| 198 | $GLOBALS['phpgw']->template->set_var('cc_is_my',lang('Is My')); |
---|
[285] | 199 | $GLOBALS['phpgw']->template->set_var('cc_ie_personal',lang('Import/Export pesonal contacts')); |
---|
[2] | 200 | $GLOBALS['phpgw']->template->set_var('cc_btn_search',lang('Search')); |
---|
| 201 | $GLOBALS['phpgw']->template->set_var('cc_add_relation',lang('Add Relation')); |
---|
[1599] | 202 | $GLOBALS['phpgw']->template->set_var('cc_del_relation',lang('Remove Selected Relations')); |
---|
[38] | 203 | $GLOBALS['phpgw']->template->set_var('cc_msg_group',lang('Group')); |
---|
| 204 | $GLOBALS['phpgw']->template->set_var('cc_msg_contact_full',lang('Contact [Full]')); |
---|
[1496] | 205 | $GLOBALS['phpgw']->template->set_var('cc_msg_contact_sh',lang('Contact [Shared]')); |
---|
[38] | 206 | $GLOBALS['phpgw']->template->set_var('cc_msg_contact_qa',lang('Contact [Quick Add]')); |
---|
[2] | 207 | $GLOBALS['phpgw']->template->set_var('cc_contact_title',lang('Contact Center').' - '.lang('Contacts')); |
---|
| 208 | $GLOBALS['phpgw']->template->set_var('cc_window_views_title',lang('Contact Center').' - '.lang('Views')); |
---|
| 209 | $GLOBALS['phpgw']->template->set_var('phpgw_img_dir', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/phpgwapi/images'); |
---|
[118] | 210 | |
---|
[285] | 211 | $GLOBALS['phpgw']->template->set_var('cc_msg_import_contacts', lang('Import Contacts')); |
---|
| 212 | $GLOBALS['phpgw']->template->set_var('cc_msg_export_contacts', lang('Export Contacts')); |
---|
| 213 | $GLOBALS['phpgw']->template->set_var('cc_msg_expresso_info_csv', lang('The Expresso supports the contacts importation in the CSV file format.')); |
---|
| 214 | $GLOBALS['phpgw']->template->set_var('cc_msg_choose_file_type', lang('Select the file type')); |
---|
| 215 | $GLOBALS['phpgw']->template->set_var('cc_msg_outlook_express', lang('Outlook Express')); |
---|
| 216 | $GLOBALS['phpgw']->template->set_var('cc_msg_outlook2k', lang('Outlook 2000')); |
---|
| 217 | $GLOBALS['phpgw']->template->set_var('cc_msg_expresso_default', lang('Expresso (default)')); |
---|
| 218 | $GLOBALS['phpgw']->template->set_var('cc_msg_choose_contacts_file', lang('Select the file that contains the contacts to be imported:')); |
---|
| 219 | $GLOBALS['phpgw']->template->set_var('cc_msg_close_win', lang('Close')); |
---|
| 220 | $GLOBALS['phpgw']->template->set_var('cc_msg_close', lang('Close')); |
---|
| 221 | $GLOBALS['phpgw']->template->set_var('cc_msg_ie_personal', lang('Import / Export personal Contacts')); |
---|
| 222 | $GLOBALS['phpgw']->template->set_var('cc_msg_import_fail', lang('The importation has failed. Verify the file format.')); |
---|
| 223 | $GLOBALS['phpgw']->template->set_var('cc_msg_importing_contacts', lang('Importing Contacts...')); |
---|
| 224 | $GLOBALS['phpgw']->template->set_var('cc_msg_import_finished', lang('The importation has finished.')); |
---|
| 225 | $GLOBALS['phpgw']->template->set_var('cc_msg_new', lang(' new')); |
---|
| 226 | $GLOBALS['phpgw']->template->set_var('cc_msg_failure', lang(' failed')); |
---|
| 227 | $GLOBALS['phpgw']->template->set_var('cc_msg_exists', lang(' were existent')); |
---|
| 228 | $GLOBALS['phpgw']->template->set_var('cc_msg_show_more_info', lang('show more info')); |
---|
| 229 | $GLOBALS['phpgw']->template->set_var('cc_msg_clean', lang('Clean')); |
---|
| 230 | $GLOBALS['phpgw']->template->set_var('cc_msg_invalid_csv', lang('Select a valid CSV file to import your contacts')); |
---|
| 231 | $GLOBALS['phpgw']->template->set_var('cc_msg_export_csv', lang('Select the format type that you want to export your contacts')); |
---|
| 232 | $GLOBALS['phpgw']->template->set_var('cc_msg_automatic', lang('Automatic')); |
---|
| 233 | $GLOBALS['phpgw']->template->set_var('cc_msg_export_error', lang('An error has occurred while the exportation.')); |
---|
| 234 | $GLOBALS['phpgw']->template->set_var('cc_msg_new_email', lang('New Email')); |
---|
| 235 | $GLOBALS['phpgw']->template->set_var('cc_msg_main', lang('Main')); |
---|
| 236 | $GLOBALS['phpgw']->template->set_var('cc_msg_alternative', lang('Alternative')); |
---|
| 237 | $GLOBALS['phpgw']->template->set_var('cc_msg_select_email', lang('Select E-Mail')); |
---|
| 238 | $GLOBALS['phpgw']->template->set_var('cc_msg_new_phone', lang('New Telephone')); |
---|
[3549] | 239 | $GLOBALS['phpgw']->template->set_var('cc_msg_home', lang('Home Phone')); |
---|
[285] | 240 | $GLOBALS['phpgw']->template->set_var('cc_msg_cellphone', lang('Cellphone')); |
---|
[1517] | 241 | $GLOBALS['phpgw']->template->set_var('cc_msg_corporative_cellphone', lang('Corporative Cellphone')); |
---|
| 242 | $GLOBALS['phpgw']->template->set_var('cc_msg_corporative_fax', lang('Corporative Fax')); |
---|
[1599] | 243 | $GLOBALS['phpgw']->template->set_var('cc_msg_corporative_pager', lang('Corporative Pager')); |
---|
[285] | 244 | $GLOBALS['phpgw']->template->set_var('cc_msg_work', lang('Work')); |
---|
| 245 | $GLOBALS['phpgw']->template->set_var('cc_msg_fax', lang('Fax')); |
---|
| 246 | $GLOBALS['phpgw']->template->set_var('cc_msg_pager', lang('Pager')); |
---|
| 247 | $GLOBALS['phpgw']->template->set_var('cc_msg_choose_phone', lang('Select the telephone')); |
---|
| 248 | $GLOBALS['phpgw']->template->set_var('cc_msg_warn_firefox', lang('Warning: Too old version of Firefox')); |
---|
| 249 | $GLOBALS['phpgw']->template->set_var('cc_msg_firefox_half1', lang('For this application work correctly</u>')); |
---|
| 250 | $GLOBALS['phpgw']->template->set_var('cc_msg_firefox_half2', lang('it\'s necessary to update your Firefox Browser for a new version (version > 1.5) Install now clicking in the link bellow, or if you want to update it later')); |
---|
| 251 | $GLOBALS['phpgw']->template->set_var('cc_msg_click_close', lang('click Close')); |
---|
| 252 | $GLOBALS['phpgw']->template->set_var('cc_msg_install_now', lang('Install Now')); |
---|
| 253 | $GLOBALS['phpgw']->template->set_var('cc_msg_install_new_firefox', lang('Install a new Firefox version')); |
---|
| 254 | $GLOBALS['phpgw']->template->set_var('cc_msg_moz_thunderbird', lang('Export as Mozilla Thunderbird CSV.')); |
---|
| 255 | $GLOBALS['phpgw']->template->set_var('cc_msg_outlook_express_pt', lang('Export as Outlook Express (Portuguese) CSV.')); |
---|
| 256 | $GLOBALS['phpgw']->template->set_var('cc_msg_outlook_express_en', lang('Export as Outlook Express (English) CSV.')); |
---|
| 257 | $GLOBALS['phpgw']->template->set_var('cc_msg_outlook_2k_pt', lang('Export as Outlook 2000 (Portuguese) CSV.')); |
---|
| 258 | $GLOBALS['phpgw']->template->set_var('cc_msg_outlook_2k_en', lang('Export as Outlook 2000 (English) CSV.')); |
---|
| 259 | $GLOBALS['phpgw']->template->set_var('cc_msg_expresso_default_csv', lang('Export as Expresso (Default) CSV.')); |
---|
| 260 | $GLOBALS['phpgw']->template->set_var('cc_msg_copy_to_catalog', lang('Copy to personal catalog.')); |
---|
| 261 | $GLOBALS['phpgw']->template->set_var('cc_msg_add_contact_to_group', lang('You did not add any contact for this group.')); |
---|
| 262 | $GLOBALS['phpgw']->template->set_var('cc_msg_fill_field_name', lang('Fill the field Full Name')); |
---|
[1599] | 263 | |
---|
[3334] | 264 | $select_groups = ''; |
---|
| 265 | |
---|
| 266 | $this->so_group = CreateObject('contactcenter.so_group'); |
---|
| 267 | |
---|
| 268 | $array_groups = $this->so_group->selectGroupsOwnerCanImportContacts($GLOBALS['phpgw_info']['user']['account_id']); |
---|
| 269 | |
---|
| 270 | $select_groups = "<select id='id_group'>";//<option value=0>Selecione um grupo...</option></select>"; |
---|
| 271 | $select_groups .= "<option value=0 selected>Nenhum...</option>"; |
---|
| 272 | foreach ($array_groups as $group){ |
---|
| 273 | $select_groups .= "<option value='".$group['id_group']."'>".$group['title']."</option>"; |
---|
| 274 | } |
---|
| 275 | $select_groups .= "</select>"; |
---|
| 276 | |
---|
| 277 | $GLOBALS['phpgw']->template->set_var('cc_select_groups',$select_groups); |
---|
| 278 | |
---|
[1517] | 279 | if($GLOBALS['phpgw_info']['server']['personal_contact_type']=='True'){ |
---|
| 280 | $GLOBALS['phpgw']->template->set_var('cc_contact_type', 'advanced'); |
---|
| 281 | }else{ |
---|
| 282 | $GLOBALS['phpgw']->template->set_var('cc_contact_type', 'default'); |
---|
| 283 | } |
---|
[2] | 284 | $GLOBALS['phpgw']->template->parse('out','index'); |
---|
[1599] | 285 | |
---|
[2] | 286 | $api = CreateObject('contactcenter.ui_api'); |
---|
| 287 | $main = $api->get_full_add(); |
---|
| 288 | $main .= $api->get_search_obj(); |
---|
| 289 | $main .= $api->get_quick_add_plugin(); |
---|
| 290 | $main .= $api->get_add_group(); |
---|
| 291 | $main .= $GLOBALS['phpgw']->template->get_var('out'); |
---|
| 292 | |
---|
| 293 | echo $main; |
---|
| 294 | } |
---|
| 295 | |
---|
[1599] | 296 | |
---|
[2] | 297 | /*! |
---|
[1599] | 298 | |
---|
[2] | 299 | @function data_manager |
---|
[1599] | 300 | @abstract Calls the right method and passes to it the right |
---|
[2] | 301 | parameters |
---|
| 302 | @author Raphael Derosso Pereira |
---|
[1599] | 303 | |
---|
[2] | 304 | */ |
---|
| 305 | function data_manager() |
---|
| 306 | { |
---|
| 307 | switch($_GET['method']) |
---|
| 308 | { |
---|
| 309 | /* Cards Methods */ |
---|
| 310 | case 'set_n_cards': |
---|
| 311 | return $this->set_n_cards((int)$_GET['ncards']); |
---|
[1599] | 312 | |
---|
| 313 | case 'get_cards_data': |
---|
[3303] | 314 | |
---|
[284] | 315 | $ids = false; |
---|
| 316 | // To support ldap catalogs using accentuation |
---|
| 317 | if ($_POST['letter'] == 'search' && isset($_POST['data'])) |
---|
| 318 | { |
---|
[285] | 319 | $ids = utf8_decode($this->search($_POST['data'])); |
---|
[284] | 320 | } |
---|
[1599] | 321 | |
---|
[285] | 322 | if(isset($_SESSION['ids'])) |
---|
| 323 | $ids = $_SESSION['ids']; |
---|
[1599] | 324 | |
---|
| 325 | return $this->get_cards_data($_POST['letter'], $_POST['page'], $ids); |
---|
| 326 | |
---|
[2] | 327 | case 'get_cards_data_get': |
---|
| 328 | return $this->get_cards_data($_GET['letter'], $_GET['page'], unserialize(str_replace('\\"','"',$_GET['ids']))); |
---|
| 329 | |
---|
| 330 | |
---|
| 331 | case 'get_photo': |
---|
| 332 | return $this->get_photo($_GET['id']); |
---|
| 333 | |
---|
[3795] | 334 | case 'get_init_values': |
---|
| 335 | echo serialize(array("visible_all_ldap" => $this->get_visible_all_ldap(), "preferences" => $this->preferences)); |
---|
[285] | 336 | return; |
---|
[1599] | 337 | |
---|
[2] | 338 | /* Catalog Methods */ |
---|
| 339 | case 'set_catalog': |
---|
| 340 | return $this->set_catalog($_GET['catalog']); |
---|
[1599] | 341 | |
---|
[2] | 342 | case 'get_catalog_tree': |
---|
| 343 | echo serialize($this->get_catalog_tree($_GET['level'])); |
---|
| 344 | return; |
---|
| 345 | |
---|
| 346 | case 'get_actual_catalog': |
---|
| 347 | echo serialize($this->get_actual_catalog()); |
---|
| 348 | return; |
---|
| 349 | |
---|
| 350 | case 'get_catalog_participants_list': |
---|
| 351 | echo serialize($this->get_catalog_participants_list($_POST['id'])); |
---|
| 352 | return; |
---|
[1599] | 353 | /**rev 104**/ |
---|
[880] | 354 | case 'get_catalog_participants_group': |
---|
| 355 | echo serialize($this->get_catalog_participants_group($_POST['id'])); |
---|
| 356 | return; |
---|
[1599] | 357 | /***/ |
---|
[2] | 358 | case 'get_catalog_add_contact': |
---|
[284] | 359 | // To support ldap catalogs with accentuation |
---|
| 360 | echo serialize($this->get_catalog_add_contact(utf8_decode($_POST['id']))); |
---|
[2] | 361 | return; |
---|
[1599] | 362 | |
---|
[2] | 363 | /* Full Add Methods */ |
---|
| 364 | case 'get_full_data': |
---|
[1599] | 365 | //return $this->get_full_data($_GET['id']); |
---|
| 366 | /**rev 104**/ |
---|
[503] | 367 | return $this->get_full_data($_GET['id'],$_GET['catalog']); |
---|
[1599] | 368 | /****/ |
---|
| 369 | |
---|
[2] | 370 | case 'get_group': |
---|
[1280] | 371 | return $this->get_group_data($_GET['id'],isset($_GET['shared_from'])?$_GET['shared_from']:null); |
---|
[1599] | 372 | |
---|
[2] | 373 | case 'get_contact_full_add_const': |
---|
| 374 | return $this->get_contact_full_add_const(); |
---|
| 375 | |
---|
| 376 | case 'post_full_add': |
---|
| 377 | return $this->post_full_add(); |
---|
| 378 | |
---|
[1496] | 379 | case 'post_full_add_shared' : |
---|
| 380 | return $this->post_full_add_shared(); |
---|
| 381 | |
---|
[2] | 382 | case 'post_photo': |
---|
| 383 | return $this->post_photo((int) $_GET['id'] ? (int) $_GET['id'] : '_new_'); |
---|
| 384 | |
---|
| 385 | case 'get_states': |
---|
| 386 | return $this->get_states($_GET['country']); |
---|
[1599] | 387 | |
---|
[2] | 388 | case 'get_cities': |
---|
| 389 | return $this->get_cities($_GET['country'], $_GET['state'] ? $_GET['state'] : null); |
---|
[1599] | 390 | |
---|
| 391 | |
---|
[2] | 392 | /* Other Methods */ |
---|
[1599] | 393 | case 'quick_add': |
---|
[2] | 394 | return $this->quick_add($_POST['add']); |
---|
[1599] | 395 | |
---|
| 396 | case 'add_group': |
---|
[2] | 397 | return $this->add_group($_POST['add']); |
---|
[1599] | 398 | |
---|
[2] | 399 | case 'remove_entry': |
---|
| 400 | return $this->remove_entry((int)$_GET['remove']); |
---|
[1599] | 401 | |
---|
[2] | 402 | case 'remove_all_entries': |
---|
| 403 | return $this->remove_all_entries(); |
---|
| 404 | |
---|
| 405 | case 'remove_group': |
---|
| 406 | |
---|
[1599] | 407 | return $this->remove_group((int)$_GET['remove']); |
---|
| 408 | |
---|
[2] | 409 | case 'search': |
---|
[285] | 410 | $ids = false; |
---|
| 411 | $ids = $this->search($_GET['data']); |
---|
| 412 | return $this->get_cards_data('search', '1', $ids); |
---|
[2] | 413 | |
---|
| 414 | case 'email_win': |
---|
| 415 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 416 | $api = CreateObject('contactcenter.ui_api'); |
---|
| 417 | $win = $api->get_email_win(); |
---|
| 418 | $win .= $api->get_quick_add_plugin(); |
---|
| 419 | $win .= '<input id="QAbutton" type="button" value="QuickAdd" />' |
---|
| 420 | .'<br><input type="button" value="EmailWin" onclick="ccEmailWin.open()" />' |
---|
| 421 | .'<script type="text/javascript">' |
---|
| 422 | .' ccQuickAdd.associateAsButton(Element("QAbutton"));' |
---|
| 423 | .'</script>'; |
---|
| 424 | echo $win; |
---|
| 425 | return; |
---|
| 426 | |
---|
| 427 | /* Information Gathering */ |
---|
| 428 | case 'get_multiple_entries': |
---|
| 429 | echo serialize($this->get_multiple_entries(str_replace('\\"','"',$_POST['data']))); |
---|
| 430 | return; |
---|
| 431 | |
---|
| 432 | case 'get_all_entries': |
---|
| 433 | echo serialize($this->get_all_entries(str_replace('\\"','"',$_POST['data']))); |
---|
| 434 | return; |
---|
| 435 | |
---|
| 436 | case 'import_contacts': |
---|
[3334] | 437 | return $this->import_contacts($_GET['typeImport'],$_GET['id_group']); |
---|
[2] | 438 | |
---|
| 439 | case 'export_contacts': |
---|
| 440 | return $this->export_contacts($_POST['typeExport']); |
---|
[3313] | 441 | |
---|
| 442 | case 'get_qtds_compartilhado': |
---|
| 443 | return $this->get_qtds_compartilhado(); |
---|
[3335] | 444 | case 'get_list_owners_perms_add': |
---|
| 445 | echo $this->get_list_owners_perms_add(); |
---|
| 446 | return; |
---|
[2] | 447 | |
---|
| 448 | } |
---|
| 449 | } |
---|
| 450 | |
---|
| 451 | /*! |
---|
[1599] | 452 | |
---|
[2] | 453 | @function set_n_cards |
---|
| 454 | @abstract Informs the class the number of cards the page can show |
---|
| 455 | @author Raphael Derosso Pereira |
---|
[1599] | 456 | |
---|
[2] | 457 | @param integer $n_cards The number of cards |
---|
[1599] | 458 | |
---|
[2] | 459 | */ |
---|
| 460 | function set_n_cards($n_cards) |
---|
| 461 | { |
---|
| 462 | if (is_int($n_cards)) |
---|
| 463 | { |
---|
| 464 | $this->page_info['n_cards'] = $n_cards; |
---|
| 465 | echo 1; |
---|
| 466 | } |
---|
[1599] | 467 | |
---|
[2] | 468 | $this->save_session(); |
---|
| 469 | } |
---|
[1599] | 470 | |
---|
[2] | 471 | /*! |
---|
[1599] | 472 | |
---|
[2] | 473 | @function set_catalog |
---|
| 474 | @abstract Sets the current catalog selected by the user |
---|
| 475 | @author Raphael Derosso Pereira |
---|
[1599] | 476 | |
---|
[2] | 477 | @param string $id_catalog The sequence of IDs to reach the catalog |
---|
| 478 | separated by commas |
---|
[1599] | 479 | |
---|
[2] | 480 | */ |
---|
| 481 | function set_catalog($id_catalog) |
---|
| 482 | { |
---|
| 483 | $id_catalog = str_replace('\\"', '"', $id_catalog); |
---|
| 484 | $temp =& $this->bo->set_catalog($id_catalog); |
---|
[1599] | 485 | |
---|
[3333] | 486 | if(!$this->bo->catalog->src_info) { |
---|
| 487 | $ldap = CreateObject('contactcenter.bo_ldap_manager'); |
---|
| 488 | $this->bo->catalog->src_info = $ldap->srcs[1]; |
---|
| 489 | } |
---|
| 490 | |
---|
| 491 | $resetCC_actual_letter = 0; |
---|
| 492 | if($this->bo->catalog->src_info['visible'] == "false") |
---|
| 493 | { |
---|
| 494 | $resetCC_actual_letter = 1; |
---|
| 495 | } |
---|
| 496 | |
---|
[2] | 497 | if ($temp) |
---|
| 498 | { |
---|
[3333] | 499 | unset($this->page_info['actual_letter']); |
---|
[2] | 500 | $this->page_info['changed'] = true; |
---|
| 501 | $this->page_info['actual_entries'] = false; |
---|
| 502 | $this->page_info['actual_catalog'] =& $temp; |
---|
| 503 | $this->save_session(); |
---|
[1599] | 504 | |
---|
[2] | 505 | $catalog_info = $this->bo->get_branch_by_level($this->bo->catalog_level[0]); |
---|
[1599] | 506 | |
---|
[2] | 507 | if ($catalog_info['class'] === 'bo_global_ldap_catalog' || |
---|
| 508 | $catalog_info['class'] === 'bo_catalog_group_catalog') |
---|
| 509 | { |
---|
| 510 | $perms = 1; |
---|
| 511 | } |
---|
| 512 | else |
---|
| 513 | { |
---|
| 514 | $perms = 15; |
---|
| 515 | } |
---|
[1599] | 516 | |
---|
[2] | 517 | echo serialize(array( |
---|
| 518 | 'status' => 'ok', |
---|
[3282] | 519 | 'catalog' => $catalog_info['class'], |
---|
| 520 | 'external' => $catalog_info['external']?true:false, |
---|
[3333] | 521 | 'resetCC_actual_letter' => $resetCC_actual_letter, |
---|
[2] | 522 | 'perms' => $perms |
---|
| 523 | )); |
---|
| 524 | |
---|
| 525 | return; |
---|
| 526 | } |
---|
[1599] | 527 | |
---|
[2] | 528 | echo serialize(array( |
---|
| 529 | 'status' => 'ok', |
---|
[3333] | 530 | 'resetCC_actual_letter' => $resetCC_actual_letter, |
---|
[2] | 531 | 'perms' => 0 |
---|
| 532 | )); |
---|
| 533 | } |
---|
[1599] | 534 | |
---|
| 535 | |
---|
[2] | 536 | /*! |
---|
[1599] | 537 | |
---|
[2] | 538 | @function get_catalog_tree |
---|
| 539 | @abstract Returns the JS serialized array to used as the tree |
---|
| 540 | level |
---|
| 541 | @author Raphael Derosso Pereira |
---|
[3334] | 542 | @author Mário César Kolling (error messages and timeout) |
---|
[1599] | 543 | |
---|
| 544 | @param (string) $level The level to be taken |
---|
| 545 | |
---|
[2] | 546 | */ |
---|
| 547 | function get_catalog_tree($level) |
---|
| 548 | { |
---|
| 549 | if ($level === '0') |
---|
| 550 | { |
---|
| 551 | $folderImageDir = $GLOBALS['phpgw_info']['server']['webserver_url'] . '/phpgwapi/dftree/images/'; |
---|
| 552 | |
---|
| 553 | $parent = '0'; |
---|
[1599] | 554 | |
---|
[2] | 555 | if (!($tree = $this->bo->get_catalog_tree($level))) |
---|
| 556 | { |
---|
| 557 | return array( |
---|
| 558 | 'msg' => lang('Couldn\'t get the Catalogue Tree. Please contact the Administrator.'), |
---|
| 559 | 'status' => 'fatal' |
---|
| 560 | ); |
---|
| 561 | } |
---|
| 562 | } |
---|
| 563 | else |
---|
| 564 | { |
---|
| 565 | $last_dot = strrpos($level,'.'); |
---|
| 566 | $parent = substr($level, 0, $last_dot); |
---|
| 567 | $child = substr($level, $last_dot+1, strlen($level)); |
---|
| 568 | if (!($tree[$child] = $this->bo->get_catalog_tree($level))) |
---|
| 569 | { |
---|
| 570 | return array( |
---|
| 571 | 'msg' => lang('Couldn\'t get the Catalogue Tree. Please contact the Administrator.'), |
---|
| 572 | 'status' => 'fatal' |
---|
| 573 | ); |
---|
| 574 | } |
---|
[284] | 575 | // Deals with timeout and returns the generated message to the browser |
---|
| 576 | else if (!empty($tree[$child]['timeout']) && !empty($tree[$child]['msg'])) |
---|
| 577 | { |
---|
| 578 | $tmp = array( |
---|
| 579 | 'msg' => $tree[$child]['msg'], |
---|
| 580 | 'status' => 'fatal' |
---|
| 581 | ); |
---|
| 582 | unset($tree[$child]); |
---|
| 583 | return $tmp; |
---|
| 584 | } |
---|
[2] | 585 | } |
---|
[1599] | 586 | |
---|
[2] | 587 | $folderImageDir = $GLOBALS['phpgw']->common->image('contactcenter','globalcatalog-mini.png'); |
---|
| 588 | $folderImageDir = substr($folderImageDir, 0, strpos($folderImageDir, 'globalcatalog-mini.png')); |
---|
[1599] | 589 | |
---|
[284] | 590 | // Deals with error messages from the server and returns them to the browser |
---|
| 591 | if ($tree['msg']) |
---|
| 592 | { |
---|
| 593 | $msg = $tree['msg']; |
---|
| 594 | unset($tree['msg']); |
---|
| 595 | } |
---|
| 596 | |
---|
[2] | 597 | $tree_js = $this->convert_tree($tree, $folderImageDir, $parent); |
---|
[284] | 598 | |
---|
| 599 | // Return status = ok, or else return generated message to the browser |
---|
| 600 | if (!$msg) |
---|
| 601 | { |
---|
| 602 | return array( |
---|
| 603 | 'data' => $tree_js, |
---|
| 604 | 'msg' => lang('Catalog Tree Successfully taken!'), |
---|
| 605 | 'status' => 'ok' |
---|
| 606 | ); |
---|
| 607 | } |
---|
| 608 | else |
---|
| 609 | { |
---|
| 610 | return array( |
---|
| 611 | 'data' => $tree_js, |
---|
| 612 | 'msg' => $msg, |
---|
| 613 | 'status' => 'error' |
---|
| 614 | ); |
---|
| 615 | } |
---|
[2] | 616 | } |
---|
[1599] | 617 | |
---|
[2] | 618 | /*! |
---|
[1599] | 619 | |
---|
[2] | 620 | @function get_actual_catalog |
---|
| 621 | @abstract Returns the actual selected Catalog |
---|
| 622 | @author Raphael Derosso Pereira |
---|
| 623 | |
---|
| 624 | */ |
---|
| 625 | function get_actual_catalog() |
---|
[1599] | 626 | { |
---|
[2] | 627 | $level = $this->bo->get_level_by_branch($this->bo->get_actual_catalog(), $this->bo->tree['branches'], '0'); |
---|
[1599] | 628 | |
---|
[2] | 629 | if ($level) |
---|
| 630 | { |
---|
| 631 | return array( |
---|
| 632 | 'status' => 'ok', |
---|
| 633 | 'data' => $level |
---|
| 634 | ); |
---|
| 635 | } |
---|
| 636 | |
---|
| 637 | return array( |
---|
| 638 | 'status' => 'fatal', |
---|
| 639 | 'msg' => lang('Couldn\'t get the actual catalog.'), |
---|
| 640 | ); |
---|
| 641 | } |
---|
[1599] | 642 | |
---|
[3313] | 643 | function get_qtds_compartilhado() { |
---|
| 644 | $so_contact = CreateObject('contactcenter.so_contact', $GLOBALS['phpgw_info']['user']['account_id']); |
---|
| 645 | $relacionados = $so_contact->get_relations(); |
---|
| 646 | |
---|
| 647 | $perms_relacao = array(); |
---|
| 648 | |
---|
| 649 | foreach($relacionados as $uid_relacionado => $tipo_relacionamento) { |
---|
| 650 | $aclTemp = CreateObject("phpgwapi.acl",$uid_relacionado); |
---|
| 651 | $aclTemp->read(); |
---|
| 652 | $perms_relacao[$uid_relacionado] = $aclTemp->get_specific_rights($GLOBALS['phpgw_info']['user']['account_id'],'contactcenter'); //Preciso verificar as permissões que o contato relacionado deu para o atual |
---|
| 653 | } |
---|
| 654 | |
---|
| 655 | $validos = array(); |
---|
| 656 | $count = 0; |
---|
| 657 | foreach($perms_relacao as $uid_relacionado => $val){ |
---|
| 658 | if ($perms_relacao[$uid_relacionado]&2) |
---|
| 659 | { |
---|
| 660 | $validos[$uid_relacionado] = $perms_relacao[$uid_relacionado]; |
---|
| 661 | $count++; |
---|
| 662 | } |
---|
| 663 | } |
---|
| 664 | echo serialize(array(0=>$count)); |
---|
| 665 | } |
---|
| 666 | |
---|
[2] | 667 | /*! |
---|
[1599] | 668 | |
---|
[2] | 669 | @function get_cards_data |
---|
| 670 | @abstract Returns the information that is placed on the cards |
---|
| 671 | @author Raphael Derosso Pereira |
---|
[1599] | 672 | |
---|
[2] | 673 | @param string $letter The first letter to be searched |
---|
[1599] | 674 | @param (int) $page The page to be taken |
---|
[2] | 675 | @param (str) $ids The ids to be taken in case of search |
---|
| 676 | |
---|
| 677 | TODO: This function is not well done. It must be rewritten |
---|
| 678 | using the new array 'msg','status','data' schema. |
---|
| 679 | */ |
---|
| 680 | function get_cards_data($letter, $page, $ids) |
---|
| 681 | { |
---|
[285] | 682 | if( $ids ) |
---|
[1599] | 683 | $_SESSION['ids'] = $ids; |
---|
[284] | 684 | |
---|
| 685 | // It's an external catalog? |
---|
| 686 | $external = $this->bo->is_external($this->page_info['actual_catalog']); |
---|
[2] | 687 | //echo $page."\n"; |
---|
| 688 | if ($letter !== 'search' and ($letter != $this->page_info['actual_letter'] or |
---|
[1599] | 689 | ($letter == $this->page_info['actual_letter'] and $page == $this->page_info['actual_page']) or |
---|
[2] | 690 | $this->page_info['changed'])) |
---|
| 691 | { |
---|
| 692 | unset($ids); |
---|
| 693 | $this->page_info['changed'] = false; |
---|
[1599] | 694 | |
---|
[2] | 695 | switch ($this->page_info['actual_catalog']['class']) |
---|
| 696 | { |
---|
[1599] | 697 | /**rev 104**/ |
---|
[752] | 698 | case 'bo_shared_people_manager': |
---|
[1599] | 699 | /****/ |
---|
[752] | 700 | case 'bo_people_catalog': |
---|
[503] | 701 | $field_name = 'id_contact'; |
---|
[1599] | 702 | |
---|
[503] | 703 | if ($letter !== 'number') |
---|
| 704 | { |
---|
| 705 | $find_restric[0] = array( |
---|
| 706 | 0 => array( |
---|
| 707 | 'field' => 'contact.names_ordered', |
---|
| 708 | 'type' => 'iLIKE', |
---|
| 709 | 'value' => $letter !== 'all' ? $letter.'%' : '%' |
---|
[1599] | 710 | /**rev 104**/ |
---|
| 711 | /* ), |
---|
| 712 | 1 => array( |
---|
| 713 | 'field' => 'contact.id_owner', |
---|
| 714 | 'type' => '=', |
---|
| 715 | 'value' => $GLOBALS['phpgw_info']['user']['account_id'] |
---|
| 716 | */ |
---|
| 717 | ) |
---|
[503] | 718 | ); |
---|
[1496] | 719 | |
---|
| 720 | //Tratamento de permissão de escrita no compartilhamento de catalogo |
---|
| 721 | $so_contact = CreateObject('contactcenter.so_contact', $GLOBALS['phpgw_info']['user']['account_id']); |
---|
| 722 | $relacionados = $so_contact->get_relations(); |
---|
| 723 | |
---|
[1599] | 724 | $perms_relacao = array(); |
---|
| 725 | |
---|
[1496] | 726 | foreach($relacionados as $uid_relacionado => $tipo_relacionamento) { |
---|
| 727 | $aclTemp = CreateObject("phpgwapi.acl",$uid_relacionado); |
---|
| 728 | $aclTemp->read(); |
---|
| 729 | $perms_relacao[$uid_relacionado] = $aclTemp->get_specific_rights($GLOBALS['phpgw_info']['user']['account_id'],'contactcenter'); //Preciso verificar as permissões que o contato relacionado deu para o atual |
---|
| 730 | } |
---|
| 731 | |
---|
| 732 | $validos = array(); |
---|
| 733 | $count = 0; |
---|
| 734 | foreach($perms_relacao as $uid_relacionado => $val){ |
---|
| 735 | if ($perms_relacao[$uid_relacionado]&2) |
---|
| 736 | { |
---|
| 737 | $validos[$uid_relacionado] = $perms_relacao[$uid_relacionado]; |
---|
| 738 | $count++; |
---|
| 739 | } |
---|
| 740 | } |
---|
| 741 | $prop_names = array(); |
---|
| 742 | if($validos) { |
---|
| 743 | $filtro = "(|"; |
---|
| 744 | foreach($validos as $i => $prop) { |
---|
| 745 | $filtro .= "(uidNumber=".$i.")"; |
---|
| 746 | } |
---|
| 747 | $filtro .= ")"; |
---|
| 748 | |
---|
| 749 | if(!$this->bo->catalog->src_info) { |
---|
| 750 | $ldaps = CreateObject('contactcenter.bo_ldap_manager'); |
---|
| 751 | $this->bo->catalog->src_info = $ldaps->srcs[1]; |
---|
| 752 | } |
---|
| 753 | $s = $GLOBALS['phpgw']->common->ldapConnect($this->bo->catalog->src_info['host'], $this->bo->catalog->src_info['acc'], $this->bo->catalog->src_info['pw'], false); |
---|
| 754 | $n=$this->bo->catalog->src_info['dn']; |
---|
| 755 | $apenasThese = array("cn","uidnumber","uid"); |
---|
[1599] | 756 | $r = ldap_search($s,$n, $filtro,$apenasThese); |
---|
[1496] | 757 | $infos = ldap_get_entries($s, $r); |
---|
[1599] | 758 | ldap_close($s); |
---|
[1496] | 759 | for($z = 0; $z < $infos['count']; $z++) { |
---|
| 760 | $prop_names[$infos[$z]['uidnumber'][0]] = array("cn" => $infos[$z]['cn'][0], "uid" => $infos[$z]['uid'][0]); |
---|
| 761 | } |
---|
| 762 | } |
---|
| 763 | //-------------------------------------------------------------------------------- |
---|
| 764 | if($this->page_info['actual_catalog']['class'] == 'bo_people_catalog') |
---|
| 765 | { |
---|
[752] | 766 | $find_restric[0][1] = array( |
---|
| 767 | 'field' => 'contact.id_owner', |
---|
| 768 | 'type' => '=', |
---|
| 769 | 'value' => $GLOBALS['phpgw_info']['user']['account_id'] |
---|
| 770 | ); |
---|
| 771 | } |
---|
[1599] | 772 | /****/ |
---|
| 773 | |
---|
[503] | 774 | } |
---|
| 775 | else |
---|
| 776 | { |
---|
| 777 | $find_restric[0] = array( |
---|
| 778 | 0 => array( |
---|
| 779 | 'type' => 'branch', |
---|
| 780 | 'value' => 'OR', |
---|
| 781 | 'sub_branch' => array( |
---|
| 782 | 0 => array( |
---|
| 783 | 'field' => 'contact.names_ordered', |
---|
| 784 | 'type' => 'LIKE', |
---|
| 785 | 'value' => '0%' |
---|
| 786 | ), |
---|
| 787 | 1 => array( |
---|
| 788 | 'field' => 'contact.names_ordered', |
---|
| 789 | 'type' => 'LIKE', |
---|
| 790 | 'value' => '1%' |
---|
| 791 | ), |
---|
| 792 | 2 => array( |
---|
| 793 | 'field' => 'contact.names_ordered', |
---|
| 794 | 'type' => 'LIKE', |
---|
| 795 | 'value' => '2%' |
---|
| 796 | ), |
---|
| 797 | 3 => array( |
---|
| 798 | 'field' => 'contact.names_ordered', |
---|
| 799 | 'type' => 'LIKE', |
---|
| 800 | 'value' => '3%' |
---|
| 801 | ), |
---|
| 802 | 4 => array( |
---|
| 803 | 'field' => 'contact.names_ordered', |
---|
| 804 | 'type' => 'LIKE', |
---|
| 805 | 'value' => '4%' |
---|
| 806 | ), |
---|
| 807 | 5 => array( |
---|
| 808 | 'field' => 'contact.names_ordered', |
---|
| 809 | 'type' => 'LIKE', |
---|
| 810 | 'value' => '5%' |
---|
| 811 | ), |
---|
| 812 | 6 => array( |
---|
| 813 | 'field' => 'contact.names_ordered', |
---|
| 814 | 'type' => 'LIKE', |
---|
| 815 | 'value' => '6%' |
---|
| 816 | ), |
---|
| 817 | 7 => array( |
---|
| 818 | 'field' => 'contact.names_ordered', |
---|
| 819 | 'type' => 'LIKE', |
---|
| 820 | 'value' => '7%' |
---|
| 821 | ), |
---|
| 822 | 8 => array( |
---|
| 823 | 'field' => 'contact.names_ordered', |
---|
| 824 | 'type' => 'LIKE', |
---|
| 825 | 'value' => '8%' |
---|
| 826 | ), |
---|
| 827 | 9 => array( |
---|
| 828 | 'field' => 'contact.names_ordered', |
---|
| 829 | 'type' => 'LIKE', |
---|
| 830 | 'value' => '9%' |
---|
[752] | 831 | ), |
---|
| 832 | ), |
---|
[1599] | 833 | /**rev 104**/ |
---|
| 834 | /* ), |
---|
| 835 | 1 => array( |
---|
| 836 | 'field' => 'contact.id_owner', |
---|
| 837 | 'type' => '=', |
---|
| 838 | 'value' => $GLOBALS['phpgw_info']['user']['account_id'] |
---|
| 839 | ), |
---|
| 840 | */ |
---|
[503] | 841 | ) |
---|
| 842 | ); |
---|
| 843 | } |
---|
[2] | 844 | |
---|
[752] | 845 | if($this->page_info['actual_catalog']['class'] == 'bo_people_catalog'){ |
---|
| 846 | $find_restric[0][1] = array( |
---|
| 847 | 'field' => 'contact.id_owner', |
---|
| 848 | 'type' => '=', |
---|
| 849 | 'value' => $GLOBALS['phpgw_info']['user']['account_id'] |
---|
[2] | 850 | ); |
---|
| 851 | } |
---|
[1599] | 852 | /*****/ |
---|
| 853 | |
---|
[2] | 854 | $find_field[0] = array('contact.id_contact','contact.names_ordered'); |
---|
[1599] | 855 | |
---|
[2] | 856 | $find_other[0] = array( |
---|
[1599] | 857 | /**rev 104**/ |
---|
| 858 | //'offset' => (($page-1)*$this->page_info['n_cards']), |
---|
| 859 | //'limit' => $this->page_info['n_cards'], |
---|
| 860 | /*****/ |
---|
[2] | 861 | 'order' => 'contact.names_ordered' |
---|
| 862 | ); |
---|
[1599] | 863 | |
---|
[2] | 864 | break; |
---|
[1599] | 865 | |
---|
[3420] | 866 | case 'bo_catalog_group_catalog': |
---|
[2] | 867 | case 'bo_global_ldap_catalog': |
---|
[1599] | 868 | |
---|
[2] | 869 | $field_name = 'id_contact'; |
---|
| 870 | |
---|
| 871 | if ($letter !== 'number') |
---|
| 872 | { |
---|
| 873 | $find_restric[0] = array( |
---|
| 874 | 0 => array( |
---|
| 875 | 'field' => 'contact.names_ordered', |
---|
| 876 | 'type' => 'iLIKE', |
---|
[3333] | 877 | 'value' => $letter !== 'all' ? $letter.'%' : '%' |
---|
[284] | 878 | ), |
---|
| 879 | /* |
---|
| 880 | * Restrict the returned contacts in a "first letter" search |
---|
[1599] | 881 | /**rev 104 |
---|
[284] | 882 | * to objectClass = phpgwAccount, must have attibute phpgwAccountStatus, |
---|
[880] | 883 | * phpgwAccountVisible != -1 |
---|
[284] | 884 | */ |
---|
| 885 | 1 => array( |
---|
| 886 | 'field' => 'contact.object_class', |
---|
| 887 | 'type' => '=', |
---|
| 888 | 'value' => 'phpgwAccount' |
---|
[1599] | 889 | /**rev 104**/ |
---|
| 890 | //),/* |
---|
[284] | 891 | ), |
---|
[1599] | 892 | /****/ |
---|
[284] | 893 | 2 => array( |
---|
| 894 | 'field' => 'contact.account_status', |
---|
| 895 | 'type' => 'iLIKE', |
---|
| 896 | 'value' => '%' |
---|
[1599] | 897 | /**rev 104**/ |
---|
| 898 | //),*/ |
---|
| 899 | //2 => array( |
---|
[284] | 900 | ), |
---|
| 901 | 3 => array( |
---|
[1599] | 902 | /*****/ |
---|
[284] | 903 | 'field' => 'contact.account_visible', |
---|
| 904 | 'type' => '!=', |
---|
| 905 | 'value' => '-1' |
---|
[1599] | 906 | /**rev 104**/ |
---|
| 907 | /* ), |
---|
| 908 | 3 => array( |
---|
| 909 | 'field' => 'contact.object_class', |
---|
| 910 | 'type' => '=', |
---|
| 911 | 'value' => 'inetOrgPerson' |
---|
| 912 | ), |
---|
| 913 | */ |
---|
[880] | 914 | ) |
---|
[1599] | 915 | /*****/ |
---|
| 916 | |
---|
[2] | 917 | ); |
---|
[284] | 918 | // If not external catalog get only phpgwAccountType = u ou l |
---|
| 919 | if (!$external) |
---|
| 920 | { |
---|
| 921 | $find_restric[0][5] = array( |
---|
| 922 | 'type' => 'branch', |
---|
| 923 | 'value' => 'OR', |
---|
| 924 | 'sub_branch' => array( |
---|
| 925 | 0 => array( |
---|
| 926 | 'field' => 'contact.account_type', |
---|
| 927 | 'type' => '=', |
---|
| 928 | 'value' => 'u' |
---|
| 929 | ), |
---|
[285] | 930 | 1 => array( |
---|
[284] | 931 | 'field' => 'contact.account_type', |
---|
| 932 | 'type' => '=', |
---|
[418] | 933 | 'value' => 'i' |
---|
[1599] | 934 | /**rev 104**/ |
---|
[418] | 935 | ), |
---|
| 936 | 2 => array( |
---|
| 937 | 'field' => 'contact.account_type', |
---|
| 938 | 'type' => '=', |
---|
[1599] | 939 | /****/ |
---|
[284] | 940 | 'value' => 'l' |
---|
[1599] | 941 | /**rev 104**/ |
---|
[880] | 942 | ), |
---|
| 943 | 3 => array( |
---|
| 944 | 'field' => 'contact.account_type', |
---|
| 945 | 'type' => '=', |
---|
| 946 | 'value' => 'g' |
---|
[1599] | 947 | /***/ |
---|
[3688] | 948 | ), |
---|
| 949 | 4 => array( |
---|
| 950 | 'field' => 'contact.account_type', |
---|
| 951 | 'type' => '=', |
---|
| 952 | 'value' => 's' |
---|
[284] | 953 | ) |
---|
[2] | 954 | ) |
---|
[3688] | 955 | ); |
---|
[284] | 956 | } |
---|
[2] | 957 | } |
---|
| 958 | else |
---|
| 959 | { |
---|
| 960 | $find_restric[0] = array( |
---|
[284] | 961 | /* |
---|
| 962 | * Restrict the returned contacts in a "first number" search |
---|
[1599] | 963 | /**rev 104 |
---|
[284] | 964 | * to objectClass = phpgwAccount, must have attibute phpgwAccountStatus, |
---|
[880] | 965 | * phpgwAccountVisible != -1 |
---|
[284] | 966 | */ |
---|
[2] | 967 | 0 => array( |
---|
[284] | 968 | 'field' => 'contact.object_class', |
---|
| 969 | 'type' => '=', |
---|
| 970 | 'value' => 'phpgwAccount' |
---|
[1599] | 971 | /**rev 104**/ |
---|
| 972 | //),/* |
---|
[284] | 973 | ), |
---|
[1599] | 974 | /****/ |
---|
[284] | 975 | 1 => array( |
---|
| 976 | 'field' => 'contact.account_status', |
---|
| 977 | 'type' => 'iLIKE', |
---|
| 978 | 'value' => '%' |
---|
[1599] | 979 | /**rev 104**/ |
---|
| 980 | //),*/ |
---|
| 981 | //1 => array( |
---|
[284] | 982 | ), |
---|
| 983 | 2 => array( |
---|
[1599] | 984 | /*****/ |
---|
[284] | 985 | 'field' => 'contact.account_visible', |
---|
| 986 | 'type' => '!=', |
---|
| 987 | 'value' => '-1' |
---|
| 988 | ), |
---|
[1599] | 989 | /**rev 104**/ |
---|
| 990 | /* 2 => array( |
---|
| 991 | 'field' => 'contact.object_class', |
---|
| 992 | 'type' => '=', |
---|
| 993 | 'value' => 'inetOrgPerson' |
---|
| 994 | ), |
---|
| 995 | */ |
---|
| 996 | /****/ |
---|
[284] | 997 | 3 => array( |
---|
[2] | 998 | 'type' => 'branch', |
---|
| 999 | 'value' => 'OR', |
---|
| 1000 | 'sub_branch' => array( |
---|
| 1001 | 0 => array( |
---|
| 1002 | 'field' => 'contact.names_ordered', |
---|
| 1003 | 'type' => 'LIKE', |
---|
| 1004 | 'value' => '0%' |
---|
| 1005 | ), |
---|
| 1006 | 1 => array( |
---|
| 1007 | 'field' => 'contact.names_ordered', |
---|
| 1008 | 'type' => 'LIKE', |
---|
| 1009 | 'value' => '1%' |
---|
| 1010 | ), |
---|
| 1011 | 2 => array( |
---|
| 1012 | 'field' => 'contact.names_ordered', |
---|
| 1013 | 'type' => 'LIKE', |
---|
| 1014 | 'value' => '2%' |
---|
| 1015 | ), |
---|
| 1016 | 3 => array( |
---|
| 1017 | 'field' => 'contact.names_ordered', |
---|
| 1018 | 'type' => 'LIKE', |
---|
| 1019 | 'value' => '3%' |
---|
| 1020 | ), |
---|
| 1021 | 4 => array( |
---|
| 1022 | 'field' => 'contact.names_ordered', |
---|
| 1023 | 'type' => 'LIKE', |
---|
| 1024 | 'value' => '4%' |
---|
| 1025 | ), |
---|
| 1026 | 5 => array( |
---|
| 1027 | 'field' => 'contact.names_ordered', |
---|
| 1028 | 'type' => 'LIKE', |
---|
| 1029 | 'value' => '5%' |
---|
| 1030 | ), |
---|
| 1031 | 6 => array( |
---|
| 1032 | 'field' => 'contact.names_ordered', |
---|
| 1033 | 'type' => 'LIKE', |
---|
| 1034 | 'value' => '6%' |
---|
| 1035 | ), |
---|
| 1036 | 7 => array( |
---|
| 1037 | 'field' => 'contact.names_ordered', |
---|
| 1038 | 'type' => 'LIKE', |
---|
| 1039 | 'value' => '7%' |
---|
| 1040 | ), |
---|
| 1041 | 8 => array( |
---|
| 1042 | 'field' => 'contact.names_ordered', |
---|
| 1043 | 'type' => 'LIKE', |
---|
| 1044 | 'value' => '8%' |
---|
| 1045 | ), |
---|
| 1046 | 9 => array( |
---|
| 1047 | 'field' => 'contact.names_ordered', |
---|
| 1048 | 'type' => 'LIKE', |
---|
| 1049 | 'value' => '9%' |
---|
| 1050 | ), |
---|
| 1051 | ), |
---|
| 1052 | ), |
---|
| 1053 | ); |
---|
[284] | 1054 | // If not external catalog get only phpgwAccountType = u ou l |
---|
| 1055 | if (!$external) |
---|
| 1056 | { |
---|
| 1057 | $find_restric[0][5] = array( |
---|
| 1058 | 'type' => 'branch', |
---|
| 1059 | 'value' => 'OR', |
---|
| 1060 | 'sub_branch' => array( |
---|
| 1061 | 0 => array( |
---|
| 1062 | 'field' => 'contact.account_type', |
---|
| 1063 | 'type' => '=', |
---|
| 1064 | 'value' => 'u' |
---|
| 1065 | ), |
---|
[418] | 1066 | 1 => array( |
---|
| 1067 | 'field' => 'contact.account_type', |
---|
| 1068 | 'type' => '=', |
---|
[1599] | 1069 | /**rev 104**/ |
---|
| 1070 | //'value' => 'g' |
---|
| 1071 | //); |
---|
| 1072 | //1 => array( |
---|
[418] | 1073 | 'value' => 'i' |
---|
| 1074 | ), |
---|
[880] | 1075 | 2 => array( |
---|
[1599] | 1076 | /****/ |
---|
[284] | 1077 | 'field' => 'contact.account_type', |
---|
| 1078 | 'type' => '=', |
---|
[880] | 1079 | 'value' => 'l' |
---|
[1599] | 1080 | /**rev 104**/ |
---|
[880] | 1081 | ), |
---|
| 1082 | 3 => array( |
---|
[284] | 1083 | 'field' => 'contact.account_type', |
---|
| 1084 | 'type' => '=', |
---|
[880] | 1085 | 'value' => 'g' |
---|
[3688] | 1086 | ), |
---|
| 1087 | /****/ |
---|
| 1088 | 4 => array( |
---|
| 1089 | 'field' => 'contact.account_type', |
---|
| 1090 | 'type' => '=', |
---|
| 1091 | 'value' => 's' |
---|
[284] | 1092 | ) |
---|
[2] | 1093 | ) |
---|
[284] | 1094 | ); |
---|
| 1095 | } |
---|
[2] | 1096 | } |
---|
[284] | 1097 | |
---|
| 1098 | if (!$external) |
---|
| 1099 | { |
---|
| 1100 | // Get only this attributes: dn, cn, phpgwAccountType, objectClass, phpgwAccountStatus, phpghAccountVisible |
---|
| 1101 | // for non-external catalogs, used to restrict the attributes used in filters |
---|
| 1102 | $find_field[0] = array('contact.id_contact','contact.names_ordered','contact.account_type', |
---|
[1599] | 1103 | 'contact.object_class','contact.account_visible'); |
---|
[284] | 1104 | } |
---|
| 1105 | else |
---|
| 1106 | { |
---|
| 1107 | // Get only this attributes: dn, cn for external catalogs, |
---|
| 1108 | // used to restrict the attributes used in filters |
---|
| 1109 | $find_field[0] = array('contact.id_contact','contact.names_ordered'); |
---|
| 1110 | } |
---|
[1599] | 1111 | |
---|
[2] | 1112 | $find_other[0] = array( |
---|
| 1113 | //'offset' => (($page-1)*$this->page_info['n_cards']), |
---|
| 1114 | //'limit' => $this->page_info['n_cards'], |
---|
| 1115 | 'order' => 'contact.names_ordered' |
---|
| 1116 | ); |
---|
[1599] | 1117 | |
---|
[2] | 1118 | break; |
---|
[1599] | 1119 | |
---|
[2] | 1120 | case 'bo_company_manager': |
---|
| 1121 | $field_name = 'id_company'; |
---|
[1599] | 1122 | |
---|
[2] | 1123 | $find_field[0] = array('company.id_company','company.company_name'); |
---|
[1599] | 1124 | |
---|
[2] | 1125 | $find_other[0] = array( |
---|
| 1126 | //'offset' => (($page-1)*$this->page_info['n_cards']), |
---|
| 1127 | //'limit' => $this->page_info['n_cards'], |
---|
| 1128 | 'order' => 'company.company_name' |
---|
| 1129 | ); |
---|
[1599] | 1130 | |
---|
[2] | 1131 | $find_restric[0] = array( |
---|
| 1132 | 0 => array( |
---|
| 1133 | 'field' => 'company.company_name', |
---|
| 1134 | 'type' => 'iLIKE', |
---|
| 1135 | 'value' => $letter !== 'all' ? $letter.'%' : '%' |
---|
| 1136 | ) |
---|
| 1137 | ); |
---|
[1599] | 1138 | |
---|
[2] | 1139 | break; |
---|
| 1140 | |
---|
| 1141 | case 'bo_group_manager': |
---|
[1599] | 1142 | /**rev 104**/ |
---|
[752] | 1143 | case 'bo_shared_group_manager': |
---|
[1599] | 1144 | /****/ |
---|
| 1145 | |
---|
[2] | 1146 | $field_name = 'id_group'; |
---|
[1599] | 1147 | |
---|
[2] | 1148 | if ($letter !== 'number') { |
---|
[1599] | 1149 | |
---|
[2] | 1150 | $find_restric[0] = array( |
---|
| 1151 | 0 => array( |
---|
| 1152 | 'field' => 'group.title', |
---|
| 1153 | 'type' => 'iLIKE', |
---|
| 1154 | 'value' => $letter !== 'all' ? $letter.'%' : '%' |
---|
| 1155 | ) |
---|
| 1156 | ); |
---|
| 1157 | } |
---|
| 1158 | else { |
---|
[1599] | 1159 | |
---|
[2] | 1160 | $find_restric[0] = array( |
---|
| 1161 | 0 => array( |
---|
| 1162 | 'field' => 'group.title', |
---|
| 1163 | 'type' => 'LIKE', |
---|
[1599] | 1164 | 'value' => '0%' |
---|
[2] | 1165 | ) |
---|
[1599] | 1166 | ); |
---|
[2] | 1167 | } |
---|
[1599] | 1168 | /**rev 104**/ |
---|
[752] | 1169 | if($this->page_info['actual_catalog']['class'] == 'bo_group_manager'){ |
---|
[1599] | 1170 | /****/ |
---|
[752] | 1171 | array_push($find_restric[0], array( |
---|
[2] | 1172 | 'field' => 'group.owner', |
---|
| 1173 | 'type' => '=', |
---|
[1599] | 1174 | 'value' => $GLOBALS['phpgw_info']['user']['account_id'] |
---|
[752] | 1175 | ) |
---|
| 1176 | ); |
---|
| 1177 | } |
---|
[1599] | 1178 | |
---|
| 1179 | $find_field[0] = array('group.id_group','group.title','group.short_name'); |
---|
[2] | 1180 | $find_other[0] = array( |
---|
| 1181 | 'order' => 'group.title' |
---|
[1599] | 1182 | ); |
---|
[2] | 1183 | break; |
---|
[1599] | 1184 | |
---|
[3420] | 1185 | /*case 'bo_catalog_group_catalog': |
---|
[2] | 1186 | $this->page_info['actual_entries'] = false; |
---|
[1599] | 1187 | |
---|
[2] | 1188 | $this->page_info['actual_letter'] = $letter; |
---|
| 1189 | $this->page_info['actual_page'] = 0; |
---|
[1599] | 1190 | |
---|
[2] | 1191 | $this->save_session(); |
---|
| 1192 | $final[0] = 0; |
---|
[285] | 1193 | $final[1] = $this->typeContact; |
---|
[1599] | 1194 | echo serialize($final); |
---|
[3420] | 1195 | return;*/ |
---|
[2] | 1196 | |
---|
| 1197 | } |
---|
[1496] | 1198 | |
---|
[2] | 1199 | $result = $this->bo->find($find_field[0],$find_restric[0],$find_other[0]); |
---|
| 1200 | $n_entries = count($result); |
---|
[1599] | 1201 | |
---|
[2] | 1202 | if ($n_entries) |
---|
| 1203 | { |
---|
| 1204 | //echo 'N_entries: '.$n_entries.'<br>'; |
---|
| 1205 | $this->page_info['n_pages'] = ceil($n_entries/($this->page_info['n_cards'] ? $this->page_info['n_cards'] : 1)); |
---|
| 1206 | } |
---|
| 1207 | else |
---|
| 1208 | { |
---|
| 1209 | $this->page_info['n_pages'] = 0; |
---|
| 1210 | } |
---|
| 1211 | |
---|
| 1212 | if (!$result) |
---|
| 1213 | { |
---|
| 1214 | $this->page_info['actual_entries'] = false; |
---|
[1599] | 1215 | |
---|
[2] | 1216 | $this->page_info['actual_letter'] = $letter; |
---|
| 1217 | $this->page_info['actual_page'] = 0; |
---|
[1599] | 1218 | |
---|
| 1219 | $this->save_session(); |
---|
[2] | 1220 | $final[0] = 0; |
---|
[285] | 1221 | $final[1] = $this->typeContact; |
---|
[1599] | 1222 | echo serialize($final); |
---|
[2] | 1223 | return; |
---|
| 1224 | } |
---|
| 1225 | else |
---|
| 1226 | { |
---|
| 1227 | unset($this->page_info['actual_entries']); |
---|
[3180] | 1228 | if(is_array($result)) { |
---|
| 1229 | foreach ($result as $id => $value) |
---|
| 1230 | { |
---|
| 1231 | if($this->page_info['actual_catalog']['class'] != 'bo_shared_people_manager' && $this->page_info['actual_catalog']['class'] != 'bo_shared_group_manager') |
---|
| 1232 | $this->page_info['actual_entries'][] = $value[$field_name]; |
---|
| 1233 | else |
---|
| 1234 | $this->page_info['actual_entries'][] = array(0=>$value[$field_name],1=>$value['perms'],2=>$value['owner']); |
---|
| 1235 | } |
---|
[1599] | 1236 | } |
---|
[2] | 1237 | } |
---|
| 1238 | } |
---|
| 1239 | else if ($letter === 'search') |
---|
| 1240 | { |
---|
[284] | 1241 | //if (!$ids and $this->page_info['actual_letter'] !== 'search') |
---|
[285] | 1242 | if (!$ids) |
---|
[2] | 1243 | { |
---|
[1599] | 1244 | /**rev 104**/ |
---|
[315] | 1245 | //error_log('!$ids e $this->page_info[\'actual_letter\'] != search'); |
---|
[1599] | 1246 | /*****/ |
---|
[2] | 1247 | $this->page_info['actual_entries'] = false; |
---|
[1599] | 1248 | |
---|
[2] | 1249 | $this->page_info['actual_letter'] = $letter; |
---|
| 1250 | $this->page_info['actual_page'] = 0; |
---|
[1599] | 1251 | |
---|
[2] | 1252 | $this->save_session(); |
---|
| 1253 | $final[0] = 0; |
---|
| 1254 | $final[1] = $this -> typeContact; |
---|
[1599] | 1255 | echo serialize($final); |
---|
[2] | 1256 | return; |
---|
| 1257 | } |
---|
[284] | 1258 | else if ($ids['error']) |
---|
| 1259 | { |
---|
| 1260 | $this->page_info['actual_entries'] = false; |
---|
| 1261 | $this->page_info['actual_letter'] = $letter; |
---|
| 1262 | $this->page_info['actual_page'] = 0; |
---|
| 1263 | |
---|
| 1264 | $this->save_session(); |
---|
| 1265 | $final[0] = 0; |
---|
| 1266 | $final[1] = $this -> typeContact; |
---|
| 1267 | $final['error'] = $ids['error']; |
---|
| 1268 | echo serialize($final); |
---|
| 1269 | return; |
---|
| 1270 | } |
---|
[285] | 1271 | else if ($ids) |
---|
[1599] | 1272 | { |
---|
[2] | 1273 | $this->page_info['actual_letter'] = $letter; |
---|
| 1274 | $this->page_info['actual_entries'] = $ids; |
---|
| 1275 | $this->page_info['n_pages'] = ceil(count($ids)/($this->page_info['n_cards'] ? $this->page_info['n_cards'] : 1)); |
---|
| 1276 | } |
---|
| 1277 | } |
---|
| 1278 | else |
---|
| 1279 | { |
---|
| 1280 | unset($ids); |
---|
| 1281 | } |
---|
| 1282 | |
---|
| 1283 | if ($this->page_info['actual_entries']) |
---|
| 1284 | { |
---|
| 1285 | if ($page >= $this->page_info['n_pages']) |
---|
| 1286 | { |
---|
| 1287 | $page = $this->page_info['n_pages']; |
---|
| 1288 | } |
---|
[1599] | 1289 | |
---|
[2] | 1290 | $final = array( |
---|
| 1291 | 0 => (int)$this->page_info['n_pages'], |
---|
| 1292 | 1 => (int)$page, |
---|
| 1293 | 2 => array( |
---|
| 1294 | 0 => 'cc_company', |
---|
| 1295 | 1 => 'cc_name', |
---|
| 1296 | 2 => 'cc_title', |
---|
| 1297 | 3 => 'cc_phone', |
---|
| 1298 | 4 => 'cc_mail', |
---|
| 1299 | 5 => 'cc_alias', |
---|
| 1300 | 6 => 'cc_id', |
---|
[1599] | 1301 | 7 => 'cc_forwarding_address', |
---|
| 1302 | 8 => 'cc_empNumber', |
---|
| 1303 | 9 => 'cc_department', |
---|
| 1304 | 10 => 'cc_mobile' |
---|
[2] | 1305 | ) |
---|
| 1306 | ); |
---|
[1599] | 1307 | |
---|
[2] | 1308 | //echo 'Page: '.$page.'<br>'; |
---|
| 1309 | $id_i = (($page-1)*$this->page_info['n_cards']); |
---|
| 1310 | $id_f = $id_i + $this->page_info['n_cards']; |
---|
| 1311 | $n_entries = count($this->page_info['actual_entries']); |
---|
[1599] | 1312 | |
---|
[2] | 1313 | //echo 'ID_I: '.$id_i.'<br>'; |
---|
| 1314 | //echo 'ID_F: '.$id_f.'<br>'; |
---|
[3334] | 1315 | ///---------------- Correção Temporária PHP5 -----------------------/// |
---|
[2] | 1316 | $ids = array(); |
---|
[1599] | 1317 | /**rev 104**/ |
---|
[503] | 1318 | $perms = array(); |
---|
[752] | 1319 | $owners = array(); |
---|
[1599] | 1320 | /****/ |
---|
| 1321 | $array_temp = array(); |
---|
| 1322 | |
---|
[2] | 1323 | foreach($this->page_info['actual_entries'] as $key=>$tmp){ |
---|
[1599] | 1324 | $array_temp[] = $tmp; |
---|
[1496] | 1325 | } |
---|
[1599] | 1326 | |
---|
[2] | 1327 | for($i = $id_i; $i < $id_f and $i < $n_entries; $i++) |
---|
| 1328 | { |
---|
[1599] | 1329 | /**rev 104**/ |
---|
[752] | 1330 | if($this->page_info['actual_catalog']['class'] != 'bo_shared_people_manager' && $this->page_info['actual_catalog']['class'] != 'bo_shared_group_manager') |
---|
[1599] | 1331 | { |
---|
| 1332 | /****/ |
---|
[503] | 1333 | $ids[] = $array_temp[$i]; |
---|
[1599] | 1334 | /**rev 104**/ |
---|
| 1335 | }else { |
---|
[503] | 1336 | $ids[] = $array_temp[$i][0]; |
---|
| 1337 | $perms[] = $array_temp[$i][1]; |
---|
[752] | 1338 | $owners[] = $array_temp[$i][2]; |
---|
[1599] | 1339 | /****/ |
---|
[503] | 1340 | } |
---|
[2] | 1341 | } |
---|
[1599] | 1342 | |
---|
| 1343 | /**rev 104**/ |
---|
[752] | 1344 | // Carrega o nome completo dos donos dos objetos (contatos e grupos); |
---|
| 1345 | $owner_names = array(); |
---|
[1599] | 1346 | |
---|
[752] | 1347 | if($owners) { |
---|
| 1348 | $filter = "(|"; |
---|
| 1349 | foreach($owners as $i => $owner) { |
---|
| 1350 | $filter .= "(uidNumber=".$owner.")"; |
---|
| 1351 | } |
---|
| 1352 | $filter .= ")"; |
---|
[1496] | 1353 | |
---|
[752] | 1354 | if(!$this->bo->catalog->src_info) { |
---|
| 1355 | $ldap = CreateObject('contactcenter.bo_ldap_manager'); |
---|
| 1356 | $this->bo->catalog->src_info = $ldap->srcs[1]; |
---|
| 1357 | } |
---|
[1599] | 1358 | $ds = $GLOBALS['phpgw']->common->ldapConnect($this->bo->catalog->src_info['host'], $this->bo->catalog->src_info['acc'], $this->bo->catalog->src_info['pw'], false); |
---|
[752] | 1359 | $dn=$this->bo->catalog->src_info['dn']; |
---|
| 1360 | $justThese = array("cn","uidnumber","uid"); |
---|
[1599] | 1361 | $sr = ldap_search($ds,$dn, $filter,$justThese); |
---|
[752] | 1362 | $info = ldap_get_entries($ds, $sr); |
---|
[1599] | 1363 | ldap_close($ds); |
---|
[752] | 1364 | for($z = 0; $z < $info['count']; $z++) { |
---|
| 1365 | $owner_names[$info[$z]['uidnumber'][0]] = array("cn" => $info[$z]['cn'][0], "uid" => $info[$z]['uid'][0]); |
---|
[1599] | 1366 | } |
---|
[752] | 1367 | } |
---|
[1599] | 1368 | |
---|
| 1369 | /*****/ |
---|
| 1370 | |
---|
| 1371 | |
---|
[2] | 1372 | /// Original |
---|
| 1373 | //for($i = $id_i; $i < $id_f and $i < $n_entries; $i++) |
---|
| 1374 | //{ |
---|
| 1375 | // $ids[] = $this->page_info['actual_entries'][$i]; |
---|
| 1376 | //} |
---|
| 1377 | /// |
---|
[1599] | 1378 | |
---|
[2] | 1379 | $fields = $this->bo->catalog->get_fields(false); |
---|
[1599] | 1380 | /**rev 104**/ |
---|
| 1381 | //if( $this->typeContact == 'groups') { |
---|
[752] | 1382 | if( $this->typeContact == 'groups' || $this->typeContact == 'shared_groups') { |
---|
[1599] | 1383 | /****/ |
---|
[2] | 1384 | $final = array( |
---|
| 1385 | 0 => (int)$this->page_info['n_pages'], |
---|
| 1386 | 1 => (int)$page, |
---|
| 1387 | 2 => array( |
---|
| 1388 | 0 => 'cc_title', |
---|
| 1389 | 1 => 'cc_short_name', |
---|
| 1390 | 2 => 'cc_id', |
---|
| 1391 | 3 => 'cc_contacts' |
---|
[1599] | 1392 | ) |
---|
| 1393 | ); |
---|
| 1394 | |
---|
[2] | 1395 | $groups =& $this->bo->catalog->get_multiple_entries($ids,$fields); |
---|
[1599] | 1396 | |
---|
[2] | 1397 | $i = 0; |
---|
| 1398 | // contatos do grupo |
---|
[1599] | 1399 | $boGroups = CreateObject('contactcenter.bo_group'); |
---|
[2] | 1400 | $contacts = array(); |
---|
[1599] | 1401 | foreach($groups as $group) { |
---|
| 1402 | |
---|
[2] | 1403 | $final[3][$i][0] = $group['title'] ? $group['title'] : 'none'; |
---|
[1599] | 1404 | $final[3][$i][1] = $group['short_name'] ? $group['short_name'] : 'none'; |
---|
[2] | 1405 | $final[3][$i][2] = $group['id_group'] ? $group['id_group'] : 'none'; |
---|
| 1406 | $contacts = $boGroups -> get_contacts_by_group($group['id_group']); |
---|
| 1407 | $final[3][$i][3] = $contacts; |
---|
[752] | 1408 | $final[3][$i][4] = $perms[$i]; |
---|
| 1409 | if($this->typeContact == 'shared_groups'){ |
---|
| 1410 | $final[3][$i][5] = lang('Shared').": ".$owner_names[$owners[$i]]['cn']; |
---|
| 1411 | $final[3][$i][6] = $owner_names[$owners[$i]]['uid']; |
---|
[1280] | 1412 | $final[3][$i][7] = $owners[$i]; //uidNumber |
---|
[752] | 1413 | } |
---|
[285] | 1414 | $i++; |
---|
[2] | 1415 | } |
---|
[1599] | 1416 | |
---|
[2] | 1417 | $this->page_info['actual_letter'] = $letter; |
---|
[1599] | 1418 | $this->page_info['actual_page'] = $page; |
---|
| 1419 | |
---|
| 1420 | |
---|
[2] | 1421 | $lnk_compose = "location.href=('../expressoMail1_2/index.php?to="; |
---|
[1599] | 1422 | |
---|
| 1423 | $final[5] = '<span class="link" onclick="'.$lnk_compose; |
---|
| 1424 | /**rev 104**/ |
---|
| 1425 | //$final[10] = 'groups'; |
---|
| 1426 | $final[10] = $this->typeContact; |
---|
| 1427 | /******/ |
---|
| 1428 | $this->save_session(); |
---|
[2] | 1429 | echo serialize($final); |
---|
[1599] | 1430 | return; |
---|
[2] | 1431 | } |
---|
[1599] | 1432 | /**rev 104**/ |
---|
[503] | 1433 | $final[10] = $this -> typeContact; |
---|
[1599] | 1434 | /*****/ |
---|
| 1435 | |
---|
[2] | 1436 | $fields['photo'] = true; |
---|
| 1437 | $fields['names_ordered'] = true; |
---|
| 1438 | $fields['alias'] = true; |
---|
| 1439 | $fields['account_type'] = true; |
---|
| 1440 | $fields['companies'] = 'default'; |
---|
| 1441 | $fields['connections'] = 'default'; |
---|
[1599] | 1442 | |
---|
| 1443 | /**rev 104**/ |
---|
[3334] | 1444 | // ?aqui alterar a chamada desse método para receber o base dn? |
---|
[1599] | 1445 | //$contacts = &$this->bo->catalog->get_multiple_entries($ids,$fields); |
---|
| 1446 | |
---|
[285] | 1447 | // ?aqui alterar a chamada desse método para receber o base dn? |
---|
[1419] | 1448 | if($external) |
---|
[1599] | 1449 | { |
---|
[1419] | 1450 | $contacts = &$this->bo->catalog->get_multiple_entries($ids,$fields,false,true); |
---|
[1599] | 1451 | } else{ |
---|
[1419] | 1452 | $contacts = &$this->bo->catalog->get_multiple_entries($ids,$fields); |
---|
[1599] | 1453 | } |
---|
| 1454 | |
---|
| 1455 | /*******/ |
---|
| 1456 | |
---|
| 1457 | |
---|
[2] | 1458 | if (!is_array($contacts) or !count($contacts)) |
---|
| 1459 | { |
---|
| 1460 | $final[0] = 0; |
---|
| 1461 | $final[1] = $this -> typeContact; |
---|
| 1462 | echo serialize($final); |
---|
| 1463 | return; |
---|
| 1464 | } |
---|
[1599] | 1465 | |
---|
[2] | 1466 | $i = 0; |
---|
[3795] | 1467 | if (!is_array($this->preferences)) |
---|
| 1468 | { |
---|
| 1469 | $this->preferences['personCardEmail'] = 1; |
---|
| 1470 | $this->preferences['personCardPhone'] = 2; |
---|
| 1471 | } |
---|
[284] | 1472 | foreach($contacts as $index => $contact) |
---|
[2] | 1473 | { |
---|
[284] | 1474 | /* |
---|
[3334] | 1475 | * TODO: Os timeouts de conexão foram retirados, ver se será necessário retornar essa funcionalidade, e, |
---|
| 1476 | * neste caso, terminar a implementação das mensagens de retorno. |
---|
[284] | 1477 | */ |
---|
| 1478 | if ($index !== 'error'){ |
---|
| 1479 | $final[3][$i][0] = $contact['companies']['company1']['company_name']?$contact['companies']['company1']['company_name']:'none'; |
---|
[1599] | 1480 | |
---|
| 1481 | /**rev 104**/ |
---|
| 1482 | //$final[3][$i][1] = $contact['names_ordered'] ? $contact['names_ordered'] : 'none'; |
---|
| 1483 | |
---|
[1419] | 1484 | if($this->page_info['actual_catalog']['class']!='bo_global_ldap_catalog'){ |
---|
[3211] | 1485 | $final[3][$i][1] = $contact['names_ordered'] ? urldecode(is_array($contact['names_ordered']) ? $contact['names_ordered'][0] : $contact['names_ordered']) : 'none'; |
---|
[1419] | 1486 | } |
---|
| 1487 | else { |
---|
| 1488 | $contact['names_ordered'][0] = urldecode($contact['names_ordered'][0]); |
---|
| 1489 | $final[3][$i][1] = $contact['names_ordered'] ? $contact['names_ordered'] : 'none'; |
---|
| 1490 | } |
---|
[1599] | 1491 | |
---|
| 1492 | /********/ |
---|
| 1493 | |
---|
[1411] | 1494 | $final[3][$i][2] = $contact['companies']['company1']['title']? urldecode( $contact['companies']['company1']['title'] ) :'none'; |
---|
[2] | 1495 | |
---|
[1599] | 1496 | //Para exibir a matricula do empregado |
---|
| 1497 | $final[3][$i][8] = $contact['companies']['company1']['empNumber']?$contact['companies']['company1']['empNumber']:'none'; |
---|
| 1498 | //Para exibir o setor/lotacao do empregado |
---|
| 1499 | $final[3][$i][9] = $contact['companies']['company1']['department']?$contact['companies']['company1']['department']:'none'; |
---|
| 1500 | //Para exibir o celular empresarial do empregado |
---|
| 1501 | $final[3][$i][10] = $contact['companies']['company1']['celPhone']?$contact['companies']['company1']['celPhone']:'none'; |
---|
| 1502 | |
---|
| 1503 | //Para exibir o celular empresarial do empregado |
---|
[3795] | 1504 | if ($this->preferences['voip_enabled'] && !$external && $final[3][$i][10] != 'none') |
---|
[1599] | 1505 | $final[3][$i][10] = "<a title=\"".lang("Call Mobile")."\" href=\"#\" onclick=\"connectVoip('".$final[3][$i][10]."', 'mob')\">".$final[3][$i][10]."</a>"; |
---|
| 1506 | |
---|
[284] | 1507 | if ($contact['connections']) |
---|
| 1508 | { |
---|
| 1509 | $default_email_found = false; |
---|
| 1510 | $default_phone_found = false; |
---|
| 1511 | foreach($contact['connections'] as $conn_info) |
---|
[2] | 1512 | { |
---|
[3795] | 1513 | if ($conn_info['id_type'] == $this->preferences['personCardEmail'] and !$default_email_found) |
---|
[2] | 1514 | { |
---|
[284] | 1515 | if ($conn_info['connection_is_default']) |
---|
| 1516 | { |
---|
| 1517 | $default_email_found = true; |
---|
| 1518 | } |
---|
| 1519 | $final[3][$i][4] = $conn_info['connection_value'] ? $conn_info['connection_value'] : 'none'; |
---|
[2] | 1520 | } |
---|
[3795] | 1521 | else if ($conn_info['id_type'] == $this->preferences['personCardPhone'] and !$default_phone_found) |
---|
[2] | 1522 | { |
---|
[284] | 1523 | if ($conn_info['connection_is_default']) |
---|
| 1524 | { |
---|
| 1525 | $default_phone_found = true; |
---|
| 1526 | } |
---|
[1599] | 1527 | |
---|
| 1528 | /**rev 104**/ |
---|
| 1529 | //if ($_SESSION['phpgw_info']['user']['preferences']['contactcenter']['voip_enabled'] && !$external){ |
---|
| 1530 | // $conn_info['connection_value'] = "<a title=\"".lang("Call Extension")."\" href=\"#\" onclick=\"connectVoip('".$conn_info['connection_value']."', 'ramal')\">".$conn_info['connection_value']."</a>"; |
---|
| 1531 | |
---|
[3795] | 1532 | if (!($this->preferences['telephone_number'] == $conn_info['connection_value']) && $this->preferences['contactcenter']['voip_enabled'] && $conn_info['connection_value'] && preg_match('/^\([0-9]{2}\)[0-9]{4}\-[0-9]{4}$/',$conn_info['connection_value'])==1 && !$external){ |
---|
[284] | 1533 | $conn_info['connection_value'] = "<a title=\"".lang("Call Extension")."\" href=\"#\" onclick=\"connectVoip('".$conn_info['connection_value']."', 'com')\">".$conn_info['connection_value']."</a>"; |
---|
[1599] | 1534 | |
---|
| 1535 | /*****/ |
---|
[285] | 1536 | } |
---|
[284] | 1537 | $final[3][$i][3] = $conn_info['connection_value'] ? $conn_info['connection_value'] : 'none'; |
---|
| 1538 | } |
---|
[2] | 1539 | } |
---|
| 1540 | } |
---|
[1599] | 1541 | |
---|
[284] | 1542 | if (!$final[3][$i][3]) |
---|
| 1543 | { |
---|
| 1544 | $final[3][$i][3] = 'none'; |
---|
| 1545 | } |
---|
| 1546 | |
---|
| 1547 | if (!$final[3][$i][4]) |
---|
| 1548 | { |
---|
| 1549 | $final[3][$i][4] = 'none'; |
---|
| 1550 | } |
---|
| 1551 | |
---|
[1411] | 1552 | $final[3][$i][5] = $contact['alias']? urldecode( $contact['alias'] ):'none'; |
---|
[284] | 1553 | $final[3][$i][6] = $ids[$i]; |
---|
| 1554 | |
---|
[1599] | 1555 | /**rev 104**/ |
---|
| 1556 | /* // If contact is a public list, then load the forwarding addresses. |
---|
| 1557 | if($contact['account_type'][0] == 'l') |
---|
| 1558 | $final[3][$i][7] = array(); |
---|
| 1559 | */ |
---|
| 1560 | |
---|
| 1561 | //If contact is a public list or a group, then load the forwarding addresses. |
---|
[880] | 1562 | if($contact['account_type'][0] == 'l' || $contact['account_type'][0] == 'g') |
---|
| 1563 | $final[3][$i][7] = ($contact['account_type'][0] == 'l' ? 'list' : 'group'); |
---|
[503] | 1564 | |
---|
[752] | 1565 | if($this->page_info['actual_catalog']['class']=='bo_shared_people_manager') { |
---|
[1599] | 1566 | $final[3][$i][11] = $perms[$i]; |
---|
| 1567 | $final[3][$i][12] = lang('Shared').": ".$owner_names[$owners[$i]]['cn']; |
---|
[503] | 1568 | } |
---|
[1599] | 1569 | /******/ |
---|
[284] | 1570 | |
---|
| 1571 | $final[4][$i] = $contact['photo'] ? 1 : 0; |
---|
| 1572 | $i++; |
---|
[2] | 1573 | } |
---|
[284] | 1574 | else |
---|
[2] | 1575 | { |
---|
[284] | 1576 | // coloca mensagem de erro no vetor que retorna para o browser |
---|
[2] | 1577 | } |
---|
[284] | 1578 | } |
---|
| 1579 | $lnk_compose = "location.href=('../expressoMail1_2/index.php?to="; |
---|
| 1580 | $final[5] = '<span class="link" onclick="'.$lnk_compose; |
---|
[1496] | 1581 | $final[6] = $prop_names; |
---|
| 1582 | $final[7] = $validos; |
---|
| 1583 | $final[8] = $this->page_info['actual_catalog']['class']; |
---|
| 1584 | $final[9] = $count; |
---|
[2] | 1585 | |
---|
[1599] | 1586 | |
---|
[2] | 1587 | $this->page_info['actual_letter'] = $letter; |
---|
| 1588 | $this->page_info['actual_page'] = $page; |
---|
[1599] | 1589 | |
---|
| 1590 | $this->save_session(); |
---|
[2] | 1591 | echo serialize($final); |
---|
| 1592 | return; |
---|
| 1593 | } |
---|
[1599] | 1594 | |
---|
[2] | 1595 | $this->page_info['actual_letter'] = $letter; |
---|
| 1596 | $this->page_info['actual_page'] = $page; |
---|
[1599] | 1597 | |
---|
[2] | 1598 | $this->save_session(); |
---|
[1599] | 1599 | |
---|
[2] | 1600 | $final[0] = 0; |
---|
| 1601 | $final[1] = $this -> typeContact; |
---|
| 1602 | echo serialize($final); |
---|
| 1603 | } |
---|
[3335] | 1604 | |
---|
| 1605 | |
---|
| 1606 | function get_list_owners_perms_add(){ |
---|
| 1607 | $acl = CreateObject('phpgwapi.acl'); |
---|
| 1608 | $find_result = $acl->get_rights_and_owners($GLOBALS['phpgw_info']['user']['account_id'],'contactcenter'); |
---|
| 1609 | if($find_result){ |
---|
| 1610 | $owner_names = array(); |
---|
| 1611 | $filter = "(|"; |
---|
| 1612 | foreach($find_result as $owner) { |
---|
| 1613 | if(($owner['acl_rights'] & PHPGW_ACL_ADD) == PHPGW_ACL_ADD){ |
---|
| 1614 | $filter .= "(uidNumber=".$owner['acl_account'].")"; |
---|
| 1615 | } |
---|
| 1616 | } |
---|
| 1617 | if(!$this->bo->catalog->src_info) { |
---|
| 1618 | $ldap = CreateObject('contactcenter.bo_ldap_manager'); |
---|
| 1619 | $this->bo->catalog->src_info = $ldap->srcs[1]; |
---|
| 1620 | } |
---|
| 1621 | $ds = $GLOBALS['phpgw']->common->ldapConnect($this->bo->catalog->src_info['host'], $this->bo->catalog->src_info['acc'], $this->bo->catalog->src_info['pw'], false); |
---|
| 1622 | $filter .= ")"; |
---|
| 1623 | $dn=$this->bo->catalog->src_info['dn']; |
---|
| 1624 | $justThese = array("cn","uidnumber","uid"); |
---|
| 1625 | $sr = ldap_search($ds,$dn, $filter,$justThese); |
---|
| 1626 | $info = ldap_get_entries($ds, $sr); |
---|
| 1627 | for($z = 0; $z < $info['count']; $z++) { |
---|
| 1628 | $owner_names[$info[$z]['uidnumber'][0]] = array("cn" => $info[$z]['cn'][0], "uid" => $info[$z]['uid'][0]); |
---|
| 1629 | } |
---|
| 1630 | ldap_close($ds); |
---|
| 1631 | } |
---|
| 1632 | echo serialize ($owner_names); |
---|
| 1633 | } |
---|
[1599] | 1634 | |
---|
[285] | 1635 | function get_visible_all_ldap() |
---|
| 1636 | { |
---|
| 1637 | $bo = CreateObject('contactcenter.bo_ldap_manager'); |
---|
| 1638 | $ldap_query = $bo->srcs; |
---|
[1599] | 1639 | return $ldap_query[1]['visible']; |
---|
[285] | 1640 | } |
---|
[284] | 1641 | |
---|
[1599] | 1642 | |
---|
[2] | 1643 | /*! |
---|
[1599] | 1644 | |
---|
[2] | 1645 | @function get_group_data |
---|
| 1646 | @abstract Returns all the information of a given Group |
---|
| 1647 | @author Nilton Emilio Buhrer Neto |
---|
[1599] | 1648 | |
---|
[2] | 1649 | @param (integer) $id The id to get information |
---|
[1599] | 1650 | |
---|
| 1651 | */ |
---|
[1280] | 1652 | function get_group_data($id,$shared_from=null) |
---|
[2] | 1653 | { |
---|
| 1654 | $this->bo->catalog = CreateObject('contactcenter.bo_group_manager'); |
---|
| 1655 | $fields = $this->bo->catalog->get_fields(true); |
---|
| 1656 | $data = $this->bo->catalog->get_single_entry($id,$fields); |
---|
[285] | 1657 | |
---|
| 1658 | if($id) { |
---|
[2] | 1659 | // get All Contacts by group. |
---|
[285] | 1660 | $data['contact_in_list'] = $this->bo->catalog->get_contacts_by_group($id); |
---|
[2] | 1661 | } |
---|
[285] | 1662 | |
---|
[2] | 1663 | $boGroup = CreateObject('contactcenter.bo_group'); |
---|
[1599] | 1664 | |
---|
[1280] | 1665 | $all_contacts = $boGroup->get_all_contacts('only_email',$shared_from); |
---|
[285] | 1666 | |
---|
| 1667 | $contact_options = ""; |
---|
| 1668 | if(count($all_contacts)) { |
---|
| 1669 | foreach($all_contacts as $idx => $contact) { |
---|
| 1670 | $contact_options .= "<OPTION value='".$contact['id_connection']."'>".$contact['names_ordered']." (".$contact['connection_value'].")</OPTION>"; |
---|
| 1671 | } |
---|
| 1672 | } |
---|
[1599] | 1673 | $data['contact_list'] = $contact_options; |
---|
| 1674 | $data['result'] = 'ok'; |
---|
[285] | 1675 | echo serialize($data); |
---|
| 1676 | } |
---|
| 1677 | |
---|
[2] | 1678 | /*! |
---|
[1599] | 1679 | |
---|
[2] | 1680 | @function get_full_data |
---|
| 1681 | @abstract Returns all the information of a given Entry |
---|
| 1682 | @author Raphael Derosso Pereira |
---|
[1599] | 1683 | |
---|
[2] | 1684 | @param (integer) $id The id to get information |
---|
[1599] | 1685 | |
---|
[2] | 1686 | */ |
---|
[1599] | 1687 | /**rev 104**/ |
---|
| 1688 | //function get_full_data($id) |
---|
[503] | 1689 | function get_full_data($id,$catalog='bo_people_catalog') |
---|
[2] | 1690 | { |
---|
| 1691 | $dateformat = $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']; |
---|
[1599] | 1692 | /**rev 104**/ |
---|
| 1693 | //$this->bo->catalog = CreateObject('contactcenter.bo_people_catalog'); |
---|
| 1694 | $this->bo->catalog = CreateObject('contactcenter.'.$catalog); |
---|
| 1695 | /****/ |
---|
[2] | 1696 | $fields = $this->bo->catalog->get_fields(true); |
---|
| 1697 | $fields['photo'] = false; |
---|
| 1698 | $entry = $this->bo->catalog->get_single_entry($id,$fields); |
---|
| 1699 | |
---|
| 1700 | if (is_bool($entry['given_names'])) |
---|
| 1701 | { |
---|
| 1702 | $data['result'] = 'false'; |
---|
| 1703 | echo serialize($data); |
---|
| 1704 | return; |
---|
| 1705 | } |
---|
| 1706 | |
---|
| 1707 | $date = explode('-', $entry['birthdate']); |
---|
| 1708 | $j = 0; |
---|
| 1709 | for ($i = 0; $i < 5; $i+=2) |
---|
| 1710 | { |
---|
| 1711 | switch($dateformat{$i}) |
---|
| 1712 | { |
---|
| 1713 | case 'Y': |
---|
| 1714 | $birthdate[$j] = $date[0]; |
---|
| 1715 | break; |
---|
| 1716 | |
---|
| 1717 | case 'm': |
---|
| 1718 | case 'M': |
---|
| 1719 | $birthdate[$j] = $date[1]; |
---|
| 1720 | break; |
---|
| 1721 | |
---|
| 1722 | case 'd': |
---|
| 1723 | $birthdate[$j] = $date[2]; |
---|
| 1724 | } |
---|
| 1725 | $j++; |
---|
| 1726 | } |
---|
| 1727 | $datecount = 0; |
---|
[1599] | 1728 | |
---|
[2] | 1729 | $data['result'] = 'ok'; |
---|
| 1730 | $data['cc_full_add_contact_id'] = $id; |
---|
| 1731 | |
---|
| 1732 | /* Personal Data */ |
---|
| 1733 | $data['personal']['cc_pd_photo'] = '../index.php?menuaction=contactcenter.ui_data.data_manager&method=get_photo&id='.$id; |
---|
| 1734 | $data['personal']['cc_pd_alias'] = $entry['alias']; |
---|
| 1735 | $data['personal']['cc_pd_given_names'] = $entry['given_names']; |
---|
| 1736 | $data['personal']['cc_pd_family_names'] = $entry['family_names']; |
---|
| 1737 | $data['personal']['cc_pd_full_name'] = $entry['names_ordered']; |
---|
| 1738 | $data['personal']['cc_pd_suffix'] = $entry['id_suffix']; |
---|
| 1739 | $data['personal']['cc_pd_birthdate_0'] = $birthdate[0]; |
---|
| 1740 | $data['personal']['cc_pd_birthdate_1'] = $birthdate[1]; |
---|
| 1741 | $data['personal']['cc_pd_birthdate_2'] = $birthdate[2]; |
---|
| 1742 | //$data['personal']['cc_pd_sex'] = $entry['sex'] === 'M' ? 1 : ($entry['sex'] === 'F' ? 2 : 0); |
---|
| 1743 | $data['personal']['cc_pd_prefix'] = $entry['id_prefix']; |
---|
| 1744 | $data['personal']['cc_pd_gpg_finger_print'] = $entry['pgp_key']; |
---|
| 1745 | $data['personal']['cc_pd_notes'] = $entry['notes']; |
---|
| 1746 | |
---|
| 1747 | /* Addresses */ |
---|
| 1748 | if (is_array($entry['addresses'])) |
---|
| 1749 | { |
---|
| 1750 | $data['addresses'] = $entry['addresses']; |
---|
| 1751 | } |
---|
| 1752 | |
---|
| 1753 | /* Connections */ |
---|
| 1754 | if (is_array($entry['connections'])) |
---|
| 1755 | { |
---|
| 1756 | $data['connections'] = array(); |
---|
| 1757 | foreach ($entry['connections'] as $connection) |
---|
| 1758 | { |
---|
| 1759 | $type = $connection['id_type']; |
---|
| 1760 | $i = count($data['connections'][$type]); |
---|
| 1761 | $data['connections'][$type][$i]['id'] = $connection['id_connection']; |
---|
| 1762 | $data['connections'][$type][$i]['name'] = $connection['connection_name']; |
---|
| 1763 | $data['connections'][$type][$i]['value'] = $connection['connection_value']; |
---|
| 1764 | $data['connections'][$type][$i]['is_default'] = $connection['connection_is_default']; |
---|
| 1765 | } |
---|
| 1766 | } |
---|
[1599] | 1767 | // print_r($data); |
---|
| 1768 | //OBSERVAR cc_department |
---|
[1517] | 1769 | /*Corporative*/ |
---|
[1656] | 1770 | if($GLOBALS['phpgw_info']['server']['personal_contact_type']=='True'){ |
---|
| 1771 | $data['personal']['cc_job_title'] = $entry['job_title']; |
---|
| 1772 | $data['personal']['cc_department'] = $entry['department']; |
---|
| 1773 | $data['personal']['cc_name_corporate'] = $entry['corporate_name']; |
---|
| 1774 | $data['personal']['cc_web_page'] = $entry['web_page']; |
---|
| 1775 | } |
---|
| 1776 | |
---|
[1599] | 1777 | |
---|
| 1778 | |
---|
[2] | 1779 | /* Relations */ |
---|
[1599] | 1780 | |
---|
[2] | 1781 | echo serialize($data); |
---|
| 1782 | } |
---|
| 1783 | |
---|
| 1784 | /*! |
---|
| 1785 | |
---|
| 1786 | @function get_contact_full_add_const |
---|
| 1787 | @abstract Returns all the constant fields in Contact Full Add Window to the JS |
---|
| 1788 | @author Raphael Derosso Pereira |
---|
| 1789 | */ |
---|
| 1790 | function get_contact_full_add_const() |
---|
| 1791 | { |
---|
| 1792 | $data = array(); |
---|
| 1793 | $boPeopleCatalog = CreateObject('contactcenter.bo_people_catalog'); |
---|
| 1794 | $predata[] = $boPeopleCatalog -> get_all_prefixes(); |
---|
| 1795 | $predata[] = $boPeopleCatalog -> get_all_suffixes(); |
---|
| 1796 | $predata[] = $boPeopleCatalog -> get_all_addresses_types(); |
---|
| 1797 | $predata[] = $boPeopleCatalog -> get_all_countries(); |
---|
| 1798 | $predata[] = $boPeopleCatalog -> get_all_connections_types(); |
---|
| 1799 | //$predata[] = $this->bo->catalog->get_all_relations_types(); |
---|
| 1800 | |
---|
| 1801 | $i = 0; |
---|
| 1802 | foreach($predata as $data_) |
---|
| 1803 | { |
---|
| 1804 | if ($data_) |
---|
| 1805 | { |
---|
| 1806 | $data[$i] = $data_; |
---|
| 1807 | } |
---|
| 1808 | |
---|
| 1809 | $i++; |
---|
| 1810 | } |
---|
| 1811 | |
---|
| 1812 | if (count($data)) |
---|
| 1813 | { |
---|
| 1814 | echo serialize($data); |
---|
| 1815 | return; |
---|
| 1816 | } |
---|
[1599] | 1817 | |
---|
[2] | 1818 | echo 0; |
---|
| 1819 | } |
---|
[1599] | 1820 | |
---|
[2] | 1821 | /*! |
---|
[1599] | 1822 | |
---|
[2] | 1823 | @function quick_add |
---|
| 1824 | @abstract Adds a new Contact using the Quick Add interface |
---|
| 1825 | @author Raphael Derosso Pereira |
---|
[1599] | 1826 | |
---|
[2] | 1827 | @param string $sdata Serialized data |
---|
| 1828 | */ |
---|
| 1829 | function quick_add($sdata) |
---|
| 1830 | { |
---|
[1599] | 1831 | |
---|
[2] | 1832 | $sdata = str_replace('\\"', '"', $sdata); |
---|
| 1833 | $new_array = unserialize($sdata); |
---|
| 1834 | $tdata = array(); |
---|
[1599] | 1835 | |
---|
[2] | 1836 | foreach($new_array as $tmp) |
---|
| 1837 | $tdata[] = $tmp; |
---|
[1599] | 1838 | |
---|
[2] | 1839 | if (!$tdata) |
---|
| 1840 | { |
---|
| 1841 | echo serialize(array( |
---|
| 1842 | 'msg' => lang('Problems on adding your Contact. Invalid Data came from client. No Contact added!'), |
---|
| 1843 | 'status' => 'abort' |
---|
| 1844 | )); |
---|
[1599] | 1845 | |
---|
[2] | 1846 | return; |
---|
| 1847 | } |
---|
[1599] | 1848 | |
---|
[3334] | 1849 | // verifica se email já existe! |
---|
[2] | 1850 | $boGroup = CreateObject('contactcenter.bo_group'); |
---|
| 1851 | $contact = $boGroup->verify_contact($tdata[4]); |
---|
[1599] | 1852 | |
---|
[2] | 1853 | if($contact) |
---|
[1599] | 1854 | { |
---|
[2] | 1855 | $str_contact = "\r\n - ".implode("\r\n - ",$contact); |
---|
[1599] | 1856 | |
---|
[2] | 1857 | echo serialize(array( |
---|
| 1858 | 'msg' => lang('Problems on adding your Contact. The email "%1" already exists in: %2',$tdata[4], $str_contact), |
---|
| 1859 | 'status' => 'alreadyExists' |
---|
| 1860 | )); |
---|
[1599] | 1861 | |
---|
| 1862 | return; |
---|
[2] | 1863 | } |
---|
| 1864 | |
---|
[3239] | 1865 | $data['alias'] = addslashes($tdata[0]); |
---|
| 1866 | $data['given_names'] = addslashes($tdata[1]); |
---|
| 1867 | $data['family_names'] = addslashes($tdata[2]); |
---|
[2] | 1868 | $data['connections']['default_phone']['connection_name'] = lang('Main'); |
---|
| 1869 | $data['connections']['default_phone']['connection_value'] = $tdata[3]; |
---|
| 1870 | $data['connections']['default_email']['connection_name'] = lang('Main'); |
---|
| 1871 | $data['connections']['default_email']['connection_value'] = $tdata[4]; |
---|
[3660] | 1872 | $data['is_quick_add'] = true; |
---|
[2] | 1873 | $boPeople = CreateObject('contactcenter.bo_people_catalog'); |
---|
| 1874 | |
---|
| 1875 | if ($boPeople ->quick_add($data)) |
---|
[1599] | 1876 | { |
---|
[2] | 1877 | $this->page_info['changed'] = true; |
---|
[1599] | 1878 | |
---|
[2] | 1879 | echo serialize(array( |
---|
| 1880 | 'msg' => lang('Entry added with success!'), |
---|
| 1881 | 'status' => 'ok' |
---|
| 1882 | )); |
---|
| 1883 | } |
---|
| 1884 | else |
---|
| 1885 | { |
---|
| 1886 | echo serialize(array( |
---|
| 1887 | 'msg' => lang('Problems on adding your Contact. No Contact added!'), |
---|
| 1888 | 'status' => 'error' |
---|
| 1889 | )); |
---|
| 1890 | } |
---|
| 1891 | |
---|
[1599] | 1892 | $this->save_session(); |
---|
| 1893 | |
---|
[2] | 1894 | } |
---|
| 1895 | |
---|
| 1896 | /*! |
---|
[1599] | 1897 | |
---|
[2] | 1898 | @function add_group |
---|
| 1899 | @abstract Adds a new Group using the Add Group interface |
---|
| 1900 | @author Nilton Emilio Buhrer Neto |
---|
[1599] | 1901 | |
---|
[2] | 1902 | @param string $sdata Serialized data |
---|
| 1903 | */ |
---|
| 1904 | function add_group($sdata) |
---|
| 1905 | { |
---|
| 1906 | $sdata = str_replace('\\"', '"', $sdata); |
---|
| 1907 | $tdata = unserialize($sdata); |
---|
| 1908 | $new_tdata = array(); |
---|
[1599] | 1909 | |
---|
[2] | 1910 | if (!$tdata) |
---|
| 1911 | { |
---|
| 1912 | echo serialize(array( |
---|
| 1913 | 'msg' => lang('Problems on adding your Contact. Invalid Data came from client. No Contact added!'), |
---|
| 1914 | 'status' => 'abort' |
---|
| 1915 | )); |
---|
[1599] | 1916 | |
---|
[2] | 1917 | return; |
---|
| 1918 | } |
---|
[1599] | 1919 | |
---|
[2] | 1920 | foreach($tdata as $tmp) |
---|
| 1921 | $new_tdata[] = $tmp; |
---|
[1599] | 1922 | |
---|
| 1923 | $data['title'] = $new_tdata[0]; |
---|
[2] | 1924 | $data['contact_in_list'] = $new_tdata[1]; |
---|
| 1925 | $data['id_group'] = $new_tdata[2]; |
---|
[1599] | 1926 | |
---|
[2] | 1927 | $boGroup = CreateObject('contactcenter.bo_group_manager'); |
---|
| 1928 | $id = $boGroup -> add_group($data); |
---|
[1599] | 1929 | |
---|
[2] | 1930 | if ($id) |
---|
| 1931 | { |
---|
| 1932 | $this->page_info['changed'] = true; |
---|
[1599] | 1933 | |
---|
[2] | 1934 | echo serialize(array( |
---|
| 1935 | 'msg' => lang('Entry added with success!'), |
---|
| 1936 | 'status' => 'ok' |
---|
| 1937 | )); |
---|
| 1938 | } |
---|
| 1939 | else |
---|
| 1940 | { |
---|
| 1941 | echo serialize(array( |
---|
[3348] | 1942 | 'msg' => lang('Problems on adding your Group. Be sure that a group with this name do not exists'), |
---|
[2] | 1943 | 'status' => 'error' |
---|
| 1944 | )); |
---|
| 1945 | } |
---|
| 1946 | |
---|
| 1947 | $this->save_session(); |
---|
| 1948 | } |
---|
| 1949 | |
---|
| 1950 | /*! |
---|
[1599] | 1951 | |
---|
[2] | 1952 | @function remove_group |
---|
| 1953 | @abstract Removes a group if the user has the right to do it |
---|
[1599] | 1954 | @author Nilton Emilio Buhrer Neto |
---|
[2] | 1955 | @param (integer) $id The id to be removed |
---|
[1599] | 1956 | |
---|
[2] | 1957 | */ |
---|
| 1958 | function remove_group($id) |
---|
[1599] | 1959 | { |
---|
| 1960 | $soGroup = CreateObject('contactcenter.so_group'); |
---|
[2] | 1961 | $data = array ('id_group' => $id); |
---|
| 1962 | if($soGroup -> delete($data)) { |
---|
| 1963 | echo serialize(array( |
---|
| 1964 | 'msg' => lang('Removed Entry ID '.$id.'!'), |
---|
| 1965 | 'status' => 'ok' |
---|
[1599] | 1966 | )); |
---|
[2] | 1967 | } |
---|
| 1968 | else { |
---|
| 1969 | echo serialize(array( |
---|
| 1970 | 'msg' => lang('Problems on adding your Contact. No Contact added!'), |
---|
| 1971 | 'status' => 'error' |
---|
| 1972 | )); |
---|
| 1973 | } |
---|
| 1974 | |
---|
[1599] | 1975 | $this->save_session(); |
---|
[2] | 1976 | } |
---|
| 1977 | |
---|
| 1978 | |
---|
| 1979 | function remove_all_entries (){ |
---|
[1599] | 1980 | |
---|
[2] | 1981 | $error = false; |
---|
| 1982 | $this->all_entries = $this->bo->catalog->get_all_entries_ids(); |
---|
| 1983 | |
---|
| 1984 | foreach($this->all_entries as $index => $id) { |
---|
| 1985 | $result = $this->bo->catalog->remove_single_entry($id); |
---|
| 1986 | if(!$result) { |
---|
| 1987 | $error = true; |
---|
[1599] | 1988 | break; |
---|
[2] | 1989 | } |
---|
| 1990 | } |
---|
| 1991 | |
---|
| 1992 | if(!$error) { |
---|
| 1993 | echo serialize(array( |
---|
| 1994 | 'msg' => lang('Removed Entry ID '.$id.'!'), |
---|
| 1995 | 'status' => 'ok' |
---|
| 1996 | )); |
---|
[1599] | 1997 | } |
---|
[2] | 1998 | else { |
---|
| 1999 | echo serialize(array( |
---|
| 2000 | 'msg' => lang('Couldn\'t remove this entry. Inform the Site Admin!'), |
---|
| 2001 | 'status' => 'fail' |
---|
| 2002 | )); |
---|
| 2003 | } |
---|
| 2004 | |
---|
| 2005 | $this->save_session(); |
---|
| 2006 | } |
---|
| 2007 | |
---|
| 2008 | /*! |
---|
[1599] | 2009 | |
---|
[2] | 2010 | @function remove_entry |
---|
| 2011 | @abstract Removes an entry if the user has the right to do it |
---|
| 2012 | @author Raphael Derosso Pereira |
---|
[1599] | 2013 | |
---|
[2] | 2014 | @param (integer) $id The id to be removed |
---|
[1599] | 2015 | |
---|
[2] | 2016 | */ |
---|
| 2017 | function remove_entry ($id) |
---|
| 2018 | { |
---|
| 2019 | if (!is_int($id)) |
---|
| 2020 | { |
---|
| 2021 | echo lang('Couldn\'t remove entry! Problem passing data to the server. Please inform admin!'); |
---|
| 2022 | return; |
---|
| 2023 | } |
---|
[1599] | 2024 | |
---|
[2] | 2025 | $this->page_info['changed'] = true; |
---|
| 2026 | $result = $this->bo->catalog->remove_single_entry($id); |
---|
[1599] | 2027 | |
---|
[2] | 2028 | if ($result) |
---|
| 2029 | { |
---|
| 2030 | if ($pos = array_search($id, $this->page_info['actual_entries'])) |
---|
| 2031 | { |
---|
| 2032 | unset($this->page_info['actual_entries'][$pos]); |
---|
| 2033 | } |
---|
[1599] | 2034 | |
---|
[2] | 2035 | $temp = false; |
---|
| 2036 | reset($this->page_info['actual_entries']); |
---|
| 2037 | foreach($this->page_info['actual_entries'] as $t) |
---|
| 2038 | { |
---|
| 2039 | $temp[] = $t; |
---|
| 2040 | } |
---|
[1599] | 2041 | |
---|
[2] | 2042 | $this->page_info['actual_entries'] = $temp; |
---|
| 2043 | |
---|
| 2044 | echo serialize(array( |
---|
| 2045 | 'msg' => lang('Removed Entry ID '.$id.'!'), |
---|
| 2046 | 'status' => 'ok' |
---|
| 2047 | )); |
---|
| 2048 | } |
---|
| 2049 | else |
---|
| 2050 | { |
---|
| 2051 | echo serialize(array( |
---|
| 2052 | 'msg' => lang('Couldn\'t remove this entry. Inform the Site Admin!'), |
---|
| 2053 | 'status' => 'fail' |
---|
| 2054 | )); |
---|
| 2055 | } |
---|
[1599] | 2056 | |
---|
[2] | 2057 | $this->save_session(); |
---|
| 2058 | } |
---|
| 2059 | |
---|
[1599] | 2060 | |
---|
[2] | 2061 | /*! |
---|
[1599] | 2062 | |
---|
[2] | 2063 | @function post_full_add |
---|
| 2064 | @abstract Saves all the information altered/entered in the Full Add |
---|
| 2065 | window |
---|
| 2066 | @author Raphael Derosso Pereira |
---|
| 2067 | |
---|
| 2068 | */ |
---|
| 2069 | function post_full_add() |
---|
| 2070 | { |
---|
[285] | 2071 | $data = $_POST['data']; |
---|
[1599] | 2072 | // Exceptions!!! utf8 special chars. |
---|
[285] | 2073 | $data = preg_replace("/\%u2(\d+)(\d+)(\d+)/","-",$data); |
---|
| 2074 | $data = unserialize(str_replace('\\"', '"', $data)); |
---|
[2] | 2075 | $this -> bo -> catalog = CreateObject('contactcenter.bo_people_catalog'); |
---|
| 2076 | |
---|
| 2077 | if (!is_array($data)) |
---|
| 2078 | { |
---|
| 2079 | echo serialize(array( |
---|
| 2080 | 'msg' => lang('<p>Some problem receiving data from browser. This is probably a bug in ContactCenter<br>'. |
---|
| 2081 | 'Please go to eGroupWare Bug Reporting page and report this bug.<br>'. |
---|
| 2082 | 'Sorry for the inconvenient!<br><br>'. |
---|
| 2083 | '<b><i>ContactCenter Developer Team</i></b></p>'), |
---|
| 2084 | 'status' => 'fatal' |
---|
| 2085 | )); |
---|
| 2086 | return; |
---|
| 2087 | } |
---|
| 2088 | // print_r($data); |
---|
| 2089 | // echo '<br><br>'; |
---|
| 2090 | |
---|
| 2091 | $replacer = $data['commercialAnd']; |
---|
| 2092 | unset($data['commercialAnd']); |
---|
| 2093 | if (!is_string($replacer) or strpos($replacer, "'") or strpos($replacer, '"')) |
---|
| 2094 | { |
---|
| 2095 | echo serialize(array( |
---|
| 2096 | 'msg' => lang('Invalid \'&\' replacer! This may be an attempt to bypass Security! Action aborted!'), |
---|
| 2097 | 'status' => 'fatal' |
---|
| 2098 | )); |
---|
[1599] | 2099 | |
---|
[2] | 2100 | return; |
---|
| 2101 | } |
---|
| 2102 | |
---|
| 2103 | if ($data['id_contact']) |
---|
| 2104 | { |
---|
| 2105 | $id = $data['id_contact']; |
---|
| 2106 | $id_photo = $id; |
---|
| 2107 | unset($data['id_contact']); |
---|
| 2108 | } |
---|
| 2109 | else |
---|
| 2110 | { |
---|
| 2111 | $id_photo = '_new_'; |
---|
| 2112 | } |
---|
[1599] | 2113 | |
---|
| 2114 | /* |
---|
| 2115 | * Process Photo, if available |
---|
[2] | 2116 | */ |
---|
| 2117 | $sleep_count = 0; |
---|
| 2118 | $photo_ok = $GLOBALS['phpgw']->session->appsession('ui_data.photo','contactcenter'); |
---|
| 2119 | while($photo_ok[0]{0} !== 'o' and $photo_ok[1]{0} === 'y') |
---|
| 2120 | { |
---|
| 2121 | sleep(1); |
---|
| 2122 | $photo_ok = $GLOBALS['phpgw']->session->appsession('ui_data.photo','contactcenter'); |
---|
| 2123 | $sleep_count++; |
---|
| 2124 | |
---|
| 2125 | if ($sleep_count > 35) |
---|
| 2126 | { |
---|
| 2127 | // TODO |
---|
| 2128 | return; |
---|
| 2129 | } |
---|
| 2130 | } |
---|
| 2131 | $GLOBALS['phpgw']->session->appsession('ui_data.photo','contactcenter', array('wait', 'n')); |
---|
[1599] | 2132 | |
---|
[2] | 2133 | if (isset($this->page_info['photos'][$id_photo])) |
---|
| 2134 | { |
---|
| 2135 | if (array_search($this->page_info['photos'][$id_photo]['status'], array('changed', 'sync')) === false) |
---|
| 2136 | { |
---|
| 2137 | echo serialize(array( |
---|
| 2138 | 'msg' => $this->page_info['photos'][$id_photo]['msg'], |
---|
| 2139 | 'status' => $this->page_info['photos'][$id_photo]['status'] |
---|
| 2140 | )); |
---|
| 2141 | |
---|
| 2142 | return; |
---|
| 2143 | } |
---|
| 2144 | |
---|
| 2145 | $data['photo'] = $this->page_info['photos'][$id_photo]['content']; |
---|
| 2146 | unset($this->page_info['photos'][$id_photo]); |
---|
| 2147 | $this->save_session(); |
---|
| 2148 | } |
---|
[1599] | 2149 | |
---|
[2] | 2150 | /* |
---|
| 2151 | * Arrange Date so it gets inserted correctly |
---|
| 2152 | */ |
---|
[1599] | 2153 | |
---|
[2] | 2154 | $dateformat = $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']; |
---|
[1599] | 2155 | |
---|
[2] | 2156 | $j = 0; |
---|
| 2157 | for ($i = 0; $i < 5; $i+=2) |
---|
| 2158 | { |
---|
| 2159 | switch($dateformat{$i}) |
---|
| 2160 | { |
---|
| 2161 | case 'Y': |
---|
| 2162 | $date[$j]['size'] = 4; |
---|
| 2163 | $date[$j]['digit'] = 'Y'; |
---|
| 2164 | break; |
---|
| 2165 | |
---|
| 2166 | case 'm': |
---|
| 2167 | case 'M': |
---|
| 2168 | $date[$j]['size'] = 2; |
---|
| 2169 | $date[$j]['digit'] = 'M'; |
---|
| 2170 | break; |
---|
| 2171 | |
---|
| 2172 | case 'd': |
---|
| 2173 | $date[$j]['size'] = 2; |
---|
| 2174 | $date[$j]['digit'] = 'D'; |
---|
| 2175 | } |
---|
| 2176 | $j++; |
---|
| 2177 | } |
---|
| 2178 | $datecount = 0; |
---|
| 2179 | |
---|
| 2180 | /* Verify Data and performs insertion/update */ |
---|
[3018] | 2181 | foreach($data as $field => $value) |
---|
[2] | 2182 | { |
---|
[1599] | 2183 | |
---|
[2] | 2184 | switch($field) |
---|
| 2185 | { |
---|
[3018] | 2186 | case 'names_ordered': |
---|
[3247] | 2187 | $data[$field] = addslashes(rawurldecode($value)); |
---|
[1517] | 2188 | case 'corporate_name': |
---|
| 2189 | case 'job_title': |
---|
| 2190 | case 'department': |
---|
| 2191 | case 'web_page': |
---|
[2] | 2192 | case 'alias': |
---|
| 2193 | case 'given_names': |
---|
| 2194 | case 'family_names': |
---|
| 2195 | case 'pgp_key': |
---|
| 2196 | case 'notes': |
---|
[3247] | 2197 | $data[$field] = addslashes(rawurldecode($data[$field])); |
---|
[2] | 2198 | break; |
---|
[1599] | 2199 | |
---|
[2] | 2200 | case 'id_status': |
---|
| 2201 | case 'id_prefix': |
---|
| 2202 | case 'id_suffix': |
---|
| 2203 | if ($data[$field] == 0) |
---|
| 2204 | { |
---|
| 2205 | unset($data[$field]); |
---|
| 2206 | } |
---|
| 2207 | break; |
---|
[1599] | 2208 | |
---|
[2] | 2209 | case 'birthdate_0': |
---|
| 2210 | case 'birthdate_1': |
---|
| 2211 | case 'birthdate_2': |
---|
[3310] | 2212 | case 'birthdate': |
---|
| 2213 | |
---|
| 2214 | if($field == 'birthdate'){ |
---|
| 2215 | $array_birth = explode("/",$data[$field]); |
---|
| 2216 | $date['value'][2] = $array_birth[2]; |
---|
| 2217 | $date['value'][1] = $array_birth[1]; |
---|
| 2218 | $date['value'][0] = $array_birth[0]; |
---|
| 2219 | }else{ |
---|
| 2220 | switch($date[$datecount]['digit']) |
---|
| 2221 | { |
---|
| 2222 | case 'Y': |
---|
| 2223 | $date['value'][2] = (int) $data[$field]; |
---|
| 2224 | break; |
---|
| 2225 | |
---|
| 2226 | case 'M': |
---|
| 2227 | $date['value'][0] = (int) $data[$field]; |
---|
| 2228 | break; |
---|
| 2229 | |
---|
| 2230 | case 'D': |
---|
| 2231 | $date['value'][1] = (int) $data[$field]; |
---|
| 2232 | break; |
---|
| 2233 | } |
---|
| 2234 | unset($data[$field]); |
---|
[2] | 2235 | } |
---|
[3310] | 2236 | |
---|
[2] | 2237 | $datecount++; |
---|
| 2238 | |
---|
| 2239 | if ($datecount != 3) |
---|
| 2240 | { |
---|
| 2241 | break; |
---|
| 2242 | } |
---|
[1599] | 2243 | |
---|
[3310] | 2244 | if($date['value'][0] =='' && $date['value'][1] =='' && $date['value'][2] ==''){ |
---|
| 2245 | $data['birthdate'] = null; |
---|
| 2246 | break; |
---|
| 2247 | } |
---|
[2] | 2248 | if (!checkdate($date['value'][0], $date['value'][1], $date['value'][2])) |
---|
| 2249 | { |
---|
| 2250 | echo serialize(array( |
---|
| 2251 | 'msg' => lang('Invalid Date'), |
---|
| 2252 | 'status' => 'invalid_data' |
---|
| 2253 | )); |
---|
| 2254 | return; |
---|
| 2255 | } |
---|
[3310] | 2256 | if( $date['value'][2] != "" && $date['value'][0] != "" && $date['value'][1] != ""){ |
---|
| 2257 | $data['birthdate'] = $date['value'][2].'-'.$date['value'][0].'-'.$date['value'][1]; |
---|
| 2258 | } |
---|
[2] | 2259 | break; |
---|
| 2260 | |
---|
| 2261 | case 'sex': |
---|
| 2262 | if ($data[$field] !== 'M' and $data[$field] !== 'F') |
---|
| 2263 | { |
---|
| 2264 | echo serialize(array( |
---|
| 2265 | 'msg' => lang('Invalid Sex'), |
---|
| 2266 | 'status' => 'invalid_data' |
---|
| 2267 | )); |
---|
| 2268 | return; |
---|
| 2269 | } |
---|
| 2270 | break; |
---|
| 2271 | |
---|
| 2272 | |
---|
| 2273 | case 'addresses': |
---|
| 2274 | /* Insert new cities/states */ |
---|
| 2275 | if (isset($value['new_states'])) |
---|
| 2276 | { |
---|
| 2277 | foreach($value['new_states'] as $type => $state_info) |
---|
| 2278 | { |
---|
| 2279 | $index = 'address'.$type; |
---|
[1599] | 2280 | |
---|
[2] | 2281 | $id_state = $this->bo->catalog->add_state($state_info); |
---|
| 2282 | $data['addresses'][$index]['id_state'] = $id_state; |
---|
| 2283 | |
---|
| 2284 | if ($value['new_cities'][$type]) |
---|
| 2285 | { |
---|
[3018] | 2286 | $data[$field]['new_cities'][$type]['id_state'] = $id_state; |
---|
[2] | 2287 | } |
---|
| 2288 | } |
---|
| 2289 | |
---|
| 2290 | unset($data['addresses']['new_states']); |
---|
| 2291 | } |
---|
| 2292 | |
---|
| 2293 | if (isset($value['new_cities'])) |
---|
| 2294 | { |
---|
| 2295 | foreach($value['new_cities'] as $type => $city_info) |
---|
| 2296 | { |
---|
| 2297 | $index = 'address'.$type; |
---|
[1599] | 2298 | |
---|
[2] | 2299 | $id_city = $this->bo->catalog->add_city($city_info); |
---|
| 2300 | $data['addresses'][$index]['id_city'] = $id_city; |
---|
| 2301 | } |
---|
| 2302 | |
---|
| 2303 | unset($data['addresses']['new_cities']); |
---|
| 2304 | } |
---|
| 2305 | |
---|
| 2306 | break; |
---|
| 2307 | |
---|
[3198] | 2308 | case 'birthdate': |
---|
[2] | 2309 | case 'connections': |
---|
[1687] | 2310 | case 'photo': |
---|
[2] | 2311 | /* Does nothing... */ |
---|
| 2312 | break; |
---|
| 2313 | |
---|
| 2314 | default: |
---|
| 2315 | echo serialize(array( |
---|
| 2316 | 'msg' => lang('Invalid field: ').$field, |
---|
| 2317 | 'status' => 'invalid_data' |
---|
| 2318 | )); |
---|
| 2319 | return; |
---|
| 2320 | } |
---|
| 2321 | } |
---|
| 2322 | |
---|
| 2323 | if (!is_null($id) and $id !== '') |
---|
| 2324 | { |
---|
[3018] | 2325 | $id = $this->bo->catalog->update_single_info($id, $data); |
---|
[2] | 2326 | $result = array( |
---|
| 2327 | 'msg' => lang('Updated Successfully!'), |
---|
| 2328 | 'status' => 'ok' |
---|
| 2329 | ); |
---|
| 2330 | } |
---|
| 2331 | else |
---|
| 2332 | { |
---|
[3018] | 2333 | $id = $this->bo->catalog->add_single_entry($data); |
---|
[2] | 2334 | $result = array( |
---|
| 2335 | 'msg' => lang('Entry Added Successfully!'), |
---|
| 2336 | 'status' => 'ok' |
---|
| 2337 | ); |
---|
| 2338 | } |
---|
[1599] | 2339 | |
---|
[2] | 2340 | if (!($id)) |
---|
| 2341 | { |
---|
| 2342 | $result = array( |
---|
| 2343 | 'msg' => lang('Some problem occured when trying to insert/update contact information.<br>'. |
---|
| 2344 | 'Report the problem to the Administrator.'), |
---|
| 2345 | 'status' => 'fail' |
---|
| 2346 | ); |
---|
| 2347 | } |
---|
| 2348 | |
---|
| 2349 | echo serialize($result); |
---|
| 2350 | } |
---|
| 2351 | |
---|
[1496] | 2352 | |
---|
| 2353 | function post_full_add_shared() |
---|
| 2354 | { |
---|
| 2355 | $data = $_POST['data']; |
---|
[1599] | 2356 | // Exceptions!!! utf8 special chars. |
---|
[1496] | 2357 | $data = preg_replace("/\%u2(\d+)(\d+)(\d+)/","-",$data); |
---|
| 2358 | $data = unserialize(str_replace('\\"', '"', $data)); |
---|
| 2359 | $this -> bo -> catalog = CreateObject('contactcenter.bo_shared_people_manager'); |
---|
| 2360 | |
---|
| 2361 | if (!is_array($data)) |
---|
| 2362 | { |
---|
| 2363 | echo serialize(array( |
---|
| 2364 | 'msg' => lang('<p>Some problem receiving data from browser. This is probably a bug in ContactCenter<br>'. |
---|
| 2365 | 'Please go to eGroupWare Bug Reporting page and report this bug.<br>'. |
---|
| 2366 | 'Sorry for the inconvenient!<br><br>'. |
---|
| 2367 | '<b><i>ContactCenter Developer Team</i></b></p>'), |
---|
| 2368 | 'status' => 'fatal' |
---|
| 2369 | )); |
---|
| 2370 | return; |
---|
| 2371 | } |
---|
| 2372 | // print_r($data); |
---|
| 2373 | // echo '<br><br>'; |
---|
| 2374 | |
---|
| 2375 | $replacer = $data['commercialAnd']; |
---|
| 2376 | unset($data['commercialAnd']); |
---|
| 2377 | if (!is_string($replacer) or strpos($replacer, "'") or strpos($replacer, '"')) |
---|
| 2378 | { |
---|
| 2379 | echo serialize(array( |
---|
| 2380 | 'msg' => lang('Invalid \'&\' replacer! This may be an attempt to bypass Security! Action aborted!'), |
---|
| 2381 | 'status' => 'fatal' |
---|
| 2382 | )); |
---|
[1599] | 2383 | |
---|
[1496] | 2384 | return; |
---|
| 2385 | } |
---|
| 2386 | |
---|
| 2387 | if ($data['id_contact']) |
---|
| 2388 | { |
---|
| 2389 | $id = $data['id_contact']; |
---|
| 2390 | $id_photo = $id; |
---|
| 2391 | unset($data['id_contact']); |
---|
| 2392 | } |
---|
| 2393 | else |
---|
| 2394 | { |
---|
| 2395 | $id_photo = '_new_'; |
---|
| 2396 | } |
---|
| 2397 | |
---|
| 2398 | if ($data['owner']) |
---|
| 2399 | { |
---|
| 2400 | $owner = $data['owner']; |
---|
| 2401 | unset($data['owner']); |
---|
| 2402 | } |
---|
[1599] | 2403 | /* |
---|
| 2404 | * Process Photo, if available |
---|
[1496] | 2405 | */ |
---|
| 2406 | $sleep_count = 0; |
---|
| 2407 | $photo_ok = $GLOBALS['phpgw']->session->appsession('ui_data.photo','contactcenter'); |
---|
| 2408 | while($photo_ok[0]{0} !== 'o' and $photo_ok[1]{0} === 'y') |
---|
| 2409 | { |
---|
| 2410 | sleep(1); |
---|
| 2411 | $photo_ok = $GLOBALS['phpgw']->session->appsession('ui_data.photo','contactcenter'); |
---|
| 2412 | $sleep_count++; |
---|
| 2413 | |
---|
| 2414 | if ($sleep_count > 35) |
---|
| 2415 | { |
---|
| 2416 | // TODO |
---|
| 2417 | return; |
---|
| 2418 | } |
---|
| 2419 | } |
---|
| 2420 | $GLOBALS['phpgw']->session->appsession('ui_data.photo','contactcenter', array('wait', 'n')); |
---|
[1599] | 2421 | |
---|
[1496] | 2422 | if (isset($this->page_info['photos'][$id_photo])) |
---|
| 2423 | { |
---|
| 2424 | if (array_search($this->page_info['photos'][$id_photo]['status'], array('changed', 'sync')) === false) |
---|
| 2425 | { |
---|
| 2426 | echo serialize(array( |
---|
| 2427 | 'msg' => $this->page_info['photos'][$id_photo]['msg'], |
---|
| 2428 | 'status' => $this->page_info['photos'][$id_photo]['status'] |
---|
| 2429 | )); |
---|
| 2430 | |
---|
| 2431 | return; |
---|
| 2432 | } |
---|
| 2433 | |
---|
| 2434 | $data['photo'] = $this->page_info['photos'][$id_photo]['content']; |
---|
| 2435 | unset($this->page_info['photos'][$id_photo]); |
---|
| 2436 | $this->save_session(); |
---|
| 2437 | } |
---|
[1599] | 2438 | |
---|
[1496] | 2439 | /* |
---|
| 2440 | * Arrange Date so it gets inserted correctly |
---|
| 2441 | */ |
---|
[1599] | 2442 | |
---|
[1496] | 2443 | $dateformat = $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']; |
---|
[1599] | 2444 | |
---|
[1496] | 2445 | $j = 0; |
---|
| 2446 | for ($i = 0; $i < 5; $i+=2) |
---|
| 2447 | { |
---|
| 2448 | switch($dateformat{$i}) |
---|
| 2449 | { |
---|
| 2450 | case 'Y': |
---|
| 2451 | $date[$j]['size'] = 4; |
---|
| 2452 | $date[$j]['digit'] = 'Y'; |
---|
| 2453 | break; |
---|
| 2454 | |
---|
| 2455 | case 'm': |
---|
| 2456 | case 'M': |
---|
| 2457 | $date[$j]['size'] = 2; |
---|
| 2458 | $date[$j]['digit'] = 'M'; |
---|
| 2459 | break; |
---|
| 2460 | |
---|
| 2461 | case 'd': |
---|
| 2462 | $date[$j]['size'] = 2; |
---|
| 2463 | $date[$j]['digit'] = 'D'; |
---|
| 2464 | } |
---|
| 2465 | $j++; |
---|
| 2466 | } |
---|
| 2467 | $datecount = 0; |
---|
| 2468 | |
---|
| 2469 | /* Verify Data and performs insertion/update */ |
---|
| 2470 | foreach($data as $field => &$value) |
---|
| 2471 | { |
---|
| 2472 | if ($value == '' or is_null($value)) |
---|
| 2473 | { |
---|
| 2474 | unset($data[$field]); |
---|
| 2475 | continue; |
---|
| 2476 | } |
---|
[1599] | 2477 | |
---|
[1496] | 2478 | switch($field) |
---|
| 2479 | { |
---|
[3341] | 2480 | case 'corporate_name': |
---|
| 2481 | case 'job_title': |
---|
| 2482 | case 'department': |
---|
| 2483 | case 'web_page': |
---|
[1496] | 2484 | case 'alias': |
---|
| 2485 | case 'given_names': |
---|
| 2486 | case 'family_names': |
---|
| 2487 | case 'names_ordered': |
---|
| 2488 | case 'pgp_key': |
---|
| 2489 | case 'notes': |
---|
| 2490 | case 'photo': |
---|
[3018] | 2491 | $data[$field] = urldecode( $value ); |
---|
[1496] | 2492 | break; |
---|
[1599] | 2493 | |
---|
[1496] | 2494 | case 'id_status': |
---|
| 2495 | case 'id_prefix': |
---|
| 2496 | case 'id_suffix': |
---|
| 2497 | if ($data[$field] == 0) |
---|
| 2498 | { |
---|
| 2499 | unset($data[$field]); |
---|
| 2500 | } |
---|
| 2501 | break; |
---|
[1599] | 2502 | |
---|
[1496] | 2503 | case 'birthdate_0': |
---|
| 2504 | case 'birthdate_1': |
---|
| 2505 | case 'birthdate_2': |
---|
[1599] | 2506 | |
---|
[1496] | 2507 | switch($date[$datecount]['digit']) |
---|
| 2508 | { |
---|
| 2509 | case 'Y': |
---|
| 2510 | $date['value'][2] = (int) $data[$field]; |
---|
| 2511 | break; |
---|
| 2512 | |
---|
| 2513 | case 'M': |
---|
| 2514 | $date['value'][0] = (int) $data[$field]; |
---|
| 2515 | break; |
---|
| 2516 | |
---|
| 2517 | case 'D': |
---|
| 2518 | $date['value'][1] = (int) $data[$field]; |
---|
| 2519 | break; |
---|
| 2520 | } |
---|
| 2521 | unset($data[$field]); |
---|
| 2522 | $datecount++; |
---|
| 2523 | |
---|
| 2524 | if ($datecount != 3) |
---|
| 2525 | { |
---|
| 2526 | break; |
---|
| 2527 | } |
---|
[1599] | 2528 | |
---|
[1496] | 2529 | if (!checkdate($date['value'][0], $date['value'][1], $date['value'][2])) |
---|
| 2530 | { |
---|
| 2531 | echo serialize(array( |
---|
| 2532 | 'msg' => lang('Invalid Date'), |
---|
| 2533 | 'status' => 'invalid_data' |
---|
| 2534 | )); |
---|
| 2535 | return; |
---|
| 2536 | } |
---|
[1599] | 2537 | |
---|
[1496] | 2538 | $data['birthdate'] = $date['value'][2].'-'.$date['value'][0].'-'.$date['value'][1]; |
---|
| 2539 | break; |
---|
| 2540 | |
---|
| 2541 | case 'sex': |
---|
| 2542 | if ($data[$field] !== 'M' and $data[$field] !== 'F') |
---|
| 2543 | { |
---|
| 2544 | echo serialize(array( |
---|
| 2545 | 'msg' => lang('Invalid Sex'), |
---|
| 2546 | 'status' => 'invalid_data' |
---|
| 2547 | )); |
---|
| 2548 | return; |
---|
| 2549 | } |
---|
| 2550 | break; |
---|
| 2551 | |
---|
| 2552 | |
---|
| 2553 | case 'addresses': |
---|
| 2554 | /* Insert new cities/states */ |
---|
| 2555 | if (isset($value['new_states'])) |
---|
| 2556 | { |
---|
| 2557 | foreach($value['new_states'] as $type => $state_info) |
---|
| 2558 | { |
---|
| 2559 | $index = 'address'.$type; |
---|
[1599] | 2560 | |
---|
[1496] | 2561 | $id_state = $this->bo->catalog->add_state($state_info); |
---|
| 2562 | $data['addresses'][$index]['id_state'] = $id_state; |
---|
| 2563 | |
---|
| 2564 | if ($value['new_cities'][$type]) |
---|
| 2565 | { |
---|
| 2566 | $value['new_cities'][$type]['id_state'] = $id_state; |
---|
| 2567 | } |
---|
| 2568 | } |
---|
| 2569 | |
---|
| 2570 | unset($data['addresses']['new_states']); |
---|
| 2571 | } |
---|
| 2572 | |
---|
| 2573 | if (isset($value['new_cities'])) |
---|
| 2574 | { |
---|
| 2575 | foreach($value['new_cities'] as $type => $city_info) |
---|
| 2576 | { |
---|
| 2577 | $index = 'address'.$type; |
---|
[1599] | 2578 | |
---|
[1496] | 2579 | $id_city = $this->bo->catalog->add_city($city_info); |
---|
| 2580 | $data['addresses'][$index]['id_city'] = $id_city; |
---|
| 2581 | } |
---|
| 2582 | |
---|
| 2583 | unset($data['addresses']['new_cities']); |
---|
| 2584 | } |
---|
| 2585 | |
---|
| 2586 | break; |
---|
| 2587 | |
---|
| 2588 | case 'connections': |
---|
| 2589 | /* Does nothing... */ |
---|
| 2590 | break; |
---|
| 2591 | |
---|
| 2592 | default: |
---|
| 2593 | echo serialize(array( |
---|
| 2594 | 'msg' => lang('Invalid field: ').$field, |
---|
| 2595 | 'status' => 'invalid_data' |
---|
| 2596 | )); |
---|
| 2597 | return; |
---|
| 2598 | } |
---|
| 2599 | } |
---|
| 2600 | |
---|
| 2601 | $code = '$id = $this->bo->catalog->'; |
---|
| 2602 | |
---|
| 2603 | if (!is_null($id) and $id !== '') |
---|
| 2604 | { |
---|
| 2605 | $code .= $code.'update_single_info($id, $data);'; |
---|
| 2606 | $result = array( |
---|
| 2607 | 'msg' => lang('Updated Successfully!'), |
---|
| 2608 | 'status' => 'ok' |
---|
| 2609 | ); |
---|
| 2610 | } |
---|
| 2611 | else |
---|
| 2612 | { |
---|
| 2613 | $code .= 'add_single_entry($data,'.$owner.');'; |
---|
| 2614 | $result = array( |
---|
| 2615 | 'msg' => lang('Entry Added Successfully!'), |
---|
| 2616 | 'status' => 'ok' |
---|
| 2617 | ); |
---|
| 2618 | } |
---|
[1599] | 2619 | |
---|
[1496] | 2620 | eval($code); |
---|
| 2621 | |
---|
| 2622 | if (!($id)) |
---|
| 2623 | { |
---|
| 2624 | $result = array( |
---|
| 2625 | 'msg' => lang('Some problem occured when trying to insert/update contact information.<br>'. |
---|
| 2626 | 'Report the problem to the Administrator.'), |
---|
| 2627 | 'status' => 'fail' |
---|
| 2628 | ); |
---|
| 2629 | } |
---|
| 2630 | |
---|
| 2631 | echo serialize($result); |
---|
| 2632 | } |
---|
[2] | 2633 | /*! |
---|
[1599] | 2634 | |
---|
[2] | 2635 | @function post_photo |
---|
| 2636 | @abstract Wrapper to post a photo without reload a page. |
---|
| 2637 | @author Raphael Derosso Pereira |
---|
| 2638 | |
---|
| 2639 | */ |
---|
| 2640 | function post_photo($id) |
---|
| 2641 | { |
---|
| 2642 | //print_r($_FILES); |
---|
| 2643 | $GLOBALS['phpgw']->session->appsession('ui_data.photo','contactcenter', array('wait', 'y')); |
---|
[1599] | 2644 | |
---|
[2] | 2645 | if (!is_array($_FILES) and is_array(!$_FILES['cc_pd_photo'])) |
---|
| 2646 | { |
---|
| 2647 | $this->page_info['photos'][$id]['status'] = 'no_upload'; |
---|
| 2648 | $this->page_info['photos'][$id]['msg'] = lang('No Photos uploaded to Server.'); |
---|
[1599] | 2649 | |
---|
[2] | 2650 | $this->save_session(); |
---|
| 2651 | $GLOBALS['phpgw']->session->appsession('ui_data.photo','contactcenter', array('ok', 'y')); |
---|
| 2652 | return; |
---|
| 2653 | } |
---|
| 2654 | |
---|
| 2655 | if (!function_exists('imagecreate')) |
---|
| 2656 | { |
---|
| 2657 | $this->page_info['photos'][$id]['status'] = 'no_GD_lib'; |
---|
| 2658 | $this->page_info['photos'][$id]['msg'] = lang('Cannot manipulate Image. No Image added. Please, if you want to use images, ask the Administrator to install GD library.'); |
---|
[1599] | 2659 | |
---|
[2] | 2660 | $this->save_session(); |
---|
| 2661 | $GLOBALS['phpgw']->session->appsession('ui_data.photo','contactcenter', array('ok', 'y')); |
---|
| 2662 | return; |
---|
| 2663 | } |
---|
| 2664 | |
---|
| 2665 | // TODO: Get Max Size from preferences! |
---|
| 2666 | if ($_FILES['cc_pd_photo']['size'] > 1000000) |
---|
| 2667 | { |
---|
| 2668 | $this->page_info['photos'][$id]['status'] = 'too_large'; |
---|
| 2669 | $this->page_info['photos'][$id]['msg'] = lang('Image too large! ContactCenter limits the image size to 1 Mb'); |
---|
| 2670 | |
---|
| 2671 | $this->save_session(); |
---|
| 2672 | $GLOBALS['phpgw']->session->appsession('ui_data.photo','contactcenter', array('ok', 'y')); |
---|
| 2673 | return; |
---|
| 2674 | } |
---|
| 2675 | |
---|
| 2676 | if ($_FILES['cc_pd_photo']['error']) |
---|
| 2677 | { |
---|
| 2678 | $this->page_info['photos'][$id]['status'] = 'error'; |
---|
| 2679 | $this->page_info['photos'][$id]['msg'] = lang('Some Error occured while processed the Image. Contact the Administrator. The error code was: ').$_FILES['cc_pd_photo']['error']; |
---|
| 2680 | |
---|
| 2681 | $this->save_session(); |
---|
| 2682 | $GLOBALS['phpgw']->session->appsession('ui_data.photo','contactcenter', array('ok', 'y')); |
---|
| 2683 | return; |
---|
| 2684 | } |
---|
[1599] | 2685 | |
---|
[2] | 2686 | switch($_FILES['cc_pd_photo']['type']) |
---|
| 2687 | { |
---|
| 2688 | case 'image/jpeg': |
---|
| 2689 | case 'image/pjpeg': |
---|
| 2690 | $src_img = imagecreatefromjpeg($_FILES['cc_pd_photo']['tmp_name']); |
---|
| 2691 | if ($src_img == '') |
---|
| 2692 | { |
---|
| 2693 | $bogus = true; |
---|
| 2694 | } |
---|
| 2695 | break; |
---|
| 2696 | |
---|
| 2697 | case 'image/png': |
---|
| 2698 | case 'image/x-png': |
---|
| 2699 | $src_img = imagecreatefrompng($_FILES['cc_pd_photo']['tmp_name']); |
---|
| 2700 | if ($src_img == '') |
---|
| 2701 | { |
---|
| 2702 | $bogus = true; |
---|
| 2703 | } |
---|
| 2704 | break; |
---|
| 2705 | |
---|
| 2706 | case 'image/gif': |
---|
| 2707 | $src_img = imagecreatefromgif($_FILES['cc_pd_photo']['tmp_name']); |
---|
| 2708 | if ($src_img == '') |
---|
| 2709 | { |
---|
| 2710 | $bogus = true; |
---|
| 2711 | } |
---|
| 2712 | break; |
---|
| 2713 | |
---|
| 2714 | default: |
---|
[1599] | 2715 | |
---|
[2] | 2716 | $this->page_info['photos'][$id]['status'] = 'invalid_image'; |
---|
| 2717 | $this->page_info['photos'][$id]['msg'] = lang('The file must be an JPEG, PNG or GIF Image.'); |
---|
| 2718 | |
---|
| 2719 | $this->save_session(); |
---|
| 2720 | $GLOBALS['phpgw']->session->appsession('ui_data.photo','contactcenter', array('ok', 'y')); |
---|
| 2721 | return; |
---|
| 2722 | } |
---|
| 2723 | |
---|
| 2724 | if ($bogus) |
---|
| 2725 | { |
---|
| 2726 | $this->page_info['photos'][$id]['status'] = 'invalid_file'; |
---|
| 2727 | $this->page_info['photos'][$id]['msg'] = lang('Couldn\'t open Image. It may be corrupted or internal library doesn\'t support this format.'); |
---|
[1599] | 2728 | |
---|
[2] | 2729 | $this->save_session(); |
---|
| 2730 | $GLOBALS['phpgw']->session->appsession('ui_data.photo','contactcenter', array('ok', 'y')); |
---|
| 2731 | return; |
---|
| 2732 | } |
---|
[1599] | 2733 | |
---|
[2] | 2734 | $img_size = getimagesize($_FILES['cc_pd_photo']['tmp_name']); |
---|
| 2735 | $dst_img = imagecreatetruecolor(60, 80); |
---|
[1599] | 2736 | |
---|
[2] | 2737 | if (!imagecopyresized($dst_img, $src_img, 0, 0, 0, 0, 60, 80, $img_size[0], $img_size[1])) |
---|
| 2738 | { |
---|
| 2739 | $this->page_info['photos'][$id]['status'] = 'invalid_file'; |
---|
| 2740 | $this->page_info['photos'][$id]['msg'] = lang('Couldn\'t open Image. It may be corrupted or internal library doesn\'t support this format.'); |
---|
[1599] | 2741 | |
---|
[2] | 2742 | $this->save_session(); |
---|
| 2743 | $GLOBALS['phpgw']->session->appsession('ui_data.photo','contactcenter', array('ok', 'y')); |
---|
| 2744 | return; |
---|
| 2745 | } |
---|
[1599] | 2746 | |
---|
[2] | 2747 | ob_start(); |
---|
| 2748 | imagepng($dst_img); |
---|
| 2749 | $this->page_info['photos'][$id]['content'] = ob_get_contents(); |
---|
| 2750 | ob_end_clean(); |
---|
| 2751 | |
---|
| 2752 | $this->page_info['photos'][$id]['status'] = 'changed'; |
---|
| 2753 | $this->page_info['photos'][$id]['msg'] = lang('Photo Successfully Updated!'); |
---|
| 2754 | |
---|
| 2755 | $this->save_session(); |
---|
[1599] | 2756 | |
---|
[2] | 2757 | $GLOBALS['phpgw']->session->appsession('ui_data.photo','contactcenter', array('ok', 'y')); |
---|
| 2758 | |
---|
| 2759 | imagedestroy($src_img); |
---|
| 2760 | imagedestroy($dst_img); |
---|
| 2761 | echo 'ok'; |
---|
| 2762 | return; |
---|
| 2763 | } |
---|
| 2764 | |
---|
| 2765 | |
---|
| 2766 | /*! |
---|
| 2767 | |
---|
| 2768 | @function get_photo |
---|
| 2769 | @abstract Returns the photo to the browser |
---|
| 2770 | @author Raphael Derosso Pereira |
---|
| 2771 | |
---|
| 2772 | */ |
---|
| 2773 | function get_photo($id) |
---|
| 2774 | { |
---|
| 2775 | $fields = $this->bo->catalog->get_fields(false); |
---|
| 2776 | $fields['photo'] = true; |
---|
[1599] | 2777 | |
---|
[2] | 2778 | $contact = $this->bo->catalog->get_single_entry($id, $fields); |
---|
| 2779 | |
---|
| 2780 | if (!$contact['photo']) |
---|
| 2781 | { |
---|
| 2782 | header('Content-type: image/png'); |
---|
| 2783 | echo file_get_contents(PHPGW_INCLUDE_ROOT.'/contactcenter/templates/default/images/photo_celepar.png'); |
---|
| 2784 | return; |
---|
| 2785 | } |
---|
[1599] | 2786 | |
---|
[2] | 2787 | header('Content-type: image/jpeg'); |
---|
| 2788 | $photo = imagecreatefromstring ($contact['photo']); |
---|
| 2789 | $width = imagesx($photo); |
---|
| 2790 | $height = imagesy($photo); |
---|
[16] | 2791 | $twidth = 70; |
---|
| 2792 | $theight = 90; |
---|
[2] | 2793 | $small_photo = imagecreatetruecolor ($twidth, $theight); |
---|
| 2794 | imagecopyresampled($small_photo, $photo, 0, 0, 0, 0,$twidth, $theight, $width, $height); |
---|
| 2795 | imagejpeg($small_photo,"",100); |
---|
| 2796 | return; |
---|
| 2797 | } |
---|
[1599] | 2798 | |
---|
[2] | 2799 | /*! |
---|
[1599] | 2800 | |
---|
[2] | 2801 | @function get_states |
---|
| 2802 | @abstract Echos a serialized array containing all the states for the given country |
---|
| 2803 | @author Raphael Derosso Pereira |
---|
| 2804 | |
---|
| 2805 | @params $id_country The ID of the Country that contains the requested states |
---|
| 2806 | |
---|
| 2807 | */ |
---|
| 2808 | function get_states($id_country) |
---|
| 2809 | { |
---|
| 2810 | $states = $this->bo->catalog->get_all_states($id_country); |
---|
| 2811 | |
---|
| 2812 | if (!$states) |
---|
| 2813 | { |
---|
| 2814 | $result = array( |
---|
| 2815 | 'msg' => lang('No States found for this Country.'), |
---|
| 2816 | 'status' => 'empty' |
---|
| 2817 | ); |
---|
| 2818 | |
---|
| 2819 | echo serialize($result); |
---|
| 2820 | return; |
---|
| 2821 | } |
---|
[1599] | 2822 | |
---|
[2] | 2823 | $result = array( |
---|
| 2824 | 'msg' => lang('States Successfully retrieved!'), |
---|
| 2825 | 'status' => 'ok' |
---|
| 2826 | ); |
---|
[1599] | 2827 | |
---|
[2] | 2828 | foreach ($states as $state_info) |
---|
| 2829 | { |
---|
| 2830 | $result['data'][$state_info['id_state']] = $state_info['name']; |
---|
| 2831 | |
---|
| 2832 | if ($state_info['symbol']) |
---|
| 2833 | { |
---|
| 2834 | $result['data'][$state_info['id_state']] .= ', '.$state_info['symbol']; |
---|
| 2835 | } |
---|
| 2836 | } |
---|
| 2837 | |
---|
| 2838 | echo serialize($result); |
---|
| 2839 | } |
---|
| 2840 | |
---|
| 2841 | /*! |
---|
| 2842 | |
---|
| 2843 | @function get_cities |
---|
| 2844 | @abstract Echos a serialized array containing all the cities of a given state |
---|
| 2845 | @author Raphael Derosso Pereira |
---|
| 2846 | |
---|
| 2847 | @param $id_country The ID of the Country that has the specified Cities (in case the |
---|
| 2848 | Country doesn't have any States) |
---|
| 2849 | @param $id_state The ID of the State that has the Cities requested |
---|
| 2850 | |
---|
| 2851 | */ |
---|
| 2852 | function get_cities($id_country, $id_state=false) |
---|
| 2853 | { |
---|
| 2854 | $cities = $this->bo->catalog->get_all_cities($id_country, $id_state); |
---|
| 2855 | |
---|
| 2856 | if (!$cities) |
---|
| 2857 | { |
---|
| 2858 | $result = array( |
---|
| 2859 | 'msg' => lang('No Cities found for this State.'), |
---|
| 2860 | 'status' => 'empty' |
---|
| 2861 | ); |
---|
| 2862 | |
---|
| 2863 | echo serialize($result); |
---|
| 2864 | return; |
---|
| 2865 | } |
---|
[1599] | 2866 | |
---|
[2] | 2867 | $result = array( |
---|
| 2868 | 'msg' => lang('Cities Successfully retrieved!'), |
---|
| 2869 | 'status' => 'ok' |
---|
| 2870 | ); |
---|
[1599] | 2871 | |
---|
[2] | 2872 | foreach ($cities as $city_info) |
---|
| 2873 | { |
---|
| 2874 | $result['data'][$city_info['id_city']] = $city_info['name']; |
---|
| 2875 | } |
---|
[1599] | 2876 | |
---|
[2] | 2877 | echo serialize($result); |
---|
| 2878 | } |
---|
| 2879 | |
---|
[3282] | 2880 | //Traduz o campo na busca completa por entradas no catálogo do usuário. |
---|
| 2881 | function aux_full_search ($field,$isldap) { |
---|
| 2882 | $retorno = ''; |
---|
| 2883 | if($isldap) { |
---|
| 2884 | switch($field) { |
---|
| 2885 | case 'mail': |
---|
| 2886 | $retorno = 'contact.connection.mail'; |
---|
| 2887 | break; |
---|
| 2888 | case 'phone': |
---|
| 2889 | $retorno = 'contact.connection.phone'; |
---|
| 2890 | break; |
---|
| 2891 | } |
---|
| 2892 | } |
---|
| 2893 | else { |
---|
| 2894 | switch($field) { |
---|
| 2895 | case 'corporate': |
---|
| 2896 | $retorno = 'contact.corporate_name'; |
---|
| 2897 | break; |
---|
| 2898 | case 'mail': |
---|
| 2899 | case 'phone': |
---|
| 2900 | $retorno = 'contact.contact_connection.connection.connection_value'; |
---|
| 2901 | break; |
---|
| 2902 | } |
---|
| 2903 | } |
---|
| 2904 | return $retorno; |
---|
| 2905 | } |
---|
[2] | 2906 | |
---|
| 2907 | /*! |
---|
[1599] | 2908 | |
---|
[2] | 2909 | @function search |
---|
| 2910 | @abstract Echos a serialized array containing the IDs |
---|
| 2911 | of the entries that matches the search argument |
---|
| 2912 | @author Raphael Derosso Pereira |
---|
[3334] | 2913 | @author Mário César Kolling (external catalogs) |
---|
[2] | 2914 | |
---|
| 2915 | @param string $str_data A serialized array with two informations: |
---|
| 2916 | $data = array( |
---|
| 2917 | 'search_for' => (string), |
---|
| 2918 | 'recursive' => (boolean), |
---|
| 2919 | ); |
---|
| 2920 | |
---|
| 2921 | */ |
---|
[285] | 2922 | // SERPRO |
---|
[2] | 2923 | function search($str_data) |
---|
| 2924 | { |
---|
| 2925 | $data = unserialize($str_data); |
---|
[284] | 2926 | // It's an external catalog? |
---|
| 2927 | $external = $this->bo->is_external($this->page_info['actual_catalog']); |
---|
[3282] | 2928 | $full_search = isset($data['full_search'])?$data['full_search']:false; |
---|
| 2929 | |
---|
| 2930 | if (!is_array($data) || (!$data['search_for'] && !$full_search) || !is_array($data['fields'])) |
---|
[1599] | 2931 | { |
---|
| 2932 | echo serialize(array( |
---|
| 2933 | 'msg' => lang('Invalid parameters'), |
---|
| 2934 | 'status' => 'abort' |
---|
| 2935 | )); |
---|
| 2936 | |
---|
| 2937 | return array('error' => lang('Invalid parameters')); |
---|
| 2938 | } |
---|
| 2939 | |
---|
| 2940 | |
---|
[284] | 2941 | /* |
---|
| 2942 | * TODO: look into the database to discover the database's encoding and convert the search_for field accordingly |
---|
| 2943 | */ |
---|
| 2944 | // Support search parameters with accentuation |
---|
| 2945 | if ($this->page_info['actual_catalog']['class'] != 'bo_people_catalog' && |
---|
[1599] | 2946 | /**rev 104**/ |
---|
| 2947 | //$this->page_info['actual_catalog']['class'] != 'bo_group_manager') |
---|
[503] | 2948 | $this->page_info['actual_catalog']['class'] != 'bo_group_manager' && |
---|
[752] | 2949 | $this->page_info['actual_catalog']['class'] != 'bo_shared_people_manager' && |
---|
| 2950 | $this->page_info['actual_catalog']['class'] != 'bo_shared_group_manager') |
---|
[1599] | 2951 | /****/ |
---|
[284] | 2952 | { |
---|
| 2953 | |
---|
| 2954 | $data['search_for'] = utf8_encode($data['search_for']); |
---|
| 2955 | } |
---|
| 2956 | |
---|
[1599] | 2957 | $rules = array(); |
---|
| 2958 | |
---|
| 2959 | if ($data['search_for'] === '*') |
---|
| 2960 | { |
---|
| 2961 | $rules = array( |
---|
| 2962 | 0 => array( |
---|
| 2963 | 'field' => $data['fields']['search'], |
---|
| 2964 | 'type' => 'LIKE', |
---|
| 2965 | 'value' => '%' |
---|
| 2966 | ) |
---|
| 2967 | ); |
---|
| 2968 | } |
---|
| 2969 | else |
---|
| 2970 | { |
---|
| 2971 | $names = explode(' ', $data['search_for']); |
---|
| 2972 | |
---|
| 2973 | if (!is_array($names)) |
---|
| 2974 | { |
---|
[3282] | 2975 | if(!$full_search) { |
---|
| 2976 | echo serialize(array( |
---|
| 2977 | 'msg' => lang('Invalid Search Parameter'), |
---|
| 2978 | 'status' => 'abort' |
---|
| 2979 | )); |
---|
| 2980 | exit; |
---|
| 2981 | } |
---|
| 2982 | else |
---|
| 2983 | $names = array(); |
---|
[1599] | 2984 | |
---|
| 2985 | } |
---|
| 2986 | |
---|
[284] | 2987 | if (!$external && $this->page_info['actual_catalog']['class'] != 'bo_people_catalog' && |
---|
[1599] | 2988 | /**rev 104**/ |
---|
| 2989 | //$this->page_info['actual_catalog']['class'] != 'bo_group_manager') |
---|
[503] | 2990 | $this->page_info['actual_catalog']['class'] != 'bo_group_manager' && |
---|
[1599] | 2991 | $this->page_info['actual_catalog']['class'] != 'bo_shared_people_manager' && |
---|
[752] | 2992 | $this->page_info['actual_catalog']['class'] != 'bo_shared_group_manager' ) |
---|
[1599] | 2993 | /*****/ |
---|
[284] | 2994 | { |
---|
| 2995 | /* |
---|
| 2996 | * Restrict the returned contacts search to objectClass = phpgwAccount, |
---|
[880] | 2997 | * must have attibute phpgwAccountStatus, phpgwAccountVisible != -1 |
---|
[284] | 2998 | */ |
---|
[3282] | 2999 | |
---|
[284] | 3000 | $rules = array( |
---|
| 3001 | 0 => array( |
---|
| 3002 | 'field' => 'contact.object_class', |
---|
| 3003 | 'type' => '=', |
---|
| 3004 | 'value' => 'phpgwAccount' |
---|
| 3005 | ), |
---|
| 3006 | 1 => array( |
---|
| 3007 | 'field' => 'contact.account_status', |
---|
| 3008 | 'type' => 'iLIKE', |
---|
| 3009 | 'value' => '%' |
---|
| 3010 | ), |
---|
[1599] | 3011 | /**rev 104**/ |
---|
| 3012 | /// |
---|
| 3013 | //1 => array( |
---|
[284] | 3014 | 2 => array( |
---|
[1599] | 3015 | /*****/ |
---|
[284] | 3016 | 'field' => 'contact.account_visible', |
---|
| 3017 | 'type' => '!=', |
---|
| 3018 | 'value' => '-1' |
---|
[1599] | 3019 | /**rev 104**/ |
---|
| 3020 | /* ), |
---|
| 3021 | 2 => array( |
---|
| 3022 | 'field' => 'contact.object_class', |
---|
| 3023 | 'type' => '=', |
---|
| 3024 | 'value' => 'inetOrgPerson' |
---|
| 3025 | /****/ |
---|
[284] | 3026 | ), |
---|
| 3027 | ); |
---|
[3282] | 3028 | |
---|
[4205] | 3029 | if($full_search) { |
---|
| 3030 | foreach($full_search as $field => $value) { |
---|
| 3031 | if(trim($value)!='') |
---|
| 3032 | array_push($rules,array( |
---|
[3282] | 3033 | 'field' => $this->aux_full_search($field,true), |
---|
| 3034 | 'type' => 'LIKE', |
---|
| 3035 | 'value' => '*'.$value.'*' |
---|
| 3036 | )); |
---|
[4205] | 3037 | } |
---|
[3282] | 3038 | } |
---|
| 3039 | |
---|
[284] | 3040 | } |
---|
[4205] | 3041 | else if(!$external && $full_search) { |
---|
[3282] | 3042 | |
---|
| 3043 | foreach($full_search as $field => $value) { |
---|
| 3044 | if(trim($value)!='') |
---|
| 3045 | array_push($rules,array( |
---|
| 3046 | 'field' => $this->aux_full_search($field,false), |
---|
| 3047 | 'type' => 'iLIKE', |
---|
| 3048 | 'value' => '%'.$value.'%' |
---|
| 3049 | )); |
---|
| 3050 | } |
---|
| 3051 | |
---|
| 3052 | } |
---|
[284] | 3053 | |
---|
[1599] | 3054 | foreach ($names as $name) |
---|
| 3055 | { |
---|
| 3056 | if ($name != '') |
---|
| 3057 | { |
---|
| 3058 | array_push($rules, array( |
---|
| 3059 | 'field' => $data['fields']['search'], |
---|
| 3060 | 'type' => 'iLIKE', |
---|
| 3061 | 'value' => '%'.$name.'%' |
---|
| 3062 | )); |
---|
| 3063 | } |
---|
| 3064 | } |
---|
| 3065 | } |
---|
| 3066 | |
---|
[284] | 3067 | if ($external || $this->page_info['actual_catalog']['class'] == 'bo_people_catalog' || |
---|
[1599] | 3068 | /**rev 104**/ |
---|
| 3069 | //$this->page_info['actual_catalog']['class'] == 'bo_group_manager') |
---|
[503] | 3070 | $this->page_info['actual_catalog']['class'] == 'bo_group_manager' || |
---|
[752] | 3071 | $this->page_info['actual_catalog']['class'] == 'bo_shared_people_manager' || |
---|
[1599] | 3072 | $this->page_info['actual_catalog']['class'] == 'bo_shared_group_manager') |
---|
| 3073 | |
---|
| 3074 | |
---|
| 3075 | /***/ |
---|
[2] | 3076 | { |
---|
[284] | 3077 | // Get only this attributes: dn, cn for external catalogs, |
---|
| 3078 | // used to restrict the attributes used in filters |
---|
[3211] | 3079 | $ids = $this->bo->find(array($data['fields']['id'], $data['fields']['search']), $rules, array('order' => $data['fields']['search'], 'sort' => 'ASC'), $data['search_for'] != null); |
---|
[2] | 3080 | } |
---|
[284] | 3081 | else |
---|
| 3082 | { |
---|
| 3083 | // Get only this attributes: dn, cn, phpgwAccountType, objectClass, phpgwAccountStatus, phpghAccountVisible |
---|
| 3084 | // for non-external catalogs, used to restrict the attributes used in filters |
---|
| 3085 | $ids = $this->bo->find(array( |
---|
| 3086 | $data['fields']['id'], |
---|
| 3087 | $data['fields']['search'], |
---|
| 3088 | 'contact.object_class', |
---|
[304] | 3089 | //'contact.account_status', |
---|
[3282] | 3090 | 'contact.account_visible', |
---|
| 3091 | 'contact.connection.mail', |
---|
| 3092 | 'contact.connection.phone' |
---|
[3211] | 3093 | ), $rules, array('order' => $data['fields']['search'], 'sort' => 'ASC'), $data['search_for_area'], $data['search_for'] != null ); |
---|
[284] | 3094 | } |
---|
[2] | 3095 | |
---|
[1599] | 3096 | if (!is_array($ids) || !count($ids)) |
---|
| 3097 | { |
---|
[284] | 3098 | $this->last_search_ids = null; |
---|
| 3099 | $this->save_session(); |
---|
| 3100 | return null; |
---|
[1599] | 3101 | } |
---|
[2] | 3102 | |
---|
[1599] | 3103 | $id_field = substr($data['fields']['id'], strrpos($data['fields']['id'], '.')+1); |
---|
[2] | 3104 | |
---|
[1599] | 3105 | $ids_f = array(); |
---|
| 3106 | |
---|
| 3107 | foreach ($ids as $e_info) |
---|
| 3108 | { |
---|
| 3109 | /**rev 104**/ |
---|
| 3110 | //$ids_f[] = $e_info[$id_field]; |
---|
[752] | 3111 | if($this->page_info['actual_catalog']['class'] != 'bo_shared_people_manager' && $this->page_info['actual_catalog']['class'] != 'bo_shared_group_manager') |
---|
[1599] | 3112 | { |
---|
| 3113 | $ids_f[] = $e_info[$id_field]; |
---|
| 3114 | } else{ |
---|
[3371] | 3115 | $ids_f[] = array(0=>$e_info[$id_field],1=>$e_info['perms'],2=>$e_info['owner']); |
---|
[1599] | 3116 | } |
---|
| 3117 | /****/ |
---|
| 3118 | } |
---|
[284] | 3119 | |
---|
| 3120 | return $ids_f; |
---|
[2] | 3121 | } |
---|
[1599] | 3122 | |
---|
[285] | 3123 | // CELEPAR |
---|
| 3124 | /* |
---|
| 3125 | function search($str_data) |
---|
| 3126 | { |
---|
| 3127 | $data = unserialize($str_data); |
---|
[2] | 3128 | |
---|
[285] | 3129 | if (!is_array($data) || !$data['search_for'] || !is_array($data['fields'])) |
---|
| 3130 | { |
---|
| 3131 | echo serialize(array( |
---|
| 3132 | 'msg' => lang('Invalid parameters'), |
---|
| 3133 | 'status' => 'abort' |
---|
| 3134 | )); |
---|
| 3135 | |
---|
| 3136 | return; |
---|
| 3137 | } |
---|
| 3138 | |
---|
| 3139 | $rules = array(); |
---|
| 3140 | |
---|
| 3141 | if ($data['search_for'] === '*') |
---|
| 3142 | { |
---|
| 3143 | $rules = array( |
---|
| 3144 | 0 => array( |
---|
| 3145 | 'field' => $data['fields']['search'], |
---|
| 3146 | 'type' => 'LIKE', |
---|
| 3147 | 'value' => '%' |
---|
| 3148 | ) |
---|
| 3149 | ); |
---|
| 3150 | } |
---|
| 3151 | else |
---|
| 3152 | { |
---|
| 3153 | $names = explode(' ', $data['search_for']); |
---|
| 3154 | |
---|
| 3155 | if (!is_array($names)) |
---|
| 3156 | { |
---|
| 3157 | echo serialize(array( |
---|
| 3158 | 'msg' => lang('Invalid Search Parameter'), |
---|
| 3159 | 'status' => 'abort' |
---|
| 3160 | )); |
---|
[1599] | 3161 | |
---|
[285] | 3162 | return; |
---|
| 3163 | } |
---|
[1599] | 3164 | |
---|
[285] | 3165 | foreach ($names as $name) |
---|
| 3166 | { |
---|
| 3167 | if ($name != '') |
---|
| 3168 | { |
---|
| 3169 | array_push($rules, array( |
---|
| 3170 | 'field' => $data['fields']['search'], |
---|
| 3171 | 'type' => 'iLIKE', |
---|
| 3172 | 'value' => '%'.$name.'%' |
---|
| 3173 | )); |
---|
| 3174 | } |
---|
| 3175 | } |
---|
| 3176 | } |
---|
| 3177 | |
---|
[1599] | 3178 | |
---|
| 3179 | |
---|
[285] | 3180 | //$catalog = $this->bo->get_branch_by_level($this->bo->catalog_level[0]); |
---|
[1599] | 3181 | |
---|
[285] | 3182 | //if ($catalog['class'] === 'bo_people_catalog') |
---|
| 3183 | //{ |
---|
| 3184 | // array_push($rules, array( |
---|
| 3185 | // 'field' => 'contact.id_owner', |
---|
| 3186 | // 'type' => '=', |
---|
| 3187 | // 'value' => $GLOBALS['phpgw_info']['user']['account_id'] |
---|
| 3188 | // )); |
---|
| 3189 | //} |
---|
[1599] | 3190 | |
---|
| 3191 | |
---|
[285] | 3192 | $ids = $this->bo->find(array($data['fields']['id'], $data['fields']['search']), $rules, array('order' => $data['fields']['search'], 'sort' => 'ASC')); |
---|
| 3193 | |
---|
| 3194 | if (!is_array($ids) || !count($ids)) |
---|
| 3195 | { |
---|
| 3196 | echo serialize(array( |
---|
| 3197 | 'msg' => lang('No Entries Found!'), |
---|
| 3198 | 'status' => 'empty' |
---|
| 3199 | )); |
---|
| 3200 | |
---|
| 3201 | return; |
---|
| 3202 | } |
---|
| 3203 | $id_field = substr($data['fields']['id'], strrpos($data['fields']['id'], '.')+1); |
---|
| 3204 | |
---|
| 3205 | $ids_f = array(); |
---|
| 3206 | foreach ($ids as $e_info) |
---|
| 3207 | { |
---|
| 3208 | $ids_f[] = $e_info[$id_field]; |
---|
| 3209 | } |
---|
| 3210 | |
---|
| 3211 | echo serialize(array( |
---|
| 3212 | 'data' => $ids_f, |
---|
| 3213 | 'msg' => lang('Found %1 Entries', count($ids)), |
---|
| 3214 | 'status' => 'ok' |
---|
| 3215 | )); |
---|
[1599] | 3216 | |
---|
[285] | 3217 | return; |
---|
| 3218 | }*/ |
---|
[2] | 3219 | /*! |
---|
| 3220 | |
---|
| 3221 | @function get_multiple_entries |
---|
| 3222 | @abstract Returns an array containing the specifiend data in the default |
---|
| 3223 | CC UI format |
---|
| 3224 | @author Raphael Derosso Pereira |
---|
| 3225 | |
---|
[1599] | 3226 | @param array str_data A serialized array containing the ID's of the entries |
---|
[2] | 3227 | to be taken, the fields to be taken and the rules to be used on the |
---|
| 3228 | retrieval: |
---|
| 3229 | $data = array( |
---|
| 3230 | 'ids' => array(...), |
---|
| 3231 | 'fields' => array(...), |
---|
| 3232 | 'rules' => array(...) |
---|
| 3233 | ); |
---|
| 3234 | |
---|
| 3235 | */ |
---|
| 3236 | function get_multiple_entries($str_data) |
---|
| 3237 | { |
---|
| 3238 | $data = unserialize($str_data); |
---|
[1599] | 3239 | |
---|
[2] | 3240 | if (!is_array($data) or !count($data) or !count($data['fields']) or !count($data['ids'])) |
---|
| 3241 | { |
---|
| 3242 | return array( |
---|
| 3243 | 'msg' => lang('Invalid Parameters'), |
---|
| 3244 | 'status' => 'abort' |
---|
| 3245 | ); |
---|
| 3246 | } |
---|
| 3247 | |
---|
| 3248 | $entries = $this->bo->catalog->get_multiple_entries($data['ids'], $data['fields']); |
---|
[1599] | 3249 | |
---|
[2] | 3250 | if (!is_array($entries) or !count($entries)) |
---|
| 3251 | { |
---|
| 3252 | return array( |
---|
| 3253 | 'msg' => lang('No Entries Found!'), |
---|
| 3254 | 'status' => 'empty' |
---|
| 3255 | ); |
---|
| 3256 | } |
---|
| 3257 | |
---|
| 3258 | return array( |
---|
| 3259 | 'msg' => lang('Found %1 Entries!', count($entries)), |
---|
| 3260 | 'status' => 'ok', |
---|
| 3261 | 'data' => $entries |
---|
| 3262 | ); |
---|
| 3263 | } |
---|
| 3264 | |
---|
| 3265 | /* |
---|
| 3266 | |
---|
| 3267 | @function get_all_entries |
---|
[1599] | 3268 | @abstract Returns the specified fields for all catalog's entries |
---|
[2] | 3269 | in the default CC UI format |
---|
| 3270 | @author Raphael Derosso Pereira |
---|
| 3271 | |
---|
[1599] | 3272 | @params array str_data A serialized array containing the fields to |
---|
[2] | 3273 | be grabbed, the maximum number of entries to be returned and a |
---|
| 3274 | boolean specifying if the calls refers to a new grab or to an |
---|
| 3275 | unfinished one. |
---|
| 3276 | |
---|
| 3277 | */ |
---|
| 3278 | function get_all_entries($str_data) |
---|
| 3279 | { |
---|
| 3280 | $data = unserialize($str_data); |
---|
[1599] | 3281 | |
---|
| 3282 | if (!is_array($data) or |
---|
| 3283 | !count($data) or |
---|
| 3284 | !count($data['fields']) or |
---|
[2] | 3285 | !$data['maxlength'] or |
---|
| 3286 | (!$data['new'] and !$data['offset'])) |
---|
| 3287 | { |
---|
| 3288 | return array( |
---|
| 3289 | 'msg' => lang('Invalid Parameters'), |
---|
| 3290 | 'status' => 'abort' |
---|
| 3291 | ); |
---|
| 3292 | } |
---|
| 3293 | |
---|
| 3294 | if ($data['new']) |
---|
| 3295 | { |
---|
| 3296 | $this->all_entries = $this->bo->catalog->get_all_entries_ids(); |
---|
| 3297 | |
---|
| 3298 | $this->save_session(); |
---|
| 3299 | |
---|
| 3300 | if (!is_array($this->all_entries) or !count($this->all_entries)) |
---|
| 3301 | { |
---|
| 3302 | return array( |
---|
| 3303 | 'msg' => lang('No Entries Found!'), |
---|
| 3304 | 'status' => 'empty' |
---|
| 3305 | ); |
---|
| 3306 | } |
---|
| 3307 | |
---|
| 3308 | $data['offset'] = 0; |
---|
| 3309 | } |
---|
[1599] | 3310 | |
---|
[2] | 3311 | if ($data['maxlength'] != -1) |
---|
| 3312 | { |
---|
| 3313 | $result = $this->bo->catalog->get_multiple_entries(array_slice($this->all_entries, $data['offset'], $data['maxlength']), $data['fields']); |
---|
| 3314 | } |
---|
| 3315 | else |
---|
| 3316 | { |
---|
| 3317 | $result = $this->bo->catalog->get_multiple_entries($this->all_entries, $data['fields']); |
---|
| 3318 | } |
---|
| 3319 | |
---|
| 3320 | $jsCode = array(); |
---|
| 3321 | $count = 0; |
---|
| 3322 | foreach ($result as $each) |
---|
| 3323 | { |
---|
| 3324 | if (!is_array($each)) |
---|
| 3325 | { |
---|
| 3326 | continue; |
---|
| 3327 | } |
---|
| 3328 | |
---|
[1599] | 3329 | if($this-> typeContact == 'groups') { |
---|
| 3330 | |
---|
[2] | 3331 | foreach ($each as $field => $value) { |
---|
[1599] | 3332 | |
---|
[2] | 3333 | if ($field === 'title') { |
---|
| 3334 | $optionName = '\\"'.$value.'\\"'; |
---|
[1599] | 3335 | |
---|
[2] | 3336 | } |
---|
| 3337 | else if ($field === 'short_name') { |
---|
[1599] | 3338 | |
---|
[2] | 3339 | $jsCode[] = '_this.entries.options[_this.entries.options.length] = new Option("'.$optionName.' ('.$value.')", "'.$count.'");'; |
---|
[1599] | 3340 | $count++; |
---|
| 3341 | } |
---|
[2] | 3342 | } |
---|
| 3343 | } |
---|
[1599] | 3344 | |
---|
| 3345 | else { |
---|
[2] | 3346 | foreach ($each as $field => $value) { |
---|
| 3347 | if ($field === 'names_ordered') { |
---|
| 3348 | if(is_array($value)) |
---|
| 3349 | $value = $value[0]; |
---|
| 3350 | $name = '\\"'.$value.'\\"'; |
---|
| 3351 | } |
---|
| 3352 | else if ($field === 'connections') { |
---|
[1599] | 3353 | |
---|
[2] | 3354 | foreach ($value as $connection) { |
---|
[3795] | 3355 | if ($connection['id_type'] == $this->preferences['personCardEmail']) { |
---|
[2] | 3356 | $jsCode[] = '_this.entries.options[_this.entries.options.length] = new Option("'.$name.' <'.$connection['connection_value'].'>", "'.$count.'");'; |
---|
| 3357 | $count++; |
---|
| 3358 | } |
---|
| 3359 | } |
---|
| 3360 | } |
---|
| 3361 | } |
---|
| 3362 | } |
---|
| 3363 | } |
---|
| 3364 | |
---|
| 3365 | $jsCodeFinal = implode("\n", $jsCode); |
---|
[1599] | 3366 | |
---|
[2] | 3367 | $nEntries = count($result); |
---|
[1599] | 3368 | |
---|
[2] | 3369 | if (!$nEntries) |
---|
| 3370 | { |
---|
| 3371 | return array( |
---|
| 3372 | 'msg' => lang('Error while getting user information...'), |
---|
| 3373 | 'status' => 'abort' |
---|
| 3374 | ); |
---|
| 3375 | } |
---|
| 3376 | |
---|
| 3377 | return array( |
---|
| 3378 | 'msg' => lang('Found %1 Entries!', $nEntries), |
---|
| 3379 | 'status' => 'ok', |
---|
| 3380 | 'typeContact' => $this -> typeContact, |
---|
| 3381 | 'final' => $nEntries + $data['offset'] < count($this->all_entries) ? false : true, |
---|
| 3382 | 'offset' => $data['offset'] + $nEntries, |
---|
| 3383 | 'data' => $jsCodeFinal |
---|
| 3384 | ); |
---|
| 3385 | } |
---|
[1599] | 3386 | |
---|
[2] | 3387 | /*********************************************************************\ |
---|
| 3388 | * Auxiliar Methods * |
---|
| 3389 | \*********************************************************************/ |
---|
| 3390 | |
---|
| 3391 | /*! |
---|
[1599] | 3392 | |
---|
[2] | 3393 | @function save_session |
---|
| 3394 | @abstract Saves the data on the session |
---|
| 3395 | @author Raphael Derosso Pereira |
---|
[1599] | 3396 | |
---|
[2] | 3397 | */ |
---|
| 3398 | function save_session() |
---|
| 3399 | { |
---|
| 3400 | $GLOBALS['phpgw']->session->appsession('ui_data.page_info','contactcenter',$this->page_info); |
---|
| 3401 | $GLOBALS['phpgw']->session->appsession('ui_data.all_entries','contactcenter',$this->all_entries); |
---|
| 3402 | } |
---|
| 3403 | |
---|
| 3404 | /*! |
---|
[1599] | 3405 | |
---|
[2] | 3406 | @function convert_tree |
---|
| 3407 | @abstract Converts the tree array in the BO format to a JS tree array compatible |
---|
| 3408 | with the one available in eGW |
---|
| 3409 | @author Raphael Derosso Pereira |
---|
[1599] | 3410 | |
---|
[2] | 3411 | @param (array) $tree The tree in the BO format |
---|
| 3412 | @param (string) $name The tree name |
---|
| 3413 | @param (string) $iconDir The dir where the icons are |
---|
| 3414 | @param (string) $parent The parent |
---|
| 3415 | */ |
---|
| 3416 | |
---|
| 3417 | function convert_tree($tree, &$iconDir, $parent='0') |
---|
| 3418 | { |
---|
| 3419 | // echo "Entrou<br>\tPai: $parent <br>"; |
---|
| 3420 | $rtree = array(); |
---|
| 3421 | |
---|
| 3422 | if ($parent === '0') |
---|
| 3423 | { |
---|
| 3424 | // echo 'Root!<br>'; |
---|
| 3425 | $rtree['0'] = array( |
---|
| 3426 | 'type' => 'catalog_group', |
---|
| 3427 | 'id' => '0', |
---|
| 3428 | 'pid' => 'none', |
---|
| 3429 | 'caption' => lang('Catalogues'), |
---|
| 3430 | 'class' => 'bo_catalog_group_catalog', |
---|
| 3431 | 'class_args' => array('_ROOT_', '$this', '$this->get_branch_by_level($this->catalog_level[0])') |
---|
| 3432 | ); |
---|
| 3433 | } |
---|
| 3434 | |
---|
| 3435 | foreach($tree as $id => $value) |
---|
| 3436 | { |
---|
| 3437 | // echo 'ID: '.$id.'<br>'; |
---|
| 3438 | $rtree[$parent.'.'.$id] = array( |
---|
| 3439 | 'type' => $value['type'], |
---|
| 3440 | 'id' => $parent.'.'.$id, |
---|
| 3441 | 'pid' => $parent, |
---|
| 3442 | 'caption' => $value['name'] |
---|
| 3443 | ); |
---|
[1599] | 3444 | |
---|
[2] | 3445 | switch($value['type']) |
---|
| 3446 | { |
---|
| 3447 | case 'catalog_group': |
---|
| 3448 | case 'mixed_catalog_group': |
---|
| 3449 | $rtree = $rtree + $this->convert_tree($value['sub_branch'],$iconDir,$parent.'.'.$id); |
---|
| 3450 | break; |
---|
| 3451 | } |
---|
| 3452 | } |
---|
| 3453 | |
---|
| 3454 | if (count($rtree)) |
---|
| 3455 | { |
---|
| 3456 | return $rtree; |
---|
| 3457 | } |
---|
| 3458 | } |
---|
| 3459 | |
---|
| 3460 | function get_catalog_add_contact($id){ |
---|
| 3461 | |
---|
| 3462 | $array_participants = array(); |
---|
[13] | 3463 | if(!$this->bo->catalog->src_info) { |
---|
| 3464 | $ldap = CreateObject('contactcenter.bo_ldap_manager'); |
---|
| 3465 | $this->bo->catalog->src_info = $ldap->srcs[1]; |
---|
[2] | 3466 | } |
---|
[1599] | 3467 | |
---|
| 3468 | $ds = $GLOBALS['phpgw']->common->ldapConnect($this->bo->catalog->src_info['host'], $this->bo->catalog->src_info['acc'], $this->bo->catalog->src_info['pw'], true); |
---|
[13] | 3469 | $dn=$this->bo->catalog->src_info['dn']; |
---|
| 3470 | $justThese = array("givenname","givenname","sn","telephonenumber","mail"); |
---|
[1599] | 3471 | $sr = ldap_read($ds,$id, "objectClass=*",$justThese); |
---|
| 3472 | $info = ldap_get_entries($ds, $sr); |
---|
[13] | 3473 | for($z = 0; $z < 5; $z++) { |
---|
[1599] | 3474 | $participant = $info[0][$justThese[$z]]; |
---|
[13] | 3475 | array_push($array_participants, $participant); |
---|
| 3476 | } |
---|
| 3477 | |
---|
| 3478 | ldap_close($ds); |
---|
[2] | 3479 | echo serialize($array_participants); |
---|
[1599] | 3480 | } |
---|
| 3481 | |
---|
| 3482 | function get_catalog_participants_group($id) |
---|
[880] | 3483 | { |
---|
| 3484 | if(!$this->bo->catalog->src_info) { |
---|
| 3485 | $ldap = CreateObject('contactcenter.bo_ldap_manager'); |
---|
| 3486 | $this->bo->catalog->src_info = $ldap->srcs[1]; |
---|
[1599] | 3487 | } |
---|
| 3488 | $ds = $GLOBALS['phpgw']->common->ldapConnect($this->bo->catalog->src_info['host'], $this->bo->catalog->src_info['acc'], $this->bo->catalog->src_info['pw'], true); |
---|
| 3489 | $justThese = array("description","memberuid"); |
---|
| 3490 | $sr = ldap_read($ds,$id, "objectClass=*",$justThese); |
---|
[880] | 3491 | $info = ldap_get_entries($ds, $sr); |
---|
| 3492 | $member_uids = $info[0]['memberuid']; |
---|
| 3493 | $contact['names_ordered'] = $info[0]['description']; |
---|
[1599] | 3494 | $filter = ""; |
---|
[880] | 3495 | for($z = 0; $z < count($member_uids); $z++) { |
---|
| 3496 | if($member_uids[$z]) |
---|
[1599] | 3497 | $filter.="(uid=".$member_uids[$z].")"; |
---|
[880] | 3498 | } |
---|
| 3499 | $array_participants = array(); |
---|
| 3500 | if($filter) { |
---|
[962] | 3501 | $filter = "(|".$filter.")"; |
---|
[904] | 3502 | $valarray = explode(',',$id); |
---|
| 3503 | array_shift($valarray); |
---|
| 3504 | $dn = implode(',',$valarray); |
---|
[880] | 3505 | $justThese = array("cn","mail"); |
---|
[1599] | 3506 | $sr = ldap_search($ds,$dn, $filter,$justThese); |
---|
| 3507 | $info = ldap_get_entries($ds, $sr); |
---|
[880] | 3508 | for($z = 0; $z < $info['count']; $z++) { |
---|
| 3509 | $participant = '<font color=\'DARKBLUE\'> "'.$info[$z]['cn'][0].'" <'.$info[$z]['mail'][0].'></font><br>'; |
---|
[1599] | 3510 | $array_emails[$info[$z]['mail'][0]] = null; |
---|
| 3511 | array_push($array_participants, $participant); |
---|
[880] | 3512 | } |
---|
| 3513 | ldap_close($ds); |
---|
[1599] | 3514 | } |
---|
[880] | 3515 | sort($array_participants); |
---|
[1599] | 3516 | $innerHTML = ''; |
---|
[880] | 3517 | foreach($array_participants as $index => $participant){ |
---|
| 3518 | $innerHTML .= $participant; |
---|
| 3519 | } |
---|
[1599] | 3520 | $return = array('size' => count($array_participants), 'names_ordered'=> $contact['names_ordered'], 'inner_html' => $innerHTML); |
---|
[880] | 3521 | echo serialize($return); |
---|
| 3522 | } |
---|
| 3523 | |
---|
[1599] | 3524 | function get_catalog_participants_list($id) |
---|
[2] | 3525 | { |
---|
[1599] | 3526 | |
---|
| 3527 | $fields = $this->bo->catalog->get_fields(false); |
---|
[2] | 3528 | $fields['names_ordered'] = true; |
---|
[1599] | 3529 | $fields['mail_forwarding_address'] = true; |
---|
| 3530 | $contact = $this->bo->catalog->get_single_entry($id,$fields); |
---|
| 3531 | |
---|
[2] | 3532 | $array_participants = array(); |
---|
| 3533 | $array_emails = array(); |
---|
[880] | 3534 | |
---|
[2] | 3535 | $filter = null; |
---|
[1599] | 3536 | for($z = 0; $z < $contact['mail_forwarding_address']['count']; $z++) { |
---|
[2] | 3537 | if(strstr($contact['mail_forwarding_address'][$z],'@')) { |
---|
| 3538 | $filter.="(mail=".$contact['mail_forwarding_address'][$z].")"; |
---|
| 3539 | $array_emails[$contact['mail_forwarding_address'][$z]] = "<font color=black>".$contact['mail_forwarding_address'][$z]."</font>"; |
---|
[1599] | 3540 | } |
---|
| 3541 | else |
---|
[2] | 3542 | $array_participants[$z] = "<font color=red>".$contact['mail_forwarding_address'][$z]."</font>"; |
---|
[1599] | 3543 | } |
---|
| 3544 | |
---|
[2] | 3545 | if($filter) { |
---|
[1599] | 3546 | $filter = "(|".$filter.")"; |
---|
[2] | 3547 | if(!$this->bo->catalog->src_info) { |
---|
| 3548 | $ldap = CreateObject('contactcenter.bo_ldap_manager'); |
---|
| 3549 | $this->bo->catalog->src_info = $ldap->srcs[1]; |
---|
| 3550 | } |
---|
[880] | 3551 | $ds = $GLOBALS['phpgw']->common->ldapConnect($this->bo->catalog->src_info['host'], $this->bo->catalog->src_info['acc'], $this->bo->catalog->src_info['pw'], true); |
---|
[2] | 3552 | $dn=$this->bo->catalog->src_info['dn']; |
---|
| 3553 | $justThese = array("cn","mail"); |
---|
[1599] | 3554 | $sr = ldap_search($ds,$dn, $filter,$justThese); |
---|
| 3555 | $info = ldap_get_entries($ds, $sr); |
---|
[2] | 3556 | for($z = 0; $z < $info['count']; $z++) { |
---|
[24] | 3557 | $participant = '<font color=\'DARKBLUE\'> "'.$info[$z]['cn'][0].'" <'.$info[$z]['mail'][0].'></font><br>'; |
---|
[1599] | 3558 | $array_emails[$info[$z]['mail'][0]] = null; |
---|
| 3559 | array_push($array_participants, $participant); |
---|
[2] | 3560 | } |
---|
[1599] | 3561 | |
---|
[2] | 3562 | foreach($array_emails as $index => $email) |
---|
[1599] | 3563 | if($email) |
---|
| 3564 | array_push($array_participants, " ".$email."<br>"); |
---|
| 3565 | |
---|
[2] | 3566 | ldap_close($ds); |
---|
| 3567 | } |
---|
| 3568 | sort($array_participants); |
---|
[1599] | 3569 | $innerHTML = ''; |
---|
[24] | 3570 | foreach($array_participants as $index => $participant){ |
---|
| 3571 | $innerHTML .= $participant; |
---|
| 3572 | } |
---|
[1599] | 3573 | $return = array('size' => count($array_participants), 'names_ordered'=> $contact['names_ordered'], 'inner_html' => $innerHTML); |
---|
[24] | 3574 | echo serialize($return); |
---|
[1599] | 3575 | } |
---|
| 3576 | |
---|
[2] | 3577 | function export_contacts($typeExport){ |
---|
| 3578 | |
---|
| 3579 | $boGroup = CreateObject('contactcenter.bo_group'); |
---|
| 3580 | $contacts = $boGroup->get_all_contacts(); |
---|
| 3581 | $streamBuffer = ''; |
---|
| 3582 | |
---|
| 3583 | if(!count($contacts)) |
---|
| 3584 | echo null; |
---|
[4227] | 3585 | |
---|
[2] | 3586 | switch($typeExport) { |
---|
| 3587 | |
---|
| 3588 | case 'outlook_en': |
---|
| 3589 | $streamBuffer = "Name;E-mail Address;Notes;Mobile Phone;Pager;Company;". |
---|
[3322] | 3590 | "Job Title;Home Phone;Home Fax;Business Phone;Business Fax\r\n"; |
---|
[293] | 3591 | foreach($contacts as $index => $object){ |
---|
[3322] | 3592 | $streamBuffer.= "\"".$object[ 'names_ordered'] . "\";" |
---|
| 3593 | . "\"".$object[ 'main-mail' ] . "\";" |
---|
| 3594 | . "\"".str_replace("\r\n\x0a","\t",$object[ 'notes' ]) . "\";" |
---|
| 3595 | . "\"".$object[ 'mobile' ] . "\";" |
---|
| 3596 | . "\"".$object[ 'business-pager' ] . "\";" |
---|
| 3597 | . "\"".$object[ 'corporate_name' ] . "\";" |
---|
| 3598 | . "\"".$object[ 'job_title' ] . "\";" |
---|
| 3599 | . "\"".$object[ 'home-phone' ] . "\";" |
---|
| 3600 | . "\"".$object[ 'home-fax' ] . "\";" |
---|
| 3601 | . "\"".$object[ 'business-phone' ] . "\";" |
---|
| 3602 | . "\"".$object[ 'business-fax' ] . "\"\r\n"; |
---|
[2] | 3603 | } |
---|
[3215] | 3604 | break; |
---|
[1599] | 3605 | |
---|
[2] | 3606 | case 'outlook_pt-BR': |
---|
[3322] | 3607 | $streamBuffer = "Nome;Sobrenome;Segundo nome;Nome;Apelido;End. de email;Endereço residencial;" |
---|
| 3608 | ."Cidade do endereço residencial;CEP do endereço residencial;Estado;País/região do endereço residencial;" |
---|
| 3609 | ."Telefone residencial;Fax residencial;Telefone celular;Página pessoal da Web;Rua do endereço comercial;" |
---|
| 3610 | ."Cidade do endereço comercial;CEP do endereço comercial;Estado do endereço comercial;" |
---|
| 3611 | ."País/região do endereço comercial;Página comercial da Web;Telefone comercial;Fax comercial;Pager;Empresa;" |
---|
| 3612 | ."Cargo;Departamento;End. comercial;Observações\r\n"; |
---|
[3215] | 3613 | |
---|
[293] | 3614 | foreach($contacts as $index => $object){ |
---|
[3322] | 3615 | $streamBuffer.= "\"".$object[ 'names_ordered'] . "\";" |
---|
| 3616 | .";;;" |
---|
| 3617 | . "\"".$object[ 'alias' ] . "\";" |
---|
| 3618 | . "\"".$object[ 'main-mail' ] . "\";" |
---|
| 3619 | . "\"".$object[ 'home-address' ] . "\";" |
---|
| 3620 | . "\"".$object[ 'home-city_name' ] . "\";" |
---|
| 3621 | . "\"".$object[ 'home-postal_code' ] . "\";" |
---|
| 3622 | . "\"".$object[ 'home-state_name' ] . "\";" |
---|
| 3623 | . "\"".$object[ 'home-id_country' ] . "\";" |
---|
| 3624 | . "\"".$object[ 'home-phone' ] . "\";" |
---|
| 3625 | . "\"".$object[ 'home-fax' ] . "\";" |
---|
| 3626 | . "\"".$object[ 'mobile' ] . "\";" |
---|
| 3627 | . "\"".$object[ 'web_page' ] . "\";" |
---|
| 3628 | . "\"".$object[ 'business-address' ] . "\";" |
---|
| 3629 | . "\"".$object[ 'business-city_name' ] . "\";" |
---|
| 3630 | . "\"".$object[ 'business-postal_code' ] . "\";" |
---|
| 3631 | . "\"".$object[ 'business-state_name' ] . "\";" |
---|
| 3632 | . "\"".$object[ 'business-id_country' ] . "\";" |
---|
| 3633 | . "\"".$object[ 'web_page' ] . "\";" |
---|
| 3634 | . "\"".$object[ 'business-phone' ] . "\";" |
---|
| 3635 | . "\"".$object[ 'business-fax' ] . "\";" |
---|
| 3636 | . "\"".$object[ 'business-pager' ] . "\";" |
---|
| 3637 | . "\"".$object[ 'corporate_name' ] . "\";" |
---|
| 3638 | . "\"".$object[ 'job_title' ] . "\";" |
---|
| 3639 | . "\"".$object[ 'department' ] . "\";" |
---|
| 3640 | .";" |
---|
| 3641 | . "\"".str_replace("\r\n\x0a","\t",$object[ 'notes' ]) . "\"\r\n"; |
---|
[2] | 3642 | } |
---|
[3322] | 3643 | |
---|
[2] | 3644 | break; |
---|
[1599] | 3645 | |
---|
[15] | 3646 | case 'outlook2000_pt-BR': |
---|
| 3647 | $streamBuffer = "\"Tratamento\",\"Nome\",\"Segundo Nome\",\"Sobrenome\",\"Sufixo\",". |
---|
[3322] | 3648 | "\"Empresa\",\"Departamento\",\"Cargo\",\"Rua do endereço comercial\",\"Rua do endereço comercial 2\",". |
---|
| 3649 | "\"Rua do endereço comercial 3\",\"Cidade do endereço comercial\",\"Estado do endereço comercial\",". |
---|
| 3650 | "\"CEP do endereço comercial\",\"País do endereço comercial\",\"Endereço residencial\",\"Rua residencial 2\",". |
---|
| 3651 | "\"Rua residencial 3\",\"Cidade do endereço residencial\",\"Estado\",\"CEP do endereço residencial\",\"País do endereço residencial\",". |
---|
| 3652 | "\"Outro endereço\",\"Outro endereço 2\",\"Outro endereço 3\",\"Cidade\",\"Estado\",\"CEP\",\"País\",". |
---|
[15] | 3653 | "\"Telefone do assistente\",\"Fax comercial\",\"Telefone comercial\",\"Telefone comercial 2\",\"Retorno de chamada\",". |
---|
| 3654 | "\"Telefone do carro\",\"Telefone principal da empresa\",\"Fax residencial\",\"Telefone residencial\",". |
---|
| 3655 | "\"Telefone residencial 2\",\"ISDN\",\"Telefone celular\",\"Outro fax\",\"Outro telefone\",\"Pager\",\"Telefone principal\",". |
---|
[3322] | 3656 | "\"Radiofone\",\"Telefone TTY/TDD\",\"Telex\",\"Aniversário\",\"Anotações\",\"Caixa postal\",\"Categorias\",". |
---|
| 3657 | "\"Código da empresa\",\"Código do governo\",\"Cônjuge\",\"Conta\",\"Endereço de correio eletrônico\",". |
---|
| 3658 | "\"Nome de exibição do correio eletr.\",\"Endereço de correio eletrônico 2\",". |
---|
| 3659 | "\"Nome de exibição do correio eletr.2\",\"Endereço de correio eletrônico 3\",". |
---|
| 3660 | "\"Nome de exibição do correio eletr.3\",\"Datas especiais\",\"Disponibilidade da Internet\",". |
---|
| 3661 | "\"Filhos\",\"Hobby\",\"Idioma\",\"Indicação\",\"Informações para cobrança\",\"Iniciais\",\"Local\",". |
---|
| 3662 | "\"Nome do assistente\",\"Nome do gerenciador\",\"Página da Web\",\"Palavras-chave\",\"Particular\",\"Personalizado 1\",\"Personalizado 2\",". |
---|
| 3663 | "\"Personalizado 3\",\"Personalizado 4\",\"Prioridade\",\"Profissão\",\"Quilometragem\",\"Sala\",\"Sensibilidade\",\"Servidor de diretório\",". |
---|
[15] | 3664 | "\"Sexo\"\r\n"; |
---|
[1599] | 3665 | |
---|
[3322] | 3666 | |
---|
| 3667 | |
---|
[293] | 3668 | foreach($contacts as $index => $object){ |
---|
[3322] | 3669 | $streamBuffer .= "\"".$object[ 'alias' ] . "\"," |
---|
| 3670 | . "\"".$object[ 'names_ordered' ] . "\"," |
---|
| 3671 | .",,," |
---|
| 3672 | . "\"".$object[ 'corporate_name' ] . "\"," |
---|
| 3673 | . "\"".$object[ 'department' ] . "\"," |
---|
| 3674 | . "\"".$object[ 'job_title' ] . "\"," |
---|
| 3675 | . "\"".$object[ 'business-address' ] . "\"," |
---|
| 3676 | . "\"".$object[ 'business-address-2' ] . "\"," |
---|
| 3677 | ."," |
---|
| 3678 | . "\"".$object[ 'business-city_name' ] . "\"," |
---|
| 3679 | . "\"".$object[ 'business-state' ] . "\"," |
---|
| 3680 | . "\"".$object[ 'business-postal_code' ] . "\"," |
---|
| 3681 | . "\"".$object[ 'business-id_country' ] . "\"," |
---|
| 3682 | . "\"".$object[ 'home-address' ] . "\"," |
---|
| 3683 | . "\"".$object[ 'home-address-2' ] . "\"," |
---|
| 3684 | ."," |
---|
| 3685 | . "\"".$object[ 'home-city_name' ] . "\"," |
---|
| 3686 | . "\"".$object[ 'home-state_name' ] . "\"," |
---|
| 3687 | . "\"".$object[ 'home-postal_code' ] . "\"," |
---|
| 3688 | . "\"".$object[ 'home-id_country' ] . "\"," |
---|
| 3689 | .",,,,,,,," |
---|
| 3690 | . "\"".$object[ 'business-fax' ] . "\"," |
---|
| 3691 | . "\"".$object[ 'business-phone' ] . "\"," |
---|
| 3692 | . "\"".$object[ 'business-mobile' ] . "\"," |
---|
| 3693 | .",,," |
---|
| 3694 | . "\"".$object[ 'home-fax' ] . "\"," |
---|
| 3695 | . "\"".$object[ 'home-phone' ] . "\"," |
---|
| 3696 | .",," |
---|
| 3697 | . "\"".$object[ 'mobile' ] . "\"," |
---|
| 3698 | .",," |
---|
| 3699 | . "\"".$object[ 'home-pager' ] . "\"," |
---|
| 3700 | . "\"".$object[ 'business-phone' ] . "\"," |
---|
| 3701 | .",,," |
---|
| 3702 | . "\"".$object[ 'birthdate' ] . "\"," |
---|
| 3703 | . "\"".str_replace("\r\n\x0a","\t",$object[ 'notes' ]) . "\"," |
---|
| 3704 | .",,,,,," |
---|
| 3705 | . "\"".$object[ 'main-mail' ] . "\"," |
---|
| 3706 | ."," |
---|
| 3707 | . "\"".$object[ 'alternative-mail' ] . "\"," |
---|
| 3708 | .",,,,,,,,,,,,,," |
---|
| 3709 | . "\"".$object[ 'web_page' ] . "\"," |
---|
| 3710 | .",,,,,,,,,,,," |
---|
| 3711 | . "\"".$object[ 'sex' ] . "\"\r\n"; |
---|
| 3712 | } |
---|
[15] | 3713 | break; |
---|
[1599] | 3714 | |
---|
[15] | 3715 | case 'outlook2000_en': |
---|
| 3716 | $streamBuffer = "Title,First Name,Middle Name,Last Name,Suffix,Company,Department,Job Title,". |
---|
| 3717 | "Business Street,Business Street 2,Business Street 3,Business City,Business State,Business Postal Code,". |
---|
| 3718 | "Business Country,Home Street,Home Street 2,Home Street 3,Home City,Home State,Home Postal Code,Home Country,". |
---|
| 3719 | "Other Street,Other Street 2,Other Street 3,Other City,Other State,Other Postal Code,Other Country,". |
---|
| 3720 | "Assistant's Phone,Business Fax,Business Phone,Business Phone 2,Callback,Car Phone,Company Main Phone,Home Fax,". |
---|
| 3721 | "Home Phone,Home Phone 2,ISDN,Mobile Phone,Other Fax,Other Phone,Pager,Primary Phone,Radio Phone,TTY/TDD Phone,Telex,". |
---|
| 3722 | "Account,Anniversary,Assistant's Name,Billing Information,Birthday,Categories,Children,Directory Server,E-mail Address,". |
---|
| 3723 | "E-mail Type,E-mail Display Name,E-mail 2 Address,E-mail 2 Type,E-mail 2 Display Name,E-mail 3 Address,E-mail 3 Type,E-mail 3 Display Name,". |
---|
| 3724 | "Gender,Government ID Number,Hobby,Initials,Internet Free Busy,Keywords,Language,Location,Manager's Name,Mileage,Notes,". |
---|
| 3725 | "Office Location,Organizational ID Number,PO Box,Priority,Private,Profession,Referred By,Sensitivity,Spouse,User 1,User 2,User 3,User 4,Web Page\r\n"; |
---|
[1599] | 3726 | |
---|
[293] | 3727 | foreach($contacts as $index => $object){ |
---|
[3322] | 3728 | $streamBuffer.= "\"".$object[ 'alias' ] . "\"," |
---|
| 3729 | . "\"".$object[ 'names_ordered'] . "\"," |
---|
| 3730 | .",,," |
---|
| 3731 | . "\"".$object[ 'corporate_name' ] . "\"," |
---|
| 3732 | . "\"".$object[ 'department' ] . "\"," |
---|
| 3733 | . "\"".$object[ 'job_title' ] . "\"," |
---|
| 3734 | . "\"".$object[ 'business-address' ] . "\"," |
---|
| 3735 | . "\"".$object[ 'business-address-2' ] . "\"," |
---|
| 3736 | ."," |
---|
| 3737 | . "\"".$object[ 'business-city_name' ] . "\"," |
---|
| 3738 | . "\"".$object[ 'business-state' ] . "\"," |
---|
| 3739 | . "\"".$object[ 'business-postal_code' ] . "\"," |
---|
| 3740 | . "\"".$object[ 'business-id_country' ] . "\"," |
---|
| 3741 | . "\"".$object[ 'home-address' ] . "\"," |
---|
| 3742 | . "\"".$object[ 'home-address-2' ] . "\"," |
---|
| 3743 | ."," |
---|
| 3744 | . "\"".$object[ 'home-city_name' ] . "\"," |
---|
| 3745 | . "\"".$object[ 'home-state_name' ] . "\"," |
---|
| 3746 | . "\"".$object[ 'home-postal_code' ] . "\"," |
---|
| 3747 | . "\"".$object[ 'home-id_country' ] . "\"," |
---|
| 3748 | .",,,,,,,," |
---|
| 3749 | . "\"".$object[ 'business-fax' ] . "\"," |
---|
| 3750 | . "\"".$object[ 'business-phone' ] . "\"," |
---|
| 3751 | . "\"".$object[ 'business-mobile' ] . "\"," |
---|
| 3752 | .",,," |
---|
| 3753 | . "\"".$object[ 'home-fax' ] . "\"," |
---|
| 3754 | . "\"".$object[ 'home-phone' ] . "\"," |
---|
| 3755 | .",," |
---|
| 3756 | . "\"".$object[ 'mobile' ] . "\"," |
---|
| 3757 | .",," |
---|
| 3758 | . "\"".$object[ 'business-pager' ] . "\"," |
---|
| 3759 | . "\"".$object[ 'home-pager' ] . "\"," |
---|
| 3760 | .",,,,,,,," |
---|
| 3761 | . "\"".$object[ 'birthdate' ] . "\"," |
---|
| 3762 | .",,," |
---|
| 3763 | . "\"".$object[ 'main-mail' ] . "\"," |
---|
| 3764 | .",," |
---|
| 3765 | . "\"".$object[ 'alternative-mail' ] . "\"," |
---|
| 3766 | .",,,,,,,,,,,,,,," |
---|
| 3767 | . "\"".str_replace("\r\n\x0a","\t",$object[ 'notes' ]) . "\"," |
---|
| 3768 | .",,,,,,,,,,,,," |
---|
| 3769 | . "\"".$object[ 'web_page' ] . "\"\r\n"; |
---|
| 3770 | |
---|
[15] | 3771 | } |
---|
| 3772 | break; |
---|
[1599] | 3773 | |
---|
[2] | 3774 | case 'thunderbird': |
---|
[3322] | 3775 | $streamBuffer = "First Name,Last Name,Display Name,Nickname,Primary Email,Secondary Email," |
---|
| 3776 | ."Screen Name,Work Phone,Home Phone,Fax Number,Pager Number,Mobile Number,Home Address," |
---|
| 3777 | ."Home Address 2,Home City,Home State,Home ZipCode,Home Country,Work Address,Work Address 2," |
---|
| 3778 | ."Work City,Work State,Work ZipCode,Work Country,Job Title,Department,Organization,Web Page 1," |
---|
| 3779 | ."Web Page 2,Birth Year,Birth Month,Birth Day,Custom 1,Custom 2,Custom 3,Custom 4,Notes,\n"; |
---|
[1599] | 3780 | |
---|
[293] | 3781 | foreach($contacts as $index => $object){ |
---|
[3322] | 3782 | $array_birth = explode("-",$object[ 'birthdate' ]); |
---|
| 3783 | $streamBuffer.= "\"".$object[ 'names_ordered'] . "\"," |
---|
| 3784 | .",," |
---|
| 3785 | . "\"".$object[ 'alias' ] . "\"," |
---|
| 3786 | . "\"".$object[ 'main-mail' ] . "\"," |
---|
| 3787 | . "\"".$object[ 'alternative-mail' ] . "\"," |
---|
| 3788 | ."," |
---|
| 3789 | . "\"".$object[ 'business-phone' ] . "\"," |
---|
| 3790 | . "\"".$object[ 'home-phone' ] . "\"," |
---|
| 3791 | . "\"".$object[ 'business-fax' ] . "\"," |
---|
| 3792 | . "\"".$object[ 'business-pager' ] . "\"," |
---|
| 3793 | . "\"".$object[ 'mobile' ] . "\"," |
---|
| 3794 | . "\"".$object[ 'home-address' ] . "\"," |
---|
| 3795 | . "\"".$object[ 'home-address-2' ] . "\"," |
---|
| 3796 | . "\"".$object[ 'home-city_name' ] . "\"," |
---|
| 3797 | . "\"".$object[ 'home-state_name' ] . "\"," |
---|
| 3798 | . "\"".$object[ 'home-postal_code' ] . "\"," |
---|
| 3799 | . "\"".$object[ 'home-id_country' ] . "\"," |
---|
| 3800 | . "\"".$object[ 'business-address' ] . "\"," |
---|
| 3801 | . "\"".$object[ 'business-address-2' ] . "\"," |
---|
| 3802 | . "\"".$object[ 'business-city_name' ] . "\"," |
---|
| 3803 | . "\"".$object[ 'business-state_name' ] . "\"," |
---|
| 3804 | . "\"".$object[ 'business-postal_code' ] . "\"," |
---|
| 3805 | . "\"".$object[ 'business-id_country' ] . "\"," |
---|
| 3806 | . "\"".$object[ 'job_title' ] . "\"," |
---|
| 3807 | . "\"".$object[ 'department' ] . "\"," |
---|
| 3808 | . "\"".$object[ 'corporate_name' ] . "\"," |
---|
| 3809 | . "\"".$object[ 'web_page' ] . "\"," |
---|
| 3810 | . "\"".$object[ 'web_page' ] . "\"," |
---|
| 3811 | . "\"".$array_birth[0] . "\"," |
---|
| 3812 | . "\"".$array_birth[1] . "\"," |
---|
| 3813 | . "\"".$array_birth[2] . "\"," |
---|
| 3814 | .",,,," |
---|
| 3815 | . "\"".str_replace("\r\n\x0a","\t",$object[ 'notes' ]) . "\",\r\n"; |
---|
| 3816 | |
---|
[2] | 3817 | } |
---|
| 3818 | break; |
---|
[1599] | 3819 | |
---|
[285] | 3820 | case 'expresso': |
---|
[4227] | 3821 | $streamBuffer = 'Nome,Apelido,E-mail Principal,E-mail Alternativo,Celular,' |
---|
| 3822 | . 'Telefone Comercial,Endereço Comercial,Complemento End. Comercial,CEP Comercial,Cidade End. Comercial,Estado End. Comercial,País End. Comercial,' |
---|
| 3823 | . 'Telefone Residencial,Endereço Residencial,Complemento End. Residencial,CEP Residencial,Cidade End. Residencial,Estado End. Residencial,País End. Residencial,' |
---|
| 3824 | . 'Aniversário,Sexo,Assinatura GPG,Notas,Página Web,Empresa,Cargo,Departamento,Fax Comercial,Pager Comercial,Celular Comercial,Fax,Pager,Endereço Comercial 2,Endereço Residencial 2' |
---|
[3322] | 3825 | . "\r\n"; |
---|
[1599] | 3826 | |
---|
[4227] | 3827 | foreach($contacts as $index => $object) |
---|
| 3828 | { |
---|
| 3829 | if( array_key_exists("phone", $object) ) |
---|
| 3830 | $phone = $object['phone']; |
---|
| 3831 | else |
---|
| 3832 | $phone = $object['business-phone']; |
---|
| 3833 | |
---|
| 3834 | $streamBuffer .= "\"".$object[ 'names_ordered'] . "\"," |
---|
| 3835 | . "\"".$object[ 'alias' ] . "\"," |
---|
| 3836 | . "\"".$object[ 'main-mail' ] . "\"," |
---|
| 3837 | . "\"".$object[ 'alternative-mail' ] . "\"," |
---|
| 3838 | . "\"".$object[ 'mobile' ] . "\"," |
---|
| 3839 | . "\"".$phone . "\"," |
---|
| 3840 | . "\"".$object[ 'business-address' ] . "\"," |
---|
| 3841 | . "\"".$object[ 'business-complement' ] . "\"," |
---|
| 3842 | . "\"".$object[ 'business-postal_code' ] . "\"," |
---|
| 3843 | . "\"".$object[ 'business-city_name' ] . "\"," |
---|
| 3844 | . "\"".$object[ 'business-state_name' ] . "\"," |
---|
| 3845 | . "\"".$object[ 'business-id_country' ] . "\"," |
---|
| 3846 | . "\"".$object[ 'home-phone' ] . "\"," |
---|
| 3847 | . "\"".$object[ 'home-address' ] . "\"," |
---|
| 3848 | . "\"".$object[ 'home-complement' ] . "\"," |
---|
| 3849 | . "\"".$object[ 'home-postal_code' ] . "\"," |
---|
| 3850 | . "\"".$object[ 'home-city_name' ] . "\"," |
---|
| 3851 | . "\"".$object[ 'home-state_name' ] . "\"," |
---|
| 3852 | . "\"".$object[ 'home-id_country' ] . "\"," |
---|
| 3853 | . "\"".$object[ 'birthdate' ] . "\"," |
---|
| 3854 | . "\"".$object[ 'sex' ] . "\"," |
---|
| 3855 | . "\"".$object[ 'pgp_key' ] . "\"," |
---|
| 3856 | . "\"".str_replace("\r\n\x0a","\t",$object[ 'notes' ]) . "\"," |
---|
| 3857 | . "\"".$object[ 'web_page' ] . "\"," |
---|
| 3858 | . "\"".$object[ 'corporate_name' ] . "\"," |
---|
| 3859 | . "\"".$object[ 'job_title' ] . "\"," |
---|
| 3860 | . "\"".$object[ 'department' ] . "\"," |
---|
| 3861 | . "\"".$object[ 'business-fax' ] . "\"," |
---|
| 3862 | . "\"".$object[ 'business-pager' ] . "\"," |
---|
| 3863 | . "\"".$object[ 'business-mobile' ] . "\"," |
---|
| 3864 | . "\"".$object[ 'home-fax' ] . "\"," |
---|
| 3865 | . "\"".$object[ 'home-pager' ] . "\"," |
---|
| 3866 | . "\"".$object[ 'business-address-2' ] . "\"," |
---|
| 3867 | . "\"".$object[ 'home-address-2' ] . "\"\r\n"; |
---|
| 3868 | |
---|
| 3869 | } |
---|
[3322] | 3870 | break; |
---|
[1599] | 3871 | |
---|
[2] | 3872 | } |
---|
| 3873 | |
---|
| 3874 | $file = "contacts_".md5(microtime()).".swp"; |
---|
| 3875 | $tempDir = ini_get("session.save_path"); |
---|
| 3876 | $f = fopen($tempDir.'/'.$file,"w"); |
---|
| 3877 | if(!$f) |
---|
| 3878 | echo null; |
---|
[1599] | 3879 | |
---|
[2] | 3880 | fputs($f,$streamBuffer); |
---|
| 3881 | fclose($f); |
---|
| 3882 | |
---|
| 3883 | echo $tempDir.'/'.$file; |
---|
| 3884 | } |
---|
| 3885 | |
---|
[285] | 3886 | // Get the csv field and put into array, from php.net |
---|
| 3887 | function parse_line($input_text, $delimiter = ',', $text_qualifier = '"') { |
---|
| 3888 | $text = trim($input_text); |
---|
| 3889 | if(is_string($delimiter) && is_string($text_qualifier)) { |
---|
| 3890 | $re_d = '\x' . dechex(ord($delimiter)); //format for regexp |
---|
| 3891 | $re_tq = '\x' . dechex(ord($text_qualifier)); //format for regexp |
---|
[1599] | 3892 | |
---|
[285] | 3893 | $fields = array(); |
---|
| 3894 | $field_num = 0; |
---|
| 3895 | while(strlen($text) > 0) { |
---|
| 3896 | if($text{0} == $text_qualifier) { |
---|
| 3897 | preg_match('/^' . $re_tq . '((?:[^' . $re_tq . ']|(?<=\x5c)' . $re_tq . ')*)' . $re_tq . $re_d . '?(.*)$/', $text, $matches); |
---|
[1599] | 3898 | |
---|
[285] | 3899 | $value = str_replace('\\' . $text_qualifier, $text_qualifier, $matches[1]); |
---|
| 3900 | $text = trim($matches[2]); |
---|
[1599] | 3901 | |
---|
[285] | 3902 | $fields[$field_num++] = $value; |
---|
| 3903 | } else { |
---|
| 3904 | preg_match('/^([^' . $re_d . ']*)' . $re_d . '?(.*)$/', $text, $matches); |
---|
[1599] | 3905 | |
---|
[285] | 3906 | $value = $matches[1]; |
---|
| 3907 | $text = trim($matches[2]); |
---|
[1599] | 3908 | |
---|
[285] | 3909 | $fields[$field_num++] = $value; |
---|
| 3910 | } |
---|
| 3911 | } |
---|
| 3912 | return $fields; |
---|
| 3913 | } else |
---|
| 3914 | return false; |
---|
| 3915 | } |
---|
[16] | 3916 | |
---|
[1599] | 3917 | //funcao alterada para importar outros campos alem de nome, telefone e email, de arquivo csv (Outlook 2000) |
---|
| 3918 | //em 08/04/2009 - Rommel Cysne (rommel.cysne@serpro.gov.br); |
---|
| 3919 | //Foi adicionada uma funcao (escapesheelcmd()) nas variaveis para que caracteres especiais sejam ignorados |
---|
| 3920 | //durante a importacao dos contatos; o processo estava travando por causa de caracteres em campos como nome, |
---|
| 3921 | //sobrenome, notas e e-mail; |
---|
| 3922 | //em 19/06/2009 - Rommel Cysne (rommel.cysne@serpro.gov.br); |
---|
[2] | 3923 | function import_contacts($typeImport){ |
---|
[3334] | 3924 | $this->so_group = CreateObject('contactcenter.so_group'); |
---|
[1599] | 3925 | if($file = $_SESSION['contactcenter']['importCSV']) { |
---|
| 3926 | unset($_SESSION['contactcenter']['importCSV']); |
---|
[2] | 3927 | $len = filesize($file); |
---|
| 3928 | $count = 0; |
---|
| 3929 | $return = array('error' => false, '_new' => 0, '_existing' => 0, '_failure' => 0); |
---|
[276] | 3930 | $handle = @fopen($file, "r") or die(serialize($return['error'] = true)); |
---|
[1599] | 3931 | |
---|
[285] | 3932 | $input_header = fgets($handle); |
---|
| 3933 | if ($typeImport == 'outlook') |
---|
| 3934 | $delim = ';'; |
---|
| 3935 | else if ($typeImport == 'auto') |
---|
| 3936 | $delim = strstr($input_header,',') ? ',' : ';'; |
---|
[1599] | 3937 | else |
---|
[285] | 3938 | $delim = ','; |
---|
| 3939 | $csv_header = $this->parse_line($input_header,$delim); |
---|
| 3940 | $firstContact = fgets($handle); |
---|
| 3941 | preg_match("/\"(.+)\"[,;]/sU",$firstContact,$matches); // yahoo csv |
---|
[1599] | 3942 | rewind($handle); |
---|
[285] | 3943 | |
---|
[2] | 3944 | $header = @fgetcsv($handle, $len, $delim) or die(serialize($return['error'] = true)); |
---|
[15] | 3945 | if(count($header) < 2 || count($header) > 100) { |
---|
[2] | 3946 | $return['error'] = true; |
---|
| 3947 | $return['sizeheader'] = count($header); |
---|
| 3948 | echo serialize($return); |
---|
| 3949 | return; |
---|
| 3950 | } |
---|
[1599] | 3951 | |
---|
[285] | 3952 | if ($matches[0][strlen($matches[0])-1] == ';') |
---|
| 3953 | $delim = ';'; |
---|
[1599] | 3954 | |
---|
[3322] | 3955 | $boGroup = CreateObject('contactcenter.bo_group'); |
---|
| 3956 | $boPeople = CreateObject('contactcenter.bo_people_catalog'); |
---|
| 3957 | switch($typeImport){ |
---|
| 3958 | case 'outlook2000': |
---|
| 3959 | $name_pos=1; |
---|
| 3960 | $name2_pos=2; |
---|
| 3961 | $name3_pos=3; |
---|
| 3962 | $corporate_street_pos=8; |
---|
| 3963 | $cep_pos=13; |
---|
| 3964 | $corporate_street_2_pos=22; |
---|
| 3965 | $fax_pos=30; |
---|
| 3966 | $phone_pos=31; |
---|
| 3967 | $home_phone_pos=37; |
---|
| 3968 | $personal_cell_pos=40; |
---|
| 3969 | $pager_pos=43; |
---|
| 3970 | $birth_pos=48; |
---|
| 3971 | $notes_pos=49; |
---|
| 3972 | $email_pos=56; |
---|
| 3973 | $aditionalEmail_pos=59; |
---|
[1599] | 3974 | |
---|
[3322] | 3975 | break; |
---|
| 3976 | case 'outlook': |
---|
| 3977 | $name_pos=3; |
---|
| 3978 | $email_pos=4; |
---|
| 3979 | $phone_pos=7; |
---|
| 3980 | $home_phone_pos=10; |
---|
| 3981 | $personal_cell_pos=12; |
---|
| 3982 | $corporate_street_pos=13; |
---|
| 3983 | $cep_pos=15; |
---|
| 3984 | $phone_pos=18; |
---|
| 3985 | $fax_pos=19; |
---|
| 3986 | $pager_pos=20; |
---|
| 3987 | $notes_pos=25; |
---|
| 3988 | break; |
---|
| 3989 | case 'thunderbird': |
---|
| 3990 | $name_pos=2; |
---|
| 3991 | $email_pos=4; |
---|
| 3992 | $phone_pos=7; |
---|
| 3993 | break; |
---|
| 3994 | case 'expresso': |
---|
| 3995 | $name_pos=0; |
---|
| 3996 | $alias_pos=1; |
---|
| 3997 | $email_pos=2; |
---|
| 3998 | $aditionalEmail_pos=3; |
---|
| 3999 | $personal_cell_pos=4; |
---|
| 4000 | $corporate_phone_pos=5; |
---|
| 4001 | $corporate_street_pos=6; |
---|
| 4002 | $corporate_comp_pos=7; |
---|
| 4003 | $corporate_cep_pos=8; |
---|
| 4004 | $corporate_city_pos=9; |
---|
| 4005 | $corporate_state_pos=10; |
---|
| 4006 | $corporate_country_pos=11; |
---|
| 4007 | $home_phone_pos=12; |
---|
| 4008 | $street_pos=13; |
---|
| 4009 | $comp_pos=14; |
---|
| 4010 | $cep_pos=15; |
---|
| 4011 | $city_pos=16; |
---|
| 4012 | $state_pos=17; |
---|
| 4013 | $country_pos=18; |
---|
| 4014 | $birth_pos=19; |
---|
| 4015 | $sex_pos = 20; |
---|
| 4016 | $pgp_key_pos = 21; |
---|
| 4017 | $notes_pos=22; |
---|
| 4018 | $web_page_pos=23; |
---|
| 4019 | $corporate_name_pos=24; |
---|
| 4020 | $job_title_pos=25; |
---|
| 4021 | $department_pos=26; |
---|
| 4022 | $corporate_fax_pos=27; |
---|
| 4023 | $corporate_pager_pos=28; |
---|
| 4024 | $corporate_cell_pos=29; |
---|
| 4025 | $fax_pos=30; |
---|
| 4026 | $pager_pos=31; |
---|
| 4027 | $corporate_street_2_pos = 32; |
---|
| 4028 | $street_2_pos = 33; |
---|
| 4029 | break; |
---|
[285] | 4030 | default: |
---|
[3322] | 4031 | foreach($csv_header as $index => $fieldName) |
---|
| 4032 | { |
---|
| 4033 | switch($fieldName){ |
---|
| 4034 | case 'Name': |
---|
| 4035 | case 'Nome': |
---|
| 4036 | case 'First Name': |
---|
| 4037 | $name_pos = $index; |
---|
| 4038 | break; |
---|
| 4039 | case 'Second name': |
---|
| 4040 | case 'Segundo nome': |
---|
| 4041 | $name2_pos = $index; |
---|
| 4042 | break; |
---|
| 4043 | case 'Sobrenome': |
---|
| 4044 | case 'Surname': |
---|
| 4045 | $name3_pos = $index; |
---|
| 4046 | break; |
---|
| 4047 | case 'Business Street': |
---|
| 4048 | case 'Rua do endereço comercial': |
---|
| 4049 | $corporate_street_pos = $index; |
---|
| 4050 | break; |
---|
| 4051 | case 'Rua do endereço comercial 2': |
---|
| 4052 | case 'Outro endereço': |
---|
| 4053 | $corporate_street_2_pos = $index; |
---|
| 4054 | break; |
---|
| 4055 | case 'Business Postal Code': |
---|
| 4056 | case 'CEP do endereço comercial': |
---|
| 4057 | $cep_pos = $index; |
---|
| 4058 | break; |
---|
| 4059 | case 'Business Fax': |
---|
| 4060 | case 'Fax comercial': |
---|
| 4061 | case 'Fax': |
---|
| 4062 | $fax_pos = $index; |
---|
| 4063 | break; |
---|
| 4064 | case 'Home Phone': |
---|
| 4065 | case 'Telefone residencial': |
---|
| 4066 | $home_phone_pos = $index; |
---|
| 4067 | break; |
---|
| 4068 | case 'Mobile phone': |
---|
| 4069 | case 'Telefone celular': |
---|
| 4070 | $personal_cell_pos = $index; |
---|
| 4071 | break; |
---|
| 4072 | case 'Pager': |
---|
| 4073 | $pager_pos = $index; |
---|
| 4074 | break; |
---|
| 4075 | case 'Phone': |
---|
| 4076 | case 'Business Phone': |
---|
| 4077 | case 'Telefone': |
---|
| 4078 | case 'Telefone principal': |
---|
| 4079 | case 'Telefone comercial': |
---|
[4227] | 4080 | case 'Telefone Comercial': |
---|
[3322] | 4081 | $phone_pos = $index; |
---|
| 4082 | break; |
---|
| 4083 | case 'Aniversário': |
---|
| 4084 | case 'Birthdate': |
---|
| 4085 | $birth_pos = $index; |
---|
| 4086 | case 'Anotações': |
---|
| 4087 | case 'Notes': |
---|
| 4088 | $notes_pos = $index; |
---|
| 4089 | case 'E-mail': |
---|
| 4090 | case 'Email': |
---|
| 4091 | case 'E-mail Address': |
---|
| 4092 | case 'Endereço de correio eletrônico': |
---|
| 4093 | case 'End. de email': |
---|
| 4094 | $email_pos = $index; |
---|
| 4095 | break; |
---|
| 4096 | case 'Endereço de correio eletrônico 2': |
---|
| 4097 | $aditionalEmail_pos = $index; |
---|
| 4098 | break; |
---|
| 4099 | } |
---|
[285] | 4100 | } |
---|
[3322] | 4101 | break; |
---|
[15] | 4102 | } |
---|
[276] | 4103 | |
---|
[2] | 4104 | while (($data = fgetcsv($handle, $len, $delim))) { |
---|
[3322] | 4105 | foreach ($header as $key=>$heading) |
---|
[2] | 4106 | $row[$heading]=(isset($data[$key])) ? $data[$key] : ''; |
---|
[1599] | 4107 | |
---|
[3322] | 4108 | $sdata = array(); |
---|
| 4109 | $full_name = trim($row[$header[$name_pos]]); |
---|
| 4110 | $email = trim($row[$header[$email_pos]]); |
---|
| 4111 | $phone = trim($row[$header[$phone_pos]]); |
---|
| 4112 | $name2 = trim($row[$header[$name2_pos]]); |
---|
| 4113 | $name3 = trim($row[$header[$name3_pos]]); |
---|
[1599] | 4114 | |
---|
[3322] | 4115 | $birth = trim($row[$header[$birth_pos]]); |
---|
| 4116 | $notes = trim($row[$header[$notes_pos]]); |
---|
| 4117 | $altEmail = trim($row[$header[$altEmail_pos]]); |
---|
| 4118 | $sdata['alias'] = trim($row[$header[$alias_pos]]); |
---|
| 4119 | $sdata['corporate_name'] = trim($row[$header[$corporate_name_pos]]); |
---|
| 4120 | $sdata['job_title'] = trim($row[$header[$job_title_pos]]); |
---|
| 4121 | $sdata['department'] = trim($row[$header[$department_pos]]); |
---|
| 4122 | $sdata['web_page'] = trim($row[$header[$web_page_pos]]); |
---|
| 4123 | |
---|
| 4124 | $sdata['sex'] = trim($row[$header[$sex_pos]]); |
---|
| 4125 | $sdata['pgp_key'] = trim($row[$header[$pgp_key_pos]]); |
---|
[1599] | 4126 | |
---|
[3322] | 4127 | |
---|
| 4128 | $full_name = $full_name; |
---|
[2] | 4129 | $array_name = explode(' ', str_replace('"','',(str_replace('\'','',$full_name)))); |
---|
[3476] | 4130 | $sdata['given_names'] = addslashes($array_name[0]); |
---|
[2] | 4131 | $array_name[0] = null; |
---|
| 4132 | $sdata['family_names'] = trim(implode(' ',$array_name)); |
---|
[1599] | 4133 | if($sdata['family_names'] == '') |
---|
| 4134 | { |
---|
[3476] | 4135 | $sdata['family_names'] = addslashes($name2) . " " . addslashes($name3); |
---|
[1599] | 4136 | } |
---|
[3476] | 4137 | |
---|
[3322] | 4138 | $sdata['connections']['default_email']['connection_name'] = lang('Main'); |
---|
[3476] | 4139 | $sdata['connections']['default_email']['connection_value'] = addslashes($email); |
---|
[3322] | 4140 | $sdata['connections']['aditional_email']['connection_name'] = "Alternativo"; |
---|
| 4141 | $sdata['connections']['aditional_email']['connection_value'] = trim($row[$header[$aditionalEmail_pos]]); |
---|
[1599] | 4142 | |
---|
[3322] | 4143 | $sdata['connections']['default_phone']['connection_name'] = lang('Main'); |
---|
[4224] | 4144 | $sdata['connections']['default_phone']['connection_value'] = $phone; |
---|
[2] | 4145 | |
---|
[4224] | 4146 | if( trim($row[$header[$home_phone_pos]]) != "" ) |
---|
| 4147 | { |
---|
| 4148 | $sdata['connections']['aditional_phone']['home_phone']['connection_name'] = 'Casa'; |
---|
| 4149 | $sdata['connections']['aditional_phone']['home_phone']['connection_value'] = trim($row[$header[$home_phone_pos]]); |
---|
| 4150 | } |
---|
[1599] | 4151 | |
---|
[4224] | 4152 | if( trim($row[$header[$personal_cell_pos]]) != "" ) |
---|
| 4153 | { |
---|
| 4154 | $sdata['connections']['aditional_phone']['cellphone']['connection_name'] = 'Celular'; |
---|
| 4155 | $sdata['connections']['aditional_phone']['cellphone']['connection_value'] = trim($row[$header[$personal_cell_pos]]); |
---|
| 4156 | } |
---|
| 4157 | |
---|
| 4158 | if( trim($row[$header[$corporate_phone_pos]]) != "") |
---|
| 4159 | { |
---|
| 4160 | $sdata['connections']['aditional_phone']['corporate_phone']['connection_name'] = 'Trabalho'; |
---|
| 4161 | $sdata['connections']['aditional_phone']['corporate_phone']['connection_value'] = trim($row[$header[$corporate_phone_pos]]); |
---|
| 4162 | } |
---|
| 4163 | |
---|
| 4164 | if( trim($row[$header[$fax_pos]]) != "" ) |
---|
| 4165 | { |
---|
| 4166 | $sdata['connections']['aditional_phone']['fax']['connection_name'] = 'Fax'; |
---|
| 4167 | $sdata['connections']['aditional_phone']['fax']['connection_value'] = trim($row[$header[$fax_pos]]); |
---|
| 4168 | } |
---|
| 4169 | |
---|
| 4170 | if ($GLOBALS['phpgw_info']['server']['personal_contact_type'] == 'True') |
---|
| 4171 | { |
---|
| 4172 | if( trim($row[$header[$pager_pos]]) != "" ) |
---|
| 4173 | { |
---|
| 4174 | $sdata['connections']['aditional_phone']['pager']['connection_name'] = 'Pager'; |
---|
| 4175 | $sdata['connections']['aditional_phone']['pager']['connection_value'] = trim($row[$header[$pager_pos]]); |
---|
| 4176 | } |
---|
| 4177 | |
---|
| 4178 | if( trim($row[$header[$corporate_fax_pos]]) != "" ) |
---|
| 4179 | { |
---|
| 4180 | $sdata['connections']['aditional_phone']['corporate_fax']['connection_name'] = 'Fax Corporativo'; |
---|
| 4181 | $sdata['connections']['aditional_phone']['corporate_fax']['connection_value'] = trim($row[$header[$corporate_fax_pos]]); |
---|
| 4182 | } |
---|
| 4183 | |
---|
| 4184 | if( trim($row[$header[$corporate_cell_pos]]) != "" ) |
---|
| 4185 | { |
---|
| 4186 | $sdata['connections']['aditional_phone']['corporate_cell']['connection_name'] = 'Celular Corporativo'; |
---|
| 4187 | $sdata['connections']['aditional_phone']['corporate_cell']['connection_value'] = trim($row[$header[$corporate_cell_pos]]); |
---|
| 4188 | } |
---|
| 4189 | |
---|
| 4190 | if( trim($row[$header[$corporate_pager_pos]]) != "" ) |
---|
| 4191 | { |
---|
| 4192 | $sdata['connections']['aditional_phone']['corporate_pager']['connection_name'] = 'Pager Corporativo'; |
---|
| 4193 | $sdata['connections']['aditional_phone']['corporate_pager']['connection_value'] = trim($row[$header[$corporate_pager_pos]]); |
---|
| 4194 | } |
---|
| 4195 | } |
---|
| 4196 | |
---|
[3322] | 4197 | $sdata['addresses']['address_corporative']['address1'] = trim($row[$header[$corporate_street_pos]]); |
---|
| 4198 | $sdata['addresses']['address_corporative']['address2'] = trim($row[$header[$corporate_street_2_pos]]); |
---|
| 4199 | $sdata['addresses']['address_corporative']['complement'] = trim($row[$header[$corporate_comp_pos]]); |
---|
| 4200 | $sdata['addresses']['address_corporative']['postal_code'] = trim($row[$header[$corporate_cep_pos]]); |
---|
| 4201 | $sdata['addresses']['address_corporative']['id_country'] = "BR"; |
---|
| 4202 | $sdata['addresses']['address_corporative']['id_state'] = trim($row[$header[$corporate_state_pos]]); |
---|
| 4203 | $sdata['addresses']['address_corporative']['id_city'] = trim($row[$header[$corporate_city_pos]]); |
---|
| 4204 | |
---|
| 4205 | |
---|
| 4206 | $sdata['addresses']['address_personal']['address1'] = trim($row[$header[$street_pos]]); |
---|
| 4207 | $sdata['addresses']['address_personal']['address2'] = trim($row[$header[$street_2_pos]]); |
---|
| 4208 | $sdata['addresses']['address_personal']['complement'] = trim($row[$header[$comp_pos]]); |
---|
| 4209 | $sdata['addresses']['address_personal']['postal_code'] = trim($row[$header[$cep_pos]]); |
---|
| 4210 | $sdata['addresses']['address_personal']['id_country'] = "BR"; |
---|
| 4211 | $sdata['addresses']['address_personal']['id_state'] = trim($row[$header[$state_pos]]); |
---|
| 4212 | $sdata['addresses']['address_personal']['id_city'] = trim($row[$header[$city_pos]]); |
---|
[1599] | 4213 | |
---|
[4076] | 4214 | if(trim($birth)) { |
---|
| 4215 | $array_birth = explode("/",trim($birth)); |
---|
| 4216 | $sdata['birthdate'] = date('Y-m-d', mktime(0,0,0,$array_birth[1],$array_birth[0],$array_birth[2])); |
---|
| 4217 | } |
---|
[1599] | 4218 | |
---|
[3476] | 4219 | $sdata['notes'] = addslashes($notes); |
---|
[3322] | 4220 | //$sdata['is_quick_add'] = true; |
---|
[16] | 4221 | $sdata['connections']['default_phone']['connection_value'] = $phone; |
---|
[1599] | 4222 | |
---|
[285] | 4223 | // verifica se email já existe! |
---|
[3476] | 4224 | $email = addslashes($email); |
---|
[2] | 4225 | $contact = $boGroup->verify_contact($email); |
---|
[1599] | 4226 | |
---|
[285] | 4227 | if(!$sdata['given_names'] && $email){ |
---|
| 4228 | $a_email = explode("@",$email); |
---|
[3476] | 4229 | $sdata['given_names'] = addslashes($a_email[0]); |
---|
[285] | 4230 | } |
---|
[2] | 4231 | |
---|
[1599] | 4232 | $line_iteration = $return['_failure'] + $return['_existing'] + $return['_new']; |
---|
| 4233 | |
---|
[2] | 4234 | if($contact){ |
---|
| 4235 | $return['_existing']++; |
---|
[1599] | 4236 | } |
---|
[3237] | 4237 | else if((!eregi("^[/_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) && $email) { |
---|
[2] | 4238 | $return['_failure']++; |
---|
[285] | 4239 | $return['_failure_status'] .= "Line: " . ($line_iteration + 2) . ", Invalid E-Mail address: " . $email ."<br>"; |
---|
[16] | 4240 | } |
---|
[3237] | 4241 | else if (!$sdata['given_names'] || !$boPeople ->quick_add($sdata)){ |
---|
[1599] | 4242 | $return['_failure']++; |
---|
[285] | 4243 | $return['_failure_status'] .= "Line: " . ($line_iteration + 2) . ", Invalid Name: " . $sdata['given_names'] ."<br>"; |
---|
[2] | 4244 | } |
---|
[3334] | 4245 | else{ |
---|
| 4246 | if($id_group != 0){ |
---|
| 4247 | $this->so_group->add_user_by_name($id_group,$full_name); |
---|
| 4248 | } |
---|
| 4249 | $return['_new']++; |
---|
| 4250 | } |
---|
[1599] | 4251 | } |
---|
[2] | 4252 | fclose($handle); |
---|
[15] | 4253 | unlink($file); |
---|
[2] | 4254 | } |
---|
| 4255 | else |
---|
| 4256 | $return['error'] = true; |
---|
| 4257 | |
---|
| 4258 | echo serialize($return); |
---|
| 4259 | } |
---|
| 4260 | } |
---|
| 4261 | |
---|
| 4262 | ?> |
---|