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; }
* @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); // Date is a string representation of the starting date for the history to be // shown. "-1 year" is default, but a date such as "20130610" will work also // This limits by the session creation date, so it may not be exact. $date = optional_param('date', '', PARAM_TEXT); if (!$date) { $date = strtotime("-1 year"); } else { $date = strtotime($date); } $contact_list = helpmenow_contact_list::get_plugin(); $is_admin = $contact_list::is_admin(); # verify session $sessionid = required_param('session', PARAM_INT); if (!(helpmenow_verify_session($sessionid) or $is_admin)) { helpmenow_fatal_error(get_string('permission_error', 'block_helpmenow')); } $session = $DB->get_record('block_helpmenow_session', array('id' => $sessionid)); # title $sql = "\n SELECT u.*\n FROM {block_helpmenow_session2user} s2u\n JOIN {user} u ON u.id = s2u.userid\n WHERE s2u.sessionid = {$sessionid}\n "; $chat_users = $DB->get_records_sql($sql); $other_users = array(); $i = 0; $joinlist = ''; foreach ($chat_users as $r) { $other_users[] = fullname($r);
function helpmenow_block_interface() { global $CFG, $USER, $OUTPUT, $DB; helpmenow_ensure_user_exists(); $output = ''; $output .= <<<EOF <div id="helpmenow_queue_div"></div> EOF; $contact_list = helpmenow_contact_list::get_plugin(); if ($contact_list::is_teacher()) { $helpmenow_user = $DB->get_record('block_helpmenow_user', array('userid' => $USER->id)); $instyle = $outstyle = ''; if ($helpmenow_user->isloggedin) { $outstyle = 'style="display: none;"'; } else { $instyle = 'style="display: none;"'; } $login_url = new moodle_url("{$CFG->wwwroot}/blocks/helpmenow/login.php"); $login_url->param('login', 0); $action = new popup_action('click', $login_url->out(), "login", array('height' => 400, 'width' => 500)); $logout = $OUTPUT->action_link($login_url->out(), get_string('leave_office', 'block_helpmenow'), $action); $login_url->param('login', 1); $action = new popup_action('click', $login_url->out(), "login", array('height' => 400, 'width' => 500)); $login = $OUTPUT->action_link($login_url->out(), get_string('enter_office', 'block_helpmenow'), $action); $my_office = get_string('my_office', 'block_helpmenow'); $out_of_office = get_string('out_of_office', 'block_helpmenow'); $online_students = get_string('online_students', 'block_helpmenow'); $output .= <<<EOF <div id="helpmenow_office"> <div><b>{$my_office}</b></div> <div id="helpmenow_motd" onclick="helpmenow.block.toggleMOTD(true);" style="border:1px dotted black; width:12em; min-height:1em; padding:.2em; margin-top:.5em;">{$helpmenow_user->motd}</div> <textarea id="helpmenow_motd_edit" onkeypress="return helpmenow.block.keypressMOTD(event);" onblur="helpmenow.block.toggleMOTD(false)" style="display:none; margin-top:.5em;" rows="4" cols="22"></textarea> <div style="text-align: center; font-size:small; margin-top:.5em;"> <div id="helpmenow_logged_in_div_0" {$instyle}>{$logout}</div> <div id="helpmenow_logged_out_div_0" {$outstyle}>{$out_of_office} | {$login}</div> </div> <div style="margin-top:.5em;">{$online_students}</div> <div id="helpmenow_users_div"></div> </div> EOF; } else { if ($contact_list::is_student()) { $output .= ' <div>' . get_string('instructors', 'block_helpmenow') . '</div> <div id="helpmenow_users_div"></div> '; } } $jplayer = helpmenow_jplayer(); $version = HELPMENOW_CLIENT_VERSION; if (!empty($CFG->helpmenow_title)) { $titlename = $CFG->helpmenow_title; } else { $titlename = get_string('helpmenow', 'block_helpmenow'); } $output .= <<<EOF <hr /> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script> {$jplayer} <script src="{$CFG->wwwroot}/blocks/helpmenow/javascript/lib/jquery.titlealert.js" type="text/javascript"></script> <script src="{$CFG->wwwroot}/blocks/helpmenow/javascript/lib/json2.js" type="text/javascript"></script> <script type="text/javascript" src="{$CFG->wwwroot}/blocks/helpmenow/javascript/client/{$version}/lib.js"></script> <script type="text/javascript" src="{$CFG->wwwroot}/blocks/helpmenow/javascript/client/{$version}/block.js"></script> <script type="text/javascript"> helpmenow.setServerURL("{$CFG->wwwroot}/blocks/helpmenow/ajax.php"); helpmenow.setTitleName("{$titlename}"); </script> <div id="helpmenow_chime"></div> EOF; return $output; }