- Timestamp:
- 07/04/2015 10:17:42 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-notifications/classes/class-bp-notifications-notification.php
r9887 r9993 1 1 <?php 2 2 /** 3 * BuddyPress Notifications Classes 3 * BuddyPress Notifications Classes. 4 4 * 5 5 * Classes used for the Notifications component. … … 103 103 * 104 104 * @param int $id Optional. Provide an ID to access an existing 105 * notification item.105 * notification item. 106 106 */ 107 107 public function __construct( $id = 0 ) { … … 145 145 * @since BuddyPress (2.0.0) 146 146 * 147 * @param BP_Notifications_Notification Current instance of the notification item being saved. Passed by reference.147 * @param BP_Notifications_Notification $value Current instance of the notification item being saved. Passed by reference. 148 148 */ 149 149 do_action_ref_array( 'bp_notification_before_save', array( &$this ) ); … … 171 171 * @since BuddyPress (2.0.0) 172 172 * 173 * @param BP_Notifications_Notification Current instance of the notification item being saved. Passed by reference.173 * @param BP_Notifications_Notification $value Current instance of the notification item being saved. Passed by reference. 174 174 */ 175 175 do_action_ref_array( 'bp_notification_after_save', array( &$this ) ); … … 216 216 * @param array $data { 217 217 * Array of notification data, passed to {@link wpdb::insert()}. 218 * @type int $user_id ID of the associated user. 219 * @type int $item_id ID of the associated item. 220 * @type int $secondary_item_id ID of the secondary associated item. 221 * @type string $component_name Name of the associated component. 222 * @type string $component_action Name of the associated component 223 * action. 224 * @type string $date_notified Timestamp of the notification. 225 * @type bool $is_new True if the notification is unread, otherwise 226 * false. 218 * @type int $user_id ID of the associated user. 219 * @type int $item_id ID of the associated item. 220 * @type int $secondary_item_id ID of the secondary associated item. 221 * @type string $component_name Name of the associated component. 222 * @type string $component_action Name of the associated component 223 * action. 224 * @type string $date_notified Timestamp of the notification. 225 * @type bool $is_new True if the notification is unread, otherwise false. 227 226 * } 228 227 * @param array $data_format See {@link wpdb::insert()}. … … 241 240 * @see wpdb::update() for further description of paramater formats. 242 241 * 243 * @param array $data Array of notification data to update, passed to244 * {@link wpdb::update()}. Accepts any property of a245 * BP_Notification_Notification object.246 * @param array $where The WHERE params as passed to wpdb::update().247 * Typically consists of array( 'ID' => $id ) to specify the ID248 * of the item being updated. See {@link wpdb::update()}.249 * @param array $data_format See {@link wpdb::insert()}.242 * @param array $data Array of notification data to update, passed to 243 * {@link wpdb::update()}. Accepts any property of a 244 * BP_Notification_Notification object. 245 * @param array $where The WHERE params as passed to wpdb::update(). 246 * Typically consists of array( 'ID' => $id ) to specify the ID 247 * of the item being updated. See {@link wpdb::update()}. 248 * @param array $data_format See {@link wpdb::insert()}. 250 249 * @param array $where_format See {@link wpdb::insert()}. 250 * 251 251 * @return int|false The number of rows updated, or false on error. 252 252 */ … … 263 263 * @see wpdb::update() for further description of paramater formats. 264 264 * 265 * @param array $where Array of WHERE clauses to filter by, passed to266 * {@link wpdb::delete()}. Accepts any property of a267 * BP_Notification_Notification object.265 * @param array $where Array of WHERE clauses to filter by, passed to 266 * {@link wpdb::delete()}. Accepts any property of a 267 * BP_Notification_Notification object. 268 268 * @param array $where_format See {@link wpdb::insert()}. 269 * 269 270 * @return int|false The number of rows updated, or false on error. 270 271 */ … … 282 283 * @since BuddyPress (1.9.0) 283 284 * 284 * @param array $args See {@link BP_Notifications_Notification::get()} 285 * for more details. 285 * @param array $args See {@link BP_Notifications_Notification::get()} 286 * for more details. 287 * @param string $select_sql SQL SELECT fragment. 288 * @param string $from_sql SQL FROM fragment. 289 * @param string $join_sql SQL JOIN fragment. 290 * @param string $meta_query_sql SQL meta query fragment. 291 * 286 292 * @return string WHERE clause. 287 293 */ … … 404 410 * 405 411 * @param array $args See {@link BP_Notifications_Notification::get()} 406 * for more details. 412 * for more details. 413 * 407 414 * @return string ORDER BY clause. 408 415 */ … … 441 448 * 442 449 * @param array $args See {@link BP_Notifications_Notification::get()} 443 * for more details. 450 * for more details. 451 * 444 452 * @return string LIMIT clause. 445 453 */ … … 468 476 * 469 477 * - associative arrays whose key/value pairs are column => value, to 470 * be used in WHERE, SET, or VALUES clauses 478 * be used in WHERE, SET, or VALUES clauses. 471 479 * - arrays of "formats", which tell $wpdb->prepare() which type of 472 480 * value to expect when sanitizing (eg, array( '%s', '%d' )) … … 497 505 * @since BuddyPress (1.9.0) 498 506 * 499 * @param $args Associative array of filter arguments. 500 * See {@BP_Notifications_Notification::get()} for a breakdown. 507 * @param array $args Associative array of filter arguments. 508 * See {@BP_Notifications_Notification::get()} 509 * for a breakdown. 510 * 501 511 * @return array Associative array of 'data' and 'format' args. 502 512 */ … … 559 569 * @since BuddyPress (1.9.0) 560 570 * 561 * @param int $user_id ID of the user being checked.571 * @param int $user_id ID of the user being checked. 562 572 * @param int $notification_id ID of the notification being checked. 573 * 563 574 * @return bool True if the notification belongs to the user, otherwise 564 * false.575 * false. 565 576 */ 566 577 public static function check_access( $user_id, $notification_id ) { … … 573 584 574 585 /** 575 * Parse notifications query arguments 586 * Parse notifications query arguments. 576 587 * 577 588 * @since BuddyPress 2.3.0 … … 609 620 * $per_page can be treated as filter values for get_where_sql() 610 621 * and get_query_clauses(). All items are optional. 611 * @type int|array $idID of notification being updated. Can be an612 * array of IDs.613 * @type int|array $user_idID of user being queried. Can be an614 * array of user IDs.615 * @type int|array $item_idID of associated item. Can be an array616 * of multiple item IDs.617 * @type int|array $secondary_item_id ID of secondary associated618 * item. Can be an array of multiple IDs.619 * @type string|array $component_name Name of the component to620 * filter by. Can be an array of component names.621 * @type string|array $component_action Name of the action to622 * filter by. Can be an array of actions.623 * @type bool $is_newWhether to limit to new notifications. True624 * returns only new notifications, false returns only non-new625 * notifications. 'both' returns all. Default: true.626 * @type string $search_termsTerm to match against component_name627 * or component_action fields.628 * @type string $order_byDatabase column to order notifications by.629 * @type string $sort_orderEither 'ASC' or 'DESC'.630 * @type string $order_byField to order results by.631 * @type string $sort_orderASC or DESC.632 * @type int $pageNumber of the current page of results. Default:633 * false (no pagination - all items).634 * @type int $per_pageNumber of items to show per page. Default:635 * false (no pagination - all items).622 * @type int|array $id ID of notification being updated. Can be an 623 * array of IDs. 624 * @type int|array $user_id ID of user being queried. Can be an 625 * array of user IDs. 626 * @type int|array $item_id ID of associated item. Can be an array 627 * of multiple item IDs. 628 * @type int|array $secondary_item_id ID of secondary associated 629 * item. Can be an array of multiple IDs. 630 * @type string|array $component_name Name of the component to 631 * filter by. Can be an array of component names. 632 * @type string|array $component_action Name of the action to 633 * filter by. Can be an array of actions. 634 * @type bool $is_new Whether to limit to new notifications. True 635 * returns only new notifications, false returns only non-new 636 * notifications. 'both' returns all. Default: true. 637 * @type string $search_terms Term to match against component_name 638 * or component_action fields. 639 * @type string $order_by Database column to order notifications by. 640 * @type string $sort_order Either 'ASC' or 'DESC'. 641 * @type string $order_by Field to order results by. 642 * @type string $sort_order ASC or DESC. 643 * @type int $page Number of the current page of results. Default: 644 * false (no pagination - all items). 645 * @type int $per_page Number of items to show per page. Default: 646 * false (no pagination - all items). 636 647 * } 637 648 * @return array Located notifications. … … 698 709 * 699 710 * @param array $args See {@link BP_Notifications_Notification::get()}. 711 * 700 712 * @return int Count of located items. 701 713 */ … … 754 766 * @param array $meta_query An array of meta_query filters. See the 755 767 * documentation for WP_Meta_Query for details. 768 * 756 769 * @return array $sql_array 'join' and 'where' clauses. 757 770 */ … … 795 808 * @param array $date_query An array of date_query parameters. See the 796 809 * documentation for the first parameter of WP_Date_Query. 810 * 797 811 * @return string 798 812 */ … … 820 834 * 821 835 * @param array $update_args Associative array of fields to update, 822 * and the values to update them to. Of the format 823 * array( 'user_id' => 4, 'component_name' => 'groups', ) 824 * @param array $where_args Associative array of columns/values, to 825 * determine which rows should be updated. Of the format 826 * array( 'item_id' => 7, 'component_action' => 'members', ) 836 * and the values to update them to. Of the format 837 * array( 'user_id' => 4, 'component_name' => 'groups', ) 838 * @param array $where_args Associative array of columns/values, to 839 * determine which rows should be updated. Of the format 840 * array( 'item_id' => 7, 'component_action' => 'members', ) 841 * 827 842 * @return int|bool Number of rows updated on success, false on failure. 828 843 */ … … 858 873 * 859 874 * @param array $args Associative array of columns/values, to determine 860 * which rows should be deleted. Of the format 861 * array( 'item_id' => 7, 'component_action' => 'members', ) 875 * which rows should be deleted. Of the format 876 * array( 'item_id' => 7, 'component_action' => 'members', ) 877 * 862 878 * @return int|bool Number of rows deleted on success, false on failure. 863 879 */ … … 890 906 * 891 907 * @param int $id ID of the notification item to be deleted. 908 * 892 909 * @return bool True on success, false on failure. 893 910 */ … … 903 920 * @since BuddyPress (1.9.0) 904 921 * 905 * @param int $user_id ID of the user whose notifications are being 906 * fetched. 907 * @param string $status Optional. Status of notifications to fetch. 908 * 'is_new' to get only unread items, 'all' to get all. 922 * @param int $user_id ID of the user whose notifications are being 923 * fetched. 924 * @param string $status Optional. Status of notifications to fetch. 925 * 'is_new' to get only unread items, 'all' to get all. 926 * 909 927 * @return array Associative array of notification items. 910 928 */ … … 922 940 * 923 941 * @param int $user_id ID of the user whose notifications are being 924 * fetched. 942 * fetched. 943 * 925 944 * @return array Associative array of unread notification items. 926 945 */ … … 938 957 * 939 958 * @param int $user_id ID of the user whose notifications are being 940 * fetched. 959 * fetched. 960 * 941 961 * @return array Associative array of unread notification items. 942 962 */ … … 955 975 * @param array $args { 956 976 * Array of arguments. 957 * @type int $user_idID of the user for whom the notifications are958 * being fetched. Default: logged-in user ID.959 * @type bool $is_newWhether to limit the query to unread960 * notifications. Default: true.961 * @type int $pageNumber of the page to return. Default: 1.962 * @type int $per_pageNumber of results to display per page.963 * Default: 10.977 * @type int $user_id ID of the user for whom the notifications are 978 * being fetched. Default: logged-in user ID. 979 * @type bool $is_new Whether to limit the query to unread 980 * notifications. Default: true. 981 * @type int $page Number of the page to return. Default: 1. 982 * @type int $per_page Number of results to display per page. 983 * Default: 10. 964 984 * @type string $search_terms Optional. A term to search against in 965 * the 'component_name' and 'component_action' columns.985 * the 'component_name' and 'component_action' columns. 966 986 * } 967 987 * @return array { 968 988 * @type array $notifications Array of notification results. 969 * @type int $totalCount of all located notifications matching970 * the query params.989 * @type int $total Count of all located notifications matching 990 * the query params. 971 991 * } 972 992 */ … … 999 1019 * @since BuddyPress (1.9.0) 1000 1020 * 1001 * @param int $user_id The ID of the user who the notifications 1002 * are for. 1003 * @param int $is_new Mark as read (1) or unread (0). 1021 * @param int $user_id The ID of the user who the notifications are for. 1022 * @param int $is_new Mark as read (1) or unread (0). 1023 * @param int $item_id Item ID being acted on. 1024 * @param string $component_name Name of component the notifications are for. 1025 * @param string $component_action Name of the component action. 1026 * @param int $secondary_item_id The ID of the secondary item. 1027 * 1028 * @return bool|int False on failure to update. ID on success. 1004 1029 */ 1005 1030 public static function mark_all_for_user( $user_id, $is_new = 0, $item_id = 0, $component_name = '', $component_action = '', $secondary_item_id = 0 ) { … … 1039 1064 * @since BuddyPress (1.9.0) 1040 1065 * 1041 * @param int $user_id The ID of the user who the notifications are from. 1042 * @param int $is_new Mark as read (1) or unread (0). 1066 * @param int $user_id The ID of the user who the notifications are from. 1067 * @param int $is_new Mark as read (1) or unread (0). 1068 * @param string $component_name Name of component the notifications are for. 1069 * @param string $component_action Name of the component action. 1070 * @param int $secondary_item_id The ID of the secondary item. 1071 * 1072 * @return bool|int 1043 1073 */ 1044 1074 public static function mark_all_from_user( $user_id, $is_new = 0, $component_name = '', $component_action = '', $secondary_item_id = 0 ) { … … 1075 1105 * @since BuddyPress (1.9.0) 1076 1106 * 1077 * @param int $item_id The ID of the item associated with the 1078 * notifications. 1079 * @param string $component_name The component that the notifications 1080 * are associated with. 1081 * @param string $component_action The action that the notifications 1082 * are associated with. 1083 * @param string $secondary_item_id Optional. ID of the secondary 1084 * associated item. 1107 * @param int $item_id The ID of the item associated with the 1108 * notifications. 1109 * @param int $is_new Mark as read (1) or unread (0). 1110 * @param string $component_name The component that the notifications 1111 * are associated with. 1112 * @param string $component_action The action that the notifications 1113 * are associated with. 1114 * @param int $secondary_item_id Optional. ID of the secondary 1115 * associated item. 1116 * 1117 * @return bool|int 1085 1118 */ 1086 1119 public static function mark_all_by_type( $item_id, $is_new = 0, $component_name = '', $component_action = '', $secondary_item_id = 0 ) {
Note: See TracChangeset
for help on using the changeset viewer.