Functions

Check to see if some content may be viewed. Exit with an access denied if not.

check_privacy(\ID_TEXT $content_type, \ID_TEXT $content_id, \?MEMBER $viewing_member_id = null
package content_privacy

Parameters

$content_type

\ID_TEXT

The content type

$content_id

\ID_TEXT

The content ID

$viewing_member_id

\?MEMBER

Viewing member to check privacy against (null: current member)

Delete privacy data.

delete_privacy_form_fields(\ID_TEXT $content_type, \ID_TEXT $content_id) : boolean
package content_privacy

Parameters

$content_type

\ID_TEXT

The content type

$content_id

\ID_TEXT

The content ID

Returns

booleanWhether it deleted something

Get form fields for setting content privacy.

get_privacy_form_fields(\?ID_TEXT $content_type, \?ID_TEXT $content_id = null, boolean $show_header = true, string $prefix = '') : \Tempcode
package content_privacy

Parameters

$content_type

\?ID_TEXT

The content type (null: could be multiple)

$content_id

\?ID_TEXT

The content ID (null: adding)

$show_header

boolean

Whether to show a header to separate the settings out

$prefix

string

Prefix for field naming

Returns

\TempcodeThe form fields

Get the SQL extension clauses for implementing privacy.

get_privacy_where_clause(\ID_TEXT $content_type, \ID_TEXT $table_alias, \?MEMBER $viewing_member_id = null, string $additional_or = '', \?MEMBER $submitter = null) : array
package content_privacy

Parameters

$content_type

\ID_TEXT

The content type

$table_alias

\ID_TEXT

The table alias in the main query

$viewing_member_id

\?MEMBER

Viewing member to check privacy against (null: current member)

$additional_or

string

Additional OR clause for letting the user through

$submitter

\?MEMBER

Member owning the content (null: do dynamically in query via content hook). Usually pass as NULL

Returns

arrayA tuple: extra JOIN clause, extra WHERE clause, table clause (rarely used), direct table WHERE clause (rarely used)

Check to see if some content may be viewed.

has_privacy_access(\ID_TEXT $content_type, \ID_TEXT $content_id, \?MEMBER $viewing_member_id = null) : boolean
package content_privacy

Parameters

$content_type

\ID_TEXT

The content type

$content_id

\ID_TEXT

The content ID

$viewing_member_id

\?MEMBER

Viewing member to check privacy against (null: current member)

Returns

booleanWhether there is access

Find list of members who may view some content.

privacy_limits_for(\ID_TEXT $content_type, \ID_TEXT $content_id, boolean $strict_all = false) : \?array
package content_privacy

Parameters

$content_type

\ID_TEXT

The content type

$content_id

\ID_TEXT

The content ID

$strict_all

boolean

Whether to get a full list including friends even when there are over a thousand friends

Returns

\?arrayA list of member IDs that have access (null: no restrictions)

Reading privacy settings from the POST environment.

read_privacy_fields(string $prefix = '') : array
package content_privacy

Parameters

$prefix

string

Prefix for field naming

Returns

arrayA pair: the privacy level, the list of usernames

Actualise form data for setting content privacy.

save_privacy_form_fields(\ID_TEXT $content_type, \?ID_TEXT $content_id, \ID_TEXT $privacy_level, array $additional_access, boolean $send_invites = true) : boolean
package content_privacy
set members friends staff guests

Parameters

$content_type

\ID_TEXT

The content type

$content_id

\?ID_TEXT

The content ID (null: adding)

$privacy_level

\ID_TEXT

The privacy level

$additional_access

array

A list of usernames

$send_invites

boolean

Whether to send out invite notifications (only do this is it is a new content entry, rather than something obscure, like a member's photo)

Returns

booleanWhether it saved something