2004-09-12 16:24:41 +00:00
|
|
|
<?php // $Id$
|
2004-08-21 20:20:58 +00:00
|
|
|
require_once("../../config.php");
|
|
|
|
require_once("lib.php");
|
|
|
|
|
2004-08-29 22:57:41 +00:00
|
|
|
require_variable($id); // course module ID
|
|
|
|
require_variable($entry); // Entry ID
|
|
|
|
optional_variable($confirm); // confirmation
|
|
|
|
optional_variable($mode);
|
|
|
|
optional_variable($hook);
|
|
|
|
|
|
|
|
$hook = strip_tags(urldecode($hook)); //XSS
|
|
|
|
$mode = strip_tags(urldecode($mode)); //XSS
|
2004-08-21 20:20:58 +00:00
|
|
|
|
2004-08-29 22:57:41 +00:00
|
|
|
global $THEME, $USER, $CFG;
|
2004-08-21 20:20:58 +00:00
|
|
|
|
|
|
|
$PermissionGranted = 1;
|
|
|
|
|
|
|
|
$cm = get_record("course_modules","id",$id);
|
|
|
|
if ( ! $cm ) {
|
|
|
|
$PermissionGranted = 0;
|
|
|
|
} else {
|
|
|
|
$mainglossary = get_record("glossary","course",$cm->course, "mainglossary",1);
|
|
|
|
if ( ! $mainglossary ) {
|
|
|
|
$PermissionGranted = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !isteacher($cm->course) ) {
|
|
|
|
$PermissionGranted = 0;
|
|
|
|
error("You must be a teacher to use this page.");
|
|
|
|
}
|
2003-09-16 03:07:21 +00:00
|
|
|
|
|
|
|
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");
|
|
|
|
}
|
|
|
|
|
|
|
|
$strglossaries = get_string("modulenameplural", "glossary");
|
|
|
|
$entryalreadyexist = get_string("entryalreadyexist","glossary");
|
|
|
|
$entryexported = get_string("entryexported","glossary");
|
|
|
|
|
2004-08-21 20:20:58 +00:00
|
|
|
print_header_simple("$glossary->name", "",
|
2004-09-12 16:24:41 +00:00
|
|
|
"<a href=\"index.php?id=$course->id\">$strglossaries</a> -> $glossary->name",
|
2003-09-16 03:07:21 +00:00
|
|
|
"", "", true, "",
|
|
|
|
navmenu($course, $cm));
|
|
|
|
|
2004-08-21 20:20:58 +00:00
|
|
|
if ( $PermissionGranted ) {
|
|
|
|
$entry = get_record("glossary_entries", "id", $entry);
|
2003-09-16 03:07:21 +00:00
|
|
|
|
2004-08-21 20:20:58 +00:00
|
|
|
if ( !$confirm ) {
|
|
|
|
echo "<center>";
|
2003-11-15 15:55:47 +00:00
|
|
|
$areyousure = get_string("areyousureexport","glossary");
|
2004-09-12 16:24:41 +00:00
|
|
|
notice_yesno ("<center><h2>$entry->concept</h2><p align=\"center\">$areyousure<br /><b>$mainglossary->name</b>?",
|
2004-09-16 17:13:57 +00:00
|
|
|
"exportentry.php?id=$id&mode=$mode&hook=$hook&entry=$entry->id&confirm=1",
|
|
|
|
"view.php?id=$cm->id&mode=$mode&hook=$hook" );
|
2004-08-21 20:20:58 +00:00
|
|
|
|
|
|
|
} else {
|
|
|
|
if ( ! $mainglossary->allowduplicatedentries ) {
|
|
|
|
$dupentry = get_record("glossary_entries","glossaryid", $mainglossary->id, "UCASE(concept)",strtoupper($entry->concept));
|
|
|
|
if ( $dupentry ) {
|
|
|
|
$PermissionGranted = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( $PermissionGranted ) {
|
|
|
|
|
2003-09-29 03:06:30 +00:00
|
|
|
$entry->glossaryid = $mainglossary->id;
|
|
|
|
$entry->sourceglossaryid = $glossary->id;
|
|
|
|
|
|
|
|
if (! update_record("glossary_entries", $entry)) {
|
2004-08-21 20:20:58 +00:00
|
|
|
error("Could not export the entry to the main glossary");
|
|
|
|
} else {
|
2003-09-29 03:06:30 +00:00
|
|
|
print_simple_box_start("center", "60%", "$THEME->cellheading");
|
2004-09-12 16:24:41 +00:00
|
|
|
echo "<p align=\"center\"><font size=\"3\">$entryexported</font></p></font>";
|
2003-09-29 03:06:30 +00:00
|
|
|
|
2004-09-16 17:13:57 +00:00
|
|
|
print_continue("view.php?id=$cm->id&mode=entry&hook=".$entry->id);
|
2003-09-29 03:06:30 +00:00
|
|
|
print_simple_box_end();
|
|
|
|
|
2004-08-21 20:20:58 +00:00
|
|
|
print_footer();
|
2003-09-29 03:06:30 +00:00
|
|
|
|
2004-09-16 17:13:57 +00:00
|
|
|
redirect("view.php?id=$cm->id&mode=entry&hook=".$entry->id);
|
2004-08-21 20:20:58 +00:00
|
|
|
die;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
print_simple_box_start("center", "60%", "#FFBBBB");
|
2004-09-12 16:24:41 +00:00
|
|
|
echo "<p align=\"center\"><font size=\"3\">$entryalreadyexist</font></p></font>";
|
|
|
|
echo "<p align=\"center\">";
|
2003-09-16 03:07:21 +00:00
|
|
|
|
2004-09-16 17:13:57 +00:00
|
|
|
print_continue("view.php?id=$cm->id&mode=entry&hook=".$entry->id);
|
2003-09-16 03:07:21 +00:00
|
|
|
|
2004-08-21 20:20:58 +00:00
|
|
|
print_simple_box_end();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
print_simple_box_start("center", "60%", "#FFBBBB");
|
|
|
|
notice("A weird error was found while trying to export this entry. Operation cancelled.");
|
2003-09-16 03:07:21 +00:00
|
|
|
|
2004-09-16 17:13:57 +00:00
|
|
|
print_continue("view.php?id=$cm->id&mode=entry&hook=".$entry->id);
|
2003-09-16 03:07:21 +00:00
|
|
|
|
2004-08-21 20:20:58 +00:00
|
|
|
print_simple_box_end();
|
|
|
|
}
|
2003-09-16 03:07:21 +00:00
|
|
|
|
2004-08-21 20:20:58 +00:00
|
|
|
print_footer();
|
2003-09-16 18:51:40 +00:00
|
|
|
?>
|