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; } }