<!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] [1868] trunk/bp-xprofile:
  Added field_order support for new profile fields created.</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd>1868</dd>
<dt>Author</dt> <dd>apeatling</dd>
<dt>Date</dt> <dd>2009-09-14 18:27:34 +0000 (Mon, 14 Sep 2009)</dd>
</dl>

<h3>Log Message</h3>
<pre>Added field_order support for new profile fields created.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkbpxprofilebpxprofileadminphp">trunk/bp-xprofile/bp-xprofile-admin.php</a></li>
<li><a href="#trunkbpxprofilebpxprofileclassesphp">trunk/bp-xprofile/bp-xprofile-classes.php</a></li>
<li><a href="#trunkbpxprofilebpxprofiletemplatetagsphp">trunk/bp-xprofile/bp-xprofile-templatetags.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkbpxprofilebpxprofileadminphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-xprofile/bp-xprofile-admin.php (1867 => 1868)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-xprofile/bp-xprofile-admin.php        2009-09-14 18:00:55 UTC (rev 1867)
+++ trunk/bp-xprofile/bp-xprofile-admin.php        2009-09-14 18:27:34 UTC (rev 1868)
</span><span class="lines">@@ -208,18 +208,20 @@
</span><span class="cx">  **************************************************************************/
</span><span class="cx"> 
</span><span class="cx"> function xprofile_admin_manage_field( $group_id, $field_id = null ) {
</span><del>-        global $message, $groups;
</del><ins>+        global $bp, $wpdb, $message, $groups;
</ins><span class="cx">         
</span><span class="cx">         $field = new BP_XProfile_Field($field_id);
</span><span class="cx">         $field-&gt;group_id = $group_id;
</span><span class="cx"> 
</span><span class="cx">         if ( isset($_POST['saveField']) ) {
</span><del>-                if ( BP_XProfile_Field::admin_validate($_POST) ) {
</del><ins>+                if ( BP_XProfile_Field::admin_validate() ) {
</ins><span class="cx">                         $field-&gt;name = wp_filter_kses( $_POST['title'] );
</span><span class="cx">                         $field-&gt;desc = wp_filter_kses( $_POST['description'] );
</span><span class="cx">                         $field-&gt;is_required = wp_filter_kses( $_POST['required'] );
</span><span class="cx">                         $field-&gt;type = wp_filter_kses( $_POST['fieldtype'] );
</span><span class="cx">                         $field-&gt;order_by = wp_filter_kses( $_POST[&quot;sort_order_$field-&gt;type&quot;] );
</span><ins>+                        $field-&gt;field_order = (int) $wpdb-&gt;get_var( $wpdb-&gt;prepare( &quot;SELECT max(field_order) FROM {$bp-&gt;profile-&gt;table_name_fields} WHERE group_id = %d&quot;, $group_id ) );
+                        $field-&gt;field_order++;
</ins><span class="cx">                         
</span><span class="cx">                         if ( !$field-&gt;save() ) {
</span><span class="cx">                                 $message = __('There was an error saving the field. Please try again', 'buddypress');
</span></span></pre></div>
<a id="trunkbpxprofilebpxprofileclassesphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-xprofile/bp-xprofile-classes.php (1867 => 1868)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-xprofile/bp-xprofile-classes.php        2009-09-14 18:00:55 UTC (rev 1867)
+++ trunk/bp-xprofile/bp-xprofile-classes.php        2009-09-14 18:27:34 UTC (rev 1868)
</span><span class="lines">@@ -249,13 +249,14 @@
</span><span class="cx">                 $this-&gt;desc = apply_filters( 'xprofile_field_description_before_save', $this-&gt;desc, $this-&gt;id );
</span><span class="cx">                 $this-&gt;is_required = apply_filters( 'xprofile_field_is_required_before_save', $this-&gt;is_required, $this-&gt;id );
</span><span class="cx">                 $this-&gt;order_by = apply_filters( 'xprofile_field_order_by_before_save', $this-&gt;order_by, $this-&gt;id );
</span><ins>+                $this-&gt;field_order = apply_filters( 'xprofile_field_field_order_before_save', $this-&gt;field_order, $this-&gt;id );
</ins><span class="cx"> 
</span><span class="cx">                 do_action( 'xprofile_field_before_save', $this );
</span><span class="cx">                 
</span><span class="cx">                 if ( $this-&gt;id != null )
</span><del>-                        $sql = $wpdb-&gt;prepare(&quot;UPDATE {$bp-&gt;profile-&gt;table_name_fields} SET group_id = %d, parent_id = 0, type = %s, name = %s, description = %s, is_required = %d, order_by = %s WHERE id = %d&quot;, $this-&gt;group_id, $this-&gt;type, $this-&gt;name, $this-&gt;desc, $this-&gt;is_required, $this-&gt;order_by, $this-&gt;id);
</del><ins>+                        $sql = $wpdb-&gt;prepare(&quot;UPDATE {$bp-&gt;profile-&gt;table_name_fields} SET group_id = %d, parent_id = 0, type = %s, name = %s, description = %s, is_required = %d, order_by = %s, field_order = %d WHERE id = %d&quot;, $this-&gt;group_id, $this-&gt;type, $this-&gt;name, $this-&gt;desc, $this-&gt;is_required, $this-&gt;order_by, $this-&gt;field_order, $this-&gt;id);
</ins><span class="cx">                 else
</span><del>-                        $sql = $wpdb-&gt;prepare(&quot;INSERT INTO {$bp-&gt;profile-&gt;table_name_fields} (group_id, parent_id, type, name, description, is_required, order_by) VALUES (%d, 0, %s, %s, %s, %d, %d)&quot;, $this-&gt;group_id, $this-&gt;type, $this-&gt;name, $this-&gt;desc, $this-&gt;is_required, $this-&gt;order_by);
</del><ins>+                        $sql = $wpdb-&gt;prepare(&quot;INSERT INTO {$bp-&gt;profile-&gt;table_name_fields} (group_id, parent_id, type, name, description, is_required, order_by, field_order ) VALUES (%d, 0, %s, %s, %s, %d, %s, %d )&quot;, $this-&gt;group_id, $this-&gt;type, $this-&gt;name, $this-&gt;desc, $this-&gt;is_required, $this-&gt;order_by, $this-&gt;field_order );
</ins><span class="cx"> 
</span><span class="cx">                 if ( $wpdb-&gt;query($sql) ) {
</span><span class="cx">                         
</span><span class="lines">@@ -565,23 +566,6 @@
</span><span class="cx">         &lt;?php
</span><span class="cx">         }
</span><span class="cx">         
</span><del>-        /* Deprecated - Signup fields are now in the template */
-        function get_signup_fields() {
-                global $wpdb, $bp;
-                
-                $sql = $wpdb-&gt;prepare( &quot;SELECT f.id FROM {$bp-&gt;profile-&gt;table_name_fields} AS f, {$bp-&gt;profile-&gt;table_name_groups} AS g WHERE g.name = %s AND f.parent_id = 0        AND g.id = f.group_id ORDER BY f.id&quot;, get_site_option('bp-xprofile-base-group-name') );
-
-                if ( !$temp_fields = $wpdb-&gt;get_results($sql) )
-                        return false;
-                
-                for ( $i = 0; $i &lt; count($temp_fields); $i++ ) {
-                        $fields[] = new BP_XProfile_Field( $temp_fields[$i]-&gt;id, null, false );
-                }
-                
-                return $fields;
-        }
-        
-        /* Deprecated, Validation is now done in the screen function */
</del><span class="cx">         function admin_validate() {
</span><span class="cx">                 global $message;
</span><span class="cx">                 
</span><span class="lines">@@ -605,6 +589,23 @@
</span><span class="cx">                         return true;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><ins>+
+        /* Deprecated - Signup fields are now in the template */
+        function get_signup_fields() {
+                global $wpdb, $bp;
+                
+                $sql = $wpdb-&gt;prepare( &quot;SELECT f.id FROM {$bp-&gt;profile-&gt;table_name_fields} AS f, {$bp-&gt;profile-&gt;table_name_groups} AS g WHERE g.name = %s AND f.parent_id = 0        AND g.id = f.group_id ORDER BY f.id&quot;, get_site_option('bp-xprofile-base-group-name') );
+
+                if ( !$temp_fields = $wpdb-&gt;get_results($sql) )
+                        return false;
+                
+                for ( $i = 0; $i &lt; count($temp_fields); $i++ ) {
+                        $fields[] = new BP_XProfile_Field( $temp_fields[$i]-&gt;id, null, false );
+                }
+                
+                return $fields;
+        }
+
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkbpxprofilebpxprofiletemplatetagsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-xprofile/bp-xprofile-templatetags.php (1867 => 1868)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-xprofile/bp-xprofile-templatetags.php        2009-09-14 18:00:55 UTC (rev 1867)
+++ trunk/bp-xprofile/bp-xprofile-templatetags.php        2009-09-14 18:27:34 UTC (rev 1868)
</span><span class="lines">@@ -395,9 +395,7 @@
</span><span class="cx">                                         } else {
</span><span class="cx">                                                 $selected = '';
</span><span class="cx">                                         }
</span><del>-                                        
-                                         
-                                        
</del><ins>+
</ins><span class="cx">                                         $html .= apply_filters( 'bp_get_the_profile_field_options_select', '&lt;option' . $selected . ' value=&quot;' . attribute_escape( $options[$k]-&gt;name ) . '&quot;&gt;' . attribute_escape( $options[$k]-&gt;name ) . '&lt;/option&gt;', $options[$k] );
</span><span class="cx">                                 }
</span><span class="cx">                                 break;
</span></span></pre>
</div>
</div>

</body>
</html>