summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
Diffstat (limited to 'includes')
-rw-r--r--includes/comment.inc12
-rw-r--r--includes/module.inc10
-rw-r--r--includes/node.inc22
3 files changed, 21 insertions, 23 deletions
diff --git a/includes/comment.inc b/includes/comment.inc
index 8ac81fbfa..a41489651 100644
--- a/includes/comment.inc
+++ b/includes/comment.inc
@@ -78,7 +78,7 @@ function comment_reply($pid, $id) {
global $theme;
if ($pid) {
- $item = db_fetch_object(db_query("SELECT c.*, u.uid, u.name FROM comments c LEFT JOIN users u ON c.author = u.uid WHERE c.cid = '$pid'"));
+ $item = db_fetch_object(db_query("SELECT c.*, u.uid, u.name FROM comments c LEFT JOIN users u ON c.uid = u.uid WHERE c.cid = '$pid'"));
comment_view(new Comment($item->uid, $item->name, $item->subject, $item->comment, $item->timestamp, $item->url, $item->cid, $item->lid), t("reply to this comment"));
}
else {
@@ -124,7 +124,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) VALUES ('". check_input($edit[id]) ."', '". check_input($edit[pid]) ."', '$user->uid', '". check_input($edit[subject]) ."', '". check_input($edit[comment]) ."', '". getenv("REMOTE_ADDR") ."', '". time() ."')");
+ db_query("INSERT INTO comments (lid, pid, uid, subject, comment, hostname, timestamp) VALUES ('". check_input($edit[id]) ."', '". check_input($edit[pid]) ."', '$user->uid', '". check_input($edit[subject]) ."', '". check_input($edit[comment]) ."', '". getenv("REMOTE_ADDR") ."', '". time() ."')");
// clear cache:
cache_clear();
@@ -176,7 +176,7 @@ function comment_order($order) {
function comment_query($lid, $order, $pid = -1) {
- $query .= "SELECT c.cid, c.pid, c.lid, c.subject, c.comment, c.timestamp, u.uid, u.name, AVG(m.score) AS score, COUNT(m.cid) AS votes FROM comments c LEFT JOIN users u ON c.author = u.uid LEFT JOIN moderate m ON c.cid = m.cid WHERE c.lid = '$lid'";
+ $query .= "SELECT c.cid, c.pid, c.lid, c.subject, c.comment, c.timestamp, u.uid, u.name, AVG(m.score) AS score, COUNT(m.cid) AS votes FROM comments c LEFT JOIN users u ON c.uid = u.uid LEFT JOIN moderate m ON c.cid = m.cid WHERE c.lid = '$lid'";
if ($pid >= 0) {
$query .= " AND pid = '$pid'";
@@ -235,7 +235,7 @@ function comment_view($comment, $folded = 0) {
function comment_thread_min($cid, $threshold) {
global $user;
- $result = db_query("SELECT c.cid, c.pid, c.lid, c.subject, c.comment, c.timestamp, u.uid, u.name, AVG(m.score) AS score, COUNT(m.cid) AS votes FROM comments c LEFT JOIN users u ON c.author = u.uid LEFT JOIN moderate m ON c.cid = m.cid WHERE c.pid = '$cid' GROUP BY c.cid, c.pid, c.lid, c.subject, c.comment, c.timestamp, u.uid, u.name ORDER BY c.timestamp");
+ $result = db_query("SELECT c.cid, c.pid, c.lid, c.subject, c.comment, c.timestamp, u.uid, u.name, AVG(m.score) AS score, COUNT(m.cid) AS votes FROM comments c LEFT JOIN users u ON c.uid = u.uid LEFT JOIN moderate m ON c.cid = m.cid WHERE c.pid = '$cid' GROUP BY c.cid, c.pid, c.lid, c.subject, c.comment, c.timestamp, u.uid, u.name ORDER BY c.timestamp");
while ($comment = db_fetch_object($result)) {
print "<ul>";
@@ -257,7 +257,7 @@ function comment_thread_max($cid, $mode, $threshold, $level = 0, $dummy = 0) {
** in terms of speed and size.
*/
- $result = db_query("SELECT c.cid, c.pid, c.lid, c.subject, c.comment, c.timestamp, u.uid, u.name, AVG(m.score) AS score, COUNT(m.cid) AS votes FROM comments c LEFT JOIN users u ON c.author = u.uid LEFT JOIN moderate m ON c.cid = m.cid WHERE c.pid = '$cid' GROUP BY c.cid, c.pid, c.lid, c.subject, c.comment, c.timestamp, u.uid, u.name ORDER BY c.timestamp");
+ $result = db_query("SELECT c.cid, c.pid, c.lid, c.subject, c.comment, c.timestamp, u.uid, u.name, AVG(m.score) AS score, COUNT(m.cid) AS votes FROM comments c LEFT JOIN users u ON c.uid = u.uid LEFT JOIN moderate m ON c.cid = m.cid WHERE c.pid = '$cid' GROUP BY c.cid, c.pid, c.lid, c.subject, c.comment, c.timestamp, u.uid, u.name ORDER BY c.timestamp");
while ($comment = db_fetch_object($result)) {
print "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><tr><td width=\"". ($level * 25) ."\">&nbsp;</td><td>\n";
@@ -307,7 +307,7 @@ function comment_render($lid, $cid) {
$theme->box(t("Control panel"), $theme->comment_controls($threshold, $mode, $order));
if ($cid > 0) {
- $result = db_query("SELECT c.cid, c.pid, c.lid, c.subject, c.comment, c.timestamp, u.uid, u.name, AVG(m.score) AS score, COUNT(m.cid) AS votes FROM comments c LEFT JOIN users u ON c.author = u.uid LEFT JOIN moderate m ON c.cid = m.cid WHERE c.cid = '$cid' GROUP BY c.cid, c.pid, c.lid, c.subject, c.comment, c.timestamp, u.uid, u.name");
+ $result = db_query("SELECT c.cid, c.pid, c.lid, c.subject, c.comment, c.timestamp, u.uid, u.name, AVG(m.score) AS score, COUNT(m.cid) AS votes FROM comments c LEFT JOIN users u ON c.uid = u.uid LEFT JOIN moderate m ON c.cid = m.cid WHERE c.cid = '$cid' GROUP BY c.cid, c.pid, c.lid, c.subject, c.comment, c.timestamp, u.uid, u.name");
if ($comment = db_fetch_object($result)) {
comment_view($comment, comment_links($comment));
}
diff --git a/includes/module.inc b/includes/module.inc
index 4b6959c34..479dcde3f 100644
--- a/includes/module.inc
+++ b/includes/module.inc
@@ -53,19 +53,21 @@ function module_hook($name, $hook) {
// rehash module-exported blocks:
function module_rehash_blocks($name) {
db_query("UPDATE blocks SET remove = '1' WHERE module = '$name'");
+
if ($blocks = module_invoke($name, "block")) {
- foreach ($blocks as $offset=>$block) {
- foreach ($block as $item=>$data) {
+ foreach ($blocks as $delta => $block) {
+ foreach ($block as $item => $data) {
$block[$item] = addslashes($data);
}
if (!db_fetch_object(db_query("SELECT * FROM blocks WHERE module = '$name' AND name = '$block[info]'"))) {
- db_query("INSERT INTO blocks (name, module, delta) VALUES ('$block[info]', '$name', '$offset')");
+ db_query("INSERT INTO blocks (name, module, delta) VALUES ('$block[info]', '$name', '$delta')");
}
else {
- db_query("UPDATE blocks SET delta = '$offset', remove = '0' WHERE module = '$name' AND name = '$block[info]'");
+ db_query("UPDATE blocks SET delta = '$delta', remove = '0' WHERE module = '$name' AND name = '$block[info]'");
}
}
}
+
db_query("DELETE FROM blocks WHERE module = '$name' AND remove = '1'");
}
diff --git a/includes/node.inc b/includes/node.inc
index 07781de26..3f15fa59d 100644
--- a/includes/node.inc
+++ b/includes/node.inc
@@ -18,18 +18,15 @@ function _node_get($conditions) {
}
if ($type) {
- $result = db_query("SELECT n.*, l.*, u.uid, u.name FROM node n LEFT JOIN $type l ON n.lid = l.lid AND n.nid = l.nid LEFT JOIN users u ON n.author = u.uid WHERE $where ORDER BY n.timestamp DESC");
-/*
- db_query ("BEGIN");
- db_query ("CREATE TEMPORARY TABLE modhole AS SELECT n.nid, SUM(m.score) / COUNT(m.cid) AS score, COUNT(m.cid) AS votes FROM node n LEFT JOIN $type l ON n.lid = l.lid AND n.nid = l.nid LEFT JOIN users u ON n.author = u.uid LEFT JOIN moderate m ON m.nid = n.nid WHERE $where GROUP BY n.nid");
- $result = db_query ("SELECT n.*, l.*, u.uid, u.name, m.score AS score, m.votes AS votes FROM node n INNER JOIN modhole m ON m.nid = n.nid LEFT JOIN $type l ON n.lid = l.lid AND n.nid = l.nid LEFT JOIN users u ON n.author = u.uid WHERE $where ORDER BY n.timestamp DESC");
+ // $result = db_query("SELECT n.*, l.*, u.uid, u.name FROM node n LEFT JOIN $type l ON n.nid = l.nid LEFT JOIN users u ON n.uid = u.uid WHERE $where ORDER BY n.timestamp DESC");
+
+ db_query("BEGIN");
+ db_query("CREATE TEMPORARY TABLE modhole AS SELECT n.nid FROM node n LEFT JOIN $type l ON n.nid = l.nid LEFT JOIN users u ON n.uid = u.uid WHERE $where GROUP BY n.nid");
+ $result = db_query("SELECT n.*, l.*, u.uid, u.name FROM node n INNER JOIN modhole m ON m.nid = n.nid LEFT JOIN $type l ON n.nid = l.nid LEFT JOIN users u ON n.uid = u.uid WHERE $where ORDER BY n.timestamp DESC");
db_query("DROP TABLE modhole");
db_query("COMMIT");
- 'score' isn't in GROUP BY
-*/
-
return $result;
}
}
@@ -62,7 +59,7 @@ function node_del($conditions) {
if ($node = node_get_object($conditions)) {
module_invoke($node->type, "delete", $node);
db_query("DELETE FROM node WHERE nid = '$node->nid'");
- db_query("DELETE FROM $node->type WHERE lid = '$node->lid' AND nid = '$node->nid'");
+ db_query("DELETE FROM $node->type WHERE nid = '$node->nid'");
db_query("DELETE FROM comments WHERE lid = '$node->nid'");
db_query("DELETE FROM moderate WHERE nid = '$node->nid'");
watchdog("special", "node: deleted '$node->title'");
@@ -78,7 +75,7 @@ function node_get_comments($nid) {
function node_save($node, $filter) {
global $db_handle;
- $rows = array(nid, lid, cid, tid, type, title, score, votes, author, status, comment, promote, moderate, attributes, timestamp, timestamp_posted, timestamp_queued, timestamp_hidden);
+ $rows = array(nid, cid, tid, type, title, score, votes, uid, status, comment, promote, moderate, attributes, timestamp, timestamp_posted, timestamp_queued, timestamp_hidden);
if ($node[nid] > 0) {
$n = node_get_object(array("nid" => $node[nid]));
@@ -141,15 +138,14 @@ function node_save($node, $filter) {
else {
$nid = $db_handle->nextId("node");
- $lid = $db_handle->nextId($filter[type]);
- $result = db_query("INSERT INTO node ($f1, nid, lid) VALUES ($v1, '$nid', '$lid')");
+ $result = db_query("INSERT INTO node ($f1, nid) VALUES ($v1, '$nid')");
if (db_error($result)) {
watchdog("warning", "node: added $filter[type] '$node[title]' - failed");
$db_handle->rollback();
}
else {
- $result = db_query("INSERT INTO $filter[type] ($f2, nid, lid) VALUES ($v2, '$nid', '$lid')");
+ $result = db_query("INSERT INTO $filter[type] ($f2, nid) VALUES ($v2, '$nid')");
if (db_error($result)) {
watchdog("warning", "node: added $filter[type] '$node[title]' - failed");
$db_handle->rollback();