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 | 'id_prefix' => array( |
---|
60 | 'name' => 'id_prefix', |
---|
61 | 'type' => 'foreign', |
---|
62 | 'association' => array( |
---|
63 | 'table' => 'phpgw_cc_prefixes', |
---|
64 | 'field' => 'id_prefix'), |
---|
65 | 'state' => 'empty', |
---|
66 | 'value' => false), |
---|
67 | 'given_names' => array( |
---|
68 | 'name' => 'given_names', |
---|
69 | 'type' => false, |
---|
70 | 'state' => 'empty', |
---|
71 | 'value' => false), |
---|
72 | 'family_names' => array( |
---|
73 | 'name' => 'family_names', |
---|
74 | 'type' => false, |
---|
75 | 'state' => 'empty', |
---|
76 | 'value' => false), |
---|
77 | 'names_ordered' => array( |
---|
78 | 'name' => 'names_ordered', |
---|
79 | 'type' => false, |
---|
80 | 'state' => 'empty', |
---|
81 | 'value' => false), |
---|
82 | 'id_suffix' => array( |
---|
83 | 'name' => 'id_suffix', |
---|
84 | 'type' => 'foreign', |
---|
85 | 'association' => array( |
---|
86 | 'table' => 'phpgw_cc_suffixes', |
---|
87 | 'field' => 'id_suffix'), |
---|
88 | 'state' => 'empty', |
---|
89 | 'value' => false), |
---|
90 | 'birthdate' => array( |
---|
91 | 'name' => 'birthdate', |
---|
92 | 'type' => false, |
---|
93 | 'state' => 'empty', |
---|
94 | 'value' => false), |
---|
95 | 'sex' => array( |
---|
96 | 'name' => 'sex', |
---|
97 | 'type' => false, |
---|
98 | 'state' => 'empty', |
---|
99 | 'value' => false), |
---|
100 | 'pgp_key' => array( |
---|
101 | 'name' => 'pgp_key', |
---|
102 | 'type' => false, |
---|
103 | 'state' => 'empty', |
---|
104 | 'value' => false), |
---|
105 | 'notes' => array( |
---|
106 | 'name' => 'notes', |
---|
107 | 'type' => false, |
---|
108 | 'state' => 'empty', |
---|
109 | 'value' => false), |
---|
110 | 'is_global' => array( |
---|
111 | 'name' => 'is_global', |
---|
112 | 'type' => false, |
---|
113 | 'state' => 'empty', |
---|
114 | 'value' => false), |
---|
115 | 'last_status' => array( |
---|
116 | 'name' => 'last_status', |
---|
117 | 'type' => false, |
---|
118 | 'state' => 'empty', |
---|
119 | 'value' => false), |
---|
120 | 'last_update' => array( |
---|
121 | 'name' => 'last_update', |
---|
122 | 'type' => false, |
---|
123 | 'state' => 'empty', |
---|
124 | 'value' => false)); |
---|
125 | |
---|
126 | $this->companies = array( |
---|
127 | 'id_contact' => array( |
---|
128 | 'name' => 'id_contact', |
---|
129 | 'type' => array('foreign', 'primary'), |
---|
130 | 'association' => array( |
---|
131 | 'table' => 'phpgw_cc_contact', |
---|
132 | 'field' => 'id_contact' |
---|
133 | ), |
---|
134 | 'states' => array(), |
---|
135 | 'values' => array() |
---|
136 | ), |
---|
137 | 'id_company' => array( |
---|
138 | 'name' => 'id_company', |
---|
139 | 'type' => array('foreign', 'primary'), |
---|
140 | 'association' => array( |
---|
141 | 'table' => 'phpgw_cc_company', |
---|
142 | 'field' => 'id_company' |
---|
143 | ), |
---|
144 | 'states' => array(), |
---|
145 | 'values' => array() |
---|
146 | ), |
---|
147 | 'title' => array( |
---|
148 | 'name' => 'title', |
---|
149 | 'type' => false, |
---|
150 | 'states' => array(), |
---|
151 | 'values' => array() |
---|
152 | ), |
---|
153 | 'department' => array( |
---|
154 | 'name' => 'department', |
---|
155 | 'type' => false, |
---|
156 | 'states' => array(), |
---|
157 | 'values' => array() |
---|
158 | ), |
---|
159 | 'default_contact' => array( |
---|
160 | 'name' => 'default_contact', |
---|
161 | 'type' => false, |
---|
162 | 'states' => array(), |
---|
163 | 'values' => array() |
---|
164 | ), |
---|
165 | 'default_company' => array( |
---|
166 | 'name' => 'default_company', |
---|
167 | 'type' => false, |
---|
168 | 'states' => array(), |
---|
169 | 'values' => array() |
---|
170 | ) |
---|
171 | ); |
---|
172 | |
---|
173 | $this->addresses = array( |
---|
174 | 'id_contact' => array( |
---|
175 | 'name' => 'id_contact', |
---|
176 | 'type' => array('foreign', 'primary'), |
---|
177 | 'association' => array( |
---|
178 | 'table' => 'phpgw_cc_contact', |
---|
179 | 'field' => 'id_contact'), |
---|
180 | 'states' => array(), |
---|
181 | 'values' => array()), |
---|
182 | 'id_address' => array( |
---|
183 | 'name' => 'id_address', |
---|
184 | 'type' => array('foreign', 'primary'), |
---|
185 | 'association' => array( |
---|
186 | 'table' => 'phpgw_cc_addresses', |
---|
187 | 'field' => 'id_address'), |
---|
188 | 'states' => array(), |
---|
189 | 'values' => array()), |
---|
190 | 'id_typeof_contact_address' => array( |
---|
191 | 'name' => 'id_typeof_contact_address', |
---|
192 | 'type' => 'foreign', |
---|
193 | 'association' => array( |
---|
194 | 'table' => 'phpgw_cc_typeof_ct_addrs', |
---|
195 | 'field' => 'id_typeof_contact_address'), |
---|
196 | 'states' => array(), |
---|
197 | 'values' => array())); |
---|
198 | |
---|
199 | |
---|
200 | $this->connections = array( |
---|
201 | 'id_contact' => array( |
---|
202 | 'name' => 'id_contact', |
---|
203 | 'type' => array('foreign', 'primary'), |
---|
204 | 'association' => array( |
---|
205 | 'table' => 'phpgw_cc_contact', |
---|
206 | 'field' => 'id_contact'), |
---|
207 | 'states' => array(), |
---|
208 | 'values' => array()), |
---|
209 | 'id_connection' => array( |
---|
210 | 'name' => 'id_connection', |
---|
211 | 'type' => array('foreign', 'primary'), |
---|
212 | 'association' => array( |
---|
213 | 'table' => 'phpgw_cc_connections', |
---|
214 | 'field' => 'id_connection'), |
---|
215 | 'states' => array(), |
---|
216 | 'values' => array()), |
---|
217 | 'id_typeof_contact_connection' => array( |
---|
218 | 'name' => 'id_typeof_contact_connection', |
---|
219 | 'type' => array('foreign', 'primary'), |
---|
220 | 'association' => array( |
---|
221 | 'table' => 'phpgw_cc_typeof_ct_conns', |
---|
222 | 'field' => 'id_typeof_contact_connection'), |
---|
223 | 'states' => array(), |
---|
224 | 'values' => array())); |
---|
225 | |
---|
226 | $this->relations = array( |
---|
227 | 'id_contact' => array( |
---|
228 | 'name' => 'id_contact', |
---|
229 | 'type' => array('foreign', 'primary'), |
---|
230 | 'association' => array( |
---|
231 | 'table' => 'phpgw_cc_contact', |
---|
232 | 'field' => 'id_contact' |
---|
233 | ), |
---|
234 | 'states' => array(), |
---|
235 | 'values' => array() |
---|
236 | ), |
---|
237 | 'id_related' => array( |
---|
238 | 'name' => 'id_related', |
---|
239 | 'type' => array('foreign', 'primary'), |
---|
240 | 'association' => array( |
---|
241 | 'table' => 'phpgw_cc_contact', |
---|
242 | 'field' => 'id_contact' |
---|
243 | ), |
---|
244 | 'states' => array(), |
---|
245 | 'values' => array() |
---|
246 | ), |
---|
247 | 'id_typeof_contact_relation' => array( |
---|
248 | 'name' => 'id_typeof_contact_relation', |
---|
249 | 'type' => array('foreign', 'primary'), |
---|
250 | 'association' => array( |
---|
251 | 'table' => 'phpgw_cc_typeof_ct_rels', |
---|
252 | 'field' => 'id_typeof_contact_relation' |
---|
253 | ), |
---|
254 | 'states' => array(), |
---|
255 | 'values' => array() |
---|
256 | ) |
---|
257 | ); |
---|
258 | |
---|
259 | |
---|
260 | $this->db_tables = array( |
---|
261 | 'phpgw_cc_contact' => array( |
---|
262 | 'type' => 'main', |
---|
263 | 'keys' => array( |
---|
264 | 'primary' => array(&$this->main_fields['id_contact']), |
---|
265 | 'foreign' => array( |
---|
266 | &$this->main_fields['id_status'], |
---|
267 | &$this->main_fields['id_prefix'], |
---|
268 | &$this->main_fields['id_suffix'])), |
---|
269 | 'fields' => & $this->main_fields), |
---|
270 | 'phpgw_cc_contact_company' => array( |
---|
271 | 'type' => 'multi', |
---|
272 | 'keys' => array( |
---|
273 | 'primary' => array( |
---|
274 | &$this->companies['id_contact'], |
---|
275 | &$this->companies['id_company']), |
---|
276 | 'foreign' => array( |
---|
277 | &$this->companies['id_contact'], |
---|
278 | &$this->companies['id_company'])), |
---|
279 | 'fields' => & $this->companies), |
---|
280 | 'phpgw_cc_contact_rels' => array( |
---|
281 | 'type' => 'multi', |
---|
282 | 'keys' => array( |
---|
283 | 'primary' => array( |
---|
284 | &$this->relations['id_contact'], |
---|
285 | &$this->relations['id_related']), |
---|
286 | 'foreign' => array( |
---|
287 | &$this->relations['id_contact'], |
---|
288 | &$this->relations['id_related'])), |
---|
289 | 'fields' => & $this->relations), |
---|
290 | 'phpgw_cc_contact_addrs' => array( |
---|
291 | 'type' => 'multi', |
---|
292 | 'keys' => array( |
---|
293 | 'primary' => array( |
---|
294 | &$this->addresses['id_contact'], |
---|
295 | &$this->addresses['id_address']), |
---|
296 | 'foreign' => array( |
---|
297 | &$this->addresses['id_contact'], |
---|
298 | &$this->addresses['id_address'], |
---|
299 | &$this->addresses['id_typeof_contact_address'])), |
---|
300 | 'fields' => & $this->addresses), |
---|
301 | 'phpgw_cc_contact_conns' => array( |
---|
302 | 'type' => 'multi', |
---|
303 | 'keys' => array( |
---|
304 | 'primary' => array( |
---|
305 | &$this->connections['id_contact'], |
---|
306 | &$this->connections['id_connection']), |
---|
307 | 'foreign' => array( |
---|
308 | &$this->connections['id_contact'], |
---|
309 | &$this->connections['id_connection'], |
---|
310 | &$this->connections['id_typeof_contact_connection'])), |
---|
311 | 'fields' => & $this->connections)); |
---|
312 | |
---|
313 | |
---|
314 | if ($id_contact) |
---|
315 | { |
---|
316 | $this->id = $id_contact; |
---|
317 | if (!$this->checkout($id_contact)) |
---|
318 | { |
---|
319 | $this->reset_values(); |
---|
320 | $this->state = 'new'; |
---|
321 | } |
---|
322 | } |
---|
323 | else |
---|
324 | { |
---|
325 | $this->state = 'new'; |
---|
326 | } |
---|
327 | |
---|
328 | } |
---|
329 | |
---|
330 | /*********************************************************************\ |
---|
331 | * Methods to Obtain Data * |
---|
332 | \*********************************************************************/ |
---|
333 | |
---|
334 | /*! |
---|
335 | |
---|
336 | @function get_photo |
---|
337 | @abstract Returns the Contact's photo binary string |
---|
338 | @author Raphael Derosso Pereira |
---|
339 | |
---|
340 | */ |
---|
341 | function get_photo ( ) |
---|
342 | { |
---|
343 | return $this->main_fields['photo']['value']; |
---|
344 | } |
---|
345 | |
---|
346 | /*! |
---|
347 | |
---|
348 | @function get_alias |
---|
349 | @abstract Returns the Contact alias |
---|
350 | @author Raphael Derosso Pereira |
---|
351 | |
---|
352 | */ |
---|
353 | function get_alias ( ) |
---|
354 | { |
---|
355 | return $this->main_fields['alias']['value']; |
---|
356 | } |
---|
357 | |
---|
358 | /*! |
---|
359 | |
---|
360 | @function get_prefix |
---|
361 | @abstract Returns the Contact prefix ID |
---|
362 | @author Raphael Derosso Pereira |
---|
363 | |
---|
364 | */ |
---|
365 | function get_prefix ( ) |
---|
366 | { |
---|
367 | return $this->main_fields['id_prefix']['value']; |
---|
368 | } |
---|
369 | |
---|
370 | /*! |
---|
371 | |
---|
372 | @function get_given_names |
---|
373 | @abstract Returns the Contact's given names |
---|
374 | @author Raphael Derosso Pereira |
---|
375 | |
---|
376 | */ |
---|
377 | function get_given_names ( ) |
---|
378 | { |
---|
379 | return $this->main_fields['given_names']['value']; |
---|
380 | } |
---|
381 | |
---|
382 | /*! |
---|
383 | |
---|
384 | @function get_family_names |
---|
385 | @abstract Returns the Contact's family names |
---|
386 | @author Raphael Derosso Pereira |
---|
387 | |
---|
388 | */ |
---|
389 | function get_family_names ( ) |
---|
390 | { |
---|
391 | return $this->main_fields['family_names']['value']; |
---|
392 | } |
---|
393 | |
---|
394 | /*! |
---|
395 | |
---|
396 | @function get_names_ordered |
---|
397 | @abstract Returns the Contact's names ordered |
---|
398 | @author Raphael Derosso Pereira |
---|
399 | |
---|
400 | */ |
---|
401 | function get_names_ordered ( ) |
---|
402 | { |
---|
403 | return $this->main_fields['names_ordered']['value']; |
---|
404 | } |
---|
405 | |
---|
406 | /*! |
---|
407 | |
---|
408 | @function get_suffix |
---|
409 | @abstract Returns the Contact's suffix |
---|
410 | @author Raphael Derosso Pereira |
---|
411 | |
---|
412 | */ |
---|
413 | function get_suffix ( ) |
---|
414 | { |
---|
415 | return $this->main_fields['id_suffix']['value']; |
---|
416 | } |
---|
417 | |
---|
418 | /*! |
---|
419 | |
---|
420 | @function get_birthdate |
---|
421 | @abstract Returns the Contact's birthdata |
---|
422 | @author Raphael Derosso Pereira |
---|
423 | |
---|
424 | */ |
---|
425 | function get_birthdate ( ) |
---|
426 | { |
---|
427 | return $this->main_fields['birthdate']['value']; |
---|
428 | } |
---|
429 | |
---|
430 | /*! |
---|
431 | |
---|
432 | @function get_sex |
---|
433 | @abstract Returns the Contact's sex |
---|
434 | @author Raphael Derosso Pereira |
---|
435 | |
---|
436 | */ |
---|
437 | function get_sex ( ) |
---|
438 | { |
---|
439 | return $this->main_fields['sex']['value']; |
---|
440 | } |
---|
441 | |
---|
442 | /*! |
---|
443 | |
---|
444 | @function get_pgp_key |
---|
445 | @abstract Returns the Contact's PGP Key |
---|
446 | @author Raphael Derosso Pereira |
---|
447 | |
---|
448 | */ |
---|
449 | function get_pgp_key ( ) |
---|
450 | { |
---|
451 | return $this->main_fields['pgp_key']['value']; |
---|
452 | } |
---|
453 | |
---|
454 | /*! |
---|
455 | |
---|
456 | @function get_notes |
---|
457 | @abstract Returns the Contact's notes |
---|
458 | @author Raphael Derosso Pereira |
---|
459 | |
---|
460 | */ |
---|
461 | function get_notes ( ) |
---|
462 | { |
---|
463 | return $this->main_fields['notes']['value']; |
---|
464 | } |
---|
465 | |
---|
466 | /*! |
---|
467 | |
---|
468 | @function get_status |
---|
469 | @abstract Returns the Contact's status ID |
---|
470 | @author Raphael Derosso Pereira |
---|
471 | |
---|
472 | */ |
---|
473 | function get_status ( ) |
---|
474 | { |
---|
475 | return $this->main_fields['status']['value']; |
---|
476 | } |
---|
477 | |
---|
478 | /*! |
---|
479 | |
---|
480 | @function get_relations |
---|
481 | @abstract Returns the Contact's Relations |
---|
482 | @author Raphael Derosso Pereira |
---|
483 | |
---|
484 | @return array Format: |
---|
485 | $return = array( |
---|
486 | '<id_related1>' => '<id_relation1_type>', |
---|
487 | '<id_related2>' => '<id_relation2_type>', |
---|
488 | ...); |
---|
489 | */ |
---|
490 | function get_relations ( ) |
---|
491 | { |
---|
492 | $return = array(); |
---|
493 | |
---|
494 | reset($this->relations['id_related']['values']); |
---|
495 | reset($this->relations['id_typeof_contact_relation']['values']); |
---|
496 | while(list(,$id_related) = each($this->relations['id_related']['values']) and |
---|
497 | list(,$id_relation_type) = each($this->relations['id_typeof_contact_relation']['values'])) |
---|
498 | { |
---|
499 | $return[$id_related] = $id_relation_type; |
---|
500 | } |
---|
501 | |
---|
502 | return $return; |
---|
503 | } |
---|
504 | |
---|
505 | /*! |
---|
506 | |
---|
507 | @function get_addresses |
---|
508 | @abstract Returns the Contact's Addresses |
---|
509 | @author Raphael Derosso Pereira |
---|
510 | |
---|
511 | @return array Format: |
---|
512 | $return = array( |
---|
513 | '<id_address1>' => '<id_address1_type>', |
---|
514 | '<id_address2>' => '<id_address2_type>', |
---|
515 | ...); |
---|
516 | */ |
---|
517 | function get_addresses ( ) |
---|
518 | { |
---|
519 | $return = array(); |
---|
520 | |
---|
521 | reset($this->addresses['id_address']['values']); |
---|
522 | reset($this->addresses['id_typeof_contact_address']['values']); |
---|
523 | while(list(,$id_address) = each($this->addresses['id_address']['values']) and |
---|
524 | list(,$id_address_type) = each($this->addresses['id_typeof_contact_address']['values'])) |
---|
525 | { |
---|
526 | $return[$id_address] = $id_address_type; |
---|
527 | } |
---|
528 | |
---|
529 | return $return; |
---|
530 | } |
---|
531 | |
---|
532 | /*! |
---|
533 | |
---|
534 | @function get_connections |
---|
535 | @abstract Returns the Contact's Connections |
---|
536 | @author Raphael Derosso Pereira |
---|
537 | |
---|
538 | @return array Format: |
---|
539 | $return = array( |
---|
540 | '<id_connection1>' => '<id_connection1_type>', |
---|
541 | '<id_connection2>' => '<id_connection2_type>', |
---|
542 | ...); |
---|
543 | */ |
---|
544 | function get_connections ( ) |
---|
545 | { |
---|
546 | $return = array(); |
---|
547 | |
---|
548 | reset($this->connections['id_connection']['values']); |
---|
549 | reset($this->connections['id_typeof_contact_connection']['values']); |
---|
550 | while(list(,$id_connection) = each($this->connections['id_connection']['values']) and |
---|
551 | list(,$id_connection_type) = each($this->connections['id_typeof_contact_connection']['values'])) |
---|
552 | { |
---|
553 | $return[$id_connection] = $id_connection_type; |
---|
554 | } |
---|
555 | |
---|
556 | return $return; |
---|
557 | } |
---|
558 | |
---|
559 | /*! |
---|
560 | |
---|
561 | @function get_companies |
---|
562 | @abstract Returns the Contact's Companies IDs and |
---|
563 | bussiness info |
---|
564 | @author Raphael Derosso Pereira |
---|
565 | |
---|
566 | @return array Format: |
---|
567 | $return = array( |
---|
568 | '<id_company1>' => array( |
---|
569 | 'title' => '<title>', |
---|
570 | 'department' => '<department>' |
---|
571 | ), |
---|
572 | '<id_company2>' => array( |
---|
573 | 'title' => '<title>', |
---|
574 | 'department' => '<department>' |
---|
575 | ), |
---|
576 | ... |
---|
577 | ); |
---|
578 | |
---|
579 | */ |
---|
580 | function get_companies ( ) |
---|
581 | { |
---|
582 | $return = array(); |
---|
583 | |
---|
584 | reset($this->companies['id_company']['values']); |
---|
585 | reset($this->companies['title']['values']); |
---|
586 | reset($this->companies['department']['values']); |
---|
587 | reset($this->companies['default_company']['values']); |
---|
588 | reset($this->companies['default_contact']['values']); |
---|
589 | while(list(,$id_company) = each($this->companies['id_company']['values']) and |
---|
590 | list(,$title) = each($this->companies['title']['values']) and |
---|
591 | list(,$department) = each($this->companies['department']['values']) and |
---|
592 | list(,$default_company) = each($this->companies['default_company']['values']) and |
---|
593 | list(,$default_contact) = each($this->companies['default_contact']['values'])) |
---|
594 | { |
---|
595 | $return[$id_company] = array( |
---|
596 | 'title' => $title, |
---|
597 | 'department' => $department, |
---|
598 | 'default_company' => $default_company, |
---|
599 | 'default_contact' => $default_contact, |
---|
600 | ); |
---|
601 | } |
---|
602 | |
---|
603 | return $return; |
---|
604 | } |
---|
605 | |
---|
606 | /*********************************************************************\ |
---|
607 | * Methods to Alter Data * |
---|
608 | \*********************************************************************/ |
---|
609 | |
---|
610 | |
---|
611 | /*! |
---|
612 | |
---|
613 | @function set_photo |
---|
614 | @abstract Sets the Contact's Photo binary string |
---|
615 | @author Raphael Derosso Pereira |
---|
616 | @param string $photo The binary photo string |
---|
617 | |
---|
618 | */ |
---|
619 | function set_photo ( $photo ) |
---|
620 | { |
---|
621 | $this->main_fields['photo']['value'] = $photo; |
---|
622 | $this->manage_fields($this->main_fields['photo'], 'changed'); |
---|
623 | } |
---|
624 | |
---|
625 | /*! |
---|
626 | |
---|
627 | @function set_alias |
---|
628 | @abstract Sets the Contact's Alias |
---|
629 | @author Raphael Derosso Pereira |
---|
630 | @param string $alias The new Contact alias |
---|
631 | |
---|
632 | */ |
---|
633 | function set_alias ( $alias ) |
---|
634 | { |
---|
635 | $this->main_fields['alias']['value'] = $alias; |
---|
636 | $this->manage_fields($this->main_fields['alias'], 'changed'); |
---|
637 | } |
---|
638 | |
---|
639 | /*! |
---|
640 | |
---|
641 | @function set_id_prefix |
---|
642 | @abstract Sets the Contact's Prefix |
---|
643 | @author Raphael Derosso Pereira |
---|
644 | @param string $id_prefix The new Contact prefix ID |
---|
645 | |
---|
646 | */ |
---|
647 | function set_id_prefix ( $id_prefix ) |
---|
648 | { |
---|
649 | $this->main_fields['prefix']['value'] = $id_prefix; |
---|
650 | $this->manage_fields($this->main_fields['prefix'], 'changed'); |
---|
651 | } |
---|
652 | |
---|
653 | /*! |
---|
654 | |
---|
655 | @function set_given_names |
---|
656 | @abstract Sets the Contact's Given Names |
---|
657 | @author Raphael Derosso Pereira |
---|
658 | @param string $names The new Contact's Given Names |
---|
659 | |
---|
660 | */ |
---|
661 | function set_given_names ( $names ) |
---|
662 | { |
---|
663 | $this->main_fields['given_names']['value'] = $names; |
---|
664 | $this->manage_fields($this->main_fields['given_names'], 'changed'); |
---|
665 | } |
---|
666 | |
---|
667 | /*! |
---|
668 | |
---|
669 | @function set_family_names |
---|
670 | @abstract Sets the Contact's Family Names |
---|
671 | @author Raphael Derosso Pereira |
---|
672 | @param string $names The new Contact's Family Names |
---|
673 | |
---|
674 | */ |
---|
675 | function set_family_names ( $names ) |
---|
676 | { |
---|
677 | $this->main_fields['family_names']['value'] = $names; |
---|
678 | $this->manage_fields($this->main_fields['family_names'], 'changed'); |
---|
679 | } |
---|
680 | |
---|
681 | /*! |
---|
682 | |
---|
683 | @function set_names_ordered |
---|
684 | @abstract Sets the Contact's Names Ordered |
---|
685 | @author Raphael Derosso Pereira |
---|
686 | @param string $names The new Contact's Names Ordered |
---|
687 | |
---|
688 | */ |
---|
689 | function set_names_ordered ( $names ) |
---|
690 | { |
---|
691 | $this->main_fields['names_ordered']['value'] = $names; |
---|
692 | $this->manage_fields($this->main_fields['names_ordered'], 'changed'); |
---|
693 | } |
---|
694 | |
---|
695 | /*! |
---|
696 | |
---|
697 | @function set_id_suffix |
---|
698 | @abstract Sets the Contact's Sulfix |
---|
699 | @author Raphael Derosso Pereira |
---|
700 | @param string $id_suffix The new Contact's Sulfix |
---|
701 | |
---|
702 | */ |
---|
703 | function set_id_suffix ( $id_suffix ) |
---|
704 | { |
---|
705 | $this->main_fields['suffix']['value'] = $names; |
---|
706 | $this->manage_fields($this->main_fields['suffix'], 'changed'); |
---|
707 | } |
---|
708 | |
---|
709 | /*! |
---|
710 | |
---|
711 | @function set_birthdate |
---|
712 | @abstract Sets the Contact's Birthdate |
---|
713 | @author Raphael Derosso Pereira |
---|
714 | @param string $date The new Contact's Birthdate |
---|
715 | |
---|
716 | */ |
---|
717 | function set_birthdate ( $date ) |
---|
718 | { |
---|
719 | $this->main_fields['birthdate']['value'] = $names; |
---|
720 | $this->manage_fields($this->main_fields['birthdate'], 'changed'); |
---|
721 | } |
---|
722 | |
---|
723 | /*! |
---|
724 | |
---|
725 | @function set_sex |
---|
726 | @abstract Sets the Contact's Sex |
---|
727 | @author Raphael Derosso Pereira |
---|
728 | @param string $sex The new Contact's Sex |
---|
729 | |
---|
730 | */ |
---|
731 | function set_sex ( $sex ) |
---|
732 | { |
---|
733 | $this->main_fields['birthdate']['value'] = $names; |
---|
734 | $this->manage_fields($this->main_fields['birthdate'], 'changed'); |
---|
735 | } |
---|
736 | |
---|
737 | /*! |
---|
738 | |
---|
739 | @function set_pgp_key |
---|
740 | @abstract Sets the Contact's PGP Key |
---|
741 | @author Raphael Derosso Pereira |
---|
742 | @param string $pgp_key The new Contact's PGP Key |
---|
743 | |
---|
744 | */ |
---|
745 | function set_pgp_key ( $pgp_key ) |
---|
746 | { |
---|
747 | $this->main_fields['birthdate']['value'] = $names; |
---|
748 | $this->manage_fields($this->main_fields['birthdate'], 'changed'); |
---|
749 | } |
---|
750 | |
---|
751 | /*! |
---|
752 | |
---|
753 | @function set_notes |
---|
754 | @abstract Sets the Contact's Notes |
---|
755 | @author Raphael Derosso Pereira |
---|
756 | @param string $notes The new Contact's Notes |
---|
757 | |
---|
758 | */ |
---|
759 | function set_notes ( $notes ) |
---|
760 | { |
---|
761 | $this->main_fields['birthdate']['value'] = $names; |
---|
762 | $this->manage_fields($this->main_fields['birthdate'], 'changed'); |
---|
763 | } |
---|
764 | |
---|
765 | /*! |
---|
766 | |
---|
767 | @function set_status |
---|
768 | @abstract Change the Contact's set Status |
---|
769 | @author Raphael Derosso Pereira |
---|
770 | @param integer $id_status The new Contact's set Status |
---|
771 | |
---|
772 | */ |
---|
773 | function set_id_status ( $id_status ) |
---|
774 | { |
---|
775 | $this->main_fields['id_status']['value'] = $names; |
---|
776 | $this->manage_fields($this->main_fields['id_status'], 'changed'); |
---|
777 | } |
---|
778 | |
---|
779 | /*! |
---|
780 | |
---|
781 | @function set_relation |
---|
782 | @abstract Sets the Contact's Relation |
---|
783 | @author Raphael Derosso Pereira |
---|
784 | @param integer $id_related The new Contact's Relation type ID |
---|
785 | @param integer $id_type The new Contact's Relation ID |
---|
786 | |
---|
787 | */ |
---|
788 | function set_relation ( $id_related, $id_type ) |
---|
789 | { |
---|
790 | if (($pos = array_search($id_related, $this->relations['id_related']['values'])) !== false) |
---|
791 | { |
---|
792 | $this->relations['id_typeof_contact_relation']['values'][$pos] = $id_type; |
---|
793 | $this->manage_fields($this->relations['id_typeof_contact_relation'], 'changed', $pos); |
---|
794 | |
---|
795 | return; |
---|
796 | } |
---|
797 | |
---|
798 | array_push($this->relations['id_contact']['values'], & $this->id); |
---|
799 | array_push($this->relations['id_related']['values'], $id_related); |
---|
800 | array_push($this->relations['id_typeof_contact_relation']['values'], $id_type); |
---|
801 | |
---|
802 | $this->manage_fields($this->relations['id_typeof_contact_relation'], 'new', 'new'); |
---|
803 | $this->manage_fields($this->relations['id_related'], 'new', 'new'); |
---|
804 | $this->manage_fields($this->relations['id_contact'], 'new', 'new'); |
---|
805 | } |
---|
806 | |
---|
807 | /*! |
---|
808 | |
---|
809 | @function set_address |
---|
810 | @abstract Sets the Contact's Address |
---|
811 | @author Raphael Derosso Pereira |
---|
812 | @param integer $id_address The new Contact's Address ID |
---|
813 | @param integer $id_type The new Contact's Address type ID |
---|
814 | |
---|
815 | */ |
---|
816 | function set_address ( $id_address, $id_type ) |
---|
817 | { |
---|
818 | if (($pos = array_search($id_address, $this->addresses['id_address']['values'])) !== false) |
---|
819 | { |
---|
820 | $this->addresses['id_typeof_contact_address']['values'][$pos] = $id_type; |
---|
821 | $this->manage_fields($this->addresses['id_typeof_contact_address'], 'changed', $pos); |
---|
822 | |
---|
823 | return; |
---|
824 | } |
---|
825 | |
---|
826 | array_push($this->addresses['id_contact']['values'], & $this->id); |
---|
827 | array_push($this->addresses['id_address']['values'], $id_address); |
---|
828 | array_push($this->addresses['id_typeof_contact_address']['values'], $id_type); |
---|
829 | |
---|
830 | $this->manage_fields($this->addresses['id_typeof_contact_address'], 'new', 'new'); |
---|
831 | $this->manage_fields($this->addresses['id_address'], 'new', 'new'); |
---|
832 | $this->manage_fields($this->addresses['id_contact'], 'new', 'new'); |
---|
833 | } |
---|
834 | |
---|
835 | /*! |
---|
836 | |
---|
837 | @function set_connection |
---|
838 | @abstract Sets the Contact's Connection |
---|
839 | @author Raphael Derosso Pereira |
---|
840 | @param integer $id_connection The new Contact's Connection ID |
---|
841 | @param integer $id_type The new Contact's Connection type ID |
---|
842 | |
---|
843 | */ |
---|
844 | function set_connection ( $id_connection, $id_type ) |
---|
845 | { |
---|
846 | if (($pos = array_search($id_connection, $this->connections['id_connection']['values'])) !== false) |
---|
847 | { |
---|
848 | $this->connections['id_typeof_contact_connection']['values'][$pos] = $id_type; |
---|
849 | $this->manage_fields($this->connections['id_typeof_contact_connection'], 'changed', $pos); |
---|
850 | |
---|
851 | return; |
---|
852 | } |
---|
853 | |
---|
854 | array_push($this->connections['id_contact']['values'], & $this->id); |
---|
855 | array_push($this->connections['id_connection']['values'], $id_connection); |
---|
856 | array_push($this->connections['id_typeof_contact_connection']['values'], $id_type); |
---|
857 | |
---|
858 | $this->manage_fields($this->connections['id_typeof_contact_connection'], 'new', 'new'); |
---|
859 | $this->manage_fields($this->connections['id_connection'], 'new', 'new'); |
---|
860 | $this->manage_fields($this->connections['id_contact'], 'new', 'new'); |
---|
861 | } |
---|
862 | |
---|
863 | /*! |
---|
864 | |
---|
865 | @function set_company |
---|
866 | @abstract Sets the Contact's Company and bussiness information |
---|
867 | @author Raphael Derosso Pereira |
---|
868 | @param array $company_info The new Contact's Company Information |
---|
869 | |
---|
870 | */ |
---|
871 | function set_company ( $company_info ) |
---|
872 | { |
---|
873 | if (is_array($company_info)) |
---|
874 | { |
---|
875 | if (($pos = array_search($company_info['id_company'], $this->companies['id_company']['values'])) !== false) |
---|
876 | { |
---|
877 | $this->companies['title']['values'][$pos] = $company_info['title']; |
---|
878 | $this->companies['department']['values'][$pos] = $company_info['department']; |
---|
879 | $this->companies['default_company']['values'][$pos] = $company_info['default_company']; |
---|
880 | $this->companies['default_contact']['values'][$pos] = $company_info['default_contact']; |
---|
881 | |
---|
882 | $this->manage_fields($this->companies['title'], 'changed', $pos); |
---|
883 | $this->manage_fields($this->companies['department'], 'changed', $pos); |
---|
884 | $this->manage_fields($this->companies['default_company'], 'changed', $pos); |
---|
885 | $this->manage_fields($this->companies['default_contact'], 'changed', $pos); |
---|
886 | |
---|
887 | return true; |
---|
888 | } |
---|
889 | |
---|
890 | array_push($this->companies['id_contact']['values'], & $this->id); |
---|
891 | array_push($this->companies['id_company']['values'], $company_info['id_company']); |
---|
892 | array_push($this->companies['title']['values'], $company_info['title']); |
---|
893 | array_push($this->companies['department']['values'], $company_info['department']); |
---|
894 | array_push($this->companies['default_company']['values'], $company_info['default_company']); |
---|
895 | array_push($this->companies['default_contact']['values'], $company_info['default_contact']); |
---|
896 | |
---|
897 | $this->manage_fields($this->companies['id_company'], 'new', 'new'); |
---|
898 | $this->manage_fields($this->companies['id_contact'], 'new', 'new'); |
---|
899 | $this->manage_fields($this->companies['title'], 'new', 'new'); |
---|
900 | $this->manage_fields($this->companies['department'], 'new', 'new'); |
---|
901 | $this->manage_fields($this->companies['default_company'], 'new', 'new'); |
---|
902 | $this->manage_fields($this->companies['default_contact'], 'new', 'new'); |
---|
903 | |
---|
904 | return true; |
---|
905 | } |
---|
906 | |
---|
907 | return false; |
---|
908 | } |
---|
909 | |
---|
910 | |
---|
911 | /*********************************************************************\ |
---|
912 | * Methods to Remove Data * |
---|
913 | \*********************************************************************/ |
---|
914 | |
---|
915 | |
---|
916 | /*! |
---|
917 | |
---|
918 | @function remove_relation |
---|
919 | @abstract Remove one Contact's Relation |
---|
920 | @author Raphael Derosso Pereira |
---|
921 | @param integer $id_related The ID of the relation to be removed |
---|
922 | |
---|
923 | */ |
---|
924 | function remove_relation ( $id_related ) |
---|
925 | { |
---|
926 | if (($pos = array_search($id_related, $this->relations['id_related']['values'])) !== false) |
---|
927 | { |
---|
928 | $this->manage_fields($this->relations['id_contact'], 'deleted', $pos); |
---|
929 | $this->manage_fields($this->relations['id_related'], 'deleted', $pos); |
---|
930 | $this->manage_fields($this->relations['id_typeof_contact_relation'], 'deleted', $pos); |
---|
931 | |
---|
932 | return true; |
---|
933 | } |
---|
934 | |
---|
935 | return false; |
---|
936 | } |
---|
937 | |
---|
938 | /*! |
---|
939 | |
---|
940 | @function remove_address |
---|
941 | @abstract Remove one Contact's Address |
---|
942 | @author Raphael Derosso Pereira |
---|
943 | @param integer $id_address The ID of the address to be removed |
---|
944 | |
---|
945 | */ |
---|
946 | function remove_address ( $id_address ) |
---|
947 | { |
---|
948 | if (($pos = array_search($id_address, $this->addresses['id_address']['values'])) !== false) |
---|
949 | { |
---|
950 | $this->manage_fields($this->addresses['id_contact'], 'deleted', $pos); |
---|
951 | $this->manage_fields($this->addresses['id_address'], 'deleted', $pos); |
---|
952 | $this->manage_fields($this->addresses['id_typeof_contact_address'], 'deleted', $pos); |
---|
953 | |
---|
954 | return true; |
---|
955 | } |
---|
956 | |
---|
957 | return false; |
---|
958 | } |
---|
959 | |
---|
960 | /*! |
---|
961 | |
---|
962 | @function remove_connection |
---|
963 | @abstract Remove one Contact's Connection |
---|
964 | @author Raphael Derosso Pereira |
---|
965 | @param integer $id_connection The ID of the connection to be removed |
---|
966 | |
---|
967 | */ |
---|
968 | function remove_connection ( $id_connection ) |
---|
969 | { |
---|
970 | if (($pos = array_search($id_connection, $this->connections['id_connection']['values'])) !== false) |
---|
971 | { |
---|
972 | $this->manage_fields($this->connections['id_contact'], 'deleted', $pos); |
---|
973 | $this->manage_fields($this->connections['id_connection'], 'deleted', $pos); |
---|
974 | $this->manage_fields($this->connections['id_typeof_contact_connection'], 'deleted', $pos); |
---|
975 | |
---|
976 | return true; |
---|
977 | } |
---|
978 | |
---|
979 | return false; |
---|
980 | } |
---|
981 | |
---|
982 | /*! |
---|
983 | |
---|
984 | @function remove_company |
---|
985 | @abstract Remove one Contact's Company |
---|
986 | @author Raphael Derosso Pereira |
---|
987 | @param integer $id_company The ID of the compay to be removed |
---|
988 | |
---|
989 | */ |
---|
990 | function remove_company ( $id_company ) |
---|
991 | { |
---|
992 | if (($pos = array_search($id_company, $this->companies['id_company']['values'])) !== false) |
---|
993 | { |
---|
994 | $this->manage_fields($this->companies['id_contact'], 'deleted', $pos); |
---|
995 | $this->manage_fields($this->companies['id_company'], 'deleted', $pos); |
---|
996 | $this->manage_fields($this->companies['title'], 'deleted', $pos); |
---|
997 | $this->manage_fields($this->companies['department'], 'deleted', $pos); |
---|
998 | |
---|
999 | return true; |
---|
1000 | } |
---|
1001 | |
---|
1002 | return false; |
---|
1003 | } |
---|
1004 | |
---|
1005 | } |
---|
1006 | ?> |
---|