Skip to content

Commit

Permalink
Now entries containing apostrophes can be exported to main glossay
Browse files Browse the repository at this point in the history
and deleted without problems. Bug 4136.
(http://moodle.org/bugs/bug.php?op=show&bugid=4136)

Merged from MOODLE_15_STABLE
  • Loading branch information
stronk7 committed Oct 5, 2005
1 parent 06b6ac3 commit d75584e
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 41 deletions.
8 changes: 5 additions & 3 deletions mod/glossary/deleteentry.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -64,9 +64,11 @@
// if it is an imported entry, just delete the relation // if it is an imported entry, just delete the relation


if ( $entry->sourceglossaryid ) { if ( $entry->sourceglossaryid ) {
$entry->glossaryid = $entry->sourceglossaryid; $dbentry = new stdClass;
$entry->sourceglossaryid = 0; $dbentry->id = $entry->id;
if (! update_record("glossary_entries", $entry)) { $dbentry->glossaryid = $entry->sourceglossaryid;
$dbentry->sourceglossaryid = 0;
if (! update_record('glossary_entries', $dbentry)) {
error("Could not update your glossary"); error("Could not update your glossary");
} }


Expand Down
78 changes: 40 additions & 38 deletions mod/glossary/exportentry.php
Original file line number Original file line Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php // $Id$ <?php // $Id$
require_once("../../config.php"); require_once('../../config.php');
require_once("lib.php"); require_once('lib.php');


require_variable($id); // course module ID require_variable($id); // course module ID
require_variable($entry); // Entry ID require_variable($entry); // Entry ID
Expand All @@ -13,11 +13,11 @@


$PermissionGranted = 1; $PermissionGranted = 1;


$cm = get_record("course_modules","id",$id); $cm = get_record('course_modules','id',$id);
if ( ! $cm ) { if ( ! $cm ) {
$PermissionGranted = 0; $PermissionGranted = 0;
} else { } else {
$mainglossary = get_record("glossary","course",$cm->course, "mainglossary",1); $mainglossary = get_record('glossary','course',$cm->course, 'mainglossary',1);
if ( ! $mainglossary ) { if ( ! $mainglossary ) {
$PermissionGranted = 0; $PermissionGranted = 0;
} }
Expand All @@ -31,77 +31,79 @@


if ( !isteacher($cm->course) ) { if ( !isteacher($cm->course) ) {
$PermissionGranted = 0; $PermissionGranted = 0;
error("You must be a teacher to use this page."); error('You must be a teacher to use this page.');
} }


if (! $course = get_record("course", "id", $cm->course)) { if (! $course = get_record('course', 'id', $cm->course)) {
error("Course is misconfigured"); error('Course is misconfigured');
} }


if (! $glossary = get_record("glossary", "id", $cm->instance)) { if (! $glossary = get_record('glossary', 'id', $cm->instance)) {
error("Course module is incorrect"); error('Course module is incorrect');
} }


$strglossaries = get_string("modulenameplural", "glossary"); $strglossaries = get_string('modulenameplural', 'glossary');
$entryalreadyexist = get_string("entryalreadyexist","glossary"); $entryalreadyexist = get_string('entryalreadyexist','glossary');
$entryexported = get_string("entryexported","glossary"); $entryexported = get_string('entryexported','glossary');


print_header_simple(format_string($glossary->name), "", print_header_simple(format_string($glossary->name), '',
"<a href=\"index.php?id=$course->id\">$strglossaries</a> -> ".format_string($glossary->name), '<a href="index.php?id='.$course->id.'">'.$strglossaries.'</a> -> '.format_string($glossary->name),
"", "", true, "", '', '', true, '',
navmenu($course, $cm)); navmenu($course, $cm));


if ( $PermissionGranted ) { if ( $PermissionGranted ) {
$entry = get_record("glossary_entries", "id", $entry); $entry = get_record('glossary_entries', 'id', $entry);


if ( !$confirm ) { if ( !$confirm ) {
echo "<center>"; echo '<center>';
$areyousure = get_string("areyousureexport","glossary"); $areyousure = get_string('areyousureexport','glossary');
notice_yesno ("<center><h2>$entry->concept</h2><p align=\"center\">$areyousure<br /><b>".format_string($mainglossary->name)."</b>?", notice_yesno ('<center><h2>'.$entry->concept.'</h2><p align="center">'.$areyousure.'<br /><b>'.format_string($mainglossary->name).'</b>?',
"exportentry.php?id=$id&amp;mode=$mode&amp;hook=$hook&amp;entry=$entry->id&amp;confirm=1", 'exportentry.php?id='.$id.'&amp;mode='.$mode.'&amp;hook='.$hook.'&amp;entry='.$entry->id.'&amp;confirm=1',
"view.php?id=$cm->id&amp;mode=$mode&amp;hook=$hook" ); 'view.php?id='.$cm->id.'&amp;mode='.$mode.'&amp;hook='.$hook);


} else { } else {
if ( ! $mainglossary->allowduplicatedentries ) { if ( ! $mainglossary->allowduplicatedentries ) {
$dupentry = get_record("glossary_entries","glossaryid", $mainglossary->id, "$ucase(concept)",strtoupper($entry->concept)); $dupentry = get_record('glossary_entries','glossaryid', $mainglossary->id, $ucase.'(concept)',strtoupper(addslashes($entry->concept)));
if ( $dupentry ) { if ( $dupentry ) {
$PermissionGranted = 0; $PermissionGranted = 0;
} }
} }
if ( $PermissionGranted ) { if ( $PermissionGranted ) {


$entry->glossaryid = $mainglossary->id; $dbentry = new stdClass;
$entry->sourceglossaryid = $glossary->id; $dbentry->id = $entry->id;
$dbentry->glossaryid = $mainglossary->id;
$dbentry->sourceglossaryid = $glossary->id;


if (! update_record("glossary_entries", $entry)) { if (! update_record('glossary_entries', $dbentry)) {
error("Could not export the entry to the main glossary"); error('Could not export the entry to the main glossary');
} else { } else {
print_simple_box_start("center", "60%"); print_simple_box_start('center', '60%');
echo "<p align=\"center\"><font size=\"3\">$entryexported</font></p></font>"; echo '<p align="center"><font size="3">'.$entryexported.'</font></p></font>';


print_continue("view.php?id=$cm->id&amp;mode=entry&amp;hook=".$entry->id); print_continue('view.php?id='.$cm->id.'&amp;mode=entry&amp;hook='.$entry->id);
print_simple_box_end(); print_simple_box_end();


print_footer(); print_footer();


redirect("view.php?id=$cm->id&amp;mode=entry&amp;hook=".$entry->id); redirect('view.php?id='.$cm->id.'&amp;mode=entry&amp;hook='.$entry->id);
die; die;
} }
} else { } else {
print_simple_box_start("center", "60%", "#FFBBBB"); print_simple_box_start('center', '60%', '#FFBBBB');
echo "<p align=\"center\"><font size=\"3\">$entryalreadyexist</font></p></font>"; echo '<p align="center"><font size="3">'.$entryalreadyexist.'</font></p></font>';
echo "<p align=\"center\">"; echo '<p align="center">';


print_continue("view.php?id=$cm->id&amp;mode=entry&amp;hook=".$entry->id); print_continue('view.php?id='.$cm->id.'&amp;mode=entry&amp;hook='.$entry->id);


print_simple_box_end(); print_simple_box_end();
} }
} }
} else { } else {
print_simple_box_start("center", "60%", "#FFBBBB"); print_simple_box_start('center', '60%', '#FFBBBB');
notice("A weird error was found while trying to export this entry. Operation cancelled."); notice('A weird error was found while trying to export this entry. Operation cancelled.');


print_continue("view.php?id=$cm->id&amp;mode=entry&amp;hook=".$entry->id); print_continue('view.php?id='.$cm->id.'&amp;mode=entry&amp;hook='.$entry->id);


print_simple_box_end(); print_simple_box_end();
} }
Expand Down

0 comments on commit d75584e

Please sign in to comment.