Changeset 4269 in subversion
- Timestamp:
- Nov 25, 2010 1:53:14 PM (2 years ago)
- Location:
- trunk/plugins/kolab_addressbook
- Files:
-
- 2 added
- 2 edited
-
kolab_addressbook.php (modified) (2 diffs)
-
localization (added)
-
localization/en_US.inc (added)
-
rcube_kolab_contacts.php (modified) (16 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/plugins/kolab_addressbook/kolab_addressbook.php
r4247 r4269 24 24 // load required plugin 25 25 $this->require_plugin('kolab_core'); 26 27 $this->add_texts('localization'); 26 28 27 29 // register hooks … … 122 124 // TODO: add more Kolab-specific fields 123 125 124 // TODO: re-order fields 126 // re-order fields according to the coltypes list 127 $block = array(); 128 $contacts = reset($this->sources); 129 foreach ($contacts->coltypes as $col => $prop) { 130 if (isset($p['form']['info']['content'][$col])) 131 $block[$col] = $p['form']['info']['content'][$col]; 132 } 133 134 $p['form']['info']['content'] = $block; 125 135 } 126 136 -
trunk/plugins/kolab_addressbook/rcube_kolab_contacts.php
r4267 r4269 28 28 'department' => array('limit' => 1), 29 29 'gender' => array('limit' => 1), 30 ' birthday' => array('limit' => 1),30 'initials' => array('type' => 'text', 'size' => 6, 'limit' => 1, 'label' => 'kolab_addressbook.initials'), 31 31 'email' => array('subtypes' => null), 32 32 'phone' => array(), … … 34 34 'website' => array('limit' => 1, 'subtypes' => null), 35 35 'address' => array('limit' => 2, 'subtypes' => array('home','business')), 36 'birthday' => array('limit' => 1), 37 'anniversary' => array('type' => 'date', 'size' => 12, 'limit' => 1, 'label' => 'kolab_addressbook.anniversary'), 38 // TODO: define more Kolab-specific fields such as: office-location, profession, manager-name, assistant, spouse-name, children, language, latitude, longitude, pgp-publickey, free-busy-url 36 39 'notes' => array(), 37 // define additional coltypes38 'initials' => array('type' => 'text', 'size' => 6, 'limit' => 1),39 'anniversary' => array('type' => 'date', 'size' => 12, 'limit' => 1),40 // TODO: define more Kolab-specific fields such as: office-location, profession, manager-name, assistant, spouse-name, children, language, latitude, longitude, pgp-publickey, free-busy-url41 40 ); 42 41 … … 49 48 private $contacts; 50 49 private $distlists; 50 private $groupmembers; 51 51 private $id2uid; 52 52 private $filter; … … 86 86 $this->coltypes['phone']['subtypes'] = $format->_phone_types; 87 87 $this->coltypes['address']['subtypes'] = $format->_address_types; 88 $this->coltypes['anniversary']['label'] = rcube_label('anniversary'); 88 89 // set localized labels for proprietary cols 90 foreach ($this->coltypes as $col => $prop) { 91 if (is_string($prop['label'])) 92 $this->coltypes[$col]['label'] = rcube_label($prop['label']); 93 } 89 94 90 95 // fetch objects from the given IMAP folder … … 209 214 public function search($fields, $value, $strict=false, $select=true) 210 215 { 216 // search by ID 217 if ($fields == $this->primary_key) { 218 return $this->get_record($value); 219 } 220 211 221 // TODO: currently not implemented 212 222 return new rcube_result_set(0, ($this->list_page-1) * $this->page_size); … … 269 279 $this->_fetch_groups(); 270 280 271 foreach ($this->distlists as $gid => $group) { 272 foreach ($group['member'] as $member) { 273 if ($member['ID'] == $id) 274 $out[$gid] = $group['last-name']; 275 } 281 foreach ((array)$this->groupmembers[$id] as $gid) { 282 if ($group = $this->distlists[$gid]) 283 $out[$gid] = $group['last-name']; 276 284 } 277 285 … … 375 383 { 376 384 $this->_fetch_contacts(); 385 $this->_fetch_groups(); 377 386 378 387 if (!is_array($ids)) … … 392 401 } 393 402 else { 394 // TODO: remove from distribution lists 395 unset($this->contacts[$id], $this->id2uid[$id]); 403 // remove from distribution lists 404 foreach ((array)$this->groupmembers[$id] as $gid) 405 $this->remove_from_group($gid, $id); 406 407 // clear internal cache 408 unset($this->contacts[$id], $this->id2uid[$id], $this->groupmembers[$id]); 396 409 $count++; 397 410 } … … 433 446 function create_group($name) 434 447 { 435 // TODO: implement this 436 return false; 437 } 438 439 /** 440 * Delete the given group and all linked group members 441 * 442 * @param string Group identifier 443 * @return boolean True on success, false if no data was changed 444 */ 445 function delete_group($gid) 446 { 447 // TODO: implement this 448 return false; 449 } 450 451 /** 452 * Rename a specific contact group 453 * 454 * @param string Group identifier 455 * @param string New name to set for this group 456 * @return boolean New name on success, false if no data was changed 457 */ 458 function rename_group($gid, $newname) 459 { 460 $this->_fetch_groups(); 461 $list = $this->distlists[$gid]; 462 463 if ($newname != $list['last-name']) { 464 $list['last-name'] = $newname; 465 $saved = $this->liststorage->save($list, $list['uid']); 466 } 448 $this->_fetch_groups(); 449 $result = false; 450 451 $list = array( 452 'uid' => $this->liststorage->generateUID(), 453 'last-name' => $name, 454 'member' => array(), 455 ); 456 $saved = $this->liststorage->save($list); 467 457 468 458 if (PEAR::isError($saved)) { … … 474 464 return false; 475 465 } 466 else { 467 $id = md5($list['uid']); 468 $this->distlists[$record['ID']] = $list; 469 $result = array('id' => $id, 'name' => $name); 470 } 471 472 return $result; 473 } 474 475 /** 476 * Delete the given group and all linked group members 477 * 478 * @param string Group identifier 479 * @return boolean True on success, false if no data was changed 480 */ 481 function delete_group($gid) 482 { 483 $this->_fetch_groups(); 484 $result = false; 485 486 if ($list = $this->distlists[$gid]) 487 $deleted = $this->liststorage->delete($list['uid']); 488 489 if (PEAR::isError($deleted)) { 490 raise_error(array( 491 'code' => 600, 'type' => 'php', 492 'file' => __FILE__, 'line' => __LINE__, 493 'message' => "Error deleting distribution-list object from the Kolab server:" . $deleted->getMessage()), 494 true, false); 495 } 496 else 497 $result = true; 498 499 return $result; 500 } 501 502 /** 503 * Rename a specific contact group 504 * 505 * @param string Group identifier 506 * @param string New name to set for this group 507 * @return boolean New name on success, false if no data was changed 508 */ 509 function rename_group($gid, $newname) 510 { 511 $this->_fetch_groups(); 512 $list = $this->distlists[$gid]; 513 514 if ($newname != $list['last-name']) { 515 $list['last-name'] = $newname; 516 $saved = $this->liststorage->save($list, $list['uid']); 517 } 518 519 if (PEAR::isError($saved)) { 520 raise_error(array( 521 'code' => 600, 'type' => 'php', 522 'file' => __FILE__, 'line' => __LINE__, 523 'message' => "Error saving distribution-list object to Kolab server:" . $saved->getMessage()), 524 true, false); 525 return false; 526 } 476 527 477 528 return $newname; … … 497 548 $list = $this->distlists[$gid]; 498 549 499 foreach ( $list['member'] as $i => $member)550 foreach ((array)$list['member'] as $i => $member) 500 551 $exists[] = $member['ID']; 501 552 502 553 // substract existing assignments from list 503 554 $ids = array_diff($ids, $exists); 504 555 505 556 foreach ($ids as $contact_id) { 506 557 if ($uid = $this->id2uid[$contact_id]) { … … 513 564 ); 514 565 } 566 $this->groupmembers[$contact_id][] = $gid; 515 567 $added++; 516 568 } … … 569 621 } 570 622 else { 623 // remove group assigments in local cache 624 foreach ($ids as $id) { 625 $j = array_search($gid, $this->groupmembers[$id]); 626 unset($this->groupmembers[$id][$j]); 627 } 571 628 $this->distlists[$gid] = $list; 572 629 return true; … … 603 660 { 604 661 if (!isset($this->distlists)) { 605 $this->distlists = array();662 $this->distlists = $this->groupmembers = array(); 606 663 foreach ((array)$this->liststorage->getObjects() as $record) { 607 664 // FIXME: folders without any distribution-list objects return contacts instead ?! … … 609 666 continue; 610 667 $record['ID'] = md5($record['uid']); 611 foreach ($record['member'] as $i => $member) 612 $record['member'][$i]['ID'] = md5($member['uid']); 668 foreach ((array)$record['member'] as $i => $member) { 669 $mid = md5($member['uid']); 670 $record['member'][$i]['ID'] = $mid; 671 $this->groupmembers[$mid][] = $record['ID']; 672 } 613 673 $this->distlists[$record['ID']] = $record; 614 674 } … … 638 698 foreach ((array)$record['email'] as $i => $email) 639 699 $out['email'][] = $email['smtp-address']; 700 701 if (!$record['email'] && $record['emails']) 702 $out['email'] = preg_split('/,\s*/', $record['emails']); 640 703 641 704 foreach ((array)$record['phone'] as $i => $phone)
Note: See TracChangeset
for help on using the changeset viewer.
