Hope you don't mind, Will, but I had to do some cleaning up of the comments pages

- comments look more like forums
   - glossary entry is displayed consistently
   - workflow makes more sense to me at least (more like forums)
   - code is shorter   :-)
This commit is contained in:
moodler
2003-12-10 16:29:56 +00:00
parent 79be5e9a41
commit a61cf7e35e
3 changed files with 66 additions and 112 deletions
+1 -14
View File
@@ -1,9 +1,4 @@
<?php
global $CFG, $THEME;
require_once("../../config.php");
require_once("lib.php");
?>
<FORM name="theform" method="post" <?=$onsubmit ?> action="comment.php">
<FORM name="theform" method="post" action="comment.php">
<table class=generalbox cellpadding=5 bgcolor="<?php p($THEME->cellheading)?>">
<tr valign=top>
<td align=right><p><b><?php echo get_string("comment","glossary") ?>:</b></p>
@@ -59,12 +54,4 @@
</table>
</p>
</form>
<?PHP
if ($usehtmleditor) {
print_richedit_javascript("theform", "text", "no");
}
?>
+56 -91
View File
@@ -3,39 +3,39 @@
/// This page prints a particular instance of glossary
require_once("../../config.php");
require_once("lib.php");
require_variable($id); // Course Module ID
require_variable($eid); // Entry ID
optional_variable($cid,0); // Comment ID
optional_variable($action,"add"); // Action to perform
optional_variable($confirm,0); // Confirm the action
$action = strtolower($action);
global $THEME, $USER, $CFG;
global $THEME, $USER, $CFG;
if (! $cm = get_record("course_modules", "id", $id)) {
error("Course Module ID was incorrect");
}
if (! $course = get_record("course", "id", $cm->course)) {
error("Course is misconfigured");
}
if (! $glossary = get_record("glossary", "id", $cm->instance)) {
error("Course module is incorrect");
}
if (! $entry = get_record("glossary_entries", "id", $eid)) {
error("Entry is incorrect");
}
if ( $cid ) {
if (! $comment = get_record("glossary_comments", "id", $cid)) {
error("Comment is incorrect");
}
}
if (! $entry = get_record("glossary_entries", "id", $eid)) {
error("Entry is incorrect");
}
if ( $cid ) {
if (! $comment = get_record("glossary_comments", "id", $cid)) {
error("Comment is incorrect");
}
}
require_login($course->id);
if (!$cm->visible and !isteacher($course->id)) {
@@ -45,12 +45,12 @@
error("Guests are not allowed to post comments", $_SERVER["HTTP_REFERER"]);
}
add_to_log($course->id, "glossary", "view", "view.php?id=$cm->id", "$glossary->id");
/// Printing the page header
/// Printing the page header
if ($course->category) {
$navigation = "<a href=\"../../course/view.php?id=$course->id\">$course->shortname</a> ->";
}
switch ( $action ){
case "add":
$straction = get_string("addingcomment","glossary");
@@ -61,51 +61,20 @@
case "delete":
$straction = get_string("deletingcomment","glossary");
break;
}
}
$strglossaries = get_string("modulenameplural", "glossary");
$strglossary = get_string("modulename", "glossary");
$strcomments = get_string("comments", "glossary");
print_header(strip_tags("$course->shortname: $glossary->name"), "$course->fullname",
"$navigation <A HREF=index.php?id=$course->id>$strglossaries</A> -> <A HREF=view.php?id=$cm->id>$glossary->name</a> -> <A HREF=comments.php?id=$cm->id&eid=$entry->id>$strcomments</a> -> " . $straction,
"", "", true, update_module_button($cm->id, $course->id, $strglossary),
navmenu($course, $cm));
print_heading($glossary->name);
/// Info boxes
if ( $glossary->intro ) {
print_simple_box(format_text($glossary->intro), "center","70%");
echo "<br />";
}
echo "<p align=center>";
echo "<table class=\"generalbox\" width=\"70%\" align=\"center\" border=\"0\" cellpadding=\"5\" cellspacing=\"0\">";
echo "<tr bgcolor=$THEME->cellheading2><td align=center>";
echo "<table border=0 width=100%><tr><td width=33%></td><td width=33% align=center>";
echo get_string("commentson","glossary") . " <b>$entry->concept</b></td>";
echo "<td width=33% align=right>";
echo "</td></tr></table>";
echo "</td></tr>";
echo "<tr><TD WIDTH=100% BGCOLOR=\"#FFFFFF\">";
if ($entry->attachment) {
$entry->course = $course->id;
echo "<table border=0 align=right><tr><td>";
echo glossary_print_attachments($entry,"html");
echo "</td></tr></table>";
}
echo "<b>$entry->concept</b>: ";
echo format_text($entry->definition, $entry->format);
echo "</td>";
echo "</TR></table>";
"$navigation <A HREF=index.php?id=$course->id>$strglossaries</A> -> <A HREF=view.php?id=$cm->id>$glossary->name</a> -> <A HREF=comments.php?id=$cm->id&eid=$entry->id>$strcomments</a> -> " . $straction,
"", "", true, update_module_button($cm->id, $course->id, $strglossary),
navmenu($course, $cm));
echo "<center>";
echo "<br />";
/// Input section
if ( $action == "delete" ) {
if ( $confirm ) {
delete_records("glossary_comments","id", $cid);
@@ -117,43 +86,32 @@
print_footer($course);
add_to_log($course->id, "glossary", "delete comment", "comments.php?id=$cm->id&eid=$entry->id", $comment);
redirect("comments.php?id=$cm->id&eid=$entry->id");
} else {
echo "<p align=center>";
echo "<table class=\"generalbox\" width=\"70%\" align=\"center\" border=\"0\" cellpadding=\"5\" cellspacing=\"0\">";
echo "<tr><td align=right width=25% BGCOLOR=\"$THEME->cellheading\">";
$user = get_record("user", "id", $comment->userid);
$strby = get_string("writtenby","glossary");
glossary_print_comment($course, $cm, $glossary, $entry, $comment);
print_user_picture($user->id, $course->id, $user->picture);
echo "<br><FONT SIZE=2>$strby $user->firstname $user->lastname</font>";
echo "<br><FONT SIZE=1>(".get_string("lastedited").": ".userdate($comment->timemodified).")</FONT></small>";
print_simple_box_start("center","40%", "#FFBBBB");
echo "<center><br>" . get_string("areyousuredeletecomment","glossary");
?>
<form name="form" method="post" action="comment.php">
<input type="hidden" name=id value="<?php p($id) ?>">
<input type="hidden" name=eid value="<?php p($eid) ?>">
<input type="hidden" name=cid value="<?php p($cid) ?>">
<input type="hidden" name=action value="delete">
<input type="hidden" name=confirm value="1">
<input type="submit" value=" <?php print_string("yes")?> ">
<input type=button value=" <?php print_string("no")?> " onclick="javascript:history.go(-1);">
echo "</td><TD WIDTH=75% BGCOLOR=\"$THEME->cellcontent\">";
echo format_text($comment->comment, $comment->format);
echo "</td></TR></table>";
echo "<p align=center>";
print_simple_box_start("center","40%", "#FFBBBB");
echo "<center><br>" . get_string("areyousuredeletecomment","glossary");
?>
<form name="form" method="post" action="comment.php">
<input type="hidden" name=id value="<?php p($id) ?>">
<input type="hidden" name=eid value="<?php p($eid) ?>">
<input type="hidden" name=cid value="<?php p($cid) ?>">
<input type="hidden" name=action value="delete">
<input type="hidden" name=confirm value="1">
<input type="submit" value=" <?php print_string("yes")?> ">
<input type=button value=" <?php print_string("no")?> " onclick="javascript:history.go(-1);">
</form>
</center>
<?php
</form>
</center>
<?php
print_simple_box_end();
}
} else {
if ( $action == "edit" ) {
if ( (time() - $comment->timemodified >= $CFG->maxeditingtime or $USER->id != $comment->userid) and !isteacher($course->id) ) {
if ( (time() - $comment->timemodified >= $CFG->maxeditingtime or
$USER->id != $comment->userid) and !isteacher($course->id) ) {
echo "<center><strong>";
if ( $USER->id != $comment->userid ) {
echo get_string("youarenottheauthor","glossary",$CFG->maxeditingtime);
@@ -165,7 +123,7 @@
die;
}
}
if ( $confirm and $form = data_submitted() ) {
$form->text = clean_text($form->text, $form->format);
@@ -173,7 +131,7 @@
$newentry->comment = $form->text;
$newentry->format = $form->format;
$newentry->timemodified = time();
if ( $action == "add" ) {
$newentry->userid = $USER->id;
@@ -199,13 +157,16 @@
print_footer($course);
redirect("comments.php?id=$cm->id&eid=$entry->id");
} else {
if ($usehtmleditor = can_use_richtext_editor()) {
/// original glossary entry
glossary_print_entry($course, $cm, $glossary, $entry, "", "", false);
echo "<br />";
if ($usehtmleditor = can_use_html_editor()) {
$defaultformat = FORMAT_HTML;
$onsubmit = "onsubmit=\"copyrichtext(theform.text);\"";
} else {
$defaultformat = FORMAT_MOODLE;
$onsubmit = "";
}
if (isset($comment) ) {
$form->text = $comment->comment;
@@ -215,8 +176,12 @@
$form->format = $defaultformat;
}
include("comment.html");
if ($usehtmleditor) {
use_html_editor();
}
}
}
/// Finish the page
/// Finish the page
print_footer($course);
?>
+9 -7
View File
@@ -47,9 +47,11 @@
$strsearchconcept = get_string("searchconcept", "glossary");
$strsearchindefinition = get_string("searchindefinition", "glossary");
$strsearch = get_string("search");
$strcomments = get_string("comments", "glossary");
$straddcomment = get_string("addcomment", "glossary");
print_header(strip_tags("$course->shortname: $glossary->name"), "$course->fullname",
"$navigation <A HREF=index.php?id=$course->id>$strglossaries</A> -> <A HREF=view.php?id=$cm->id>$glossary->name</a> -> $entry->concept",
print_header(strip_tags("$course->shortname: $strcomments: $entry->concept"), "$course->fullname",
"$navigation <A HREF=index.php?id=$course->id>$strglossaries</A> -> <A HREF=view.php?id=$cm->id>$glossary->name</a> -> $strcomments",
"", "", true, update_module_button($cm->id, $course->id, $strglossary),
navmenu($course, $cm));
@@ -61,12 +63,11 @@
/// comments
$strheading = get_string('commentson','glossary')." <b>\"$entry->concept\"</b>";
if ($glossary->allowcomments) {
$strheading .= "&nbsp;&nbsp;<a href=\"comment.php?id=$cm->id&eid=$entry->id\"><img title=\"" . get_string("addcomment","glossary") . "\" src=\"comment.gif\" height=11 width=11 border=0></a> ";
}
print_heading(get_string('commentson','glossary')." <b>\"$entry->concept\"</b>");
print_heading($strheading);
if ($glossary->allowcomments) {
print_heading("<a href=\"comment.php?id=$cm->id&eid=$entry->id\">$straddcomment</a> <img title=\"$straddcomment\" src=\"comment.gif\" height=11 width=11 border=0>");
}
if ($comments = get_records("glossary_comments","entryid",$entry->id,"timemodified ASC")) {
foreach ($comments as $comment) {
@@ -77,6 +78,7 @@
print_heading(get_string("nocomments","glossary"));
}
/// Finish the page
print_footer($course);