comment.module 17.6 KB
Newer Older
Dries's avatar
   
Dries committed
1
<?
2
// $Id$
Dries's avatar
 
Dries committed
3

Dries's avatar
   
Dries committed
4
5
$GLOBALS["cmodes"] = array(1 => "List - min", 2 => "List - max", 3 => "Threaded - min", 4 => "Threaded - max");
$GLOBALS["corder"] = array(1 => "Date - new", 2 => "Date - old", 3 => "Rate - high", 4 => "Rate - low");
Dries's avatar
   
Dries committed
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40

function comment_moderate($moderate) {
  global $user;

  if ($user->uid && $moderate) {
    foreach ($moderate as $cid => $score) {
      if ($score > 0 && $score < 6) {
        if (db_fetch_object(db_query("SELECT * FROM moderate WHERE uid = '". check_query($user->uid) ."' AND cid = '". check_query($cid) ."'"))) {
          db_query("UPDATE moderate SET score = '". check_query($score) ."' WHERE uid = '". check_query($user->uid) ."' AND cid = '". check_query($cid) ."'");
        }
        else {
          db_query("INSERT INTO moderate (uid, cid, score, timestamp) VALUES ('". check_query($user->uid) ."', '". check_query($cid) ."', '". check_query($score) ."', '". time() ."')");
        }
      }
    }
  }
}

function comment_settings($mode, $order, $threshold) {
  global $user;

  if ($user->uid) {
    $user = user_save($user, array("mode" => $mode, "sort" => $order, "threshold" => $threshold));
  }
}

function comment_form($edit) {
  global $user;

  $form .= "<a name=\"comment\"></a>\n";

  // name field:
  $form .= form_item(t("Your name"), format_name($user));

  // subject field:
Dries's avatar
   
Dries committed
41
  $form .= form_textfield(t("Subject"), "subject", $edit["subject"], 50, 64);
Dries's avatar
   
Dries committed
42
43

  // comment field:
Dries's avatar
   
Dries committed
44
  $form .= form_textarea(t("Comment"), "comment", $edit["comment"] ? $edit["comment"] : $user->signature, 70, 10, t("Allowed HTML tags") .": ". htmlspecialchars(variable_get("allowed_html", "")));
Dries's avatar
   
Dries committed
45
46

  // preview button:
Dries's avatar
   
Dries committed
47
48
  $form .= form_hidden("pid", $edit["pid"]);
  $form .= form_hidden("id", $edit["id"]);
Dries's avatar
   
Dries committed
49

Dries's avatar
   
Dries committed
50
  if (!$edit["comment"]) {
Dries's avatar
   
Dries committed
51
52
53
54
55
56
57
58
59
60
61
62
63
64
    $form .= form_submit(t("Preview comment"));
  }
  else {
    $form .= form_submit(t("Preview comment"));
    $form .= form_submit(t("Post comment"));
  }

  return form($form);
}

function comment_reply($pid, $id) {
  global $theme;

  if ($pid) {
Dries's avatar
   
Dries committed
65
66
    $comment = db_fetch_object(db_query("SELECT c.*, u.uid, u.name FROM comments c LEFT JOIN users u ON c.uid = u.uid WHERE c.cid = '$pid'"));
    comment_view($comment, t("reply to this comment"));
Dries's avatar
   
Dries committed
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
  }
  else {
    node_view(node_load(array("nid" => $id)));
    $pid = 0;
  }

  if (user_access("post comments")) {
    $theme->box(t("Reply"), comment_form(array(pid=>$pid, id=>$id)));
  }
  else {
    $theme->box(t("Reply"), t("You are not authorized to post comments."));
  }
}

function comment_preview($edit) {
  global $theme, $user;

Dries's avatar
   
Dries committed
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
  foreach ($edit as $key => $value) {
    $comment->$key = filter($value);
  }

  /*
  ** Attach the user information:
  */

  $comment->uid = $user->uid;
  $comment->name = $user->name;

  /*
  ** Attach the time:
  */

  $comment->timestamp = time();

  /*
  ** Preview the comment:
  */

  comment_view($comment, t("reply to this comment"));
Dries's avatar
   
Dries committed
106
107
108
109
110
111
112
113

  $theme->box(t("Reply"), comment_form($edit));
}

function comment_post($edit) {
  global $theme, $user;

  if (user_access("post comments")) {
Dries's avatar
   
Dries committed
114
115
116
117
118
    /*
    ** Check the user's comment submission rate.  If exceeded,
    ** throttle() will bail out.
    */

Dries's avatar
   
Dries committed
119
120
    throttle("post comment", variable_get(max_comment_rate, 60));

Dries's avatar
   
Dries committed
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
    /*
    ** Validate the comment's subject.  If not specified, extract
    ** one from the comment's body.
    */

    $edit["subject"] = strip_tags(($edit["subject"] ? $edit["subject"] : substr($edit["comment"], 0, 29)));

    /*
    ** Validate the comment's body.
    */

    $edit["comment"] = filter($edit["comment"]);

    /*
    ** Check for duplicate comments.  Note that we have to use the
    ** validated/filtered data to perform such check.
    */

    $duplicate = db_result(db_query("SELECT COUNT(cid) FROM comments WHERE pid = '". check_input($edit["pid"]) ."' AND lid = '". check_input($edit["id"]) ."' AND subject = '". check_input($edit["subject"]) ."' AND comment = '". check_input($edit["comment"]) ."'"), 0);
Dries's avatar
   
Dries committed
140
141

    if ($duplicate != 0) {
Dries's avatar
   
Dries committed
142
      watchdog("warning", "comment: duplicate '". $edit["subject"] ."'");
Dries's avatar
   
Dries committed
143
144
    }
    else {
Dries's avatar
   
Dries committed
145
146
147
      /*
      ** Add the comment to database:
      */
Dries's avatar
   
Dries committed
148

Dries's avatar
   
Dries committed
149
      db_query("INSERT INTO comments (lid, pid, uid, subject, comment, hostname, timestamp) VALUES ('". check_query($edit["id"]) ."', '". check_query($edit["pid"]) ."', '$user->uid', '". check_query($edit["subject"]) ."', '". check_query($edit["comment"]) ."', '". getenv("REMOTE_ADDR") ."', '". time() ."')");
Dries's avatar
   
Dries committed
150

Dries's avatar
   
Dries committed
151
152
153
154
155
156
157
158
159
      /*
      ** Add entry to the watchdog log:
      */

      watchdog("special", "comment: added '". $edit["subject"] ."'");

      /*
      ** Clear the cache:
      */
Dries's avatar
   
Dries committed
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175

      cache_clear();
    }
  }
}

function comment_num_replies($id, $count = 0) {

  $result = db_query("SELECT COUNT(cid) FROM comments WHERE pid = '$id'");
  return ($result) ? db_result($result, 0) : 0;

}

function comment_moderation($comment) {
  global $user;

Dries's avatar
   
Dries committed
176
  $values = array("--", "1", "2", "3", "4", "5");
Dries's avatar
   
Dries committed
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196

  $moderate = db_fetch_object(db_query("SELECT * FROM moderate WHERE cid = '$comment->cid' AND uid = '$user->uid'"));

  foreach ($values as $key => $value) {
    $options .= " <option value=\"$key\"". ($moderate->score == $key ? " selected=\"selected\"" : "") .">$value</option>\n";
  }

 $output .= "<select name=\"moderate[comment][$comment->cid]\">$options</select><br />". ($comment->score ? $comment->score : "--") ." / $comment->votes";

  return $output;
}

function comment_threshold($threshold) {
  for ($i = 0; $i < 6; $i++) $options .= " <option value=\"$i\"". ($threshold == $i ? " SELECTED" : "") .">". t("Visibility") ." - $i</option>";
  return "<select name=\"threshold\">$options</select>\n";
}

function comment_mode($mode) {
  global $cmodes;

Dries's avatar
   
Dries committed
197
  foreach ($cmodes as $key => $value) $options .= " <option value=\"$key\"". ($mode == $key ? " SELECTED" : "") .">$value</option>\n";
Dries's avatar
   
Dries committed
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
  return "<select name=\"mode\">$options</select>\n";
}

function comment_order($order) {
  global $corder;

  foreach ($corder as $key=>$value) $options .= " <option value=\"$key\"". ($order == $key ? " SELECTED" : "") .">$value</option>\n";
  return "<select name=\"order\">$options</select>\n";
}

function comment_query($lid, $order, $pid = -1) {

  $query .= "SELECT c.cid, c.pid, c.lid, c.subject, c.comment, c.timestamp, u.uid, u.name, AVG(m.score) AS score, COUNT(m.cid) AS votes FROM comments c LEFT JOIN users u ON c.uid = u.uid LEFT JOIN moderate m ON c.cid = m.cid WHERE c.lid = '$lid'";

  if ($pid >= 0) {
    $query .= " AND pid = '$pid'";
  }

  $query .= " GROUP BY c.cid, c.pid, c.lid, c.subject, c.comment, c.timestamp, u.uid, u.name";

  if ($order == 1) {
    $query .= " ORDER BY c.timestamp DESC";
  }
  else if ($order == 2) {
    $query .= " ORDER BY c.timestamp";
  }
  else if ($order == 3) {
    $query .= " ORDER BY score DESC";
  }
  else if ($order == 4) {
    $query .= " ORDER BY score";
  }

  return db_query($query);

}

function comment_visible($comment, $threshold = 0) {
  if ($comment->votes == 0 || $comment->score >= $threshold) {
    return 1;
  }
  else {
    return 0;
  }
}

function comment_links($comment, $return = 1) {
  global $theme;

  if ($return) {
    return "<a href=\"node.php?id=$comment->lid#$comment->cid\"><font color=\"$theme->type\">". t("return") ."</font></a> | <a href=\"node.php?op=reply&id=$comment->lid&pid=$comment->cid\"><font color=\"$theme->type\">". t("reply to this comment") ."</font></a>";
  }
  else {
    return "<a href=\"node.php?op=reply&id=$comment->lid&pid=$comment->cid\"><font color=\"$theme->type\">". t("reply to this comment") ."</font></a>";
  }
}

function comment_view($comment, $folded = 0) {
  global $theme;

  if ($folded) {
    $theme->comment($comment, $folded);
  }
  else {
    print "<a href=\"node.php?id=$comment->lid&cid=$comment->cid#$comment->cid\">". check_output($comment->subject) ."</a> by ". format_name($comment) ." <small>(". ($comment->score ? $comment->score : "--") ." / $comment->votes)</small><p />";
  }
}

function comment_thread_min($cid, $threshold) {
  global $user;

  $result = db_query("SELECT c.cid, c.pid, c.lid, c.subject, c.comment, c.timestamp, u.uid, u.name, AVG(m.score) AS score, COUNT(m.cid) AS votes FROM comments c LEFT JOIN users u ON c.uid = u.uid LEFT JOIN moderate m ON c.cid = m.cid WHERE c.pid = '$cid' GROUP BY c.cid, c.pid, c.lid, c.subject, c.comment, c.timestamp, u.uid, u.name ORDER BY c.timestamp");

  while ($comment = db_fetch_object($result)) {
    print "<ul>";
    print comment_view($comment);
    comment_thread_min($comment->cid, $threshold);
    print "</ul>";
  }
}

function comment_thread_max($cid, $mode, $threshold, $level = 0) {
  global $user;

  /*
  ** We had quite a few browser specific issues: expanded comments below
  ** the top level got truncated on the right hand side.  A range of
  ** solutions have been proposed and tried but either the right margins of
  ** the comments didn't line up well, or the heavily nested tables made
  ** for slow rendering and cluttered HTML.  This is the best work-around
  ** in terms of speed and size.
  */

  $result = db_query("SELECT c.cid, c.pid, c.lid, c.subject, c.comment, c.timestamp, u.uid, u.name, AVG(m.score) AS score, COUNT(m.cid) AS votes FROM comments c LEFT JOIN users u ON c.uid = u.uid LEFT JOIN moderate m ON c.cid = m.cid WHERE c.pid = '$cid' GROUP BY c.cid, c.pid, c.lid, c.subject, c.comment, c.timestamp, u.uid, u.name ORDER BY c.timestamp");

  while ($comment = db_fetch_object($result)) {
    print "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><tr><td width=\"". ($level * 25) ."\">&nbsp;</td><td>\n";
    comment_view($comment, (comment_visible($comment, $threshold) ? comment_links($comment, 0) : 0));
    print "</td></tr></table>\n";

    comment_thread_max($comment->cid, $mode, $threshold, $level + 1);
  }

}

function comment_render($lid, $cid) {
  global $user, $theme, $mode, $order, $threshold, $REQUEST_URI;

  if (user_access("access comments")) {

    /*
    ** Pre-process variables:
    */

    if (empty($lid)) {
      $lid = 0;
    }

    if (empty($cid)) {
      $cid = 0;
    }

    if (empty($mode)) {
      $mode = $user->uid ? $user->mode : variable_get(default_comment_mode, 4);
    }

    if (empty($order)) {
      $order = $user->uid ? $user->sort : variable_get(default_comment_order, 1);
    }

    if (empty($threshold)) {
      $threshold = $user->uid ? $user->threshold : variable_get(default_comment_threshold, 3);
    }

    print "<a name=\"comment\"></a>\n";
    print "<form method=\"post\" action=\"$REQUEST_URI\">\n";

    /*
    ** Render control panel:
    */

    $theme->box(t("Control panel"), $theme->comment_controls($threshold, $mode, $order));

    if ($cid > 0) {
      $result = db_query("SELECT c.cid, c.pid, c.lid, c.subject, c.comment, c.timestamp, u.uid, u.name, AVG(m.score) AS score, COUNT(m.cid) AS votes  FROM comments c LEFT JOIN users u ON c.uid = u.uid LEFT JOIN moderate m ON c.cid = m.cid WHERE c.cid = '$cid' GROUP BY c.cid, c.pid, c.lid, c.subject, c.comment, c.timestamp, u.uid, u.name");
      if ($comment = db_fetch_object($result)) {
        comment_view($comment, comment_links($comment));
      }
    }
    else {
      if ($mode == 1) {
        $result = comment_query($lid, $order);
        print "<table border=\"0\" cellpadding=\"2\" cellspacing=\"2\">\n";
        print " <tr><th>Subject</th><th>Author</th><th>Date</th><th>Score</th></tr>\n";
        while ($comment = db_fetch_object($result)) {
          if (comment_visible($comment, $threshold)) {
            print " <tr><td><a href=\"node.php?id=$comment->lid&cid=$comment->cid#$comment->cid\">". check_output($comment->subject) ."</a></td><td>". format_name($comment) ."</td><td>". format_date($comment->timestamp, "small") ."</td><td>$comment->score</td></tr>\n";
          }
        }
        print "</table>\n";
      }
      else if ($mode == 2) {
        $result = comment_query($lid, $order);
        while ($comment = db_fetch_object($result)) {
          comment_view($comment, (comment_visible($comment, $threshold) ? comment_links($comment, 0) : 0));
        }
      }
      else if ($mode == 3) {
        $result = comment_query($lid, $order, 0);
        while ($comment = db_fetch_object($result)) {
          comment_view($comment);
          comment_thread_min($comment->cid, $threshold);
        }
      }
      else {
        $result = comment_query($lid, $order, 0);
        while ($comment = db_fetch_object($result)) {
          comment_view($comment, (comment_visible($comment, $threshold) ? comment_links($comment, 0) : 0));
          comment_thread_max($comment->cid, $mode, $threshold, $level + 1);
        }
      }
    }

    print "</form>";

  }
}

Dries's avatar
   
Dries committed
386
function comment_search($keys) {
Dries's avatar
   
Dries committed
387
  global $PHP_SELF;
Dries's avatar
   
Dries committed
388
  $result = db_query("SELECT c.*, u.name FROM comments c LEFT JOIN users u ON c.uid = u.uid WHERE c.subject LIKE '%$keys%' OR c.comment LIKE '%$keys%' ORDER BY c.timestamp DESC LIMIT 20");
Dries's avatar
   
Dries committed
389
  while ($comment = db_fetch_object($result)) {
Dries's avatar
   
Dries committed
390
    $find[$i++] = array("title" => check_output($comment->subject), "link" => (strstr($PHP_SELF, "admin.php") ? "admin.php?mod=comment&op=edit&id=$comment->cid" : "node.php?id=$comment->lid&cid=$comment->cid"), "user" => $comment->name, "date" => $comment->timestamp);
Dries's avatar
   
Dries committed
391
392
393
  }
  return $find;
}
Dries's avatar
 
Dries committed
394

Dries's avatar
   
Dries committed
395
function comment_perm() {
Dries's avatar
   
Dries committed
396
397
398
  return array("access comments", "post comments", "administer comments");
}

Dries's avatar
   
Dries committed
399
function comment_link($type, $node = 0, $main = 0) {
Dries's avatar
   
Dries committed
400
401
402
403
  if ($type == "admin" and user_access("administer comments")) {
    $links[] = "<a href=\"admin.php?mod=comment\">comments</a>";
  }

Dries's avatar
   
Dries committed
404
  if ($type == "node" && $node->comment) {
Dries's avatar
   
Dries committed
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427

    if ($main) {

      /*
      ** Main page: display the number of comments that have been posted.
      */

      if (user_access("access comments")) {
        $links[] = "<a href=\"node.php?id=$node->nid#comment\">". format_plural(node_get_comments($node->nid), "comment", "comments") ."</a>";
      }
    }
    else {
      /*
      ** Node page: add a "post comment" link if the user is allowed to
      ** post comments.
      */

      if (user_access("post comments")) {
        $links[] = "<a href=\"node.php?id=$node->nid&op=comment#comment\">". t("add new comment") ."</a>";
      }
    }
  }

Dries's avatar
   
Dries committed
428
  return $links ? $links : array();
Dries's avatar
   
Dries committed
429
430
}

Dries's avatar
   
Dries committed
431
432
function comment_node_link($node) {

Dries's avatar
   
Dries committed
433
  if (node_get_comments($node->nid)) {
Dries's avatar
   
Dries committed
434

Dries's avatar
   
Dries committed
435
436
437
    /*
    ** Edit comments:
    */
Dries's avatar
   
Dries committed
438

Dries's avatar
   
Dries committed
439
    $result = db_query("SELECT c.cid, c.subject, u.uid, u.name FROM comments c LEFT JOIN users u ON u.uid = c.uid WHERE lid = '$node->nid' ORDER BY c.timestamp");
Dries's avatar
   
Dries committed
440

Dries's avatar
   
Dries committed
441
442
443
444
445
446
447
448
449
450
451
452
    $output .= "<h3>". t("Edit comments") ."</h3>";
    $output .= "<table border=\"1\" cellpadding=\"2\" cellspacing=\"2\">";
    $output .= " <tr><th>title</th><th>author</th><th colspan=\"3\">operations</th></tr>";

    while ($comment = db_fetch_object($result)) {
      $output .= "<tr><td><a href=\"node.php?id=$node->nid&cid=$comment->cid#$comment->cid\">$comment->subject</a></td><td>". format_name($comment) ."</td><td><a href=\"node.php?id=$node->nid&cid=$comment->cid#$comment->cid\">". t("view comment") ."</a></td><td><a href=\"admin.php?mod=comment&op=edit&id=$comment->cid\">". t("edit comment") ."</a></td><td><a href=\"admin.php?mod=comment&op=delete&id=$comment->cid\">". t("delete comment") ."</a></td></tr>";
    }

    $output .= "</table>";

    return $output;
  }
Dries's avatar
   
Dries committed
453
454
}

Dries's avatar
 
Dries committed
455
function comment_edit($id) {
Dries's avatar
   
Dries committed
456

Dries's avatar
   
Dries committed
457
  $result = db_query("SELECT c.*, u.name, u.uid FROM comments c LEFT JOIN users u ON c.uid = u.uid WHERE c.cid = '$id'");
Dries's avatar
 
Dries committed
458
459
  $comment = db_fetch_object($result);

Dries's avatar
   
Dries committed
460
  $form .= form_item(t("Author"), format_name($comment));
Dries's avatar
   
Dries committed
461
462
  $form .= form_textfield(t("Subject"), "subject", $comment->subject, 70, 128);
  $form .= form_textarea(t("Comment"), "comment", $comment->comment, 70, 15);
Dries's avatar
   
Dries committed
463
  $form .= form_submit(t("Submit"));
Dries's avatar
 
Dries committed
464

Dries's avatar
   
Dries committed
465
  return form($form);
Dries's avatar
 
Dries committed
466
467
}

Dries's avatar
   
Dries committed
468
function comment_save($id, $edit) {
Dries's avatar
   
Dries committed
469
470
  db_query("UPDATE comments SET subject = '". check_query(filter($edit["subject"])) ."', comment = '". check_query(filter($edit["comment"])) ."' WHERE cid = '$id'");
  watchdog("special", "comment: modified '". $edit["subject"] ."'");
Dries's avatar
 
Dries committed
471
472
}

Dries's avatar
   
Dries committed
473
function comment_overview() {
Dries's avatar
   
Dries committed
474
  $result = db_query("SELECT c.*, u.name, u.uid FROM comments c LEFT JOIN users u ON u.uid = c.uid ORDER BY timestamp DESC LIMIT 50");
Dries's avatar
   
Dries committed
475

Dries's avatar
   
Dries committed
476
477
  $output .= "<table border=\"1\" cellpadding=\"2\" cellspacing=\"2\">\n";
  $output .= " <tr><th>subject</th><th>author</th><th>date</th><th colspan=\"2\">operations</th></tr>\n";
Dries's avatar
 
Dries committed
478
  while ($comment = db_fetch_object($result)) {
Dries's avatar
   
Dries committed
479
    $output .= " <tr><td><a href=\"node.php?id=$comment->lid&cid=$comment->cid&pid=$comment->pid#$comment->cid\">". check_output($comment->subject) ."</a></td><td>". format_name($comment) ."</td><td>". format_date($comment->timestamp, "small") ."</td><td><a href=\"admin.php?mod=comment&op=edit&id=$comment->cid\">edit comment</a></td><td><a href=\"admin.php?mod=comment&op=delete&id=$comment->cid\">delete comment</a></td></tr>\n";
Dries's avatar
 
Dries committed
480
  }
Dries's avatar
   
Dries committed
481
  $output .= "</table>\n";
Dries's avatar
   
Dries committed
482

Dries's avatar
   
Dries committed
483
  return $output;
Dries's avatar
 
Dries committed
484
485
}

Dries's avatar
   
Dries committed
486
487
function comment_delete($id) {
  db_query("DELETE FROM comments WHERE cid = '$id'");
Dries's avatar
   
Dries committed
488
  db_query("DELETE FROM moderate WHERE cid = '$id'");
Dries's avatar
   
Dries committed
489
490
491
  watchdog("special", "comment: deleted '$id'");
}

Dries's avatar
 
Dries committed
492
function comment_admin() {
Dries's avatar
   
Dries committed
493
  global $op, $id, $edit, $mod, $keys, $order;
Dries's avatar
 
Dries committed
494

Dries's avatar
   
Dries committed
495
  if (user_access("administer comments")) {
Dries's avatar
   
Dries committed
496

Dries's avatar
   
Dries committed
497
    print "<small><a href=\"admin.php?mod=comment\">overview</a> | <a href=\"admin.php?mod=comment&op=search\">search comment</a></small><hr />\n";
Dries's avatar
   
Dries committed
498
499
500
501
502
503

    switch ($op) {
      case "edit":
        print comment_edit($id);
        break;
      case "search":
Dries's avatar
   
Dries committed
504
        print search_type("comment", "admin.php?mod=comment&op=search");
Dries's avatar
   
Dries committed
505
        break;
Dries's avatar
   
Dries committed
506
      case "delete":
Dries's avatar
   
Dries committed
507
        print comment_delete(check_query($id));
Dries's avatar
   
Dries committed
508
509
        print comment_overview();
        break;
Dries's avatar
   
Dries committed
510
      case t("Submit"):
Dries's avatar
   
Dries committed
511
        print status(comment_save(check_query($id), $edit));
Dries's avatar
   
Dries committed
512
513
514
515
516
517
518
519
        print comment_overview();
        break;
      default:
        print comment_overview();
    }
  }
  else {
    print message_access();
Dries's avatar
 
Dries committed
520
521
  }
}
Dries's avatar
   
Dries committed
522

Dries's avatar
   
Dries committed
523
?>