diff options
author | Dries Buytaert <dries@buytaert.net> | 2001-04-02 15:54:37 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2001-04-02 15:54:37 +0000 |
commit | 805107cd2202ddee66c4743e43804a3069508f29 (patch) | |
tree | 39a0661f2e8a84ee743831ee7abac5c9a626637c /includes | |
parent | 1f5bc83d794906c1b88dde20e107363cf2f71c17 (diff) | |
download | brdo-805107cd2202ddee66c4743e43804a3069508f29.tar.gz brdo-805107cd2202ddee66c4743e43804a3069508f29.tar.bz2 |
Commiting my work of last Sunday:
- removed ban.inc and ban.module and integrated it in account.module
under the name "access control" --> the ban code was not really up
to standard so this has now been dealt with. This refactoring and
reintegration cuts down the code size with 100 lines too. :-)
(The ban.module code was really old and it showed.)
- added node.module and made the other modules reuse some of this
code --> cut down the code size of modules by at least 100 lines
and adds stability.
- added a status() function to admin.php to display a conform status
message where appropriate. See admin.php for usage.
- removed $theme->control() and made comments.inc handle this itself
wrapped in a $theme->box(). No need to clutter the themes with
such complexity --> updated all themes already. :-)
- some small visual changes to some administration pages to be more
consistent across different modules.
Diffstat (limited to 'includes')
-rw-r--r-- | includes/ban.inc | 54 | ||||
-rw-r--r-- | includes/comment.inc | 4 | ||||
-rw-r--r-- | includes/node.inc | 8 | ||||
-rw-r--r-- | includes/user.inc | 5 |
4 files changed, 11 insertions, 60 deletions
diff --git a/includes/ban.inc b/includes/ban.inc deleted file mode 100644 index 98f39be6d..000000000 --- a/includes/ban.inc +++ /dev/null @@ -1,54 +0,0 @@ -<?php - -$type2index = array("addresses" => 0x01, - "profanity" => 0x02, - "hostnames" => 0x03, - "usernames" => 0x04); - -$index2type = array(0x01 => "addresses", - 0x02 => "profanity", - 0x03 => "hostnames", - 0x04 => "usernames"); - -function ban_match($mask, $category) { - // Perform query: - $result = db_query("SELECT * FROM bans WHERE type = '$category' AND LOWER('$mask') LIKE LOWER(mask)"); - - // Return result: - return db_fetch_object($result); -} - -// TODO --> $message by reference -function ban_add($mask, $category, $reason, $message = 0) { - global $index2type; - - if (empty($mask)) { - $message = "failed: empty banmasks are not allowed.<P>\n"; - } - else if ($ban = db_fetch_object(db_query("SELECT * FROM bans WHERE type = '$category' AND '$mask' LIKE mask"))) { - $message = "failed: ban is already matched by '$ban->mask'.<P>\n"; - } - else { - $result = db_query("INSERT INTO bans (mask, type, reason, timestamp) VALUES ('$mask', '$category', '$reason', '". time() ."')"); - $message = "added new ban with mask '$mask'.<P>\n"; - - // Add log entry: - watchdog("message", "added new ban '$mask' to category '". $index2type[$category] ."' with reason '$reason'."); - } -} - -function ban_delete($id) { - global $index2type; - - $result = db_query("SELECT * FROM bans WHERE id = '$id'"); - - if ($ban = db_fetch_object($result)) { - // Perform query: - $result = db_query("DELETE FROM bans WHERE id = '$id'"); - - // Deleted log entry: - watchdog("message", "removed ban '$ban->mask' from category '". $index2type[$ban->type] ."'."); - } -} - -?> diff --git a/includes/comment.inc b/includes/comment.inc index 57b87583b..b15cee23b 100644 --- a/includes/comment.inc +++ b/includes/comment.inc @@ -184,14 +184,12 @@ function comment_moderation($comment) { function comment_controls($threshold = 1, $mode = 3, $order = 1) { global $REQUEST_URI, $user; - $output .= "<FONT SIZE=\"2\">\n"; $output .= "<FORM METHOD=\"post\" ACTION=\"$REQUEST_URI\">\n"; $output .= comment_mode(($user->id ? $user->mode : $mode)); $output .= comment_order(($user->id ? $user->sort : $order)); $output .= comment_threshold(($user->id ? $user->threshold : $threshold)); $output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"". t("Update settings") ."\">\n"; $output .= "</FORM>\n"; - $output .= "</FONT>\n"; return $output; } @@ -289,7 +287,7 @@ function comment_render($lid, $cid) { if ($user->id) { // Comment control: - $theme->controls($threshold, $mode, $order); + $theme->box(t("Comment control"), "<DIV ALIGN=\"center\">". comment_controls($threshold, $mode, $order) ."</DIV>"); // Print moderation form: print "<FORM METHOD=\"post\" ACTION=\"$REQUEST_URI\">\n"; diff --git a/includes/node.inc b/includes/node.inc index 8afed3ecc..d67eb470d 100644 --- a/includes/node.inc +++ b/includes/node.inc @@ -36,6 +36,8 @@ function node_save($node) { $rows = array(nid, pid, lid, log, type, title, score, votes, author, status, timestamp); if ($node[nid] > 0) { + $n = node_get_object("nid", $node[nid]); + $u1 = array(); $u2 = array(); @@ -49,10 +51,10 @@ function node_save($node) { } if ($u1 = implode(", ", $u1)) db_query("UPDATE node SET $u1 WHERE nid = '$node[nid]'"); - if ($u2 = implode(", ", $u2)) db_query("UPDATE $node[type] SET $u2 WHERE nid = '$node[nid]'"); - if (($node[pid]) && ($node[status] == $status[posted])) db_query("UPDATE node SET status = '$status[expired]' WHERE nid = '$node[pid]'"); + if ($u2 = implode(", ", $u2)) db_query("UPDATE $n->type SET $u2 WHERE nid = '$node[nid]'"); + if ($n->pid && ($node[status] == $status[posted])) db_query("UPDATE node SET status = '$status[expired]' WHERE nid = '$node[pid]'"); - watchdog("message", "node: modified '$node[title]'"); + watchdog("message", "node: modified '$n->title'"); } else { $duplicate = node_get_object("title", $node[title]); diff --git a/includes/user.inc b/includes/user.inc index 66a015e4f..09b434102 100644 --- a/includes/user.inc +++ b/includes/user.inc @@ -95,4 +95,9 @@ function user_access($account, $section = 0) { else return ($account->access || $account->id == 1); } +function user_ban($mask, $type) { + $result = db_query("SELECT * FROM access WHERE type = '$type' AND '$mask' REGEXP mask"); + return db_fetch_object($result); +} + ?>
\ No newline at end of file |