- Timestamp:
- 06/01/2024 10:25:18 PM (14 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/classes/class-bp-invitation-manager.php
r13500 r13888 26 26 * 27 27 * @since 5.0.0 28 * @access public28 * 29 29 * @var string 30 30 */ … … 35 35 * 36 36 * @since 5.0.0 37 * 38 * @param array|string $args { 39 * } 40 */ 41 public function __construct( $args = array() ) { 37 */ 38 public function __construct() { 42 39 $this->class_name = get_class( $this ); 43 40 } … … 47 44 * 48 45 * @since 5.0.0 49 * @access public46 * 50 47 * @return string 51 48 */ … … 64 61 * @param array $args { 65 62 * Array of arguments describing the invitation. All are optional. 66 * 67 * 68 * 69 * 70 * 71 * 72 * 73 * 74 * 75 * 76 * 77 * 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? 78 75 * } 79 76 * @return int|bool ID of the newly created invitation on success, false 80 * on failure.77 * on failure. 81 78 */ 82 79 public function add_invitation( $args = array() ) { 83 84 80 $r = bp_parse_args( 85 81 $args, … … 121 117 122 118 // 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 ); 130 128 131 129 if ( ! $invite_id ) { 132 130 // Set up the new invitation as a draft. 133 $invitation = new BP_Invitation ;131 $invitation = new BP_Invitation(); 134 132 $invitation->user_id = $r['user_id']; 135 133 $invitation->inviter_id = $r['inviter_id']; … … 162 160 * 163 161 * @since 5.0.0 164 * @access public165 162 * 166 163 * @param int $invitation_id ID of invitation to send. 167 164 * @param array $args See BP_Invitation::mark_sent(). 168 165 * 169 * @return bool The result of `run_send_action()`.166 * @return bool 170 167 */ 171 168 public function send_invitation_by_id( $invitation_id = 0, $args = array() ) { … … 195 192 'secondary_item_id' => $invitation->secondary_item_id, 196 193 ); 197 $request = $this->request_exists( $request_args );194 $request = $this->request_exists( $request_args ); 198 195 199 196 if ( ! empty( $request ) ) { … … 220 217 * @param array $args { 221 218 * Array of arguments describing the invitation. All are optional. 222 * 223 * 224 * 225 * 226 * 227 * 228 * 229 * 230 * 231 * 232 * 233 * 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? 234 231 * } 235 232 * @return int|bool ID of the newly created invitation on success, false 236 * on failure.233 * on failure. 237 234 */ 238 235 public function add_request( $args = array() ) { 239 240 236 $r = bp_parse_args( 241 237 $args, … … 289 285 */ 290 286 $invite_args = array_merge( $base_args, array( 'invite_sent' => 'sent' ) ); 291 $invite = $this->invitation_exists( $invite_args );287 $invite = $this->invitation_exists( $invite_args ); 292 288 293 289 if ( $invite ) { … … 296 292 } else { 297 293 // Set up the new request. 298 $request = new BP_Invitation ;294 $request = new BP_Invitation(); 299 295 $request->user_id = $r['user_id']; 300 296 $request->inviter_id = $r['inviter_id']; … … 344 340 'item_id' => $request->item_id, 345 341 '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 ); 349 345 350 346 if ( ! empty( $invites ) ) { … … 451 447 452 448 $args['fields'] = 'ids'; 453 $invites = $this->get_invitations( $args );449 $invites = $this->get_invitations( $args ); 454 450 if ( $invites ) { 455 451 $is_invited = current( $invites ); … … 471 467 472 468 $args['fields'] = 'ids'; 473 $requests = $this->get_requests( $args );469 $requests = $this->get_requests( $args ); 474 470 if ( $requests ) { 475 471 $has_request = current( $requests ); … … 608 604 * @param array $update_args Associative array of fields to update, 609 605 * and the values to update them to. Of the format 610 * array( 'user_id' => 4 ) 606 * array( 'user_id' => 4 ). 611 607 * @param array $where_args Associative array of columns/values, to 612 608 * determine which invitations should be updated. Formatted as 613 * array( 'item_id' => 7 ) 609 * array( 'item_id' => 7 ). 614 610 * @return int|bool Number of rows updated on success, false on failure. 615 611 */ … … 647 643 * Special cases 648 644 * @type string|array $invitee_email Email address of invited users 649 * 645 * being queried. Can be an array of addresses. 650 646 * @type string|array $class Name of the class to 651 647 * filter by. Can be an array of class names. … … 667 663 * @since 5.0.0 668 664 * 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 ); 673 670 674 671 /** … … 679 676 * @see BP_Invitation::mark_accepted() 680 677 * for a description of arguments. 681 * @return bool True on success, false on failure. 678 * 679 * @return bool 682 680 */ 683 681 public function mark_accepted_by_id( $id, $args ) { … … 708 706 * 709 707 * @see BP_Invitation::delete for a description of arguments. 708 * 710 709 * @return int|bool Number of rows deleted on success, false on failure. 711 710 */ … … 743 742 */ 744 743 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 ); 748 749 } 749 750 … … 772 773 * @since 5.0.0 773 774 * 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() { 778 778 return true; 779 779 } … … 785 785 * @since 5.0.0 786 786 * 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() { 791 790 return true; 792 791 } 793 794 792 }
Note: See TracChangeset
for help on using the changeset viewer.