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