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