From: moodler
Date: Wed, 10 Dec 2003 16:29:56 +0000 (+0000)
Subject: Hope you don't mind, Will, but I had to do some cleaning up of the comments pages
X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=a61cf7e35ea46c1f9267e921ec0c94d329dbe40c;p=moodle.git
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 :-)
---
diff --git a/mod/glossary/comment.html b/mod/glossary/comment.html
index 922baab32b..e8571c6e1a 100644
--- a/mod/glossary/comment.html
+++ b/mod/glossary/comment.html
@@ -1,9 +1,4 @@
-
-
-
-
-
-
diff --git a/mod/glossary/comment.php b/mod/glossary/comment.php
index 67a14bbe8e..7f57a2df00 100644
--- a/mod/glossary/comment.php
+++ b/mod/glossary/comment.php
@@ -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 = "id\">$course->shortname ->";
}
-
+
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 id>$strglossaries -> id>$glossary->name -> id&eid=$entry->id>$strcomments -> " . $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 "
";
- }
-
- echo "";
- echo "
";
- echo "cellheading2>";
- echo " | ";
- echo get_string("commentson","glossary") . " $entry->concept | ";
- echo "";
- echo " | ";
-
- echo " |
";
- echo "";
- if ($entry->attachment) {
- $entry->course = $course->id;
- echo "";
- echo glossary_print_attachments($entry,"html");
- echo " | ";
- }
- echo "$entry->concept: ";
- echo format_text($entry->definition, $entry->format);
- echo " | ";
- echo "
";
-
+ "$navigation id>$strglossaries -> id>$glossary->name -> id&eid=$entry->id>$strcomments -> " . $straction,
+ "", "", true, update_module_button($cm->id, $course->id, $strglossary),
+ navmenu($course, $cm));
echo "";
- echo "
";
/// 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 "";
- echo "
";
- echo "cellheading\">";
- $user = get_record("user", "id", $comment->userid);
- $strby = get_string("writtenby","glossary");
-
- print_user_picture($user->id, $course->id, $user->picture);
- echo " $strby $user->firstname $user->lastname";
- echo " (".get_string("lastedited").": ".userdate($comment->timemodified).")";
+ } else {
- echo " | cellcontent\">";
- echo format_text($comment->comment, $comment->format);
- echo " |
";
- echo "";
+ glossary_print_comment($course, $cm, $glossary, $entry, $comment);
- print_simple_box_start("center","40%", "#FFBBBB");
- echo "
" . get_string("areyousuredeletecomment","glossary");
-?>
-
-
-
" . get_string("areyousuredeletecomment","glossary");
+ ?>
+
+
+ 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 "";
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 "
";
+
+ 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);
?>
diff --git a/mod/glossary/comments.php b/mod/glossary/comments.php
index 8597bc2d5c..027c4817fb 100644
--- a/mod/glossary/comments.php
+++ b/mod/glossary/comments.php
@@ -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 id>$strglossaries -> id>$glossary->name -> $entry->concept",
+ print_header(strip_tags("$course->shortname: $strcomments: $entry->concept"), "$course->fullname",
+ "$navigation id>$strglossaries -> id>$glossary->name -> $strcomments",
"", "", true, update_module_button($cm->id, $course->id, $strglossary),
navmenu($course, $cm));
@@ -61,13 +63,12 @@
/// comments
- $strheading = get_string('commentson','glossary')." \"$entry->concept\"";
+ print_heading(get_string('commentson','glossary')." \"$entry->concept\"");
+
if ($glossary->allowcomments) {
- $strheading .= " id&eid=$entry->id\">
";
+ print_heading("id&eid=$entry->id\">$straddcomment
");
}
- print_heading($strheading);
-
if ($comments = get_records("glossary_comments","entryid",$entry->id,"timemodified ASC")) {
foreach ($comments as $comment) {
glossary_print_comment($course, $cm, $glossary, $entry, $comment);
@@ -77,6 +78,7 @@
print_heading(get_string("nocomments","glossary"));
}
+
/// Finish the page
print_footer($course);