/** * Returns the webex user that hosts this meeting. * * @return bool|user The WebEx user. False on failure. */ public function get_host_webex_user() { global $USER; $webexuser = false; if (isset($this->hostwebexid)) { try { // Try and load the user for this meetings user. $webexuser = \mod_webexactivity\user::load_webex_id($this->hostwebexid); } catch (\coding_exception $e) { $webexuser = false; } } // If we haven't set it, try and set it to the current user. if (!$webexuser) { $webexuser = \mod_webexactivity\user::load_for_user($USER); } return $webexuser; }
} 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; } } if ($webexuser) { $data = new stdClass(); $data->id = $id; $data->action = 'useredit'; if (isset($webexuser->password)) { $data->password = $webexuser->password; } else {
/** * Get the response from WebEx for a XML message. * * @param string $xml The XML to send to WebEx. * @param user|bool $webexuser The WebEx user to use for auth. False to use the API user. * @return array|bool XML response (as array). False on failure. * @throws webex_xml_exception on XML parse error. */ public function get_response($basexml, $webexuser = false) { global $USER; if (!$webexuser) { $webexuser = user::load_admin_user(); } $xml = type\base\xml_gen::auth_wrap($basexml, $webexuser); list($status, $response, $errors) = $this->fetch_response($xml); if ($status) { return $response; } else { // Bad user password, reset it and try again. if (!$webexuser->isadmin && isset($errors['exception']) && $errors['exception'] === '030002') { if ($webexuser->update_password(self::generate_password())) { $xml = type\base\xml_gen::auth_wrap($basexml, $webexuser); list($status, $response, $errors) = $this->fetch_response($xml); if ($status) { return $response; } } throw new exception\bad_password(); } // Handling of special cases. if (isset($errors['exception']) && $errors['exception'] === '000015') { // No records found (000015), which is not really a failure, return empty array. return array(); } if (isset($errors['exception']) && $errors['exception'] === '030001') { // No user found (030001), which is not really a failure, return empty array. return array(); } if (isset($errors['exception']) && ($errors['exception'] === '030004' || $errors['exception'] === '030005')) { // Username or email already exists. throw new exception\webex_user_collision(); } if (isset($errors['exception']) && $errors['exception'] === '060021') { // The passed user cannot schedule meetings for the WebEx Host ID passed. throw new exception\host_scheduling(); } if (isset($errors['exception']) && $errors['exception'] === '060019') { // The WebEx Host ID doesn't exist. throw new exception\unknown_hostwebexid(); } // Generic exception for other cases. throw new exception\webex_xml_exception($errors['exception'], $errors['message'], $xml); } }
$event->add_record_snapshot('webexactivity', $webexrecord); $event->trigger(); redirect($returnurl->out(false)); } } } } // Do redirect actions here. switch ($action) { case 'hostmeeting': if (!$webexmeeting->is_available(true)) { break; } require_capability('mod/webexactivity:hostmeeting', $context); try { $webexuser = \mod_webexactivity\user::load_for_user($USER); } catch (Exception $e) { $collision = $e instanceof \mod_webexactivity\local\exception\webex_user_collision; $password = $e instanceof \mod_webexactivity\local\exception\bad_password; if ($collision || $password) { \mod_webexactivity\webex::password_redirect($returnurl); } else { throw $e; } throw $e; } if ($webexmeeting->is_admin_created()) { // New style. $webexmeeting->change_webexuser_host($webexuser); $params = array('id' => $id, 'action' => 'hostmeetingerror'); $failurl = new moodle_url($returnurl, $params);
*/ require_once dirname(dirname(dirname(__FILE__))) . '/config.php'; require_once $CFG->libdir . '/adminlib.php'; admin_externalpage_setup('modwebexactivityusers'); $pageurl = new moodle_url('/mod/webexactivity/admin_users.php'); $action = optional_param('action', false, PARAM_ALPHA); switch ($action) { case 'login': // First log the user out (in case they are logged in, then bring back to logintrue. $webexid = required_param('webexid', PARAM_ALPHAEXT); $returnurl = new moodle_url($pageurl, array('action' => 'logintrue', 'webexid' => $webexid)); redirect(\mod_webexactivity\user::get_logout_url($returnurl->out(false))); break; case 'logintrue': // Actually log the user in. $webexid = required_param('webexid', PARAM_ALPHAEXT); $webexuser = \mod_webexactivity\user::load_webex_id($webexid); redirect($webexuser->get_login_url()); break; } // Setup the table for output. $table = new \mod_webexactivity\admin_users_table('webexactivityadminrecordingstable'); $table->define_baseurl($pageurl); $table->set_sql('*', '{webexactivity_user}', '1=1', array()); $table->define_columns(array('firstname', 'lastname', 'email', 'webexid', 'login')); $table->define_headers(array(get_string('firstname'), get_string('lastname'), get_string('email'), get_string('webexid', 'webexactivity'), '')); $table->no_sorting('login'); echo $OUTPUT->header(); // Output the table. $table->out(50, false); echo $OUTPUT->footer();