<!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" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { 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 #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#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>
<title>[BuddyPress] [3270] branches/1.2/bp-xprofile:
  Clean up HTML in xprofile admin area.</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd>3270</dd>
<dt>Author</dt> <dd>johnjamesjacoby</dd>
<dt>Date</dt> <dd>2010-09-17 18:07:07 +0000 (Fri, 17 Sep 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>Clean up HTML in xprofile admin area. Add maybe_unserialize to get_value_byid. Fixes #2637.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#branches12bpxprofilebpxprofileclassesphp">branches/1.2/bp-xprofile/bp-xprofile-classes.php</a></li>
<li><a href="#branches12bpxprofilebpxprofiletemplatetagsphp">branches/1.2/bp-xprofile/bp-xprofile-templatetags.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="branches12bpxprofilebpxprofileclassesphp"></a>
<div class="modfile"><h4>Modified: branches/1.2/bp-xprofile/bp-xprofile-classes.php (3269 => 3270)</h4>
<pre class="diff"><span>
<span class="info">--- branches/1.2/bp-xprofile/bp-xprofile-classes.php        2010-09-13 23:13:20 UTC (rev 3269)
+++ branches/1.2/bp-xprofile/bp-xprofile-classes.php        2010-09-17 18:07:07 UTC (rev 3270)
</span><span class="lines">@@ -482,15 +482,14 @@
</span><span class="cx">                 //This function populates the items for radio buttons checkboxes and drop down boxes
</span><span class="cx">                 $input_types = array( 'checkbox', 'selectbox', 'multiselectbox', 'radio' );
</span><span class="cx"> 
</span><del>-                foreach ($input_types as $type) {
</del><ins>+                foreach ( $input_types as $type ) {
</ins><span class="cx">                         $default_name = '';
</span><span class="cx"> 
</span><del>-                        if ( 'multiselectbox' == $type || 'checkbox' == $type ) {
</del><ins>+                        if ( 'multiselectbox' == $type || 'checkbox' == $type )
</ins><span class="cx">                                 $default_input = 'checkbox';
</span><del>-                        } else {
-                                $default_input = 'radio';
-                        }
-                ?&gt;
</del><ins>+                        else
+                                $default_input = 'radio'; ?&gt;
+
</ins><span class="cx">                         &lt;div id=&quot;&lt;?php echo $type ?&gt;&quot; class=&quot;options-box&quot; style=&quot;&lt;?php if ( $this-&gt;type != $type ) { ?&gt;display: none;&lt;?php } ?&gt; margin-left: 15px;&quot;&gt;
</span><span class="cx">                                 &lt;h4&gt;&lt;?php _e('Please enter options for this Field:', 'buddypress') ?&gt;&lt;/h4&gt;
</span><span class="cx">                                 &lt;p&gt;&lt;?php _e( 'Order By:', 'buddypress' ) ?&gt;
</span><span class="lines">@@ -519,33 +518,41 @@
</span><span class="cx">                                         }
</span><span class="cx">                                 }
</span><span class="cx"> 
</span><del>-                                if ( !empty($options) ) {
-                                        for ( $i = 0; $i &lt; count($options); $i++ ) {
</del><ins>+                                if ( !empty( $options ) ) {
+                                        for ( $i = 0; $i &lt; count( $options ); $i++ ) {
</ins><span class="cx">                                                 $j = $i + 1;
</span><span class="cx"> 
</span><span class="cx">                                                 if ( 'multiselectbox' == $type || 'checkbox' == $type )
</span><del>-                                                        $default_name = '[' . $j . ']';
-                                        ?&gt;
-                                                &lt;p&gt;&lt;?php _e('Option', 'buddypress') ?&gt; &lt;?php echo $j ?&gt;:
-                                                   &lt;input type=&quot;text&quot; name=&quot;&lt;?php echo $type ?&gt;_option[&lt;?php echo $j ?&gt;]&quot; id=&quot;&lt;?php echo $type ?&gt;_option&lt;?php echo $j ?&gt;&quot; value=&quot;&lt;?php echo esc_attr( $options[$i]-&gt;name ) ?&gt;&quot; /&gt;
-                                                   &lt;input type=&quot;&lt;?php echo $default_input ?&gt;&quot; name=&quot;isDefault_&lt;?php echo $type ?&gt;_option&lt;?php echo $default_name ?&gt;&quot; &lt;?php if ( (int) $options[$i]-&gt;is_default_option ) {?&gt; checked=&quot;checked&quot;&lt;?php } ?&gt; &quot; value=&quot;&lt;?php echo $j ?&gt;&quot; /&gt; &lt;?php _e( 'Default Value', 'buddypress' ) ?&gt;
-                                                        &lt;?php if ( $j != 1 &amp;&amp;
-                                                                $options[$i]-&gt;id != -1 ) : ?&gt;&lt;a href=&quot;admin.php?page=bp-profile-setup&amp;amp;mode=delete_option&amp;amp;option_id=&lt;?php echo $options[$i]-&gt;id ?&gt;&quot; class=&quot;ajax-option-delete&quot; id=&quot;delete-&lt;?php echo $options[$i]-&gt;id ?&gt;&quot;&gt;[x]&lt;/a&gt;&lt;?php endif ?&gt;&lt;/p&gt;
</del><ins>+                                                        $default_name = '[' . $j . ']'; ?&gt;
+
+                                                &lt;p&gt;
+                                                        &lt;?php _e('Option', 'buddypress') ?&gt; &lt;?php echo $j ?&gt;:
+                                                        &lt;input type=&quot;text&quot; name=&quot;&lt;?php echo $type ?&gt;_option[&lt;?php echo $j ?&gt;]&quot; id=&quot;&lt;?php echo $type ?&gt;_option&lt;?php echo $j ?&gt;&quot; value=&quot;&lt;?php echo esc_attr( $options[$i]-&gt;name ) ?&gt;&quot; /&gt;
+                                                        &lt;input type=&quot;&lt;?php echo $default_input ?&gt;&quot; name=&quot;isDefault_&lt;?php echo $type ?&gt;_option&lt;?php echo $default_name ?&gt;&quot; &lt;?php if ( (int) $options[$i]-&gt;is_default_option ) {?&gt; checked=&quot;checked&quot;&lt;?php } ?&gt; value=&quot;&lt;?php echo $j ?&gt;&quot; /&gt; &lt;?php _e( 'Default Value', 'buddypress' ) ?&gt;
+
+                                                        &lt;?php if ( $j != 1 &amp;&amp; $options[$i]-&gt;id != -1 ) : ?&gt;
+
+                                                                   &lt;a href=&quot;admin.php?page=bp-profile-setup&amp;amp;mode=delete_option&amp;amp;option_id=&lt;?php echo $options[$i]-&gt;id ?&gt;&quot; class=&quot;ajax-option-delete&quot; id=&quot;delete-&lt;?php echo $options[$i]-&gt;id ?&gt;&quot;&gt;[x]&lt;/a&gt;
+
+                                                        &lt;?php endif ?&gt;
+
</ins><span class="cx">                                                 &lt;/p&gt;
</span><ins>+
</ins><span class="cx">                                         &lt;?php } // end for ?&gt;
</span><ins>+
</ins><span class="cx">                                         &lt;input type=&quot;hidden&quot; name=&quot;&lt;?php echo $type ?&gt;_option_number&quot; id=&quot;&lt;?php echo $type ?&gt;_option_number&quot; value=&quot;&lt;?php echo $j + 1 ?&gt;&quot; /&gt;
</span><span class="cx"> 
</span><span class="cx">                                 &lt;?php
</span><span class="cx">                                 } else {
</span><span class="cx">                                         if ( 'multiselectbox' == $type || 'checkbox' == $type )
</span><del>-                                                $default_name = '[1]';
-                                ?&gt;
</del><ins>+                                                $default_name = '[1]'; ?&gt;
</ins><span class="cx"> 
</span><span class="cx">                                         &lt;p&gt;&lt;?php _e('Option', 'buddypress') ?&gt; 1: &lt;input type=&quot;text&quot; name=&quot;&lt;?php echo $type ?&gt;_option[1]&quot; id=&quot;&lt;?php echo $type ?&gt;_option1&quot; /&gt;
</span><span class="cx">                                         &lt;input type=&quot;&lt;?php echo $default_input ?&gt;&quot; name=&quot;isDefault_&lt;?php echo $type ?&gt;_option&lt;?php echo $default_name; ?&gt;&quot; id=&quot;isDefault_&lt;?php echo $type ?&gt;_option&quot; value=&quot;1&quot; /&gt; &lt;?php _e( 'Default Value', 'buddypress' ) ?&gt;
</span><span class="cx">                                         &lt;input type=&quot;hidden&quot; name=&quot;&lt;?php echo $type ?&gt;_option_number&quot; id=&quot;&lt;?php echo $type ?&gt;_option_number&quot; value=&quot;2&quot; /&gt;
</span><span class="cx"> 
</span><span class="cx">                                 &lt;?php } // end if ?&gt;
</span><ins>+
</ins><span class="cx">                                 &lt;div id=&quot;&lt;?php echo $type ?&gt;_more&quot;&gt;&lt;/div&gt;
</span><span class="cx">                                 &lt;p&gt;&lt;a href=&quot;javascript:add_option('&lt;?php echo $type ?&gt;')&quot;&gt;&lt;?php _e('Add Another Option', 'buddypress') ?&gt;&lt;/a&gt;&lt;/p&gt;
</span><span class="cx">                         &lt;/div&gt;
</span><span class="lines">@@ -626,6 +633,8 @@
</span><span class="cx">                                                  &lt;?php _e('or', 'buddypress') ?&gt; &lt;a href=&quot;admin.php?page=bp-profile-setup&quot; style=&quot;color: red&quot;&gt;&lt;?php _e( 'Cancel', 'buddypress' ) ?&gt;&lt;/a&gt;
</span><span class="cx">                                 &lt;/p&gt;
</span><span class="cx"> 
</span><ins>+                        &lt;/div&gt;
+
</ins><span class="cx">                         &lt;div class=&quot;clear&quot;&gt;&lt;/div&gt;
</span><span class="cx"> 
</span><span class="cx">                         &lt;?php if ( function_exists('wp_nonce_field') )
</span><span class="lines">@@ -799,10 +808,11 @@
</span><span class="cx">                 if ( is_array( $user_ids ) ) {
</span><span class="cx">                         $user_ids = implode( ',', (array)$user_ids );
</span><span class="cx">                         $data = $wpdb-&gt;get_results( $wpdb-&gt;prepare( &quot;SELECT user_id, value FROM {$bp-&gt;profile-&gt;table_name_data} WHERE field_id = %d AND user_id IN ({$user_ids})&quot;, $field_id ) );
</span><del>-                } else
</del><ins>+                } else {
</ins><span class="cx">                         $data = $wpdb-&gt;get_var( $wpdb-&gt;prepare( &quot;SELECT value FROM {$bp-&gt;profile-&gt;table_name_data} WHERE field_id = %d AND user_id = %d&quot;, $field_id, $user_ids ) );
</span><ins>+                }
</ins><span class="cx"> 
</span><del>-                return $data;
</del><ins>+                return maybe_unserialize( $data );
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         function get_value_byfieldname( $fields, $user_id = null ) {
</span></span></pre></div>
<a id="branches12bpxprofilebpxprofiletemplatetagsphp"></a>
<div class="modfile"><h4>Modified: branches/1.2/bp-xprofile/bp-xprofile-templatetags.php (3269 => 3270)</h4>
<pre class="diff"><span>
<span class="info">--- branches/1.2/bp-xprofile/bp-xprofile-templatetags.php        2010-09-13 23:13:20 UTC (rev 3269)
+++ branches/1.2/bp-xprofile/bp-xprofile-templatetags.php        2010-09-17 18:07:07 UTC (rev 3270)
</span><span class="lines">@@ -376,7 +376,7 @@
</span><span class="cx">                                         $html .= '&lt;option value=&quot;&quot;&gt;--------&lt;/option&gt;';
</span><span class="cx"> 
</span><span class="cx">                                 for ( $k = 0; $k &lt; count($options); $k++ ) {
</span><del>-                                        $option_values = maybe_unserialize( BP_XProfile_ProfileData::get_value_byid( $options[$k]-&gt;parent_id ) );
</del><ins>+                                        $option_values = BP_XProfile_ProfileData::get_value_byid( $options[$k]-&gt;parent_id );
</ins><span class="cx">                                         $option_values = (array)$option_values;
</span><span class="cx"> 
</span><span class="cx">                                         /* Check for updated posted values, but errors preventing them from being saved first time */
</span></span></pre>
</div>
</div>

</body>
</html>