Add simpleid-1.0.5
diff --git a/simpleid/extensions/hooks.php b/simpleid/extensions/hooks.php
new file mode 100644
index 0000000..24219ce
--- /dev/null
+++ b/simpleid/extensions/hooks.php
@@ -0,0 +1,337 @@
+<?php
+
+/**
+ *
+ * This page lists out all the hooks which are available to SimpleID extensions.
+ *
+ * When implementing these hooks in your extensions, you should replace the word
+ * hook with the name of your extension.
+ *
+ * @package extensions
+ */
+
+/**
+ * Returns an array of type URIs to be included in SimpleID's XRDS document.
+ *
+ * For example:
+ *
+ * <code>
+ * <?php
+ * return array('http://specs.openid.net/extensions/ui/1.0/lang-pref', 'http://specs.openid.net/extensions/ui/1.0/mode/popup');
+ * ?>
+ * </code>
+ *
+ * @return array an array of URIs
+ * @since 0.7
+ */
+function hook_xrds_types() {
+}
+
+/**
+ * Processes an authentication request that is <i>not</i> about an identifier.
+ *
+ * The OpenID specifications provides a mechanism for extensions to process
+ * authentication requests that are not about an identifier. Authentication requests
+ * about identifiers are automatically processed by the {@link simpleid_checkid_identity()}
+ * function and the {@link hook_checkid_identity()} hooks.
+ *
+ * Assertion results are coded within SimpleID as an integer between 127 ({@link CHECKID_OK})
+ * and -127 ({@link CHECKID_PROTOCOL_ERROR}). Positive values indicate a potential
+ * positive assertion (subject to various types of user approval), while negative
+ * values indicate a irrecoverable negative assertion.
+ *
+ * This hook should return one of these values. If the extension is unable to
+ * handle this particular type of authentication request, it should return NULL.
+ *
+ * @param array $request the OpenID request
+ * @param bool $immediate true if openid.mode is checkid_immediate
+ * @return int a return value from the list of possible values returned by
+ * {@link simpleid_checkid_identity()} or NULL
+ * @see simpleid_checkid()
+ */
+function hook_checkid($request, $immediate) {
+}
+
+
+/**
+ * Processes an authentication request where the assertion is potentially
+ * positive.
+ *
+ * Assertion results are coded within SimpleID as an integer between 127 ({@link CHECKID_OK})
+ * and -127 ({@link CHECKID_PROTOCOL_ERROR}). Positive values indicate a potential
+ * positive assertion (subject to various types of user approval), while negative
+ * values indicate a irrecoverable negative assertion.
+ *
+ * Extensions are able to examine the authentication request to modify change
+ * the assertion result from positive to negative. As SimpleID takes the
+ * minimum from the results returned by this hook, extensions are
+ * not able to change the assertion result from negative to positive.
+ *
+ * If the extension is indifferent to the result of the current authentication
+ * request (e.g. it cannot understand it), it should return NULL.
+ *
+ * This hook is not called at all if SimpleID determines that the assertion
+ * is negative.
+ *
+ * @param array $request the OpenID request
+ * @param string $identity the identity to be checked against
+ * @param bool $immediate true if openid.mode is checkid_immediate
+ * @return int a return value from the list of possible values returned by
+ * {@link simpleid_checkid_identity()} or NULL
+ * @see simpleid_checkid_identity()
+ */
+function hook_checkid_identity($request, $identity, $immediate) {
+}
+
+/**
+ * Gets fields and values to be included in the OpenID response.
+ *
+ * For positive assertions, this hook should assume that all user approvals
+ * have been given and return a response array accordingly. The extension has
+ * the opportunity to modify the response what the user has actually approved
+ * in the {@link hook_send() send hook}.
+ *
+ * This hook will need to provide any aliases required.
+ *
+ * An example:
+ *
+ * <code>
+ * <?php
+ * $alias = openid_extension_alias($my_uri);
+ * return array(
+ * 'openid.ns.' . $alias => $my_uri,
+ * 'openid.' . $alias . '.field' => 'value'
+ * );
+ * ?>
+ * </code>
+ *
+ * @param bool $assertion true if a positive assertion is made, false otherwise
+ * @param array $request the OpenID request
+ * @return array the fields and values to include
+ */
+function hook_response($assertion, $request) {
+}
+
+/**
+ * Gets fields associated with this extension which needs to be signed
+ *
+ * SimpleID automatically handles signing fields required by the OpenID
+ * specification, so only the fields introduced by this extension
+ * needed to be returned by this function.
+ *
+ * The array of fields returned by this function must include any applicable
+ * aliases as required. For example
+ *
+ * <code>
+ * <?php
+ * $alias = openid_extension_alias($my_uri);
+ * return array($alias . '.field1', $alias . 'field2');
+ * ?>
+ * </code>
+ *
+ * @param array $response the OpenID response to sign
+ * @return array an array of fields to sign
+ */
+function hook_signed_fields($response) {
+}
+
+/**
+ * Determines the format in which assertions are sent, when they are sent via
+ * indirect communication.
+ *
+ * The OpenID specification version 2.0 provides for the sending of assertions
+ * via indirect communication. The original specifications provide that the
+ * response should be formatted within the query string.
+ *
+ * Some extensions to the OpenID specification allows the assertion to be
+ * formatted in some other way, e.g. via the fragment. This hook allows
+ * extensions to specify which format the assertion should be sent.
+ *
+ * If the extension is indifferent regarding the format, it should return
+ * null
+ *
+ * @param string $url the URL of the RP to which the response is to be sent
+ * @param array $response the assertion to be sent
+ * @return int one of OPENID_RESPONSE_QUERY or OPENID_RESPONSE_FRAGMENT or NULL
+ */
+function hook_indirect_response($url, $response) {
+}
+
+/**
+ * Provides additional form items when displaying the relying party consent
+ * form
+ *
+ *
+ * @param array $request the OpenID request
+ * @param array $response the proposed OpenID response
+ * @param array $rp the user's preferences saved with this relying party
+ * @return string HTML code to be inserted into the verification form
+ * @see simpleid_consent_form()
+ * @deprecated Use {@link hook_consent_form()}
+ */
+function hook_rp_form($request, $response, $rp) {
+}
+
+/**
+ * Provides additional form items when displaying the relying party consent
+ * form
+ *
+ *
+ * @param array $request the OpenID request
+ * @param array $response the proposed OpenID response
+ * @param array $rp the user's preferences saved with this relying party
+ * @return string HTML code to be inserted into the verification form
+ * @see simpleid_consent_form()
+ * @since 0.8
+ */
+function hook_consent_form($request, $response, $rp) {
+}
+
+/**
+ * Processes the relying party consent form.
+ *
+ * This provides the extension with the opportunity to:
+ *
+ * - modify the OpenID response based on the user's preferences by editing
+ * $response
+ * - save the user's preferences by editing $rp
+ *
+ * <strong>WARNING</strong> Because this function requires parameters to be
+ * passed by reference, this does not work with {@link extension_invoke_all()}.
+ *
+ * @param array $form_request the data submitted by the user in the relying
+ * party verification form
+ * @param array &$response pointer to the proposed OpenID response
+ * @param array &$rp pointer to the user's preferences saved with this relying party
+ * @deprecated Use {@link hook_consent()}
+ *
+ */
+function hook_send($form_request, &$response, &$rp) {
+}
+
+/**
+ * Processes the relying party verification form.
+ *
+ * This provides the extension with the opportunity to:
+ *
+ * - modify the OpenID response based on the user's preferences by editing
+ * $response
+ * - save the user's preferences by editing $rp
+ *
+ * <strong>WARNING</strong> Because this function requires parameters to be
+ * passed by reference, this does not work with {@link extension_invoke_all()}.
+ *
+ * @param array $form_request the data submitted by the user in the relying
+ * party verification form
+ * @param array &$response pointer to the proposed OpenID response
+ * @param array &$rp pointer to the user's preferences saved with this relying party
+ * @since 0.8
+ *
+ */
+function hook_consent($form_request, &$response, &$rp) {
+}
+
+/**
+ * Return any additional items provided by the extension to be appended to the
+ * Simpleweb route array.
+ *
+ * @see simpleweb.inc.php
+ * @see simpleid_start()
+ * @return array the routes array
+ * @since 0.7
+ */
+function hook_routes() {
+}
+
+/**
+ * Provides additional form items when displaying the login form
+ *
+ * @param string $destination he SimpleID location to which the user is directed
+ * if login is successful
+ * @param string $state the current SimpleID state, if required by the location
+ * @see user_login_form()
+ */
+function hook_user_login_form($destination, $state) {
+}
+
+/**
+ * Attempts to automatically login using credentials presented by the user agent.
+ *
+ * This hook is called by the {@link user_auto_login()} function. The hook
+ * should detect any credentials present in the request and return a $user array
+ * (loaded using the {@link user_load()} function) if credentials identifying
+ * the user is present.
+ *
+ * If no credentials are present, or the credentials are invalid, this hook
+ * should return NULL.
+ *
+ * @return array the user array, or NULL
+ */
+function hook_user_auto_login() {
+}
+
+/**
+ * Verifies a set of credentials for a specified user.
+ *
+ * A set of credentials comprises:
+ *
+ * - A user name
+ * - Some kind of verifying information, such as a plaintext password, a hashed
+ * password (e.g. digest) or some other kind of identifying information.
+ *
+ * The user name is passed to this function using the $uid parameter. The user
+ * name may or may not exist. If the user name does not exist, this function
+ * <strong>must</strong> return false.
+ *
+ * The credentials are supplied as an array using the $credentials parameter.
+ * Typically this array will be a subset of the $_POST superglobal passed to the
+ * {@link user_login()} function. Thus it will generally contain the keys 'pass' and
+ * 'digest'.
+ *
+ * This hook must check whether the credentials supplied matches the credentials
+ * for the specified user in the store. If for any reason that credentials
+ * do not match, this function <strong>must</strong> return false.
+ *
+ * @param string $uid the name of the user to verify
+ * @param array $credentials the credentials supplied by the browser
+ * @return bool whether the credentials supplied matches those for the specified
+ * user
+ */
+function hook_user_verify_credentials($uid, $credentials) {
+}
+
+
+
+/**
+ * Returns additional blocks to be displayed in the user's dashboard.
+ *
+ * A block is coded as an array in accordance with the specifications set
+ * out in {@link page.inc}.
+ *
+ * This hook should return an <i>array</i> of blocks, i.e. an array of
+ * arrays.
+ *
+ * @see page_dashboard()
+ * @return array an array of blocks to add to the user's dashboard
+ * @since 0.7
+ */
+function hook_page_dashboard() {
+}
+
+/**
+ * Returns additional blocks to be displayed in the user's profile page.
+ *
+ * A block is coded as an array in accordance with the specifications set
+ * out in {@link page.inc}.
+ *
+ * This hook should return an <i>array</i> of blocks, i.e. an array of
+ * arrays.
+ *
+ * @see page_profile()
+ * @return array an array of blocks to add to the user's profile page
+ * @since 0.7
+ */
+function hook_page_profile() {
+}
+
+?>