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