From 3d7902e978eeb46b73855ec696a04bea0e564d90 Mon Sep 17 00:00:00 2001 From: Joey Schulze Date: Thu, 11 Jul 2019 21:51:42 +0200 Subject: [PATCH] Allow to edit calendar comments --- class/calendar_item.class.php | 13 ++++++++++--- class/calendar_item_log.class.php | 16 ++++++++++++++++ src/Infodrom/calendar/index.wml | 6 +++++- 3 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 class/calendar_item_log.class.php diff --git a/class/calendar_item.class.php b/class/calendar_item.class.php index b8fb50d..08c656d 100644 --- a/class/calendar_item.class.php +++ b/class/calendar_item.class.php @@ -108,26 +108,33 @@ class Calendar_Item extends DatabaseTable { $items = array(); $items[] = array('dt' => substr($this->data->created,0,16), + 'edit' => false, 'log' => 'Item created'); - $sql = sprintf("SELECT name,url,comment,sys_edit,sys_user " . + $sql = sprintf("SELECT id,name,url,comment,sys_edit,sys_user " . "FROM calendar_item_log WHERE dav_id = %d ORDER BY sys_edit", $this->id); foreach ($this->fetchObjectList($sql) as $row) { if (strlen($row->url)) $items[] = array('dt' => substr($row->sys_edit,0,16), + 'edit' => false, 'log' => sprintf('%s', $row->url, $row->name ? $row->name : 'Link')); if (strlen($row->comment)) $items[] = array('dt' => substr($row->sys_edit,0,16), + 'id' => $row->id, + 'edit' => true, 'log' => $row->comment); } foreach ($items as $item) { $color = !$color; - $out .= sprintf('
%s
%s
', + $out .= sprintf('
%s
%s
', $color, - $item['dt'], $item['log']); + $item['dt'], + $item['edit'] ? ' editable' : '', + $item['edit'] ? sprintf(' route="Calendar_Item_Log/EditComment" item_id="%d"', $item['id']) : '', + $item['log']); } return array('html' => array('log' => $out)); diff --git a/class/calendar_item_log.class.php b/class/calendar_item_log.class.php new file mode 100644 index 0000000..4d361b2 --- /dev/null +++ b/class/calendar_item_log.class.php @@ -0,0 +1,16 @@ +modify('comment', utf8_decode($data['content'])); + } +} diff --git a/src/Infodrom/calendar/index.wml b/src/Infodrom/calendar/index.wml index 558e86c..7c63676 100644 --- a/src/Infodrom/calendar/index.wml +++ b/src/Infodrom/calendar/index.wml @@ -2,6 +2,7 @@ +