From 343e71c8ebdea6dafbd085782b5d042a7a60f2c3 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Wed, 2 May 2001 20:52:19 +0000 Subject: CHANGES: - Added moderator permissions to nodes. - Added moderator support to structure.module. - Added new moderate.module. - Renamed moderation.module to queue.module to avoid confusing. Updated theme yaroon as it seems to have a hard-coded reference to moderation.module. - Polished on: + account.module: improved access list + fixed HTML typo in node.module ACTIONS: - Jeroen: can jeroen2.theme be removed from ./themes/yaroon? --- modules/moderate.module | 106 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 modules/moderate.module (limited to 'modules/moderate.module') diff --git a/modules/moderate.module b/modules/moderate.module new file mode 100644 index 000000000..02f4974b5 --- /dev/null +++ b/modules/moderate.module @@ -0,0 +1,106 @@ + "moderate_admin"); + +function moderate_comment_access($cid) { + global $user; + return db_fetch_object(db_query("SELECT n.moderate FROM comments c LEFT JOIN node n ON c.lid = n.nid WHERE c.cid = '". check_input($cid) ."' AND n.moderate LIKE '%$user->userid%'")); +} + +function moderate_overview($query = array()) { + global $user; + + $result = db_query("SELECT n.*, u.userid FROM node n LEFT JOIN users u ON n.author = u.id WHERE n.moderate LIKE '%$user->userid%' ORDER BY n.timestamp DESC LIMIT 15"); + + $output .= status($query[0]); + $output .= "\n"; + $output .= " \n"; + + $r1 = db_query("SELECT n.*, u.userid FROM node n LEFT JOIN users u ON n.author = u.id WHERE n.moderate LIKE '%$user->userid%' ORDER BY n.timestamp DESC LIMIT 30"); + while ($node = db_fetch_object($r1)) { + $output .= " \n"; + + $r2 = db_query("SELECT c.*, u.userid FROM comments c LEFT JOIN users u ON c.author = u.id WHERE c.lid = '$node->nid' ORDER BY c.timestamp DESC"); + while ($comment = db_fetch_object($r2)) { + $output .= "\n"; + } + } + $output .= "
nodecategory / topicstatusauthordateoperations
nid\">". check_output($node->title) ."". category_name($node->cid) ." / ". topic_name($node->tid) ."". node_status($node, $node->status) ."". format_username($node->userid) ."". format_date($node->timestamp, "small") ."nid\">edit $node->type
 - lid&cid=$comment->cid&pid=$comment->pid#$comment->cid\">". check_output($comment->subject) ."". format_username($user->userid) ."". format_date($node->timestamp, "small") ."cid\">edit comment
\n"; + + return $output; +} + +function moderate_node_edit($id) { + global $user; + + $node = node_get_array("nid", $id); + if ($node && strstr($node[moderate], $user->userid)) { + return node_form($node); + } + else { + return "access denied"; + } +} + +function moderate_node_save($edit) { + global $user; + + $node = node_get_array("nid", $edit[nid]); + if ($node && strstr($node[moderate], $user->userid)) { + $edit[type] = $node[type]; + return node_invoke($edit, "save"); + } + else { + return "access denied"; + } +} + +function moderate_comment_edit($id) { + if (moderate_comment_access($id)) { + return comment_edit($id); + } + else { + return "access denied"; + } +} + +function moderate_comment_save($id, $edit) { + if (moderate_comment_access($id)) { + return comment_save($id, $edit); + } + else { + return "access denied"; + } +} + +function moderate_admin() { + global $op, $id, $edit, $type; + + switch ($type) { + case "comment": + switch ($op) { + case "edit": + print moderate_comment_edit($id); + break; + case "Submit": + print status(moderate_comment_save($id, $edit)); + // fall through: + default: + print moderate_overview(); + } + break; + default: + switch ($op) { + case "edit": + print moderate_node_edit($id); + break; + case "Submit": + print status(moderate_node_save($edit)); + // fall through: + default: + print moderate_overview(); + } + } +} + +?> -- cgit v1.2.3