/** * Get a list of fields to be displayed in lists of users, etc. * * The input of the function is a user record; * possibly null, in this case the function should return only the field titles. * * The function returns an array of objects that describe user data fields. * Each of these objects has the following properties: * $field->title : Displayable title of the field * $field->value : Value of the field for this user (not set if $user is null) * * @param stdClass $user the user record; may be null * @return array an array of field objects */ function scheduler_get_user_fields($user) { $fields = array(); $emailfield = new stdClass(); $fields[] = $emailfield; $emailfield->title = get_string('email'); if ($user) { $emailfield->value = obfuscate_mailto($user->email); } /* * As an example: Uncomment the following lines in order to display the user's city and country. */ /* $cityfield = new stdClass(); $cityfield->title = get_string('city'); $fields[] = $cityfield; $countryfield = new stdClass(); $countryfield->title = get_string('country'); $fields[] = $countryfield; if ($user) { $cityfield->value = $user->city; if ($user->country) { $countryfield->value = get_string($user->country, 'countries'); } else { $countryfield->value = ''; } } */ return $fields; }
print_row(get_string("phone") . ":", "{$user->phone1}"); } if (isset($identityfields['phone2']) && $user->phone2) { print_row(get_string("phone2") . ":", "{$user->phone2}"); } if (isset($identityfields['institution']) && $user->institution) { print_row(get_string("institution") . ":", "{$user->institution}"); } if (isset($identityfields['department']) && $user->department) { print_row(get_string("department") . ":", "{$user->department}"); } if (isset($identityfields['idnumber']) && $user->idnumber) { print_row(get_string("idnumber") . ":", "{$user->idnumber}"); } if (isset($identityfields['email']) and ($currentuser or $user->maildisplay == 1 or has_capability('moodle/course:useremail', $context) or $user->maildisplay == 2 and enrol_sharing_course($user, $USER))) { print_row(get_string("email") . ":", obfuscate_mailto($user->email, '')); } if ($user->url && !isset($hiddenfields['webpage'])) { $url = $user->url; if (strpos($user->url, '://') === false) { $url = 'http://' . $url; } print_row(get_string("webpage") . ":", '<a href="' . s($url) . '">' . s($user->url) . '</a>'); } if ($user->icq && !isset($hiddenfields['icqnumber'])) { print_row(get_string('icqnumber') . ':', "<a href=\"http://web.icq.com/wwp?uin=" . urlencode($user->icq) . "\">" . s($user->icq) . " <img src=\"http://web.icq.com/whitepages/online?icq=" . urlencode($user->icq) . "&img=5\" alt=\"\" /></a>"); } if ($user->skype && !isset($hiddenfields['skypeid'])) { if (strpos($CFG->httpswwwroot, 'https:') === 0) { // Bad luck, skype devs are lazy to set up SSL on their servers - see MDL-37233. $statusicon = '';
} $options = array('overflowdiv' => true); echo format_text($user->description, $user->descriptionformat, $options); } } echo '</div>'; // Print all the little details in a list echo html_writer::start_tag('dl', array('class' => 'list')); // Show email if any of the following conditions match. // 1. User is viewing his own profile. // 2. Has allowed everyone to see email // 3. User has allowed course members to can see email and current user is in same course // 4. Has either course:viewhiddenuserfields or site:viewuseridentity capability. if ($currentuser or $user->maildisplay == 1 or $user->maildisplay == 2 && is_enrolled($coursecontext, $USER) or has_capability('moodle/course:viewhiddenuserfields', $coursecontext) or has_capability('moodle/site:viewuseridentity', $coursecontext)) { echo html_writer::tag('dt', get_string('email')); echo html_writer::tag('dd', obfuscate_mailto($user->email, '')); } // Show last time this user accessed this course if (!isset($hiddenfields['lastaccess'])) { if ($lastaccess = $DB->get_record('user_lastaccess', array('userid' => $user->id, 'courseid' => $course->id))) { $datestring = userdate($lastaccess->timeaccess) . " (" . format_time(time() - $lastaccess->timeaccess) . ")"; } else { $datestring = get_string("never"); } echo html_writer::tag('dt', get_string('lastcourseaccess')); echo html_writer::tag('dd', $datestring); } // Show roles in this course if ($rolestring = get_user_roles_in_course($id, $course->id)) { echo html_writer::tag('dt', get_string('roles')); echo html_writer::tag('dd', $rolestring);
protected function render_external_badge(external_badge $ibadge) { $issued = $ibadge->issued; $assertion = $issued->assertion; $issuer = $assertion->badge->issuer; $userinfo = $ibadge->recipient; $table = new html_table(); $imagetable = new html_table(); $imagetable->attributes = array('class' => 'clearfix badgeissuedimage'); $imagetable->data[] = array(html_writer::empty_tag('img', array('src' => $issued->imageUrl, 'width' => '100px'))); $datatable = new html_table(); $datatable->attributes = array('class' => 'badgeissuedinfo'); $datatable->colclasses = array('bfield', 'bvalue'); // Recipient information. $datatable->data[] = array($this->output->heading(get_string('recipientdetails', 'badges'), 3), ''); // Technically, we should alway have a user at this point, but added an extra check just in case. if ($userinfo) { $notify = ''; if (!$ibadge->valid) { $notify = $this->output->notification(get_string('recipientvalidationproblem', 'badges'), 'notifynotice'); } $datatable->data[] = array(get_string('name'), fullname($userinfo) . $notify); } else { $notify = $this->output->notification(get_string('recipientidentificationproblem', 'badges'), 'notifynotice'); $datatable->data[] = array(get_string('name'), $notify); } $datatable->data[] = array($this->output->heading(get_string('issuerdetails', 'badges'), 3), ''); $datatable->data[] = array(get_string('issuername', 'badges'), s($issuer->name)); $datatable->data[] = array(get_string('issuerurl', 'badges'), html_writer::tag('a', s($issuer->origin), array('href' => $issuer->origin))); if (isset($issuer->contact)) { $datatable->data[] = array(get_string('contact', 'badges'), obfuscate_mailto($issuer->contact)); } $datatable->data[] = array($this->output->heading(get_string('badgedetails', 'badges'), 3), ''); $datatable->data[] = array(get_string('name'), s($assertion->badge->name)); $datatable->data[] = array(get_string('description', 'badges'), s($assertion->badge->description)); $datatable->data[] = array(get_string('bcriteria', 'badges'), html_writer::tag('a', s($assertion->badge->criteria), array('href' => $assertion->badge->criteria))); $datatable->data[] = array($this->output->heading(get_string('issuancedetails', 'badges'), 3), ''); if (isset($assertion->issued_on)) { $issuedate = !strtotime($assertion->issued_on) ? s($assertion->issued_on) : strtotime($assertion->issued_on); $datatable->data[] = array(get_string('dateawarded', 'badges'), userdate($issuedate)); } if (isset($assertion->expires)) { $today_date = date('Y-m-d'); $today = strtotime($today_date); $expiration = !strtotime($assertion->expires) ? s($assertion->expires) : strtotime($assertion->expires); if ($expiration < $today) { $cell = new html_table_cell(userdate($expiration) . get_string('warnexpired', 'badges')); $cell->attributes = array('class' => 'notifyproblem warning'); $datatable->data[] = array(get_string('expirydate', 'badges'), $cell); $image = html_writer::start_tag('div', array('class' => 'badge')); $image .= html_writer::empty_tag('img', array('src' => $issued->imageUrl)); $image .= html_writer::start_tag('span', array('class' => 'expired')) . $this->output->pix_icon('i/expired', get_string('expireddate', 'badges', userdate($expiration)), 'moodle', array('class' => 'expireimage')) . html_writer::end_tag('span'); $image .= html_writer::end_tag('div'); $imagetable->data[0] = array($image); } else { $datatable->data[] = array(get_string('expirydate', 'badges'), userdate($expiration)); } } if (isset($assertion->evidence)) { $datatable->data[] = array(get_string('evidence', 'badges'), html_writer::tag('a', s($assertion->evidence), array('href' => $assertion->evidence))); } $table->attributes = array('class' => 'generalbox boxaligncenter issuedbadgebox'); $table->data[] = array(html_writer::table($imagetable), html_writer::table($datatable)); $htmlbadge = html_writer::table($table); return $htmlbadge; }
protected function render_external_badge(external_badge $ibadge) { $issued = $ibadge->issued; $assertion = $issued->assertion; $issuer = $assertion->badge->issuer; $userinfo = $ibadge->recipient; $table = new html_table(); $today = strtotime(date('Y-m-d')); $output = ''; $output .= html_writer::start_tag('div', array('id' => 'badge')); $output .= html_writer::start_tag('div', array('id' => 'badge-image')); $output .= html_writer::empty_tag('img', array('src' => $issued->imageUrl)); if (isset($assertion->expires)) { $expiration = !strtotime($assertion->expires) ? s($assertion->expires) : strtotime($assertion->expires); if ($expiration < $today) { $output .= $this->output->pix_icon('i/expired', get_string('expireddate', 'badges', userdate($expiration)), 'moodle', array('class' => 'expireimage')); } } $output .= html_writer::end_tag('div'); $output .= html_writer::start_tag('div', array('id' => 'badge-details')); // Recipient information. $output .= $this->output->heading(get_string('recipientdetails', 'badges'), 3); $dl = array(); // Technically, we should alway have a user at this point, but added an extra check just in case. if ($userinfo) { if (!$ibadge->valid) { $notify = $this->output->notification(get_string('recipientvalidationproblem', 'badges'), 'notifynotice'); $dl[get_string('name')] = fullname($userinfo) . $notify; } else { $dl[get_string('name')] = fullname($userinfo); } } else { $notify = $this->output->notification(get_string('recipientidentificationproblem', 'badges'), 'notifynotice'); $dl[get_string('name')] = $notify; } $output .= $this->definition_list($dl); $output .= $this->output->heading(get_string('issuerdetails', 'badges'), 3); $dl = array(); $dl[get_string('issuername', 'badges')] = s($issuer->name); $dl[get_string('issuerurl', 'badges')] = html_writer::tag('a', $issuer->origin, array('href' => $issuer->origin)); if (isset($issuer->contact)) { $dl[get_string('contact', 'badges')] = obfuscate_mailto($issuer->contact); } $output .= $this->definition_list($dl); $output .= $this->output->heading(get_string('badgedetails', 'badges'), 3); $dl = array(); $dl[get_string('name')] = s($assertion->badge->name); $dl[get_string('description', 'badges')] = s($assertion->badge->description); $dl[get_string('bcriteria', 'badges')] = html_writer::tag('a', s($assertion->badge->criteria), array('href' => $assertion->badge->criteria)); $output .= $this->definition_list($dl); $output .= $this->output->heading(get_string('issuancedetails', 'badges'), 3); $dl = array(); if (isset($assertion->issued_on)) { $issuedate = !strtotime($assertion->issued_on) ? s($assertion->issued_on) : strtotime($assertion->issued_on); $dl[get_string('dateawarded', 'badges')] = userdate($issuedate); } if (isset($assertion->expires)) { if ($expiration < $today) { $dl[get_string('expirydate', 'badges')] = userdate($expiration) . get_string('warnexpired', 'badges'); } else { $dl[get_string('expirydate', 'badges')] = userdate($expiration); } } if (isset($assertion->evidence)) { $dl[get_string('evidence', 'badges')] = html_writer::tag('a', s($assertion->evidence), array('href' => $assertion->evidence)); } $output .= $this->definition_list($dl); $output .= html_writer::end_tag('div'); return $output; }
/** * Defines core nodes for my profile navigation tree. * * @param \core_user\output\myprofile\tree $tree Tree object * @param stdClass $user user object * @param bool $iscurrentuser is the user viewing profile, current user ? * @param stdClass $course course object * * @return bool */ function core_myprofile_navigation(core_user\output\myprofile\tree $tree, $user, $iscurrentuser, $course) { global $CFG, $USER, $DB; $usercontext = context_user::instance($user->id, MUST_EXIST); $systemcontext = context_system::instance(); $context = !empty($course) ? context_course::instance($course->id) : $systemcontext; $courseid = !empty($course) ? $course->id : SITEID; $contactcategory = new core_user\output\myprofile\category('contact', get_string('userdetails')); $coursedetailscategory = new core_user\output\myprofile\category('coursedetails', get_string('coursedetails'), 'contact'); $miscategory = new core_user\output\myprofile\category('miscellaneous', get_string('miscellaneous'), 'coursedetails'); $reportcategory = new core_user\output\myprofile\category('reports', get_string('reports'), 'miscellaneous'); $admincategory = new core_user\output\myprofile\category('administration', get_string('administration'), 'reports'); $loginactivitycategory = new core_user\output\myprofile\category('loginactivity', get_string('loginactivity'), 'administration'); // Add categories. $tree->add_category($contactcategory); $tree->add_category($coursedetailscategory); $tree->add_category($miscategory); $tree->add_category($reportcategory); $tree->add_category($admincategory); $tree->add_category($loginactivitycategory); // Add core nodes. // Full profile node. if (!empty($course)) { if (empty($CFG->forceloginforprofiles) || $iscurrentuser || has_capability('moodle/user:viewdetails', context_user::instance($user->id)) || has_coursecontact_role($user->id)) { $url = new moodle_url('/user/profile.php', array('id' => $user->id)); $node = new core_user\output\myprofile\node('miscellaneous', 'fullprofile', get_string('fullprofile'), null, $url); $tree->add_node($node); } } // Edit profile. if (isloggedin() && !isguestuser($user) && !is_mnet_remote_user($user)) { if (($iscurrentuser || is_siteadmin($USER) || !is_siteadmin($user)) && has_capability('moodle/user:update', $systemcontext)) { $url = new moodle_url('/user/editadvanced.php', array('id' => $user->id, 'course' => $courseid)); $node = new core_user\output\myprofile\node('contact', 'editprofile', get_string('editmyprofile'), null, $url); $tree->add_node($node); } else { if (has_capability('moodle/user:editprofile', $usercontext) && !is_siteadmin($user) || $iscurrentuser && has_capability('moodle/user:editownprofile', $systemcontext)) { $userauthplugin = false; if (!empty($user->auth)) { $userauthplugin = get_auth_plugin($user->auth); } if ($userauthplugin && $userauthplugin->can_edit_profile()) { $url = $userauthplugin->edit_profile_url(); if (empty($url)) { if (empty($course)) { $url = new moodle_url('/user/edit.php', array('userid' => $user->id)); } else { $url = new moodle_url('/user/edit.php', array('userid' => $user->id, 'course' => $course->id)); } } $node = new core_user\output\myprofile\node('contact', 'editprofile', get_string('editmyprofile'), null, $url); $tree->add_node($node); } } } } // Preference page. Only visible by administrators. if (is_siteadmin()) { $url = new moodle_url('/user/preferences.php', array('userid' => $user->id)); $title = $iscurrentuser ? get_string('mypreferences') : get_string('userspreferences', 'moodle', fullname($user)); $node = new core_user\output\myprofile\node('administration', 'preferences', $title, null, $url); $tree->add_node($node); } // Login as ... if (!$user->deleted && !$iscurrentuser && !\core\session\manager::is_loggedinas() && has_capability('moodle/user:loginas', $context) && !is_siteadmin($user->id)) { $url = new moodle_url('/course/loginas.php', array('id' => $courseid, 'user' => $user->id, 'sesskey' => sesskey())); $node = new core_user\output\myprofile\node('administration', 'loginas', get_string('loginas'), null, $url); $tree->add_node($node); } // Contact details. if (has_capability('moodle/user:viewhiddendetails', $usercontext)) { $hiddenfields = array(); } else { $hiddenfields = array_flip(explode(',', $CFG->hiddenuserfields)); } if (has_capability('moodle/site:viewuseridentity', $context)) { $identityfields = array_flip(explode(',', $CFG->showuseridentity)); } else { $identityfields = array(); } if (is_mnet_remote_user($user)) { $sql = "SELECT h.id, h.name, h.wwwroot,\n a.name as application, a.display_name\n FROM {mnet_host} h, {mnet_application} a\n WHERE h.id = ? AND h.applicationid = a.id"; $remotehost = $DB->get_record_sql($sql, array($user->mnethostid)); $remoteuser = new stdclass(); $remoteuser->remotetype = $remotehost->display_name; $hostinfo = new stdclass(); $hostinfo->remotename = $remotehost->name; $hostinfo->remoteurl = $remotehost->wwwroot; $node = new core_user\output\myprofile\node('contact', 'mnet', get_string('remoteuser', 'mnet', $remoteuser), null, null, get_string('remoteuserinfo', 'mnet', $hostinfo), null, 'remoteuserinfo'); $tree->add_node($node); } if (isset($identityfields['email']) and ($iscurrentuser or $user->maildisplay == 1 or has_capability('moodle/course:useremail', $usercontext) or $user->maildisplay == 2 and enrol_sharing_course($user, $USER))) { $node = new core_user\output\myprofile\node('contact', 'email', get_string('email'), null, null, obfuscate_mailto($user->email, '')); $tree->add_node($node); } if (!isset($hiddenfields['country']) && $user->country) { $node = new core_user\output\myprofile\node('contact', 'country', get_string('country'), null, null, get_string($user->country, 'countries')); $tree->add_node($node); } if (!isset($hiddenfields['city']) && $user->city) { $node = new core_user\output\myprofile\node('contact', 'city', get_string('city'), null, null, $user->city); $tree->add_node($node); } if (isset($identityfields['address']) && $user->address) { $node = new core_user\output\myprofile\node('contact', 'address', get_string('address'), null, null, $user->address); $tree->add_node($node); } if (isset($identityfields['phone1']) && $user->phone1) { $node = new core_user\output\myprofile\node('contact', 'phone1', get_string('phone'), null, null, $user->phone1); $tree->add_node($node); } if (isset($identityfields['phone2']) && $user->phone2) { $node = new core_user\output\myprofile\node('contact', 'phone2', get_string('phone2'), null, null, $user->phone2); $tree->add_node($node); } if (isset($identityfields['institution']) && $user->institution) { $node = new core_user\output\myprofile\node('contact', 'institution', get_string('institution'), null, null, $user->institution); $tree->add_node($node); } if (isset($identityfields['department']) && $user->department) { $node = new core_user\output\myprofile\node('contact', 'department', get_string('department'), null, null, $user->institution); $tree->add_node($node); } if (isset($identityfields['idnumber']) && $user->idnumber) { $node = new core_user\output\myprofile\node('contact', 'idnumber', get_string('idnumber'), null, null, $user->institution); $tree->add_node($node); } if ($user->url && !isset($hiddenfields['webpage'])) { $url = $user->url; if (strpos($user->url, '://') === false) { $url = 'http://' . $url; } $webpageurl = new moodle_url($url); $node = new core_user\output\myprofile\node('contact', 'webpage', get_string('webpage'), null, null, html_writer::link($url, $webpageurl)); $tree->add_node($node); } // Printing tagged interests. We want this only for full profile. if (!empty($CFG->usetags) && empty($course)) { if ($interests = tag_get_tags_csv('user', $user->id)) { $node = new core_user\output\myprofile\node('contact', 'interests', get_string('interests'), null, null, $interests); $tree->add_node($node); } } if (!isset($hiddenfields['mycourses'])) { $showallcourses = optional_param('showallcourses', 0, PARAM_INT); if ($mycourses = enrol_get_all_users_courses($user->id, true, null, 'visible DESC, sortorder ASC')) { $shown = 0; $courselisting = html_writer::start_tag('ul'); foreach ($mycourses as $mycourse) { if ($mycourse->category) { context_helper::preload_from_record($mycourse); $ccontext = context_course::instance($mycourse->id); if (!isset($course) || $mycourse->id != $course->id) { $linkattributes = null; if ($mycourse->visible == 0) { if (!has_capability('moodle/course:viewhiddencourses', $ccontext)) { continue; } $linkattributes['class'] = 'dimmed'; } $params = array('id' => $user->id, 'course' => $mycourse->id); if ($showallcourses) { $params['showallcourses'] = 1; } $url = new moodle_url('/user/view.php', $params); $courselisting .= html_writer::tag('li', html_writer::link($url, $ccontext->get_context_name(false), $linkattributes)); } else { $courselisting .= html_writer::tag('li', $course->fullname); } } $shown++; if (!$showallcourses && $shown == $CFG->navcourselimit) { $url = null; if (isset($course)) { $url = new moodle_url('/user/view.php', array('id' => $user->id, 'course' => $course->id, 'showallcourses' => 1)); } else { $url = new moodle_url('/user/profile.php', array('id' => $user->id, 'showallcourses' => 1)); } $courselisting .= html_writer::tag('li', html_writer::link($url, get_string('viewmore'), array('title' => get_string('viewmore')))); break; } } $courselisting .= html_writer::end_tag('ul'); if (!empty($mycourses)) { // Add this node only if there are courses to display. $node = new core_user\output\myprofile\node('coursedetails', 'courseprofiles', get_string('courseprofiles'), null, null, rtrim($courselisting, ', ')); $tree->add_node($node); } } } if (!empty($course)) { // Show roles in this course. if ($rolestring = get_user_roles_in_course($user->id, $course->id)) { $node = new core_user\output\myprofile\node('coursedetails', 'roles', get_string('roles'), null, null, $rolestring); $tree->add_node($node); } // Show groups this user is in. if (!isset($hiddenfields['groups']) && !empty($course)) { $accessallgroups = has_capability('moodle/site:accessallgroups', $context); if ($usergroups = groups_get_all_groups($course->id, $user->id)) { $groupstr = ''; foreach ($usergroups as $group) { if ($course->groupmode == SEPARATEGROUPS and !$accessallgroups and $user->id != $USER->id) { if (!groups_is_member($group->id, $user->id)) { continue; } } if ($course->groupmode != NOGROUPS) { $groupstr .= ' <a href="' . $CFG->wwwroot . '/user/index.php?id=' . $course->id . '&group=' . $group->id . '">' . format_string($group->name) . '</a>,'; } else { // The user/index.php shows groups only when course in group mode. $groupstr .= ' ' . format_string($group->name); } } if ($groupstr !== '') { $node = new core_user\output\myprofile\node('coursedetails', 'groups', get_string('group'), null, null, rtrim($groupstr, ', ')); $tree->add_node($node); } } } if (!isset($hiddenfields['suspended'])) { if ($user->suspended) { $node = new core_user\output\myprofile\node('coursedetails', 'suspended', null, null, null, get_string('suspended', 'auth')); $tree->add_node($node); } } echo html_writer::end_tag('dl'); } if ($user->icq && !isset($hiddenfields['icqnumber'])) { $imurl = new moodle_url('http://web.icq.com/wwp', array('uin' => $user->icq)); $iconurl = new moodle_url('http://web.icq.com/whitepages/online', array('icq' => $user->icq, 'img' => '5')); $statusicon = html_writer::tag('img', '', array('src' => $iconurl, 'class' => 'icon icon-post', 'alt' => get_string('status'))); $node = new core_user\output\myprofile\node('contact', 'icqnumber', get_string('icqnumber'), null, null, html_writer::link($imurl, s($user->icq) . $statusicon)); $tree->add_node($node); } if ($user->skype && !isset($hiddenfields['skypeid'])) { $imurl = 'skype:' . urlencode($user->skype) . '?call'; $iconurl = new moodle_url('http://mystatus.skype.com/smallicon/' . urlencode($user->skype)); if (is_https()) { // Bad luck, skype devs are lazy to set up SSL on their servers - see MDL-37233. $statusicon = ''; } else { $statusicon = html_writer::empty_tag('img', array('src' => $iconurl, 'class' => 'icon icon-post', 'alt' => get_string('status'))); } $node = new core_user\output\myprofile\node('contact', 'skypeid', get_string('skypeid'), null, null, html_writer::link($imurl, s($user->skype) . $statusicon)); $tree->add_node($node); } if ($user->yahoo && !isset($hiddenfields['yahooid'])) { $imurl = new moodle_url('http://edit.yahoo.com/config/send_webmesg', array('.target' => $user->yahoo, '.src' => 'pg')); $iconurl = new moodle_url('http://opi.yahoo.com/online', array('u' => $user->yahoo, 'm' => 'g', 't' => '0')); $statusicon = html_writer::tag('img', '', array('src' => $iconurl, 'class' => 'iconsmall icon-post', 'alt' => get_string('status'))); $node = new core_user\output\myprofile\node('contact', 'yahooid', get_string('yahooid'), null, null, html_writer::link($imurl, s($user->yahoo) . $statusicon)); $tree->add_node($node); } if ($user->aim && !isset($hiddenfields['aimid'])) { $imurl = 'aim:goim?screenname=' . urlencode($user->aim); $node = new core_user\output\myprofile\node('contact', 'aimid', get_string('aimid'), null, null, html_writer::link($imurl, s($user->aim))); $tree->add_node($node); } if ($user->msn && !isset($hiddenfields['msnid'])) { $node = new core_user\output\myprofile\node('contact', 'msnid', get_string('msnid'), null, null, s($user->msn)); $tree->add_node($node); } if ($categories = $DB->get_records('user_info_category', null, 'sortorder ASC')) { foreach ($categories as $category) { if ($fields = $DB->get_records('user_info_field', array('categoryid' => $category->id), 'sortorder ASC')) { foreach ($fields as $field) { require_once $CFG->dirroot . '/user/profile/field/' . $field->datatype . '/field.class.php'; $newfield = 'profile_field_' . $field->datatype; $formfield = new $newfield($field->id, $user->id); if ($formfield->is_visible() and !$formfield->is_empty()) { $node = new core_user\output\myprofile\node('contact', $formfield->field->shortname, format_string($formfield->field->name), null, null, $formfield->display_data()); $tree->add_node($node); } } } } } // First access. (Why only for sites ?) if (!isset($hiddenfields['firstaccess']) && empty($course)) { if ($user->firstaccess) { $datestring = userdate($user->firstaccess) . " (" . format_time(time() - $user->firstaccess) . ")"; } else { $datestring = get_string("never"); } $node = new core_user\output\myprofile\node('loginactivity', 'firstaccess', get_string('firstsiteaccess'), null, null, $datestring); $tree->add_node($node); } // Last access. if (!isset($hiddenfields['lastaccess'])) { if (empty($course)) { $string = get_string('lastsiteaccess'); if ($user->lastaccess) { $datestring = userdate($user->lastaccess) . " (" . format_time(time() - $user->lastaccess) . ")"; } else { $datestring = get_string("never"); } } else { $string = get_string('lastcourseaccess'); if ($lastaccess = $DB->get_record('user_lastaccess', array('userid' => $user->id, 'courseid' => $course->id))) { $datestring = userdate($lastaccess->timeaccess) . " (" . format_time(time() - $lastaccess->timeaccess) . ")"; } else { $datestring = get_string("never"); } } $node = new core_user\output\myprofile\node('loginactivity', 'lastaccess', $string, null, null, $datestring); $tree->add_node($node); } // Last ip. if (has_capability('moodle/user:viewlastip', $usercontext) && !isset($hiddenfields['lastip'])) { if ($user->lastip) { $iplookupurl = new moodle_url('/iplookup/index.php', array('ip' => $user->lastip, 'user' => $USER->id)); $ipstring = html_writer::link($iplookupurl, $user->lastip); } else { $ipstring = get_string("none"); } $node = new core_user\output\myprofile\node('loginactivity', 'lastip', get_string('lastip'), null, null, $ipstring); $tree->add_node($node); } }
function alter_mailto($matches) { return obfuscate_mailto($matches[2], $matches[4]); }
$switchpix = 'email.gif'; } $emailswitch = " <a title=\"{$switchclick}\" " . "href=\"view.php?id={$user->id}&course={$course->id}&{$switchparam}=1\">" . "<img src=\"{$CFG->pixpath}/t/{$switchpix}\" alt=\"{$switchclick}\" /></a>"; } else { if ($currentuser) { /// Can only re-enable an email this way if ($user->emailstop) { // Include link that tells how to re-enable their email $switchparam = 'enable'; $switchtitle = get_string('emaildisable'); $switchclick = get_string('emailenableclick'); $emailswitch = " (<a title=\"{$switchclick}\" " . "href=\"view.php?id={$user->id}&course={$course->id}&enable=1\">{$switchtitle}</a>)"; } } } print_row(get_string("email") . ":", obfuscate_mailto($user->email, '', $user->emailstop) . "{$emailswitch}"); } if ($user->url && !isset($hiddenfields['webpage'])) { $url = $user->url; if (strpos($user->url, '://') === false) { $url = 'http://' . $url; } print_row(get_string("webpage") . ":", "<a href=\"{$url}\">{$user->url}</a>"); } if ($user->icq && !isset($hiddenfields['icqnumber'])) { print_row(get_string('icqnumber') . ':', "<a href=\"http://web.icq.com/wwp?uin={$user->icq}\">{$user->icq} <img src=\"http://web.icq.com/whitepages/online?icq={$user->icq}&img=5\" alt=\"\" /></a>"); } if ($user->skype && !isset($hiddenfields['skypeid'])) { print_row(get_string('skypeid') . ':', '<a href="callto:' . urlencode($user->skype) . '">' . s($user->skype) . ' <img src="http://mystatus.skype.com/smallicon/' . urlencode($user->skype) . '" alt="' . get_string('status') . '" ' . ' /></a>'); } if ($user->yahoo && !isset($hiddenfields['yahooid'])) {
/** * block contents * * @return object */ public function get_content() { global $CFG, $USER, $DB, $OUTPUT, $PAGE; if ($this->content !== NULL) { return $this->content; } if (!isloggedin() or isguestuser()) { return ''; // Never useful unless you are logged in as real users } $this->content = new stdClass(); $this->content->text = ''; $this->content->footer = ''; $course = $this->page->course; if (!isset($this->config->display_picture) || $this->config->display_picture == 1) { $this->content->text .= '<div class="myprofileitem picture">'; $this->content->text .= $OUTPUT->user_picture($USER, array('courseid' => $course->id, 'size' => '100', 'class' => 'profilepicture')); // The new class makes CSS easier $this->content->text .= '</div>'; } $this->content->text .= '<div class="myprofileitem fullname">' . fullname($USER) . '</div>'; if (!isset($this->config->display_country) || $this->config->display_country == 1) { $countries = get_string_manager()->get_list_of_countries(); if (isset($countries[$USER->country])) { $this->content->text .= '<div class="myprofileitem country">'; $this->content->text .= get_string('country') . ': ' . $countries[$USER->country]; $this->content->text .= '</div>'; } } if (!isset($this->config->display_city) || $this->config->display_city == 1) { $this->content->text .= '<div class="myprofileitem city">'; $this->content->text .= get_string('city') . ': ' . format_string($USER->city); $this->content->text .= '</div>'; } if (!isset($this->config->display_email) || $this->config->display_email == 1) { $this->content->text .= '<div class="myprofileitem email">'; $this->content->text .= obfuscate_mailto($USER->email, ''); $this->content->text .= '</div>'; } if (!empty($this->config->display_icq) && !empty($USER->icq)) { $this->content->text .= '<div class="myprofileitem icq">'; $this->content->text .= 'ICQ: ' . s($USER->icq); $this->content->text .= '</div>'; } if (!empty($this->config->display_skype) && !empty($USER->skype)) { $this->content->text .= '<div class="myprofileitem skype">'; $this->content->text .= 'Skype: ' . s($USER->skype); $this->content->text .= '</div>'; } if (!empty($this->config->display_yahoo) && !empty($USER->yahoo)) { $this->content->text .= '<div class="myprofileitem yahoo">'; $this->content->text .= 'Yahoo: ' . s($USER->yahoo); $this->content->text .= '</div>'; } if (!empty($this->config->display_aim) && !empty($USER->aim)) { $this->content->text .= '<div class="myprofileitem aim">'; $this->content->text .= 'AIM: ' . s($USER->aim); $this->content->text .= '</div>'; } if (!empty($this->config->display_msn) && !empty($USER->msn)) { $this->content->text .= '<div class="myprofileitem msn">'; $this->content->text .= 'MSN: ' . s($USER->msn); $this->content->text .= '</div>'; } if (!empty($this->config->display_phone1) && !empty($USER->phone1)) { $this->content->text .= '<div class="myprofileitem phone1">'; $this->content->text .= get_string('phone') . ': ' . s($USER->phone1); $this->content->text .= '</div>'; } if (!empty($this->config->display_phone2) && !empty($USER->phone2)) { $this->content->text .= '<div class="myprofileitem phone2">'; $this->content->text .= get_string('phone') . ': ' . s($USER->phone2); $this->content->text .= '</div>'; } if (!empty($this->config->display_institution) && !empty($USER->institution)) { $this->content->text .= '<div class="myprofileitem institution">'; $this->content->text .= format_string($USER->institution); $this->content->text .= '</div>'; } if (!empty($this->config->display_address) && !empty($USER->address)) { $this->content->text .= '<div class="myprofileitem address">'; $this->content->text .= format_string($USER->address); $this->content->text .= '</div>'; } if (!empty($this->config->display_firstaccess) && !empty($USER->firstaccess)) { $this->content->text .= '<div class="myprofileitem firstaccess">'; $this->content->text .= get_string('firstaccess') . ': ' . userdate($USER->firstaccess); $this->content->text .= '</div>'; } if (!empty($this->config->display_lastaccess) && !empty($USER->lastaccess)) { $this->content->text .= '<div class="myprofileitem lastaccess">'; $this->content->text .= get_string('lastaccess') . ': ' . userdate($USER->lastaccess); $this->content->text .= '</div>'; } if (!empty($this->config->display_currentlogin) && !empty($USER->currentlogin)) { $this->content->text .= '<div class="myprofileitem currentlogin">'; $this->content->text .= get_string('login') . ': ' . userdate($USER->currentlogin); $this->content->text .= '</div>'; } if (!empty($this->config->display_lastip) && !empty($USER->lastip)) { $this->content->text .= '<div class="myprofileitem lastip">'; $this->content->text .= 'IP: ' . $USER->lastip; $this->content->text .= '</div>'; } return $this->content; }
function view_dates() { global $CFG, $USER; $rday = optional_param('rday', NULL, PARAM_INT); $rslot = optional_param('rslot', NULL, PARAM_INT); $delete = optional_param('delete', NULL, PARAM_INT); $resid = optional_param('resid', NULL, PARAM_INT); $uid = optional_param('uid', NULL, PARAM_INT); require_once "../../config.php"; $cmid = $this->cm->id; if (!($course = get_record('course', 'id', $this->cm->course))) { error('Course is misconfigured'); } $itemid = $this->bookings->itemid; $username = $USER->username; $UID = $USER->id; $firstname = $USER->firstname; $lastname = $USER->lastname; if ($firstname == '' or $lastname == '') { return ""; } $html .= '<form name=myform id=myform method=post action="view.php?id=' . $cmid . '">'; $proplist = bookings_item_properties($itemid); $days = explode(',', 'A,B,C,D,E,F'); $daylimits = array(); if (isset($proplist['days']) and $proplist['days'] != '') { $days = explode(',', $proplist['days']); $dag = 0; foreach ($days as $day) { list($dy, $lim) = explode(':', $day); // pick out optional size limit $days[$dag] = $dy; $daylimits[$dag] = (int) $lim; $dag++; } } $widthprcent = (int) (95 / count($days)); // default width $slots = explode(',', '1,2,3,4,5,6'); $slotlimits = array(); if (isset($proplist['slots']) and $proplist['slots'] != '') { $slots = explode(',', $proplist['slots']); $slt = 0; foreach ($slots as $slot) { list($sl, $lim) = explode(':', $slot); // pick out optional size limit $slots[$slt] = $sl; $slotlimits[$slt] = (int) $lim; $slt++; } } $multiple = 0; if (isset($proplist['multiple'])) { $multiple = (int) $proplist['multiple']; } $exclusive = 'non'; // many entries pr user if (isset($proplist['exclusive'])) { $exclusive = $proplist['exclusive']; } $can_edit = 1; // any user can make a booking if (isset($proplist['edit_group'])) { $can_edit = isadmin() ? 1 : 0; if ($proplist['edit_group'] == 'teachers' and isteacherinanycourse($USER->id)) { $can_edit = 1; } else { if ($proplist['edit_group'] == 'students') { $can_edit = 1; } else { $can_edit = isteacherinanycourse($USER->id) ? 1 : 0; // default is teachers can make a booking } } } $privilege = isteacherinanycourse($USER->id) ? isadmin() ? 2 : 1 : 0; /// here we fetch out all reservations $sql = 'SELECT * FROM ' . $CFG->prefix . 'bookings_calendar WHERE eventtype="reservation" AND bookingid=' . $this->bookings->id; $reservation = array(); $daycount = array(); // count of reservations pr day (colcount) $slotcount = array(); // count of reservations pr slot (rowcount) $total = 0; if ($res = get_records_sql($sql)) { foreach ($res as $re) { $reservation[$re->day][$re->slot][] = $re; $reservation[$re->day][$re->slot]->res = $re; $daycount[$re->day] += 1; $slotcount[$re->slot] += 1; $total++; } } /// this is where we make the reservation or delete reservations if ((isset($resid) and isset($uid) or isset($rday) and isset($rslot)) and $can_edit) { if (!isteacherinanycourse($USER->id) and !isadmin() and isset($reservation[$rday][$rslot])) { if ($uid != $UID) { // return; // assume an attempt to phreak the system with params } } /// exclusive decides if and how multiple bookings made by one user is handled /// default is that a user can book once in any available slot switch ($exclusive) { case 'row': /// only one booking pr row $sql = 'DELETE FROM ' . $CFG->prefix . 'bookings_calendar WHERE eventtype="reservation" AND userid=' . $UID . ' AND slot=' . $rslot; break; case 'rowcol': /// only one booking in this row+col $sql = 'DELETE FROM ' . $CFG->prefix . 'bookings_calendar WHERE eventtype="reservation" AND userid=' . $UID . ' AND (day=' . $rday . ' OR slot=' . $rslot . ')'; break; case 'col': /// only one booking pr col $sql = 'DELETE FROM ' . $CFG->prefix . 'bookings_calendar WHERE eventtype="reservation" AND userid=' . $UID . ' AND day=' . $rday; break; case 'all': /// only one booking $sql = 'DELETE FROM ' . $CFG->prefix . 'bookings_calendar WHERE eventtype="reservation" AND userid=' . $UID; break; default: $sql = 'DELETE FROM ' . $CFG->prefix . 'bookings_calendar WHERE eventtype="reservation" AND slot=' . $rslot . ' AND day=' . $rday . ' AND userid=' . $UID; } execute_sql($sql, 0); /// this removes multiple bookings by one person for a given slot (or all bookings if exclusive) if (isset($resid)) { $sql = 'DELETE FROM ' . $CFG->prefix . 'bookings_calendar WHERE id=' . $resid; execute_sql($sql, 0); } if (!isset($delete)) { $sql = 'INSERT INTO ' . $CFG->prefix . 'bookings_calendar (bookingid,name,value,userid,eventtype,slot,day) VALUES (' . $this->bookings->id . ',"' . $username . '","' . $username . '",' . $UID . ',"reservation",' . $rslot . ',' . $rday . ')'; execute_sql($sql, 0); } // have to refetch data $sql = 'SELECT * FROM ' . $CFG->prefix . 'bookings_calendar WHERE eventtype="reservation" AND bookingid=' . $this->bookings->id; $reservation = array(); $daycount = array(); // count of reservations pr day (colcount) $slotcount = array(); // count of reservations pr slot (rowcount) $total = 0; // total number of reservations if ($res = get_records_sql($sql)) { foreach ($res as $re) { $reservation[$re->day][$re->slot][] = $re; $daycount[$re->day] += 1; $slotcount[$re->slot] += 1; $total++; } } } $html .= '<div id="all">'; // now we draw up the table $table = array(); $lastrow = ''; if ($can_edit) { $baselink = '<a href="view.php?id=' . $cmid; } else { $baselink = ''; } $table[] = '<table border=1 width=100%>'; $table[] = '<tr><th width=5%> </th>'; $dag = 0; foreach ($days as $day) { if ($day == '') { continue; } $table[] = '<th>' . $day . '</th>'; $lastrow .= "<td>" . $daycount[$dag] . " </td>\n"; $dag++; } $table[] = '</tr>'; $time = 0; foreach ($slots as $slottime) { $t = $time + 1; $table[] = "<tr><th class=\"number\"><span class=\"time\">{$slottime}</span></th>"; $dag = 0; $scanedit = ($slotlimits[$time] == 0 or $slotlimits[$time] > $slotcount[$time]) ? $can_edit : 0; foreach ($days as $day) { $canedit = $scanedit; $class = 'normal'; if ($day != '') { $canedit = ($daylimits[$dag] == 0 or $daylimits[$dag] > $daycount[$dag]) ? $canedit : 0; if ($tp[$dag][$time] == '') { $class = 'free'; $tp[$dag][$time] = $canedit ? $baselink . '&rday=' . $dag . '&rslot=' . $time . '">' . get_string('free', 'bookings') . '</a>' : get_string('free', 'bookings'); } if (isset($reservation[$dag][$time])) { $tp[$dag][$time] = ''; foreach ($reservation[$dag][$time] as $myres) { $class = 'reserved'; $linktext = 'Reserved ' . $myres->value; if ($myres->userid == $UID) { $linktext = 'M'; } else { if (sizeof($reservation[$dag][$time] > 1)) { $linktext = isteacherinanycourse($myres->userid) ? 'T' : 'S'; } } // admin can override any, teacher can override student if ($myres->userid == $UID or isadmin() or isteacherinanycourse($USER->id) and !isteacherinanycourse($myres->userid)) { $tp[$dag][$time] .= $can_edit ? $baselink . '&delete=1&resid=' . $myres->id . '&uid=' . $myres->userid . '" title="' . $myres->value . '" >' . $linktext . '</a> ' : $linktext . $myres->value; } else { $tp[$dag][$time] .= '<span title="' . $myres->value . '">' . $linktext . ' </span>'; } } if (isset($multiple) and $multiple > sizeof($reservation[$dag][$time])) { /// $tp[$dag][$time] .= ' ' .$reservation[$dag][$time]->count . ' '; $tp[$dag][$time] .= $canedit ? $baselink . '&rday=' . $dag . '&rslot=' . $time . '">' . get_string('free', 'bookings') . '</a>' : get_string('free', 'bookings'); } } $table[] = "<td width=\"{$widthprcent}%\" class=\"{$class}\" >" . $tp[$dag][$time] . " </td>\n"; } $dag++; } if ($privilege > 0) { $table[] = "<td>" . $slotcount[$time] . " </td>\n"; } $table[] = "</tr>\n"; $idx++; $time += 1; } if ($privilege > 0) { $table[] = "<tr><td></td>" . $lastrow . "<td>{$total}</td></tr>"; } $table[] = "</table>\n"; $html .= implode("", $table); $html .= '<input type="hidden" name="itemid" value="' . $itemid . '">'; $html .= '<input type="hidden" name="jday" value="' . $jday . '">'; $html .= '</div>'; // end div=all print $html; if ($privilege > 0) { unset($table); $table->head = array(' ', get_string('name')); $table->align = array('center', 'left'); $table->wrap = array('nowrap', 'nowrap'); $table->width = '100%'; $table->size = array(10, '*'); $table->head[] = get_string('email'); $table->align[] = 'center'; $table->wrap[] = 'nowrap'; $table->size[] = '*'; $table->head[] = get_string('reservation', 'bookings'); $table->align[] = 'center'; $table->wrap[] = 'nowrap'; $table->size[] = '*'; $table->head[] = get_string('choice', 'bookings'); $table->align[] = 'center'; $table->wrap[] = 'nowrap'; $table->size[] = '*'; // $books = get_records('calendar', 'bookingid', $this->bookings->id); if ($books = get_records_sql("SELECT r.*, u.firstname, u.lastname, u.picture, u.email\n FROM {$CFG->prefix}bookings_calendar r,\n {$CFG->prefix}user u\n WHERE r.bookingid = '{$this->bookings->id}' \n AND r.userid = u.id ORDER BY r.day,r.slot")) { foreach ($books as $request) { $row = array(); $row[] = print_user_picture($request->userid, $course->id, $request->picture, 0, true); $row[] = '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $request->userid . '&course=' . $course->id . '">' . $request->lastname . ' ' . $request->firstname . '</a>'; $row[] = obfuscate_mailto($request->email); $row[] = $days[$request->day]; $row[] = $slots[$request->slot]; $table->data[] = $row; } print "<p>"; print_table($table); } } print "</form>"; return; }
/** * Render an issued badge. * * No functional changes, but this override is required due to incorrect use * of the self:: scope (as opposed to static:: or $this->) in core. * * @param \issued_badge $issuedbadge * * @return string */ protected function render_issued_badge(issued_badge $issuedbadge) { global $CFG, $DB, $SITE, $USER; $badge = new badge($issuedbadge->badgeid); $now = time(); $table = new html_table(); $table->id = 'issued-badge-table'; $imagetable = new html_table(); $imagetable->attributes = array('class' => 'clearfix badgeissuedimage'); $imagetable->data[] = array(html_writer::empty_tag('img', array('src' => $issuedbadge->badgeclass['image']))); if ($USER->id == $issuedbadge->recipient->id && !empty($CFG->enablebadges)) { $imagetable->data[] = array($this->output->single_button(new moodle_url('/badges/badge.php', array('hash' => $issuedbadge->issued['uid'], 'bake' => true)), get_string('download'), 'POST')); $expiration = isset($issuedbadge->issued['expires']) ? $issuedbadge->issued['expires'] : $now + 86400; if (!empty($CFG->badges_allowexternalbackpack) && $expiration > $now && badges_user_has_backpack($USER->id)) { $assertion = new moodle_url('/badges/assertion.php', array('b' => $issuedbadge->issued['uid'])); $action = new component_action('click', 'addtobackpack', array('assertion' => $assertion->out(false))); $attributes = array('type' => 'button', 'id' => 'addbutton', 'value' => get_string('addtobackpack', 'badges')); $tobackpack = html_writer::tag('input', '', $attributes); $this->output->add_action_handler($action, 'addbutton'); $imagetable->data[] = array($tobackpack); } } $datatable = new html_table(); $datatable->attributes = array('class' => 'badgeissuedinfo'); $datatable->colclasses = array('bfield', 'bvalue'); // Recipient information. $datatable->data[] = array($this->output->heading(get_string('recipientdetails', 'badges'), 3), ''); if ($issuedbadge->recipient->deleted) { $strdata = new stdClass(); $strdata->user = fullname($issuedbadge->recipient); $strdata->site = format_string($SITE->fullname, true, array('context' => context_system::instance())); $datatable->data[] = array(get_string('name'), get_string('error:userdeleted', 'badges', $strdata)); } else { $datatable->data[] = array(get_string('name'), fullname($issuedbadge->recipient)); } $datatable->data[] = array($this->output->heading(get_string('issuerdetails', 'badges'), 3), ''); $datatable->data[] = array(get_string('issuername', 'badges'), $badge->issuername); if (isset($badge->issuercontact) && !empty($badge->issuercontact)) { $datatable->data[] = array(get_string('contact', 'badges'), obfuscate_mailto($badge->issuercontact)); } $datatable->data[] = array($this->output->heading(get_string('badgedetails', 'badges'), 3), ''); $datatable->data[] = array(get_string('name'), $badge->name); $datatable->data[] = array(get_string('description', 'badges'), $badge->description); if ($badge->type == BADGE_TYPE_COURSE && isset($badge->courseid)) { $coursename = $DB->get_field('course', 'fullname', array('id' => $badge->courseid)); $datatable->data[] = array(get_string('course'), $coursename); } $datatable->data[] = array(get_string('bcriteria', 'badges'), $this->print_badge_criteria($badge)); $datatable->data[] = array($this->output->heading(get_string('issuancedetails', 'badges'), 3), ''); $datatable->data[] = array(get_string('dateawarded', 'badges'), userdate($issuedbadge->issued['issuedOn'])); if (isset($issuedbadge->issued['expires'])) { if ($issuedbadge->issued['expires'] < $now) { $cell = new html_table_cell(userdate($issuedbadge->issued['expires']) . get_string('warnexpired', 'badges')); $cell->attributes = array('class' => 'notifyproblem warning'); $datatable->data[] = array(get_string('expirydate', 'badges'), $cell); $image = html_writer::start_tag('div', array('class' => 'badge')); $image .= html_writer::empty_tag('img', array('src' => $issuedbadge->badgeclass['image'])); $image .= $this->output->pix_icon('i/expired', get_string('expireddate', 'badges', userdate($issuedbadge->issued['expires'])), 'moodle', array('class' => 'expireimage')); $image .= html_writer::end_tag('div'); $imagetable->data[0] = array($image); } else { $datatable->data[] = array(get_string('expirydate', 'badges'), userdate($issuedbadge->issued['expires'])); } } // Print evidence. $agg = $badge->get_aggregation_methods(); $evidence = $badge->get_criteria_completions($issuedbadge->recipient->id); $eids = array_map(create_function('$o', 'return $o->critid;'), $evidence); unset($badge->criteria[BADGE_CRITERIA_TYPE_OVERALL]); $items = array(); foreach ($badge->criteria as $type => $criteria) { if (in_array($criteria->id, $eids)) { $items[] = $this->print_badge_criteria_single($badge, $agg, $type, $criteria); } } $datatable->data[] = array(get_string('evidence', 'badges'), get_string('completioninfo', 'badges') . html_writer::alist($items, array(), 'ul')); $table->attributes = array('class' => 'generalbox boxaligncenter issuedbadgebox'); $table->data[] = array(html_writer::table($imagetable), html_writer::table($datatable)); $htmlbadge = html_writer::table($table); return $htmlbadge; }
function filter_emailprotect_alter_mailto($matches) { return obfuscate_mailto($matches[2], $matches[4]); }
function build_facstu_list_table($interview, $cm, $course) { global $DB, $OUTPUT; $strstudent = get_string('student', 'interview'); $strphoto = get_string('photo', 'interview'); $stremail = get_string('email', 'interview'); // collects the students in the course $students = get_course_students($course->id, $sort = "u.lastname", $dir = "ASC"); // If there are no students, will notify if (!$students) { $OUTPUT->notify(get_string('noexistingstudents')); // If there are students, creates a table with the users // that have not picked a horary string } else { // Defines the headings and alignments in the table of students $stu_list_table = new html_table(); $stu_list_table->head = array($strphoto, $strstudent, $stremail); $stu_list_table->align = array('CENTER', 'CENTER', 'CENTER'); $stu_list_table->data = array(); // Begins the link to send mail to all the // students that have not picked a string $mailto = '<a href="mailto:'; // Para cada uno de los estudiantes // For each of the students foreach ($students as $student) { $row = array(); // If a relationship that complies with the restrictions does not exist if (!$DB->record_exists('interview_slots', array('student' => $student->id, 'interviewid' => $interview->id))) { // Shows the user image $picture = $OUTPUT->user_picture($student); $row["picture"] = $picture; // Shows the full name in link format $name = "<a href=\"../../user/view.php?id={$student->id}&course={$interview->course}\">" . fullname($student) . "</a>"; $row["name"] = $name; // Creates a link to the mailto list for the user $email = obfuscate_mailto($student->email); $row["email"] = $email; // Inserts the data in the table $stu_list_table->data[] = array($picture, $name, $email); //, $actions); } } } return $stu_list_table; }
notify($nostudentstr); } else { $mtable->head = array('', $strname, $stremail, $strseen, $straction); $mtable->align = array('CENTER', 'LEFT', 'LEFT', 'CENTER', 'CENTER'); $mtable->width = array('', '', '', '', ''); $mtable->data = array(); // In $mailto the mailing list for reminder emails is built up $mailto = '<a href="mailto:'; $date = usergetdate(time()); foreach ($students as $student) { if (!scheduler_has_slot($student->id, $scheduler, true, $scheduler->schedulermode == 'onetime')) { $picture = print_user_picture($student->id, $course->id, $student->picture, false, true); $name = "<a href=\"../../user/view.php?id={$student->id}&course={$scheduler->course}\">"; $name .= fullname($student); $name .= '</a>'; $email = obfuscate_mailto($student->email); if (scheduler_has_slot($student->id, $scheduler, true, false) == 0) { // student has never scheduled $mailto .= $student->email . ', '; } $checkbox = "<a href=\"view.php?what=schedule&id={$cm->id}&studentid={$student->id}&page={$page}&seen=1\">"; $checkbox .= '<img src="pix/unticked.gif" border="0" />'; $checkbox .= '</a>'; $actions = '<span style="font-size: x-small;">'; $actions .= "<a href=\"view.php?what=schedule&id={$cm->id}&studentid={$student->id}&page={$page}\">"; $actions .= get_string('schedule', 'scheduler'); $actions .= '</a></span>'; $mtable->data[] = array($picture, $name, $email, $checkbox, $actions); } } // dont print if allowed to book multiple appointments
/** * block contents * * @return object */ public function get_content() { global $CFG, $USER, $DB, $OUTPUT, $PAGE; if ($this->content !== NULL) { return $this->content; } if (!isloggedin()) { return ''; // Never useful unless you are logged in } $this->content = new stdClass(); $this->content->text = ''; $this->content->footer = ''; $course = $this->page->course; if ($PAGE->context->contextlevel == CONTEXT_USER) { $user = $DB->get_record('user', array('id' => $PAGE->context->instanceid)); } else { $user = $USER; } if ($course->id == SITEID) { $coursecontext = get_context_instance(CONTEXT_SYSTEM); } else { $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id); // Course context // Make sure they can view the course if (!is_viewing($coursecontext)) { return ''; } } // TODO: clean up the following even more if (!isset($this->config->display_picture) || $this->config->display_picture == 1) { $this->content->text .= '<div class="myprofileitem picture">'; $this->content->text .= $OUTPUT->user_picture($user, array('courseid' => $course->id, 'size' => '100', 'class' => 'profilepicture')); // The new class makes CSS easier $this->content->text .= '</div>'; } $this->content->text .= '<div class="myprofileitem fullname">' . fullname($user) . '</div>'; if (!isset($this->config->display_country) || $this->config->display_country == 1) { $countries = get_string_manager()->get_list_of_countries(); if (isset($countries[$user->country])) { $this->content->text .= '<div class="myprofileitem country">'; $this->content->text .= get_string('country') . ': ' . $countries[$user->country]; $this->content->text .= '</div>'; } } if (!isset($this->config->display_city) || $this->config->display_city == 1) { $this->content->text .= '<div class="myprofileitem city">'; $this->content->text .= get_string('city') . ': ' . $user->city; $this->content->text .= '</div>'; } if (!isset($this->config->display_email) || $this->config->display_email == 1) { $this->content->text .= '<div class="myprofileitem email">'; $this->content->text .= obfuscate_mailto($user->email, ''); $this->content->text .= '</div>'; } if (!empty($this->config->display_icq) && !empty($user->icq)) { $this->content->text .= '<div class="myprofileitem icq">'; $this->content->text .= 'ICQ: ' . $user->icq; $this->content->text .= '</div>'; } if (!empty($this->config->display_skype) && !empty($user->skype)) { $this->content->text .= '<div class="myprofileitem skype">'; $this->content->text .= 'Skype: ' . $user->skype; $this->content->text .= '</div>'; } if (!empty($this->config->display_yahoo) && !empty($user->yahoo)) { $this->content->text .= '<div class="myprofileitem yahoo">'; $this->content->text .= 'Yahoo: ' . $user->yahoo; $this->content->text .= '</div>'; } if (!empty($this->config->display_aim) && !empty($user->aim)) { $this->content->text .= '<div class="myprofileitem aim">'; $this->content->text .= 'AIM: ' . $user->aim; $this->content->text .= '</div>'; } if (!empty($this->config->display_msn) && !empty($user->msn)) { $this->content->text .= '<div class="myprofileitem msn">'; $this->content->text .= 'MSN: ' . $user->msn; $this->content->text .= '</div>'; } if (!empty($this->config->display_phone1) && !empty($user->phone1)) { $this->content->text .= '<div class="myprofileitem phone1">'; $this->content->text .= get_string('phone') . ': ' . $user->phone1; $this->content->text .= '</div>'; } if (!empty($this->config->display_phone2) && !empty($user->phone2)) { $this->content->text .= '<div class="myprofileitem phone2">'; $this->content->text .= get_string('phone') . ': ' . $user->phone2; $this->content->text .= '</div>'; } if (!empty($this->config->display_institution) && !empty($user->institution)) { $this->content->text .= '<div class="myprofileitem institution">'; $this->content->text .= $user->institution; $this->content->text .= '</div>'; } if (!empty($this->config->display_address) && !empty($user->address)) { $this->content->text .= '<div class="myprofileitem address">'; $this->content->text .= $user->address; $this->content->text .= '</div>'; } if (!empty($this->config->display_firstaccess) && !empty($user->firstaccess)) { $this->content->text .= '<div class="myprofileitem firstaccess">'; $this->content->text .= get_string('firstaccess') . ': ' . userdate($user->firstaccess); $this->content->text .= '</div>'; } if (!empty($this->config->display_lastaccess) && !empty($user->lastaccess)) { $this->content->text .= '<div class="myprofileitem lastaccess">'; $this->content->text .= get_string('lastaccess') . ': ' . userdate($user->lastaccess); $this->content->text .= '</div>'; } if (!empty($this->config->display_currentlogin) && !empty($user->currentlogin)) { $this->content->text .= '<div class="myprofileitem currentlogin">'; $this->content->text .= get_string('login') . ': ' . userdate($user->currentlogin); $this->content->text .= '</div>'; } if (!empty($this->config->display_lastip) && !empty($user->lastip)) { $this->content->text .= '<div class="myprofileitem lastip">'; $this->content->text .= 'IP: ' . $user->lastip; $this->content->text .= '</div>'; } $editscript = NULL; if (isguestuser($user)) { // guest account can not be edited } else { if (is_mnet_remote_user($user)) { // cannot edit remote users } else { if (isguestuser() or !isloggedin()) { // guests and not logged in can not edit own profile } else { if ($USER->id == $user->id) { $systemcontext = get_context_instance(CONTEXT_SYSTEM); if (has_capability('moodle/user:update', $systemcontext)) { $editscript = '/user/editadvanced.php'; } else { if (has_capability('moodle/user:editownprofile', $systemcontext)) { $editscript = '/user/edit.php'; } } } else { $systemcontext = get_context_instance(CONTEXT_SYSTEM); $personalcontext = get_context_instance(CONTEXT_USER, $user->id); if (has_capability('moodle/user:update', $systemcontext) and !is_primary_admin($user->id)) { $editscript = '/user/editadvanced.php'; } else { if (has_capability('moodle/user:editprofile', $personalcontext) and !is_primary_admin($user->id)) { //teachers, parents, etc. $editscript = '/user/edit.php'; } } } } } } if ($editscript) { $this->content->text .= '<div class="myprofileitem edit">'; $this->content->text .= '<a href="' . $CFG->wwwroot . $editscript . '?id=' . $user->id . '&course=' . $course->id . '">' . get_string('editmyprofile') . '</a>'; $this->content->text .= '</div>'; } return $this->content; }