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"); } } require_login($course->id); if (!$cm->visible and !isteacher($course->id)) { notice(get_string("activityiscurrentlyhidden")); } if (isguest()) { 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 if ($course->category) { $navigation = "id\">$course->shortname ->"; } switch ( $action ){ case "add": $straction = get_string("addingcomment","glossary"); break; case "edit": $straction = get_string("editingcomment","glossary"); break; 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 "
"; echo ""; echo "
"; echo get_string("commentson","glossary") . " $entry->concept"; 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 "

"; echo "
"; /// Input section if ( $action == "delete" ) { if ( $confirm ) { delete_records("glossary_comments","id", $cid); print_simple_box_start("center","40%", "#FFBBBB"); echo "
" . get_string("commentdeleted","glossary") . "
"; print_simple_box_end(); 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).")"; echo "
cellcontent\">"; echo format_text($comment->comment, $comment->format); echo "
"; echo "

"; print_simple_box_start("center","40%", "#FFBBBB"); echo "


" . get_string("areyousuredeletecomment","glossary"); ?>
"> " onclick="javascript:history.go(-1);">
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); } elseif (time() - $comment->timemodified >= $CFG->maxeditingtime ) { echo get_string("maxtimehaspassed","glossary",$CFG->maxeditingtime); } echo "
"; print_footer($course); die; } } if ( $confirm and $form = data_submitted() ) { $form->text = clean_text($form->text, $form->format); $newentry->entryid = $entry->id; $newentry->comment = $form->text; $newentry->format = $form->format; $newentry->timemodified = time(); if ( $action == "add" ) { $newentry->userid = $USER->id; if (! $newentry->id = insert_record("glossary_comments", $newentry)) { error("Could not insert this new comment"); } else { add_to_log($course->id, "glossary", "add comment", "comments.php?id=$cm->id&eid=$entry->id", "$newentry->id"); } } else { $newentry->id = $form->cid; $newentry->userid = $comment->userid; if (! update_record("glossary_comments", $newentry)) { error("Could not update this comment"); } else { add_to_log($course->id, "glossary", "update comment", "comments.php?id=$cm->id&eid=$entry->id", "$newentry->id"); } } print_simple_box_start("center","40%", "#FFBBBB"); echo "
" . get_string("commentupdated","glossary") . "
"; print_simple_box_end(); print_footer($course); redirect("comments.php?id=$cm->id&eid=$entry->id"); } else { if ($usehtmleditor = can_use_richtext_editor()) { $defaultformat = FORMAT_HTML; $onsubmit = "onsubmit=\"copyrichtext(theform.text);\""; } else { $defaultformat = FORMAT_MOODLE; $onsubmit = ""; } if (isset($comment) ) { $form->text = $comment->comment; $form->format = $comment->format; } else { $form->text = ""; $form->format = $defaultformat; } include("comment.html"); } } /// Finish the page print_footer($course); ?>