Changeset 7622 for trunk/bp-activity/bp-activity-functions.php
- Timestamp:
- 11/30/2013 05:13:05 AM (13 years ago)
- File:
-
- 1 edited
-
trunk/bp-activity/bp-activity-functions.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-activity/bp-activity-functions.php
r7576 r7622 189 189 190 190 return true; 191 }192 193 /**194 * Format notifications related to activity.195 *196 * @since BuddyPress (1.5)197 *198 * @uses bp_loggedin_user_domain()199 * @uses bp_get_activity_slug()200 * @uses bp_core_get_user_displayname()201 * @uses apply_filters() To call the 'bp_activity_multiple_at_mentions_notification' hook.202 * @uses apply_filters() To call the 'bp_activity_single_at_mentions_notification' hook.203 * @uses do_action() To call 'activity_format_notifications' hook.204 *205 * @param string $action The type of activity item. Just 'new_at_mention' for now.206 * @param int $item_id The activity ID.207 * @param int $secondary_item_id In the case of at-mentions, this is the mentioner's ID.208 * @param int $total_items The total number of notifications to format.209 * @param string $format 'string' to get a BuddyBar-compatible notification, 'array' otherwise.210 * @return string $return Formatted @mention notification.211 */212 function bp_activity_format_notifications( $action, $item_id, $secondary_item_id, $total_items, $format = 'string' ) {213 214 switch ( $action ) {215 case 'new_at_mention':216 $activity_id = $item_id;217 $poster_user_id = $secondary_item_id;218 $at_mention_link = bp_loggedin_user_domain() . bp_get_activity_slug() . '/mentions/';219 $at_mention_title = sprintf( __( '@%s Mentions', 'buddypress' ), bp_get_loggedin_user_username() );220 221 if ( (int) $total_items > 1 ) {222 $text = sprintf( __( 'You have %1$d new mentions', 'buddypress' ), (int) $total_items );223 $filter = 'bp_activity_multiple_at_mentions_notification';224 } else {225 $user_fullname = bp_core_get_user_displayname( $poster_user_id );226 $text = sprintf( __( '%1$s mentioned you', 'buddypress' ), $user_fullname );227 $filter = 'bp_activity_single_at_mentions_notification';228 }229 break;230 }231 232 if ( 'string' == $format ) {233 $return = apply_filters( $filter, '<a href="' . $at_mention_link . '" title="' . $at_mention_title . '">' . $text . '</a>', $at_mention_link, (int) $total_items, $activity_id, $poster_user_id );234 } else {235 $return = apply_filters( $filter, array(236 'text' => $text,237 'link' => $at_mention_link238 ), $at_mention_link, (int) $total_items, $activity_id, $poster_user_id );239 }240 241 do_action( 'activity_format_notifications', $action, $item_id, $secondary_item_id, $total_items );242 243 return $return;244 191 } 245 192 … … 1267 1214 */ 1268 1215 function bp_activity_new_comment( $args = '' ) { 1269 global $bp; 1270 1271 $defaults = array( 1216 1217 $params = wp_parse_args( $args, array( 1272 1218 'id' => false, 1273 1219 'content' => false, … … 1275 1221 'activity_id' => false, // ID of the root activity item 1276 1222 'parent_id' => false // ID of a parent comment (optional) 1277 ); 1278 1279 $params = wp_parse_args( $args, $defaults ); 1223 ) ); 1224 1280 1225 extract( $params, EXTR_SKIP ); 1281 1226 1282 if ( empty( $content ) || empty( $user_id ) || empty( $activity_id ) ) 1283 return false; 1284 1285 if ( empty( $parent_id ) ) 1227 // Bail if missing necessary data 1228 if ( empty( $content ) || empty( $user_id ) || empty( $activity_id ) ) { 1229 return false; 1230 } 1231 1232 // Maybe set current activity ID as the parent 1233 if ( empty( $parent_id ) ) { 1286 1234 $parent_id = $activity_id; 1235 } 1287 1236 1288 1237 // Check to see if the parent activity is hidden, and if so, hide this comment publically. 1289 $activity = new BP_Activity_Activity( $activity_id );1238 $activity = new BP_Activity_Activity( $activity_id ); 1290 1239 $is_hidden = ( (int) $activity->hide_sitewide ) ? 1 : 0; 1291 1240 … … 1295 1244 'action' => apply_filters( 'bp_activity_comment_action', sprintf( __( '%s posted a new activity comment', 'buddypress' ), bp_core_get_userlink( $user_id ) ) ), 1296 1245 'content' => apply_filters( 'bp_activity_comment_content', $content ), 1297 'component' => $bp->activity->id,1246 'component' => buddypress()->activity->id, 1298 1247 'type' => 'activity_comment', 1299 1248 'user_id' => $user_id, … … 1302 1251 'hide_sitewide' => $is_hidden 1303 1252 ) ); 1304 1305 // Send an email notification if settings allow1306 bp_activity_new_comment_notification( $comment_id, $user_id, $params );1307 1253 1308 1254 // Clear the comment cache for this activity
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)