Safely shut down extension hooks.

It was possible to trigger shutting down an extension twice, which could
easily break hooks. Hooks assume they'll be initialized once and shut
down once, but this would break if extensions ever called shutdown on
themselves.

We now check an initialization state on the hook just to be sure before
we do any shutdown work.

Extensions wishing to shut down the hooks should now call
shutdown_hooks() instead of shutdown().
Include query parameters in datagrid pagination links.

The datagrid pagination links had some implementation for preserving query
parameters, but it wasn't very complete. The review board code made sure that
the "user" and "group" parameters were part of it, but that lost all the other
things like sort order and show/hide closed.

I've removed the reviewboard implementation for "user" and "group" (in a
separate change) and instead generalized our existing `get_url_params_except()`
method (from `Column`). Because I hadn't realized that this method exists, I've
also included a refactor from my previous similar API change to use the new
generalized util method.

Other consumers of the datagrid who set extra_context['extra_query'] will be
unaffected by this change because it will overwrite the one that this adds.

Testing done:
Added a bunch of review requests, and checked that the pagination links
preserved "sort", "view", and other query parameters.

Fixes bug 1155.

Reviewed at https://reviews.reviewboard.org/r/5354/