Changeset View
Changeset View
Standalone View
Standalone View
plugins/libkolab/lib/kolab_storage_config.php
Show First 20 Lines • Show All 180 Lines • ▼ Show 20 Lines | public function save(&$object, $type) | ||||
} | } | ||||
$folder = $this->find_folder($object); | $folder = $this->find_folder($object); | ||||
if ($type) { | if ($type) { | ||||
$object['type'] = $type; | $object['type'] = $type; | ||||
} | } | ||||
$status = $folder->save($object, self::FOLDER_TYPE . '.' . $object['type'], $object['uid']); | $status = $folder->save($object, self::FOLDER_TYPE . '.' . ($object['type'] ?? null), $object['uid'] ?? null); | ||||
// on success, update cached tags list | // on success, update cached tags list | ||||
if ($status && $object['category'] == 'tag' && is_array($this->tags)) { | if ($status && ($object['category'] ?? null) == 'tag' && is_array($this->tags)) { | ||||
$found = false; | $found = false; | ||||
unset($object['_formatobj']); // we don't need it anymore | unset($object['_formatobj']); // we don't need it anymore | ||||
foreach ($this->tags as $idx => $tag) { | foreach ($this->tags as $idx => $tag) { | ||||
if ($tag['uid'] == $object['uid']) { | if ($tag['uid'] == $object['uid']) { | ||||
$found = true; | $found = true; | ||||
$this->tags[$idx] = $object; | $this->tags[$idx] = $object; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | class kolab_storage_config | ||||
*/ | */ | ||||
public function find_folder($object = array()) | public function find_folder($object = array()) | ||||
{ | { | ||||
if (!$this->is_enabled()) { | if (!$this->is_enabled()) { | ||||
return; | return; | ||||
} | } | ||||
// find folder object | // find folder object | ||||
if ($object['_mailbox']) { | if ($object['_mailbox'] ?? false) { | ||||
foreach ($this->folders as $folder) { | foreach ($this->folders as $folder) { | ||||
if ($folder->name == $object['_mailbox']) { | if ($folder->name == $object['_mailbox']) { | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
else { | else { | ||||
$folder = $this->default; | $folder = $this->default; | ||||
▲ Show 20 Lines • Show All 403 Lines • ▼ Show 20 Lines | public function apply_links(&$records) | ||||
if (strpos($member, 'imap://') === 0) { | if (strpos($member, 'imap://') === 0) { | ||||
$members[$member] = $member; | $members[$member] = $member; | ||||
} | } | ||||
} | } | ||||
$members = array_values($members); | $members = array_values($members); | ||||
// assign links to objects | // assign links to objects | ||||
foreach ((array) $relation['members'] as $member) { | foreach ((array) $relation['members'] as $member) { | ||||
if (($id = $ids[$member]) !== null) { | if (($id = ($ids[$member] ?? null)) !== null) { | ||||
foreach ($id as $i) { | foreach ($id as $i) { | ||||
$records[$i]['links'] = array_unique(array_merge($records[$i]['links'], $members)); | $records[$i]['links'] = array_unique(array_merge($records[$i]['links'], $members)); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 322 Lines • Show Last 20 Lines |