Added commenting system
This commit is contained in:
@@ -25,7 +25,7 @@ class CrashStats
|
||||
{
|
||||
$ret = array();
|
||||
$where = $this->filter->getWhere();
|
||||
$q = "select count(r.id) as nr, s.id as signature_id, s.signature as signature_text from reports r join signature s on r.signature_id = s.id $where group by signature_id order by nr desc";
|
||||
$q = "select count(r.id) as nr, s.id as signature_id, s.signature as signature_text, s.has_comments from reports r join signature s on r.signature_id = s.id $where group by signature_id order by nr desc";
|
||||
$q .= kl_str_sql(" limit !i", 100);
|
||||
if (false !== $cached = Memc::getq($q)) return $cached;
|
||||
|
||||
@@ -153,4 +153,41 @@ class CrashStats
|
||||
Memc::setq($q, $ret);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
function updateCommentCount($id)
|
||||
{
|
||||
$q = kl_str_sql("update signature set has_comments=(select count(*) as count from comment where signature_id=!i) where id=!i", $id, $id);
|
||||
DBH::$db->query($q);
|
||||
}
|
||||
|
||||
function addSignatureComment($id, $text)
|
||||
{
|
||||
global $S;
|
||||
$q = kl_str_sql("insert into comment (signature_id, user_id, comment) values (!i, !i, !s)", $id, $S->user_id, $text);
|
||||
DBH::$db->query($q);
|
||||
self::updateCommentCount($id);
|
||||
}
|
||||
|
||||
function getSignatureComments($id)
|
||||
{
|
||||
$ret = array();
|
||||
$q = kl_str_sql("select c.*, u.name, u.email from comment c join users u on c.user_id = u.user_id where signature_id=!i order by id asc;", $id);
|
||||
if (!$res = DBH::$db->query($q)) return;
|
||||
|
||||
while ($row = DBH::$db->fetchRow($res))
|
||||
{
|
||||
$c = new stdClass;
|
||||
DBH::$db->loadFromDbRow($c, $res, $row);
|
||||
$ret[] = $c;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
function delSignatureComment($id, $del_id)
|
||||
{
|
||||
$q = kl_str_sql("delete from comment where id=!i", $del_id);
|
||||
DBH::$db->query($q);
|
||||
self::updateCommentCount($id);
|
||||
}
|
||||
}
|
||||
1514
htdocs/lib/Markdown.php
Normal file
1514
htdocs/lib/Markdown.php
Normal file
File diff suppressed because it is too large
Load Diff
@@ -59,5 +59,14 @@ create table reports(
|
||||
create table signature(
|
||||
id integer not null auto_increment primary key,
|
||||
hash varchar(32) not null unique,
|
||||
signature text
|
||||
signature text,
|
||||
has_comments integer
|
||||
);
|
||||
|
||||
create table comment(
|
||||
id integer not null auto_increment primary key,
|
||||
signature_id integer,
|
||||
user_id integer,
|
||||
commented timestamp not null default current_timestamp,
|
||||
comment text
|
||||
);
|
||||
Reference in New Issue
Block a user