From 2d1e9126cb10f52e7711ce121f8bdaa5bdc71aa4 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sun, 16 Sep 2001 11:33:14 +0000 Subject: - Added the new user module! --- includes/comment.inc | 46 ++++++++++++------------ includes/common.inc | 27 ++++++-------- includes/conf.php | 6 ++-- includes/locale.inc | 2 +- includes/node.inc | 6 ++-- includes/search.inc | 2 +- includes/theme.inc | 48 +++++++------------------ includes/user.inc | 99 ---------------------------------------------------- 8 files changed, 55 insertions(+), 181 deletions(-) delete mode 100644 includes/user.inc (limited to 'includes') diff --git a/includes/comment.inc b/includes/comment.inc index 30bf24e3e..a87a1a429 100644 --- a/includes/comment.inc +++ b/includes/comment.inc @@ -10,13 +10,13 @@ $cmodes = array(1 => "List - min", 2 => "List - max", 3 => "Threaded - min", 4 = $corder = array(1 => "Date - new", 2 => "Date - old", 3 => "Rate - high", 4 => "Rate - low"); class Comment { - function Comment($name, $subject, $comment, $timestamp, $url, $fake_email, $score, $votes, $cid, $lid) { + function Comment($uid, $name, $subject, $comment, $timestamp, $url, $score, $votes, $cid, $lid) { + $this->uid = $uid; $this->name = $name; $this->subject = $subject; $this->comment = $comment; $this->timestamp = $timestamp; $this->url = $url; - $this->fake_email = $fake_email; $this->score = $score; $this->votes = $votes; $this->cid = $cid; @@ -27,7 +27,7 @@ class Comment { function comment_moderate($moderate) { global $user, $comment_votes; - if ($user->id && $moderate) { + if ($user->uid && $moderate) { $none = $comment_votes[key($comment_votes)]; foreach ($moderate as $id=>$vote) { @@ -35,8 +35,8 @@ function comment_moderate($moderate) { $id = check_output($id); $vote = check_output($vote); $comment = db_fetch_object(db_query("SELECT * FROM comments WHERE cid = '$id'")); - if ($comment && !field_get($comment->users, $user->id)) { - $result = db_query("UPDATE comments SET score = score $vote, votes = votes + 1, users = '". field_set($comment->users, $user->id, $vote) ."' WHERE cid = '$id'"); + if ($comment && !field_get($comment->users, $user->uid)) { + $result = db_query("UPDATE comments SET score = score $vote, votes = votes + 1, users = '". field_set($comment->users, $user->uid, $vote) ."' WHERE cid = '$id'"); } } } @@ -45,14 +45,14 @@ function comment_moderate($moderate) { function comment_settings($mode, $order, $threshold) { global $user; - if ($user->id) $user = user_save($user, array("mode" => $mode, "sort" => $order, "threshold" => $threshold)); + if ($user->uid) $user = user_save($user, array("mode" => $mode, "sort" => $order, "threshold" => $threshold)); } function comment_form($edit) { global $REQUEST_URI, $user; // name field: - $form .= form_item(t("Your name"), format_name($user->name)); + $form .= form_item(t("Your name"), format_name($user)); // subject field: $form .= form_textfield(t("Subject"), "subject", $edit[subject], 50, 64); @@ -79,8 +79,8 @@ function comment_reply($pid, $id) { global $theme; if ($pid) { - $item = db_fetch_object(db_query("SELECT c.*, u.name FROM comments c LEFT JOIN users u ON c.author = u.id WHERE c.cid = '$pid'")); - comment_view(new Comment($item->name, $item->subject, $item->comment, $item->timestamp, $item->url, $item->fake_email, comment_score($comment), $comment->votes, $item->cid, $item->lid), t("reply to this comment")); + $item = db_fetch_object(db_query("SELECT c.*, u.name FROM comments c LEFT JOIN user u ON c.author = u.uid WHERE c.cid = '$pid'")); + comment_view(new Comment($item->uid, $item->name, $item->subject, $item->comment, $item->timestamp, $item->url, comment_score($comment), $comment->votes, $item->cid, $item->lid), t("reply to this comment")); } else { node_view(node_get_object(array("nid" => $id))); @@ -99,7 +99,7 @@ function comment_preview($edit) { global $REQUEST_URI, $theme, $user; // Preview comment: - comment_view(new Comment($user->name, check_preview($edit[subject]), check_preview($edit[comment]), time(), check_preview($user->url), check_preview($user->fake_email), 0, 0, 0, 0), t("reply to this comment")); + comment_view(new Comment($user->uid, $user->name, check_preview($edit[subject]), check_preview($edit[comment]), time(), check_preview($user->homepage), 0, 0, 0, 0), t("reply to this comment")); $theme->box(t("Reply"), comment_form($edit)); } @@ -125,7 +125,7 @@ function comment_post($edit) { watchdog("special", "comment: added '$edit[subject]'"); // add comment to database: - db_query("INSERT INTO comments (lid, pid, author, subject, comment, hostname, timestamp, score) VALUES ('". check_input($edit[id]) ."', '". check_input($edit[pid]) ."', '$user->id', '". check_input($edit[subject]) ."', '". check_input($edit[comment]) ."', '". getenv("REMOTE_ADDR") ."', '". time() ."', '". ($user->name ? 1 : 0) ."')"); + db_query("INSERT INTO comments (lid, pid, author, subject, comment, hostname, timestamp, score) VALUES ('". check_input($edit[id]) ."', '". check_input($edit[pid]) ."', '$user->uid', '". check_input($edit[subject]) ."', '". check_input($edit[comment]) ."', '". getenv("REMOTE_ADDR") ."', '". time() ."', '". ($user->name ? 1 : 0) ."')"); // clear cache: cache_clear(); @@ -150,7 +150,7 @@ function comment_moderation($comment) { // preview comment: $output .= " "; } - else if ($user->id && $user->name != $comment->name && !field_get($comment->users, $user->id)) { + else if ($user->uid && $user->name != $comment->name && !field_get($comment->users, $user->uid)) { // comment hasn't been moderated yet: foreach ($comment_votes as $key=>$value) $options .= " \n"; $output .= "\n"; @@ -181,7 +181,7 @@ function comment_order($order) { } function comment_query($lid, $order, $pid = -1) { - $query .= "SELECT c.*, u.* FROM comments c LEFT JOIN users u ON c.author = u.id WHERE c.lid = '$lid'"; + $query .= "SELECT c.*, u.* FROM comments c LEFT JOIN user u ON c.author = u.uid WHERE c.lid = '$lid'"; if ($pid >= 0) $query .= " AND pid = '$pid'"; if ($order == 1) $query .= " ORDER BY c.timestamp DESC"; else if ($order == 2) $query .= " ORDER BY c.timestamp"; @@ -216,13 +216,13 @@ function comment_view($comment, $folded = 0) { // display comment: if ($folded) $theme->comment($comment, $folded); - else print "lid&cid=$comment->cid#$comment->cid") ."\">". check_output($comment->subject) ." by ". format_name($comment->name) ." ($comment->score)

"; + else print "lid&cid=$comment->cid#$comment->cid") ."\">". check_output($comment->subject) ." by ". format_name($comment) ." ($comment->score)

"; } function comment_thread_min($cid, $threshold) { global $user; - $result = db_query("SELECT c.*, u.* FROM comments c LEFT JOIN users u ON c.author = u.id WHERE c.pid = '$cid' ORDER BY c.timestamp, c.cid"); + $result = db_query("SELECT c.*, u.* FROM comments c LEFT JOIN user u ON c.author = u.uid WHERE c.pid = '$cid' ORDER BY c.timestamp, c.cid"); while ($comment = db_fetch_object($result)) { print "