Update of /cvsroot/php-blog/serendipity
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8555
Modified Files:
serendipity_admin_comments.inc.php
Log Message:
Add filters to comment administration page
Index: serendipity_admin_comments.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_admin_comments.inc.php,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- serendipity_admin_comments.inc.php 26 Jul 2004 22:18:42 -0000 1.9
+++ serendipity_admin_comments.inc.php 3 Aug 2004 18:05:54 -0000 1.10
@@ -95,25 +95,43 @@
return true;
}
-$sql = serendipity_db_query("SELECT COUNT(*) AS total FROM {$serendipity['dbPrefix']}comments WHERE type = 'normal'", true);
+/* Searchable fields */
+$filters = array('author', 'email', 'ip', 'url', 'body');
+
+/* Compress the filters into an "AND" SQL query, and a querystring */
+foreach ( $filters as $filter ) {
+ $and .= (!empty($serendipity['GET']['filter'][$filter]) ? "AND c.". $filter ." LIKE '%". serendipity_db_escape_string($serendipity['GET']['filter'][$filter]) ."%'" : "");
+ $searchString .= (!empty($serendipity['GET']['filter'][$filter]) ? "&serendipity[filter][". $filter ."]=". $serendipity['GET']['filter'][$filter] : "");
+}
+
+
+/* Paging */
+$sql = serendipity_db_query("SELECT COUNT(*) AS total FROM {$serendipity['dbPrefix']}comments c WHERE c.type = 'normal' ". $and, true);
$totalComments = $sql['total'];
$pages = ceil($totalComments/$commentsPerPage);
$page = (int)$serendipity['GET']['page'];
-if ( $page == 0 ) {
+if ( $page == 0 || $page > $pages ) {
$page = 1;
}
if ( $page != 1 && $page <= $pages ) {
- $linkPrevious = '<a href="?serendipity[adminModule]=comments&serendipity[page]='. ($page-1) .'">« '. PREVIOUS_PAGE .'</a>';
+ $linkPrevious = '<input type="button" name="serendipity[previouspage]" value="<<<" onclick="location.href=\'serendipity_entries.php?serendipity[adminModule]=comments&serendipity[page]='. ($page-1) . $searchString . '\'">';
+} else {
+ $linkPrevious = '<input type="button" name="serendipity[previouspage]" value="<<<" disabled="disabled" />';
}
+
if ( $page != $pages ) {
- $linkNext = '<a href="?serendipity[adminModule]=comments&serendipity[page]='. ($page+1) .'"> '. NEXT_PAGE .' »</a>';
+ $linkNext = '<input type="button" name="serendipity[nextpage]" value=">>>" onclick="location.href=\'serendipity_entries.php?serendipity[adminModule]=comments&serendipity[page]='. ($page+1) . $searchString . '\'">';
+} else {
+ $linkNext = '<input type="button" name="serendipity[nextpage]" value=">>>" disabled="disabled" />';
}
+
$sql = serendipity_db_query("SELECT c.*, e.title FROM {$serendipity['dbPrefix']}comments c
LEFT JOIN {$serendipity['dbPrefix']}entries e ON (e.id = c.entry_id)
WHERE type = 'NORMAL'
+ ". $and ."
" . (($serendipity['serendipityUserlevel'] != USERLEVEL_ADMIN) ? 'AND e.authorid = ' . $serendipity['authorId'] : '') . "
ORDER BY id DESC
LIMIT ". ($page-1)*$commentsPerPage .",". $commentsPerPage);
@@ -136,10 +154,43 @@
}
}
</script>
+<form action="" method="GET" style="margin: 0">
+<input type="hidden" name="serendipity[adminModule]" value="comments">
+<input type="hidden" name="serendipity[page]" value="<?php echo $page ?>">
+<table class="serendipity_admin_filters" width="100%">
+ <tr>
+ <td colspan="6" class="serendipity_admin_filters_headline"><strong><?php echo FILTERS ?></strong> - <?php echo FIND_COMMENTS ?></td>
+ </tr>
+ <tr>
+ <td><?php echo AUTHOR ?>:</td>
+ <td><input type="text" name="serendipity[filter][author]" size="15" value="<?php echo $serendipity['GET']['filter']['author'] ?>"></td>
+ <td><?php echo EMAIL ?>:</td>
+ <td><input type="text" name="serendipity[filter][email]" size="15" value="<?php echo $serendipity['GET']['filter']['email'] ?>"></td>
+ <td><?php echo URL ?>:</td>
+ <td><input type="text" name="serendipity[filter][url]" size="15" value="<?php echo $serendipity['GET']['filter']['url'] ?>"></td>
+ </tr>
+ <tr>
+ <td>IP:</td>
+ <td><input type="text" name="serendipity[filter][ip]" size="15" value="<?php echo $serendipity['GET']['filter']['ip'] ?>"></td>
+ <td><?php echo CONTENT ?>:</td>
+ <td><input type="text" name="serendipity[filter][body]" size="15" value="<?php echo $serendipity['GET']['filter']['body'] ?>"></td>
+ <td colspan="2" align="center"><input type="submit" name="submit" value=" - <?php echo GO ?> - "></td>
+ </tr>
+</table>
+</form>
+
<form action="" method="POST">
<table width="100%" cellspacing="5" cellpadding="0" border="0" class="serendipity_admin_list">
<tr>
- <td align="center"><?php echo $linkPrevious; ?> (<?php printf(PAGE_BROWSE_COMMENTS, $page, $pages, $totalComments); ?>) <?php echo $linkNext ?></td>
+ <td align="center">
+ <table width="100%" cellspacing="5" cellpadding="0" border="0">
+ <tr>
+ <td><?php echo $linkPrevious; ?></td>
+ <td align="center"><?php printf(PAGE_BROWSE_COMMENTS, $page, $pages, $totalComments); ?></td>
+ <td align="right"><?php echo $linkNext ?></td>
+ </tr>
+ </table>
+ </td>
</tr>
<?php
$i = 0;
@@ -209,7 +260,15 @@
</tr>
<?php } ?>
<tr>
- <td align="center"><?php echo $linkPrevious; ?> (<?php printf(PAGE_BROWSE_COMMENTS, $page, $pages, $totalComments); ?>) <?php echo $linkNext ?></td>
+ <td align="center">
+ <table width="100%" cellspacing="5" cellpadding="0" border="0">
+ <tr>
+ <td><?php echo $linkPrevious; ?></td>
+ <td align="center"><?php printf(PAGE_BROWSE_COMMENTS, $page, $pages, $totalComments); ?></td>
+ <td align="right"><?php echo $linkNext ?></td>
+ </tr>
+ </table>
+ </td>
</tr>
</table>
</form>
|