Added functionality to support post modification (keeping a separate timestamp for modification time).

svn path=/trunk/boinc/; revision=1743
This commit is contained in:
David Anderson 2003-07-19 00:27:12 +00:00
parent 23acdfd476
commit 700b08c992
1 changed files with 11 additions and 2 deletions

View File

@ -130,8 +130,9 @@ class Post {
var $user;
var $timestamp;
var $content;
var $modified;
function Post($id = -1, $thread = -1, $user = -1, $timestamp = 0, $content = "") {
function Post($id = -1, $thread = -1, $user = -1, $timestamp = 0, $content = "", $modified = NULL) {
$vars = get_class_vars('Post');
foreach ($vars as $var => $value)
$this->$var = $$var;
@ -144,6 +145,14 @@ class Post {
return false;
return ($this->id = sql_insert_id());
}
function update($content) {
$sql = "UPDATE post SET content = \"$content\", modified = UNIX_TIMESTAMP() WHERE id = " . $this->id;
$result = sql_query($sql);
if (!$result)
return false;
return true;
}
}
/* group database functions */
@ -187,7 +196,7 @@ function getNextPost($result) {
return false;
foreach ($post as $var => $value)
$post[$var] = stripslashes($value);
return new Post($post['id'], $post['thread'], $post['user'], $post['timestamp'], $post['content']);
return new Post($post['id'], $post['thread'], $post['user'], $post['timestamp'], $post['content'], $post['modified']);
}
/* specific database functions */