Changeset 4244 in subversion
- Timestamp:
- Nov 21, 2010 11:47:51 AM (3 years ago)
- Location:
- trunk/plugins/kolab_addressbook
- Files:
-
- 3 edited
-
kolab_addressbook.php (modified) (2 diffs)
-
lib/rcube_kolab.php (modified) (2 diffs)
-
rcube_kolab_contacts.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/plugins/kolab_addressbook/kolab_addressbook.php
r4205 r4244 30 30 $this->add_hook('addressbooks_list', array($this, 'address_sources')); 31 31 $this->add_hook('addressbook_get', array($this, 'get_address_book')); 32 $this->add_hook('contact_form', array($this, 'contact_form')); 32 33 33 34 // extend include path to load bundled Horde classes … … 113 114 return $this->sources; 114 115 } 116 117 118 /** 119 * Plugin hook called before rendering the contact form or detail view 120 */ 121 public function contact_form($p) 122 { 123 // extend the list of contact fields to be displayed in the 'info' section 124 if (is_array($p['form']['info'])) { 125 $p['form']['info']['content']['initials'] = array('size' => 6); 126 $p['form']['info']['content']['anniversary'] = array('size' => 12, 'render_func' => 'rcmail_format_date_col'); 127 128 // TODO: add more Kolab-specific fields 129 130 // TODO: re-order fields 131 } 132 133 return $p; 134 } 115 135 116 136 } -
trunk/plugins/kolab_addressbook/lib/rcube_kolab.php
r4205 r4244 2 2 3 3 require_once 'Horde/Kolab/Storage/List.php'; 4 require_once 'Horde/Kolab/Format.php'; 4 5 require_once 'Horde/Auth.php'; 5 6 require_once 'Horde/Auth/kolab.php'; … … 49 50 } 50 51 } 52 53 54 /** 55 * Get instance of a Kolab (XML) format object 56 * 57 * @param string Data type (contact,event,task,note) 58 * @return object Horde_Kolab_Format_XML The format object 59 */ 60 public static function get_format($type) 61 { 62 self::setup(); 63 return Horde_Kolab_Format::factory('XML', $type); 64 } 51 65 52 66 /** -
trunk/plugins/kolab_addressbook/rcube_kolab_contacts.php
r4206 r4244 16 16 public $readonly = true; 17 17 public $groups = true; 18 public $coltypes = array( 19 'name' => array('limit' => 1), 20 'firstname' => array('limit' => 1), 21 'surname' => array('limit' => 1), 22 'middlename' => array('limit' => 1), 23 'prefix' => array('limit' => 1), 24 'suffix' => array('limit' => 1), 25 'nickname' => array('limit' => 1), 26 'jobtitle' => array('limit' => 1), 27 'organization' => array('limit' => 1), 28 'department' => array('limit' => 1), 29 'gender' => array('limit' => 1), 30 'birthday' => array('limit' => 1), 31 'email' => array(), 32 'phone' => array(), 33 'im' => array('limit' => 1), 34 'website' => array('limit' => 1), 35 'address' => array(), 36 'notes' => array(), 37 // define additional coltypes 38 '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-url 41 ); 18 42 19 43 private $gid; … … 29 53 private $result; 30 54 private $imap_folder = 'INBOX/Contacts'; 55 private $gender_map = array(0 => 'male', 1 => 'female'); 31 56 32 57 … … 35 60 if ($imap_folder) 36 61 $this->imap_folder = $imap_folder; 62 63 // extend coltypes configuration 64 $format = rcube_kolab::get_format('contact'); 65 $this->coltypes['phone']['subtypes'] = $format->_phone_types; 66 $this->coltypes['address']['subtypes'] = $format->_address_types; 67 $this->coltypes['anniversary']['label'] = rcube_label('anniversary'); 37 68 38 69 // fetch objects from the given IMAP folder … … 294 325 private function _to_rcube_contact($record) 295 326 { 296 returnarray(327 $out = array( 297 328 'ID' => md5($record['uid']), 298 329 'name' => $record['full-name'], 299 330 'firstname' => $record['given-name'], 331 'middlename' => $record['middle-names'], 300 332 'surname' => $record['last-name'], 301 'email' => $record['emails'], 333 'prefix' => $record['prefix'], 334 'suffix' => $record['suffix'], 335 'nickname' => $record['nick-name'], 336 'organization' => $record['organization'], 337 'department' => $record['department'], 338 'jobtitle' => $record['job-title'], 339 'initials' => $record['initials'], 340 'birthday' => $record['birthday'], 341 'anniversary' => $record['anniversary'], 342 'email' => array(), 343 'phone' => array(), 344 'notes' => $record['body'], 302 345 ); 346 347 if (isset($record['gender'])) 348 $out['gender'] = $this->gender_map[$record['gender']]; 349 350 foreach ((array)$record['email'] as $i => $email) 351 $out['email'][] = $email['smtp-address']; 352 353 foreach ((array)$record['phone'] as $i => $phone) 354 $out['phone:'.$phone['type']][] = $phone['number']; 355 356 if ($record['im-address']) 357 $out['im:aim'] = array($record['im-address']); 358 if ($record['web-page']) 359 $out['website:work'] = array($record['web-page']); 360 361 if ($record['addr-home-type']) { 362 $key = 'address:' . $record['addr-home-type']; 363 $out[$key][] = array( 364 'street' => $record['addr-home-street'], 365 'locality' => $record['addr-home-locality'], 366 'zipcode' => $record['addr-home-postal-code'], 367 'region' => $record['addr-home-region'], 368 'country' => $record['addr-home-country'], 369 ); 370 } 371 372 // remove empty fields 373 return array_filter($out); 303 374 } 304 375
Note: See TracChangeset
for help on using the changeset viewer.
