Changeset View
Changeset View
Standalone View
Standalone View
plugins/libkolab/lib/kolab_format_file.php
Show All 35 Lines | class kolab_format_file extends kolab_format | ||||
* | * | ||||
* @param array Object data as hash array | * @param array Object data as hash array | ||||
*/ | */ | ||||
public function set(&$object) | public function set(&$object) | ||||
{ | { | ||||
// set common object properties | // set common object properties | ||||
parent::set($object); | parent::set($object); | ||||
$this->obj->setCategories(self::array2vector($object['categories'])); | $this->obj->setCategories(self::array2vector($object['categories'] ?? null)); | ||||
if (isset($object['notes'])) { | if (isset($object['notes'])) { | ||||
$this->obj->setNote($object['notes']); | $this->obj->setNote($object['notes']); | ||||
} | } | ||||
// Add file attachment | // Add file attachment | ||||
if (!empty($object['_attachments'])) { | if (!empty($object['_attachments'] ?? null)) { | ||||
$cid = key($object['_attachments']); | $cid = key($object['_attachments']); | ||||
$attach_attr = $object['_attachments'][$cid]; | $attach_attr = $object['_attachments'][$cid]; | ||||
$attach = new Attachment; | $attach = new Attachment; | ||||
$attach->setLabel((string)$attach_attr['name']); | $attach->setLabel((string)$attach_attr['name']); | ||||
$attach->setUri('cid:' . $cid, $attach_attr['mimetype']); | $attach->setUri('cid:' . $cid, $attach_attr['mimetype']); | ||||
$this->obj->setFile($attach); | $this->obj->setFile($attach); | ||||
▲ Show 20 Lines • Show All 61 Lines • ▼ Show 20 Lines | class kolab_format_file extends kolab_format | ||||
* Callback for kolab_storage_cache to get object specific tags to cache | * Callback for kolab_storage_cache to get object specific tags to cache | ||||
* | * | ||||
* @return array List of tags to save in cache | * @return array List of tags to save in cache | ||||
*/ | */ | ||||
public function get_tags() | public function get_tags() | ||||
{ | { | ||||
$tags = array(); | $tags = array(); | ||||
foreach ((array)$this->data['categories'] as $cat) { | foreach ((array)($this->data['categories'] ?? null) as $cat) { | ||||
$tags[] = rcube_utils::normalize_string($cat); | $tags[] = rcube_utils::normalize_string($cat); | ||||
} | } | ||||
// Add file mimetype to tags | // Add file mimetype to tags | ||||
if (!empty($this->data['_attachments'])) { | if (!empty($this->data['_attachments'] ?? null)) { | ||||
reset($this->data['_attachments']); | reset($this->data['_attachments']); | ||||
$key = key($this->data['_attachments']); | $key = key($this->data['_attachments']); | ||||
$attachment = $this->data['_attachments'][$key]; | $attachment = $this->data['_attachments'][$key]; | ||||
if ($attachment['mimetype']) { | if ($attachment['mimetype'] ?? false) { | ||||
$tags[] = $attachment['mimetype']; | $tags[] = $attachment['mimetype']; | ||||
} | } | ||||
} | } | ||||
return $tags; | return $tags; | ||||
} | } | ||||
} | } |