course, 'mainglossary',1); if ( ! $mainglossary ) { $PermissionGranted = 0; } } $context = get_context_instance(CONTEXT_MODULE, $cm->id); require_capability('mod/glossary:export', $context); 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'); print_header_simple(format_string($glossary->name), '', ''.$strglossaries.' -> '.format_string($glossary->name), '', '', true, '', navmenu($course, $cm)); if ( $PermissionGranted ) { $entry = get_record('glossary_entries', 'id', $entry); if ( !$confirm ) { echo '
'.$areyousure.'
'.format_string($mainglossary->name).'?',
'exportentry.php?id='.$id.'&mode='.$mode.'&hook='.$hook.'&entry='.$entry->id.'&confirm=1',
'view.php?id='.$cm->id.'&mode='.$mode.'&hook='.$hook);
} else {
if ( ! $mainglossary->allowduplicatedentries ) {
$dupentry = get_record('glossary_entries','glossaryid', $mainglossary->id, 'lower(concept)',moodle_strtolower(addslashes($entry->concept)));
if ( $dupentry ) {
$PermissionGranted = 0;
}
}
if ( $PermissionGranted ) {
$dbentry = new stdClass;
$dbentry->id = $entry->id;
$dbentry->glossaryid = $mainglossary->id;
$dbentry->sourceglossaryid = $glossary->id;
if (! update_record('glossary_entries', $dbentry)) {
error('Could not export the entry to the main glossary');
} else {
print_simple_box_start('center', '60%');
echo '
'.$entryexported.'
'; print_continue('view.php?id='.$cm->id.'&mode=entry&hook='.$entry->id); print_simple_box_end(); print_footer(); redirect('view.php?id='.$cm->id.'&mode=entry&hook='.$entry->id); die; } } else { print_simple_box_start('center', '60%', '#FFBBBB'); echo ''.$entryalreadyexist.'
'; echo ''; print_continue('view.php?id='.$cm->id.'&mode=entry&hook='.$entry->id); 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.'); print_continue('view.php?id='.$cm->id.'&mode=entry&hook='.$entry->id); print_simple_box_end(); } print_footer(); ?>