Changeset 9572
- Timestamp:
- 03/01/2015 05:22:59 PM (10 years ago)
- Location:
- trunk/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/admin/bp-core-admin-schema.php
r9546 r9572 113 113 KEY component_action (component_action), 114 114 KEY useritem (user_id,is_new) 115 ) {$charset_collate};"; 116 117 $sql[] = "CREATE TABLE {$bp_prefix}bp_notifications_meta ( 118 id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY, 119 notification_id bigint(20) NOT NULL, 120 meta_key varchar(255) DEFAULT NULL, 121 meta_value longtext DEFAULT NULL, 122 KEY notification_id (notification_id), 123 KEY meta_key (meta_key) 115 124 ) {$charset_collate};"; 116 125 -
trunk/src/bp-core/bp-core-update.php
r9503 r9572 212 212 bp_core_install(); 213 213 214 // 1.5 214 // 1.5.0 215 215 if ( $raw_db_version < 1801 ) { 216 216 bp_update_to_1_5(); … … 218 218 } 219 219 220 // 1.6 220 // 1.6.0 221 221 if ( $raw_db_version < 6067 ) { 222 222 bp_update_to_1_6(); 223 223 } 224 224 225 // 1.9 225 // 1.9.0 226 226 if ( $raw_db_version < 7553 ) { 227 227 bp_update_to_1_9(); … … 233 233 } 234 234 235 // 2.0 235 // 2.0.0 236 236 if ( $raw_db_version < 7892 ) { 237 237 bp_update_to_2_0(); … … 243 243 } 244 244 245 // 2.2 245 // 2.2.0 246 246 if ( $raw_db_version < 9181 ) { 247 247 bp_update_to_2_2(); 248 } 249 250 // 2.3.0 251 if ( $raw_db_version < 9572 ) { 252 bp_update_to_2_3(); 248 253 } 249 254 } … … 415 420 bp_cleanup_friendship_activities(); 416 421 } 422 } 423 } 424 425 /** 426 * 2.3.0 update routine. 427 * 428 * - Add notifications meta table 429 * 430 * @since BuddyPress (2.3.0) 431 */ 432 function bp_update_to_2_3() { 433 if ( bp_is_active( 'notifications' ) ) { 434 bp_core_install_notifications(); 417 435 } 418 436 } -
trunk/src/bp-loader.php
r9559 r9572 304 304 305 305 $this->version = '2.3-alpha'; 306 $this->db_version = 9 181;306 $this->db_version = 9572; 307 307 308 308 /** Loading ***********************************************************/ -
trunk/src/bp-notifications/bp-notifications-cache.php
r9352 r9572 6 6 * @since BuddyPress (2.0.0) 7 7 */ 8 9 /** 10 * Slurp up metadata for a set of notifications. 11 * 12 * It grabs all notification meta associated with all of the notifications 13 * passed in $notification_ids and adds it to WP cache. This improves efficiency 14 * when using notification meta within a loop context. 15 * 16 * @since BuddyPress (2.3.0) 17 * 18 * @param int|str|array $notification_ids Accepts a single notification_id, or a 19 * comma-separated list or array of 20 * notification ids. 21 */ 22 function bp_notifications_update_meta_cache( $notification_ids = false ) { 23 bp_update_meta_cache( array( 24 'object_ids' => $notification_ids, 25 'object_type' => buddypress()->notifications->id, 26 'cache_group' => 'notification_meta', 27 'object_column' => 'notification_id', 28 'meta_table' => buddypress()->notifications->table_name_meta, 29 'cache_key_prefix' => 'bp_notifications_meta' 30 ) ); 31 } 8 32 9 33 /** -
trunk/src/bp-notifications/bp-notifications-functions.php
r9352 r9572 612 612 return apply_filters( 'bp_notifications_get_registered_components', $component_names, $active_components ); 613 613 } 614 615 /** Meta **********************************************************************/ 616 617 /** 618 * Delete a meta entry from the DB for a notification item. 619 * 620 * @since BuddyPress (2.3.0) 621 * 622 * @global object $wpdb WordPress database access object. 623 * 624 * @param int $notification_id ID of the notification item whose metadata is being deleted. 625 * @param string $meta_key Optional. The key of the metadata being deleted. If 626 * omitted, all metadata associated with the notification 627 * item will be deleted. 628 * @param string $meta_value Optional. If present, the metadata will only be 629 * deleted if the meta_value matches this parameter. 630 * @param bool $delete_all Optional. If true, delete matching metadata entries 631 * for all objects, ignoring the specified object_id. Otherwise, 632 * only delete matching metadata entries for the specified 633 * notification item. Default: false. 634 * 635 * @return bool True on success, false on failure. 636 */ 637 function bp_notifications_delete_meta( $notification_id, $meta_key = '', $meta_value = '', $delete_all = false ) { 638 639 // Legacy - if no meta_key is passed, delete all for the item 640 if ( empty( $meta_key ) ) { 641 $all_meta = bp_notifications_get_meta( $notification_id ); 642 $keys = ! empty( $all_meta ) 643 ? array_keys( $all_meta ) 644 : array(); 645 646 // With no meta_key, ignore $delete_all 647 $delete_all = false; 648 } else { 649 $keys = array( $meta_key ); 650 } 651 652 $retval = true; 653 654 add_filter( 'query', 'bp_filter_metaid_column_name' ); 655 foreach ( $keys as $key ) { 656 $retval = delete_metadata( 'notifications', $notification_id, $key, $meta_value, $delete_all ); 657 } 658 remove_filter( 'query', 'bp_filter_metaid_column_name' ); 659 660 return $retval; 661 } 662 663 /** 664 * Get metadata for a given notification item. 665 * 666 * @since BuddyPress (2.3.0) 667 * 668 * @uses apply_filters() To call the 'bp_notifications_get_meta' hook. 669 * 670 * @param int $notification_id ID of the notification item whose metadata is being requested. 671 * @param string $meta_key Optional. If present, only the metadata matching 672 * that meta key will be returned. Otherwise, all metadata for the 673 * notification item will be fetched. 674 * @param bool $single Optional. If true, return only the first value of the 675 * specified meta_key. This parameter has no effect if meta_key is not 676 * specified. Default: true. 677 * 678 * @return mixed The meta value(s) being requested. 679 */ 680 function bp_notifications_get_meta( $notification_id = 0, $meta_key = '', $single = true ) { 681 add_filter( 'query', 'bp_filter_metaid_column_name' ); 682 $retval = get_metadata( 'notifications', $notification_id, $meta_key, $single ); 683 remove_filter( 'query', 'bp_filter_metaid_column_name' ); 684 685 /** 686 * Filters the metadata for a specified notification item. 687 * 688 * @since BuddyPress (2.3.0) 689 * 690 * @param mixed $retval The meta values for the notification item. 691 * @param int $notification_id ID of the notification item. 692 * @param string $meta_key Meta key for the value being requested. 693 * @param bool $single Whether to return one matched meta key row or all. 694 */ 695 return apply_filters( 'bp_notifications_get_meta', $retval, $notification_id, $meta_key, $single ); 696 } 697 698 /** 699 * Update a piece of notification meta. 700 * 701 * @since BuddyPress (1.2.0) 702 * 703 * @param int $notification_id ID of the notification item whose metadata is being 704 * updated. 705 * @param string $meta_key Key of the metadata being updated. 706 * @param mixed $meta_value Value to be set. 707 * @param mixed $prev_value Optional. If specified, only update existing 708 * metadata entries with the specified value. 709 * Otherwise, update all entries. 710 * 711 * @return bool|int Returns false on failure. On successful 712 * update of existing metadata, returns true. On 713 * successful creation of new metadata, returns 714 * the integer ID of the new metadata row. 715 */ 716 function bp_notifications_update_meta( $notification_id, $meta_key, $meta_value, $prev_value = '' ) { 717 add_filter( 'query', 'bp_filter_metaid_column_name' ); 718 $retval = update_metadata( 'notifications', $notification_id, $meta_key, $meta_value, $prev_value ); 719 remove_filter( 'query', 'bp_filter_metaid_column_name' ); 720 721 return $retval; 722 } 723 724 /** 725 * Add a piece of notification metadata. 726 * 727 * @since BuddyPress (2.3.0) 728 * 729 * @param int $notification_id ID of the notification item. 730 * @param string $meta_key Metadata key. 731 * @param mixed $meta_value Metadata value. 732 * @param bool $unique Optional. Whether to enforce a single metadata value 733 * for the given key. If true, and the object already has a value for 734 * the key, no change will be made. Default: false. 735 * 736 * @return int|bool The meta ID on successful update, false on failure. 737 */ 738 function bp_notifications_add_meta( $notification_id, $meta_key, $meta_value, $unique = false ) { 739 add_filter( 'query', 'bp_filter_metaid_column_name' ); 740 $retval = add_metadata( 'notifications', $notification_id, $meta_key, $meta_value, $unique ); 741 remove_filter( 'query', 'bp_filter_metaid_column_name' ); 742 743 return $retval; 744 } -
trunk/src/bp-notifications/bp-notifications-loader.php
r9387 r9572 248 248 // Global groups 249 249 wp_cache_add_global_groups( array( 250 'bp_notifications' 250 'bp_notifications', 251 'notification_meta' 251 252 ) ); 252 253
Note: See TracChangeset
for help on using the changeset viewer.