Changeset 8481
- Timestamp:
- 06/07/2014 11:47:51 PM (10 years ago)
- Location:
- trunk/src/bp-messages
- Files:
-
- 2 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 ); -
trunk/src/bp-messages/bp-messages-loader.php
r8223 r8481 13 13 if ( !defined( 'ABSPATH' ) ) exit; 14 14 15 /** 16 * Implementation of BP_Component for the Messages component. 17 * 18 * @since BuddyPress (1.5.0) 19 */ 15 20 class BP_Messages_Component extends BP_Component { 16 21 /** … … 24 29 25 30 /** 26 * Start the messages component creation process 27 * 28 * @since BuddyPress (1.5 )31 * Start the messages component creation process. 32 * 33 * @since BuddyPress (1.5.0) 29 34 */ 30 35 public function __construct() { … … 40 45 41 46 /** 42 * Include files 47 * Include files. 48 * 49 * @since BuddyPress (1.5.0) 50 * 51 * @param array $includes See {BP_Component::includes()} for details. 43 52 */ 44 53 public function includes( $includes = array() ) { … … 62 71 63 72 /** 64 * Set up globals73 * Set up globals for the Messages component. 65 74 * 66 75 * The BP_MESSAGES_SLUG constant is deprecated, and only used here for 67 76 * backwards compatibility. 68 77 * 69 * @since BuddyPress (1.5) 78 * @since BuddyPress (1.5.0) 79 * 80 * @param array $args Not used. 70 81 */ 71 82 public function setup_globals( $args = array() ) { … … 99 110 100 111 /** 101 * Setup BuddyBar navigation 112 * Set up navigation for user pages. 113 * 114 * @param array $main_nav See {BP_Component::setup_nav()} for details. 115 * @param array $sub_nav See {BP_Component::setup_nav()} for details. 102 116 */ 103 117 public function setup_nav( $main_nav = array(), $sub_nav = array() ) { … … 182 196 183 197 /** 184 * Set up the Toolbar 198 * Set up the Toolbar. 199 * 200 * @param array $wp_admin_nav See {BP_Component::setup_admin_bar()} 201 * for details. 185 202 */ 186 203 public function setup_admin_bar( $wp_admin_nav = array() ) { … … 251 268 252 269 /** 253 * Set s up the title for pages and <title>270 * Set up the title for pages and <title>. 254 271 */ 255 272 public function setup_title() { … … 273 290 } 274 291 292 /** 293 * Bootstrap the Messages component. 294 */ 275 295 function bp_setup_messages() { 276 296 buddypress()->messages = new BP_Messages_Component();
Note: See TracChangeset
for help on using the changeset viewer.