[6779] | 1 | <?php |
---|
| 2 | /***************************************************************************\ |
---|
| 3 | * eGroupWare - Contacts Center * |
---|
| 4 | * http://www.egroupware.org * |
---|
| 5 | * * |
---|
| 6 | * Storage Object Classes * |
---|
| 7 | * Written by: * |
---|
| 8 | * - Raphael Derosso Pereira <raphaelpereira@users.sourceforge.net> * |
---|
| 9 | * sponsored by Thyamad - http://www.thyamad.com * |
---|
| 10 | * ------------------------------------------------------------------------- * |
---|
| 11 | * This program is free software; you can redistribute it and/or modify it * |
---|
| 12 | * under the terms of the GNU General Public License as published by the * |
---|
| 13 | * Free Software Foundation; either version 2 of the License, or (at your * |
---|
| 14 | * option) any later version. * |
---|
| 15 | \***************************************************************************/ |
---|
| 16 | |
---|
| 17 | /** |
---|
| 18 | * This class handles the Contact DB Table |
---|
| 19 | * |
---|
| 20 | */ |
---|
| 21 | |
---|
| 22 | include_once("class.so_main.inc.php"); |
---|
| 23 | |
---|
| 24 | class so_contact extends so_main { |
---|
| 25 | |
---|
| 26 | function so_contact ( $id_contact = false) |
---|
| 27 | { |
---|
| 28 | $this->init(); |
---|
| 29 | |
---|
| 30 | $this->main_fields = array( |
---|
| 31 | 'id_contact' => array( |
---|
| 32 | 'name' => 'id_contact', |
---|
| 33 | 'type' => 'primary', |
---|
| 34 | 'state' => 'empty', |
---|
| 35 | 'value' => &$this->id), |
---|
| 36 | 'id_owner' => array( |
---|
| 37 | 'name' => 'id_owner', |
---|
| 38 | 'type' => false, |
---|
| 39 | 'state' => 'empty', |
---|
| 40 | 'value' => false), |
---|
| 41 | 'id_status' => array( |
---|
| 42 | 'name' => 'id_status', |
---|
| 43 | 'type' => 'foreign', |
---|
| 44 | 'association' => array( |
---|
| 45 | 'table' => 'phpgw_cc_status', |
---|
| 46 | 'field' => 'id_status'), |
---|
| 47 | 'state' => 'empty', |
---|
| 48 | 'value' => false), |
---|
| 49 | 'photo' => array( |
---|
| 50 | 'name' => 'photo', |
---|
| 51 | 'type' => false, |
---|
| 52 | 'state' => 'empty', |
---|
| 53 | 'value' => false), |
---|
| 54 | 'alias' => array( |
---|
| 55 | 'name' => 'alias', |
---|
| 56 | 'type' => false, |
---|
| 57 | 'state' => 'empty', |
---|
| 58 | 'value' => false), |
---|
| 59 | 'web_page' => array( |
---|
| 60 | 'name' => 'web_page', |
---|
| 61 | 'type' => false, |
---|
| 62 | 'state' => 'empty', |
---|
| 63 | 'value' => false), |
---|
| 64 | 'corporate_name' => array( |
---|
| 65 | 'name' => 'corporate_name', |
---|
| 66 | 'type' => false, |
---|
| 67 | 'state' => 'empty', |
---|
| 68 | 'value' => false), |
---|
| 69 | 'job_title' => array( |
---|
| 70 | 'name' => 'job_title', |
---|
| 71 | 'type' => false, |
---|
| 72 | 'state' => 'empty', |
---|
| 73 | 'value' => false), |
---|
| 74 | 'department' => array( |
---|
| 75 | 'name' => 'department', |
---|
| 76 | 'type' => false, |
---|
| 77 | 'state' => 'empty', |
---|
| 78 | 'value' => false), |
---|
| 79 | 'id_prefix' => array( |
---|
| 80 | 'name' => 'id_prefix', |
---|
| 81 | 'type' => 'foreign', |
---|
| 82 | 'association' => array( |
---|
| 83 | 'table' => 'phpgw_cc_prefixes', |
---|
| 84 | 'field' => 'id_prefix'), |
---|
| 85 | 'state' => 'empty', |
---|
| 86 | 'value' => false), |
---|
| 87 | 'given_names' => array( |
---|
| 88 | 'name' => 'given_names', |
---|
| 89 | 'type' => false, |
---|
| 90 | 'state' => 'empty', |
---|
| 91 | 'value' => false), |
---|
| 92 | 'family_names' => array( |
---|
| 93 | 'name' => 'family_names', |
---|
| 94 | 'type' => false, |
---|
| 95 | 'state' => 'empty', |
---|
| 96 | 'value' => false), |
---|
| 97 | 'names_ordered' => array( |
---|
| 98 | 'name' => 'names_ordered', |
---|
| 99 | 'type' => false, |
---|
| 100 | 'state' => 'empty', |
---|
| 101 | 'value' => false), |
---|
| 102 | 'id_suffix' => array( |
---|
| 103 | 'name' => 'id_suffix', |
---|
| 104 | 'type' => 'foreign', |
---|
| 105 | 'association' => array( |
---|
| 106 | 'table' => 'phpgw_cc_suffixes', |
---|
| 107 | 'field' => 'id_suffix'), |
---|
| 108 | 'state' => 'empty', |
---|
| 109 | 'value' => false), |
---|
| 110 | 'birthdate' => array( |
---|
| 111 | 'name' => 'birthdate', |
---|
| 112 | 'type' => false, |
---|
| 113 | 'state' => 'empty', |
---|
| 114 | 'value' => false), |
---|
| 115 | 'sex' => array( |
---|
| 116 | 'name' => 'sex', |
---|
| 117 | 'type' => false, |
---|
| 118 | 'state' => 'empty', |
---|
| 119 | 'value' => false), |
---|
| 120 | 'pgp_key' => array( |
---|
| 121 | 'name' => 'pgp_key', |
---|
| 122 | 'type' => false, |
---|
| 123 | 'state' => 'empty', |
---|
| 124 | 'value' => false), |
---|
| 125 | 'notes' => array( |
---|
| 126 | 'name' => 'notes', |
---|
| 127 | 'type' => false, |
---|
| 128 | 'state' => 'empty', |
---|
| 129 | 'value' => false), |
---|
| 130 | 'is_global' => array( |
---|
| 131 | 'name' => 'is_global', |
---|
| 132 | 'type' => false, |
---|
| 133 | 'state' => 'empty', |
---|
| 134 | 'value' => false), |
---|
| 135 | 'last_status' => array( |
---|
| 136 | 'name' => 'last_status', |
---|
| 137 | 'type' => false, |
---|
| 138 | 'state' => 'empty', |
---|
| 139 | 'value' => false), |
---|
| 140 | 'last_update' => array( |
---|
| 141 | 'name' => 'last_update', |
---|
| 142 | 'type' => false, |
---|
| 143 | 'state' => 'empty', |
---|
| 144 | 'value' => false)); |
---|
| 145 | |
---|
| 146 | $this->companies = array( |
---|
| 147 | 'id_contact' => array( |
---|
| 148 | 'name' => 'id_contact', |
---|
| 149 | 'type' => array('foreign', 'primary'), |
---|
| 150 | 'association' => array( |
---|
| 151 | 'table' => 'phpgw_cc_contact', |
---|
| 152 | 'field' => 'id_contact' |
---|
| 153 | ), |
---|
| 154 | 'states' => array(), |
---|
| 155 | 'values' => array() |
---|
| 156 | ), |
---|
| 157 | 'id_company' => array( |
---|
| 158 | 'name' => 'id_company', |
---|
| 159 | 'type' => array('foreign', 'primary'), |
---|
| 160 | 'association' => array( |
---|
| 161 | 'table' => 'phpgw_cc_company', |
---|
| 162 | 'field' => 'id_company' |
---|
| 163 | ), |
---|
| 164 | 'states' => array(), |
---|
| 165 | 'values' => array() |
---|
| 166 | ), |
---|
| 167 | 'title' => array( |
---|
| 168 | 'name' => 'title', |
---|
| 169 | 'type' => false, |
---|
| 170 | 'states' => array(), |
---|
| 171 | 'values' => array() |
---|
| 172 | ), |
---|
| 173 | 'department' => array( |
---|
| 174 | 'name' => 'department', |
---|
| 175 | 'type' => false, |
---|
| 176 | 'states' => array(), |
---|
| 177 | 'values' => array() |
---|
| 178 | ), |
---|
| 179 | 'default_contact' => array( |
---|
| 180 | 'name' => 'default_contact', |
---|
| 181 | 'type' => false, |
---|
| 182 | 'states' => array(), |
---|
| 183 | 'values' => array() |
---|
| 184 | ), |
---|
| 185 | 'default_company' => array( |
---|
| 186 | 'name' => 'default_company', |
---|
| 187 | 'type' => false, |
---|
| 188 | 'states' => array(), |
---|
| 189 | 'values' => array() |
---|
| 190 | ) |
---|
| 191 | ); |
---|
| 192 | |
---|
| 193 | $this->addresses = array( |
---|
| 194 | 'id_contact' => array( |
---|
| 195 | 'name' => 'id_contact', |
---|
| 196 | 'type' => array('foreign', 'primary'), |
---|
| 197 | 'association' => array( |
---|
| 198 | 'table' => 'phpgw_cc_contact', |
---|
| 199 | 'field' => 'id_contact'), |
---|
| 200 | 'states' => array(), |
---|
| 201 | 'values' => array()), |
---|
| 202 | 'id_address' => array( |
---|
| 203 | 'name' => 'id_address', |
---|
| 204 | 'type' => array('foreign', 'primary'), |
---|
| 205 | 'association' => array( |
---|
| 206 | 'table' => 'phpgw_cc_addresses', |
---|
| 207 | 'field' => 'id_address'), |
---|
| 208 | 'states' => array(), |
---|
| 209 | 'values' => array()), |
---|
| 210 | 'id_typeof_contact_address' => array( |
---|
| 211 | 'name' => 'id_typeof_contact_address', |
---|
| 212 | 'type' => 'foreign', |
---|
| 213 | 'association' => array( |
---|
| 214 | 'table' => 'phpgw_cc_typeof_ct_addrs', |
---|
| 215 | 'field' => 'id_typeof_contact_address'), |
---|
| 216 | 'states' => array(), |
---|
| 217 | 'values' => array())); |
---|
| 218 | |
---|
| 219 | |
---|
| 220 | $this->connections = array( |
---|
| 221 | 'id_contact' => array( |
---|
| 222 | 'name' => 'id_contact', |
---|
| 223 | 'type' => array('foreign', 'primary'), |
---|
| 224 | 'association' => array( |
---|
| 225 | 'table' => 'phpgw_cc_contact', |
---|
| 226 | 'field' => 'id_contact'), |
---|
| 227 | 'states' => array(), |
---|
| 228 | 'values' => array()), |
---|
| 229 | 'id_connection' => array( |
---|
| 230 | 'name' => 'id_connection', |
---|
| 231 | 'type' => array('foreign', 'primary'), |
---|
| 232 | 'association' => array( |
---|
| 233 | 'table' => 'phpgw_cc_connections', |
---|
| 234 | 'field' => 'id_connection'), |
---|
| 235 | 'states' => array(), |
---|
| 236 | 'values' => array()), |
---|
| 237 | 'id_typeof_contact_connection' => array( |
---|
| 238 | 'name' => 'id_typeof_contact_connection', |
---|
| 239 | 'type' => array('foreign', 'primary'), |
---|
| 240 | 'association' => array( |
---|
| 241 | 'table' => 'phpgw_cc_typeof_ct_conns', |
---|
| 242 | 'field' => 'id_typeof_contact_connection'), |
---|
| 243 | 'states' => array(), |
---|
| 244 | 'values' => array())); |
---|
| 245 | |
---|
| 246 | $this->relations = array( |
---|
| 247 | 'id_contact' => array( |
---|
| 248 | 'name' => 'id_contact', |
---|
| 249 | 'type' => array('foreign', 'primary'), |
---|
| 250 | 'association' => array( |
---|
| 251 | 'table' => 'phpgw_cc_contact', |
---|
| 252 | 'field' => 'id_contact' |
---|
| 253 | ), |
---|
| 254 | 'states' => array(), |
---|
| 255 | 'values' => array() |
---|
| 256 | ), |
---|
| 257 | 'id_related' => array( |
---|
| 258 | 'name' => 'id_related', |
---|
| 259 | 'type' => array('foreign', 'primary'), |
---|
| 260 | 'association' => array( |
---|
| 261 | 'table' => 'phpgw_cc_contact', |
---|
| 262 | 'field' => 'id_contact' |
---|
| 263 | ), |
---|
| 264 | 'states' => array(), |
---|
| 265 | 'values' => array() |
---|
| 266 | ), |
---|
| 267 | 'id_typeof_contact_relation' => array( |
---|
| 268 | 'name' => 'id_typeof_contact_relation', |
---|
| 269 | 'type' => array('foreign', 'primary'), |
---|
| 270 | 'association' => array( |
---|
| 271 | 'table' => 'phpgw_cc_typeof_ct_rels', |
---|
| 272 | 'field' => 'id_typeof_contact_relation' |
---|
| 273 | ), |
---|
| 274 | 'states' => array(), |
---|
| 275 | 'values' => array() |
---|
| 276 | ) |
---|
| 277 | ); |
---|
| 278 | $this->relateds = array( |
---|
| 279 | 'id_related' => array( |
---|
| 280 | 'name' => 'id_related', |
---|
| 281 | 'type' => array('foreign', 'primary'), |
---|
| 282 | 'association' => array( |
---|
| 283 | 'table' => 'phpgw_cc_contact', |
---|
| 284 | 'field' => 'id_contact' |
---|
| 285 | ), |
---|
| 286 | 'states' => array(), |
---|
| 287 | 'values' => array() |
---|
| 288 | ), |
---|
| 289 | 'id_contact' => array( |
---|
| 290 | 'name' => 'id_contact', |
---|
| 291 | 'type' => array('foreign', 'primary'), |
---|
| 292 | 'association' => array( |
---|
| 293 | 'table' => 'phpgw_cc_contact', |
---|
| 294 | 'field' => 'id_contact' |
---|
| 295 | ), |
---|
| 296 | 'states' => array(), |
---|
| 297 | 'values' => array() |
---|
| 298 | ), |
---|
| 299 | 'id_typeof_contact_relation' => array( |
---|
| 300 | 'name' => 'id_typeof_contact_relation', |
---|
| 301 | 'type' => array('foreign', 'primary'), |
---|
| 302 | 'association' => array( |
---|
| 303 | 'table' => 'phpgw_cc_typeof_ct_rels', |
---|
| 304 | 'field' => 'id_typeof_contact_relation' |
---|
| 305 | ), |
---|
| 306 | 'states' => array(), |
---|
| 307 | 'values' => array() |
---|
| 308 | ) |
---|
| 309 | ); |
---|
| 310 | |
---|
| 311 | |
---|
| 312 | $this->db_tables = array( |
---|
| 313 | 'phpgw_cc_contact' => array( |
---|
| 314 | 'type' => 'main', |
---|
| 315 | 'keys' => array( |
---|
| 316 | 'primary' => array(&$this->main_fields['id_contact']), |
---|
| 317 | 'foreign' => array( |
---|
| 318 | &$this->main_fields['id_status'], |
---|
| 319 | &$this->main_fields['id_prefix'], |
---|
| 320 | &$this->main_fields['id_suffix'])), |
---|
| 321 | 'fields' => & $this->main_fields), |
---|
| 322 | 'phpgw_cc_contact_company' => array( |
---|
| 323 | 'type' => 'multi', |
---|
| 324 | 'keys' => array( |
---|
| 325 | 'primary' => array( |
---|
| 326 | &$this->companies['id_contact'], |
---|
| 327 | &$this->companies['id_company']), |
---|
| 328 | 'foreign' => array( |
---|
| 329 | &$this->companies['id_contact'], |
---|
| 330 | &$this->companies['id_company'])), |
---|
| 331 | 'fields' => & $this->companies), |
---|
| 332 | 'phpgw_cc_contact_rels' => array( |
---|
| 333 | 'type' => 'multi', |
---|
| 334 | 'keys' => array( |
---|
| 335 | 'primary' => array( |
---|
| 336 | &$this->relations['id_contact'], |
---|
| 337 | &$this->relations['id_related']), |
---|
| 338 | 'foreign' => array( |
---|
| 339 | &$this->relations['id_contact'], |
---|
| 340 | &$this->relations['id_related'])), |
---|
| 341 | 'fields' => & $this->relations), |
---|
| 342 | 'phpgw_cc_contact_addrs' => array( |
---|
| 343 | 'type' => 'multi', |
---|
| 344 | 'keys' => array( |
---|
| 345 | 'primary' => array( |
---|
| 346 | &$this->addresses['id_contact'], |
---|
| 347 | &$this->addresses['id_address']), |
---|
| 348 | 'foreign' => array( |
---|
| 349 | &$this->addresses['id_contact'], |
---|
| 350 | &$this->addresses['id_address'], |
---|
| 351 | &$this->addresses['id_typeof_contact_address'])), |
---|
| 352 | 'fields' => & $this->addresses), |
---|
| 353 | 'phpgw_cc_contact_conns' => array( |
---|
| 354 | 'type' => 'multi', |
---|
| 355 | 'keys' => array( |
---|
| 356 | 'primary' => array( |
---|
| 357 | &$this->connections['id_contact'], |
---|
| 358 | &$this->connections['id_connection']), |
---|
| 359 | 'foreign' => array( |
---|
| 360 | &$this->connections['id_contact'], |
---|
| 361 | &$this->connections['id_connection'], |
---|
| 362 | &$this->connections['id_typeof_contact_connection'])), |
---|
| 363 | 'fields' => & $this->connections)); |
---|
| 364 | |
---|
| 365 | |
---|
| 366 | if ($id_contact) |
---|
| 367 | { |
---|
| 368 | $this->id = $id_contact; |
---|
| 369 | if (!$this->checkout($id_contact)) |
---|
| 370 | { |
---|
| 371 | $this->reset_values(); |
---|
| 372 | $this->state = 'new'; |
---|
| 373 | } |
---|
| 374 | $temp = $this->db_tables; |
---|
| 375 | |
---|
| 376 | $this->db_tables = array(); //Limpo o array para fazer checkout apenas dos contatos relacionados |
---|
| 377 | $this->db_tables['phpgw_cc_contact_rels'] = array( |
---|
| 378 | 'type' => 'multi', |
---|
| 379 | 'keys' => array( |
---|
| 380 | 'primary' => array( |
---|
| 381 | &$this->relateds['id_related']), |
---|
| 382 | &$this->relateds['id_contact'], |
---|
| 383 | 'foreign' => array( |
---|
| 384 | &$this->relateds['id_related'])), |
---|
| 385 | &$this->relateds['id_contact'], |
---|
| 386 | 'fields' => & $this->relateds); |
---|
| 387 | if (!$this->checkout($id_contact)) |
---|
| 388 | { |
---|
| 389 | $this->reset_values(); |
---|
| 390 | $this->state = 'new'; |
---|
| 391 | } |
---|
| 392 | $this->db_tables = $temp; //Coloco o valor do array antigo. |
---|
| 393 | } |
---|
| 394 | else |
---|
| 395 | { |
---|
| 396 | $this->state = 'new'; |
---|
| 397 | } |
---|
| 398 | |
---|
| 399 | } |
---|
| 400 | |
---|
| 401 | /*********************************************************************\ |
---|
| 402 | * Methods to Obtain Data * |
---|
| 403 | \*********************************************************************/ |
---|
| 404 | |
---|
| 405 | /*! |
---|
| 406 | |
---|
| 407 | @function get_photo |
---|
| 408 | @abstract Returns the Contact's photo binary string |
---|
| 409 | @author Raphael Derosso Pereira |
---|
| 410 | |
---|
| 411 | */ |
---|
| 412 | function get_photo ( ) |
---|
| 413 | { |
---|
| 414 | return $this->main_fields['photo']['value']; |
---|
| 415 | } |
---|
| 416 | |
---|
| 417 | /*! |
---|
| 418 | |
---|
| 419 | @function get_alias |
---|
| 420 | @abstract Returns the Contact alias |
---|
| 421 | @author Raphael Derosso Pereira |
---|
| 422 | |
---|
| 423 | */ |
---|
| 424 | function get_alias ( ) |
---|
| 425 | { |
---|
| 426 | return $this->main_fields['alias']['value']; |
---|
| 427 | } |
---|
| 428 | |
---|
| 429 | /*! |
---|
| 430 | |
---|
| 431 | @function get_prefix |
---|
| 432 | @abstract Returns the Contact prefix ID |
---|
| 433 | @author Raphael Derosso Pereira |
---|
| 434 | |
---|
| 435 | */ |
---|
| 436 | function get_prefix ( ) |
---|
| 437 | { |
---|
| 438 | return $this->main_fields['id_prefix']['value']; |
---|
| 439 | } |
---|
| 440 | |
---|
| 441 | /*! |
---|
| 442 | |
---|
| 443 | @function get_corporate_name |
---|
| 444 | @abstract Returns the Contact corporate_name |
---|
| 445 | @author David Buarque |
---|
| 446 | |
---|
| 447 | */ |
---|
| 448 | function get_corporate_name ( ) |
---|
| 449 | { |
---|
| 450 | return $this->main_fields['corporate_name']['value']; |
---|
| 451 | } |
---|
| 452 | |
---|
| 453 | /*! |
---|
| 454 | |
---|
| 455 | @function get_job_title |
---|
| 456 | @abstract Returns the Contact job_title |
---|
| 457 | @author David Buarque |
---|
| 458 | |
---|
| 459 | */ |
---|
| 460 | function get_job_title ( ) |
---|
| 461 | { |
---|
| 462 | return $this->main_fields['job_title']['value']; |
---|
| 463 | } |
---|
| 464 | |
---|
| 465 | /*! |
---|
| 466 | |
---|
| 467 | @function get_department |
---|
| 468 | @abstract Returns the Contact department |
---|
| 469 | @author David Buarque |
---|
| 470 | |
---|
| 471 | */ |
---|
| 472 | function get_department ( ) |
---|
| 473 | { |
---|
| 474 | return $this->main_fields['department']['value']; |
---|
| 475 | } |
---|
| 476 | |
---|
| 477 | /*! |
---|
| 478 | |
---|
| 479 | @function get_web_page |
---|
| 480 | @abstract Returns the Contact web_page |
---|
| 481 | @author David Buarque |
---|
| 482 | |
---|
| 483 | */ |
---|
| 484 | function get_web_page ( ) |
---|
| 485 | { |
---|
| 486 | return $this->main_fields['web_page']['value']; |
---|
| 487 | } |
---|
| 488 | |
---|
| 489 | /*! |
---|
| 490 | |
---|
| 491 | @function get_given_names |
---|
| 492 | @abstract Returns the Contact's given names |
---|
| 493 | @author Raphael Derosso Pereira |
---|
| 494 | |
---|
| 495 | */ |
---|
| 496 | function get_given_names ( ) |
---|
| 497 | { |
---|
| 498 | return $this->main_fields['given_names']['value']; |
---|
| 499 | } |
---|
| 500 | |
---|
| 501 | /*! |
---|
| 502 | |
---|
| 503 | @function get_family_names |
---|
| 504 | @abstract Returns the Contact's family names |
---|
| 505 | @author Raphael Derosso Pereira |
---|
| 506 | |
---|
| 507 | */ |
---|
| 508 | function get_family_names ( ) |
---|
| 509 | { |
---|
| 510 | return $this->main_fields['family_names']['value']; |
---|
| 511 | } |
---|
| 512 | |
---|
| 513 | /*! |
---|
| 514 | |
---|
| 515 | @function get_names_ordered |
---|
| 516 | @abstract Returns the Contact's names ordered |
---|
| 517 | @author Raphael Derosso Pereira |
---|
| 518 | |
---|
| 519 | */ |
---|
| 520 | function get_names_ordered ( ) |
---|
| 521 | { |
---|
| 522 | return $this->main_fields['names_ordered']['value']; |
---|
| 523 | } |
---|
| 524 | |
---|
| 525 | /*! |
---|
| 526 | |
---|
| 527 | @function get_suffix |
---|
| 528 | @abstract Returns the Contact's suffix |
---|
| 529 | @author Raphael Derosso Pereira |
---|
| 530 | |
---|
| 531 | */ |
---|
| 532 | function get_suffix ( ) |
---|
| 533 | { |
---|
| 534 | return $this->main_fields['id_suffix']['value']; |
---|
| 535 | } |
---|
| 536 | |
---|
| 537 | /*! |
---|
| 538 | |
---|
| 539 | @function get_birthdate |
---|
| 540 | @abstract Returns the Contact's birthdata |
---|
| 541 | @author Raphael Derosso Pereira |
---|
| 542 | |
---|
| 543 | */ |
---|
| 544 | function get_birthdate ( ) |
---|
| 545 | { |
---|
| 546 | return $this->main_fields['birthdate']['value']; |
---|
| 547 | } |
---|
| 548 | |
---|
| 549 | /*! |
---|
| 550 | |
---|
| 551 | @function get_sex |
---|
| 552 | @abstract Returns the Contact's sex |
---|
| 553 | @author Raphael Derosso Pereira |
---|
| 554 | |
---|
| 555 | */ |
---|
| 556 | function get_sex ( ) |
---|
| 557 | { |
---|
| 558 | return $this->main_fields['sex']['value']; |
---|
| 559 | } |
---|
| 560 | |
---|
| 561 | /*! |
---|
| 562 | |
---|
| 563 | @function get_pgp_key |
---|
| 564 | @abstract Returns the Contact's PGP Key |
---|
| 565 | @author Raphael Derosso Pereira |
---|
| 566 | |
---|
| 567 | */ |
---|
| 568 | function get_pgp_key ( ) |
---|
| 569 | { |
---|
| 570 | return $this->main_fields['pgp_key']['value']; |
---|
| 571 | } |
---|
| 572 | |
---|
| 573 | /*! |
---|
| 574 | |
---|
| 575 | @function get_notes |
---|
| 576 | @abstract Returns the Contact's notes |
---|
| 577 | @author Raphael Derosso Pereira |
---|
| 578 | |
---|
| 579 | */ |
---|
| 580 | function get_notes ( ) |
---|
| 581 | { |
---|
| 582 | return $this->main_fields['notes']['value']; |
---|
| 583 | } |
---|
| 584 | |
---|
| 585 | /*! |
---|
| 586 | |
---|
| 587 | @function get_status |
---|
| 588 | @abstract Returns the Contact's status ID |
---|
| 589 | @author Raphael Derosso Pereira |
---|
| 590 | |
---|
| 591 | */ |
---|
| 592 | function get_status ( ) |
---|
| 593 | { |
---|
| 594 | return $this->main_fields['status']['value']; |
---|
| 595 | } |
---|
| 596 | |
---|
| 597 | /*! |
---|
| 598 | |
---|
| 599 | @function get_relations |
---|
| 600 | @abstract Returns the Contact's Relations |
---|
| 601 | @author Raphael Derosso Pereira |
---|
| 602 | |
---|
| 603 | @return array Format: |
---|
| 604 | $return = array( |
---|
| 605 | '<id_related1>' => '<id_relation1_type>', |
---|
| 606 | '<id_related2>' => '<id_relation2_type>', |
---|
| 607 | ...); |
---|
| 608 | */ |
---|
| 609 | function get_relations ( ) |
---|
| 610 | { |
---|
| 611 | $return = array(); |
---|
| 612 | |
---|
| 613 | reset($this->relations['id_related']['values']); |
---|
| 614 | reset($this->relations['id_typeof_contact_relation']['values']); |
---|
| 615 | while(list(,$id_related) = each($this->relations['id_related']['values']) and |
---|
| 616 | list(,$id_relation_type) = each($this->relations['id_typeof_contact_relation']['values'])) |
---|
| 617 | { |
---|
| 618 | $return[$id_related] = $id_relation_type; |
---|
| 619 | } |
---|
| 620 | |
---|
| 621 | return $return; |
---|
| 622 | } |
---|
| 623 | |
---|
| 624 | function get_relateds() { |
---|
| 625 | $return = array(); |
---|
| 626 | |
---|
| 627 | reset($this->relateds['id_contact']['values']); |
---|
| 628 | reset($this->relateds['id_typeof_contact_relation']['values']); |
---|
| 629 | while(list(,$id_relation) = each($this->relateds['id_contact']['values']) and |
---|
| 630 | list(,$id_relation_type) = each($this->relateds['id_typeof_contact_relation']['values'])) |
---|
| 631 | { |
---|
| 632 | $return[$id_relation] = $id_relation_type; |
---|
| 633 | } |
---|
| 634 | return $return; |
---|
| 635 | } |
---|
| 636 | |
---|
| 637 | /*! |
---|
| 638 | |
---|
| 639 | @function get_addresses |
---|
| 640 | @abstract Returns the Contact's Addresses |
---|
| 641 | @author Raphael Derosso Pereira |
---|
| 642 | |
---|
| 643 | @return array Format: |
---|
| 644 | $return = array( |
---|
| 645 | '<id_address1>' => '<id_address1_type>', |
---|
| 646 | '<id_address2>' => '<id_address2_type>', |
---|
| 647 | ...); |
---|
| 648 | */ |
---|
| 649 | function get_addresses ( ) |
---|
| 650 | { |
---|
| 651 | $return = array(); |
---|
| 652 | |
---|
| 653 | reset($this->addresses['id_address']['values']); |
---|
| 654 | reset($this->addresses['id_typeof_contact_address']['values']); |
---|
| 655 | while(list(,$id_address) = each($this->addresses['id_address']['values']) and |
---|
| 656 | list(,$id_address_type) = each($this->addresses['id_typeof_contact_address']['values'])) |
---|
| 657 | { |
---|
| 658 | $return[$id_address] = $id_address_type; |
---|
| 659 | } |
---|
| 660 | |
---|
| 661 | return $return; |
---|
| 662 | } |
---|
| 663 | |
---|
| 664 | /*! |
---|
| 665 | |
---|
| 666 | @function get_connections |
---|
| 667 | @abstract Returns the Contact's Connections |
---|
| 668 | @author Raphael Derosso Pereira |
---|
| 669 | |
---|
| 670 | @return array Format: |
---|
| 671 | $return = array( |
---|
| 672 | '<id_connection1>' => '<id_connection1_type>', |
---|
| 673 | '<id_connection2>' => '<id_connection2_type>', |
---|
| 674 | ...); |
---|
| 675 | */ |
---|
| 676 | function get_connections ( ) |
---|
| 677 | { |
---|
| 678 | $return = array(); |
---|
| 679 | |
---|
| 680 | reset($this->connections['id_connection']['values']); |
---|
| 681 | reset($this->connections['id_typeof_contact_connection']['values']); |
---|
| 682 | while(list(,$id_connection) = each($this->connections['id_connection']['values']) and |
---|
| 683 | list(,$id_connection_type) = each($this->connections['id_typeof_contact_connection']['values'])) |
---|
| 684 | { |
---|
| 685 | $return[$id_connection] = $id_connection_type; |
---|
| 686 | } |
---|
| 687 | |
---|
| 688 | return $return; |
---|
| 689 | } |
---|
| 690 | |
---|
| 691 | /*! |
---|
| 692 | |
---|
| 693 | @function get_companies |
---|
| 694 | @abstract Returns the Contact's Companies IDs and |
---|
| 695 | bussiness info |
---|
| 696 | @author Raphael Derosso Pereira |
---|
| 697 | |
---|
| 698 | @return array Format: |
---|
| 699 | $return = array( |
---|
| 700 | '<id_company1>' => array( |
---|
| 701 | 'title' => '<title>', |
---|
| 702 | 'department' => '<department>' |
---|
| 703 | ), |
---|
| 704 | '<id_company2>' => array( |
---|
| 705 | 'title' => '<title>', |
---|
| 706 | 'department' => '<department>' |
---|
| 707 | ), |
---|
| 708 | ... |
---|
| 709 | ); |
---|
| 710 | |
---|
| 711 | */ |
---|
| 712 | function get_companies ( ) |
---|
| 713 | { |
---|
| 714 | $return = array(); |
---|
| 715 | |
---|
| 716 | reset($this->companies['id_company']['values']); |
---|
| 717 | reset($this->companies['title']['values']); |
---|
| 718 | reset($this->companies['department']['values']); |
---|
| 719 | reset($this->companies['default_company']['values']); |
---|
| 720 | reset($this->companies['default_contact']['values']); |
---|
| 721 | while(list(,$id_company) = each($this->companies['id_company']['values']) and |
---|
| 722 | list(,$title) = each($this->companies['title']['values']) and |
---|
| 723 | list(,$department) = each($this->companies['department']['values']) and |
---|
| 724 | list(,$default_company) = each($this->companies['default_company']['values']) and |
---|
| 725 | list(,$default_contact) = each($this->companies['default_contact']['values'])) |
---|
| 726 | { |
---|
| 727 | $return[$id_company] = array( |
---|
| 728 | 'title' => $title, |
---|
| 729 | 'department' => $department, |
---|
| 730 | 'default_company' => $default_company, |
---|
| 731 | 'default_contact' => $default_contact, |
---|
| 732 | ); |
---|
| 733 | } |
---|
| 734 | |
---|
| 735 | return $return; |
---|
| 736 | } |
---|
| 737 | |
---|
| 738 | /*********************************************************************\ |
---|
| 739 | * Methods to Alter Data * |
---|
| 740 | \*********************************************************************/ |
---|
| 741 | |
---|
| 742 | |
---|
| 743 | /*! |
---|
| 744 | |
---|
| 745 | @function set_photo |
---|
| 746 | @abstract Sets the Contact's Photo binary string |
---|
| 747 | @author Raphael Derosso Pereira |
---|
| 748 | @param string $photo The binary photo string |
---|
| 749 | |
---|
| 750 | */ |
---|
| 751 | function set_photo ( $photo ) |
---|
| 752 | { |
---|
| 753 | $this->main_fields['photo']['value'] = $photo; |
---|
| 754 | $this->manage_fields($this->main_fields['photo'], 'changed'); |
---|
| 755 | } |
---|
| 756 | |
---|
| 757 | /*! |
---|
| 758 | |
---|
| 759 | @function set_alias |
---|
| 760 | @abstract Sets the Contact's Alias |
---|
| 761 | @author Raphael Derosso Pereira |
---|
| 762 | @param string $alias The new Contact alias |
---|
| 763 | |
---|
| 764 | */ |
---|
| 765 | function set_alias ( $alias ) |
---|
| 766 | { |
---|
| 767 | $this->main_fields['alias']['value'] = $alias; |
---|
| 768 | $this->manage_fields($this->main_fields['alias'], 'changed'); |
---|
| 769 | } |
---|
| 770 | |
---|
| 771 | /*! |
---|
| 772 | |
---|
| 773 | @function set_corporate_name |
---|
| 774 | @abstract Sets the Contact's corporate_name |
---|
| 775 | @author David Buaque |
---|
| 776 | @param string $corporate_name The new Contact corporate_name |
---|
| 777 | |
---|
| 778 | */ |
---|
| 779 | function set_corporate_name ( $corporate_name ) |
---|
| 780 | { |
---|
| 781 | $this->main_fields['corporate_name']['value'] = $corporate_name; |
---|
| 782 | $this->manage_fields($this->main_fields['corporate_name'], 'changed'); |
---|
| 783 | } |
---|
| 784 | |
---|
| 785 | /*! |
---|
| 786 | |
---|
| 787 | @function set_job_title |
---|
| 788 | @abstract Sets the Contact's job_title |
---|
| 789 | @author David Buaque |
---|
| 790 | @param string $alias The new Contact job_title |
---|
| 791 | |
---|
| 792 | */ |
---|
| 793 | function set_job_title ( $job_title ) |
---|
| 794 | { |
---|
| 795 | $this->main_fields['job_title']['value'] = $job_title; |
---|
| 796 | $this->manage_fields($this->main_fields['job_title'], 'changed'); |
---|
| 797 | } |
---|
| 798 | |
---|
| 799 | /*! |
---|
| 800 | |
---|
| 801 | @function set_department |
---|
| 802 | @abstract Sets the Contact's department |
---|
| 803 | @author David Buaque |
---|
| 804 | @param string $alias The new Contact department |
---|
| 805 | |
---|
| 806 | */ |
---|
| 807 | function set_department ( $department ) |
---|
| 808 | { |
---|
| 809 | $this->main_fields['department']['value'] = $department; |
---|
| 810 | $this->manage_fields($this->main_fields['department'], 'changed'); |
---|
| 811 | } |
---|
| 812 | |
---|
| 813 | /*! |
---|
| 814 | |
---|
| 815 | @function set_web_page |
---|
| 816 | @abstract Sets the Contact's web_page |
---|
| 817 | @author David Buaque |
---|
| 818 | @param string $alias The new Contact web_page |
---|
| 819 | |
---|
| 820 | */ |
---|
| 821 | function set_web_page ( $web_page ) |
---|
| 822 | { |
---|
| 823 | $this->main_fields['web_page']['value'] = $web_page; |
---|
| 824 | $this->manage_fields($this->main_fields['web_page'], 'changed'); |
---|
| 825 | } |
---|
| 826 | |
---|
| 827 | /*! |
---|
| 828 | |
---|
| 829 | @function set_id_prefix |
---|
| 830 | @abstract Sets the Contact's Prefix |
---|
| 831 | @author Raphael Derosso Pereira |
---|
| 832 | @param string $id_prefix The new Contact prefix ID |
---|
| 833 | |
---|
| 834 | */ |
---|
| 835 | function set_id_prefix ( $id_prefix ) |
---|
| 836 | { |
---|
| 837 | $this->main_fields['prefix']['value'] = $id_prefix; |
---|
| 838 | $this->manage_fields($this->main_fields['prefix'], 'changed'); |
---|
| 839 | } |
---|
| 840 | |
---|
| 841 | /*! |
---|
| 842 | |
---|
| 843 | @function set_given_names |
---|
| 844 | @abstract Sets the Contact's Given Names |
---|
| 845 | @author Raphael Derosso Pereira |
---|
| 846 | @param string $names The new Contact's Given Names |
---|
| 847 | |
---|
| 848 | */ |
---|
| 849 | function set_given_names ( $names ) |
---|
| 850 | { |
---|
| 851 | $this->main_fields['given_names']['value'] = $names; |
---|
| 852 | $this->manage_fields($this->main_fields['given_names'], 'changed'); |
---|
| 853 | } |
---|
| 854 | |
---|
| 855 | /*! |
---|
| 856 | |
---|
| 857 | @function set_family_names |
---|
| 858 | @abstract Sets the Contact's Family Names |
---|
| 859 | @author Raphael Derosso Pereira |
---|
| 860 | @param string $names The new Contact's Family Names |
---|
| 861 | |
---|
| 862 | */ |
---|
| 863 | function set_family_names ( $names ) |
---|
| 864 | { |
---|
| 865 | $this->main_fields['family_names']['value'] = $names; |
---|
| 866 | $this->manage_fields($this->main_fields['family_names'], 'changed'); |
---|
| 867 | } |
---|
| 868 | |
---|
| 869 | /*! |
---|
| 870 | |
---|
| 871 | @function set_names_ordered |
---|
| 872 | @abstract Sets the Contact's Names Ordered |
---|
| 873 | @author Raphael Derosso Pereira |
---|
| 874 | @param string $names The new Contact's Names Ordered |
---|
| 875 | |
---|
| 876 | */ |
---|
| 877 | function set_names_ordered ( $names ) |
---|
| 878 | { |
---|
| 879 | $this->main_fields['names_ordered']['value'] = $names; |
---|
| 880 | $this->manage_fields($this->main_fields['names_ordered'], 'changed'); |
---|
| 881 | } |
---|
| 882 | |
---|
| 883 | /*! |
---|
| 884 | |
---|
| 885 | @function set_id_suffix |
---|
| 886 | @abstract Sets the Contact's Sulfix |
---|
| 887 | @author Raphael Derosso Pereira |
---|
| 888 | @param string $id_suffix The new Contact's Sulfix |
---|
| 889 | |
---|
| 890 | */ |
---|
| 891 | function set_id_suffix ( $id_suffix ) |
---|
| 892 | { |
---|
| 893 | $this->main_fields['suffix']['value'] = $names; |
---|
| 894 | $this->manage_fields($this->main_fields['suffix'], 'changed'); |
---|
| 895 | } |
---|
| 896 | |
---|
| 897 | /*! |
---|
| 898 | |
---|
| 899 | @function set_birthdate |
---|
| 900 | @abstract Sets the Contact's Birthdate |
---|
| 901 | @author Raphael Derosso Pereira |
---|
| 902 | @param string $date The new Contact's Birthdate |
---|
| 903 | |
---|
| 904 | */ |
---|
| 905 | function set_birthdate ( $date ) |
---|
| 906 | { |
---|
| 907 | $this->main_fields['birthdate']['value'] = $names; |
---|
| 908 | $this->manage_fields($this->main_fields['birthdate'], 'changed'); |
---|
| 909 | } |
---|
| 910 | |
---|
| 911 | /*! |
---|
| 912 | |
---|
| 913 | @function set_sex |
---|
| 914 | @abstract Sets the Contact's Sex |
---|
| 915 | @author Raphael Derosso Pereira |
---|
| 916 | @param string $sex The new Contact's Sex |
---|
| 917 | |
---|
| 918 | */ |
---|
| 919 | function set_sex ( $sex ) |
---|
| 920 | { |
---|
| 921 | $this->main_fields['birthdate']['value'] = $names; |
---|
| 922 | $this->manage_fields($this->main_fields['birthdate'], 'changed'); |
---|
| 923 | } |
---|
| 924 | |
---|
| 925 | /*! |
---|
| 926 | |
---|
| 927 | @function set_pgp_key |
---|
| 928 | @abstract Sets the Contact's PGP Key |
---|
| 929 | @author Raphael Derosso Pereira |
---|
| 930 | @param string $pgp_key The new Contact's PGP Key |
---|
| 931 | |
---|
| 932 | */ |
---|
| 933 | function set_pgp_key ( $pgp_key ) |
---|
| 934 | { |
---|
| 935 | $this->main_fields['birthdate']['value'] = $names; |
---|
| 936 | $this->manage_fields($this->main_fields['birthdate'], 'changed'); |
---|
| 937 | } |
---|
| 938 | |
---|
| 939 | /*! |
---|
| 940 | |
---|
| 941 | @function set_notes |
---|
| 942 | @abstract Sets the Contact's Notes |
---|
| 943 | @author Raphael Derosso Pereira |
---|
| 944 | @param string $notes The new Contact's Notes |
---|
| 945 | |
---|
| 946 | */ |
---|
| 947 | function set_notes ( $notes ) |
---|
| 948 | { |
---|
| 949 | $this->main_fields['birthdate']['value'] = $names; |
---|
| 950 | $this->manage_fields($this->main_fields['birthdate'], 'changed'); |
---|
| 951 | } |
---|
| 952 | |
---|
| 953 | /*! |
---|
| 954 | |
---|
| 955 | @function set_status |
---|
| 956 | @abstract Change the Contact's set Status |
---|
| 957 | @author Raphael Derosso Pereira |
---|
| 958 | @param integer $id_status The new Contact's set Status |
---|
| 959 | |
---|
| 960 | */ |
---|
| 961 | function set_id_status ( $id_status ) |
---|
| 962 | { |
---|
| 963 | $this->main_fields['id_status']['value'] = $names; |
---|
| 964 | $this->manage_fields($this->main_fields['id_status'], 'changed'); |
---|
| 965 | } |
---|
| 966 | |
---|
| 967 | /*! |
---|
| 968 | |
---|
| 969 | @function set_relation |
---|
| 970 | @abstract Sets the Contact's Relation |
---|
| 971 | @author Raphael Derosso Pereira |
---|
| 972 | @param integer $id_related The new Contact's Relation type ID |
---|
| 973 | @param integer $id_type The new Contact's Relation ID |
---|
| 974 | |
---|
| 975 | */ |
---|
| 976 | function set_relation ( $id_related, $id_type ) |
---|
| 977 | { |
---|
| 978 | if (($pos = array_search($id_related, $this->relations['id_related']['values'])) !== false) |
---|
| 979 | { |
---|
| 980 | $this->relations['id_typeof_contact_relation']['values'][$pos] = $id_type; |
---|
| 981 | $this->manage_fields($this->relations['id_typeof_contact_relation'], 'changed', $pos); |
---|
| 982 | |
---|
| 983 | return; |
---|
| 984 | } |
---|
| 985 | |
---|
| 986 | array_push($this->relations['id_contact']['values'], & $this->id); |
---|
| 987 | array_push($this->relations['id_related']['values'], $id_related); |
---|
| 988 | array_push($this->relations['id_typeof_contact_relation']['values'], $id_type); |
---|
| 989 | |
---|
| 990 | $this->manage_fields($this->relations['id_typeof_contact_relation'], 'new', 'new'); |
---|
| 991 | $this->manage_fields($this->relations['id_related'], 'new', 'new'); |
---|
| 992 | $this->manage_fields($this->relations['id_contact'], 'new', 'new'); |
---|
| 993 | } |
---|
| 994 | |
---|
| 995 | /*! |
---|
| 996 | @function set_related |
---|
| 997 | @abstract Sets the Contact's related |
---|
| 998 | @author Raphael Derosso Pereira |
---|
| 999 | @param integer $id_related The new Contact's Relation type ID |
---|
| 1000 | @param integer $id_type The new Contact's Relation ID |
---|
| 1001 | |
---|
| 1002 | */ |
---|
| 1003 | function set_relateds ( $relations , $id_type ) |
---|
| 1004 | { |
---|
| 1005 | $id = $this->id; |
---|
| 1006 | $db = $GLOBALS['phpgw']->db; |
---|
| 1007 | |
---|
| 1008 | //Remove todos os contatos relacionados |
---|
| 1009 | $query = "delete from phpgw_cc_contact_rels where id_related=$id and id_typeof_contact_relation=1"; |
---|
| 1010 | |
---|
| 1011 | if (!$db->query($query, __LINE__, __FILE__)) { |
---|
| 1012 | return false; |
---|
| 1013 | } |
---|
| 1014 | foreach($relations as $id_relation) { |
---|
| 1015 | $query = "insert into phpgw_cc_contact_rels (id_contact,id_related,id_typeof_contact_relation) values ($id_relation,$id,$id_type)"; |
---|
| 1016 | |
---|
| 1017 | if (!$db->query($query, __LINE__, __FILE__)) { |
---|
| 1018 | return false; |
---|
| 1019 | } |
---|
| 1020 | } |
---|
| 1021 | return true; |
---|
| 1022 | } |
---|
| 1023 | |
---|
| 1024 | /*! |
---|
| 1025 | |
---|
| 1026 | @function set_address |
---|
| 1027 | @abstract Sets the Contact's Address |
---|
| 1028 | @author Raphael Derosso Pereira |
---|
| 1029 | @param integer $id_address The new Contact's Address ID |
---|
| 1030 | @param integer $id_type The new Contact's Address type ID |
---|
| 1031 | |
---|
| 1032 | */ |
---|
| 1033 | function set_address ( $id_address, $id_type ) |
---|
| 1034 | { |
---|
| 1035 | if (($pos = array_search($id_address, $this->addresses['id_address']['values'])) !== false) |
---|
| 1036 | { |
---|
| 1037 | $this->addresses['id_typeof_contact_address']['values'][$pos] = $id_type; |
---|
| 1038 | $this->manage_fields($this->addresses['id_typeof_contact_address'], 'changed', $pos); |
---|
| 1039 | |
---|
| 1040 | return; |
---|
| 1041 | } |
---|
| 1042 | |
---|
| 1043 | array_push($this->addresses['id_contact']['values'], & $this->id); |
---|
| 1044 | array_push($this->addresses['id_address']['values'], $id_address); |
---|
| 1045 | array_push($this->addresses['id_typeof_contact_address']['values'], $id_type); |
---|
| 1046 | |
---|
| 1047 | $this->manage_fields($this->addresses['id_typeof_contact_address'], 'new', 'new'); |
---|
| 1048 | $this->manage_fields($this->addresses['id_address'], 'new', 'new'); |
---|
| 1049 | $this->manage_fields($this->addresses['id_contact'], 'new', 'new'); |
---|
| 1050 | |
---|
| 1051 | } |
---|
| 1052 | |
---|
| 1053 | /*! |
---|
| 1054 | |
---|
| 1055 | @function set_connection |
---|
| 1056 | @abstract Sets the Contact's Connection |
---|
| 1057 | @author Raphael Derosso Pereira |
---|
| 1058 | @param integer $id_connection The new Contact's Connection ID |
---|
| 1059 | @param integer $id_type The new Contact's Connection type ID |
---|
| 1060 | |
---|
| 1061 | */ |
---|
| 1062 | function set_connection ( $id_connection, $id_type ) |
---|
| 1063 | { |
---|
| 1064 | if (($pos = array_search($id_connection, $this->connections['id_connection']['values'])) !== false) |
---|
| 1065 | { |
---|
| 1066 | $this->connections['id_typeof_contact_connection']['values'][$pos] = $id_type; |
---|
| 1067 | $this->manage_fields($this->connections['id_typeof_contact_connection'], 'changed', $pos); |
---|
| 1068 | |
---|
| 1069 | return; |
---|
| 1070 | } |
---|
| 1071 | |
---|
| 1072 | array_push($this->connections['id_contact']['values'], & $this->id); |
---|
| 1073 | array_push($this->connections['id_connection']['values'], $id_connection); |
---|
| 1074 | array_push($this->connections['id_typeof_contact_connection']['values'], $id_type); |
---|
| 1075 | |
---|
| 1076 | $this->manage_fields($this->connections['id_typeof_contact_connection'], 'new', 'new'); |
---|
| 1077 | $this->manage_fields($this->connections['id_connection'], 'new', 'new'); |
---|
| 1078 | $this->manage_fields($this->connections['id_contact'], 'new', 'new'); |
---|
| 1079 | } |
---|
| 1080 | |
---|
| 1081 | /*! |
---|
| 1082 | |
---|
| 1083 | @function set_company |
---|
| 1084 | @abstract Sets the Contact's Company and bussiness information |
---|
| 1085 | @author Raphael Derosso Pereira |
---|
| 1086 | @param array $company_info The new Contact's Company Information |
---|
| 1087 | |
---|
| 1088 | */ |
---|
| 1089 | function set_company ( $company_info ) |
---|
| 1090 | { |
---|
| 1091 | if (is_array($company_info)) |
---|
| 1092 | { |
---|
| 1093 | if (($pos = array_search($company_info['id_company'], $this->companies['id_company']['values'])) !== false) |
---|
| 1094 | { |
---|
| 1095 | $this->companies['title']['values'][$pos] = $company_info['title']; |
---|
| 1096 | $this->companies['department']['values'][$pos] = $company_info['department']; |
---|
| 1097 | $this->companies['default_company']['values'][$pos] = $company_info['default_company']; |
---|
| 1098 | $this->companies['default_contact']['values'][$pos] = $company_info['default_contact']; |
---|
| 1099 | |
---|
| 1100 | $this->manage_fields($this->companies['title'], 'changed', $pos); |
---|
| 1101 | $this->manage_fields($this->companies['department'], 'changed', $pos); |
---|
| 1102 | $this->manage_fields($this->companies['default_company'], 'changed', $pos); |
---|
| 1103 | $this->manage_fields($this->companies['default_contact'], 'changed', $pos); |
---|
| 1104 | |
---|
| 1105 | return true; |
---|
| 1106 | } |
---|
| 1107 | |
---|
| 1108 | array_push($this->companies['id_contact']['values'], & $this->id); |
---|
| 1109 | array_push($this->companies['id_company']['values'], $company_info['id_company']); |
---|
| 1110 | array_push($this->companies['title']['values'], $company_info['title']); |
---|
| 1111 | array_push($this->companies['department']['values'], $company_info['department']); |
---|
| 1112 | array_push($this->companies['default_company']['values'], $company_info['default_company']); |
---|
| 1113 | array_push($this->companies['default_contact']['values'], $company_info['default_contact']); |
---|
| 1114 | |
---|
| 1115 | $this->manage_fields($this->companies['id_company'], 'new', 'new'); |
---|
| 1116 | $this->manage_fields($this->companies['id_contact'], 'new', 'new'); |
---|
| 1117 | $this->manage_fields($this->companies['title'], 'new', 'new'); |
---|
| 1118 | $this->manage_fields($this->companies['department'], 'new', 'new'); |
---|
| 1119 | $this->manage_fields($this->companies['default_company'], 'new', 'new'); |
---|
| 1120 | $this->manage_fields($this->companies['default_contact'], 'new', 'new'); |
---|
| 1121 | |
---|
| 1122 | return true; |
---|
| 1123 | } |
---|
| 1124 | |
---|
| 1125 | return false; |
---|
| 1126 | } |
---|
| 1127 | |
---|
| 1128 | |
---|
| 1129 | /*********************************************************************\ |
---|
| 1130 | * Methods to Remove Data * |
---|
| 1131 | \*********************************************************************/ |
---|
| 1132 | |
---|
| 1133 | |
---|
| 1134 | /*! |
---|
| 1135 | |
---|
| 1136 | @function remove_relation |
---|
| 1137 | @abstract Remove one Contact's Relation |
---|
| 1138 | @author Raphael Derosso Pereira |
---|
| 1139 | @param integer $id_related The ID of the relation to be removed |
---|
| 1140 | |
---|
| 1141 | */ |
---|
| 1142 | function remove_relation ( $id_related ) |
---|
| 1143 | { |
---|
| 1144 | if (($pos = array_search($id_related, $this->relations['id_related']['values'])) !== false) |
---|
| 1145 | { |
---|
| 1146 | $this->manage_fields($this->relations['id_contact'], 'deleted', $pos); |
---|
| 1147 | $this->manage_fields($this->relations['id_related'], 'deleted', $pos); |
---|
| 1148 | $this->manage_fields($this->relations['id_typeof_contact_relation'], 'deleted', $pos); |
---|
| 1149 | |
---|
| 1150 | return true; |
---|
| 1151 | } |
---|
| 1152 | |
---|
| 1153 | return false; |
---|
| 1154 | } |
---|
| 1155 | |
---|
| 1156 | /*! |
---|
| 1157 | |
---|
| 1158 | @function remove_address |
---|
| 1159 | @abstract Remove one Contact's Address |
---|
| 1160 | @author Raphael Derosso Pereira |
---|
| 1161 | @param integer $id_address The ID of the address to be removed |
---|
| 1162 | |
---|
| 1163 | */ |
---|
| 1164 | function remove_address ( $id_address ) |
---|
| 1165 | { |
---|
| 1166 | if (($pos = array_search($id_address, $this->addresses['id_address']['values'])) !== false) |
---|
| 1167 | { |
---|
| 1168 | $this->manage_fields($this->addresses['id_contact'], 'deleted', $pos); |
---|
| 1169 | $this->manage_fields($this->addresses['id_address'], 'deleted', $pos); |
---|
| 1170 | $this->manage_fields($this->addresses['id_typeof_contact_address'], 'deleted', $pos); |
---|
| 1171 | |
---|
| 1172 | return true; |
---|
| 1173 | } |
---|
| 1174 | |
---|
| 1175 | return false; |
---|
| 1176 | } |
---|
| 1177 | |
---|
| 1178 | /*! |
---|
| 1179 | |
---|
| 1180 | @function remove_connection |
---|
| 1181 | @abstract Remove one Contact's Connection |
---|
| 1182 | @author Raphael Derosso Pereira |
---|
| 1183 | @param integer $id_connection The ID of the connection to be removed |
---|
| 1184 | |
---|
| 1185 | */ |
---|
| 1186 | function remove_connection ( $id_connection ) |
---|
| 1187 | { |
---|
| 1188 | if (($pos = array_search($id_connection, $this->connections['id_connection']['values'])) !== false) |
---|
| 1189 | { |
---|
| 1190 | $this->manage_fields($this->connections['id_contact'], 'deleted', $pos); |
---|
| 1191 | $this->manage_fields($this->connections['id_connection'], 'deleted', $pos); |
---|
| 1192 | $this->manage_fields($this->connections['id_typeof_contact_connection'], 'deleted', $pos); |
---|
| 1193 | |
---|
| 1194 | return true; |
---|
| 1195 | } |
---|
| 1196 | |
---|
| 1197 | return false; |
---|
| 1198 | } |
---|
| 1199 | |
---|
| 1200 | /*! |
---|
| 1201 | |
---|
| 1202 | @function remove_company |
---|
| 1203 | @abstract Remove one Contact's Company |
---|
| 1204 | @author Raphael Derosso Pereira |
---|
| 1205 | @param integer $id_company The ID of the compay to be removed |
---|
| 1206 | |
---|
| 1207 | */ |
---|
| 1208 | function remove_company ( $id_company ) |
---|
| 1209 | { |
---|
| 1210 | if (($pos = array_search($id_company, $this->companies['id_company']['values'])) !== false) |
---|
| 1211 | { |
---|
| 1212 | $this->manage_fields($this->companies['id_contact'], 'deleted', $pos); |
---|
| 1213 | $this->manage_fields($this->companies['id_company'], 'deleted', $pos); |
---|
| 1214 | $this->manage_fields($this->companies['title'], 'deleted', $pos); |
---|
| 1215 | $this->manage_fields($this->companies['department'], 'deleted', $pos); |
---|
| 1216 | |
---|
| 1217 | return true; |
---|
| 1218 | } |
---|
| 1219 | |
---|
| 1220 | return false; |
---|
| 1221 | } |
---|
| 1222 | |
---|
| 1223 | } |
---|
| 1224 | ?> |
---|