| [ Index ] |
PHP Cross Reference of Moodle 1.9.3 [Build 15-Oct-2008] |
[Summary view] [Print] [Text view]
1 <?php // $Id: exportentry.php,v 1.30.2.1 2007/10/12 16:09:44 tjhunt Exp $ 2 require_once('../../config.php'); 3 require_once ('lib.php'); 4 5 $id = required_param('id', PARAM_INT); // course module ID 6 $entry = required_param('entry', PARAM_INT); // Entry ID 7 $confirm = optional_param('confirm', 0, PARAM_INT); // confirmation 8 9 $hook = optional_param('hook', '', PARAM_ALPHANUM); 10 $mode = optional_param('mode', '', PARAM_ALPHA); 11 12 global $USER, $CFG; 13 14 $PermissionGranted = 1; 15 16 $cm = get_coursemodule_from_id('glossary', $id); 17 if ( ! $cm ) { 18 $PermissionGranted = 0; 19 } else { 20 $mainglossary = get_record('glossary','course',$cm->course, 'mainglossary',1); 21 if ( ! $mainglossary ) { 22 $PermissionGranted = 0; 23 } 24 } 25 26 $context = get_context_instance(CONTEXT_MODULE, $cm->id); 27 require_capability('mod/glossary:export', $context); 28 29 if (! $course = get_record('course', 'id', $cm->course)) { 30 error('Course is misconfigured'); 31 } 32 33 if (! $glossary = get_record('glossary', 'id', $cm->instance)) { 34 error('Course module is incorrect'); 35 } 36 37 $strglossaries = get_string('modulenameplural', 'glossary'); 38 $entryalreadyexist = get_string('entryalreadyexist','glossary'); 39 $entryexported = get_string('entryexported','glossary'); 40 41 $navigation = build_navigation('', $cm); 42 print_header_simple(format_string($glossary->name), '', $navigation, '', '', true, '', navmenu($course, $cm)); 43 44 if ( $PermissionGranted ) { 45 $entry = get_record('glossary_entries', 'id', $entry); 46 47 if ( !$confirm ) { 48 echo '<div class="boxaligncenter">'; 49 $areyousure = get_string('areyousureexport','glossary'); 50 notice_yesno ('<h2>'.format_string($entry->concept).'</h2><p align="center">'.$areyousure.'<br /><b>'.format_string($mainglossary->name).'</b>?', 51 'exportentry.php?id='.$id.'&mode='.$mode.'&hook='.$hook.'&entry='.$entry->id.'&confirm=1', 52 'view.php?id='.$cm->id.'&mode='.$mode.'&hook='.$hook); 53 echo '</div>'; 54 } else { 55 if ( ! $mainglossary->allowduplicatedentries ) { 56 $dupentry = get_record('glossary_entries','glossaryid', $mainglossary->id, 'lower(concept)',moodle_strtolower(addslashes($entry->concept))); 57 if ( $dupentry ) { 58 $PermissionGranted = 0; 59 } 60 } 61 if ( $PermissionGranted ) { 62 63 $dbentry = new stdClass; 64 $dbentry->id = $entry->id; 65 $dbentry->glossaryid = $mainglossary->id; 66 $dbentry->sourceglossaryid = $glossary->id; 67 68 if (! update_record('glossary_entries', $dbentry)) { 69 error('Could not export the entry to the main glossary'); 70 } else { 71 print_simple_box_start('center', '60%'); 72 echo '<p align="center"><font size="3">'.$entryexported.'</font></p></font>'; 73 74 print_continue('view.php?id='.$cm->id.'&mode=entry&hook='.$entry->id); 75 print_simple_box_end(); 76 77 print_footer(); 78 79 redirect('view.php?id='.$cm->id.'&mode=entry&hook='.$entry->id); 80 die; 81 } 82 } else { 83 print_simple_box_start('center', '60%', '#FFBBBB'); 84 echo '<p align="center"><font size="3">'.$entryalreadyexist.'</font></p></font>'; 85 echo '<p align="center">'; 86 87 print_continue('view.php?id='.$cm->id.'&mode=entry&hook='.$entry->id); 88 89 print_simple_box_end(); 90 } 91 } 92 } else { 93 print_simple_box_start('center', '60%', '#FFBBBB'); 94 notice('A weird error was found while trying to export this entry. Operation cancelled.'); 95 96 print_continue('view.php?id='.$cm->id.'&mode=entry&hook='.$entry->id); 97 98 print_simple_box_end(); 99 } 100 101 print_footer(); 102 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Jan 14 11:33:29 2009 | Cross-referenced by PHPXref 0.7 |