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: Attachments

» Return to Contents



sources/attachments.php

Global_functions_attachments.php

Function summary

void attachments_script ()
boolean has_attachment_access (MEMBER member, AUTO_LINK id, ?object connection)
void attachment_popup_script ()
tempcode render_attachment (ID_TEXT tag, array attributes, array attachment, string pass_id, MEMBER source_member, boolean as_admin, object connection, ?array highlight_bits, ?MEMBER on_behalf_of_member, boolean semiparse_mode)

void attachments_script()

Show the image of an attachment/thumbnail.

Parameters…

(No return value)


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

boolean has_attachment_access(MEMBER member, AUTO_LINK id, ?object connection)

Find if the specified member has access to view the specified attachment.

Parameters…

Name member
Description The member being checked whether to have the access
Type MEMBER

Name id
Description The ID code for the attachment being checked
Type AUTO_LINK

Name connection
Description The database connection to use (NULL: site DB)
Default value
Type ?object

Returns…

Description Whether the member has attachment access
Type boolean

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

void attachment_popup_script()

Shows an HTML page of all attachments we can access with selection buttons.

Parameters…

(No return value)


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

tempcode render_attachment(ID_TEXT tag, array attributes, array attachment, string pass_id, MEMBER source_member, boolean as_admin, object connection, ?array highlight_bits, ?MEMBER on_behalf_of_member, boolean semiparse_mode)

Get tempcode for a Comcode rich-media attachment.

Parameters…

Name tag
Description The attachment tag
Type ID_TEXT
Values restricted to attachment attachment_safe attachment2

Name attributes
Description A map of the attributes (name=>val) for the tag
Type array

Name attachment
Description A map of the attachment properties (name=>val) for the attachment
Type array

Name pass_id
Description A special identifier to mark where the resultant tempcode is going to end up (e.g. the ID of a post)
Type string

Name source_member
Description The member who is responsible for this Comcode
Type MEMBER

Name as_admin
Description Whether to check as arbitrary admin
Type boolean

Name connection
Description The database connection to use
Type object

Name highlight_bits
Description A list of words to highlight (NULL: none)
Default value
Type ?array

Name on_behalf_of_member
Description The member we are running on behalf of, with respect to how attachments are handled; we may use this members attachments that are already within this post, and our new attachments will be handed to this member (NULL: member evaluating)
Default value
Type ?MEMBER

Name semiparse_mode
Description Whether to parse so as to create something that would fit inside a semihtml tag. It means we generate HTML, with Comcode written into it where the tag could never be reverse-converted (e.g. a block).
Default value boolean-false
Type boolean

Returns…

Description The tempcode for the attachment
Type tempcode

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

sources/attachments2.php

Global_functions_attachments2.php

Function summary

array do_comcode_attachments (LONG_TEXT original_comcode, ID_TEXT type, ID_TEXT id, boolean previewing_only, ?object connection, ?boolean insert_as_admin, ?MEMBER for_member)
void _check_attachment_count ()
integer insert_lang_comcode_attachments (integer level, LONG_TEXT text, ID_TEXT type, ID_TEXT id, ?object connection, boolean insert_as_admin, ?MEMBER for_member)
void final_attachments_from_preview (ID_TEXT id, ?object connection)

array do_comcode_attachments(LONG_TEXT original_comcode, ID_TEXT type, ID_TEXT id, boolean previewing_only, ?object connection, ?boolean insert_as_admin, ?MEMBER for_member)

Get an array containing new comcode, and tempcode. The function wraps the normal comcode_to_tempcode function. The function will do attachment management, including deleting of attachments that have become unused due to editing of some comcode and removing of the reference.

Parameters…

Name original_comcode
Description The unparsed comcode that references the attachments
Type LONG_TEXT

Name type
Description The type the attachment will be used for (e.g. download)
Type ID_TEXT

Name id
Description The ID the attachment will be used for
Type ID_TEXT

Name previewing_only
Description Whether we are only previewing the attachments (i.e. don't store them!)
Default value boolean-false
Type boolean

Name connection
Description The database connection to use (NULL: standard site connection)
Default value
Type ?object

Name insert_as_admin
Description Whether to insert it as an admin (any comcode parsing will be carried out with admin privileges) (NULL: autodetect)
Default value
Type ?boolean

Name for_member
Description The member to use for ownership permissions (NULL: current member)
Default value
Type ?MEMBER

Returns…

Description A map containing 'comcode' (after substitution for tying down the new attachments) and 'tempcode'
Type array

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

void _check_attachment_count()

Check that not too many attachments have been uploaded for the member submitting.

Parameters…

(No return value)


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

integer insert_lang_comcode_attachments(integer level, LONG_TEXT text, ID_TEXT type, ID_TEXT id, ?object connection, boolean insert_as_admin, ?MEMBER for_member)

Insert some comcode content that may contain attachments, and return the language id.

Parameters…

Name level
Description The level of importance this language string holds
Type integer
Values restricted to 1 2 3 4

Name text
Description The comcode content
Type LONG_TEXT

Name type
Description The arbitrary type that the attached is for (e.g. download)
Type ID_TEXT

Name id
Description The id in the set of the arbitrary types that the attached is for
Type ID_TEXT

Name connection
Description The database connection to use (NULL: standard site connection)
Default value
Type ?object

Name insert_as_admin
Description Whether to insert it as an admin (any comcode parsing will be carried out with admin privileges)
Default value boolean-false
Type boolean

Name for_member
Description The member to use for ownership permissions (NULL: current member)
Default value
Type ?MEMBER

Returns…

Description The language id
Type integer

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

void final_attachments_from_preview(ID_TEXT id, ?object connection)

Finalise attachments which were created during a preview, so that they have the proper reference IDs.

Parameters…

Name id
Description The ID in the set of the arbitrary types that the attached is for
Type ID_TEXT

Name connection
Description The database connection to use (NULL: standard site connection)
Default value
Type ?object

(No return value)


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