HTML Logo by World Wide Web Consortium (www.w3.org). Click to learn more about our commitment to accessibility and standards.

ocPortal Developer's Guide: Users and forums

» Return to Contents



sources/users.php

Global_functions_users.php

Function summary

void init__users ()
void handle_logins ()
boolean is_guest (?MEMBER member_id, boolean quick_only)
MEMBER get_member (boolean quick_only)
string apply_forum_driver_md5_variant (string data, string key)
integer get_session_id ()
boolean is_httpauth_login ()
URLPATH enforce_sessioned_url (URLPATH url)
?AUTO_LINK delete_expired_sessions_or_recover (?MEMBER member)
string get_member_cookie ()
string get_pass_cookie ()
?string ocp_admirecookie (string name, ?string default)
boolean ocp_eatcookie (string name)
string get_ocp_cpf (ID_TEXT cpf, ?MEMBER member)
?array get_online_members (boolean longer_time, ?MEMBER filter, integer count)
boolean member_is_online (MEMBER member_id)
boolean member_blocked (MEMBER member_id, ?MEMBER member_blocker)

void init__users()

Standard code module initialisation function.

Parameters…

(No return value)


Return to the function index for this class Expand: View the source code to this function

void handle_logins()

Handles an attempted login or logout, and take care of all the sessions and cookies etc.

Parameters…

(No return value)


Return to the function index for this class Expand: View the source code to this function

boolean is_guest(?MEMBER member_id, boolean quick_only)

Find whether the current member is a guest.

Parameters…

Name member_id
Description Member ID to check (NULL: current user)
Default value
Type ?MEMBER

Name quick_only
Description Whether to just do a quick check, don't establish new sessions
Default value boolean-false
Type boolean

Returns…

Description Whether the current member is a guest
Type boolean

Return to the function index for this class Expand: View the source code to this function

MEMBER get_member(boolean quick_only)

Get the ID of the currently active member.It see's if the session exists / cookie is valid – and gets the member id accordingly

Parameters…

Name quick_only
Description Whether to just do a quick check, don't establish new sessions
Default value boolean-false
Type boolean

Returns…

Description The member requesting this web page (possibly the guest member - which strictly speaking, is not a member)
Type MEMBER

Return to the function index for this class Expand: View the source code to this function

string apply_forum_driver_md5_variant(string data, string key)

Apply hashing to some input. To this date, all forum drivers use md5, but some use it differently.This function will pass through the parameters to an equivalent forum_md5 function if it is defined.

Parameters…

Name data
Description The data to hash (the password in actuality)
Type string

Name key
Description The string converted member-ID in actuality, although this function is more general
Type string

Returns…

Description The hashed data
Type string

Return to the function index for this class Expand: View the source code to this function

integer get_session_id()

Get the current session ID.

Parameters…

Returns…

Description The current session ID
Type integer

Return to the function index for this class Expand: View the source code to this function

boolean is_httpauth_login()

Find whether the current member is logged in via httpauth.

Parameters…

Returns…

Description Whether the current member is logged in via httpauth
Type boolean

Return to the function index for this class Expand: View the source code to this function

URLPATH enforce_sessioned_url(URLPATH url)

Make sure that the given URL contains a session if cookies are disabled.NB: This is used for login redirection. It had to add the session id into the redirect url.

Parameters…

Name url
Description The URL to enforce results in session persistence for the user
Type URLPATH

Returns…

Description The fixed URL (potentially nothing was done, depending on cookies)
Type URLPATH

Return to the function index for this class Expand: View the source code to this function

?AUTO_LINK delete_expired_sessions_or_recover(?MEMBER member)

Find what sessions are expired and delete them, and recover an existing one for $member if there is one.

Parameters…

Name member
Description User to get a current session for (NULL: do not try, which guarantees a return result of NULL also)
Default value
Type ?MEMBER

Returns…

Description The session id we rebound to (NULL: did not rebind)
Type ?AUTO_LINK

Return to the function index for this class Expand: View the source code to this function

string get_member_cookie()

Get the member cookie's name.

Parameters…

Returns…

Description The member username/id (depending on forum driver) cookie's name
Type string

Return to the function index for this class Expand: View the source code to this function

string get_pass_cookie()

Get the member password cookie's name.

Parameters…

Returns…

Description The member password cookie's name
Type string

Return to the function index for this class Expand: View the source code to this function

?string ocp_admirecookie(string name, ?string default)

Get a cookie value.

Parameters…

Name name
Description The name of the cookie
Type string

Name default
Description The default value (NULL: just use the value NULL)
Default value
Type ?string

Returns…

Description The value stored in the cookie (NULL: the default default)
Type ?string

Return to the function index for this class Expand: View the source code to this function

boolean ocp_eatcookie(string name)

Deletes a cookie (if it exists), from within ocPortal's cookie environment.

Parameters…

Name name
Description The name of the cookie
Type string

Returns…

Description The result of the PHP setcookie command
Type boolean

Return to the function index for this class Expand: View the source code to this function

string get_ocp_cpf(ID_TEXT cpf, ?MEMBER member)

Get the value of a special 'ocp_' custom profile field. For OCF it can also do it for a pure field title, e.g. "Example Field".

Parameters…

Name cpf
Description The CPF name stem
Type ID_TEXT

Name member
Description Member to lookup for (NULL: current member)
Default value
Type ?MEMBER

Returns…

Description The value (blank: has a blank value, or does not exist)
Type string

Return to the function index for this class Expand: View the source code to this function

?array get_online_members(boolean longer_time, ?MEMBER filter, integer count)

Get database rows of all the online members.

Parameters…

Name longer_time
Description Whether to use a longer online-time -- the session expiry-time
Type boolean

Name filter
Description We really only need to make sure we get the status for this user, although at this functions discretion more may be returned and the row won't be there if the user is not online (NULL: no filter). May not be the guest ID
Type ?MEMBER

Name count
Description The total online members, returned by reference
Type integer

Returns…

Description Database rows (NULL: too many)
Type ?array

Return to the function index for this class Expand: View the source code to this function

boolean member_is_online(MEMBER member_id)

Find if a member is online.

Parameters…

Name member_id
Description The member to check
Type MEMBER

Returns…

Description Whether they are online
Type boolean

Return to the function index for this class Expand: View the source code to this function

boolean member_blocked(MEMBER member_id, ?MEMBER member_blocker)

Find if a member is blocked by a member.

Parameters…

Name member_id
Description The member being checked
Type MEMBER

Name member_blocker
Description The member who may be blocking (NULL: current member)
Default value
Type ?MEMBER

Returns…

Description Whether the member is blocked
Type boolean

Return to the function index for this class Expand: View the source code to this function

Fully internal driver functions

sources/forum_stub.php

Global_functions_forum_stub.php

Function summary


void init__forum_stub()

Standard code module initialisation function.

Parameters…

(No return value)


Return to the function index for this class Expand: View the source code to this function

forum_driver_base

Function summary

GROUP get_guest_group ()
mixed member_profile_url (MEMBER id, boolean definitely_profile, boolean tempcode_okay)
tempcode member_profile_hyperlink (MEMBER id, boolean definitely_profile, string _username)
mixed join_url ()
mixed online_members_url ()
mixed member_pm_url (MEMBER id)
mixed forum_url (integer id, boolean tempcode_okay)
?SHORT_TEXT get_username (MEMBER id)
SHORT_TEXT get_member_email_address (MEMBER id)
boolean is_staff (MEMBER id, boolean skip_staff_filter)
boolean disable_staff_filter ()
boolean is_super_admin (MEMBER id)
array get_super_admin_groups ()
array get_moderator_groups ()
array get_usergroup_list (boolean hide_hidden, boolean only_permissive, boolean force_show_all, ?array force_find, ?MEMBER for_member, boolean skip_hidden)
array get_members_groups (MEMBER id, boolean skip_secret, boolean handle_probation)
ID_TEXT get_theme (?ID_TEXT zone_for)
integer get_num_new_forum_posts ()
boolean topic_is_threaded (integer topic_id)
array get_post_remaining_details (AUTO_LINK topic_id, array post_ids)

GROUP get_guest_group()

Find the usergroup id of the forum guest member.

Parameters…

Returns…

Description The usergroup id of the forum guest member
Type GROUP

Return to the function index for this class Expand: View the source code to this function

mixed member_profile_url(MEMBER id, boolean definitely_profile, boolean tempcode_okay)

Get a URL to a forum member's member profile.

Parameters…

Name id
Description The forum member
Type MEMBER

Name definitely_profile
Description Whether to be insistent that we go to the profile, rather than possibly starting an IM which can link to the profile
Default value boolean-false
Type boolean

Name tempcode_okay
Description Whether it is okay to return the result using Tempcode (more efficient, and allows keep_* parameters to propagate which you almost certainly want!)
Default value boolean-false
Type boolean

Returns…

Description The URL
Type mixed

Return to the function index for this class Expand: View the source code to this function

tempcode member_profile_hyperlink(MEMBER id, boolean definitely_profile, string _username)

Get a hyperlink (i.e. HTML link, not just a URL) to a forum member's member profile.

Parameters…

Name id
Description The forum member
Type MEMBER

Name definitely_profile
Description Whether to be insistent that we go to the profile, rather than possibly starting an IM which can link to the profile
Default value boolean-false
Type boolean

Name _username
Description The username (blank: look it up)
Default value
Type string

Returns…

Description The hyperlink
Type tempcode

Return to the function index for this class Expand: View the source code to this function

mixed join_url()

Get a URL to a forum join page.

Parameters…

Returns…

Description The URL
Type mixed

Return to the function index for this class Expand: View the source code to this function

mixed online_members_url()

Get a URL to a forum 'user online' list.

Parameters…

Returns…

Description The URL
Type mixed

Return to the function index for this class Expand: View the source code to this function

mixed member_pm_url(MEMBER id)

Get a URL to send a forum member a PM.

Parameters…

Name id
Description The forum member
Type MEMBER

Returns…

Description The URL
Type mixed

Return to the function index for this class Expand: View the source code to this function

mixed forum_url(integer id, boolean tempcode_okay)

Get a URL to a forum.

Parameters…

Name id
Description The ID of the forum
Type integer

Name tempcode_okay
Description Whether it is okay to return the result using Tempcode (more efficient)
Default value boolean-false
Type boolean

Returns…

Description The URL
Type mixed

Return to the function index for this class Expand: View the source code to this function

?SHORT_TEXT get_username(MEMBER id)

Get a member's username.

Parameters…

Name id
Description The member
Type MEMBER

Returns…

Description The username (NULL: deleted member)
Type ?SHORT_TEXT

Return to the function index for this class Expand: View the source code to this function

SHORT_TEXT get_member_email_address(MEMBER id)

Get a member's e-mail address.

Parameters…

Name id
Description The member
Type MEMBER

Returns…

Description The e-mail address (blank: not known)
Type SHORT_TEXT

Return to the function index for this class Expand: View the source code to this function

boolean is_staff(MEMBER id, boolean skip_staff_filter)

Find whether a member is staff.

Parameters…

Name id
Description The member
Type MEMBER

Name skip_staff_filter
Description Whether to avoid checking the staff filter (i.e. ignore M.S.N.'s)
Default value boolean-false
Type boolean

Returns…

Description The answer
Type boolean

Return to the function index for this class Expand: View the source code to this function

boolean disable_staff_filter()

If we can't get a list of admins via a usergroup query, we have to disable the staff filter - else the staff filtering can cause disaster at the point of being turned on (because it can't automatically sync).

Parameters…

Returns…

Description Whether the staff filter is disabled
Type boolean

Return to the function index for this class Expand: View the source code to this function

boolean is_super_admin(MEMBER id)

Find whether a member is a super administrator.

Parameters…

Name id
Description The member
Type MEMBER

Returns…

Description The answer
Type boolean

Return to the function index for this class Expand: View the source code to this function

array get_super_admin_groups()

Get a list of the super admin usergroups.

Parameters…

Returns…

Description The list of usergroups
Type array

Return to the function index for this class Expand: View the source code to this function

array get_moderator_groups()

Get a list of the moderator usergroups.

Parameters…

Returns…

Description The list of usergroups
Type array

Return to the function index for this class Expand: View the source code to this function

array get_usergroup_list(boolean hide_hidden, boolean only_permissive, boolean force_show_all, ?array force_find, ?MEMBER for_member, boolean skip_hidden)

Get a map of forum usergroups (id=>name).

Parameters…

Name hide_hidden
Description Whether to obscure the name of hidden usergroups
Default value boolean-false
Type boolean

Name only_permissive
Description Whether to only grab permissive usergroups
Default value boolean-false
Type boolean

Name force_show_all
Description Do not limit things even if there are huge numbers of usergroups
Default value boolean-false
Type boolean

Name force_find
Description Usergroups that must be included in the results (NULL: no extras must be)
Default value
Type ?array

Name for_member
Description Always return usergroups of this member (NULL: current member)
Default value
Type ?MEMBER

Name skip_hidden
Description Whether to completely skip hidden usergroups
Default value boolean-false
Type boolean

Returns…

Description The map
Type array

Return to the function index for this class Expand: View the source code to this function

array get_members_groups(MEMBER id, boolean skip_secret, boolean handle_probation)

Get a list of usergroups a member is in.

Parameters…

Name id
Description The member
Type MEMBER

Name skip_secret
Description Whether to skip looking at secret usergroups.
Default value boolean-false
Type boolean

Name handle_probation
Description Whether to take probation into account
Default value boolean-true
Type boolean

Returns…

Description The list of usergroups
Type array

Return to the function index for this class Expand: View the source code to this function

ID_TEXT get_theme(?ID_TEXT zone_for)

Get the current member's theme identifier.

Parameters…

Name zone_for
Description The zone we are getting the theme for (NULL: current zone)
Default value
Type ?ID_TEXT

Returns…

Description The theme identifier
Type ID_TEXT

Return to the function index for this class Expand: View the source code to this function

integer get_num_new_forum_posts()

Get the number of new forum posts on the system in the last 24 hours.

Parameters…

Returns…

Description Number of forum posts
Type integer

Return to the function index for this class Expand: View the source code to this function

boolean topic_is_threaded(integer topic_id)

Find whether a forum is threaded.

Parameters…

Name topic_id
Description The topic ID
Type integer

Returns…

Description Whether it is
Type boolean

Return to the function index for this class Expand: View the source code to this function

array get_post_remaining_details(AUTO_LINK topic_id, array post_ids)

Load extra details for a list of posts. Does not need to return anything if forum driver doesn't support partial post loading (which is only useful for threaded topic partial-display).

Parameters…

Name topic_id
Description Topic the posts come from
Type AUTO_LINK

Name post_ids
Description List of post IDs
Type array

Returns…

Description Extra details
Type array

Return to the function index for this class Expand: View the source code to this function

Drivers may define extra methods, that are called directly, if they exist.

Code (php)

$output = forum_create_cookie($id,$name,$password);

This function will create an auth cookie based on the input parameters. It is defined for forums that don't store plain-hashed cookies.