<!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>[373] sites/trunk/wordpress.org/public_html/wp-content/plugins/trac-notifications/trac-notifications.php: Trac Notifications: Updates to the preferences form for focuses, new tickets, and subcomponents.</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">
<dt>Revision</dt> <dd><a href="http://meta.trac.wordpress.org/changeset/373">373</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2014-02-05 08:52:43 +0000 (Wed, 05 Feb 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>Trac Notifications: Updates to the preferences form for focuses, new tickets, and subcomponents. see <a href="http://meta.trac.wordpress.org/ticket/127">#127</a>, <a href="http://meta.trac.wordpress.org/ticket/287">#287</a>, <a href="http://meta.trac.wordpress.org/ticket/300">#300</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentpluginstracnotificationstracnotificationsphp">sites/trunk/wordpress.org/public_html/wp-content/plugins/trac-notifications/trac-notifications.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentpluginstracnotificationstracnotificationsphp"></a>
<div class="modfile"><h4>Modified: sites/trunk/wordpress.org/public_html/wp-content/plugins/trac-notifications/trac-notifications.php (372 => 373)</h4>
<pre class="diff"><span>
<span class="info">--- sites/trunk/wordpress.org/public_html/wp-content/plugins/trac-notifications/trac-notifications.php 2014-02-04 22:08:20 UTC (rev 372)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/trac-notifications/trac-notifications.php 2014-02-05 08:52:43 UTC (rev 373)
</span><span class="lines">@@ -33,7 +33,7 @@
</span><span class="cx"> function set_trac( $trac ) {
</span><span class="cx"> $this->trac_subdomain = $trac;
</span><span class="cx"> if ( function_exists( 'add_db_table' ) ) {
</span><del>- $tables = array( 'ticket', '_ticket_subs', '_notifications', 'ticket_change', 'component', 'milestone' );
</del><ins>+ $tables = array( 'ticket', '_ticket_subs', '_notifications', 'ticket_change', 'component', 'milestone', 'ticket_custom' );
</ins><span class="cx"> foreach ( $tables as $table ) {
</span><span class="cx"> add_db_table( 'trac_' . $trac, $table );
</span><span class="cx"> }
</span><span class="lines">@@ -79,6 +79,10 @@
</span><span class="cx"> return $this->trac->get_row( $this->trac->prepare( "SELECT * FROM ticket WHERE id = %d", $ticket_id ) );
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ function get_trac_ticket_focuses( $ticket_id ) {
+ return $this->trac->get_var( $this->trac->prepare( "SELECT value FROM ticket_custom WHERE ticket = %d AND name = 'focuses'", $ticket_id ) );
+ }
+
</ins><span class="cx"> function get_trac_ticket_participants( $ticket_id ) {
</span><span class="cx"> return $this->trac->get_col( $this->trac->prepare( "SELECT DISTINCT author FROM ticket_change WHERE ticket = %d", $ticket_id ) );
</span><span class="cx"> }
</span><span class="lines">@@ -87,8 +91,40 @@
</span><span class="cx"> return $this->trac->get_col( $this->trac->prepare( "SELECT username FROM _ticket_subs WHERE ticket = %s AND status = 1", $ticket_id ) );
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ function get_trac_focuses() {
+ return array( 'accessibility', 'administration', 'docs', 'javascript', 'multisite', 'performance', 'rtl', 'template', 'ui' );
+ }
+
+ function make_components_tree( $components ) {
+ $tree = array();
+ $subcomponents = array(
+ 'Comments' => array( 'Pings/Trackbacks' ),
+ 'Editor' => array( 'Autosave', 'Press This', 'Quick/Bulk Edit', 'TinyMCE' ),
+ 'Formatting' => array( 'Charset', 'Shortcodes' ),
+ 'Media' => array( 'Embeds', 'Gallery', 'Upload' ),
+ 'Permalinks' => array( 'Canonical', 'Rewrite Rules' ),
+ 'Posts, Post Types' => array( 'Post Formats', 'Post Thumbnails', 'Revisions' ),
+ 'Themes' => array( 'Appearance', 'Widgets', 'Menus' ),
+ 'Users' => array( 'Role/Capability', 'Login and Registration' )
+ );
+ foreach ( $components as $component ) {
+ if ( false === $tree[ $component ] ) {
+ continue;
+ } elseif ( isset( $subcomponents[ $component ] ) ) {
+ $tree[ $component ] = $subcomponents[ $component ];
+ foreach ( $subcomponents[ $component ] as $subcomponent ) {
+ $tree[ $subcomponent ] = false;
+ }
+ } else {
+ $tree[ $component ] = true;
+ }
+ }
+ $tree = array_filter( $tree );
+ return $tree;
+ }
+
</ins><span class="cx"> function get_trac_components() {
</span><del>- return $this->trac->get_col( "SELECT name FROM component ORDER BY name ASC" );
</del><ins>+ return $this->trac->get_col( "SELECT name FROM component WHERE name <> 'WordPress.org site' ORDER BY name ASC" );
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> function get_trac_milestones() {
</span><span class="lines">@@ -100,11 +136,13 @@
</span><span class="cx">
</span><span class="cx"> function get_trac_notifications_for_user( $username ) {
</span><span class="cx"> $rows = $this->trac->get_results( $this->trac->prepare( "SELECT type, value FROM _notifications WHERE username = %s ORDER BY type ASC, value ASC", $username ) );
</span><del>- $notifications = array( 'component' => array(), 'milestone' => array() );
</del><ins>+ $notifications = array( 'component' => array(), 'milestone' => array(), 'focus' => array(), 'newticket' => array() );
</ins><span class="cx">
</span><span class="cx"> foreach ( $rows as $row ) {
</span><span class="cx"> $notifications[ $row->type ][ $row->value ] = true;
</span><span class="cx"> }
</span><ins>+ $notifications['newticket'] = ! empty( $notifications['newticket']['1'] );
+
</ins><span class="cx"> return $notifications;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -205,6 +243,8 @@
</span><span class="cx"> exit;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ $focuses = explode( ', ', $this->get_trac_ticket_focuses( $ticket_id ) );
+
</ins><span class="cx"> $notifications = $this->get_trac_notifications_for_user( $username );
</span><span class="cx">
</span><span class="cx"> $ticket_sub = $this->get_trac_ticket_subscription_status_for_user( $ticket_id, $username );
</span><span class="lines">@@ -225,6 +265,21 @@
</span><span class="cx"> if ( in_array( $username, $participants ) ) {
</span><span class="cx"> $reasons['participant'] = 'you have commented';
</span><span class="cx"> }
</span><ins>+
+ $intersected_focuses = array();
+ foreach ( $focuses as $focus ) {
+ if ( ! empty( $notifications['focus'][ $focus ] ) ) {
+ $intersected_focuses[] = $focus;
+ }
+ }
+ if ( $intersected_focuses ) {
+ if ( count( $intersected_focuses ) === 1 ) {
+ $reasons['focus'] = sprintf( 'you subscribe to the %s focus', $intersected_focuses[0] );
+ } else {
+ $reasons['focus'] = 'you subscribe to the ' . wp_sprintf( '%l focuses', $intersected_focuses );
+ }
+ }
+
</ins><span class="cx"> if ( ! empty( $notifications['component'][ $ticket->component ] ) ) {
</span><span class="cx"> $reasons['component'] = sprintf( 'you subscribe to the %s component', $ticket->component );
</span><span class="cx"> }
</span><span class="lines">@@ -333,12 +388,13 @@
</span><span class="cx">
</span><span class="cx"> function notification_settings_page() {
</span><span class="cx"> if ( ! is_user_logged_in() ) {
</span><del>- return 'Please log in to save your notification preferences.';
</del><ins>+ return 'Please <a href="//wordpress.org/support/bb-login.php">log in</a> to save your notification preferences.';
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> ob_start();
</span><span class="cx"> $components = $this->get_trac_components();
</span><span class="cx"> $milestones = $this->get_trac_milestones();
</span><ins>+ $focuses = $this->get_trac_focuses();
</ins><span class="cx">
</span><span class="cx"> $username = wp_get_current_user()->user_login;
</span><span class="cx"> $notifications = $this->get_trac_notifications_for_user( $username );
</span><span class="lines">@@ -346,8 +402,8 @@
</span><span class="cx"> if ( $_POST && isset( $_POST['trac-nonce'] ) ) {
</span><span class="cx"> check_admin_referer( 'save-trac-notifications', 'trac-nonce' );
</span><span class="cx">
</span><del>- foreach ( array( 'milestone', 'component' ) as $type ) {
- foreach ( $_POST[ $type ] as $value => $on ) {
</del><ins>+ foreach ( array( 'milestone', 'component', 'focus' ) as $type ) {
+ foreach ( $_POST['notifications'][ $type ] as $value => $on ) {
</ins><span class="cx"> if ( empty( $notifications[ $type ][ $value ] ) ) {
</span><span class="cx"> $this->trac->insert( '_notifications', compact( 'username', 'type', 'value' ) );
</span><span class="cx"> $notifications[ $type ][ $value ] = true;
</span><span class="lines">@@ -355,25 +411,45 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> foreach ( $notifications[ $type ] as $value => $on ) {
</span><del>- if ( empty( $_POST[ $type ][ $value ] ) ) {
</del><ins>+ if ( empty( $_POST['notifications'][ $type ][ $value ] ) ) {
</ins><span class="cx"> $this->trac->delete( '_notifications', compact( 'username', 'type', 'value' ) );
</span><span class="cx"> unset( $notifications[ $type ][ $value ] );
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx"> }
</span><ins>+ if ( empty( $_POST['notifications']['newticket'] ) && ! empty( $notifications['newticket'] ) ) {
+ $this->trac->delete( '_notifications', array( 'username' => $username, 'type' => 'newticket' ) );
+ } elseif ( ! empty( $_POST['notifications']['newticket'] ) && empty( $notifications['newticket'] ) ) {
+ $this->trac->insert( '_notifications', array( 'username' => $username, 'type' => 'newticket', 'value' => '1' ) );
+ }
</ins><span class="cx"> }
</span><span class="cx"> ?>
</span><span class="cx">
</span><span class="cx"> <style>
</span><del>- #components, #milestones, p.save-changes {
</del><ins>+ #focuses, #components, #milestones, p.save-changes {
</ins><span class="cx"> clear: both;
</span><span class="cx"> }
</span><span class="cx"> #milestones, p.save-changes {
</span><span class="cx"> padding-top: 1em;
</span><span class="cx"> }
</span><del>- #components li,
- #milestones li {
</del><ins>+ #focuses li {
+ display: inline-block !important;
+ list-style: none;
+ min-width: 15%;
+ margin-right: 30px;
+ }
+ #components > ul {
</ins><span class="cx"> float: left;
</span><ins>+ width: 24%;
+ margin: 0 0 0 1% !important;
+ margin: 0;
+ padding: 0;
+ }
+ #components > ul > li {
+ list-style: none;
+ }
+ #milestones > ul > li {
+ float: left;
</ins><span class="cx"> width: 25%;
</span><span class="cx"> list-style: none;
</span><span class="cx"> }
</span><span class="lines">@@ -401,13 +477,40 @@
</span><span class="cx"> <?php
</span><span class="cx"> echo '<form method="post" action="">';
</span><span class="cx"> wp_nonce_field( 'save-trac-notifications', 'trac-nonce', false );
</span><ins>+ echo '<h3>New Tickets</h3>';
+ $checked = checked( $notifications['newticket'], true, false );
+ echo '<ul><li style="list-style:none"><label><input type="checkbox" ' . $checked . 'name="notifications[newticket]" /> Receive all new ticket notifications.</label><br /><em>To receive comments to a ticket, you will need to star it, unless it matches one of your other preferences below.</em></li></ul>';
+ echo '<div id="focuses">';
+ echo '<h3>Focuses</h3>';
+ echo '<ul>';
+ foreach ( $focuses as $focus ) {
+ $checked = checked( ! empty( $notifications['focus'][ $focus ] ), true, false );
+ echo '<li><label><input type="checkbox" ' . $checked . 'name="notifications[focus][' . esc_attr( $focus ) . ']" /> ' . $focus . '</label></li>';
+ }
+ echo '</ul>';
+ echo '</div>';
</ins><span class="cx"> echo '<div id="components">';
</span><span class="cx"> echo '<h3>Components</h3>';
</span><span class="cx"> echo '<p class="select-all"><a href="#" data-action="select-all">select all</a> • <a href="#" data-action="clear-all">clear all</a></p>';
</span><del>- echo '<ul>';
- foreach ( $components as $component ) {
</del><ins>+ echo "<ul>\n";
+ $components_tree = $this->make_components_tree( $components );
+ $breakpoints = array( 'Export', 'Media', 'Script Loader' );
+ foreach ( $components_tree as $component => $subcomponents ) {
+ if ( in_array( $component, $breakpoints ) ) {
+ echo '</ul><ul>';
+ }
</ins><span class="cx"> $checked = checked( ! empty( $notifications['component'][ $component ] ), true, false );
</span><del>- echo '<li><label><input type="checkbox" ' . $checked . 'name="component[' . esc_attr( $component ) . ']" /> ' . $component . '</label></li>';
</del><ins>+ echo '<li><label><input type="checkbox" ' . $checked . 'name="notifications[component][' . esc_attr( $component ) . ']" /> ' . $component . "</label>\n";
+ if ( is_array( $subcomponents ) ) {
+ echo "<ul>\n";
+ foreach ( $subcomponents as $subcomponent ) {
+ $i++;
+ $checked = checked( ! empty( $notifications['component'][ $subcomponent ] ), true, false );
+ echo '<li><label><input type="checkbox" ' . $checked . 'name="notifications[component][' . esc_attr( $subcomponent ) . ']" /> ' . $subcomponent . "</label></li>\n";
+ }
+ echo "</ul>\n";
+ }
+ echo "</li>\n";
</ins><span class="cx"> }
</span><span class="cx"> echo '</ul>';
</span><span class="cx"> echo '</div>';
</span><span class="lines">@@ -424,7 +527,7 @@
</span><span class="cx"> }
</span><span class="cx"> $class = ' class="' . $class . '"';
</span><span class="cx"> }
</span><del>- echo '<li' . $class . '><label><input type="checkbox" ' . $checked . 'name="milestone[' . esc_attr( $milestone->name ) . ']" /> ' . $milestone->name . '</label></li>';
</del><ins>+ echo '<li' . $class . '><label><input type="checkbox" ' . $checked . 'name="notifications[milestone][' . esc_attr( $milestone->name ) . ']" /> ' . $milestone->name . '</label></li>';
</ins><span class="cx"> }
</span><span class="cx"> echo '<li id="show-completed"><a href="#">Show recently completed…</a></li>';
</span><span class="cx"> echo '</ul>';
</span></span></pre>
</div>
</div>
</body>
</html>