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