Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.
/my/ -> indexsys.php (source)

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

   1  <?php
   2  
   3  // This file is part of Moodle - http://moodle.org/
   4  //
   5  // Moodle is free software: you can redistribute it and/or modify
   6  // it under the terms of the GNU General Public License as published by
   7  // the Free Software Foundation, either version 3 of the License, or
   8  // (at your option) any later version.
   9  //
  10  // Moodle is distributed in the hope that it will be useful,
  11  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13  // GNU General Public License for more details.
  14  //
  15  // You should have received a copy of the GNU General Public License
  16  // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
  17  
  18  /**
  19   * My Moodle -- a user's personal dashboard
  20   *
  21   * - each user can currently have their own page (cloned from system and then customised)
  22   * - only the user can see their own dashboard
  23   * - users can add any blocks they want
  24   * - the administrators can define a default site dashboard for users who have
  25   *   not created their own dashboard
  26   *
  27   * This script implements the user's view of the dashboard, and allows editing
  28   * of the dashboard.
  29   *
  30   * @package    moodlecore
  31   * @subpackage my
  32   * @copyright  2010 Remote-Learner.net
  33   * @author     Hubert Chathi <hubert@remote-learner.net>
  34   * @author     Olav Jordan <olav.jordan@remote-learner.net>
  35   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  36   */
  37  
  38  define('NO_OUTPUT_BUFFERING', true);
  39  require_once(__DIR__ . '/../config.php');
  40  require_once($CFG->dirroot . '/my/lib.php');
  41  require_once($CFG->libdir.'/adminlib.php');
  42  
  43  $resetall = optional_param('resetall', false, PARAM_BOOL);
  44  
  45  $pagetitle = get_string('mypage', 'admin');
  46  
  47  $PAGE->set_secondary_active_tab('appearance');
  48  $PAGE->set_blocks_editing_capability('moodle/my:configsyspages');
  49  $PAGE->set_url(new moodle_url('/my/indexsys.php'));
  50  admin_externalpage_setup('mypage', '', null, '', array('pagelayout' => 'mydashboard'));
  51  $PAGE->add_body_class('limitedwidth');
  52  $PAGE->set_pagetype('my-index');
  53  $PAGE->blocks->add_region('content');
  54  $PAGE->set_title($pagetitle);
  55  $PAGE->set_heading($pagetitle);
  56  $PAGE->set_secondary_navigation(false);
  57  $PAGE->set_primary_active_tab('myhome');
  58  
  59  // If we are resetting all, just output a progress bar.
  60  if ($resetall && confirm_sesskey()) {
  61      echo $OUTPUT->header($pagetitle);
  62      echo $OUTPUT->heading(get_string('resettingdashboards', 'my'), 3);
  63  
  64      $progressbar = new progress_bar();
  65      $progressbar->create();
  66  
  67      \core\session\manager::write_close();
  68      my_reset_page_for_all_users(MY_PAGE_PRIVATE, 'my-index', $progressbar);
  69      core\notification::success(get_string('alldashboardswerereset', 'my'));
  70      echo $OUTPUT->continue_button($PAGE->url);
  71      echo $OUTPUT->footer();
  72      die();
  73  }
  74  
  75  // Get the My Moodle page info.  Should always return something unless the database is broken.
  76  if (!$currentpage = my_get_page(null, MY_PAGE_PRIVATE)) {
  77      print_error('mymoodlesetup');
  78  }
  79  $PAGE->set_subpage($currentpage->id);
  80  
  81  // Display a button to reset everyone's dashboard.
  82  $url = $PAGE->url;
  83  $url->params(['resetall' => true, 'sesskey' => sesskey()]);
  84  $button = $OUTPUT->single_button($url, get_string('reseteveryonesdashboard', 'my'));
  85  $PAGE->set_button($button . $PAGE->button);
  86  
  87  echo $OUTPUT->header();
  88  
  89  echo $OUTPUT->addblockbutton('content');
  90  
  91  echo $OUTPUT->custom_block_region('content');
  92  
  93  echo $OUTPUT->footer();