Changeset View
Changeset View
Standalone View
Standalone View
plugins/libkolab/lib/kolab_storage_cache_contact.php
Show All 32 Lines | class kolab_storage_cache_contact extends kolab_storage_cache | ||||
* @override | * @override | ||||
*/ | */ | ||||
protected function _serialize($object) | protected function _serialize($object) | ||||
{ | { | ||||
$sql_data = parent::_serialize($object); | $sql_data = parent::_serialize($object); | ||||
$sql_data['type'] = $object['_type']; | $sql_data['type'] = $object['_type']; | ||||
// columns for sorting | // columns for sorting | ||||
$sql_data['name'] = rcube_charset::clean($object['name'] . $object['prefix']); | $sql_data['name'] = rcube_charset::clean(($object['name'] ?? null) . ($object['prefix'] ?? null)); | ||||
$sql_data['firstname'] = rcube_charset::clean($object['firstname'] . $object['middlename'] . $object['surname']); | $sql_data['firstname'] = rcube_charset::clean(($object['firstname'] ?? null) . ($object['middlename'] ?? null) . ($object['surname'] ?? null)); | ||||
$sql_data['surname'] = rcube_charset::clean($object['surname'] . $object['firstname'] . $object['middlename']); | $sql_data['surname'] = rcube_charset::clean(($object['surname'] ?? null) . ($object['firstname'] ?? null) . ($object['middlename'] ?? null)); | ||||
$sql_data['email'] = rcube_charset::clean(is_array($object['email']) ? $object['email'][0] : $object['email']); | $sql_data['email'] = rcube_charset::clean(is_array($object['email'] ?? null) ? $object['email'][0] : ($object['email'] ?? null)); | ||||
if (is_array($sql_data['email'])) { | if (is_array($sql_data['email'] ?? null)) { | ||||
$sql_data['email'] = $sql_data['email']['address']; | $sql_data['email'] = $sql_data['email']['address']; | ||||
} | } | ||||
// avoid value being null | // avoid value being null | ||||
if (empty($sql_data['email'])) { | if (empty($sql_data['email'] ?? null)) { | ||||
$sql_data['email'] = ''; | $sql_data['email'] = ''; | ||||
} | } | ||||
// use organization if name is empty | // use organization if name is empty | ||||
if (empty($sql_data['name']) && !empty($object['organization'])) { | if (empty($sql_data['name'] ?? null) && !empty($object['organization'] ?? null)) { | ||||
$sql_data['name'] = rcube_charset::clean($object['organization']); | $sql_data['name'] = rcube_charset::clean($object['organization']); | ||||
} | } | ||||
// make sure some data is not longer that database limit (#5291) | // make sure some data is not longer that database limit (#5291) | ||||
foreach ($this->extra_cols as $col) { | foreach ($this->extra_cols as $col) { | ||||
if (strlen($sql_data[$col]) > $this->extra_cols_max) { | if (strlen($sql_data[$col]) > $this->extra_cols_max) { | ||||
$sql_data[$col] = rcube_charset::clean(substr($sql_data[$col], 0, $this->extra_cols_max)); | $sql_data[$col] = rcube_charset::clean(substr($sql_data[$col], 0, $this->extra_cols_max)); | ||||
} | } | ||||
} | } | ||||
return $sql_data; | return $sql_data; | ||||
} | } | ||||
} | } |