Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
06/01/2024 10:25:18 PM (14 months ago)
Author:
espellcaste
Message:

WPCS: Part IV: miscellaneous fixes for some of the files of the core component.

Follow-up to [13883], [13886], and [13887]

See #9164 and #7228

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/classes/class-bp-invitation-manager.php

    r13500 r13888  
    2626     *
    2727     * @since 5.0.0
    28      * @access public
     28     *
    2929     * @var string
    3030     */
     
    3535     *
    3636     * @since 5.0.0
    37      *
    38      * @param array|string $args {
    39      * }
    40      */
    41     public function __construct( $args = array() ) {
     37     */
     38    public function __construct() {
    4239        $this->class_name = get_class( $this );
    4340    }
     
    4744     *
    4845     * @since 5.0.0
    49      * @access public
     46     *
    5047     * @return string
    5148     */
     
    6461     * @param array $args {
    6562     *     Array of arguments describing the invitation. All are optional.
    66      *     @type int    $user_id           ID of the invited user.
    67      *     @type int    $inviter_id        ID of the user who created the invitation.
    68      *     @type string $invitee_email     Email address of the invited user.
    69      *     @type int    $item_id           ID associated with the invitation and class.
    70      *     @type int    $secondary_item_id Secondary ID associated with the
    71      *                                     invitation and class.
    72      *     @type string $type              Type of record this is: 'invite' or 'request'.
    73      *     @type string $content           Extra information provided by the requester
    74      *                                     or inviter.
    75      *     @type string $date_modified     Date the invitation was last modified.
    76      *     @type int    $send_invite       Should the invitation also be sent, or is it a
    77      *                                     draft invite?
     63     *     @type int    $user_id           ID of the invited user.
     64     *     @type int    $inviter_id        ID of the user who created the invitation.
     65     *     @type string $invitee_email     Email address of the invited user.
     66     *     @type int    $item_id           ID associated with the invitation and class.
     67     *     @type int    $secondary_item_id Secondary ID associated with the
     68     *                                     invitation and class.
     69     *     @type string $type              Type of record this is: 'invite' or 'request'.
     70     *     @type string $content           Extra information provided by the requester
     71     *                                     or inviter.
     72     *     @type string $date_modified     Date the invitation was last modified.
     73     *     @type int    $send_invite       Should the invitation also be sent, or is it a
     74     *                                     draft invite?
    7875     * }
    7976     * @return int|bool ID of the newly created invitation on success, false
    80      *         on failure.
     77     *                  on failure.
    8178     */
    8279    public function add_invitation( $args = array() ) {
    83 
    8480        $r = bp_parse_args(
    8581            $args,
     
    121117
    122118        // Avoid creating duplicate invitations.
    123         $invite_id = $this->invitation_exists( array(
    124             'user_id'           => $r['user_id'],
    125             'invitee_email'     => $r['invitee_email'],
    126             'inviter_id'        => $r['inviter_id'],
    127             'item_id'           => $r['item_id'],
    128             'secondary_item_id' => $r['secondary_item_id'],
    129         ) );
     119        $invite_id = $this->invitation_exists(
     120            array(
     121                'user_id'           => $r['user_id'],
     122                'invitee_email'     => $r['invitee_email'],
     123                'inviter_id'        => $r['inviter_id'],
     124                'item_id'           => $r['item_id'],
     125                'secondary_item_id' => $r['secondary_item_id'],
     126            )
     127        );
    130128
    131129        if ( ! $invite_id ) {
    132130            // Set up the new invitation as a draft.
    133             $invitation                    = new BP_Invitation;
     131            $invitation                    = new BP_Invitation();
    134132            $invitation->user_id           = $r['user_id'];
    135133            $invitation->inviter_id        = $r['inviter_id'];
     
    162160     *
    163161     * @since 5.0.0
    164      * @access public
    165162     *
    166163     * @param int   $invitation_id ID of invitation to send.
    167164     * @param array $args          See BP_Invitation::mark_sent().
    168165     *
    169      * @return bool The result of `run_send_action()`.
     166     * @return bool
    170167     */
    171168    public function send_invitation_by_id( $invitation_id = 0, $args = array() ) {
     
    195192            'secondary_item_id' => $invitation->secondary_item_id,
    196193        );
    197         $request = $this->request_exists( $request_args );
     194        $request      = $this->request_exists( $request_args );
    198195
    199196        if ( ! empty( $request ) ) {
     
    220217     * @param array $args {
    221218     *     Array of arguments describing the invitation. All are optional.
    222      *     @type int    $user_id ID of the invited user.
    223      *     @type int    $inviter_id ID of the user who created the invitation.
    224      *     @type string $class Name of the invitations class.
    225      *     @type int    $item_id ID associated with the invitation and class.
    226      *     @type int    $secondary_item_id secondary ID associated with the
    227      *                  invitation and class.
    228      *     @type string $type    Type of record this is: 'invite' or 'request'.
    229      *     @type string $content Extra information provided by the requester
    230      *                  or inviter.
    231      *     @type string $date_modified Date the invitation was last modified.
    232      *     @type int    $invite_sent Has the invitation been sent, or is it a
    233      *          draft invite?
     219     *     @type int    $user_id ID of the invited user.
     220     *     @type int    $inviter_id ID of the user who created the invitation.
     221     *     @type string $class Name of the invitations class.
     222     *     @type int    $item_id ID associated with the invitation and class.
     223     *     @type int    $secondary_item_id secondary ID associated with the
     224     *                  invitation and class.
     225     *     @type string $type    Type of record this is: 'invite' or 'request'.
     226     *     @type string $content Extra information provided by the requester
     227     *                  or inviter.
     228     *     @type string $date_modified Date the invitation was last modified.
     229     *     @type int    $invite_sent Has the invitation been sent, or is it a
     230     *          draft invite?
    234231     * }
    235232     * @return int|bool ID of the newly created invitation on success, false
    236      *         on failure.
     233     *                  on failure.
    237234     */
    238235    public function add_request( $args = array() ) {
    239 
    240236        $r = bp_parse_args(
    241237            $args,
     
    289285         */
    290286        $invite_args = array_merge( $base_args, array( 'invite_sent' => 'sent' ) );
    291         $invite = $this->invitation_exists( $invite_args );
     287        $invite      = $this->invitation_exists( $invite_args );
    292288
    293289        if ( $invite ) {
     
    296292        } else {
    297293            // Set up the new request.
    298             $request                    = new BP_Invitation;
     294            $request                    = new BP_Invitation();
    299295            $request->user_id           = $r['user_id'];
    300296            $request->inviter_id        = $r['inviter_id'];
     
    344340            'item_id'           => $request->item_id,
    345341            'secondary_item_id' => $request->secondary_item_id,
    346             'invite_sent'       => 'sent'
    347         );
    348         $invites = $this->invitation_exists( $invite_args );
     342            'invite_sent'       => 'sent',
     343        );
     344        $invites     = $this->invitation_exists( $invite_args );
    349345
    350346        if ( ! empty( $invites ) ) {
     
    451447
    452448        $args['fields'] = 'ids';
    453         $invites = $this->get_invitations( $args );
     449        $invites        = $this->get_invitations( $args );
    454450        if ( $invites ) {
    455451            $is_invited = current( $invites );
     
    471467
    472468        $args['fields'] = 'ids';
    473         $requests = $this->get_requests( $args );
     469        $requests       = $this->get_requests( $args );
    474470        if ( $requests ) {
    475471            $has_request = current( $requests );
     
    608604     * @param array $update_args Associative array of fields to update,
    609605     *              and the values to update them to. Of the format
    610      *              array( 'user_id' => 4 )
     606     *              array( 'user_id' => 4 ).
    611607     * @param array $where_args Associative array of columns/values, to
    612608     *              determine which invitations should be updated. Formatted as
    613      *              array( 'item_id' => 7 )
     609     *              array( 'item_id' => 7 ).
    614610     * @return int|bool Number of rows updated on success, false on failure.
    615611     */
     
    647643     *                        Special cases
    648644     *     @type string|array $invitee_email Email address of invited users
    649      *                        being queried. Can be an array of addresses.
     645     *                        being queried. Can be an array of addresses.
    650646     *     @type string|array $class Name of the class to
    651647     *                        filter by. Can be an array of class names.
     
    667663     * @since 5.0.0
    668664     *
    669      * @param int $id The ID of the invitation to mark as sent.
    670      * @return bool True on success, false on failure.
    671      */
    672     abstract public function run_acceptance_action( $type, $r  );
     665     * @param string $type The type of record being accepted: 'invite' or 'request'.
     666     * @param array  $r    Associative array of arguments.
     667     * @return bool
     668     */
     669    abstract public function run_acceptance_action( $type, $r );
    673670
    674671    /**
     
    679676     * @see BP_Invitation::mark_accepted()
    680677     *      for a description of arguments.
    681      * @return bool True on success, false on failure.
     678     *
     679     * @return bool
    682680     */
    683681    public function mark_accepted_by_id( $id, $args ) {
     
    708706     *
    709707     * @see BP_Invitation::delete for a description of arguments.
     708     *
    710709     * @return int|bool Number of rows deleted on success, false on failure.
    711710     */
     
    743742     */
    744743    public function delete_all() {
    745         return BP_Invitation::delete( array(
    746             'class' => $this->class_name,
    747         ) );
     744        return BP_Invitation::delete(
     745            array(
     746                'class' => $this->class_name,
     747            )
     748        );
    748749    }
    749750
     
    772773     * @since 5.0.0
    773774     *
    774      * @param array $args The parameters describing the invitation.
    775      * @return bool True if allowed, false to end process.
    776      */
    777     public function allow_invitation( $args ) {
     775     * @return bool
     776     */
     777    public function allow_invitation() {
    778778        return true;
    779779    }
     
    785785     * @since 5.0.0
    786786     *
    787      * @param array $args The parameters describing the request.
    788      * @return bool True if allowed, false to end process.
    789      */
    790     public function allow_request( $args ) {
     787     * @return bool
     788     */
     789    public function allow_request() {
    791790        return true;
    792791    }
    793 
    794792}
Note: See TracChangeset for help on using the changeset viewer.