Allow to edit calendar comments
[infodrom.org/service.infodrom.org] / class / calendar_item.class.php
index b8fb50d..08c656d 100644 (file)
@@ -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('<a href="%s" target="_blank">%s</a>',
                                           $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('<div class="row%d"><div class="logl">%s</div><div class="logr">%s</div><div class="clear"></div></div>',
+       $out .= sprintf('<div class="row%d"><div class="logl">%s</div><div class="logr%s"%s>%s</div><div class="clear"></div></div>',
                        $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));