Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
07/04/2015 10:17:42 PM (11 years ago)
Author:
tw2113
Message:

Docs cleanup for Notifications component.

See #6404.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-notifications/classes/class-bp-notifications-notification.php

    r9887 r9993  
    11<?php
    22/**
    3  * BuddyPress Notifications Classes
     3 * BuddyPress Notifications Classes.
    44 *
    55 * Classes used for the Notifications component.
     
    103103         *
    104104         * @param int $id Optional. Provide an ID to access an existing
    105          *        notification item.
     105         *                notification item.
    106106         */
    107107        public function __construct( $id = 0 ) {
     
    145145                 * @since BuddyPress (2.0.0)
    146146                 *
    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.
    148148                 */
    149149                do_action_ref_array( 'bp_notification_before_save', array( &$this ) );
     
    171171                 * @since BuddyPress (2.0.0)
    172172                 *
    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.
    174174                 */
    175175                do_action_ref_array( 'bp_notification_after_save', array( &$this ) );
     
    216216         * @param array $data {
    217217         *     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.
    227226         * }
    228227         * @param array $data_format See {@link wpdb::insert()}.
     
    241240         * @see wpdb::update() for further description of paramater formats.
    242241         *
    243          * @param array $data Array of notification data to update, passed to
    244          *        {@link wpdb::update()}. Accepts any property of a
    245          *        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 ID
    248          *        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()}.
    250249         * @param array $where_format See {@link wpdb::insert()}.
     250         *
    251251         * @return int|false The number of rows updated, or false on error.
    252252         */
     
    263263         * @see wpdb::update() for further description of paramater formats.
    264264         *
    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.
     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.
    268268         * @param array $where_format See {@link wpdb::insert()}.
     269         *
    269270         * @return int|false The number of rows updated, or false on error.
    270271         */
     
    282283         * @since BuddyPress (1.9.0)
    283284         *
    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         *
    286292         * @return string WHERE clause.
    287293         */
     
    404410         *
    405411         * @param array $args See {@link BP_Notifications_Notification::get()}
    406          *        for more details.
     412         *                    for more details.
     413         *
    407414         * @return string ORDER BY clause.
    408415         */
     
    441448         *
    442449         * @param array $args See {@link BP_Notifications_Notification::get()}
    443          *        for more details.
     450         *                    for more details.
     451         *
    444452         * @return string LIMIT clause.
    445453         */
     
    468476         *
    469477         * - 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.
    471479         * - arrays of "formats", which tell $wpdb->prepare() which type of
    472480         *   value to expect when sanitizing (eg, array( '%s', '%d' ))
     
    497505         * @since BuddyPress (1.9.0)
    498506         *
    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         *
    501511         * @return array Associative array of 'data' and 'format' args.
    502512         */
     
    559569         * @since BuddyPress (1.9.0)
    560570         *
    561          * @param int $user_id ID of the user being checked.
     571         * @param int $user_id         ID of the user being checked.
    562572         * @param int $notification_id ID of the notification being checked.
     573         *
    563574         * @return bool True if the notification belongs to the user, otherwise
    564          *         false.
     575         *              false.
    565576         */
    566577        public static function check_access( $user_id, $notification_id ) {
     
    573584
    574585        /**
    575          * Parse notifications query arguments
     586         * Parse notifications query arguments.
    576587         *
    577588         * @since BuddyPress 2.3.0
     
    609620         *     $per_page can be treated as filter values for get_where_sql()
    610621         *     and get_query_clauses(). All items are optional.
    611          *     @type int|array $id ID of notification being updated. Can be an
    612          *           array of IDs.
    613          *     @type int|array $user_id ID of user being queried. Can be an
    614          *           array of user IDs.
    615          *     @type int|array $item_id ID of associated item. Can be an array
    616          *           of multiple item IDs.
    617          *     @type int|array $secondary_item_id ID of secondary associated
    618          *           item. Can be an array of multiple IDs.
    619          *     @type string|array $component_name Name of the component to
    620          *           filter by. Can be an array of component names.
    621          *     @type string|array $component_action Name of the action to
    622          *           filter by. Can be an array of actions.
    623          *     @type bool $is_new Whether to limit to new notifications. True
    624          *           returns only new notifications, false returns only non-new
    625          *           notifications. 'both' returns all. Default: true.
    626          *     @type string $search_terms Term to match against component_name
    627          *           or component_action fields.
    628          *     @type string $order_by Database column to order notifications by.
    629          *     @type string $sort_order Either 'ASC' or 'DESC'.
    630          *     @type string $order_by Field to order results by.
    631          *     @type string $sort_order ASC or DESC.
    632          *     @type int $page Number of the current page of results. Default:
    633          *           false (no pagination - all items).
    634          *     @type int $per_page Number 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).
    636647         * }
    637648         * @return array Located notifications.
     
    698709         *
    699710         * @param array $args See {@link BP_Notifications_Notification::get()}.
     711         *
    700712         * @return int Count of located items.
    701713         */
     
    754766         * @param  array $meta_query An array of meta_query filters. See the
    755767         *                           documentation for WP_Meta_Query for details.
     768         *
    756769         * @return array $sql_array 'join' and 'where' clauses.
    757770         */
     
    795808         * @param array $date_query An array of date_query parameters. See the
    796809         *                          documentation for the first parameter of WP_Date_Query.
     810         *
    797811         * @return string
    798812         */
     
    820834         *
    821835         * @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         *
    827842         * @return int|bool Number of rows updated on success, false on failure.
    828843         */
     
    858873         *
    859874         * @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         *
    862878         * @return int|bool Number of rows deleted on success, false on failure.
    863879         */
     
    890906         *
    891907         * @param int $id ID of the notification item to be deleted.
     908         *
    892909         * @return bool True on success, false on failure.
    893910         */
     
    903920         * @since BuddyPress (1.9.0)
    904921         *
    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         *
    909927         * @return array Associative array of notification items.
    910928         */
     
    922940         *
    923941         * @param int $user_id ID of the user whose notifications are being
    924          *        fetched.
     942         *                     fetched.
     943         *
    925944         * @return array Associative array of unread notification items.
    926945         */
     
    938957         *
    939958         * @param int $user_id ID of the user whose notifications are being
    940          *        fetched.
     959         *                     fetched.
     960         *
    941961         * @return array Associative array of unread notification items.
    942962         */
     
    955975         * @param array $args {
    956976         *     Array of arguments.
    957          *     @type int $user_id ID of the user for whom the notifications are
    958          *           being fetched. Default: logged-in user ID.
    959          *     @type bool $is_new Whether to limit the query to unread
    960          *           notifications. Default: true.
    961          *     @type int $page Number of the page to return. Default: 1.
    962          *     @type int $per_page Number 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.
    964984         *     @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.
    966986         * }
    967987         * @return array {
    968988         *     @type array $notifications Array of notification results.
    969          *     @type int $total Count of all located notifications matching
    970          *           the query params.
     989         *     @type int   $total        Count of all located notifications matching
     990         *                                the query params.
    971991         * }
    972992         */
     
    9991019         * @since BuddyPress (1.9.0)
    10001020         *
    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.
    10041029         */
    10051030        public static function mark_all_for_user( $user_id, $is_new = 0, $item_id = 0, $component_name = '', $component_action = '', $secondary_item_id = 0 ) {
     
    10391064         * @since BuddyPress (1.9.0)
    10401065         *
    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
    10431073         */
    10441074        public static function mark_all_from_user( $user_id, $is_new = 0, $component_name = '', $component_action = '', $secondary_item_id = 0 ) {
     
    10751105         * @since BuddyPress (1.9.0)
    10761106         *
    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
    10851118         */
    10861119        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.