Changeset 8481 for trunk/src/bp-messages/bp-messages-functions.php
- Timestamp:
- 06/07/2014 11:47:51 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-messages/bp-messages-functions.php
r8185 r8481 16 16 if ( !defined( 'ABSPATH' ) ) exit; 17 17 18 /** 19 * Create a new message. 20 * 21 * @param array $args { 22 * Array of arguments. 23 * @type int $sender_id Optional. ID of the user who is sending the 24 * message. Default: ID of the logged-in user. 25 * @type int $thread_id Optional. ID of the parent thread. Leave blank to 26 * create a new thread for the message. 27 * @type array $recipients IDs or usernames of message recipients. If this 28 * is an existing thread, it is unnecessary to pass a $recipients 29 * argument - existing thread recipients will be assumed. 30 * @type string $subject Optional. Subject line for the message. For 31 * existing threads, the existing subject will be used. For new 32 * threads, 'No Subject' will be used if no $subject is provided. 33 * @type string $content Content of the message. Cannot be empty. 34 * @type string $date_sent Date sent, in 'Y-m-d H:i:s' format. Default: 35 * current date/time. 36 * } 37 * @return int|bool ID of the message thread on success, false on failure. 38 */ 18 39 function messages_new_message( $args = '' ) { 19 40 … … 123 144 } 124 145 125 146 /** 147 * Send a notice. 148 * 149 * @param string $subject Subject of the notice. 150 * @param string $message Content of the notice. 151 * @return bool True on success, false on failure. 152 */ 126 153 function messages_send_notice( $subject, $message ) { 127 154 if ( !bp_current_user_can( 'bp_moderate' ) || empty( $subject ) || empty( $message ) ) { … … 143 170 } 144 171 172 /** 173 * Delete message thread(s). 174 * 175 * @param int|array Thread ID or array of thread IDs. 176 * @return bool True on success, false on failure. 177 */ 145 178 function messages_delete_thread( $thread_ids ) { 146 179 do_action( 'messages_before_delete_thread', $thread_ids ); … … 170 203 } 171 204 205 /** 206 * Check whether a user has access to a thread. 207 * 208 * @param int $thread_id ID of the thread. 209 * @param int $user_id Optional. ID of the user. Default: ID of the logged-in 210 * user. 211 * @return int|null Message ID if the user has access, otherwise null. 212 */ 172 213 function messages_check_thread_access( $thread_id, $user_id = 0 ) { 173 214 if ( empty( $user_id ) ) … … 177 218 } 178 219 220 /** 221 * Mark a thread as read. 222 * 223 * Wrapper for {@link BP_Messages_Thread::mark_as_read()}. 224 * 225 * @param int $thread_id ID of the thread. 226 */ 179 227 function messages_mark_thread_read( $thread_id ) { 180 228 return BP_Messages_Thread::mark_as_read( $thread_id ); 181 229 } 182 230 231 /** 232 * Mark a thread as unread. 233 * 234 * Wrapper for {@link BP_Messages_Thread::mark_as_unread()}. 235 * 236 * @param int $thread_id ID of the thread. 237 */ 183 238 function messages_mark_thread_unread( $thread_id ) { 184 239 return BP_Messages_Thread::mark_as_unread( $thread_id ); 185 240 } 186 241 242 /** 243 * Set messages-related cookies. 244 * 245 * Saves the 'bp_messages_send_to', 'bp_messages_subject', and 246 * 'bp_messages_content' cookies, which are used when setting up the default 247 * values on the messages page. 248 * 249 * @param string $recipients Comma-separated list of recipient usernames. 250 * @param string $subject Subject of the message. 251 * @param string $content Content of the message. 252 */ 187 253 function messages_add_callback_values( $recipients, $subject, $content ) { 188 254 @setcookie( 'bp_messages_send_to', $recipients, time() + 60 * 60 * 24, COOKIEPATH ); … … 191 257 } 192 258 259 /** 260 * Unset messages-related cookies. 261 * 262 * @see messages_add_callback_values() 263 */ 193 264 function messages_remove_callback_values() { 194 265 @setcookie( 'bp_messages_send_to', false, time() - 1000, COOKIEPATH ); … … 197 268 } 198 269 270 /** 271 * Get the unread messages count for a user. 272 * 273 * @param int $user_id Optional. ID of the user. Default: ID of the 274 * logged-in user. 275 * @return int 276 */ 199 277 function messages_get_unread_count( $user_id = 0 ) { 200 278 if ( empty( $user_id ) ) … … 204 282 } 205 283 284 /** 285 * Check whether a user is the sender of a message. 286 * 287 * @param int $user_id ID of the user. 288 * @param int $message_id ID of the message. 289 * @return int|null Returns the ID of the message if the user is the 290 * sender, otherwise null. 291 */ 206 292 function messages_is_user_sender( $user_id, $message_id ) { 207 293 return BP_Messages_Message::is_user_sender( $user_id, $message_id ); 208 294 } 209 295 296 /** 297 * Get the ID of the sender of a message. 298 * 299 * @param int $message_id ID of the message. 300 * @return int|null The ID of the sender if found, otherwise null. 301 */ 210 302 function messages_get_message_sender( $message_id ) { 211 303 return BP_Messages_Message::get_message_sender( $message_id ); 212 304 } 213 305 306 /** 307 * Check whether a message thread exists. 308 * 309 * @param int $thread_id ID of the thread. 310 * @return int|null The message thread ID on success, null on failure. 311 */ 214 312 function messages_is_valid_thread( $thread_id ) { 215 313 return BP_Messages_Thread::is_valid( $thread_id );
Note: See TracChangeset
for help on using the changeset viewer.