/** * Perform the result of an action. * * This function may redirect the user to another URL rather than returning a value. * * @return string Output to be displayed (redirection, or display HTML or message) */ private function result() { // TODO: Call $this->onError(); hook // FIXME: Should be executed when exception is caught if (false) { // If not valid, return an error message to the tool consumer if a return URL is provided if (!empty($this->returnUrl)) { $error_url = $this->returnUrl; if (strpos($error_url, '?') === false) { $error_url .= '?'; } else { $error_url .= '&'; } if ($this->debugMode && !is_null($this->reason)) { $error_url .= 'lti_errormsg=' . urlencode("Debug error: {$this->reason}"); } else { $error_url .= 'lti_errormsg=' . urlencode($this->message); if (!is_null($this->reason)) { $error_url .= '<i_errorlog=' . urlencode("Debug error: {$this->reason}"); } } if (!is_null($this->consumer) && isset($_POST['lti_message_type']) && $_POST['lti_message_type'] === 'ContentItemSelectionRequest') { $form_params = []; if (isset($_POST['data'])) { $form_params['data'] = $_POST['data']; } $version = isset($_POST['lti_version']) ? $_POST['lti_version'] : ToolProvider::LTI_VERSION1; $form_params = $this->consumer->signParameters($error_url, 'ContentItemSelection', $version, $form_params); $page = ToolProvider::sendForm($error_url, $form_params); echo $page; } else { header("Location: {$error_url}"); } exit; } else { if (!is_null($this->errorOutput)) { echo $this->errorOutput; } else { if ($this->debugMode && !empty($this->reason)) { echo "Debug error: {$this->reason}"; } else { echo "Error: {$this->message}"; } } } } else { if (!is_null($this->redirectUrl)) { header("Location: {$this->redirectUrl}"); exit; } else { if (!is_null($this->output)) { echo $this->output; } } } }