NOBUG: Change travis.yml to MOODLE_36_STABLE
[moodle.git] / blocks / myoverview / lib.php
blobed7334abeecdc47ffc6f66da3cd6dad4f70d7835
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.
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/>.
17 /**
18 * Library functions for overview.
20 * @package block_myoverview
21 * @copyright 2018 Peter Dias
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25 defined('MOODLE_INTERNAL') || die();
27 /**
28 * Constants for the user preferences grouping options
30 define('BLOCK_MYOVERVIEW_GROUPING_ALL', 'all');
31 define('BLOCK_MYOVERVIEW_GROUPING_INPROGRESS', 'inprogress');
32 define('BLOCK_MYOVERVIEW_GROUPING_FUTURE', 'future');
33 define('BLOCK_MYOVERVIEW_GROUPING_PAST', 'past');
34 define('BLOCK_MYOVERVIEW_GROUPING_FAVOURITES', 'favourites');
35 define('BLOCK_MYOVERVIEW_GROUPING_HIDDEN', 'hidden');
37 /**
38 * Constants for the user preferences sorting options
39 * timeline
41 define('BLOCK_MYOVERVIEW_SORTING_TITLE', 'title');
42 define('BLOCK_MYOVERVIEW_SORTING_LASTACCESSED', 'lastaccessed');
44 /**
45 * Constants for the user preferences view options
47 define('BLOCK_MYOVERVIEW_VIEW_CARD', 'cards');
48 define('BLOCK_MYOVERVIEW_VIEW_LIST', 'list');
49 define('BLOCK_MYOVERVIEW_VIEW_SUMMARY', 'summary');
51 /**
52 * Constants for the user paging preferences
54 define('BLOCK_MYOVERVIEW_PAGING_12', 12);
55 define('BLOCK_MYOVERVIEW_PAGING_24', 24);
56 define('BLOCK_MYOVERVIEW_PAGING_48', 48);
58 /**
59 * Get the current user preferences that are available
61 * @return mixed Array representing current options along with defaults
63 function block_myoverview_user_preferences() {
64 $preferences['block_myoverview_user_grouping_preference'] = array(
65 'null' => NULL_NOT_ALLOWED,
66 'default' => BLOCK_MYOVERVIEW_GROUPING_ALL,
67 'type' => PARAM_ALPHA,
68 'choices' => array(
69 BLOCK_MYOVERVIEW_GROUPING_ALL,
70 BLOCK_MYOVERVIEW_GROUPING_INPROGRESS,
71 BLOCK_MYOVERVIEW_GROUPING_FUTURE,
72 BLOCK_MYOVERVIEW_GROUPING_PAST,
73 BLOCK_MYOVERVIEW_GROUPING_FAVOURITES,
74 BLOCK_MYOVERVIEW_GROUPING_HIDDEN
77 $preferences['block_myoverview_user_sort_preference'] = array(
78 'null' => NULL_NOT_ALLOWED,
79 'default' => BLOCK_MYOVERVIEW_SORTING_TITLE,
80 'type' => PARAM_ALPHA,
81 'choices' => array(
82 BLOCK_MYOVERVIEW_SORTING_TITLE,
83 BLOCK_MYOVERVIEW_SORTING_LASTACCESSED
86 $preferences['block_myoverview_user_view_preference'] = array(
87 'null' => NULL_NOT_ALLOWED,
88 'default' => BLOCK_MYOVERVIEW_VIEW_CARD,
89 'type' => PARAM_ALPHA,
90 'choices' => array(
91 BLOCK_MYOVERVIEW_VIEW_CARD,
92 BLOCK_MYOVERVIEW_VIEW_LIST,
93 BLOCK_MYOVERVIEW_VIEW_SUMMARY
97 $preferences['/^block_myoverview_hidden_course_(\d)+$/'] = array(
98 'isregex' => true,
99 'choices' => array(0, 1),
100 'type' => PARAM_INT,
101 'null' => NULL_NOT_ALLOWED,
102 'default' => 'none'
105 $preferences['block_myoverview_user_paging_preference'] = array(
106 'null' => NULL_NOT_ALLOWED,
107 'default' => BLOCK_MYOVERVIEW_PAGING_12,
108 'type' => PARAM_INT,
109 'choices' => array(
110 BLOCK_MYOVERVIEW_PAGING_12,
111 BLOCK_MYOVERVIEW_PAGING_24,
112 BLOCK_MYOVERVIEW_PAGING_48
116 return $preferences;