* @author: Robert Bienert * @version: 0.3 * @date: 2009-01-25 * * Mit diesem Plugin landen alle neuen Kommentare erst einmal in der * Moderationswarteschlange und muessen vom Administrator genehmigt * werden. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ define('COMMENT_MOD_KEY', 'inModeration'); class CommentModeration extends JlogPlugin { var $commSid; // zwischengespeicherte Session-ID var $nWaiting; // Anzahl wartender Kommentare // Ausgabe des Hinweises auf die Moderation function hook_commentForm($form) { return str_replace('

', '

… wird moderiert

', $form); } // Vor dem Speichern eines neuen Kommentars function hook_newComment($form) { // Idee vom AkismetPlugin: neuer Typ 'inModeration': $form['type'] = COMMENT_MOD_KEY; // Session-ID zwischenspeichern fuer die Anzeige $this->commSid = $form['sid']; return $form; } // Kommentare in der Warteschlange werden nicht angezeigt. function hook_showComment($comment, $data, $nr) { if (COMMENT_MOD_KEY == $data['type']) { ++$this->nWaiting; if ($this->commSid != $data['sid']) return NULL; $comment .= '

Dein Kommentar wird moderiert.

'; } return $comment; } // TODO: Was macht diese Methode genau? function hook_countComments($com) { $q = new Query('SELECT reference, COUNT(*) as count FROM ' . JLOG_DB_COMMENTS . ' WHERE type <> \'pingback\' ' . 'AND type <> \''. COMMENT_MOD_KEY . '\' GROUP BY reference'); if($q->error()) { echo "
\n";
			echo $comments->getError();
			echo "
\n"; die(); } $com = array(); while($c = $q->fetch()) $com[$c['reference']] = $c['count']; return $com; } /* Biete in der Mail an den Admin einen Direktlink zum Genehmigen * des Kommentars an. */ function hook_adminMail($mail, $blogentry, $id) { $mail->appendText("\n\nKommentar genehmigen\n" . JLOG_PATH . '/admin/plugin.php?jplug=CommentModeration&allow=' . $id); return $mail; } /* function hook_commentorMail($mail, $blog) { if ($this->commSid) $mail['nomail'] = TRUE; return $mail; } */ // Anzeige aller Kommentare im Admin-Center: function hook_commentAdminList($comment, $data) { global $l; if (COMMENT_MOD_KEY == $data['type']) return str_replace('/img/JLOG_edit.png\' alt=\'' . $l['admin']['change'] . '\' />', '/img/JLOG_edit.png\' alt=\'' . $l['admin']['change'] . '\' /> Genehmigen', $comment); return $comment; } function hook_adminContent($html) { if (isset($_GET['allow'])) { $id = mysql_real_escape_string($_GET['allow']); $q = new Query('UPDATE ' . JLOG_DB_COMMENTS . ' SET type=\'\' WHERE id=\''. $id . '\''); global $categories; global $bbcode; global $plugins; include(JLOG_BASEPATH . 'scripts' . DIRECTORY_SEPARATOR . 'update.php'); return '

Kommentar #' . htmlspecialchars($_GET['allow']) . ' genehmigt.

'; } return <<Version 0.3

Copyright © 2008, 2009 Robert Bienert, Jlog-Plugin CommentModeration

Mit diesem Plugin werden alle neuen Kommentare in die Moderation eingestellt und nicht angezeigt. Aus dem Admin-Center heraus können die Kommentare dann genehmigt oder gelöscht werden.

EOF; } }