<!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>[7221] sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt: WordCamp: Add personal data exporters for the WordCamp post type</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/7221">7221</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/7221","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>coreymckrill</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2018-05-23 23:56:12 +0000 (Wed, 23 May 2018)</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'>WordCamp: Add personal data exporters for the WordCamp post type</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentpluginswcptwcptloaderphp">sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-loader.php</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentpluginswcptwcptwordcampprivacyphp">sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-wordcamp/privacy.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="sitestrunkwordcamporgpublic_htmlwpcontentpluginswcptwcptloaderphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-loader.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-loader.php 2018-05-23 23:47:23 UTC (rev 7220)
+++ sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-loader.php 2018-05-23 23:56:12 UTC (rev 7221)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -53,6 +53,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( is_admin() || ( defined( 'DOING_CRON' ) && DOING_CRON ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> require_once ( WCPT_DIR . 'wcpt-admin.php' );
</span><span class="cx" style="display: block; padding: 0 10px"> require_once ( WCPT_DIR . 'wcpt-wordcamp/wordcamp-admin.php' );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ require_once ( WCPT_DIR . 'wcpt-wordcamp/privacy.php' );
</ins><span class="cx" style="display: block; padding: 0 10px"> require_once ( WCPT_DIR . 'mentors/dashboard.php' );
</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="sitestrunkwordcamporgpublic_htmlwpcontentpluginswcptwcptwordcampprivacyphp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-wordcamp/privacy.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-wordcamp/privacy.php (rev 0)
+++ sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-wordcamp/privacy.php 2018-05-23 23:56:12 UTC (rev 7221)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,423 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+
+namespace WordCamp\WCPT\Privacy;
+defined( 'WPINC' ) || die();
+
+use WP_Query;
+
+add_filter( 'wp_privacy_personal_data_exporters', __NAMESPACE__ . '\register_personal_data_exporters' );
+//add_filter( 'wp_privacy_personal_data_erasers', __NAMESPACE__ . '\register_personal_data_erasers' );
+
+/**
+ * Registers the personal data exporter for each WordCamp post type.
+ *
+ * @param array $exporters
+ *
+ * @return array
+ */
+function register_personal_data_exporters( $exporters ) {
+ $exporters['wcpt-details'] = array(
+ 'exporter_friendly_name' => __( 'WordCamp Details', 'wordcamporg' ),
+ 'callback' => __NAMESPACE__ . '\details_personal_data_exporter',
+ );
+
+ $exporters['wcpt-application'] = array(
+ 'exporter_friendly_name' => __( 'WordCamp Application Data', 'wordcamporg' ),
+ 'callback' => __NAMESPACE__ . '\application_personal_data_exporter',
+ );
+
+ return $exporters;
+}
+
+/**
+ * Finds and exports personal data associated with an email address in WCPT postmeta.
+ *
+ * @param string $email_address
+ * @param int $page
+ *
+ * @return array
+ */
+function details_personal_data_exporter( $email_address, $page ) {
+ $post_query = _get_wordcamp_posts( 'details', $email_address, $page );
+ $email_keys = _get_email_postmeta_keys();
+ $data_to_export = [];
+
+ foreach ( (array) $post_query->posts as $post ) {
+ $wcpt_data_to_export = [];
+
+ foreach ( $email_keys as $email_key => $props ) {
+ $email_value = get_post_meta( $post->ID, $email_key, true );
+
+ if ( $email_value === $email_address ) {
+ $wcpt_data_to_export[] = [
+ 'name' => $email_key,
+ 'value' => $email_value,
+ ];
+
+ foreach ( $props['assoc_fields'] as $assoc_key ) {
+ $assoc_value = get_post_meta( $post->ID, $assoc_key, true );
+
+ if ( ! empty( $assoc_value ) ) {
+ $wcpt_data_to_export[] = [
+ 'name' => $assoc_key,
+ 'value' => $assoc_value,
+ ];
+ }
+ }
+ }
+ }
+
+ if ( ! empty( $wcpt_data_to_export ) ) {
+ $data_to_export[] = array(
+ 'group_id' => 'wcpt-details',
+ 'group_label' => 'WordCamp Details',
+ 'item_id' => "wcpt-{$post->ID}",
+ 'data' => $wcpt_data_to_export,
+ );
+ }
+ }
+
+ $done = $post_query->max_num_pages <= $page;
+
+ return [
+ 'data' => $data_to_export,
+ 'done' => $done,
+ ];
+}
+
+/**
+ * Finds and exports personal data associated with an email address in a WCPT's original application data.
+ *
+ * @param string $email_address
+ * @param int $page
+ *
+ * @return array
+ */
+function application_personal_data_exporter( $email_address, $page ) {
+ $post_query = _get_wordcamp_posts( 'application', $email_address, $page );
+ $data_to_export = [];
+
+ foreach ( (array) $post_query->posts as $post ) {
+ $application_data = get_post_meta( $post->ID, '_application_data', true );
+ $wcpt_data_to_export = [];
+
+ $lead_organizer_keys = [
+ 'q_1079074_first_name' => 'First Name',
+ 'q_1079074_last_name' => 'Last Name',
+ 'q_1079059_email' => 'Email',
+ 'q_4236565_wporg_username' => 'WordPress.org Username',
+ 'q_4236565_slack_username' => 'WordPress Slack Username',
+ 'where_find_online' => 'Where can we find you online?',
+ 'q_1079060_add1' => 'Address Line 1',
+ 'q_1079060_add2' => 'Address Line 2',
+ 'q_1079060_city' => 'City',
+ 'q_1079060_state' => 'State',
+ 'q_1079060_zip' => 'Zip Code',
+ 'q_1079060_country' => 'Country',
+ 'q_1045947_years_using_wp' => 'How long have you been using WordPress?',
+ 'q_1068246_ways_involved' => 'How have you been involved in the WordPress community so far?',
+ 'q_1068246_ways_involved_other' => 'How have you been involved in the WordPress community so far? (Other)',
+ 'q_1046032_attended_camp_before' => 'Have you ever attended a WordCamp before?',
+ 'q_1046033_camps_been_to' => 'What WordCamps have you been to?',
+ 'q_1068223_hope_to_accomplish' => 'What do you hope to accomplish by organizing a WordCamp?',
+ 'q_1068223_hope_to_accomplish_other' => 'What do you hope to accomplish by organizing a WordCamp? (Other)',
+ 'q_1045953_role_in_meetup' => 'What is your role in the meetup group?',
+ 'q_1046038_organized_event_before' => 'Have you ever organized an event like this before?',
+ 'q_1046099_describe_events' => 'Please give a brief description of the events you've been involved in organizing and what your role was.',
+ 'q_1068188_relationship_co_organizers' => 'What's your relationship to your co-organizers?',
+ 'q_1068188_relationship_co_organizers_other' => 'What's your relationship to your co-organizers? (Other)',
+ 'q_1068214_raise_money' => 'Are you confident you can raise money from local sponsors to cover the event costs?',
+ 'q_1079098_anything_else' => 'Anything else you want us to know while we're looking over your application?',
+ 'q_1079112_best_describes_you' => 'Which of these best describes you?',
+ 'q_1079112_best_describes_you_other' => 'Which of these best describes you? (Other)',
+ ];
+
+ $co_organizer_keys = [
+ 'q_1068188_relationship_co_organizers' => 'What's your relationship to your co-organizers?',
+ 'q_1068188_relationship_co_organizers_other' => 'What's your relationship to your co-organizers? (Other)',
+ 'q_1068187_co_organizer_contact_info' => 'Please enter the names and email addresses of your co-organizers',
+ ];
+
+ if ( $application_data['q_1079059_email'] === $email_address ) {
+ foreach ( $lead_organizer_keys as $lkey => $llabel ) {
+ if ( isset( $application_data[ $lkey ] ) && ! empty( $application_data[ $lkey ] ) ) {
+ $lvalue = $application_data[ $lkey ];
+
+ if ( is_array( $lvalue ) ) {
+ $lvalue = implode( ', ', $lvalue );
+ }
+
+ $wcpt_data_to_export[] = [
+ 'name' => $llabel,
+ 'value' => $lvalue,
+ ];
+ }
+ }
+ }
+
+ if ( preg_match( "/.*\b$email_address\b.*/", $application_data['q_1068187_co_organizer_contact_info'] ) ) {
+ foreach ( $co_organizer_keys as $ckey => $clabel ) {
+ if ( isset( $application_data[ $ckey ] ) && ! empty( $application_data[ $ckey ] ) ) {
+ $cvalue = $application_data[ $ckey ];
+
+ if ( is_array( $cvalue ) ) {
+ $cvalue = implode( ', ', $cvalue );
+ }
+
+ $wcpt_data_to_export[] = [
+ 'name' => $clabel,
+ 'value' => $cvalue,
+ ];
+ }
+ }
+ }
+
+ if ( ! empty( $wcpt_data_to_export ) ) {
+ $data_to_export[] = array(
+ 'group_id' => 'wcpt-application',
+ 'group_label' => 'WordCamp Application Data',
+ 'item_id' => "wcpt-{$post->ID}",
+ 'data' => $wcpt_data_to_export,
+ );
+ }
+ }
+
+ $done = $post_query->max_num_pages <= $page;
+
+ return [
+ 'data' => $data_to_export,
+ 'done' => $done,
+ ];
+}
+
+/**
+ * Registers the personal data eraser for each WordCamp post type.
+ *
+ * @param array $erasers
+ *
+ * @return array
+ */
+function register_personal_data_erasers( $erasers ) {
+ $erasers['wcpt-details'] = array(
+ 'exporter_friendly_name' => __( 'WordCamp Details', 'wordcamporg' ),
+ 'callback' => __NAMESPACE__ . '\details_personal_data_eraser',
+ );
+
+ $erasers['wcpt-application'] = array(
+ 'exporter_friendly_name' => __( 'WordCamp Application Data', 'wordcamporg' ),
+ 'callback' => __NAMESPACE__ . '\application_personal_data_eraser',
+ );
+
+ return $erasers;
+}
+
+/**
+ * Finds and erases personal data associated with an email address in WCPT postmeta.
+ *
+ * @param string $email_address
+ * @param int $page
+ *
+ * @return array
+ */
+function details_personal_data_eraser( $email_address, $page ) {
+ $post_query = _get_wordcamp_posts( 'details', $email_address, $page );
+ $items_removed = false;
+ $items_retained = false;
+ $messages = [];
+
+ foreach ( (array) $post_query->posts as $post ) {
+ // @todo
+ }
+
+ $done = $post_query->max_num_pages <= $page;
+
+ return array(
+ 'items_removed' => $items_removed,
+ 'items_retained' => $items_retained,
+ 'messages' => $messages,
+ 'done' => $done,
+ );
+}
+
+/**
+ * Finds and erases personal data associated with an email address in a WCPT's original application data.
+ *
+ * @param string $email_address
+ * @param int $page
+ *
+ * @return array
+ */
+function application_personal_data_eraser( $email_address, $page ) {
+ $post_query = _get_wordcamp_posts( 'application', $email_address, $page );
+ $items_removed = false;
+ $items_retained = false;
+ $messages = [];
+
+ foreach ( (array) $post_query->posts as $post ) {
+ // @todo
+ }
+
+ $done = $post_query->max_num_pages <= $page;
+
+ return array(
+ 'items_removed' => $items_removed,
+ 'items_retained' => $items_retained,
+ 'messages' => $messages,
+ 'done' => $done,
+ );
+}
+
+/**
+ * Get the list of WCPT posts associated with a particular email address.
+ *
+ * @param string $query_type `details` or `application`.
+ * @param string $email_address
+ * @param int $page
+ *
+ * @return WP_Query
+ */
+function _get_wordcamp_posts( $query_type, $email_address, $page ) {
+ $page = (int) $page;
+ $number = 20;
+
+ $args = [
+ 'post_type' => WCPT_POST_TYPE_ID,
+ 'post_status' => 'any',
+ 'orderby' => 'ID',
+ 'numberposts' => - 1,
+ 'perm' => 'readable',
+ 'posts_per_page' => $number,
+ 'paged' => $page,
+ ];
+
+ switch ( $query_type ) {
+ case 'details' :
+ $email_keys = _get_email_postmeta_keys();
+
+ $args['meta_query'] = [
+ 'relation' => 'OR',
+ ];
+
+ foreach ( $email_keys as $key => $props ) {
+ $args['meta_query'][] = [
+ 'key' => $key,
+ 'value' => $email_address,
+ ];
+ }
+ break;
+ case 'application' :
+ $args['meta_query'] = [
+ 'relation' => 'OR',
+ [
+ 'key' => '_application_data',
+ 'value' => $email_address,
+ 'compare' => 'LIKE', // There are multiple places in the serialized array where an email address could be.
+ ],
+ ];
+ break;
+ }
+
+ return new WP_Query( $args );
+}
+
+/**
+ * Define the list of postmeta fields that may contain an email address, and other fields associated with each of them.
+ *
+ * @return array
+ */
+function _get_email_postmeta_keys() {
+ // @todo Since the postmeta keys are also the field labels, we might need to expand this array to include translatable
+ // strings for the labels.
+
+ return [
+ 'Email Address' => [
+ 'assoc_fields' => [
+ 'Organizer Name',
+ 'WordPress.org Username',
+ 'Telephone',
+ 'Mailing Address',
+ ],
+ ],
+ 'Sponsor Wrangler E-mail Address' => [
+ 'assoc_fields' => [
+ 'Sponsor Wrangler Name',
+ ],
+ ],
+ 'Budget Wrangler E-mail Address' => [
+ 'assoc_fields' => [
+ 'Budget Wrangler Name',
+ ],
+ ],
+ 'Venue Wrangler E-mail Address' => [
+ 'assoc_fields' => [
+ 'Venue Wrangler Name',
+ ],
+ ],
+ 'Speaker Wrangler E-mail Address' => [
+ 'assoc_fields' => [
+ 'Speaker Wrangler Name',
+ ],
+ ],
+ 'Food/Beverage Wrangler E-mail Address' => [
+ 'assoc_fields' => [
+ 'Food/Beverage Wrangler Name',
+ ],
+ ],
+ 'Swag Wrangler E-mail Address' => [
+ 'assoc_fields' => [
+ 'Swag Wrangler Name',
+ ],
+ ],
+ 'Volunteer Wrangler E-mail Address' => [
+ 'assoc_fields' => [
+ 'Volunteer Wrangler Name',
+ ],
+ ],
+ 'Printing Wrangler E-mail Address' => [
+ 'assoc_fields' => [
+ 'Printing Wrangler Name',
+ ],
+ ],
+ 'Design Wrangler E-mail Address' => [
+ 'assoc_fields' => [
+ 'Design Wrangler Name',
+ ],
+ ],
+ 'Website Wrangler E-mail Address' => [
+ 'assoc_fields' => [
+ 'Website Wrangler Name',
+ ],
+ ],
+ 'Social Media/Publicity Wrangler E-mail Address' => [
+ 'assoc_fields' => [
+ 'Social Media/Publicity Wrangler Name',
+ ],
+ ],
+ 'A/V Wrangler E-mail Address' => [
+ 'assoc_fields' => [
+ 'A/V Wrangler Name',
+ ],
+ ],
+ 'Party Wrangler E-mail Address' => [
+ 'assoc_fields' => [
+ 'Party Wrangler Name',
+ ],
+ ],
+ 'Travel Wrangler E-mail Address' => [
+ 'assoc_fields' => [
+ 'Travel Wrangler Name',
+ ],
+ ],
+ 'Safety Wrangler E-mail Address' => [
+ 'assoc_fields' => [
+ 'Safety Wrangler Name',
+ ],
+ ],
+ 'Mentor E-mail Address' => [
+ 'assoc_fields' => [
+ 'Mentor WordPress.org User Name',
+ 'Mentor Name',
+ ],
+ ],
+ ];
+}
</ins></span></pre>
</div>
</div>
</body>
</html>