/** * 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() { $ok = FALSE; if (!$this->isOK) { $ok = $this->onError(); } if (!$ok) { if (!$this->isOK) { # ### If not valid, return an error message to the tool consumer if a return URL is provided # if (!empty($this->return_url)) { $error_url = $this->return_url; 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 = array(); if (isset($_POST['data'])) { $form_params['data'] = $_POST['data']; } $version = isset($_POST['lti_version']) ? $_POST['lti_version'] : LTI_Tool_Provider::LTI_VERSION1; $form_params = $this->consumer->signParameters($error_url, 'ContentItemSelection', $version, $form_params); $page = LTI_Tool_Provider::sendForm($error_url, $form_params); echo $page; } else { header("Location: {$error_url}"); } exit; } else { if (!is_null($this->error_output)) { echo $this->error_output; } 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; } } } } }