Cover API

The file include/sessions.php contains functions to enable interaction with the Cover API.

Most interactions are based on cookies and therefore need an active local instance of the Cover website. If a local instance should be used, it can be configured by setting the Rack configuration options COVER_API_URL, COVER_COOKIE_NAME, COVER_LOGIN_URL and COVER_LOGOUT_URL.

Functions

get_cover_session()
Returns a PHP object with the information about the user that is logged in on the Cover website. Returns null is user is not logged in on the Cover website.

cover_session_logged_in()
Returns true if a user is logged in on the Cover website. Returns false otherwise.

cover_login_url($next_url=null)
Returns a string with the login url of the Cover website and optionally injects the URL the user should be redirected to after logging in.

cover_logout_url($next_url=null)
Analogous to cover_login_url.

cover_session_get_committees()
Returns an associative array of 'committee_login' => 'committee_name' pairs of the committees the user is in, or an empty array if no user is logged in.

cover_session_in_committee($committee_login)
Returns true if the logged in user is a member of the committee. Returns false otherwise or if not user is logged in. An array of multiple committee logins can be provided to check if the user is a member of one of these committees.

cover_get_json($method, array $data = array(), $use_session = true)
Issues a GET request to a $method of the Cover API.