/** * * @param mixed $handler_id The ID of the handler. * @param array &$data The local request data. */ public function _show_list($handler_id, array &$data) { if ($handler_id == 'mycontacts_xml') { $schemadb_person = midcom_helper_datamanager2_schema::load_database($this->_config->get('schemadb_person')); $datamanager = new midcom_helper_datamanager2_datamanager($schemadb_person); $xml = '<contacts></contacts>'; $simplexml = simplexml_load_string($xml); foreach ($data['mycontacts'] as $person) { $contact = $simplexml->addChild('contact'); $contact->addAttribute('guid', $person->guid); $datamanager->autoset_storage($person); $person_data = $datamanager->get_content_xml(); foreach ($person_data as $key => $value) { $contact->addChild($key, $value); } $mc = midcom_db_member::new_collector('uid', $person->id); $memberships = $mc->get_values('gid'); $qb = org_openpsa_contacts_group_dba::new_query_builder(); $qb->add_constraint('gid', 'IN', $memberships); $qb->add_constraint('orgOpenpsaObtype', '>', org_openpsa_contacts_list_dba::MYCONTACTS); $organisations = $qb->execute(); foreach ($organisations as $organisation) { $contact->addChild('company', str_replace('&', '&', ${$organisation}->get_label())); } } echo $simplexml->asXml(); } else { midcom_show_style("show-mycontacts-header"); foreach ($data['mycontacts'] as $person) { $data['person'] = $person; midcom_show_style("show-mycontacts-item"); } midcom_show_style("show-mycontacts-footer"); } }
/** * Make XML out of an object loaded into datamanager * * @param midcom_helper_datamanager2_datamanager $datamanager * @return xmldata */ function dm2data($datamanager, $fallback_label = 'default', $additional_data = array()) { $content = $datamanager->get_content_xml(); $content['guid'] = $datamanager->storage->object->guid; $label = $datamanager->schema->name; if ($label == 'default') { $label = $fallback_label; } $content = array_merge($content, $additional_data); return $this->array2data($content, $label); }