function get_content() { global $OUTPUT; if ($this->content !== NULL) { return $this->content; } global $CFG, $USER, $SESSION, $DB; $this->content = (object) array('text' => '', 'footer' => ''); $this->content->text .= '<noscript>' . get_string('noscript', 'block_helpmenow') . '</noscript>'; # the first time a user loads the block this session try to popout helpmenow_clean_sessions(); # clean up users sessions $popout_url = "{$CFG->wwwroot}/blocks/helpmenow/popout.php"; $contact_list = helpmenow_contact_list::get_plugin(); $contact_list::update_contacts($USER->id); # do stuff that stuff that should be done when a user first logs in if (!isset($SESSION->helpmenow_first_load)) { $SESSION->helpmenow_first_load = true; # try to popout the interface (except if the user is not logged in) if (!empty($USER->id)) { $this->content->text .= <<<EOF <script> try { var popout = window.open('', 'hmn_popout', 'menubar=0,location=0,scrollbars,resizable,width=250,height=400'); if (popout.location.href == "about:blank" || typeof popout.location === 'undefined') { popout.location = "{$popout_url}"; } } catch (error) { } </script> EOF; } # update the users contacts } $this->content->text .= helpmenow_block_interface(); $break = false; if ($contact_list_display = $contact_list::block_display()) { $this->contect->footer .= $contact_list_display; $break = true; } # admin link $sitecontext = context_system::instance(); if (has_capability(HELPMENOW_CAP_MANAGE, $sitecontext)) { $admin = "{$CFG->wwwroot}/blocks/helpmenow/admin/manage_queues.php"; $admin_text = get_string('admin_link', 'block_helpmenow'); if ($break) { $this->content->footer .= "<br />"; } else { $break = true; } $this->content->footer .= "<a href='{$admin}'>{$admin_text}</a>"; } # "hallway" link if (has_capability(HELPMENOW_CAP_MANAGE, $sitecontext) or $DB->record_exists('block_helpmenow_helper', array('userid' => $USER->id))) { $who = get_string('who', 'block_helpmenow'); if ($break) { $this->content->footer .= "<br />"; } else { $break = true; } $this->content->footer .= "<a href='{$CFG->wwwroot}/blocks/helpmenow/hallway.php'>{$who}</a>"; } # Chat histories link $chathistories = get_string('chathistories', 'block_helpmenow'); if ($break) { $this->content->footer .= "<br />"; } else { $break = true; } $chat_history_url = new moodle_url("{$CFG->wwwroot}/blocks/helpmenow/chathistorylist.php"); $chat_history_url->param('userid', $USER->id); $this->content->footer .= "<a href=" . $chat_history_url->out() . ">{$chathistories}</a>"; if ($contact_list::is_admin_or_teacher()) { # call plugin methods to check for additional display information foreach (helpmenow_plugin::get_plugins() as $pluginname) { $class = "helpmenow_plugin_{$pluginname}"; if ($plugindisplay = $class::block_display()) { if ($break) { $this->content->footer .= "<br />"; } else { $break = true; } $this->content->footer .= $plugindisplay; } } } $this->content->footer .= <<<EOF <div id="helpmenow_last_refresh_div"></div> <div class="helpmenow_textalignright"> <div class="helpmenow_floatleft"> <a href="javascript:void(0)" onclick="helpmenow.chime();"> <img src="{$CFG->wwwroot}/blocks/helpmenow/media/Bell.png" /> </a> </div> EOF; $popout = get_string('popout', 'block_helpmenow'); $action = new popup_action('click', $popout_url, 'hmn_popout', array('height' => 400, 'width' => 250)); $this->content->footer .= $OUTPUT->action_link($popout_url, $popout, $action) . '</div>'; return $this->content; }
* * @package block_helpmenow * @copyright 2012 VLACS * @author David Zaharee <*****@*****.**> * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ require_once dirname(dirname(dirname(__FILE__))) . '/config.php'; require_once dirname(__FILE__) . '/lib.php'; require_login(0, false); $PAGE->set_context(context_system::instance()); $PAGE->set_url('/blocks/helpmenow/login.php'); $PAGE->set_pagelayout('standard'); // Add style.css. $PAGE->requires->css('/blocks/helpmenow/style.css'); if (!empty($CFG->helpmenow_title)) { $title = $CFG->helpmenow_title; } else { $title = get_string('helpmenow', 'block_helpmenow'); } $PAGE->set_title($title); echo $OUTPUT->header(); $output = <<<EOF <div class="helpmenow_popup"> <div id="chatDiv" class="helpmenow_chat"> EOF; $output .= helpmenow_block_interface(); $output .= <<<EOF <div id="helpmenow_last_refresh_div" class="helpmenow_last_refresh_div"></div> </div></div></div></body></html> EOF; echo $output;