Beispiel #1
0
 public function addComment($text, $eid)
 {
     $note = new Dase_DBO_Comment($this->db);
     $note->item_id = $this->id;
     //todo: security! filter input....
     $note->text = $text;
     $note->p_collection_ascii_id = $this->p_collection_ascii_id;
     $note->p_serial_number = $this->serial_number;
     $note->updated = date(DATE_ATOM);
     $note->updated_by_eid = $eid;
     $res = $note->insert();
     //denormalization
     $this->comments_count = $this->comments_count + 1;
     $this->comments_updated = $note->updated;
     $this->update();
     $this->buildSearchIndex();
     return $res;
 }
<?php

include 'config.php';
$comms = new Dase_DBO_Comment($db);
foreach ($comms->find() as $c) {
    $item = new Dase_DBO_Item($db);
    $item->load($c->item_id);
    $item->comments_updated = $c->updated;
    $item->comments_count = $item->comment_count + 1;
    $item;
    $item->update();
}
$cs = new Dase_DBO_Collection($db);
$i = 0;
foreach ($cs->find() as $c) {
    print "\nworking on {$c->collection_name}\n\n";
    foreach ($c->getItems() as $item) {
        $i++;
        $item = clone $item;
        if (!$item->collection_name) {
            $item->collection_name = $c->collection_name;
            $type = $item->getItemType();
            $item->item_type_ascii_id = $type->ascii_id;
            $item->item_type_name = $type->name;
            $item->update();
        }
        print "\n{$i}";
    }
}
Beispiel #3
0
 public function deleteComment($r)
 {
     $user = $r->getUser();
     if (!$user->can('read', $this->item)) {
         $r->renderError(401, 'user cannot read this item');
     }
     $comment = new Dase_DBO_Comment($this->db);
     $comment->load($r->get('comment_id'));
     if ($user->eid == $comment->updated_by_eid) {
         $comment->delete();
     }
     //todo: I don't think we are indexing comments (??)
     //$this->item->buildSearchIndex();
     $r->renderResponse('deleted comment ' . $comment->id);
 }