switch ($action) { case 'useredit': $view = 'useredit'; // Load the form for recording editing. $mform = new \mod_webexactivity\useredit_form(); if ($mform->is_cancelled()) { \mod_webexactivity\webex::password_return_redirect(); } else { if ($fromform = $mform->get_data()) { $webexuser = \mod_webexactivity\user::load_for_user($user, false); if (!$webexuser) { throw new coding_exception('An unknown error occurred while trying to reload the user'); } $webexuser->password = $fromform->password; $webexuser->save_to_db(); \mod_webexactivity\webex::password_return_redirect(); } else { $webexuser = false; try { $webexuser = \mod_webexactivity\user::load_for_user($user); } catch (\mod_webexactivity\local\exception\webexactivity_exception $e) { // TODO: Should not be needed after 0.2.0. $webexuser = \mod_webexactivity\user::create(); $webexuser->moodleuserid = $id; $webexuser->email = $user->email; if ($webexuser->update_from_webex()) { $webexuser->save_to_db(); } else { $webexuser = false; } }
/** * Get the link for external users to join the meeting. * * @return string The external join url. */ public function get_external_join_url() { $baseurl = \mod_webexactivity\webex::get_base_url(); if (!isset($this->eventid)) { $this->get_info(true); } $url = $baseurl . '/k2/j.php?ED=' . $this->eventid . '&UID=1'; return $url; }
/** * Update an WebEx Meeting instance. * * @param stdClass $data Form data * @param mod_assign_mod_form $form The form * @return bool If the update passed (true) or failed */ function webexactivity_update_instance($data, $mform) { global $PAGE; $cmid = $data->coursemodule; $cm = get_coursemodule_from_id('webexactivity', $cmid, 0, false, MUST_EXIST); $meeting = \mod_webexactivity\meeting::load($cm->instance); $meeting->starttime = $data->starttime; $meeting->duration = $data->duration; if (isset($data->longavailability)) { $meeting->endtime = $data->endtime; } else { $meeting->endtime = null; } $meeting->intro = $data->intro; $meeting->introformat = $data->introformat; $meeting->name = $data->name; $meeting->course = $data->course; if (isset($data->password) && !empty($data->password)) { $meeting->password = $data->password; } else { $meeting->password = null; } if (isset($data->studentdownload) && $data->studentdownload) { $meeting->studentdownload = 1; } else { $meeting->studentdownload = 0; } try { return $meeting->save(); } catch (Exception $e) { $collision = $e instanceof \mod_webexactivity\exception\webex_user_collision; $password = $e instanceof \mod_webexactivity\exception\bad_password; if ($collision || $password) { \mod_webexactivity\webex::password_redirect($PAGE->url); } else { throw $e; } throw $e; } }
/** * Save this recording object into WebEx. * * @return bool True on success, false on failure. */ public function save_to_webex() { $params = new \stdClass(); $params->recordingid = $this->__get('recordingid'); $params->name = $this->recording->name; $xml = type\base\xml_gen::update_recording($params); $webex = new webex(); $response = $webex->get_response($xml); if ($response) { $this->webexchange = false; return true; } else { return false; } }
if ($webexmeeting->is_admin_created()) { // New style. $webexmeeting->change_webexuser_host($webexuser); $params = array('id' => $id, 'action' => 'hostmeetingerror'); $failurl = new moodle_url($returnurl, $params); $authurl = $webexmeeting->get_authed_host_url($failurl->out(false), $returnurl->out(false)); } else { // Old style (pre 0.2.0). $webexmeeting->add_webexuser_host($webexuser); $hosturl = $webexmeeting->get_host_url($returnurl); $params = array('id' => $id, 'action' => 'hostmeetingerror'); $failurl = new moodle_url($returnurl, $params); try { $authurl = $webexuser->get_login_url($failurl->out(false), $hosturl); } catch (\mod_webexactivity\local\exception\bad_password $e) { \mod_webexactivity\webex::password_redirect($returnurl); } } if (empty($SESSION->mod_webexactivity_sestype) || $SESSION->mod_webexactivity_sestype != $webexmeeting::TYPE_CODE) { $SESSION->mod_webexactivity_sestype = $webexmeeting::TYPE_CODE; $hostreturnurl = $returnurl . "&action=hostmeeting"; $switchmturl = $webexmeeting->get_switch_meeting_type_ulr($webexmeeting::TYPE_CODE, $hostreturnurl); redirect($switchmturl); } else { redirect($authurl); } break; case 'joinmeeting': if (!$webexmeeting->is_available()) { break; }
/** * Load user info from WebEx. * * @param string $webexid WebEx ID of the user to get info for. * @return array|bool array of user info, false if failed. */ public static function get_webex_info($webexid) { $webex = new webex(); $xml = xml_gen::get_user_info($webexid); $response = $webex->get_response($xml); if (!$response) { // Not found (or maybe another error). return false; } return $response; }
/** * Get the link to switch meeting type for further URL API requests * * @param string $mtype Meeting type to switch to * @param string $returnurl The url to return the use to. * @return string The url for switching meeting type */ public function get_switch_meeting_type_ulr($mtype = 'MC', $returnurl = false) { $baseurl = \mod_webexactivity\webex::get_base_url(); $url = $baseurl . "/o.php?AT=ST&SP=" . $mtype; if ($returnurl) { $url .= '&BU=' . urlencode($returnurl); } return $url; }