<!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>[2930] sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory: Plugin Directory: Initial setup for post status transitions.</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 { 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/2930">2930</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/2930","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>obenland</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2016-04-11 13:42:53 +0000 (Mon, 11 Apr 2016)</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: Initial setup for post status transitions.

Provides a place to handle post status transitions for plugins.

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

<h3>Modified Paths</h3>
<ul>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectoryclasscapabilitiesphp">sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-capabilities.php</a></li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectoryclassplugindirectoryphp">sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-directory.php</a></li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectorytoolsclasssvnphp">sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/tools/class-svn.php</a></li>
</ul>

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

</div>
<div id="patch">
<h3>Diff</h3>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectoryadminclassstatustransitionsphp"></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/class-status-transitions.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-status-transitions.php                              (rev 0)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/class-status-transitions.php        2016-04-11 13:42:53 UTC (rev 2930)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,107 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+namespace WordPressdotorg\Plugin_Directory\Admin;
+use WordPressdotorg\Plugin_Directory\Tools;
+use WordPressdotorg\Plugin_Directory\Tools\SVN;
+
+/**
+ * All functionality related to Status Transitions.
+ *
+ * @package WordPressdotorg\Plugin_Directory\Admin
+ */
+class Status_Transitions {
+
+       /**
+        * Fetch the instance of the Status Transitions class.
+        */
+       public static function instance() {
+               static $instance = null;
+
+               return ! is_null( $instance ) ? $instance : $instance = new Status_Transitions();
+       }
+
+       /**
+        * Constructor.
+        */
+       private function __construct() {
+               add_action( 'publish_plugin', array( $this, 'publish' ), 10, 2 );
+               add_action( 'rejected_plugin', array( $this, 'rejected' ), 10, 2 );
+       }
+
+       /**
+        * Fires when a post is transitioned to 'publish'.
+        *
+        * @param int      $post_id Post ID.
+        * @param \WP_Post $post    Post object.
+        */
+       public function publish( $post_id, $post ) {
+               $plugin_author = get_user_by( 'id', $post->post_author );
+
+               // Create SVN repo.
+               $svn_dirs = array(
+                       "{$post->post_name}/",
+                       "{$post->post_name}/trunk",
+                       "{$post->post_name}/branches",
+                       "{$post->post_name}/tags",
+                       "{$post->post_name}/assets",
+               );
+               SVN::mkdir( $svn_dirs, array(
+                       'message' => sprintf( 'Adding %1$s by %2$s.', $post->post_title, $plugin_author->user_login ),
+               ) );
+
+               // Read zip and add/commit files to svn.
+               $attachments   = get_attached_media( 'application/zip', $post_id );
+               $attachment_id = $attachments[0]->ID;
+               SVN::add( Filesystem::unzip( get_attached_file( $attachment_id ) ) );
+
+               // Delete zip.
+               wp_delete_attachment( $attachment_id, true );
+
+               // Grant commit access.
+               Tools::grant_plugin_committer( $post->post_name, $plugin_author );
+
+               // Send email.
+               $subject = sprintf( __( '[WordPress Plugins] %s has been approved!', 'wporg-plugins' ), $post->post_title );
+
+               /* Translators: Plugin name. */
+               $content  = sprintf( __( 'Congratulations, your plugin hosting request for %s has been approved.', 'wporg-plugins' ), $post->post_title ). "\n";
+
+               $content .= __( 'Within one hour, you will have access to your SVN repository with your WordPress.org username and password (the same one you use on the forums).', 'wporg-plugins' ) . "\n";
+               $content .= "http://plugins.svn.wordpress.org/{$post->post_name}\n\n";
+
+               $content .= __( 'Here are some handy links to help you get started.', 'wporg-plugins' ) . "\n";
+               $content .= __( 'Using Subversion with the WordPress Plugins Directory', 'wporg-plugins' ) . "\n";
+               $content .= "https://wordpress.org/plugins/about/svn/\n\n";
+               $content .= __( 'FAQ about the WordPress Plugins Directory', 'wporg-plugins' ) . "\n";
+               $content .= "https://wordpress.org/plugins/about/faq/\n\n";
+               $content .= __( 'WordPress Plugins Directory readme.txt standard', 'wporg-plugins' ) . "\n";
+               $content .= "https://wordpress.org/plugins/about/readme.txt\n\n";
+               $content .= __( 'readme.txt validator:', 'wporg-plugins' ) . "\n";
+               $content .= "https://wordpress.org/plugins/about/validator/\n\n\n";
+
+               $content .= __( 'The WordPress.org Plugins Team', 'wporg-plugins' ) . "\n";
+               $content .= 'https://make.wordpress.org/plugins';
+
+               wp_mail( $plugin_author->user_email, $subject, $content, 'From: plugins@wordpress.org' );
+       }
+
+       /**
+        * Fires when a post is transitioned to 'rejected'.
+        *
+        * @param int      $post_id Post ID.
+        * @param \WP_Post $post    Post object.
+        */
+       public function rejected( $post_id, $post ) {
+               // Delete zip?
+
+               // Send email.
+               $email   = get_user_by( 'id', $post->post_author )->user_email;
+               $subject = sprintf( __( '[WordPress Plugins] %s has been rejected', 'wporg-plugins' ), $post->post_title );
+
+               /* Translators: Plugin name. */
+               $content  = sprintf( __( 'Unfortunately your plugin hosting request for %s has been rejected.', 'wporg-plugins' ), $post->post_title ). "\n\n\n";
+               $content .= __( 'The WordPress.org Plugins Team', 'wporg-plugins' ) . "\n";
+               $content .= 'https://make.wordpress.org/plugins';
+
+               wp_mail( $email, $subject, $content, 'From: plugins@wordpress.org' );
+       }
+}
</ins></span></pre></div>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectoryclasscapabilitiesphp"></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/class-capabilities.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/class-capabilities.php  2016-04-11 13:37:50 UTC (rev 2929)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-capabilities.php    2016-04-11 13:42:53 UTC (rev 2930)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -15,6 +15,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">         * @param string $cap           Capability name.
</span><span class="cx" style="display: block; padding: 0 10px">         * @param int    $user_id       The user ID.
</span><span class="cx" style="display: block; padding: 0 10px">         * @param array  $context       Adds the context to the cap. Typically the object ID.
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * @return array Primitive caps.
</ins><span class="cx" style="display: block; padding: 0 10px">          */
</span><span class="cx" style="display: block; padding: 0 10px">        public static function map_meta_cap( $required_caps, $cap, $user_id, $context ) {
</span><span class="cx" style="display: block; padding: 0 10px">                switch( $cap ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -80,13 +81,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $reviewer = array_merge( $committer, array(
</span><span class="cx" style="display: block; padding: 0 10px">                        'plugin_edit_pending' => true,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        'plugin_approve' => true,
-                       'plugin_reject' => true,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 'plugin_review' => true,
</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">                $admin = array_merge( $reviewer, array(
</span><span class="cx" style="display: block; padding: 0 10px">                        'plugin_add_committer' => true,
</span><span class="cx" style="display: block; padding: 0 10px">                        'plugin_edit_others' => true,
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                        'plugin_approve' => true,
+                       'plugin_reject' => true,
</ins><span class="cx" style="display: block; padding: 0 10px">                         'plugin_disable' => true,
</span><span class="cx" style="display: block; padding: 0 10px">                        'plugin_close' => true,
</span><span class="cx" style="display: block; padding: 0 10px">                        'plugin_set_category' => true, // Special categories
</span></span></pre></div>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectoryclassplugindirectoryphp"></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/class-plugin-directory.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/class-plugin-directory.php      2016-04-11 13:37:50 UTC (rev 2929)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-directory.php        2016-04-11 13:42:53 UTC (rev 2930)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -33,6 +33,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">                // Cannot be included on `admin_init` to allow access to menu hooks
</span><span class="cx" style="display: block; padding: 0 10px">                if ( defined( 'WP_ADMIN' ) && WP_ADMIN ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        Admin\Customizations::instance();
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+                       add_action( 'transition_post_status', array( 'Admin\Status_Transitions', 'instance' ) );
</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">                register_activation_hook( PLUGIN_FILE, array( $this, 'activate' ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -75,9 +77,10 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                'read_post'          => 'read',
</span><span class="cx" style="display: block; padding: 0 10px">                                'edit_posts'         => 'plugin_dashboard_access',
</span><span class="cx" style="display: block; padding: 0 10px">                                'edit_others_posts'  => 'plugin_edit_others',
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                'publish_posts'      => 'plugin_approve',
</ins><span class="cx" style="display: block; padding: 0 10px">                                 'read_private_posts' => 'do_not_allow',
</span><span class="cx" style="display: block; padding: 0 10px">                                'delete_posts'       => 'do_not_allow',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'create_posts'       => 'do_not_allow'
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         'create_posts'       => 'do_not_allow',
</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">@@ -124,7 +127,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                register_post_status( 'pending', array(
</span><span class="cx" style="display: block; padding: 0 10px">                        'label'                     => _x( 'Pending', 'plugin status', 'wporg-plugins' ),
</span><span class="cx" style="display: block; padding: 0 10px">                        'public'                    => false,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        'show_in_admin_status_list' => current_user_can( 'plugin_approve' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 'show_in_admin_status_list' => current_user_can( 'plugin_review' ),
</ins><span class="cx" style="display: block; padding: 0 10px">                         'label_count'               => _n_noop( 'Pending <span class="count">(%s)</span>', 'Pending <span class="count">(%s)</span>', 'wporg-plugins' ),
</span><span class="cx" style="display: block; padding: 0 10px">                ) );
</span><span class="cx" style="display: block; padding: 0 10px">                register_post_status( 'disabled', array(
</span></span></pre></div>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectorytoolsclasssvnphp"></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/tools/class-svn.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/tools/class-svn.php     2016-04-11 13:37:50 UTC (rev 2929)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/tools/class-svn.php       2016-04-11 13:42:53 UTC (rev 2930)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -8,6 +8,10 @@
</span><span class="cx" style="display: block; padding: 0 10px">  */
</span><span class="cx" style="display: block; padding: 0 10px"> class SVN {
</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 static function add( $dirs, $args = array() ) {
+               return true;
+       }
+
</ins><span class="cx" style="display: block; padding: 0 10px">         /**
</span><span class="cx" style="display: block; padding: 0 10px">         * Create an SVN Export of a URL to a local directory.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -81,6 +85,10 @@
</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="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        public static function mkdir( $dirs, $args = array() ) {
+               return true;
+       }
+
</ins><span class="cx" style="display: block; padding: 0 10px">         /**
</span><span class="cx" style="display: block; padding: 0 10px">         * Parse and escape the provided SVN arguements for usage on the CLI.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span></span></pre>
</div>
</div>

</body>
</html>