mirror of
https://github.com/moodle/moodle.git
synced 2025-08-10 19:36:41 +02:00
mod-glossary MDL-19809 Added set_url calls, replaced deprecated functions
This commit is contained in:
parent
cd4e6b1769
commit
5fa0208ec3
16 changed files with 1954 additions and 1791 deletions
|
@ -1,112 +1,123 @@
|
|||
<?php // $Id$
|
||||
require_once('../../config.php');
|
||||
require_once('lib.php');
|
||||
<?php
|
||||
|
||||
$id = required_param('id', PARAM_INT); // Entry ID
|
||||
$confirm = optional_param('confirm', 0, PARAM_BOOL); // export confirmation
|
||||
$prevmode = required_param('prevmode', PARAM_ALPHA);
|
||||
$hook = optional_param('hook', '', PARAM_CLEAN);
|
||||
require_once('../../config.php');
|
||||
require_once('lib.php');
|
||||
|
||||
if (!$entry = $DB->get_record('glossary_entries', array('id'=>$id))) {
|
||||
print_error('invalidentry');
|
||||
}
|
||||
$id = required_param('id', PARAM_INT); // Entry ID
|
||||
$confirm = optional_param('confirm', 0, PARAM_BOOL); // export confirmation
|
||||
$prevmode = required_param('prevmode', PARAM_ALPHA);
|
||||
$hook = optional_param('hook', '', PARAM_CLEAN);
|
||||
|
||||
if ($entry->sourceglossaryid) {
|
||||
//already exported
|
||||
if (!$cm = get_coursemodule_from_id('glossary', $entry->sourceglossaryid)) {
|
||||
print_error('invalidcoursemodule');
|
||||
}
|
||||
redirect('view.php?id='.$cm->id.'&mode=entry&hook='.$entry->id);
|
||||
}
|
||||
$url = new moodle_url($CFG->wwwroot.'/mod/glossary/exportentry.php', array('id'=>$id,'prevmode'=>$prevmode));
|
||||
if ($confirm !== 0) {
|
||||
$url->param('confirm', $confirm);
|
||||
}
|
||||
if ($hook !== 'ALL') {
|
||||
$url->param('hook', $hook);
|
||||
}
|
||||
$PAGE->set_url($url);
|
||||
|
||||
if (!$cm = get_coursemodule_from_instance('glossary', $entry->glossaryid)) {
|
||||
if (!$entry = $DB->get_record('glossary_entries', array('id'=>$id))) {
|
||||
print_error('invalidentry');
|
||||
}
|
||||
|
||||
if ($entry->sourceglossaryid) {
|
||||
//already exported
|
||||
if (!$cm = get_coursemodule_from_id('glossary', $entry->sourceglossaryid)) {
|
||||
print_error('invalidcoursemodule');
|
||||
}
|
||||
redirect('view.php?id='.$cm->id.'&mode=entry&hook='.$entry->id);
|
||||
}
|
||||
|
||||
if (!$glossary = $DB->get_record('glossary', array('id'=>$cm->instance))) {
|
||||
print_error('invalidid', 'glossary');
|
||||
}
|
||||
if (!$cm = get_coursemodule_from_instance('glossary', $entry->glossaryid)) {
|
||||
print_error('invalidcoursemodule');
|
||||
}
|
||||
|
||||
if (!$course = $DB->get_record('course', array('id'=>$cm->course))) {
|
||||
print_error('coursemisconf');
|
||||
}
|
||||
if (!$glossary = $DB->get_record('glossary', array('id'=>$cm->instance))) {
|
||||
print_error('invalidid', 'glossary');
|
||||
}
|
||||
|
||||
require_course_login($course->id, true, $cm);
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
require_capability('mod/glossary:export', $context);
|
||||
if (!$course = $DB->get_record('course', array('id'=>$cm->course))) {
|
||||
print_error('coursemisconf');
|
||||
}
|
||||
|
||||
$returnurl = "view.php?id=$cm->id&mode=$prevmode&hook=".urlencode($hook);
|
||||
require_course_login($course->id, true, $cm);
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
require_capability('mod/glossary:export', $context);
|
||||
|
||||
if (!$mainglossary = $DB->get_record('glossary', array('course'=>$cm->course, 'mainglossary'=>1))) {
|
||||
//main glossary not present
|
||||
redirect($returnurl);
|
||||
}
|
||||
$returnurl = "view.php?id=$cm->id&mode=$prevmode&hook=".urlencode($hook);
|
||||
|
||||
if (!$maincm = get_coursemodule_from_instance('glossary', $mainglossary->id)) {
|
||||
print_error('invalidcoursemodule');
|
||||
}
|
||||
if (!$mainglossary = $DB->get_record('glossary', array('course'=>$cm->course, 'mainglossary'=>1))) {
|
||||
//main glossary not present
|
||||
redirect($returnurl);
|
||||
}
|
||||
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
$maincontext = get_context_instance(CONTEXT_MODULE, $maincm->id);
|
||||
if (!$maincm = get_coursemodule_from_instance('glossary', $mainglossary->id)) {
|
||||
print_error('invalidcoursemodule');
|
||||
}
|
||||
|
||||
if (!$course = $DB->get_record('course', array('id'=>$cm->course))) {
|
||||
print_error('coursemisconf');
|
||||
}
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
$maincontext = get_context_instance(CONTEXT_MODULE, $maincm->id);
|
||||
|
||||
if (!$course = $DB->get_record('course', array('id'=>$cm->course))) {
|
||||
print_error('coursemisconf');
|
||||
}
|
||||
|
||||
|
||||
$strglossaries = get_string('modulenameplural', 'glossary');
|
||||
$entryalreadyexist = get_string('entryalreadyexist','glossary');
|
||||
$entryexported = get_string('entryexported','glossary');
|
||||
$strglossaries = get_string('modulenameplural', 'glossary');
|
||||
$entryalreadyexist = get_string('entryalreadyexist','glossary');
|
||||
$entryexported = get_string('entryexported','glossary');
|
||||
|
||||
if (!$mainglossary->allowduplicatedentries) {
|
||||
if ($DB->get_record('glossary_entries', array('glossaryid'=>$mainglossary->id, 'lower(concept)'=>moodle_strtolower($entry->concept)))) {
|
||||
$PAGE->set_title(format_string($glossary->name));
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->notification(get_string('errconceptalreadyexists', 'glossary'));
|
||||
echo $OUTPUT->continue_button($returnurl);
|
||||
echo $OUTPUT->box_end();
|
||||
echo $OUTPUT->footer();
|
||||
die;
|
||||
}
|
||||
}
|
||||
|
||||
if (!data_submitted() or !$confirm or !confirm_sesskey()) {
|
||||
if (!$mainglossary->allowduplicatedentries) {
|
||||
if ($DB->get_record('glossary_entries', array('glossaryid'=>$mainglossary->id, 'lower(concept)'=>moodle_strtolower($entry->concept)))) {
|
||||
$PAGE->set_title(format_string($glossary->name));
|
||||
echo $OUTPUT->header();
|
||||
echo '<div class="boxaligncenter">';
|
||||
$areyousure = '<h2>'.format_string($entry->concept).'</h2><p align="center">'.get_string('areyousureexport','glossary').'<br /><b>'.format_string($mainglossary->name).'</b>?';
|
||||
$linkyes = 'exportentry.php';
|
||||
$linkno = 'view.php';
|
||||
$optionsyes = array('id'=>$entry->id, 'confirm'=>1, 'sesskey'=>sesskey(), 'prevmode'=>$prevmode, 'hook'=>$hook);
|
||||
$optionsno = array('id'=>$cm->id, 'mode'=>$prevmode, 'hook'=>$hook);
|
||||
|
||||
echo $OUTPUT->confirm($areyousure, new moodle_url($linkyes, $optionsyes), new moodle_url($linkno, $optionsno));
|
||||
echo '</div>';
|
||||
echo $OUTPUT->notification(get_string('errconceptalreadyexists', 'glossary'));
|
||||
echo $OUTPUT->continue_button($returnurl);
|
||||
echo $OUTPUT->box_end();
|
||||
echo $OUTPUT->footer();
|
||||
die;
|
||||
|
||||
} else {
|
||||
$entry->glossaryid = $mainglossary->id;
|
||||
$entry->sourceglossaryid = $glossary->id;
|
||||
|
||||
$DB->update_record('glossary_entries', $entry);
|
||||
|
||||
// move attachments too
|
||||
$fs = get_file_storage();
|
||||
|
||||
if ($oldfiles = $fs->get_area_files($context->id, 'glossary_attachment', $entry->id)) {
|
||||
foreach ($oldfiles as $oldfile) {
|
||||
$file_record = new object();
|
||||
$file_record->contextid = $maincontext->id;
|
||||
$fs->create_file_from_storedfile($file_record, $oldfile);
|
||||
}
|
||||
$fs->delete_area_files($context->id, 'glossary_attachment', $entry->id);
|
||||
$entry->attachment = '1';
|
||||
} else {
|
||||
$entry->attachment = '0';
|
||||
}
|
||||
$DB->update_record('glossary_entries', $entry);
|
||||
|
||||
redirect ($returnurl);
|
||||
}
|
||||
?>
|
||||
}
|
||||
|
||||
if (!data_submitted() or !$confirm or !confirm_sesskey()) {
|
||||
$PAGE->set_title(format_string($glossary->name));
|
||||
echo $OUTPUT->header();
|
||||
echo '<div class="boxaligncenter">';
|
||||
$areyousure = '<h2>'.format_string($entry->concept).'</h2><p align="center">'.get_string('areyousureexport','glossary').'<br /><b>'.format_string($mainglossary->name).'</b>?';
|
||||
$linkyes = 'exportentry.php';
|
||||
$linkno = 'view.php';
|
||||
$optionsyes = array('id'=>$entry->id, 'confirm'=>1, 'sesskey'=>sesskey(), 'prevmode'=>$prevmode, 'hook'=>$hook);
|
||||
$optionsno = array('id'=>$cm->id, 'mode'=>$prevmode, 'hook'=>$hook);
|
||||
|
||||
echo $OUTPUT->confirm($areyousure, new moodle_url($linkyes, $optionsyes), new moodle_url($linkno, $optionsno));
|
||||
echo '</div>';
|
||||
echo $OUTPUT->footer();
|
||||
die;
|
||||
|
||||
} else {
|
||||
$entry->glossaryid = $mainglossary->id;
|
||||
$entry->sourceglossaryid = $glossary->id;
|
||||
|
||||
$DB->update_record('glossary_entries', $entry);
|
||||
|
||||
// move attachments too
|
||||
$fs = get_file_storage();
|
||||
|
||||
if ($oldfiles = $fs->get_area_files($context->id, 'glossary_attachment', $entry->id)) {
|
||||
foreach ($oldfiles as $oldfile) {
|
||||
$file_record = new object();
|
||||
$file_record->contextid = $maincontext->id;
|
||||
$fs->create_file_from_storedfile($file_record, $oldfile);
|
||||
}
|
||||
$fs->delete_area_files($context->id, 'glossary_attachment', $entry->id);
|
||||
$entry->attachment = '1';
|
||||
} else {
|
||||
$entry->attachment = '0';
|
||||
}
|
||||
$DB->update_record('glossary_entries', $entry);
|
||||
|
||||
redirect ($returnurl);
|
||||
}
|
||||
|
||||
?>
|
Loading…
Add table
Add a link
Reference in a new issue