- KNOWN BUG: It does not restore the comments even when userinfo is set... Eloy! I need your help! :)
<?PHP // $Id$
// glossary.php - created with Moodle 1.1 Beta (2003082001)
+$string['addcomment'] = "Add comment";
$string['addentry'] = "Add a new entry";
$string['allentries'] = "ALL";
$string['allcategories'] = "All Categories";
+$string['allowcomments'] = "Allow comments on entries";
$string['allowduplicatedentries'] = "Duplicated entries allowed";
$string['alphabet'] = "A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z";
$string['areyousuredelete'] = "Are you sure you want to delete this entry?";
+$string['areyousuredeletecomment'] = "Are you sure you want to delete this comment?";
$string['attachment'] = "Attachment";
$string['back'] = "Back";
$string['categories'] = "Categories";
$string['categoryview'] = "Browse by category";
$string['category'] = "Category";
$string['categorydeleted'] = "Category deleted";
+$string['comment'] = "Comment";
+$string['commentdeleted'] = "The comment has been deleted.";
+$string['commentupdated'] = "The comment has been updated.";
+$string['comments'] = "Comments";
+$string['commentson'] = "Comments on";
$string['concept'] = "Concept";
$string['concepts'] = "Concepts";
+$string['deletingcomment'] = "Deleting comment";
$string['definition'] = "Definition";
$string['definitions'] = "Definitions";
$string['deleteentry'] = "Delete entry";
$string['displayformat1'] = "Full without author";
$string['displayformat2'] = "Full with author";
$string['displayformat3'] = "Encyclopedia";
-$string['editentry'] = "Edit entry";
$string['editcategories'] = "Edit categories";
+$string['editentry'] = "Edit entry";
+$string['editingcomment'] = "Editing comment";
$string['entries'] = "Entries";
$string['entrieswithoutcategory'] = "Entries without category";
$string['entry'] = "Entry";
$string['mainglossary'] = "Main glossary";
$string['modulename'] = "Glossary";
$string['modulenameplural'] = "Glossaries";
+$string['maxtimehaspassed'] = "Sorry, but the maximum time for editing this comment (\$a) has passed!";
$string['newglossaryentries'] = "New glossary entries:";
$string['notcategorised'] = "Not categorised";
+$string['nocomment'] = "No comment found";
+$string['nocomments'] = "(No comments found on this entry)";
$string['noentries'] = "No entries found in this section";
$string['noentry'] = "No entry found.";
$string['searchindefinition'] = "Search definitions too";
$string['studentcanpost'] = "Students can add entries";
$string['warningstudentcapost'] = "(Applies only if the glossary is not the main one)";
$string['writtenby'] = "by";
+$string['youarenottheauthor'] = "You are not the author of this comment, therefore, you are not allowed to edit it.";
?>
--- /dev/null
+<P ALIGN=CENTER><B>Allow comments on entries</B></P>
+
+<P>You can specify if the system should or should not allow comments on glossary entries.
+
// | |
// glossary_entries -------------- glossary_entries_categories
// (UL,pk->id, fk->glossaryid, files) (UL, [pk->categoryid,entryid]
+ // |
+ // |
+ // |
+ // glossary_comments
+ // (UL,pk->id, fk->entryid)
+ //
//
// Meaning: pk->primary key field of the table
// fk->foreign key to link with parent
fwrite ($bf,full_tag("SHOWSPECIAL",4,false,$glossary->showspecial));
fwrite ($bf,full_tag("SHOWALPHABET",4,false,$glossary->showalphabet));
fwrite ($bf,full_tag("SHOWALL",4,false,$glossary->showall));
+ fwrite ($bf,full_tag("ALLOWCOMMENTS",4,false,$glossary->allowcomments));
fwrite ($bf,full_tag("TIMECREATED",4,false,$glossary->timecreated));
fwrite ($bf,full_tag("TIMEMODIFIED",4,false,$glossary->timemodified));
backup_glossary_categories($bf,$preferences,$glossary->id, $preferences->mods["glossary"]->userinfo);
+ if ( $preferences->mods["glossary"]->userinfo ) {
+ backup_glossary_comments($bf,$preferences,$glossary->id, $preferences->mods["glossary"]->userinfo);
+ }
//End mod
$status =fwrite ($bf,end_tag("MOD",3,true));
}
fwrite ($bf,full_tag("TIMECREATED",6,false,$glo_ent->timecreated));
fwrite ($bf,full_tag("TIMEMODIFIED",6,false,$glo_ent->timemodified));
fwrite ($bf,full_tag("TEACHERENTRY",6,false,$glo_ent->teacherentry));
-
+/*
+ if ( $userinfo ) {
+ $comments = get_records("glossary_comments","entryid",$glo_ent->id);
+ if ( $comments ) {
+ $status =fwrite ($bf,start_tag("COMMENTS",6,true));
+ foreach ($comments as $comment) {
+ $status =fwrite ($bf,start_tag("COMMENT",7,true));
+
+ fwrite ($bf,full_tag("ID",6,false,$comment->id));
+ fwrite ($bf,full_tag("USERID",6,false,$comment->userid));
+ fwrite ($bf,full_tag("COMMENT",6,false,$comment->comment));
+ fwrite ($bf,full_tag("FORMAT",6,false,$comment->format));
+ fwrite ($bf,full_tag("TIMEMODIFIED",6,false,$comment->timemodified));
+
+ $status =fwrite ($bf,end_tag("COMMENT",7,true));
+ }
+ $status =fwrite ($bf,end_tag("COMMENTS",6,true));
+ }
+ }
+*/
$status =fwrite ($bf,end_tag("ENTRY",5,true));
//Now include entry attachment in backup (if it exists)
return $status;
}
-
//Backup glossary files because we've selected to backup user info
//or current entry is a teacher entry
function backup_glossary_files($bf,$preferences,$glossary,$entry) {
--- /dev/null
+<?php
+ global $CFG, $THEME;
+ require_once("../../config.php");
+ require_once("lib.php");
+?>
+<FORM name="theform" method="post" <?=$onsubmit ?> 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>
+ <font size="1">
+ <?php
+ helpbutton("writing", get_string("helpwriting"), "moodle", true, true);
+ echo "<br />";
+ if ($usehtmleditor) {
+ helpbutton("richtext", get_string("helprichtext"), "moodle", true, true);
+ } else {
+ emoticonhelpbutton("form", "comment");
+ }
+ ?>
+ <br />
+ </font>
+ </td>
+ <td>
+ <?php
+ print_textarea($usehtmleditor, 20, 60, 680, 400, "text", $form->text);
+
+ echo "<p align=right>";
+ helpbutton("textformat", get_string("helpformatting"));
+ print_string("formattexttype");
+ echo ": ";
+ if (!$form->format) {
+ $form->format = $defaultformat;
+ }
+ choose_from_menu(format_text_menu(), "format", $format->format, "");
+ echo "</p>";
+ ?>
+ </td>
+</tr>
+<tr>
+<td colspan=2>
+ <p align=center>
+ <?php
+ if ($comment->id) {
+ echo "<input type=\"hidden\" name=cid value=\"$comment->id\">";
+ }
+ ?>
+ <input type="hidden" name=id value="<?=$cm->id ?>">
+ <input type="hidden" name=eid value="<?=$entry->id ?>">
+ <input type="hidden" name=action value="<?=$action ?>">
+ <input type="hidden" name=confirm value="1">
+
+ <input type="submit" value="<?php print_string("savechanges") ?>">
+ <input type="reset" value="<?php print_string("revert") ?>">
+ </P>
+</td>
+</tr>
+</table>
+</p>
+
+
+</form>
+
+<?PHP
+ if ($usehtmleditor) {
+ print_richedit_javascript("theform", "text", "no");
+ }
+?>
+
--- /dev/null
+<?php // $Id$
+
+/// 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;
+
+ 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");
+ }
+ }
+
+ require_login($course->id);
+ if (!$cm->visible and !isteacher($course->id)) {
+ notice(get_string("activityiscurrentlyhidden"));
+ }
+
+ add_to_log($course->id, "glossary", "view", "view.php?id=$cm->id", "$glossary->id");
+
+/// 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");
+ 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 <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_start("center","70%");
+ echo '<p>';
+ echo $glossary->intro;
+ echo '</p>';
+ print_simple_box_end();
+ }
+
+ 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 "<b>$entry->concept</b>";
+ 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 format_text($entry->definition, $entry->format);
+ echo "</td>";
+ echo "</TR></table><p align=center>";
+
+/// Input section
+ if ( $action == "delete" ) {
+ if ( $confirm ) {
+ delete_records("glossary_comments","id", $cid);
+
+ print_simple_box_start("center","40%", "#FFBBBB");
+ echo "<center>" . get_string("commentdeleted","glossary") . "</center>";
+ 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 "<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");
+
+ 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>";
+
+ 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
+ print_simple_box_end();
+ }
+ } else {
+ if ( $action == "edit" ) {
+ 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);
+ } elseif (time() - $comment->timemodified >= $CFG->maxeditingtime ) {
+ echo get_string("maxtimehaspassed","glossary",$CFG->maxeditingtime);
+ }
+ echo "</strong></center>";
+ 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 = $comment->timemodified;
+
+ 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 "<center>" . get_string("commentupdated","glossary") . "</center>";
+ 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 = "";
+ }
+
+ $form->text = $comment->comment;
+ $form->format = $comment->format;
+ include("comment.html");
+ }
+ }
+/// Finish the page
+ print_footer($course);
+?>
\ No newline at end of file
--- /dev/null
+<?php // $Id$
+
+/// 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
+
+ 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");
+ }
+
+
+ require_login($course->id);
+ if (!$cm->visible and !isteacher($course->id)) {
+ notice(get_string("activityiscurrentlyhidden"));
+ }
+
+ add_to_log($course->id, "glossary", "view", "view.php?id=$cm->id", "$glossary->id");
+
+
+/// Printing the page header
+ if ($course->category) {
+ $navigation = "<a href=\"../../course/view.php?id=$course->id\">$course->shortname</a> ->";
+ }
+
+ $strglossaries = get_string("modulenameplural", "glossary");
+ $strglossary = get_string("modulename", "glossary");
+ $strallcategories = get_string("allcategories", "glossary");
+ $straddentry = get_string("addentry", "glossary");
+ $strnoentries = get_string("noentries", "glossary");
+ $strsearchconcept = get_string("searchconcept", "glossary");
+ $strsearchindefinition = get_string("searchindefinition", "glossary");
+ $strsearch = get_string("search");
+
+ 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> -> " . get_string("comments","glossary"),
+ "", "", true, update_module_button($cm->id, $course->id, $strglossary),
+ navmenu($course, $cm));
+
+ print_heading($glossary->name);
+
+/// Info boxes
+
+ if ( $glossary->intro ) {
+ print_simple_box_start("center","70%");
+ echo '<p>';
+ echo $glossary->intro;
+ echo '</p>';
+ print_simple_box_end();
+ }
+
+ 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>";
+ if ( $glossary->allowcomments ) {
+ echo "<a href=\"comment.php?id=$cm->id&eid=$entry->id\"><img alt=\"" . get_string("addcomment","glossary") . "\" src=\"comment.gif\" height=16 width=16 border=0></a> ";
+ }
+ 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>";
+
+/// comments
+ $comments = get_records("glossary_comments","entryid",$entry->id,"timemodified ASC");
+ if ( !$comments ) {
+ echo "<p align=center><strong>" . get_string("nocomments","glossary") . "</string>";
+ } else {
+ foreach ($comments as $comment) {
+ echo "<p align=center>";
+ glossary_print_comment($course, $cm, $glossary, $entry, $comment);
+ }
+ }
+
+/// Finish the page
+ print_footer($course);
+?>
\ No newline at end of file
}
+ if ( $oldversion < 2003101501 ) {
+ execute_sql( "ALTER TABLE `{$CFG->prefix}glossary` " .
+ "ADD `allowcomments` TINYINT(2) UNSIGNED NOT NULL DEFAULT '0' AFTER `showall` " );
+
+ execute_sql("CREATE TABLE `{$CFG->prefix}glossary_comments` (
+ `id` INT(10) unsigned NOT NULL auto_increment,
+ `entryid` INT(10) UNSIGNED NOT NULL default '0',
+ `userid` INT(10) UNSIGNED NOT NULL default '0',
+ `comment` TEXT NOT NULL default '',
+ `timemodified` INT(10) UNSIGNED NOT NULL default '0',
+ `format` TINYINT(2) UNSIGNED NOT NULL default '0',
+ PRIMARY KEY (`id`)
+ ) TYPE=MyISAM COMMENT='comments on glossary entries'");
+
+ execute_sql(" INSERT INTO {$CFG->prefix}log_display VALUES ('glossary', 'add comment', 'glossary', 'name') ");
+ execute_sql(" INSERT INTO {$CFG->prefix}log_display VALUES ('glossary', 'update comment', 'glossary', 'name') ");
+ execute_sql(" INSERT INTO {$CFG->prefix}log_display VALUES ('glossary', 'delete comment', 'glossary', 'name') ");
+ }
+
return true;
}
showspecial tinyint(2) unsigned NOT NULL default '1',
showalphabet tinyint(2) unsigned NOT NULL default '1',
showall tinyint(2) unsigned NOT NULL default '1',
+ allowcomments tinyint(2) unsigned NOT NULL default '0',
timecreated int(10) unsigned NOT NULL default '0',
timemodified int(10) unsigned NOT NULL default '0',
PRIMARY KEY (id)
PRIMARY KEY (id)
) TYPE=MyISAM COMMENT='categories of each glossary entry';
+CREATE TABLE prefix_glossary_comments (
+ id int(10) unsigned NOT NULL auto_increment,
+ entryid int(10) unsigned NOT NULL default '0',
+ userid int(10) unsigned NOT NULL default '0',
+ comment text NOT NULL,
+ format tinyint(2) unsigned NOT NULL default '0',
+ timemodified int(10) unsigned NOT NULL default '0',
+
+ PRIMARY KEY (id)
+) TYPE=MyISAM COMMENT='comments on glossary entries';
+
#
# Dumping data for table `log_display`
#
INSERT INTO prefix_log_display VALUES ('glossary', 'add category', 'glossary', 'name');
INSERT INTO prefix_log_display VALUES ('glossary', 'update category', 'glossary', 'name');
INSERT INTO prefix_log_display VALUES ('glossary', 'delete category', 'glossary', 'name');
+INSERT INTO prefix_log_display VALUES ('glossary', 'add comment', 'glossary', 'name');
+INSERT INTO prefix_log_display VALUES ('glossary', 'update comment', 'glossary', 'name');
+INSERT INTO prefix_log_display VALUES ('glossary', 'delete comment', 'glossary', 'name');
showspecial int2 NOT NULL default '1',
showalphabet int2 NOT NULL default '1',
showall int2 NOT NULL default '1',
+ allowcomments int2 NOT NULL default '0',
timecreated int4 NOT NULL default '0',
timemodified int4 NOT NULL default '0',
PRIMARY KEY (id)
PRIMARY KEY (id)
);
+#
+# Table structure for table `glossary_comments`
+#
+
+CREATE TABLE prefix_glossary_comments (
+ id SERIAL,
+ entryid int4 NOT NULL default '0',
+ userid int4 NOT NULL default '0',
+ comment text NOT NULL,
+ format int2 NOT NULL default '0',
+ timemodified int4 NOT NULL default '0',
+ PRIMARY KEY (id)
+);
+
#
# Dumping data for table `log_display`
#
INSERT INTO prefix_log_display VALUES ('glossary', 'add category', 'glossary', 'name');
INSERT INTO prefix_log_display VALUES ('glossary', 'update category', 'glossary', 'name');
INSERT INTO prefix_log_display VALUES ('glossary', 'delete category', 'glossary', 'name');
-
+INSERT INTO prefix_log_display VALUES ('glossary', 'add comment', 'glossary', 'name');
+INSERT INTO prefix_log_display VALUES ('glossary', 'update comment', 'glossary', 'name');
+INSERT INTO prefix_log_display VALUES ('glossary', 'delete comment', 'glossary', 'name');
$isteacher = isteacher($course->id);
$ismainglossary = $glossary->mainglossary;
- if ($isteacher or $glossary->studentcanpost and $entry->userid == $USER->id) {
- echo "<p align=right>";
- // only teachers can export entries so check it out
- if ($isteacher and !$ismainglossary and !$importedentry) {
- $mainglossary = get_record("glossary","mainglossary",1,"course",$course->id);
- if ( $mainglossary ) { // if there is a main glossary defined, allow to export the current entry
-
+ echo "<table width=100% border=0><tr><td>";
+
+ $count = count_records("glossary_comments","entryid",$entry->id);
+ echo "<a href=\"comments.php?id=$cm->id&eid=$entry->id\">$count " . get_string("comments","glossary") . "</a>";
+ echo "</td><td align=\"right\">";
+ if ( $glossary->allowcomments ) {
+ echo "<a href=\"comment.php?id=$cm->id&eid=$entry->id\"><img alt=\"" . get_string("addcomment","glossary") . "\" src=\"comment.gif\" height=16 width=16 border=0></a> ";
+ }
+
+ if ($isteacher or $glossary->studentcanpost and $entry->userid == $USER->id) {
+ // only teachers can export entries so check it out
+
+ if ($isteacher and !$ismainglossary and !$importedentry) {
+ $mainglossary = get_record("glossary","mainglossary",1,"course",$course->id);
+ if ( $mainglossary ) { // if there is a main glossary defined, allow to export the current entry
+
echo "<a href=\"exportentry.php?id=$cm->id&entry=$entry->id¤tview=$currentview&cat=$cat\"><img alt=\"" . get_string("exporttomainglossary","glossary") . "\"src=\"export.gif\" height=11 width=11 border=0></a> ";
- }
- }
-
+ }
+ }
+
if ( $entry->sourceglossaryid ) {
$icon = "minus.gif"; // graphical metaphor (minus) for deleting an imported entry
} else {
$icon = "../../pix/t/delete.gif";
}
- // Exported entries can be updated/deleted only by teachers in the main glossary
+ // Exported entries can be updated/deleted only by teachers in the main glossary
if ( !$importedentry and ($isteacher or !$ismainglossary) ) {
echo "<a href=\"deleteentry.php?id=$cm->id&mode=delete&entry=$entry->id¤tview=$currentview&cat=$cat\"><img alt=\"" . get_string("delete") . "\"src=\"";
echo $icon;
} elseif ( $importedentry ) {
echo "<font size=-1>" . get_string("exportedentry","glossary") . "</font>";
}
- }
+ }
+ echo "</td></tr></table>";
}
function glossary_search_entries($searchterms, $glossary, $includedefinition) {
}
}
- if ( !$includedefinition ) {
- $definitionsearch = "0";
- }
+ if ( !$includedefinition ) {
+ $definitionsearch = "0";
+ }
$selectsql = "{$CFG->prefix}glossary_entries e,
{$CFG->prefix}glossary g $onlyvisibletable
$totalcount = count_records_sql("SELECT COUNT(*) FROM $selectsql");
- return get_records_sql("SELECT e.concept, e.definition, e.userid, e.timemodified, e.id, e.format FROM
+ return get_records_sql("SELECT e.concept, e.definition, e.userid, e.timemodified, e.id, e.format FROM
$selectsql ORDER BY e.concept ASC $limit");
}
echo "<a href=\"" . $data[$tabproccessed]->link . "\">";
}
- if ( !$data[$tabproccessed]->link ) {
- echo "<font color=\"$inactivefontcolor\">";
- }
+ if ( !$data[$tabproccessed]->link ) {
+ echo "<font color=\"$inactivefontcolor\">";
+ }
echo $data[$tabproccessed]->caption;
- if ( !$data[$tabproccessed]->link ) {
- echo "</font>";
- }
+ if ( !$data[$tabproccessed]->link ) {
+ echo "</font>";
+ }
if ($tabproccessed != $currenttab and $data[$tabproccessed]->link) {
echo "</a>";
echo "<a href=\"" . $data[$tabproccessed]->link . "\">";
}
- if ( !$data[$tabproccessed]->link ) {
- echo "<font color=\"$inactivefontcolor\">";
- }
+ if ( !$data[$tabproccessed]->link ) {
+ echo "<font color=\"$inactivefontcolor\">";
+ }
echo $data[$tabproccessed]->caption;
- if ( !$data[$tabproccessed]->link ) {
- echo "</font>";
- }
+ if ( !$data[$tabproccessed]->link ) {
+ echo "</font>";
+ }
if ($tabproccessed != $currenttab and $data[$tabproccessed]->link) {
echo "</a>";
}
}
+function glossary_print_comment($course, $cm, $glossary, $entry, $comment) {
+ global $THEME, $CFG, $USER;
+
+// if ($entry->timemarked < $entry->modified) {
+ $colour = $THEME->cellheading2;
+// } else {
+// $colour = $THEME->cellheading;
+// }
+
+ $user = get_record("user", "id", $comment->userid);
+ $strby = get_string("writtenby","glossary");
+
+ echo "<table class=\"generalbox\" BORDER=1 CELLSPACING=0 valign=top cellpadding=0 width=70% border=0><tr><td>";
+
+ echo "\n<TABLE width=\"100%\" BORDER=0 CELLSPACING=0 valign=top cellpadding=5><tr>";
+
+ echo "\n<TD BGCOLOR=\"$THEME->cellheading\" WIDTH=25% VALIGN=TOP align=right >";
+ 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><br>";
+ echo "</TD>";
+
+ echo "<TD NOWRAP valign=top WIDTH=75% BGCOLOR=\"$THEME->cellcontent\">";
+ if ($comment) {
+ echo format_text($comment->comment, $comment->format);
+ } else {
+ echo "<center>";
+ print_string("nocomment", "glossary");
+ echo "</center>";
+ }
+
+ echo "<p align=right>";
+ if ( (time() - $comment->timemodified < $CFG->maxeditingtime and $USER->id == $comment->userid) or isteacher($course->id) ) {
+ echo "<a href=\"comment.php?id=$cm->id&eid=$entry->id&cid=$comment->id&action=edit\"><img alt=\"" . get_string("edit") . "\" src=\"../../pix/t/edit.gif\" height=11 width=11 border=0></a> ";
+ }
+ if ( $USER->id == $comment->userid or isteacher($course->id) ) {
+ echo "<a href=\"comment.php?id=$cm->id&eid=$entry->id&cid=$comment->id&action=delete\"><img alt=\"" . get_string("delete") . "\" src=\"../../pix/t/delete.gif\" height=11 width=11 border=0></a>";
+ }
+ echo "</td>";
+
+ echo "</tr></TABLE>\n";
+
+ echo "</td></tr></table>";
+}
+
?>
</select> <?php helpbutton("allowduplicatedentries", get_string("allowduplicatedentries", "glossary"), "glossary") ?>
</TD>
</TR>
+<TR valign=top>
+ <TD align=right><P><B><?php echo get_string("allowcomments", "glossary") ?>:</B></P></TD>
+ <TD>
+ <select size="1" name="allowcomments">
+ <option value="1" <?php
+ if ( $form->allowcomments ) {
+ echo "selected";
+ }
+ ?>
+ ><?php echo get_string("yes") ?></option>
+ <option value="0" <?php
+ if ( !$form->allowcomments ) {
+ echo "selected";
+ }
+ ?>><?php echo get_string("no") ?>
+ </option>
+ </select> <?php helpbutton("allowcomments", get_string("allowcomments", "glossary"), "glossary") ?>
+ </TD>
+</TR>
<TR valign=top>
<td colspan=2><hr>
</tr>
$glossary->showspecial = backup_todb($info['MOD']['#']['SHOWSPECIAL']['0']['#']);
$glossary->showalphabet = backup_todb($info['MOD']['#']['SHOWALPHABET']['0']['#']);
$glossary->showall = backup_todb($info['MOD']['#']['SHOWALL']['0']['#']);
+ $glossary->allowcomments = backup_todb($info['MOD']['#']['ALLOWCOMMENTS']['0']['#']);
$glossary->timecreated = backup_todb($info['MOD']['#']['TIMECREATED']['0']['#']);
$glossary->timemodified = backup_todb($info['MOD']['#']['TIMEMODIFIED']['0']['#']);
$entry->timemodified = backup_todb($ent_info['#']['TIMEMODIFIED']['0']['#']);
$entry->teacherentry = backup_todb($ent_info['#']['TEACHERENTRY']['0']['#']);
-
//We have to recode the userid field
$user = backup_getid($restore->backup_unique_code,"user",$entry->userid);
if ($user) {
/// This fragment is called by moodle_needs_upgrading() and /admin/index.php
/////////////////////////////////////////////////////////////////////////////////
-$module->version = 2003101500; // The current module version (Date: YYYYMMDDXX)
+$module->version = 2003101501; // The current module version (Date: YYYYMMDDXX)
$module->cron = 0; // Period for cron to check this module (secs)
$release = "0.5 development"; // User-friendly version number