See Release Notes
Long Term Support Release
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 * Block displaying information about current logged-in user. 19 * 20 * This block can be used as anti cheating measure, you 21 * can easily check the logged-in user matches the person 22 * operating the computer. 23 * 24 * @package block_myprofile 25 * @copyright 2010 Remote-Learner.net 26 * @author Olav Jordan <olav.jordan@remote-learner.ca> 27 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 28 */ 29 30 defined('MOODLE_INTERNAL') || die(); 31 32 /** 33 * Displays the current user's profile information. 34 * 35 * @copyright 2010 Remote-Learner.net 36 * @author Olav Jordan <olav.jordan@remote-learner.ca> 37 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 38 */ 39 class block_myprofile extends block_base { 40 /** 41 * block initializations 42 */ 43 public function init() { 44 $this->title = get_string('pluginname', 'block_myprofile'); 45 } 46 47 /** 48 * block contents 49 * 50 * @return object 51 */ 52 public function get_content() { 53 54 if ($this->content !== NULL) { 55 return $this->content; 56 } 57 58 if (!isloggedin() or isguestuser()) { 59 // Only real users can access myprofile block. 60 return; 61 } 62 63 $renderable = new \block_myprofile\output\myprofile($this->config); 64 $renderer = $this->page->get_renderer('block_myprofile'); 65 66 $this->content = new stdClass(); 67 $this->content->text = $renderer->render($renderable); 68 $this->content->footer = ''; 69 70 return $this->content; 71 } 72 73 /** 74 * allow the block to have a configuration page 75 * 76 * @return boolean 77 */ 78 public function has_config() { 79 return false; 80 } 81 82 /** 83 * allow more than one instance of the block on a page 84 * 85 * @return boolean 86 */ 87 public function instance_allow_multiple() { 88 //allow more than one instance on a page 89 return false; 90 } 91 92 /** 93 * allow instances to have their own configuration 94 * 95 * @return boolean 96 */ 97 function instance_allow_config() { 98 //allow instances to have their own configuration 99 return false; 100 } 101 102 /** 103 * instance specialisations (must have instance allow config true) 104 * 105 */ 106 public function specialization() { 107 } 108 109 /** 110 * locations where block can be displayed 111 * 112 * @return array 113 */ 114 public function applicable_formats() { 115 return array('all'=>true); 116 } 117 118 /** 119 * post install configurations 120 * 121 */ 122 public function after_install() { 123 } 124 125 /** 126 * post delete configurations 127 * 128 */ 129 public function before_delete() { 130 } 131 132 /** 133 * Return the plugin config settings for external functions. 134 * 135 * @return stdClass the configs for both the block instance and plugin 136 * @since Moodle 3.8 137 */ 138 public function get_config_for_external() { 139 // Return all settings for all users since it is safe (no private keys, etc..). 140 $configs = !empty($this->config) ? $this->config : new stdClass(); 141 142 return (object) [ 143 'instance' => $configs, 144 'plugin' => new stdClass(), 145 ]; 146 } 147 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body