/** * Outputs the user menu. * @return custom_menu object */ public function custom_menu_user() { // Die if executed during install. if (during_initial_install()) { return false; } if (!isloggedin() || isguestuser()) { return $this->login_info(); } global $USER, $CFG, $DB, $SESSION; $loginurl = get_login_url(); $usermenu = html_writer::start_tag('ul', array('class' => 'nav')); $usermenu .= html_writer::start_tag('li', array('class' => 'dropdown')); $course = $this->page->course; $context = context_course::instance($course->id); // Output Profile link $userurl = new moodle_url('#'); $userpic = parent::user_picture($USER, array('link' => false)); $caret = '<i class="fa fa-caret-right"></i>'; $userclass = array('class' => 'dropdown-toggle', 'data-toggle' => 'dropdown'); $usermenu .= html_writer::link($userurl, $userpic . $USER->firstname . $caret, $userclass); // Start dropdown menu items $usermenu .= html_writer::start_tag('ul', array('class' => 'dropdown-menu pull-right')); $usermenu .= html_writer::tag('li', $this->login_info()); // Add preferences submenu $usermenu .= $this->theme_campus_render_preferences($context); $usermenu .= html_writer::empty_tag('hr', array('class' => 'sep')); // Output Calendar link if user is allowed to edit own calendar entries if (has_capability('moodle/calendar:manageownentries', $context)) { $branchlabel = '<em><i class="fa fa-calendar"></i>' . get_string('pluginname', 'block_calendar_month') . '</em>'; $branchurl = new moodle_url('/calendar/view.php'); $usermenu .= html_writer::tag('li', html_writer::link($branchurl, $branchlabel)); } // Check if messaging is enabled. if (!empty($CFG->messaging)) { $branchlabel = '<em><i class="fa fa-envelope"></i>' . get_string('pluginname', 'block_messages') . '</em>'; $branchurl = new moodle_url('/message/index.php'); $usermenu .= html_writer::tag('li', html_writer::link($branchurl, $branchlabel)); } // Check if user is allowed to manage files if (has_capability('moodle/user:manageownfiles', $context)) { $branchlabel = '<em><i class="fa fa-file"></i>' . get_string('privatefiles', 'block_private_files') . '</em>'; $branchurl = new moodle_url('/user/files.php'); $usermenu .= html_writer::tag('li', html_writer::link($branchurl, $branchlabel)); } // Check if user is allowed to view discussions if (has_capability('mod/forum:viewdiscussion', $context)) { $branchlabel = '<em><i class="fa fa-list-alt"></i>' . get_string('forumposts', 'mod_forum') . '</em>'; $branchurl = new moodle_url('/mod/forum/user.php', array('id' => $USER->id)); $usermenu .= html_writer::tag('li', html_writer::link($branchurl, $branchlabel)); $branchlabel = '<em><i class="fa fa-list"></i>' . get_string('discussions', 'mod_forum') . '</em>'; $branchurl = new moodle_url('/mod/forum/user.php', array('id' => $USER->id, 'mode' => 'discussions')); $usermenu .= html_writer::tag('li', html_writer::link($branchurl, $branchlabel)); $usermenu .= html_writer::empty_tag('hr', array('class' => 'sep')); } // Output user grade links course sensitive, workaround for frontpage, selecting first enrolled course if ($course->id == 1) { $hascourses = enrol_get_my_courses(NULL, 'visible DESC,id ASC', 1); foreach ($hascourses as $hascourse) { $reportcontext = context_course::instance($hascourse->id); if (has_capability('gradereport/user:view', $reportcontext) && $hascourse->visible) { $branchlabel = '<em><i class="fa fa-list-alt"></i>' . get_string('mygrades', 'theme_campus') . '</em>'; $branchurl = new moodle_url('/grade/report/overview/index.php', array('id' => $hascourse->id, 'userid' => $USER->id)); $usermenu .= html_writer::tag('li', html_writer::link($branchurl, $branchlabel)); } } } else { if (has_capability('gradereport/user:view', $context)) { $branchlabel = '<em><i class="fa fa-list-alt"></i>' . get_string('mygrades', 'theme_campus') . '</em>'; $branchurl = new moodle_url('/grade/report/overview/index.php', array('id' => $course->id, 'userid' => $USER->id)); $usermenu .= html_writer::tag('li', html_writer::link($branchurl, $branchlabel)); // In Course also output Course grade links $branchlabel = '<em><i class="fa fa-list-alt"></i>' . get_string('coursegrades', 'theme_campus') . '</em>'; $branchurl = new moodle_url('/grade/report/user/index.php', array('id' => $course->id, 'userid' => $USER->id)); $usermenu .= html_writer::tag('li', html_writer::link($branchurl, $branchlabel)); } } // Check if badges are enabled. if (!empty($CFG->enablebadges) && has_capability('moodle/badges:manageownbadges', $context)) { $branchlabel = '<em><i class="fa fa-certificate"></i>' . get_string('badges') . '</em>'; $branchurl = new moodle_url('/badges/mybadges.php'); $usermenu .= html_writer::tag('li', html_writer::link($branchurl, $branchlabel)); } $usermenu .= html_writer::end_tag('ul'); $usermenu .= html_writer::end_tag('li'); $usermenu .= html_writer::end_tag('ul'); return $usermenu; }
/** * overridding user_profile_picture function. */ public function user_profile_picture() { GLOBAL $USER; $userpic = parent::user_picture($USER, array('link' => false, 'size' => 28)); return $userpic; }