Changeset 2077 for trunk/bp-core/bp-core-notifications.php
- Timestamp:
- 11/02/2009 07:54:21 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-core/bp-core-notifications.php
r1905 r2077 3 3 function bp_core_add_notification( $item_id, $user_id, $component_name, $component_action, $secondary_item_id = false, $date_notified = false ) { 4 4 global $bp; 5 5 6 6 if ( !$date_notified ) 7 7 $date_notified = time(); 8 8 9 9 $notification = new BP_Core_Notification; 10 10 $notification->item_id = $item_id; … … 17 17 if ( $secondary_item_id ) 18 18 $notification->secondary_item_id = $secondary_item_id; 19 19 20 20 if ( !$notification->save() ) 21 21 return false; 22 22 23 23 return true; 24 24 } … … 27 27 if ( !bp_core_check_notification_access( $bp->loggedin_user->id, $id ) ) 28 28 return false; 29 29 30 30 return BP_Core_Notification::delete( $id ); 31 31 } 32 32 33 33 function bp_core_get_notification( $id ) { 34 return new BP_Core_Notification( $id ); 34 return new BP_Core_Notification( $id ); 35 35 } 36 36 37 37 function bp_core_get_notifications_for_user( $user_id ) { 38 38 global $bp; 39 39 40 40 $notifications = BP_Core_Notification::get_all_for_user( $user_id ); 41 41 42 42 /* Group notifications by component and component_action and provide totals */ 43 43 for ( $i = 0; $i < count($notifications); $i++ ) { 44 44 $notification = $notifications[$i]; 45 45 46 46 $grouped_notifications[$notification->component_name][$notification->component_action][] = $notification; 47 47 } 48 48 49 49 if ( !$grouped_notifications ) 50 50 return false; 51 51 52 52 /* Calculated a renderable outcome for each notification type */ 53 53 foreach ( $grouped_notifications as $component_name => $action_arrays ) { 54 54 if ( !$action_arrays ) 55 55 continue; 56 56 57 57 foreach ( $action_arrays as $component_action_name => $component_action_items ) { 58 58 $action_item_count = count($component_action_items); 59 59 60 60 if ( $action_item_count < 1 ) 61 61 continue; … … 65 65 } 66 66 } 67 } 68 67 } 68 69 69 return $renderable; 70 70 } … … 89 89 if ( !BP_Core_Notification::check_access( $user_id, $notification_id ) ) 90 90 return false; 91 91 92 92 return true; 93 93 }
Note: See TracChangeset
for help on using the changeset viewer.