Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.
/mod/data/ -> view.php (source)

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

   1  <?php
   2  // This file is part of Moodle - http://moodle.org/
   3  //
   4  // Moodle is free software: you can redistribute it and/or modify
   5  // it under the terms of the GNU General Public License as published by
   6  // the Free Software Foundation, either version 3 of the License, or
   7  // (at your option) any later version.
   8  //
   9  // Moodle is distributed in the hope that it will be useful,
  10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12  // GNU General Public License for more details.
  13  //
  14  // You should have received a copy of the GNU General Public License
  15  // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
  16  
  17  /**
  18   * This file is part of the Database module for Moodle
  19   *
  20   * @copyright 2005 Martin Dougiamas  http://dougiamas.com
  21   * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  22   * @package mod_data
  23   */
  24  
  25  use mod_data\manager;
  26  
  27  require_once(__DIR__ . '/../../config.php');
  28  require_once($CFG->dirroot . '/mod/data/locallib.php');
  29  require_once($CFG->libdir . '/rsslib.php');
  30  
  31  /// One of these is necessary!
  32  $id = optional_param('id', 0, PARAM_INT);  // course module id
  33  $d = optional_param('d', 0, PARAM_INT);   // database id
  34  $rid = optional_param('rid', 0, PARAM_INT);    //record id
  35  $mode = optional_param('mode', '', PARAM_ALPHA);    // Force the browse mode  ('single')
  36  $filter = optional_param('filter', 0, PARAM_BOOL);
  37  // search filter will only be applied when $filter is true
  38  
  39  $edit = optional_param('edit', -1, PARAM_BOOL);
  40  $page = optional_param('page', 0, PARAM_INT);
  41  /// These can be added to perform an action on a record
  42  $approve = optional_param('approve', 0, PARAM_INT);    //approval recordid
  43  $disapprove = optional_param('disapprove', 0, PARAM_INT);    // disapproval recordid
  44  $delete = optional_param('delete', 0, PARAM_INT);    //delete recordid
  45  $multidelete = optional_param_array('delcheck', null, PARAM_INT);
  46  $serialdelete = optional_param('serialdelete', null, PARAM_RAW);
  47  $confirm = optional_param('confirm', 0, PARAM_INT);
  48  
  49  $record = null;
  50  
  51  if ($id) {
  52      list($course, $cm) = get_course_and_cm_from_cmid($id, manager::MODULE);
  53      $manager = manager::create_from_coursemodule($cm);
  54  } else if ($rid) {
  55      $record = $DB->get_record('data_records', ['id' => $rid], '*', MUST_EXIST);
  56      $manager = manager::create_from_data_record($record);
  57      $cm = $manager->get_coursemodule();
  58      $course = get_course($cm->course);
  59  } else {   // We must have $d.
  60      $data = $DB->get_record('data', ['id' => $d], '*', MUST_EXIST);
  61      $manager = manager::create_from_instance($data);
  62      $cm = $manager->get_coursemodule();
  63      $course = get_course($cm->course);
  64  }
  65  
  66  $data = $manager->get_instance();
  67  $context = $manager->get_context();
  68  
  69  require_login($course, true, $cm);
  70  
  71  require_once($CFG->dirroot . '/comment/lib.php');
  72  comment::init();
  73  
  74  require_capability('mod/data:viewentry', $context);
  75  
  76  /// Check further parameters that set browsing preferences
  77  if (!isset($SESSION->dataprefs)) {
  78      $SESSION->dataprefs = array();
  79  }
  80  if (!isset($SESSION->dataprefs[$data->id])) {
  81      $SESSION->dataprefs[$data->id] = array();
  82      $SESSION->dataprefs[$data->id]['search'] = '';
  83      $SESSION->dataprefs[$data->id]['search_array'] = array();
  84      $SESSION->dataprefs[$data->id]['sort'] = $data->defaultsort;
  85      $SESSION->dataprefs[$data->id]['advanced'] = 0;
  86      $SESSION->dataprefs[$data->id]['order'] = ($data->defaultsortdir == 0) ? 'ASC' : 'DESC';
  87  }
  88  
  89  // reset advanced form
  90  if (!is_null(optional_param('resetadv', null, PARAM_RAW))) {
  91      $SESSION->dataprefs[$data->id]['search_array'] = array();
  92      // we need the redirect to cleanup the form state properly
  93      redirect("view.php?id=$cm->id&amp;mode=$mode&amp;search=&amp;advanced=1");
  94  }
  95  
  96  $advanced = optional_param('advanced', -1, PARAM_INT);
  97  if ($advanced == -1) {
  98      $advanced = $SESSION->dataprefs[$data->id]['advanced'];
  99  } else {
 100      if (!$advanced) {
 101          // explicitly switched to normal mode - discard all advanced search settings
 102          $SESSION->dataprefs[$data->id]['search_array'] = array();
 103      }
 104      $SESSION->dataprefs[$data->id]['advanced'] = $advanced;
 105  }
 106  
 107  $search_array = $SESSION->dataprefs[$data->id]['search_array'];
 108  
 109  if (!empty($advanced)) {
 110      $search = '';
 111  
 112      //Added to ammend paging error. This error would occur when attempting to go from one page of advanced
 113      //search results to another.  All fields were reset in the page transfer, and there was no way of determining
 114      //whether or not the user reset them.  This would cause a blank search to execute whenever the user attempted
 115      //to see any page of results past the first.
 116      //This fix works as follows:
 117      //$paging flag is set to false when page 0 of the advanced search results is viewed for the first time.
 118      //Viewing any page of results after page 0 passes the false $paging flag though the URL (see line 523) and the
 119      //execution falls through to the second condition below, allowing paging to be set to true.
 120      //Paging remains true and keeps getting passed though the URL until a new search is performed
 121      //(even if page 0 is revisited).
 122      //A false $paging flag generates advanced search results based on the fields input by the user.
 123      //A true $paging flag generates davanced search results from the $SESSION global.
 124  
 125      $paging = optional_param('paging', NULL, PARAM_BOOL);
 126      if($page == 0 && !isset($paging)) {
 127          $paging = false;
 128      }
 129      else {
 130          $paging = true;
 131      }
 132  
 133      // Now build the advanced search array.
 134      list($search_array, $search) = data_build_search_array($data, $paging, $search_array);
 135      $SESSION->dataprefs[$data->id]['search_array'] = $search_array;     // Make it sticky.
 136  
 137  } else {
 138      $search = optional_param('search', $SESSION->dataprefs[$data->id]['search'], PARAM_NOTAGS);
 139      //Paging variable not used for standard search. Set it to null.
 140      $paging = NULL;
 141  }
 142  
 143  // Disable search filters if $filter is not true:
 144  if (! $filter) {
 145      $search = '';
 146  }
 147  
 148  $SESSION->dataprefs[$data->id]['search'] = $search;   // Make it sticky
 149  
 150  $sort = optional_param('sort', $SESSION->dataprefs[$data->id]['sort'], PARAM_INT);
 151  $SESSION->dataprefs[$data->id]['sort'] = $sort;       // Make it sticky
 152  
 153  $order = (optional_param('order', $SESSION->dataprefs[$data->id]['order'], PARAM_ALPHA) == 'ASC') ? 'ASC': 'DESC';
 154  $SESSION->dataprefs[$data->id]['order'] = $order;     // Make it sticky
 155  
 156  
 157  $oldperpage = get_user_preferences('data_perpage_'.$data->id, 10);
 158  $perpage = optional_param('perpage', $oldperpage, PARAM_INT);
 159  
 160  if ($perpage < 2) {
 161      $perpage = 2;
 162  }
 163  if ($perpage != $oldperpage) {
 164      set_user_preference('data_perpage_'.$data->id, $perpage);
 165  }
 166  
 167  // Trigger module viewed event and completion.
 168  $manager->set_module_viewed($course);
 169  
 170  $urlparams = array('d' => $data->id);
 171  if ($record) {
 172      $urlparams['rid'] = $record->id;
 173  }
 174  if ($mode) {
 175      $urlparams['mode'] = $mode;
 176  }
 177  if ($page) {
 178      $urlparams['page'] = $page;
 179  }
 180  if ($filter) {
 181      $urlparams['filter'] = $filter;
 182  }
 183  $pageurl = new moodle_url('/mod/data/view.php', $urlparams);
 184  
 185  // Initialize $PAGE, compute blocks.
 186  $PAGE->set_url($pageurl);
 187  
 188  if (($edit != -1) and $PAGE->user_allowed_editing()) {
 189      $USER->editing = $edit;
 190  }
 191  
 192  $courseshortname = format_string($course->shortname, true, array('context' => context_course::instance($course->id)));
 193  
 194  /// RSS and CSS and JS meta
 195  $meta = '';
 196  if (!empty($CFG->enablerssfeeds) && !empty($CFG->data_enablerssfeeds) && $data->rssarticles > 0) {
 197      $rsstitle = $courseshortname . ': ' . format_string($data->name);
 198      rss_add_http_header($context, 'mod_data', $data, $rsstitle);
 199  }
 200  if ($data->csstemplate) {
 201      $PAGE->requires->css('/mod/data/css.php?d='.$data->id);
 202  }
 203  if ($data->jstemplate) {
 204      $PAGE->requires->js('/mod/data/js.php?d='.$data->id, true);
 205  }
 206  
 207  /// Print the page header
 208  // Note: MDL-19010 there will be further changes to printing header and blocks.
 209  // The code will be much nicer than this eventually.
 210  
 211  if ($PAGE->user_allowed_editing() && !$PAGE->theme->haseditswitch) {
 212      // Change URL parameter and block display string value depending on whether editing is enabled or not
 213      if ($PAGE->user_is_editing()) {
 214          $urlediting = 'off';
 215          $strediting = get_string('blockseditoff');
 216      } else {
 217          $urlediting = 'on';
 218          $strediting = get_string('blocksediton');
 219      }
 220      $editurl = new moodle_url($CFG->wwwroot.'/mod/data/view.php', ['id' => $cm->id, 'edit' => $urlediting]);
 221      $PAGE->set_button($OUTPUT->single_button($editurl, $strediting));
 222  }
 223  
 224  if ($mode == 'asearch') {
 225      $PAGE->navbar->add(get_string('search'));
 226  }
 227  
 228  $PAGE->add_body_class('mediumwidth');
 229  $titleparts = [
 230      format_string($data->name),
 231      format_string($course->fullname),
 232  ];
 233  if (!empty(trim($search))) {
 234      // Indicate search results on page title when searching.
 235      array_unshift($titleparts, get_string('searchresults', 'data', s($search)));
 236  } else if (!empty($delete) && empty($confirm)) {
 237      // Displaying the delete confirmation page.
 238      array_unshift($titleparts, get_string('deleteentry', 'data'));
 239  } else if ($record !== null || $mode == 'single') {
 240      // Indicate on the page tile if the user is viewing this page on single view mode.
 241      array_unshift($titleparts, get_string('single', 'data'));
 242  }
 243  $PAGE->set_title(implode(moodle_page::TITLE_SEPARATOR, $titleparts));
 244  $PAGE->set_heading($course->fullname);
 245  $PAGE->force_settings_menu(true);
 246  if ($delete && confirm_sesskey() && (data_user_can_manage_entry($delete, $data, $context))) {
 247      $PAGE->activityheader->disable();
 248  }
 249  
 250  // Check to see if groups are being used here.
 251  // We need the most up to date current group value. Make sure it is updated at this point.
 252  $currentgroup = groups_get_activity_group($cm, true);
 253  $groupmode = groups_get_activity_groupmode($cm);
 254  $canmanageentries = has_capability('mod/data:manageentries', $context);
 255  echo $OUTPUT->header();
 256  
 257  if (!$manager->has_fields()) {
 258      // It's a brand-new database. There are no fields.
 259      $renderer = $manager->get_renderer();
 260      echo $renderer->render_database_zero_state($manager);
 261      echo $OUTPUT->footer();
 262      // Don't check the rest of the options. There is no field, there is nothing else to work with.
 263      exit;
 264  }
 265  
 266  // Detect entries not approved yet and show hint instead of not found error.
 267  if ($record and !data_can_view_record($data, $record, $currentgroup, $canmanageentries)) {
 268      throw new \moodle_exception('notapprovederror', 'data');
 269  }
 270  
 271  // Do we need to show a link to the RSS feed for the records?
 272  //this links has been Settings (database activity administration) block
 273  /*if (!empty($CFG->enablerssfeeds) && !empty($CFG->data_enablerssfeeds) && $data->rssarticles > 0) {
 274      echo '<div style="float:right;">';
 275      rss_print_link($context->id, $USER->id, 'mod_data', $data->id, get_string('rsstype'));
 276      echo '</div>';
 277      echo '<div style="clear:both;"></div>';
 278  }*/
 279  
 280  if ($data->intro and empty($page) and empty($record) and $mode != 'single') {
 281      $options = new stdClass();
 282      $options->noclean = true;
 283  }
 284  
 285  /// Delete any requested records
 286  
 287  if ($delete && confirm_sesskey() && (data_user_can_manage_entry($delete, $data, $context))) {
 288      if ($confirm) {
 289          if (data_delete_record($delete, $data, $course->id, $cm->id)) {
 290              echo $OUTPUT->notification(get_string('recorddeleted','data'), 'notifysuccess');
 291          }
 292      } else {   // Print a confirmation page
 293          $userfieldsapi = \core_user\fields::for_userpic()->excluding('id');
 294          $allnamefields = $userfieldsapi->get_sql('u', false, '', '', false)->selects;
 295          $dbparams = array($delete);
 296          if ($deleterecord = $DB->get_record_sql("SELECT dr.*, $allnamefields
 297                                                     FROM {data_records} dr
 298                                                          JOIN {user} u ON dr.userid = u.id
 299                                                    WHERE dr.id = ?", $dbparams, MUST_EXIST)) { // Need to check this is valid.
 300              if ($deleterecord->dataid == $data->id) {                       // Must be from this database
 301                  echo $OUTPUT->heading(get_string('deleteentry', 'mod_data'), 2, 'mb-4');
 302                  $deletebutton = new single_button(new moodle_url('/mod/data/view.php?d='.$data->id.'&delete='.$delete.'&confirm=1'), get_string('delete'), 'post');
 303                  echo $OUTPUT->confirm(get_string('confirmdeleterecord','data'),
 304                          $deletebutton, 'view.php?d='.$data->id);
 305  
 306                  $records[] = $deleterecord;
 307                  $parser = $manager->get_template('singletemplate');
 308                  echo $parser->parse_entries($records);
 309  
 310                  echo $OUTPUT->footer();
 311                  exit;
 312              }
 313          }
 314      }
 315  }
 316  
 317  
 318  // Multi-delete.
 319  if ($serialdelete) {
 320      $multidelete = json_decode($serialdelete);
 321  }
 322  
 323  if ($multidelete && confirm_sesskey() && $canmanageentries) {
 324      if ($confirm = optional_param('confirm', 0, PARAM_INT)) {
 325          foreach ($multidelete as $value) {
 326              data_delete_record($value, $data, $course->id, $cm->id);
 327          }
 328      } else {
 329          $validrecords = array();
 330          $recordids = array();
 331          foreach ($multidelete as $value) {
 332              $userfieldsapi = \core_user\fields::for_userpic()->excluding('id');
 333              $allnamefields = $userfieldsapi->get_sql('u', false, '', '', false)->selects;
 334              $dbparams = array('id' => $value);
 335              if ($deleterecord = $DB->get_record_sql("SELECT dr.*, $allnamefields
 336                                                         FROM {data_records} dr
 337                                                         JOIN {user} u ON dr.userid = u.id
 338                                                        WHERE dr.id = ?", $dbparams)) { // Need to check this is valid.
 339                  if ($deleterecord->dataid == $data->id) {  // Must be from this database.
 340                      $validrecords[] = $deleterecord;
 341                      $recordids[] = $deleterecord->id;
 342                  }
 343              }
 344          }
 345          $serialiseddata = json_encode($recordids);
 346          $submitactions = array('d' => $data->id, 'sesskey' => sesskey(), 'confirm' => '1', 'serialdelete' => $serialiseddata);
 347          $action = new moodle_url('/mod/data/view.php', $submitactions);
 348          $cancelurl = new moodle_url('/mod/data/view.php', array('d' => $data->id));
 349          $deletebutton = new single_button($action, get_string('delete'));
 350          echo $OUTPUT->confirm(get_string('confirmdeleterecords', 'data'), $deletebutton, $cancelurl);
 351          $parser = $manager->get_template('listtemplate');
 352          echo $parser->parse_entries($validrecords);
 353          echo $OUTPUT->footer();
 354          exit;
 355      }
 356  }
 357  
 358  // If data activity closed dont let students in.
 359  // No need to display warnings because activity dates are displayed at the top of the page.
 360  list($showactivity, $warnings) = data_get_time_availability_status($data, $canmanageentries);
 361  
 362  if ($showactivity) {
 363  
 364      if ($mode == 'asearch') {
 365          $maxcount = 0;
 366          data_print_preference_form($data, $perpage, $search, $sort, $order, $search_array, $advanced, $mode);
 367  
 368      } else {
 369          // Approve or disapprove any requested records
 370          $approvecap = has_capability('mod/data:approve', $context);
 371  
 372          if (($approve || $disapprove) && confirm_sesskey() && $approvecap) {
 373              $newapproved = $approve ? true : false;
 374              $recordid = $newapproved ? $approve : $disapprove;
 375              if ($approverecord = $DB->get_record('data_records', array('id' => $recordid))) {   // Need to check this is valid
 376                  if ($approverecord->dataid == $data->id) {                       // Must be from this database
 377                      data_approve_entry($approverecord->id, $newapproved);
 378                      $msgkey = $newapproved ? 'recordapproved' : 'recorddisapproved';
 379                      echo $OUTPUT->notification(get_string($msgkey, 'data'), 'notifysuccess');
 380                  }
 381              }
 382          }
 383  
 384          $numentries = data_numentries($data);
 385      /// Check the number of entries required against the number of entries already made (doesn't apply to teachers)
 386          if ($data->entriesleft = data_get_entries_left_to_add($data, $numentries, $canmanageentries)) {
 387              $strentrieslefttoadd = get_string('entrieslefttoadd', 'data', $data);
 388              echo $OUTPUT->notification($strentrieslefttoadd);
 389          }
 390  
 391      /// Check the number of entries required before to view other participant's entries against the number of entries already made (doesn't apply to teachers)
 392          $requiredentries_allowed = true;
 393          if ($data->entrieslefttoview = data_get_entries_left_to_view($data, $numentries, $canmanageentries)) {
 394              $strentrieslefttoaddtoview = get_string('entrieslefttoaddtoview', 'data', $data);
 395              echo $OUTPUT->notification($strentrieslefttoaddtoview);
 396              $requiredentries_allowed = false;
 397          }
 398  
 399          if ($groupmode != NOGROUPS) {
 400              $returnurl = new moodle_url('/mod/data/view.php', ['d' => $data->id, 'mode' => $mode, 'search' => s($search),
 401                  'sort' => s($sort), 'order' => s($order)]);
 402              echo html_writer::div(groups_print_activity_menu($cm, $returnurl, true), 'mb-3');
 403          }
 404  
 405          // Search for entries.
 406          list($records, $maxcount, $totalcount, $page, $nowperpage, $sort, $mode) =
 407              data_search_entries($data, $cm, $context, $mode, $currentgroup, $search, $sort, $order, $page, $perpage, $advanced, $search_array, $record);
 408          $hasrecords = !empty($records);
 409  
 410          if ($maxcount == 0) {
 411              $renderer = $manager->get_renderer();
 412              echo $renderer->render_empty_database($manager);
 413              echo $OUTPUT->footer();
 414              // There is no entry, so makes no sense to check different views, pagination, etc.
 415              exit;
 416          }
 417  
 418          $actionbar = new \mod_data\output\action_bar($data->id, $pageurl);
 419          echo $actionbar->get_view_action_bar($hasrecords, $mode);
 420  
 421          // Advanced search form doesn't make sense for single (redirects list view).
 422          if ($maxcount && $mode != 'single') {
 423              data_print_preference_form($data, $perpage, $search, $sort, $order, $search_array, $advanced, $mode);
 424          }
 425  
 426          if (empty($records)) {
 427              if ($maxcount){
 428                  $a = new stdClass();
 429                  $a->max = $maxcount;
 430                  $a->reseturl = "view.php?id=$cm->id&amp;mode=$mode&amp;search=&amp;advanced=0";
 431                  echo $OUTPUT->box_start();
 432                  echo get_string('foundnorecords', 'data', $a);
 433                  echo $OUTPUT->box_end();
 434              } else {
 435                  echo $OUTPUT->box_start();
 436                  echo get_string('norecords', 'data');
 437                  echo $OUTPUT->box_end();
 438              }
 439  
 440          } else {
 441              //  We have some records to print.
 442              $formurl = new moodle_url('/mod/data/view.php', ['d' => $data->id, 'sesskey' => sesskey()]);
 443              echo html_writer::start_tag('form', ['action' => $formurl, 'method' => 'post']);
 444  
 445              if ($maxcount != $totalcount) {
 446                  $a = new stdClass();
 447                  $a->num = $totalcount;
 448                  $a->max = $maxcount;
 449                  $a->reseturl = "view.php?id=$cm->id&amp;mode=$mode&amp;search=&amp;advanced=0";
 450                  echo $OUTPUT->box_start();
 451                  echo get_string('foundrecords', 'data', $a);
 452                  echo $OUTPUT->box_end();
 453              }
 454  
 455              if ($mode == 'single') { // Single template
 456                  $baseurl = '/mod/data/view.php';
 457                  $baseurlparams = ['d' => $data->id, 'mode' => 'single'];
 458                  if (!empty($search)) {
 459                      $baseurlparams['filter'] = 1;
 460                  }
 461                  if (!empty($page)) {
 462                      $baseurlparams['page'] = $page;
 463                  }
 464                  $baseurl = new moodle_url($baseurl, $baseurlparams);
 465  
 466                  echo $OUTPUT->box_start('', 'data-singleview-content');
 467                  require_once($CFG->dirroot.'/rating/lib.php');
 468                  if ($data->assessed != RATING_AGGREGATE_NONE) {
 469                      $ratingoptions = new stdClass;
 470                      $ratingoptions->context = $context;
 471                      $ratingoptions->component = 'mod_data';
 472                      $ratingoptions->ratingarea = 'entry';
 473                      $ratingoptions->items = $records;
 474                      $ratingoptions->aggregate = $data->assessed;//the aggregation method
 475                      $ratingoptions->scaleid = $data->scale;
 476                      $ratingoptions->userid = $USER->id;
 477                      $ratingoptions->returnurl = $baseurl->out();
 478                      $ratingoptions->assesstimestart = $data->assesstimestart;
 479                      $ratingoptions->assesstimefinish = $data->assesstimefinish;
 480  
 481                      $rm = new rating_manager();
 482                      $records = $rm->get_ratings($ratingoptions);
 483                  }
 484  
 485                  $options = [
 486                      'search' => $search,
 487                      'page' => $page,
 488                      'baseurl' => $baseurl,
 489                  ];
 490                  $parser = $manager->get_template('singletemplate', $options);
 491                  echo $parser->parse_entries($records);
 492                  echo $OUTPUT->box_end();
 493              } else {
 494                  // List template.
 495                  $baseurl = '/mod/data/view.php';
 496                  $baseurlparams = ['d' => $data->id, 'advanced' => $advanced, 'paging' => $paging];
 497                  if (!empty($search)) {
 498                      $baseurlparams['filter'] = 1;
 499                  }
 500                  $baseurl = new moodle_url($baseurl, $baseurlparams);
 501  
 502                  echo $OUTPUT->box_start('', 'data-listview-content');
 503                  echo $data->listtemplateheader;
 504                  $options = [
 505                      'search' => $search,
 506                      'page' => $page,
 507                      'baseurl' => $baseurl,
 508                  ];
 509                  $parser = $manager->get_template('listtemplate', $options);
 510                  echo $parser->parse_entries($records);
 511  
 512                  echo $data->listtemplatefooter;
 513                  echo $OUTPUT->box_end();
 514              }
 515  
 516              $stickyfooter = new mod_data\output\view_footer(
 517                  $manager,
 518                  $totalcount,
 519                  $page,
 520                  $nowperpage,
 521                  $baseurl,
 522                  $parser
 523              );
 524              echo $OUTPUT->render($stickyfooter);
 525  
 526              echo html_writer::end_tag('form');
 527          }
 528      }
 529  
 530      $search = trim($search);
 531      if (empty($records)) {
 532          $records = array();
 533      }
 534  }
 535  
 536  echo $OUTPUT->footer();