Translates the keys of the first hash from the generalized Turba
attributes to the driver-specific fields. The translation is based on
the contents of $this->map.
public toDriverKeys ( array $hash ) : array | ||
$hash | array | Hash using Turba keys. |
리턴 | array | Translated version of $hash. |
/** * Translates the keys of the first hash from the generalized Turba * attributes to the driver-specific fields. The translation is based on * the contents of $this->map. * * @param array $hash Hash using Turba keys. * * @return array Translated version of $hash. */ public function toDriverKeys(array $hash) { if (isset($hash['__tags'])) { if (!is_array($hash['__tags'])) { $hash['__tags'] = $GLOBALS['injector']->getInstance('Turba_Tagger')->split($hash['__tags']); } usort($hash['__tags'], 'strcoll'); $hash['__internaltags'] = serialize($hash['__tags']); } $hash = parent::toDriverKeys($hash); if (isset($hash['name'])) { $hash['name'] = array('full-name' => $hash['name']); } /* TODO: use Horde_Kolab_Format_Xml_Type_Composite_* */ foreach (array('full-name', 'given-name', 'middle-names', 'last-name', 'initials', 'prefix', 'suffix') as $sub) { if (isset($hash[$sub])) { $hash['name'][$sub] = $hash[$sub]; unset($hash[$sub]); } } if (isset($hash['__type']) && $hash['__type'] == 'Group' && isset($hash['name']['full-name'])) { $hash['display-name'] = $hash['name']['full-name']; } if (isset($hash['emails'])) { $list = new Horde_Mail_Rfc822_List($hash['emails']); $hash['email'] = array(); foreach ($list as $address) { $hash['email'][] = array('smtp-address' => $address->bare_address); } unset($hash['emails']); } foreach (array('phone-business1', 'phone-business2', 'phone-businessfax', 'phone-car', 'phone-company', 'phone-home1', 'phone-home2', 'phone-homefax', 'phone-mobile', 'phone-pager', 'phone-radio', 'phone-assistant') as $sub) { if (isset($hash[$sub])) { if (!isset($hash['phone'])) { $hash['phone'] = array(); } $hash['phone'][] = array('type' => substr($sub, 6), 'number' => $hash[$sub]); unset($hash[$sub]); } } $address = array(); foreach (array('addr-business-street', 'addr-business-locality', 'addr-business-region', 'addr-business-postal-code', 'addr-business-country') as $sub) { if (isset($hash[$sub])) { $address[substr($sub, 14)] = $hash[$sub]; unset($hash[$sub]); } } if ($address) { $hash['address'] = array(); $address['type'] = 'business'; $hash['address'][] = $address; } $address = array(); foreach (array('addr-home-street', 'addr-home-locality', 'addr-home-region', 'addr-home-postal-code', 'addr-home-country') as $sub) { if (isset($hash[$sub])) { $address[substr($sub, 10)] = $hash[$sub]; unset($hash[$sub]); } } if ($address) { if (!isset($hash['address'])) { $hash['address'] = array(); } $address['type'] = 'home'; $hash['address'][] = $address; } if (isset($hash['categories'])) { $hash['categories'] = unserialize($hash['categories']); } if (!empty($hash['birthday'])) { $hash['birthday'] = new DateTime($hash['birthday']); } if (!empty($hash['anniversary'])) { $hash['anniversary'] = new DateTime($hash['anniversary']); } return $hash; }
/** * Extends parent function to build composed fields needed for the dn * based on the contents of $this->map. * * @param array $hash Hash using Turba keys. * * @return array Translated version of $hash. */ public function toDriverKeys(array $hash) { // First check for combined fields in the dn-fields and add them. if (is_array($this->_params['dn'])) { foreach ($this->_params['dn'] as $param) { foreach ($this->map as $turbaname => $ldapname) { if (is_array($ldapname) && isset($ldapname['attribute']) && $ldapname['attribute'] == $param) { $fieldarray = array(); foreach ($ldapname['fields'] as $mapfield) { $fieldarray[] = isset($hash[$mapfield]) ? $hash[$mapfield] : ''; } $hash[$turbaname] = Turba::formatCompositeField($ldapname['format'], $fieldarray); } } } } // Now convert the turba-fieldnames to ldap-fieldnames return parent::toDriverKeys($hash); }
/** * Translates the keys of the first hash from the generalized Turba * attributes to the driver-specific fields. The translation is based on * the contents of $this->map. * * @param array $hash Hash using Turba keys. * * @return array Translated version of $hash. */ public function toDriverKeys(array $hash) { return $this->_driver->toDriverKeys($hash); }