/** * 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; }
/** * 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; } }
/** * 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); } }