/**
  * Returns the webex user that created this meeting.
  *
  * @return bool|user    The WebEx user. False on failure.
  */
 public function get_creator_webex_user()
 {
     $webexuser = false;
     if (isset($this->creatorwebexid)) {
         try {
             // Try and load the user for this meetings user.
             $webexuser = \mod_webexactivity\user::load_webex_id($this->creatorwebexid);
         } catch (\coding_exception $e) {
             $webexuser = false;
         }
     }
     // If we haven't set it, try and set it to the admin user.
     if (!$webexuser) {
         $webexuser = \mod_webexactivity\user::load_admin_user();
     }
     return $webexuser;
 }
 /**
  * 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);
     }
 }