[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
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 global $CFG, $USER, $DB, $OUTPUT, $PAGE; 54 55 if ($this->content !== NULL) { 56 return $this->content; 57 } 58 59 if (!isloggedin() or isguestuser()) { 60 return ''; // Never useful unless you are logged in as real users 61 } 62 63 $this->content = new stdClass; 64 $this->content->text = ''; 65 $this->content->footer = ''; 66 67 $course = $this->page->course; 68 69 if (!isset($this->config->display_picture) || $this->config->display_picture == 1) { 70 $this->content->text .= '<div class="myprofileitem picture">'; 71 $this->content->text .= $OUTPUT->user_picture($USER, array('courseid'=>$course->id, 'size'=>'100', 'class'=>'profilepicture')); // The new class makes CSS easier 72 $this->content->text .= '</div>'; 73 } 74 75 $this->content->text .= '<div class="myprofileitem fullname">'.fullname($USER).'</div>'; 76 77 if(!isset($this->config->display_country) || $this->config->display_country == 1) { 78 $countries = get_string_manager()->get_list_of_countries(); 79 if (isset($countries[$USER->country])) { 80 $this->content->text .= '<div class="myprofileitem country">'; 81 $this->content->text .= get_string('country') . ': ' . $countries[$USER->country]; 82 $this->content->text .= '</div>'; 83 } 84 } 85 86 if(!isset($this->config->display_city) || $this->config->display_city == 1) { 87 $this->content->text .= '<div class="myprofileitem city">'; 88 $this->content->text .= get_string('city') . ': ' . format_string($USER->city); 89 $this->content->text .= '</div>'; 90 } 91 92 if(!isset($this->config->display_email) || $this->config->display_email == 1) { 93 $this->content->text .= '<div class="myprofileitem email">'; 94 $this->content->text .= obfuscate_mailto($USER->email, ''); 95 $this->content->text .= '</div>'; 96 } 97 98 if(!empty($this->config->display_icq) && !empty($USER->icq)) { 99 $this->content->text .= '<div class="myprofileitem icq">'; 100 $this->content->text .= 'ICQ: ' . s($USER->icq); 101 $this->content->text .= '</div>'; 102 } 103 104 if(!empty($this->config->display_skype) && !empty($USER->skype)) { 105 $this->content->text .= '<div class="myprofileitem skype">'; 106 $this->content->text .= 'Skype: ' . s($USER->skype); 107 $this->content->text .= '</div>'; 108 } 109 110 if(!empty($this->config->display_yahoo) && !empty($USER->yahoo)) { 111 $this->content->text .= '<div class="myprofileitem yahoo">'; 112 $this->content->text .= 'Yahoo: ' . s($USER->yahoo); 113 $this->content->text .= '</div>'; 114 } 115 116 if(!empty($this->config->display_aim) && !empty($USER->aim)) { 117 $this->content->text .= '<div class="myprofileitem aim">'; 118 $this->content->text .= 'AIM: ' . s($USER->aim); 119 $this->content->text .= '</div>'; 120 } 121 122 if(!empty($this->config->display_msn) && !empty($USER->msn)) { 123 $this->content->text .= '<div class="myprofileitem msn">'; 124 $this->content->text .= 'MSN: ' . s($USER->msn); 125 $this->content->text .= '</div>'; 126 } 127 128 if(!empty($this->config->display_phone1) && !empty($USER->phone1)) { 129 $this->content->text .= '<div class="myprofileitem phone1">'; 130 $this->content->text .= get_string('phone1').': ' . s($USER->phone1); 131 $this->content->text .= '</div>'; 132 } 133 134 if(!empty($this->config->display_phone2) && !empty($USER->phone2)) { 135 $this->content->text .= '<div class="myprofileitem phone2">'; 136 $this->content->text .= get_string('phone2').': ' . s($USER->phone2); 137 $this->content->text .= '</div>'; 138 } 139 140 if(!empty($this->config->display_institution) && !empty($USER->institution)) { 141 $this->content->text .= '<div class="myprofileitem institution">'; 142 $this->content->text .= format_string($USER->institution); 143 $this->content->text .= '</div>'; 144 } 145 146 if(!empty($this->config->display_address) && !empty($USER->address)) { 147 $this->content->text .= '<div class="myprofileitem address">'; 148 $this->content->text .= format_string($USER->address); 149 $this->content->text .= '</div>'; 150 } 151 152 if(!empty($this->config->display_firstaccess) && !empty($USER->firstaccess)) { 153 $this->content->text .= '<div class="myprofileitem firstaccess">'; 154 $this->content->text .= get_string('firstaccess').': ' . userdate($USER->firstaccess); 155 $this->content->text .= '</div>'; 156 } 157 158 if(!empty($this->config->display_lastaccess) && !empty($USER->lastaccess)) { 159 $this->content->text .= '<div class="myprofileitem lastaccess">'; 160 $this->content->text .= get_string('lastaccess').': ' . userdate($USER->lastaccess); 161 $this->content->text .= '</div>'; 162 } 163 164 if(!empty($this->config->display_currentlogin) && !empty($USER->currentlogin)) { 165 $this->content->text .= '<div class="myprofileitem currentlogin">'; 166 $this->content->text .= get_string('login').': ' . userdate($USER->currentlogin); 167 $this->content->text .= '</div>'; 168 } 169 170 if(!empty($this->config->display_lastip) && !empty($USER->lastip)) { 171 $this->content->text .= '<div class="myprofileitem lastip">'; 172 $this->content->text .= 'IP: ' . $USER->lastip; 173 $this->content->text .= '</div>'; 174 } 175 176 return $this->content; 177 } 178 179 /** 180 * allow the block to have a configuration page 181 * 182 * @return boolean 183 */ 184 public function has_config() { 185 return false; 186 } 187 188 /** 189 * allow more than one instance of the block on a page 190 * 191 * @return boolean 192 */ 193 public function instance_allow_multiple() { 194 //allow more than one instance on a page 195 return false; 196 } 197 198 /** 199 * allow instances to have their own configuration 200 * 201 * @return boolean 202 */ 203 function instance_allow_config() { 204 //allow instances to have their own configuration 205 return false; 206 } 207 208 /** 209 * instance specialisations (must have instance allow config true) 210 * 211 */ 212 public function specialization() { 213 } 214 215 /** 216 * locations where block can be displayed 217 * 218 * @return array 219 */ 220 public function applicable_formats() { 221 return array('all'=>true); 222 } 223 224 /** 225 * post install configurations 226 * 227 */ 228 public function after_install() { 229 } 230 231 /** 232 * post delete configurations 233 * 234 */ 235 public function before_delete() { 236 } 237 238 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |