redirect($user2plugin->presenter_url); } if ($user2plugin->verify_active_meeting(true)) { $js = <<<EOF close(); EOF; } else { $user2plugin->create_meeting(); # create meeting only if we don't have one $js = <<<EOF window.name = 'wiziq_session'; window.location.replace("{$user2plugin->presenter_url}") EOF; } if (!helpmenow_wiziq_invite($session_id, $user2plugin->class_id)) { helpmenow_fatal_error('Could not insert message record'); } echo <<<EOF <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" > <head> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script> <script type="text/javascript"> \$(document).ready(function () { {$js} }); </script> </head> <body> </body>
$i += 1; } $title = get_string('chat_history', 'block_helpmenow') . ': ' . implode(', ', $other_users); $sql = "\n SELECT s.id\n FROM {block_helpmenow_session} s\n {$joinlist}\n WHERE s.timecreated > {$date}\n "; $messages = ''; $sessionids = array(); if ($sessions = $DB->get_records_sql($sql)) { foreach ($sessions as $s) { $sessionids[] = $s->id; } $sessionids = implode(', ', $sessionids); if ($history = helpmenow_get_history_list($sessionids)) { $messages = helpmenow_format_messages_history(helpmenow_filter_messages_history($history), ''); } } else { helpmenow_fatal_error(get_string('history_not_available', 'block_helpmenow')); } echo <<<EOF <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" > <head> <title>{$title}</title> <link rel="stylesheet" type="text/css" href="{$CFG->wwwroot}/blocks/helpmenow/style/history.css" /> </head> <body> <div id="titleDiv"><b>{$title}</b></div> <div id="chatDiv"> {$messages} <div id="recent"></div> </div>
} // Only add user if the session doesn't already exist. if (!$DB->record_exists('block_helpmenow_session2user', array('userid' => $USER->id, 'sessionid' => $sessionid))) { helpmenow_add_user($USER->id, $session->id); } } else { # users connecting to users or users making new queue sessions # build sql to check for existing sesssions $sql = "\n SELECT s.*\n FROM {block_helpmenow_session2user} s2u\n JOIN {block_helpmenow_session} s ON s2u.sessionid = s.id\n "; if ($userid) { $sql .= "\n JOIN {block_helpmenow_session2user} s2u2 ON s2u2.sessionid = s.id AND s2u2.userid <> s2u.userid\n WHERE s2u2.userid = {$userid}\n AND s.queueid IS NULL\n "; } else { if ($queueid) { $sql .= " WHERE s.queueid = {$queueid} "; } else { helpmenow_fatal_error(get_string('permission_error', 'block_helpmenow')); } } $sql .= "\n AND s2u.userid = {$USER->id}\n AND s.iscurrent = 1\n "; if (!($session = $DB->get_record_sql($sql))) { # if we don't have a current session, create one $session = (object) array('timecreated' => time(), 'iscurrent' => 1, 'createdby' => $USER->id); if ($queueid) { $session->queueid = $queueid; } $session->id = $DB->insert_record('block_helpmenow_session', $session); # add user(s) helpmenow_add_user($USER->id, $session->id, time()); if ($userid) { helpmenow_add_user($userid, $session->id); }
if (!$session_id) { $sitecontext = context_system::instance(); if (!has_capability(HELPMENOW_CAP_MANAGE, $sitecontext)) { redirect(); } } else { # verify sesion if (!helpmenow_verify_session($session_id)) { helpmenow_fatal_error('You do not have permission to view this page.'); } if (!($s2p_rec = $DB->get_record('block_helpmenow_s2p', array('sessionid' => $session_id, 'plugin' => 'wiziq')))) { helpmenow_fatal_error('Invalid session.'); } $s2p = new helpmenow_session2plugin_wiziq(null, $s2p_rec); if (!in_array($class_id, $s2p->classes)) { helpmenow_fatal_error('Invalid class.'); } } if ($user2plugin = helpmenow_user2plugin_wiziq::get_user2plugin()) { if ($user2plugin->class_id == $class_id) { redirect($user2plugin->presenter_url); } } $response = helpmenow_wiziq_add_attendee($class_id); if (debugging()) { print_object($response); } if ((string) $response['status'] == 'fail') { helpmenow_fatal_error('You were unable to join the session. It may no longer be active.'); } redirect((string) $response->add_attendees->attendee_list->attendee[0]->attendee_url);
* to handle that by presenting links to the user instead of auto redirecting */ $redirects = array(); foreach (helpmenow_plugin::get_plugins() as $pluginname) { $class = "helpmenow_plugin_{$pluginname}"; $method = $login ? 'on_login' : 'on_logout'; if (!method_exists($class, $method)) { continue; } $returned = $class::$method(); if (!is_bool($returned)) { $redirects[$pluginname] = $returned; } } if (count($redirects) == 0) { helpmenow_fatal_error(get_string('may_close', 'block_helpmenow'), true, true); } if (count($redirects) == 1) { redirect(reset($redirects)); } $output = '<p>' . get_string('multiple_plugins', 'block_helpmenow') . '</p>'; foreach ($redirects as $pluginname => $redirect) { $action = new popup_action('click', $redirect, $pluginname, array('height' => 400, 'width' => 500)); $output .= $OUTPUT->action_link($redirect, $pluginname, $action) . "<br />"; } $title = get_string('helpmenow', 'block_helpmenow'); $nav = array(array('name' => $title)); foreach ($nav as $node) { $PAGE->navbar->add($node['name'], isset($node['link']) ? $node['link'] : null); } $PAGE->set_title($title);
/** * This script creates g2m sessions * * @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(dirname(dirname(__FILE__))))) . '/config.php'; require_once dirname(__FILE__) . '/lib.php'; require_login(0, false); # make sure user is instructor or helper $user = $DB->get_record('block_helpmenow_user', array('userid' => $USER->id)); $helper = $DB->get_records('block_helpmenow_helper', array('userid' => $USER->id)); if (!$user and !$helper) { helpmenow_fatal_error('You do not have permission to view this page.'); } # make sure we've got a gotomeeting user2plugin record with a token $token_url = new moodle_url("{$CFG->wwwroot}/blocks/helpmenow/plugins/gotomeeting/token.php"); $token_url->param('redirect', qualified_me()); $token_url = $token_url->out(); if ($record = $DB->get_record('block_helpmenow_user2plugin', array('userid' => $USER->id, 'plugin' => 'gotomeeting'))) { $user2plugin = new helpmenow_user2plugin_gotomeeting(null, $record); } else { $user2plugin = new helpmenow_user2plugin_gotomeeting(); $user2plugin->userid = $USER->id; $user2plugin->insert(); redirect($token_url); } # check to see if the oauth token has expired if ($user2plugin->token_expiration < time()) {
* This script invites users to adobe connect sessions and then redirects the * inviter as well. * * @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(dirname(dirname(__FILE__))))) . '/config.php'; require_once dirname(__FILE__) . '/lib.php'; $testing = optional_param('testing', 0, PARAM_BOOL); $username = required_param('username', PARAM_TEXT); if (!empty($CFG->helpmenow_adobeconnect_url)) { $url = $CFG->helpmenow_adobeconnect_url . "/{$username}"; } else { helpmenow_fatal_error('This page has not been configured for adobe connect.'); } $PAGE->set_context(context_system::instance()); $PAGE->set_url('/blocks/helpmenow/plugins/adobeconnect/meetnow.php'); $PAGE->set_pagelayout('standard'); $heading = $CFG->helpmenow_adobeconnect_orgname . '-Adobe Connect Redirector'; $PAGE->set_title($heading); $PAGE->set_heading($heading); echo $OUTPUT->header(); $me = new moodle_url("{$CFG->wwwroot}/blocks/helpmenow/plugins/adobeconnect/meetnow.php"); $me->param('username', $username); $me = $me->out(); $logo = $CFG->helpmenow_adobeconnect_logourl; print <<<EOF <img src="{$logo}" width="287px"/> <div id="message"></div>
/** * Create the meeting. */ public function create_meeting() { global $CFG, $USER; $update_url = new moodle_url("{$CFG->wwwroot}/blocks/helpmenow/plugins/wiziq/update.php"); $update_url->param('user_id', $USER->id); $params = array('title' => fullname($USER), 'start_time' => date('m/d/Y G:i:s'), 'time_zone' => date('e'), 'presenter_id' => $USER->id, 'presenter_name' => fullname($USER), 'duration' => HELPMENOW_WIZIQ_DURATION, 'status_ping_url' => $update_url->out()); $response = helpmenow_wiziq_api('create', $params); if ((string) $response['status'] == 'fail') { $error = (int) $response->error['code']; $error_msg = (string) $response->error['msg']; helpmenow_log($USER->id, 'wiziq_error', "code: {$error}; msg: {$error_msg}"); switch ($error) { case 1012: helpmenow_fatal_error('License limit has been reached. Please contact your administrator'); default: helpmenow_fatal_error("WizIQ error: {$error}. Please contact your administrator.<br />Error: {$error_msg}"); } } $this->class_id = (int) $response->create->class_details->class_id; $this->presenter_url = (string) $response->create->class_details->presenter_list->presenter[0]->presenter_url; $this->duration = HELPMENOW_WIZIQ_DURATION * 60; # we're saving in seconds instead of minutes $this->timecreated = time(); $this->last_updated = time(); $this->update(); return true; }