-
FAQ
- Forum Search
- Community
- Online Manual
- Support Helpers of the Month
- Function Database
createPost
Description
Inserts a new post into the database with the appropriate options.
Syntax
bool createPost (array &$msgOptions, array &$topicOptions, array &$posterOptions)
Parameter &$msgOptions
Expected type: Array
Description: An array of information related specifically to the post - the body of the message, options such as whether or not smileys are enabled and the message icon
Array Elements of $msgOptions Key Optional Expected type Description body no Escaped String The message itself subject no Escaped String The subject of this post approved yes Integer 1 if the message is approved, 0 otherwise. Defaults to 1. attachments yes Array of Integers An array containing attachment (or thumbnail) IDs for each attachment this post has (defaults to an empty array) icon yes String The message icon. Defaults to 'xx' id yes Integer The message ID (set after the message has been inserted and used when inserting the topic details) smileys_enabled yes Boolean Whether or not smileys are enabled.
Parameter &$topicOptions
Expected type: Array
Description: An array of information specifically related to the topic
Array Elements of $topicOptions Key Optional Expected type Description board no Integer The board ID mark_as_read no Boolean Whether or not to mark the topic as read when it gets posted. Always true. id yes Integer The topic ID. Defaults to 0. If we're posting to an existing topic, this will be set. Otherwise it is set after the topic info is inserted into the database. is_approved yes Boolean Whether or not this topic is approved. If post moderation is disabled, this is set to true. Otherwise if the topic ID is set, the value is pulled from the database. If this is a new topic and post moderation is enabled, this is dependent on $msgOptions['approved']. lock_mode yes Integer 0 if the topic is being unlocked or 1 if the topic is being locked (defaults to null) poll yes Integer The ID of the poll associated with this topic (defaults to null) sticky_mode yes Integer 0 if the topic is being un-stickied, 1 if it's being stickied (defaults to null)
Parameter &$posterOptions
Expected type: Array
Description: An array of data about the poster of this message (all of this is technically optional)
Array Elements of $posterOptions Key Optional Expected type Description email yes String Email address of the poster. If the name and id are empty, this defaults to an empty string. Otherwise it is either pulled from the database or set to $user_info['email'] depending on whether or not the two ids match. id yes Integer The member ID of the poster (defaults to 0, indicating that the poster was a guest) ip yes String The poster's IP address. If empty, $user_info['ip'] will be used instead, so this should always be set for posts from guests. name yes String The name of the poster. If this is empty and $posterOptions['id'] is empty, this will default to $txt['guest_title']. Otherwise SMF will either set it to $user_info['name'] or try to pull it from the database, depending on whether or not $posterOptions['id'] and $user_info['id'] are the same. update_post_count yes Enumerated String Option to determine whehter the post count of the poster should be increased. Possible values 'never', 'auto' (default; based on the board setting), 'always'
Return value
Expected type: Boolean
Description: True if the message was created successfully, false otherwise
Notes
- Called from the Post2() function in Sources/Post.php after the input has been validated
- Sets up default values for the items which are marked optional
- Updates all the appropriate statistics
- Updates the custom search index, if there is one
Advertisement:- Help | Terms and Rules | Go Up ▲
- Copyright © 2022 Simple Machines. All Rights Reserved.
- Page created in 0.037 seconds with 13 queries.
- Forum Search