Skip to:
Content

bbPress.org

Changeset 6520


Ignore:
Timestamp:
06/10/2017 08:52:34 PM (8 years ago)
Author:
johnjamesjacoby
Message:

Engagements: Updates to phpdoc & helper functions.

  • New function to remove all users from an object
  • New function to remove all users from all objects
  • Remove references to taxonomy term storage (from original implementation)
  • Update phpdoc with more accurate descriptions of intended parameter usages

See #3068.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/users/engagements.php

    r6518 r6520  
    2121 * @param int    $user_id   The user id
    2222 * @param string $meta_key  The relationship key
    23  * @param string $meta_type The relationship type
     23 * @param string $meta_type The relationship type (usually 'post')
    2424 * @param bool   $unique    Whether metadata should be unique to the object
    2525 *
    26  * @uses add_post_meta() To set the term on the object
    27  * @uses apply_filters() Calls 'bbp_add_user_to_object' with the return value & parameters
    28  * @return bool Returns true if the user is added to the object, otherwise false
     26 * @uses add_post_meta() To add the user to an object
     27 *
     28 * @return bool Returns true on success, false on failure
    2929 */
    3030function bbp_add_user_to_object( $object_id = 0, $user_id = 0, $meta_key = '', $meta_type = 'post', $unique = true ) {
     
    4040 * @since 2.6.0 bbPress (r6109)
    4141 *
    42  * @param int    $object_id The post id
     42 * @param int    $object_id The object id
    4343 * @param int    $user_id   The user id
    4444 * @param string $meta_key  The relationship key
    45  * @param string $meta_type The relationship type
    46  *
    47  * @uses delete_post_meta() To remove the term from the object
    48  * @uses apply_filters() Calls 'bbp_remove_user_from_object' with the object
    49  *                        id, user id, and taxonomy
    50  * @return bool Returns true is the user taxonomy term is removed from the object,
    51  *               otherwise false
     45 * @param string $meta_type The relationship type (usually 'post')
     46 *
     47 * @uses delete_metadata() To remove a user from an objects
     48 *
     49 * @return bool Returns true on success, false on failure
    5250 */
    5351function bbp_remove_user_from_object( $object_id = 0, $user_id = 0, $meta_key = '', $meta_type = 'post' ) {
     
    5957
    6058/**
    61  * Remove a user id from all objects
     59 * Remove all users from an object
    6260 *
    6361 * @since 2.6.0 bbPress (r6109)
    6462 *
    65  * @param int    $object_id The post id
     63 * @param int    $object_id The object id
    6664 * @param int    $user_id   The user id
    6765 * @param string $meta_key  The relationship key
    68  * @param string $meta_type The relationship type
    69  *
    70  * @uses delete_post_meta() To remove the term from the object
    71  * @uses apply_filters() Calls 'bbp_remove_user_from_object' with the object
    72  *                        id, user id, and taxonomy
    73  * @return bool Returns true is the user taxonomy term is removed from the object,
    74  *               otherwise false
     66 * @param string $meta_type The relationship type (usually 'post')
     67 *
     68 * @uses delete_metadata() To remove all user from an object
     69 *
     70 * @return bool Returns true on success, false on failure
     71 */
     72function bbp_remove_all_users_from_object( $object_id = 0, $meta_key = '', $meta_type = 'post' ) {
     73    $retval = delete_metadata( $meta_type, $object_id, $meta_key, null, false );
     74
     75    // Filter & return
     76    return (bool) apply_filters( 'bbp_remove_all_users_from_object', (bool) $retval, $object_id, $meta_key, $meta_type );
     77}
     78
     79/**
     80 * Remove a user id from all objects
     81 *
     82 * @since 2.6.0 bbPress (r6109)
     83 *
     84 * @param int    $user_id   The user id
     85 * @param string $meta_key  The relationship key
     86 * @param string $meta_type The relationship type (usually 'post')
     87 *
     88 * @uses delete_metadata() To remove user from all objects
     89 *
     90 * @return bool Returns true on success, false on failure
    7591 */
    7692function bbp_remove_user_from_all_objects( $user_id = 0, $meta_key = '', $meta_type = 'post' ) {
     
    8298
    8399/**
    84  * Get user taxonomy terms for an object
     100 * Remove all users from all objects
     101 *
     102 * @since 2.6.0 bbPress (r6109)
     103 *
     104 * @param string $meta_key  The relationship key
     105 * @param string $meta_type The relationship type (usually 'post')
     106 *
     107 * @uses delete_metadata() To remove users from objects
     108 *
     109 * @return bool Returns true on success, false on failure
     110 */
     111function bbp_remove_all_users_from_all_objects( $meta_key = '', $meta_type = 'post' ) {
     112    $retval = delete_metadata( $meta_type, null, $meta_key, null, true );
     113
     114    // Filter & return
     115    return (bool) apply_filters( 'bbp_remove_all_users_from_all_objects', (bool) $retval, $meta_key, $meta_type );
     116}
     117
     118/**
     119 * Get users of an object
    85120 *
    86121 * @since 2.6.0 bbPress (r6109)
     
    90125 * @param string $meta_type The type of meta to look in
    91126 *
    92  * @uses get_post_meta() To get the user taxonomy terms
    93  * @uses apply_filters() Calls 'bbp_get_users_for_object' with the user
    94  *                        taxonomy terms, object id, and taxonomy
    95  * @return array Returns the user taxonomy terms of the object
     127 * @uses get_metadata() To get the users of an object
     128 *
     129 * @return array Returns ids of users
    96130 */
    97131function bbp_get_users_for_object( $object_id = 0, $meta_key = '', $meta_type = 'post' ) {
     
    104138
    105139/**
    106  * Check if the user id is set on an object
     140 * Check if an object has a specific user
    107141 *
    108142 * @since 2.6.0 bbPress (r6109)
     
    111145 * @param int    $user_id   The user id
    112146 * @param string $meta_key  The relationship key
    113  * @param string $meta_type The relationship type
    114  *
    115  * @uses get_post_meta() To check if the user id is set on the object
    116  * @uses apply_filters() Calls 'bbp_is_object_of_user' with the object id,
    117  *                        user id, and taxonomy
    118  * @return bool Returns true if the user id is set on the object for the
    119  *               taxonomy, otherwise false
     147 * @param string $meta_type The relationship type (usually 'post')
     148 *
     149 * @uses bbp_get_users_for_object() To get all users of an object
     150 *
     151 * @return bool Returns true if object has a user, false if not
    120152 */
    121153function bbp_is_object_of_user( $object_id = 0, $user_id = 0, $meta_key = '', $meta_type = 'post' ) {
Note: See TracChangeset for help on using the changeset viewer.