Skip to content
Snippets Groups Projects
Select Git revision
  • f39bba80fa351d0c4d5d010fc46c73f0467882b0
  • 11.x default protected
  • 10.6.x protected
  • 10.5.x protected
  • 11.2.x protected
  • 11.1.x protected
  • 10.4.x protected
  • 11.0.x protected
  • 10.3.x protected
  • 7.x protected
  • 10.2.x protected
  • 10.1.x protected
  • 9.5.x protected
  • 10.0.x protected
  • 9.4.x protected
  • 9.3.x protected
  • 9.2.x protected
  • 9.1.x protected
  • 8.9.x protected
  • 9.0.x protected
  • 8.8.x protected
  • 10.5.1 protected
  • 11.2.2 protected
  • 11.2.1 protected
  • 11.2.0 protected
  • 10.5.0 protected
  • 11.2.0-rc2 protected
  • 10.5.0-rc1 protected
  • 11.2.0-rc1 protected
  • 10.4.8 protected
  • 11.1.8 protected
  • 10.5.0-beta1 protected
  • 11.2.0-beta1 protected
  • 11.2.0-alpha1 protected
  • 10.4.7 protected
  • 11.1.7 protected
  • 10.4.6 protected
  • 11.1.6 protected
  • 10.3.14 protected
  • 10.4.5 protected
  • 11.0.13 protected
41 results

comment.module

Blame
  • Dries Buytaert's avatar
    Dries Buytaert authored
    - All comments on the administration page are actually "linked" now: the
      comments on the drupal page where originally *not* click-able but this
      turned out to be confusing only.   Now we live in a nodified world, we
      can simply link all comments without a single problem! :-)
    f39bba80
    History
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    comment.module 3.92 KiB
    <?php
    
    $module = array("find" => "comment_find",
                    "admin" => "comment_admin");
    
    function comment_find($keys) {
      global $user;
      $find = array();
      $result = db_query("SELECT c.*, u.userid FROM comments c LEFT JOIN users u ON c.author = u.id WHERE c.subject LIKE '%$keys%' OR c.comment LIKE '%$keys%' ORDER BY c.timestamp DESC LIMIT 20");
      while ($comment = db_fetch_object($result)) {
        array_push($find, array("title" => check_output($comment->subject), "link" => (user_access($user, "comment") ? "admin.php?mod=comment&op=edit&id=$comment->cid" : "node.php?id=$comment->lid&cid=$comment->cid"), "user" => $comment->userid, "date" => $comment->timestamp));
      }
      return $find;
    }
    
    function comment_search() {
      global $keys, $mod;
      print search_form($keys);
      print search_data($keys, $mod);
    }
    
    function comment_edit($id) {
      $result = db_query("SELECT c.*, u.userid FROM comments c LEFT JOIN users u ON c.author = u.id WHERE c.cid = '$id'");
    
      $comment = db_fetch_object($result);
    
      $output .= "<FORM ACTION=\"admin.php?mod=comment&op=save&id=$id\" METHOD=\"post\">\n";
    
      $output .= "<B>Author:</B><BR>\n";
      $output .= format_username($comment->userid) ."<P>\n";
    
      $output .= "<B>Subject:</B><BR>\n";
      $output .= "<INPUT TYPE=\"text\" NAME=\"subject\" SIZE=\"50\" VALUE=\"". check_textfield($comment->subject) ."\"><P>\n";
    
      $output .= "<B>Comment:</B><BR>\n";
      $output .= "<TEXTAREA WRAP=\"virtual\" COLS=\"50\" ROWS=\"10\" NAME=\"comment\">". check_textarea($comment->comment) ."</TEXTAREA><P>\n";
    
      $output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Save comment\">\n";
      $output .= "</FORM>\n";
    
      print $output;
    }
    
    function comment_save($id, $subject, $comment) {
      db_query("UPDATE comments SET subject = '$subject', comment = '$comment' WHERE cid = '$id'");
      watchdog("message", "comment: modified '$subject'");
    }
    
    function comment_display($order = "date") {
      // Initialize variables:
      $fields = array("author" => "author", "date" => "timestamp DESC", "subject" => "subject");
    
      // Perform SQL query:
      $result = db_query("SELECT c.*, u.userid FROM comments c LEFT JOIN users u ON u.id = c.author ORDER BY c.$fields[$order] LIMIT 50");
    
      // Display comments:
      $output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n";
      $output .= " <TR>\n";
      $output .= "  <TH ALIGN=\"right\" COLSPAN=\"3\">\n";
      $output .= "   <FORM ACTION=\"admin.php?mod=comment\" METHOD=\"post\">\n";
      $output .= "    <SELECT NAME=\"order\">\n";
      foreach ($fields as $key=>$value) {
        $output .= "     <OPTION VALUE=\"$key\"". ($key == $order ? " SELECTED" : "") .">Sort by $key</OPTION>\n";
      }
      $output .= "    </SELECT>\n";
      $output .= "    <INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Update\">\n";
      $output .= "   </FORM>\n";
      $output .= "  </TH>\n";
      $output .= " </TR>\n";
    
      $output .= " <TR>\n";
      $output .= "  <TH>subject</TH>\n";
      $output .= "  <TH>author</TH>\n";
      $output .= "  <TH>operations</TH>\n";
      $output .= " </TR>\n";
    
      while ($comment = db_fetch_object($result)) {
        $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_username($comment->userid) ."</TD><TD ALIGN=\"center\"><A HREF=\"admin.php?mod=comment&op=edit&id=$comment->cid\">edit</A></TD></TR>\n";
      }
    
      $output .= "</TABLE>\n";
    
      print $output;
    }
    
    function comment_admin() {
      global $op, $id, $subject, $comment, $order;
    
      print "<SMALL><A HREF=\"admin.php?mod=comment\">overview</A> | <A HREF=\"admin.php?mod=comment&op=search\">search comment</A></SMALL><HR>\n";
    
      switch ($op) {
        case "edit":
          comment_edit($id);
          break;
        case "search":
          comment_search();
          break;
        case "Save comment":
          comment_save(check_input($id), check_input($subject), check_input($comment));
          comment_display();
          break;
        case "Update":
          comment_display(check_input($order));
          break;
        default:
          comment_display();
      }
    }
    
    ?>