<!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>[12591] sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin: Plugin Directory: Introduce assigned reviewer functionality.</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://meta.trac.wordpress.org/changeset/12591">12591</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"http://meta.trac.wordpress.org/changeset/12591","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>dd32</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2023-05-17 08:38:01 +0000 (Wed, 17 May 2023)</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'>Plugin Directory: Introduce assigned reviewer functionality.

Previously the group of reviewers was so small that they knew who was handling which submission, now that we have a larger set of reviewers being onboarded we need to keep track of review assignments a bit better.

See <a href="http://meta.trac.wordpress.org/ticket/6993">#6993</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectoryadminclasscustomizationsphp">sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/class-customizations.php</a></li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectoryadminlisttableclasspluginpostsphp">sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/list-table/class-plugin-posts.php</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectoryadminmetaboxclassreviewerphp">sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-reviewer.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectoryadminclasscustomizationsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/class-customizations.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/class-customizations.php  2023-05-16 20:16:11 UTC (rev 12590)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/class-customizations.php    2023-05-17 08:38:01 UTC (rev 12591)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -63,9 +63,14 @@
</span><span class="cx" style="display: block; padding: 0 10px">                add_filter( 'wp_ajax_delete-support-rep', array( __NAMESPACE__ . '\Metabox\Support_Reps', 'remove_support_rep' ) );
</span><span class="cx" style="display: block; padding: 0 10px">                add_action( 'wp_ajax_plugin-author-lookup', array( __NAMESPACE__ . '\Metabox\Author', 'lookup_author' ) );
</span><span class="cx" style="display: block; padding: 0 10px">                add_action( 'wp_ajax_plugin-svn-sync', array( __NAMESPACE__ . '\Metabox\Review_Tools', 'svn_sync' ) );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                add_action( 'wp_ajax_plugin-set-reviewer', array( __NAMESPACE__ . '\Metabox\Reviewer', 'xhr_set_reviewer' ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                add_action( 'save_post', array( __NAMESPACE__ . '\Metabox\Release_Confirmation', 'save_post' ) );
</span><span class="cx" style="display: block; padding: 0 10px">                add_action( 'save_post', array( __NAMESPACE__ . '\Metabox\Author_Notice', 'save_post' ) );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                add_action( 'save_post', array( __NAMESPACE__ . '\Metabox\Reviewer', 'save_post' ) );
+
+               // Audit logs
+               add_action( 'updated_postmeta', array( $this, 'updated_postmeta' ), 10, 4 );
</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 class="lines" style="display: block; padding: 0 10px; color: #888">@@ -211,6 +216,17 @@
</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">+                // Filter by reviewer.
+               if ( ! empty( $_REQUEST['reviewer'] ) ) {
+                       $meta_query = $query->get( 'meta_query' ) ?: [];
+                       $meta_query[] = [
+                               'key'   => 'assigned_reviewer',
+                               'value' => intval( $_GET['reviewer'] ),
+                       ];
+
+                       $query->set( 'meta_query', $meta_query );
+               }
+
</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 class="lines" style="display: block; padding: 0 10px; color: #888">@@ -241,7 +257,7 @@
</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">                $action = array_intersect(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        [ 'plugin_open', 'plugin_close', 'plugin_disable', 'plugin_reject' ],
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 [ 'plugin_open', 'plugin_close', 'plugin_disable', 'plugin_reject', 'plugin_assign' ],
</ins><span class="cx" style="display: block; padding: 0 10px">                         [ $_REQUEST['action'], $_REQUEST['action2'] ]
</span><span class="cx" style="display: block; padding: 0 10px">                );
</span><span class="cx" style="display: block; padding: 0 10px">                $action = array_shift( $action );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -251,6 +267,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                check_admin_referer( 'bulk-posts' );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                $new_status = false;
+               $from_state = false;
+               $meta_data  = false;
+
</ins><span class="cx" style="display: block; padding: 0 10px">                 switch( $action ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        case 'plugin_open':
</span><span class="cx" style="display: block; padding: 0 10px">                                $capability = 'plugin_approve';
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -276,27 +296,51 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                $message    = _n_noop( '%s plugin rejected.', '%s plugins rejected.', 'wporg-plugins' );
</span><span class="cx" style="display: block; padding: 0 10px">                                $from_state = [ 'new', 'pending' ];
</span><span class="cx" style="display: block; padding: 0 10px">                                break;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                        case 'plugin_assign':
+                               if ( ! isset( $_REQUEST['reviewer'] ) ) {
+                                       return;
+                               }
+
+                               $capability = 'plugin_review';
+                               $from_state = 'any';
+                               $message    = _n_noop( '%s plugin assigned.', '%s plugins assigned.', 'wporg-plugins' );
+                               $meta_data = array(
+                                       'assigned_reviewer'      => intval( $_REQUEST['reviewer'] ),
+                                       'assigned_reviewer_time' => time(),
+                               );
+                               break;
</ins><span class="cx" style="display: block; padding: 0 10px">                         default:
</span><span class="cx" style="display: block; padding: 0 10px">                                return;
</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">                $closed = 0;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $plugins  = get_posts( array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $args = array(
</ins><span class="cx" style="display: block; padding: 0 10px">                         'post_type'      => 'plugin',
</span><span class="cx" style="display: block; padding: 0 10px">                        'post__in'       => array_map( 'absint', $_REQUEST['post'] ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        'post_status'    => $from_state,
</del><span class="cx" style="display: block; padding: 0 10px">                         'posts_per_page' => count( $_REQUEST['post'] ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         );
+               if ( $from_state ) {
+                       $args['post_status'] = $from_state;
+               }
+               $plugins  = get_posts( $args );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                foreach ( $plugins as $plugin ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        if ( ! current_user_can( $capability, $plugin ) ) {
</span><span class="cx" style="display: block; padding: 0 10px">                                continue;
</span><span class="cx" style="display: block; padding: 0 10px">                        }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                        $updated = false;
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        $updated = wp_update_post( array(
-                               'ID'          => $plugin->ID,
-                               'post_status' => $new_status,
-                       ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 if ( $new_status ) {
+                               $updated = wp_update_post( array(
+                                       'ID'          => $plugin->ID,
+                                       'post_status' => $new_status,
+                               ) );
+                       }
+                       if ( $meta_data ) {
+                               foreach ( $meta_data as $key => $value ) {
+                                       $updated = update_post_meta( $plugin->ID, $key, $value );
+                               }
+                       }
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                        if ( $updated && ! is_wp_error( $updated ) ) {
</span><span class="cx" style="display: block; padding: 0 10px">                                $closed++;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -547,6 +591,13 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        'plugin', 'side', 'high'
</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">+                add_meta_box(
+                       'reviewerdiv',
+                       __( 'Reviewer', 'wporg-plugins' ),
+                       array( __NAMESPACE__ . '\Metabox\Reviewer', 'display' ),
+                       'plugin', 'side', 'high'
+               );
+
</ins><span class="cx" style="display: block; padding: 0 10px">                 if ( 'new' !== $post->post_status && 'pending' != $post->post_status ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        add_meta_box(
</span><span class="cx" style="display: block; padding: 0 10px">                                'plugin-committers',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -806,4 +857,23 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                return $keys;
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+       /**
+        * Watch for post_meta updates and log accordingly.
+        */
+       public function updated_postmeta( $meta_id, $post_id, $meta_key, $meta_value ) {
+               if ( 'assigned_reviewer' === $meta_key && $meta_value ) {
+                       $reviewer = get_user_by( 'id', $meta_value );
+                       Tools::audit_log(
+                               sprintf(
+                                       'Assigned to <a href="%s">%s</a>.',
+                                       esc_url( 'https://profiles.wordpress.org/' . $reviewer->user_nicename . '/' ),
+                                       $reviewer->display_name ?: $reviewer->user_login
+                               ),
+                               get_post( $post_id )
+                       );
+               } elseif ( 'assigned_reviewer' === $meta_key && ! $meta_value ) {
+                       Tools::audit_log( 'Unassigned.', get_post( $post_id ) );
+               }
+       }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectoryadminlisttableclasspluginpostsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/list-table/class-plugin-posts.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/list-table/class-plugin-posts.php 2023-05-16 20:16:11 UTC (rev 12590)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/list-table/class-plugin-posts.php   2023-05-17 08:38:01 UTC (rev 12591)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -94,6 +94,10 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        $actions['plugin_disable'] = __( 'Disable', 'wporg-plugins' );
</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">+                if ( current_user_can( 'plugin_review' ) ) {
+                       $actions['plugin_assign'] = __( 'Assign reviewer', 'wporg-plugins' );
+               }
+
</ins><span class="cx" style="display: block; padding: 0 10px">                 return $actions;
</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">@@ -104,10 +108,11 @@
</span><span class="cx" style="display: block; padding: 0 10px">        public function get_columns() {
</span><span class="cx" style="display: block; padding: 0 10px">                $post_type     = $this->screen->post_type;
</span><span class="cx" style="display: block; padding: 0 10px">                $posts_columns = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        'cb'     => '<input type="checkbox" />',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 'cb'       => '<input type="checkbox" />',
</ins><span class="cx" style="display: block; padding: 0 10px">                         /* translators: manage posts column name */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        'title'  => _x( 'Title', 'column name', 'wporg-plugins' ),
-                       'author' => __( 'Submitter', 'wporg-plugins' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 'title'    => _x( 'Title', 'column name', 'wporg-plugins' ),
+                       'author'   => __( 'Submitter', 'wporg-plugins' ),
+                       'reviewer' => __( 'Assigned Reviewer', 'wporg-plugins' ),
</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">                $taxonomies = get_object_taxonomies( $post_type, 'objects' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -410,8 +415,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                        $mine_inner_html = sprintf(
</span><span class="cx" style="display: block; padding: 0 10px">                                _nx(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                        'Mine <span class="count">(%s)</span>',
-                                       'Mine <span class="count">(%s)</span>',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                 'My Plugins <span class="count">(%s)</span>',
+                                       'My Plugins <span class="count">(%s)</span>',
</ins><span class="cx" style="display: block; padding: 0 10px">                                         $user_post_count,
</span><span class="cx" style="display: block; padding: 0 10px">                                        'posts',
</span><span class="cx" style="display: block; padding: 0 10px">                                        'wporg-plugins'
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -447,6 +452,36 @@
</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">                $status_links['all'] = $this->get_edit_link( $all_args, $all_inner_html, $class );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+               // Assigned to me.
+               if ( current_user_can( 'plugin_review' ) ) {
+                       $assigned_count = $wpdb->get_var( $wpdb->prepare(
+                               "SELECT COUNT(p.ID)
+                               FROM $wpdb->posts p
+                                       JOIN $wpdb->postmeta pm ON p.ID = pm.post_id
+                               WHERE pm.meta_key = 'assigned_reviewer' AND pm.meta_value = %d AND p.post_status NOT IN( 'approved', 'publish' )",
+                               get_current_user_id()
+                       ) );
+
+                       $assigned_args = array(
+                               'post_type' => $post_type,
+                               'reviewer'  => get_current_user_id(),
+                       );
+
+                       $assigned_label = sprintf(
+                               _nx(
+                                       'Assigned to Me <span class="count">(%s)</span>',
+                                       'Assigned to Me <span class="count">(%s)</span>',
+                                       $assigned_count,
+                                       'posts',
+                                       'wporg-plugins'
+                               ),
+                               number_format_i18n( $assigned_count )
+                       );
+
+                       $status_links['assigned'] = $this->get_edit_link( $assigned_args, $assigned_label, ( ($_REQUEST['reviewer'] ?? 0) === get_current_user_id() ? 'current' : '' ) );
+               }
+
</ins><span class="cx" style="display: block; padding: 0 10px">                 if ( $mine ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        $status_links['mine'] = $mine;
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -518,6 +553,36 @@
</span><span class="cx" style="display: block; padding: 0 10px">        public function extra_tablenav( $which ) {
</span><span class="cx" style="display: block; padding: 0 10px">                parent::extra_tablenav( $which );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                if ( 'top' === $which ) {
+                       // The first is the reviewer filter, the second is the assign review bulk action.
+                       ?>
+                       <fieldset class="alignleft actions filter-reviewer">
+                               <?php
+                               wp_dropdown_users( [
+                                       'name'              => 'reviewer',
+                                       'selected'          => intval( $_REQUEST['reviewer'] ?? 0 ),
+                                       'show_option_none'  => __( 'All Reviewers', 'wporg-plugins' ),
+                                       'option_none_value' => 0,
+                                       'role__in'          => [ 'plugin_admin', 'plugin_reviewer' ],
+                               ] );
+                               submit_button( __( 'Filter', 'wporg-plugins' ), 'secondary', false, false );
+                               ?>
+                       </fieldset>
+                       <fieldset class="alignleft actions hide-if-js bulk-plugin_assign" disabled="disabled">
+                               <?php
+                               wp_dropdown_users( [
+                                       'name'              => 'reviewer',
+                                       'selected'          => 0,
+                                       'show_option_none'  => __( 'Assign Review to ...', 'wporg-plugins' ),
+                                       'option_none_value' => 0,
+                                       'role__in'          => [ 'plugin_admin', 'plugin_reviewer' ],
+                               ] );
+                               submit_button( __( 'Assign', 'wporg-plugins' ), 'primary', false, false );
+                               ?>
+                       </fieldset>
+                       <?php
+               }
+
</ins><span class="cx" style="display: block; padding: 0 10px">                 // TODO: This shouldn't have inline CSS/JS.
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                if ( 'top' === $which ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -529,6 +594,12 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                                <option value="<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $label ); ?></option>
</span><span class="cx" style="display: block; padding: 0 10px">                                        <?php endforeach; ?>
</span><span class="cx" style="display: block; padding: 0 10px">                                </select>
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                <span class="actions bulk-plugin_close">
+                                       <?php submit_button( __( 'Close', 'wporg-plugins' ), 'primary', 'bulk_close', false ); ?>
+                               </span>
+                               <span class="actions bulk-plugin_disable">
+                                       <?php submit_button( __( 'Disable', 'wporg-plugins' ), 'primary', 'bulk_close', false ); ?>
+                               </span>
</ins><span class="cx" style="display: block; padding: 0 10px">                         </fieldset>
</span><span class="cx" style="display: block; padding: 0 10px">                        <style>
</span><span class="cx" style="display: block; padding: 0 10px">                                #posts-filter fieldset.bulk-plugin_close {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -542,7 +613,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                                val = $this.find(':selected').val(),
</span><span class="cx" style="display: block; padding: 0 10px">                                                $tablenav = $this.parents('form').find( '.tablenav.top' );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                        $tablenav.find( '.actions.bulk-plugin_close, .actions.bulk-plugin_disable' ).prop( 'disabled', true ).hide();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                 $tablenav.find( '.actions.bulk-plugin_close, .actions.bulk-plugin_disable, .actions.bulk-plugin_assign' ).prop( 'disabled', true ).hide();
</ins><span class="cx" style="display: block; padding: 0 10px">                                         $tablenav.find( '.actions.bulk-' + val ).prop( 'disabled', false ).show();
</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">@@ -550,4 +621,26 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        <?php
</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">+
+       /**
+        * The custom Assigned Reviewer column.
+        */
+       public function column_reviewer( $post ) {
+               $reviewer_id   = (int) ( $post->assigned_reviewer ?? 0 );
+               $reviewer      = $reviewer_id ? get_user_by( 'id', $reviewer_id ) : false;
+               $reviewer_time = (int) ( $post->assigned_reviewer_time ?? 0 );
+
+               if ( $reviewer ) {
+                       printf(
+                               "<a href='%s'>%s</a><br><span>%s</span>",
+                               add_query_arg( [ 'reviewer' => $reviewer_id ] ),
+                               $reviewer->display_name ?: $reviewer->user_login,
+                               sprintf(
+                                       /* translators: %s The time/date different, '1 hour' */
+                                       __( '%s ago', 'wporg-plugins' ),
+                                       human_time_diff( $reviewer_time )
+                               )
+                       );
+               }
+       }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectoryadminmetaboxclassreviewerphp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-reviewer.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-reviewer.php                                (rev 0)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-reviewer.php  2023-05-17 08:38:01 UTC (rev 12591)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,132 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+/**
+ * The Plugin Reviewer metabox.
+ *
+ * @package WordPressdotorg\Plugin_Directory\Admin\Metabox
+ */
+
+namespace WordPressdotorg\Plugin_Directory\Admin\Metabox;
+
+use WordPressdotorg\Plugin_Directory\Template;
+use WordPressdotorg\Plugin_Directory\Tools;
+
+/**
+ * The Plugin Reviewer metabox.
+ *
+ * @package WordPressdotorg\Plugin_Directory\Admin\Metabox
+ */
+class Reviewer {
+
+       /**
+        * Displays the Assigned Reviewer metabox.
+        */
+       public static function display() {
+               $post = get_post();
+
+               // Fetch the assigned reviewer.
+               $reviewer_id     = (int) ( $post->assigned_reviewer ?? 0 );
+               $reviewer_time   = (int) ( $post->assigned_reviewer_time ?? 0 );
+               $reviewer        = $reviewer_id ? get_user_by( 'id', $reviewer_id ) : false;
+               $is_current_user = $reviewer_id === get_current_user_id();
+
+               // Display the reviewer assignee dropdown.
+               wp_dropdown_users( [
+                       'name'              => 'assigned_reviewer',
+                       'selected'          => $reviewer_id,
+                       'show_option_none'  => '— No one —',
+                       'option_none_value' => 0,
+                       'role__in'          => [ 'plugin_admin', 'plugin_reviewer' ],
+               ] );
+               wp_nonce_field( 'set_reviewer', '_set_reviewer_nonce' );
+               echo '<span class="spinner"></span>';
+               echo '<style>#assigned_reviewer { width: 80%; }</style>';
+
+               // Display the "Assign to me" button.
+               if ( ! $reviewer_id ) {
+                       ?>
+                       <p style="text-align: right">
+                               <button type="button" class="button-primary" id="assign-to-me"><?php esc_html_e( 'Assign to me', 'wporg-plugins' ); ?></button>
+                       </p>
+                       <?php
+               } else {
+                       printf( '<p>%s ago</p>', human_time_diff( $reviewer_time ) );
+               }
+
+               ?>
+               <script>
+                       jQuery( function( $ ) {
+                               $( '#assign-to-me' ).click( function( e ) {
+                                       e.preventDefault();
+                                       $(this).prop( 'disabled', true );
+
+                                       $('#assigned_reviewer').val( userSettings.uid ).change();
+                               } );
+
+                               // XHR save it.
+                               $('#assigned_reviewer').change( function( e ) {
+                                       var $this = $(this),
+                                               $spinner = $(this).parent().find('.spinner'),
+                                               nonce = $('#_set_reviewer_nonce').val();
+
+                                       e.preventDefault();
+                                       $spinner.addClass('is-active');
+
+                                       $.post(
+                                               ajaxurl,
+                                               {
+                                                       action: 'plugin-set-reviewer',
+                                                       _set_reviewer_nonce: nonce,
+                                                       post_id: new URL(document.location).searchParams.get('post'),
+                                                       assigned_reviewer: $this.val(),
+                                               },
+                                               function() {
+                                                       $spinner.removeClass('is-active');
+                                               }
+                                       );
+                               } );
+                       } );
+               </script>
+               <?php
+       }
+
+       /**
+        * Set the Reviewer via XHR.
+        */
+       public static function xhr_set_reviewer() {
+               check_admin_referer( 'set_reviewer', '_set_reviewer_nonce' );
+
+               $post_id     = absint( $_POST['post_id'] ?? 0 );
+               $reviewer_id = absint( $_POST['assigned_reviewer'] ?? 0 );
+
+               if ( ! $post_id || ! current_user_can( 'plugin_admin_edit', $post_id ) ) {
+                       return;
+               }
+
+               update_post_meta( $post_id, 'assigned_reviewer', $reviewer_id );
+               update_post_meta( $post_id, 'assigned_reviewer_time', time() );
+
+               $assigned_reviewer = get_post_meta( $post_id, 'assigned_reviewer', true );
+
+               die( json_encode( compact( 'assigned_reviewer' ) ) );
+       }
+
+       /**
+        * Set the reviewer on save.
+        *
+        * @param int|WP_Post $post Post ID or post object.
+        */
+       public static function save_post( $post_id ) {
+               if (
+                       ! current_user_can( 'plugin_admin_edit', $post_id ) ||
+                       ! isset( $_POST['_set_reviewer_nonce'] ) ||
+                       ! wp_verify_nonce( $_POST['_set_reviewer_nonce'], 'set_reviewer' )
+               ) {
+                       return;
+               }
+
+               $reviewer_id = absint( $_POST['assigned_reviewer'] ?? 0 );
+
+               update_post_meta( $post_id, 'assigned_reviewer', $reviewer_id );
+               update_post_meta( $post_id, 'assigned_reviewer_time', time() );
+       }
+}
</ins><span class="cx" style="display: block; padding: 0 10px">Property changes on: sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-reviewer.php
</span><span class="cx" style="display: block; padding: 0 10px">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: svn:eol-style</h4></div>
<ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+native
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span></div>

</body>
</html>