Update of /cvsroot/php-blog/serendipity
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20423
Modified Files:
serendipity_admin_comments.inc.php
Log Message:
Tom, we agreed to use no first-level indenting for our coding guidelines.
Index: serendipity_admin_comments.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_admin_comments.inc.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- serendipity_admin_comments.inc.php 16 Jul 2004 22:17:23 -0000 1.1
+++ serendipity_admin_comments.inc.php 17 Jul 2004 12:04:10 -0000 1.2
@@ -1,159 +1,159 @@
<?php
- if (IN_serendipity !== true) {
- die ("Don't hack!");
- }
-
+if (IN_serendipity !== true) {
+ die ("Don't hack!");
+}
- /* We are asked to save the edited comment, and we are not in preview mode */
- if ( isset($serendipity['GET']['adminAction']) && $serendipity['GET']['adminAction'] == 'doEdit' && !isset($serendipity['POST']['preview']) ) {
- $sql = "UPDATE {$serendipity['dbPrefix']}comments
- SET
- author = '". $serendipity['POST']['name'] ."',
- email = '". $serendipity['POST']['email'] ."',
- url = '". $serendipity['POST']['url'] ."',
- parent_id = '". $serendipity['POST']['replyTo']."',
- body = '". $serendipity['POST']['comment']."'
- WHERE id = ". $serendipity['GET']['id'] ." AND entry_id = ". $serendipity['POST']['entry_id'];
- serendipity_db_query($sql);
- echo COMMENT_EDITED;
- return 1;
- }
+/* We are asked to save the edited comment, and we are not in preview mode */
+if ( isset($serendipity['GET']['adminAction']) && $serendipity['GET']['adminAction'] == 'doEdit' && !isset($serendipity['POST']['preview']) ) {
+ $sql = "UPDATE {$serendipity['dbPrefix']}comments
+ SET
+ author = '". $serendipity['POST']['name'] ."',
+ email = '". $serendipity['POST']['email'] ."',
+ url = '". $serendipity['POST']['url'] ."',
+ parent_id = '". $serendipity['POST']['replyTo']."',
+ body = '". $serendipity['POST']['comment']."'
+ WHERE id = ". $serendipity['GET']['id'] ." AND entry_id = ". $serendipity['POST']['entry_id'];
+ serendipity_db_query($sql);
+ echo COMMENT_EDITED;
+ return 1;
+}
- /* We approve a comment */
- if ( isset($serendipity['GET']['adminAction']) && $serendipity['GET']['adminAction'] == 'approve' ) {
- $sql = "SELECT c.*, e.title, a.email as authoremail, a.mail_comments
- FROM {$serendipity['dbPrefix']}comments c
- LEFT JOIN {$serendipity['dbPrefix']}entries e ON (e.id = c.entry_id)
- LEFT JOIN {$serendipity['dbPrefix']}authors a ON (e.authorid = a.authorid)
- WHERE c.id = ". $serendipity['GET']['id'] ." AND status = 'pending'";
- $rs = serendipity_db_query($sql, true);
- if ( $rs === false ) {
- echo ERROR .': '. sprintf(COMMENT_ALREADY_APPROVED, $serendipity['GET']['id']);
- return 1;
- }
+/* We approve a comment */
+if ( isset($serendipity['GET']['adminAction']) && $serendipity['GET']['adminAction'] == 'approve' ) {
+ $sql = "SELECT c.*, e.title, a.email as authoremail, a.mail_comments
+ FROM {$serendipity['dbPrefix']}comments c
+ LEFT JOIN {$serendipity['dbPrefix']}entries e ON (e.id = c.entry_id)
+ LEFT JOIN {$serendipity['dbPrefix']}authors a ON (e.authorid = a.authorid)
+ WHERE c.id = ". $serendipity['GET']['id'] ." AND status = 'pending'";
+ $rs = serendipity_db_query($sql, true);
- serendipity_approveComment($serendipity['GET']['id'], serendipity_db_bool($rs['mail_comments']), $rs['entry_id'], $rs['authoremail'], $rs['email'], $rs['author'], $rs['url'], $rs['title'], $rs['body'], $rs['type']);
- echo DONE .': '. sprintf(COMMENT_APPROVED, $serendipity['GET']['id']);
+ if ( $rs === false ) {
+ echo ERROR .': '. sprintf(COMMENT_ALREADY_APPROVED, $serendipity['GET']['id']);
return 1;
}
- /* We are asked to delete a comment */
- if ( isset($serendipity['GET']['adminAction']) && $serendipity['GET']['adminAction'] == 'delete' ) {
- serendipity_deleteComment($serendipity['GET']['id'], $serendipity['GET']['entry_id']);
- echo DONE .': '. sprintf(COMMENT_DELETED, $serendipity['GET']['id']);;
- return 1;
- }
+ serendipity_approveComment($serendipity['GET']['id'], serendipity_db_bool($rs['mail_comments']), $rs['entry_id'], $rs['authoremail'], $rs['email'], $rs['author'], $rs['url'], $rs['title'], $rs['body'], $rs['type']);
+ echo DONE .': '. sprintf(COMMENT_APPROVED, $serendipity['GET']['id']);
+ return 1;
+}
- /* We are either in edit mode, or preview mode */
- if ( isset($serendipity['GET']['adminAction']) && $serendipity['GET']['adminAction'] == 'edit' || isset($serendipity['POST']['preview'])) {
+/* We are asked to delete a comment */
+if ( isset($serendipity['GET']['adminAction']) && $serendipity['GET']['adminAction'] == 'delete' ) {
+ serendipity_deleteComment($serendipity['GET']['id'], $serendipity['GET']['entry_id']);
+ echo DONE .': '. sprintf(COMMENT_DELETED, $serendipity['GET']['id']);;
+ return 1;
+}
- /* If we are not in preview, we need data from our database */
- if (!isset($serendipity['POST']['preview']) ) {
- $comment = serendipity_db_query("SELECT * FROM {$serendipity['dbPrefix']}comments WHERE id = ". $serendipity['GET']['id']);
- $data['name'] = $comment[0]['author'];
- $data['email'] = $comment[0]['email'];
- $data['url'] = $comment[0]['url'];
- $data['replyTo'] = $comment[0]['parent_id'];
- $data['comment'] = $comment[0]['body'];
+/* We are either in edit mode, or preview mode */
+if ( isset($serendipity['GET']['adminAction']) && $serendipity['GET']['adminAction'] == 'edit' || isset($serendipity['POST']['preview'])) {
- /* If we are in preview, we get data from our form */
- } elseif ( isset($serendipity['POST']['preview']) ) {
- $data['name'] = $serendipity['POST']['name'];
- $data['email'] = $serendipity['POST']['email'];
- $data['url'] = $serendipity['POST']['url'];
- $data['replyTo'] = $serendipity['POST']['replyTo'];
- $data['comment'] = $serendipity['POST']['comment'];
- serendipity_printComments(
- array(
- array(
- 'email' => $serendipity['POST']['email'],
- 'author' => $serendipity['POST']['name'],
- 'body' => $serendipity['POST']['comment'],
- 'url' => $serendipity['POST']['url'],
- 'timestamp' => time()
- )
- ),
- false,
- false
- );
+ /* If we are not in preview, we need data from our database */
+ if (!isset($serendipity['POST']['preview']) ) {
+ $comment = serendipity_db_query("SELECT * FROM {$serendipity['dbPrefix']}comments WHERE id = ". $serendipity['GET']['id']);
+ $data['name'] = $comment[0]['author'];
+ $data['email'] = $comment[0]['email'];
+ $data['url'] = $comment[0]['url'];
+ $data['replyTo'] = $comment[0]['parent_id'];
+ $data['comment'] = $comment[0]['body'];
- }
+ /* If we are in preview, we get data from our form */
+ } elseif ( isset($serendipity['POST']['preview']) ) {
+ $data['name'] = $serendipity['POST']['name'];
+ $data['email'] = $serendipity['POST']['email'];
+ $data['url'] = $serendipity['POST']['url'];
+ $data['replyTo'] = $serendipity['POST']['replyTo'];
+ $data['comment'] = $serendipity['POST']['comment'];
+ serendipity_printComments(
+ array(
+ array(
+ 'email' => $serendipity['POST']['email'],
+ 'author' => $serendipity['POST']['name'],
+ 'body' => $serendipity['POST']['comment'],
+ 'url' => $serendipity['POST']['url'],
+ 'timestamp' => time()
+ )
+ ),
+ false,
+ false
+ );
- serendipity_displayCommentForm($serendipity['GET']['entry_id'], '?serendipity[action]=admin&serendipity[adminModule]=comments&serendipity[adminAction]=doEdit&serendipity[id]='. $serendipity['GET']['id'] .'&serendipity[entry_id]='. $serendipity['GET']['entry_id'], NULL, $data, false);
- return 1;
}
- $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'
- ". (($serendipity['serendipityUserlevel'] != USERLEVEL_ADMIN) ? 'AND e.authorid = '. $serendipity['authorId'] : '') ."
- ORDER BY id DESC
- LIMIT 10");
- if ( !is_array($sql) ) {
- echo NO_COMMENTS;
- return;
- }
+ serendipity_displayCommentForm($serendipity['GET']['entry_id'], '?serendipity[action]=admin&serendipity[adminModule]=comments&serendipity[adminAction]=doEdit&serendipity[id]='. $serendipity['GET']['id'] .'&serendipity[entry_id]='. $serendipity['GET']['entry_id'], NULL, $data, false);
+ return 1;
+}
+
+$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'
+ ". (($serendipity['serendipityUserlevel'] != USERLEVEL_ADMIN) ? 'AND e.authorid = '. $serendipity['authorId'] : '') ."
+ ORDER BY id DESC
+ LIMIT 10");
+if ( !is_array($sql) ) {
+ echo NO_COMMENTS;
+ return;
+}
?>
<script language="Javascript1.2" type="text/javascript">
- function toggle(id) {
- if ( document.getElementById(id +'_full').style.display == '' ) {
- document.getElementById(id +'_full').style.display='none';
- document.getElementById(id +'_summary').style.display='';
- document.getElementById(id +'_link').innerHTML = '<?php echo VIEW ?>';
- } else {
- document.getElementById(id +'_full').style.display='';
- document.getElementById(id +'_summary').style.display='none';
- document.getElementById(id +'_link').innerHTML = '<?php echo HIDE ?>';
- }
-
+function toggle(id) {
+ if ( document.getElementById(id +'_full').style.display == '' ) {
+ document.getElementById(id +'_full').style.display='none';
+ document.getElementById(id +'_summary').style.display='';
+ document.getElementById(id +'_link').innerHTML = '<?php echo VIEW ?>';
+ } else {
+ document.getElementById(id +'_full').style.display='';
+ document.getElementById(id +'_summary').style.display='none';
+ document.getElementById(id +'_link').innerHTML = '<?php echo HIDE ?>';
}
+
+}
</script>
<table width="100%" cellspacing="5" cellpadding="0" border="0" class="serendipity_admin_list">
<?php
- $i = 0;
- foreach ( $sql as $rs ) {
- if (empty($rs['author'])) {
- $rs['author'] = ANONYMOUS;
- }
- if (empty($rs['ip'])) {
- $rs['ip'] = '0.0.0.0';
- }
- if (empty($rs['email'])) {
- $rs['email'] = 'N/A';
- }
+$i = 0;
+foreach ( $sql as $rs ) {
+ if (empty($rs['author'])) {
+ $rs['author'] = ANONYMOUS;
+ }
+ if (empty($rs['ip'])) {
+ $rs['ip'] = '0.0.0.0';
+ }
+ if (empty($rs['email'])) {
+ $rs['email'] = 'N/A';
+ }
- $class = 'serendipity_admin_list_item_'. (($i++ % 2 == 0 ) ? 'even' : 'uneven');
+ $class = 'serendipity_admin_list_item_'. (($i++ % 2 == 0 ) ? 'even' : 'uneven');
?>
- <tr>
- <td class="serendipity_admin_list_item <?php echo $class ?>" style="padding: 3px">
- <a name="c<?php echo $rs['id'] ?>"></a>
- <strong><?php echo $rs['title'] ?></strong>
- <table width="100%" cellspacing="0" cellpadding="2" border="0">
- <tr>
- <td width="30">
+<tr>
+ <td class="serendipity_admin_list_item <?php echo $class ?>" style="padding: 3px">
+ <a name="c<?php echo $rs['id'] ?>"></a>
+ <strong><?php echo $rs['title'] ?></strong>
+ <table width="100%" cellspacing="0" cellpadding="2" border="0">
+ <tr>
+ <td width="30">
<?php
- // TODO; Multi-Delete
- /* <input type="checkbox" name="delete[<?php echo $rs['id'] ?>]"> */
+// TODO; Multi-Delete
+/* <input type="checkbox" name="delete[<?php echo $rs['id'] ?>]"> */
?> </td>
- <td width="160"><?php echo $rs['author'] ?></td>
- <td><?php echo $rs['email'] ?></td>
- <td align="right">(<?php echo $rs['ip'] ?>)</td>
- </tr>
- <tr>
- <td style="border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC" colspan="4"><div id="<?php echo $rs['id'] ?>_summary"><?php echo nl2br(substr(strip_tags($rs['body']), 0, 200)) ?> ...</div><div id="<?php echo $rs['id'] ?>_full" style="display: none"><?php echo nl2br(strip_tags($rs['body'])) ?></div></td>
- </tr>
- </table>
+ <td width="160"><?php echo $rs['author'] ?></td>
+ <td><?php echo $rs['email'] ?></td>
+ <td align="right">(<?php echo $rs['ip'] ?>)</td>
+ </tr>
+ <tr>
+ <td style="border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC" colspan="4"><div id="<?php echo $rs['id'] ?>_summary"><?php echo nl2br(substr(strip_tags($rs['body']), 0, 200)) ?> ...</div><div id="<?php echo $rs['id'] ?>_full" style="display: none"><?php echo nl2br(strip_tags($rs['body'])) ?></div></td>
+ </tr>
+ </table>
<?php if ( $rs['status'] == 'pending' ) { ?>
- <strong>[<a href="?serendipity[action]=admin&serendipity[adminModule]=comments&serendipity[adminAction]=approve&serendipity[id]=<?php echo $rs['id'] ?>">Approve</a>]</strong> -
+ <strong>[<a href="?serendipity[action]=admin&serendipity[adminModule]=comments&serendipity[adminAction]=approve&serendipity[id]=<?php echo $rs['id'] ?>">Approve</a>]</strong> -
<?php } ?>
- [<a href="?serendipity[action]=admin&serendipity[adminModule]=comments&serendipity[adminAction]=delete&serendipity[id]=<?php echo $rs['id'] ?>&serendipity[entry_id]=<?php echo $rs['entry_id'] ?>"><?php echo DELETE ?></a>] -
- [<a href="?serendipity[action]=admin&serendipity[adminModule]=comments&serendipity[adminAction]=edit&serendipity[id]=<?php echo $rs['id'] ?>&serendipity[entry_id]=<?php echo $rs['entry_id'] ?>"><?php echo EDIT ?></a>] -
- [<a href="#c<?php echo $rs['id'] ?>" onClick="toggle(<?php echo $rs['id'] ?>)" id="<?php echo $rs['id'] ?>_link"><?php echo VIEW ?></a>]
- </td>
- </tr>
+ [<a href="?serendipity[action]=admin&serendipity[adminModule]=comments&serendipity[adminAction]=delete&serendipity[id]=<?php echo $rs['id'] ?>&serendipity[entry_id]=<?php echo $rs['entry_id'] ?>"><?php echo DELETE ?></a>] -
+ [<a href="?serendipity[action]=admin&serendipity[adminModule]=comments&serendipity[adminAction]=edit&serendipity[id]=<?php echo $rs['id'] ?>&serendipity[entry_id]=<?php echo $rs['entry_id'] ?>"><?php echo EDIT ?></a>] -
+ [<a href="#c<?php echo $rs['id'] ?>" onClick="toggle(<?php echo $rs['id'] ?>)" id="<?php echo $rs['id'] ?>_link"><?php echo VIEW ?></a>]
+ </td>
+</tr>
<?php } ?>
-</table>
+</table>
\ No newline at end of file
|