[buddypress-trac] [BuddyPress Trac] #6025: Add function to send single invitation
buddypress-trac
noreply at wordpress.org
Wed Nov 19 02:12:59 UTC 2014
#6025: Add function to send single invitation
-------------------------+------------------
Reporter: dcavins | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: 2.2
Component: Groups | Version:
Severity: normal | Resolution:
Keywords: has-patch |
-------------------------+------------------
Changes (by dcavins):
* keywords: needs-patch => has-patch
Comment:
This new patch modifies `groups_send_invites()` to use the new function
`groups_send_invite_by_invitee()` internally.
Adding a number of tests for those functions made me think about when
these functions (and the functions they rely on) should return true or
false. Here are the decisions that I made in this patch:
`groups_notification_group_invites()`
* Returns false when the group or member objects don't contain ids.
* Returns false when the submitted inviter_id doesn't match the recorded
inviter_id in the groups_members db.
* Returns true if the notification has already been sent, and we haven't
specified resend.
* If it completes, it returns the result of `wp_mail()`.
`groups_send_invite_by_invitee()`
* Returns false if the required parameters aren't provided.
* Returns false if an invitation doesn't exist from that group to that
user.
* Returns true if `groups_notification_group_invites()` returns true and
`$member->invite_sent` gets updated (or doesn't need to be)
`groups_send_invites()`
* Returns false if the inviter can't send invitations from this group
* Returns true if all calls to `groups_send_invite_by_invitee()` return
true, false if any fail
I also modified `bp_groups_user_can_send_invites()` to accept a
`$user_id`. (It previously only worked off the logged-in user id.) So I
added a number of tests for it as well. (I'd like to apply a
`bp_groups_user_can_send_invites()` check to `groups_invite_user()` as
well. I think the check is happening in the template or js file, but it
seems like it should happen at the point of recording the new invite.)
Since I modified it, I figured I'd better write tests for it, too.
Please let me know if these return values seem to make sense and are BP-
typical.
Thanks in advance for your comments. (Especially about the new tests. I
was hoping to cover the major cases, so let me know if I missed any,
overdid it or just plain did it wrong.)
--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/6025#comment:4>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac
More information about the buddypress-trac
mailing list