Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 3.9.x will end* 10 May 2021 (12 months).
  • Bug fixes for security issues in 3.9.x will end* 8 May 2023 (36 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

Differences Between: [Versions 39 and 400] [Versions 39 and 401] [Versions 39 and 402] [Versions 39 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   * Library functions for timeline
  19   *
  20   * @package   block_timeline
  21   * @copyright 2018 Peter Dias
  22   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  defined('MOODLE_INTERNAL') || die();
  25  
  26  /**
  27   * Define constants to store the SORT user preference
  28   */
  29  define('BLOCK_TIMELINE_SORT_BY_DATES', 'sortbydates');
  30  define('BLOCK_TIMELINE_SORT_BY_COURSES', 'sortbycourses');
  31  
  32  /**
  33   * Define constants to store the FILTER user preference
  34   */
  35  define('BLOCK_TIMELINE_FILTER_BY_NONE', 'all');
  36  define('BLOCK_TIMELINE_FILTER_BY_OVERDUE', 'overdue');
  37  define('BLOCK_TIMELINE_FILTER_BY_7_DAYS', 'next7days');
  38  define('BLOCK_TIMELINE_FILTER_BY_30_DAYS', 'next30days');
  39  define('BLOCK_TIMELINE_FILTER_BY_3_MONTHS', 'next3months');
  40  define('BLOCK_TIMELINE_FILTER_BY_6_MONTHS', 'next6months');
  41  define('BLOCK_TIMELINE_ACTIVITIES_LIMIT_DEFAULT', 5);
  42  
  43  /**
  44   * Returns the name of the user preferences as well as the details this plugin uses.
  45   *
  46   * @return array
  47   */
  48  function block_timeline_user_preferences() {
  49      $preferences['block_timeline_user_sort_preference'] = array(
  50          'null' => NULL_NOT_ALLOWED,
  51          'default' => BLOCK_TIMELINE_SORT_BY_DATES,
  52          'type' => PARAM_ALPHA,
  53          'choices' => array(BLOCK_TIMELINE_SORT_BY_DATES, BLOCK_TIMELINE_SORT_BY_COURSES)
  54      );
  55  
  56      $preferences['block_timeline_user_filter_preference'] = array(
  57          'null' => NULL_NOT_ALLOWED,
  58          'default' => BLOCK_TIMELINE_FILTER_BY_30_DAYS,
  59          'type' => PARAM_ALPHANUM,
  60          'choices' => array(
  61                  BLOCK_TIMELINE_FILTER_BY_NONE,
  62                  BLOCK_TIMELINE_FILTER_BY_OVERDUE,
  63                  BLOCK_TIMELINE_FILTER_BY_7_DAYS,
  64                  BLOCK_TIMELINE_FILTER_BY_30_DAYS,
  65                  BLOCK_TIMELINE_FILTER_BY_3_MONTHS,
  66                  BLOCK_TIMELINE_FILTER_BY_6_MONTHS
  67          )
  68      );
  69  
  70      $preferences['block_timeline_user_limit_preference'] = array(
  71          'null' => NULL_NOT_ALLOWED,
  72          'default' => BLOCK_TIMELINE_ACTIVITIES_LIMIT_DEFAULT,
  73          'type' => PARAM_INT
  74      );
  75  
  76      return $preferences;
  77  }