Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403]

   1  <?php
   2  
   3  require_once("../../config.php");
   4  require_once ("lib.php");
   5  
   6  $id = required_param('id', PARAM_INT);      // Course Module ID
   7  
   8  $mode= optional_param('mode', '', PARAM_ALPHA);           // term entry cat date letter search author approval
   9  $hook= optional_param('hook', '', PARAM_CLEAN);           // the term, entry, cat, etc... to look for based on mode
  10  $cat = optional_param('cat',0, PARAM_ALPHANUM);
  11  
  12  $url = new moodle_url('/mod/glossary/export.php', array('id'=>$id));
  13  if ($cat !== 0) {
  14      $url->param('cat', $cat);
  15  }
  16  if ($mode !== '') {
  17      $url->param('mode', $mode);
  18  }
  19  
  20  $PAGE->set_url($url);
  21  
  22  if (! $cm = get_coursemodule_from_id('glossary', $id)) {
  23      print_error('invalidcoursemodule');
  24  }
  25  
  26  if (! $course = $DB->get_record("course", array("id"=>$cm->course))) {
  27      print_error('coursemisconf');
  28  }
  29  
  30  if (! $glossary = $DB->get_record("glossary", array("id"=>$cm->instance))) {
  31      print_error('invalidid', 'glossary');
  32  }
  33  
  34  require_login($course, false, $cm);
  35  
  36  $context = context_module::instance($cm->id);
  37  require_capability('mod/glossary:export', $context);
  38  
  39  $strglossaries = get_string("modulenameplural", "glossary");
  40  $strglossary = get_string("modulename", "glossary");
  41  $strallcategories = get_string("allcategories", "glossary");
  42  $straddentry = get_string("addentry", "glossary");
  43  $strnoentries = get_string("noentries", "glossary");
  44  $strsearchindefinition = get_string("searchindefinition", "glossary");
  45  $strsearch = get_string("search");
  46  $strexportfile = get_string("exportfile", "glossary");
  47  $strexportentries = get_string('exportentriestoxml', 'glossary');
  48  
  49  $PAGE->set_url('/mod/glossary/export.php', array('id'=>$cm->id));
  50  $PAGE->navbar->add($strexportentries);
  51  $PAGE->set_title($glossary->name);
  52  $PAGE->set_heading($course->fullname);
  53  
  54  echo $OUTPUT->header();
  55  echo $OUTPUT->heading($strexportentries);
  56  echo $OUTPUT->box_start('glossarydisplay generalbox');
  57  $exporturl = moodle_url::make_pluginfile_url($context->id, 'mod_glossary', 'export', 0, "/$cat/", 'export.xml', true);
  58  
  59  ?>
  60      <form action="<?php echo $exporturl->out(); ?>" method="post">
  61          <input class="btn btn-primary" type="submit" value="<?php p($strexportfile)?>" />
  62      </form>
  63  <?php
  64      // don't need cap check here, we share with the general export.
  65      if (!empty($CFG->enableportfolios) && $DB->count_records('glossary_entries', array('glossaryid' => $glossary->id))) {
  66          require_once($CFG->libdir . '/portfoliolib.php');
  67          $button = new portfolio_add_button();
  68          $button->set_callback_options('glossary_full_portfolio_caller', array('id' => $cm->id), 'mod_glossary');
  69          $button->render();
  70      }
  71      echo $OUTPUT->box_end();
  72      echo $OUTPUT->footer();
  73  ?>