<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[BuddyPress][12873] trunk: BP_Invitation: Increment date_modified on key actions.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="http://buddypress.trac.wordpress.org/changeset/12873">12873</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"http://buddypress.trac.wordpress.org/changeset/12873","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>dcavins</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2021-03-23 23:31:33 +0000 (Tue, 23 Mar 2021)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>BP_Invitation: Increment date_modified on key actions.
When an invitation is sent or accepted, the `date_modified`
should be updated. However, if a `date_modified` has been
specified in the invitation or request creation function
(as we do in our unit test functions), the `date_modified`
should be set to that, even if notices are sent (now) as
part of the creation process.
Ensure that BP_Invitation::get_query_clauses() handles specified date_modified data updates.
Fixes <a href="http://buddypress.trac.wordpress.org/ticket/8444">#8444</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcbpcoreclassesclassbpinvitationmanagerphp">trunk/src/bp-core/classes/class-bp-invitation-manager.php</a></li>
<li><a href="#trunksrcbpcoreclassesclassbpinvitationphp">trunk/src/bp-core/classes/class-bp-invitation.php</a></li>
<li><a href="#trunksrcbpgroupsbpgroupsfunctionsphp">trunk/src/bp-groups/bp-groups-functions.php</a></li>
<li><a href="#trunktestsphpunittestcasescoreinvitationsphp">trunk/tests/phpunit/testcases/core/invitations.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcbpcoreclassesclassbpinvitationmanagerphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/bp-core/classes/class-bp-invitation-manager.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-core/classes/class-bp-invitation-manager.php 2021-03-22 19:51:14 UTC (rev 12872)
+++ trunk/src/bp-core/classes/class-bp-invitation-manager.php 2021-03-23 23:31:33 UTC (rev 12873)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -139,7 +139,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // "Send" the invite if necessary.
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $invite_id && $r['send_invite'] ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $sent = $this->send_invitation_by_id( $invite_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $sent = $this->send_invitation_by_id( $invite_id, $r );
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! $sent ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -154,11 +154,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 5.0.0
</span><span class="cx" style="display: block; padding: 0 10px"> * @access public
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param int $invitation_id ID of invitation to send.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param int $invitation_id ID of invitation to send.
+ * @param array $args See BP_Invitation::mark_sent().
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @return int|bool The number of rows updated, or false on error.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function send_invitation_by_id( $invitation_id = 0 ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function send_invitation_by_id( $invitation_id = 0, $args = array() ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $updated = false;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $invitation = new BP_Invitation( $invitation_id );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -196,7 +197,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // Perform the send action.
</span><span class="cx" style="display: block; padding: 0 10px"> $this->run_send_action( $invitation );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $updated = BP_Invitation::mark_sent( $invitation->id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $updated = BP_Invitation::mark_sent( $invitation->id, $args );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> return $updated;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -305,11 +306,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 5.0.0
</span><span class="cx" style="display: block; padding: 0 10px"> * @access public
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param int $request_id ID of request to send.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param int $request_id ID of request to send.
+ * @param array $args See BP_Invitation::mark_sent().
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @return int|bool The number of rows updated, or false on error.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function send_request_notification_by_id( $request_id = 0 ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function send_request_notification_by_id( $request_id = 0, $args = array() ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $updated = false;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $request = new BP_Invitation( $request_id );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -325,7 +327,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Before sending notifications, check for outstanding invitations to the same item.
</span><span class="cx" style="display: block; padding: 0 10px"> * A sent invitation + a request = acceptance.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $args = array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $invite_args = array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'user_id' => $request->user_id,
</span><span class="cx" style="display: block; padding: 0 10px"> 'invitee_email' => $request->invitee_email,
</span><span class="cx" style="display: block; padding: 0 10px"> 'item_id' => $request->item_id,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -332,17 +334,17 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'secondary_item_id' => $request->secondary_item_id,
</span><span class="cx" style="display: block; padding: 0 10px"> 'invite_sent' => 'sent'
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $invites = $this->invitation_exists( $args );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $invites = $this->invitation_exists( $invite_args );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $invites ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> // Accept the request.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return $this->accept_invitation( $args );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return $this->accept_invitation( $invite_args );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Perform the send action.
</span><span class="cx" style="display: block; padding: 0 10px"> $this->run_send_action( $request );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $updated = BP_Invitation::mark_sent( $request->id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $updated = BP_Invitation::mark_sent( $request->id, $args );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> return $updated;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -452,19 +454,26 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @see BP_Invitation::get() for a description of
</span><span class="cx" style="display: block; padding: 0 10px"> * accepted update/where arguments.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param array $update_args Associative array of fields to update,
- * and the values to update them to. Of the format
- * array( 'user_id' => 4 )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param array $args {
+ * Invitation characteristics. Some basic info is required to accept an invitation,
+ * because we'll need to accept all similar invitations and requests.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @type int $user_id User ID of the invitee.
+ * Either 'user_id' or 'invitee_email' is required.
+ * @type string $invitee_email Email address of the invitee.
+ * Either 'user_id' or 'invitee_email' is required.
+ * @type int $item_id Item ID of the invitation to accept.
+ * @type int $secondary_item_id Optional. Secondary item ID if needed.
+ * @type string $invite_sent Optional. Defaults to only allowing the
+ * acceptance of sent invitations.
+ * @type string $date_modified Modified time in 'Y-m-d h:i:s' format, GMT.
+ * Defaults to current time if not specified.
+ * }
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * @return int|bool Number of rows updated on success, false on failure.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function accept_invitation( $args = array() ) {
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /*
- * Some basic info is required to accept an invitation,
- * because we'll need to mark all similar invitations and requests.
- * The following, except the optional 'secondary_item_id', are required.
- */
</del><span class="cx" style="display: block; padding: 0 10px"> $r = bp_parse_args( $args, array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'user_id' => 0,
</span><span class="cx" style="display: block; padding: 0 10px"> 'invitee_email' => '',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -471,6 +480,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'item_id' => null,
</span><span class="cx" style="display: block; padding: 0 10px"> 'secondary_item_id' => null,
</span><span class="cx" style="display: block; padding: 0 10px"> 'invite_sent' => 'sent',
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'date_modified' => bp_core_current_time(),
</ins><span class="cx" style="display: block; padding: 0 10px"> ), 'accept_invitation' );
</span><span class="cx" style="display: block; padding: 0 10px"> $r['class'] = $this->class_name;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -501,22 +511,26 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @see BP_Invitation::get() for a description of
</span><span class="cx" style="display: block; padding: 0 10px"> * accepted update/where arguments.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param array $update_args Associative array of fields to update,
- * and the values to update them to. Of the format
- * array( 'user_id' => 4 )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param array $args {
+ * Invitation characteristics. Some basic info is required to accept an invitation,
+ * because we'll need to accept all similar invitations and requests.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @type int $user_id User ID of the invitee.
+ * @type int $item_id Item ID of the invitation to accept.
+ * @type int $secondary_item_id Optional. Secondary item ID if needed.
+ * @type string $date_modified Modified time in 'Y-m-d h:i:s' format, GMT.
+ * Defaults to current time if not specified.
+ * }
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * @return bool Number of rows updated on success, false on failure.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function accept_request( $args = array() ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /*
- * Some basic info is required to accept an invitation,
- * because we'll need to accept all similar invitations and requests.
- * The following, except the optional 'secondary_item_id', are required.
- */
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $r = bp_parse_args( $args, array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'user_id' => 0,
</span><span class="cx" style="display: block; padding: 0 10px"> 'item_id' => null,
</span><span class="cx" style="display: block; padding: 0 10px"> 'secondary_item_id' => null,
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'date_modified' => bp_core_current_time(),
</ins><span class="cx" style="display: block; padding: 0 10px"> ), 'accept_request' );
</span><span class="cx" style="display: block; padding: 0 10px"> $r['class'] = $this->class_name;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -618,11 +632,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 5.0.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param int $id The ID of the invitation to mark as sent.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @see BP_Invitation::mark_accepted()
+ * for a description of arguments.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @return bool True on success, false on failure.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function mark_accepted_by_id( $id ) {
- return BP_Invitation::mark_accepted( $id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function mark_accepted_by_id( $id, $args ) {
+ return BP_Invitation::mark_accepted( $id, $args );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span></span></pre></div>
<a id="trunksrcbpcoreclassesclassbpinvitationphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/bp-core/classes/class-bp-invitation.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-core/classes/class-bp-invitation.php 2021-03-22 19:51:14 UTC (rev 12872)
+++ trunk/src/bp-core/classes/class-bp-invitation.php 2021-03-23 23:31:33 UTC (rev 12873)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -640,6 +640,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // date_modified
+ if ( ! empty( $args['date_modified'] ) ) {
+ $where_clauses['data']['date_modified'] = $args['date_modified'];
+ $where_clauses['format'][] = '%s';
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> return $where_clauses;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -987,9 +993,17 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 5.0.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param int $id The ID of the invitation to mark as sent.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param int $id The ID of the invitation to mark as sent.
+ * @param array $args {
+ * Optional. Invitation characteristics used
+ * to override certain sending behaviors.
+ *
+ * @type string $date_modified Modified time in 'Y-m-d h:i:s' format, GMT.
+ * Defaults to current time if not specified.
+ * }
+ * @return int|bool The number of rows updated, or false on error.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public static function mark_sent( $id = 0 ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function mark_sent( $id = 0, $args = array() ) {
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! $id ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -997,8 +1011,13 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Values to be updated.
</span><span class="cx" style="display: block; padding: 0 10px"> $update_args = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'invite_sent' => 'sent',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'invite_sent' => 'sent',
+ 'date_modified' => bp_core_current_time(),
</ins><span class="cx" style="display: block; padding: 0 10px"> );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Respect a specified `date-modified`.
+ if ( ! empty( $args['date_modified'] ) ) {
+ $update_args['date_modified'] = $args['date_modified'];
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // WHERE clauses.
</span><span class="cx" style="display: block; padding: 0 10px"> $where_args = array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1014,14 +1033,20 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 5.0.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param array $args See BP_Invitation::update().
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param array $args See BP_Invitation::update().
+ * @return int|bool The number of rows updated, or false on error.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public static function mark_sent_by_data( $args ) {
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Values to be updated.
</span><span class="cx" style="display: block; padding: 0 10px"> $update_args = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'invite_sent' => 'sent',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'invite_sent' => 'sent',
+ 'date_modified' => bp_core_current_time(),
</ins><span class="cx" style="display: block; padding: 0 10px"> );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Respect a specified `date-modified`.
+ if ( ! empty( $args['date_modified'] ) ) {
+ $update_args['date_modified'] = $args['date_modified'];
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> return self::update( $update_args, $args );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1033,9 +1058,17 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 5.0.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param int $id The ID of the invitation to mark as sent.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param int $id The ID of the invitation to mark as sent.
+ * @param array $args {
+ * Optional. Invitation characteristics used
+ * to override certain sending behaviors.
+ *
+ * @type string $date_modified Modified time in 'Y-m-d h:i:s' format, GMT.
+ * Defaults to current time if not specified.
+ * }
+ * @return int|bool The number of rows updated, or false on error.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public static function mark_accepted( $id = 0 ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function mark_accepted( $id = 0, $args = array() ) {
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! $id ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1043,8 +1076,13 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Values to be updated.
</span><span class="cx" style="display: block; padding: 0 10px"> $update_args = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'accepted' => 'accepted',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'accepted' => 'accepted',
+ 'date_modified' => bp_core_current_time(),
</ins><span class="cx" style="display: block; padding: 0 10px"> );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Respect a specified `date-modified`.
+ if ( ! empty( $args['date_modified'] ) ) {
+ $update_args['date_modified'] = $args['date_modified'];
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // WHERE clauses.
</span><span class="cx" style="display: block; padding: 0 10px"> $where_args = array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1060,14 +1098,20 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 5.0.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param array $args See BP_Invitation::update().
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param array $args See BP_Invitation::update().
+ * @return int|bool The number of rows updated, or false on error.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public static function mark_accepted_by_data( $args ) {
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Values to be updated.
</span><span class="cx" style="display: block; padding: 0 10px"> $update_args = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'accepted' => 'accepted',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'accepted' => 'accepted',
+ 'date_modified' => bp_core_current_time(),
</ins><span class="cx" style="display: block; padding: 0 10px"> );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Respect a specified `date-modified`.
+ if ( ! empty( $args['date_modified'] ) ) {
+ $update_args['date_modified'] = $args['date_modified'];
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> return self::update( $update_args, $args );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunksrcbpgroupsbpgroupsfunctionsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/bp-groups/bp-groups-functions.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-groups/bp-groups-functions.php 2021-03-22 19:51:14 UTC (rev 12872)
+++ trunk/src/bp-groups/bp-groups-functions.php 2021-03-23 23:31:33 UTC (rev 12873)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2044,7 +2044,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // If a new request was created, send the emails.
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $request_id && is_int( $request_id ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $invites_class->send_request_notification_by_id( $request_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $invites_class->send_request_notification_by_id( $request_id, $r );
</ins><span class="cx" style="display: block; padding: 0 10px"> $admins = groups_get_group_admins( $r['group_id'] );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span></span></pre></div>
<a id="trunktestsphpunittestcasescoreinvitationsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/testcases/core/invitations.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/testcases/core/invitations.php 2021-03-22 19:51:14 UTC (rev 12872)
+++ trunk/tests/phpunit/testcases/core/invitations.php 2021-03-23 23:31:33 UTC (rev 12873)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -332,4 +332,52 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->set_current_user( $old_current_user );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_bp_invitations_add_request_with_date_modified() {
+ $old_current_user = get_current_user_id();
+
+ $u1 = $this->factory->user->create();
+ $this->set_current_user( $u1 );
+
+ $invites_class = new BPTest_Invitation_Manager_Extension();
+
+ $time = gmdate( 'Y-m-d H:i:s', time() - 100 );
+ $args = array(
+ 'user_id' => $u1,
+ 'item_id' => 7,
+ 'date_modified' => $time,
+ );
+ $r1 = $invites_class->add_request( $args );
+
+ $req = new BP_Invitation( $r1 );
+ $this->assertEquals( $time, $req->date_modified );
+
+ $this->set_current_user( $old_current_user );
+ }
+
+ public function test_bp_invitations_add_invite_with_date_modified() {
+ $old_current_user = get_current_user_id();
+
+ $u1 = $this->factory->user->create();
+ $u2 = $this->factory->user->create();
+ $this->set_current_user( $u1 );
+
+ $invites_class = new BPTest_Invitation_Manager_Extension();
+ $time = gmdate( 'Y-m-d H:i:s', time() - 100 );
+
+ // Create an invitation.
+ $invite_args = array(
+ 'user_id' => $u2,
+ 'inviter_id' => $u1,
+ 'item_id' => 1,
+ 'send_invite' => 1,
+ 'date_modified' => $time,
+ );
+ $i1 = $invites_class->add_invitation( $invite_args );
+
+ $inv = new BP_Invitation( $i1 );
+ $this->assertEquals( $time, $inv->date_modified );
+
+ $this->set_current_user( $old_current_user );
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre>
</div>
</div>
</body>
</html>