See Release Notes
Long Term Support Release
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 overview. 19 * 20 * @package block_myoverview 21 * @copyright 2018 Peter Dias 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 defined('MOODLE_INTERNAL') || die(); 26 27 /** 28 * Constants for the user preferences grouping options 29 */ 30 define('BLOCK_MYOVERVIEW_GROUPING_ALLINCLUDINGHIDDEN', 'allincludinghidden'); 31 define('BLOCK_MYOVERVIEW_GROUPING_ALL', 'all'); 32 define('BLOCK_MYOVERVIEW_GROUPING_INPROGRESS', 'inprogress'); 33 define('BLOCK_MYOVERVIEW_GROUPING_FUTURE', 'future'); 34 define('BLOCK_MYOVERVIEW_GROUPING_PAST', 'past'); 35 define('BLOCK_MYOVERVIEW_GROUPING_FAVOURITES', 'favourites'); 36 define('BLOCK_MYOVERVIEW_GROUPING_HIDDEN', 'hidden'); 37 define('BLOCK_MYOVERVIEW_GROUPING_CUSTOMFIELD', 'customfield'); 38 39 /** 40 * Allows selection of all courses without a value for the custom field. 41 */ 42 define('BLOCK_MYOVERVIEW_CUSTOMFIELD_EMPTY', -1); 43 44 /** 45 * Constants for the user preferences sorting options 46 * timeline 47 */ 48 define('BLOCK_MYOVERVIEW_SORTING_TITLE', 'title'); 49 define('BLOCK_MYOVERVIEW_SORTING_LASTACCESSED', 'lastaccessed'); 50 define('BLOCK_MYOVERVIEW_SORTING_SHORTNAME', 'shortname'); 51 52 /** 53 * Constants for the user preferences view options 54 */ 55 define('BLOCK_MYOVERVIEW_VIEW_CARD', 'card'); 56 define('BLOCK_MYOVERVIEW_VIEW_LIST', 'list'); 57 define('BLOCK_MYOVERVIEW_VIEW_SUMMARY', 'summary'); 58 59 /** 60 * Constants for the user paging preferences 61 */ 62 define('BLOCK_MYOVERVIEW_PAGING_12', 12); 63 define('BLOCK_MYOVERVIEW_PAGING_24', 24); 64 define('BLOCK_MYOVERVIEW_PAGING_48', 48); 65 define('BLOCK_MYOVERVIEW_PAGING_96', 96); 66 define('BLOCK_MYOVERVIEW_PAGING_ALL', 0); 67 68 /** 69 * Constants for the admin category display setting 70 */ 71 define('BLOCK_MYOVERVIEW_DISPLAY_CATEGORIES_ON', 'on'); 72 define('BLOCK_MYOVERVIEW_DISPLAY_CATEGORIES_OFF', 'off'); 73 74 /** 75 * Get the current user preferences that are available 76 * 77 * @return mixed Array representing current options along with defaults 78 */ 79 function block_myoverview_user_preferences() { 80 $preferences['block_myoverview_user_grouping_preference'] = array( 81 'null' => NULL_NOT_ALLOWED, 82 'default' => BLOCK_MYOVERVIEW_GROUPING_ALL, 83 'type' => PARAM_ALPHA, 84 'choices' => array( 85 BLOCK_MYOVERVIEW_GROUPING_ALLINCLUDINGHIDDEN, 86 BLOCK_MYOVERVIEW_GROUPING_ALL, 87 BLOCK_MYOVERVIEW_GROUPING_INPROGRESS, 88 BLOCK_MYOVERVIEW_GROUPING_FUTURE, 89 BLOCK_MYOVERVIEW_GROUPING_PAST, 90 BLOCK_MYOVERVIEW_GROUPING_FAVOURITES, 91 BLOCK_MYOVERVIEW_GROUPING_HIDDEN, 92 BLOCK_MYOVERVIEW_GROUPING_CUSTOMFIELD, 93 ) 94 ); 95 96 $preferences['block_myoverview_user_grouping_customfieldvalue_preference'] = [ 97 'null' => NULL_ALLOWED, 98 'default' => null, 99 'type' => PARAM_RAW, 100 ]; 101 102 $preferences['block_myoverview_user_sort_preference'] = array( 103 'null' => NULL_NOT_ALLOWED, 104 'default' => BLOCK_MYOVERVIEW_SORTING_TITLE, 105 'type' => PARAM_ALPHA, 106 'choices' => array( 107 BLOCK_MYOVERVIEW_SORTING_TITLE, 108 BLOCK_MYOVERVIEW_SORTING_LASTACCESSED, 109 BLOCK_MYOVERVIEW_SORTING_SHORTNAME 110 ) 111 ); 112 $preferences['block_myoverview_user_view_preference'] = array( 113 'null' => NULL_NOT_ALLOWED, 114 'default' => BLOCK_MYOVERVIEW_VIEW_CARD, 115 'type' => PARAM_ALPHA, 116 'choices' => array( 117 BLOCK_MYOVERVIEW_VIEW_CARD, 118 BLOCK_MYOVERVIEW_VIEW_LIST, 119 BLOCK_MYOVERVIEW_VIEW_SUMMARY 120 ) 121 ); 122 123 $preferences['/^block_myoverview_hidden_course_(\d)+$/'] = array( 124 'isregex' => true, 125 'choices' => array(0, 1), 126 'type' => PARAM_INT, 127 'null' => NULL_NOT_ALLOWED, 128 'default' => 'none' 129 ); 130 131 $preferences['block_myoverview_user_paging_preference'] = array( 132 'null' => NULL_NOT_ALLOWED, 133 'default' => BLOCK_MYOVERVIEW_PAGING_12, 134 'type' => PARAM_INT, 135 'choices' => array( 136 BLOCK_MYOVERVIEW_PAGING_12, 137 BLOCK_MYOVERVIEW_PAGING_24, 138 BLOCK_MYOVERVIEW_PAGING_48, 139 BLOCK_MYOVERVIEW_PAGING_96, 140 BLOCK_MYOVERVIEW_PAGING_ALL 141 ) 142 ); 143 144 return $preferences; 145 } 146 147 /** 148 * Pre-delete course hook to cleanup any records with references to the deleted course. 149 * 150 * @param stdClass $course The deleted course 151 */ 152 function block_myoverview_pre_course_delete(\stdClass $course) { 153 // Removing any favourited courses which have been created for users, for this course. 154 $service = \core_favourites\service_factory::get_service_for_component('core_course'); 155 $service->delete_favourites_by_type_and_item('courses', $course->id); 156 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body