<!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] [1798] trunk/bp-xprofile: Added profile field re-ordering</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd>1798</dd>
<dt>Author</dt> <dd>apeatling</dd>
<dt>Date</dt> <dd>2009-09-06 01:07:21 +0000 (Sun, 06 Sep 2009)</dd>
</dl>

<h3>Log Message</h3>
<pre>Added profile field re-ordering</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkbpxprofileadmincssadmincss">trunk/bp-xprofile/admin/css/admin.css</a></li>
<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="#trunkbpxprofilebpxprofilecssjsphp">trunk/bp-xprofile/bp-xprofile-cssjs.php</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li>trunk/bp-xprofile/admin/</li>
<li>trunk/bp-xprofile/admin/css/</li>
<li>trunk/bp-xprofile/admin/images/</li>
<li><a href="#trunkbpxprofileadminimagesmovegif">trunk/bp-xprofile/admin/images/move.gif</a></li>
<li><a href="#trunkbpxprofileadminimagestickgif">trunk/bp-xprofile/admin/images/tick.gif</a></li>
<li>trunk/bp-xprofile/admin/js/</li>
<li><a href="#trunkbpxprofileadminjsadminjs">trunk/bp-xprofile/admin/js/admin.js</a></li>
</ul>

<h3>Removed Paths</h3>
<ul>
<li>trunk/bp-xprofile/css/</li>
<li><a href="#trunkbpxprofiledeprecatedimagestickgif">trunk/bp-xprofile/deprecated/images/tick.gif</a></li>
<li>trunk/bp-xprofile/js/</li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkbpxprofileadmincssfromrev1789trunkbpxprofilecss"></a>
<div class="copfile"><h4>Copied: trunk/bp-xprofile/admin/css (from rev 1789, trunk/bp-xprofile/css)</h4></div>
<a id="trunkbpxprofileadmincssadmincss"></a>
<div class="modfile"><h4>Modified: trunk/bp-xprofile/admin/css/admin.css (1789 => 1798)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-xprofile/css/admin.css        2009-09-04 18:30:04 UTC (rev 1789)
+++ trunk/bp-xprofile/admin/css/admin.css        2009-09-06 01:07:21 UTC (rev 1798)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+table.field-group tbody {
+        cursor: move;
+}
+        table.field-group tbody tr.nodrag {
+                cursor: default !important;
+        }
+
+table.field-group tbody tr:hover {
+        background-color: #fffee9;
+}
+        
</ins><span class="cx"> tr.header td {
</span><span class="cx">         border-bottom: 2px solid #eee;
</span><span class="cx">         font-weight: bold;
</span></span></pre></div>
<a id="trunkbpxprofileadminimagesmovegif"></a>
<div class="binary"><h4>Added: trunk/bp-xprofile/admin/images/move.gif</h4>
<pre class="diff"><span>
<span class="cx">(Binary files differ)
</span></span></pre></div>
<span class="cx">Property changes on: trunk/bp-xprofile/admin/images/move.gif
</span><span class="cx">___________________________________________________________________
</span><span class="cx">Name: svn:mime-type
</span><span class="cx">   + application/octet-stream
</span><a id="trunkbpxprofileadminimagestickgiffromrev1789trunkbpxprofiledeprecatedimagestickgif"></a>
<div class="binary"><h4>Copied: trunk/bp-xprofile/admin/images/tick.gif (from rev 1789, trunk/bp-xprofile/deprecated/images/tick.gif)</h4>
<pre class="diff"><span>
<span class="cx">(Binary files differ)
</span></span></pre></div>
<a id="trunkbpxprofileadminjsadminjs"></a>
<div class="addfile"><h4>Added: trunk/bp-xprofile/admin/js/admin.js (0 => 1798)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-xprofile/admin/js/admin.js                                (rev 0)
+++ trunk/bp-xprofile/admin/js/admin.js        2009-09-06 01:07:21 UTC (rev 1798)
</span><span class="lines">@@ -0,0 +1,136 @@
</span><ins>+function add_option(forWhat) {
+        var holder = document.getElementById(forWhat + &quot;_more&quot;);
+        var theId = document.getElementById(forWhat + '_option_number').value;
+
+        var newDiv = document.createElement('p');
+        newDiv.setAttribute('id', forWhat + '_div' + theId);
+
+        var newOption = document.createElement('input');
+        newOption.setAttribute('type', 'text');
+        newOption.setAttribute('name', forWhat + '_option[' + theId + ']');
+        newOption.setAttribute('id', forWhat + '_option' + theId);
+
+        var label = document.createElement('label');
+        label.setAttribute('for', forWhat + '_option' + theId);
+        
+        var txt = document.createTextNode(&quot;Option &quot; + theId + &quot;: &quot;);
+        label.appendChild(txt);
+        
+        var isDefault = document.createElement('input');
+        
+        if(forWhat == 'checkbox' || forWhat == 'multiselectbox') {
+                isDefault.setAttribute('type', 'checkbox');
+                isDefault.setAttribute('name', 'isDefault_' + forWhat + '_option[' + theId + ']');
+        } else {
+                isDefault.setAttribute('type', 'radio');
+                isDefault.setAttribute('name', 'isDefault_' + forWhat + '_option');                                        
+        }
+        
+        isDefault.setAttribute('value', theId);
+
+        var label1 = document.createElement('label');
+        var txt1 = document.createTextNode(&quot; Default Value &quot;);
+        
+        label1.appendChild(txt1);
+        label1.setAttribute('for', 'isDefault_' + forWhat + '_option[]');
+        toDelete = document.createElement('a');
+        
+        toDeleteText = document.createTextNode('[x]');
+        toDelete.setAttribute('href',&quot;javascript:hide('&quot; + forWhat + '_div' + theId + &quot;')&quot;);
+        
+        toDelete.setAttribute('class','delete');
+
+        toDelete.appendChild(toDeleteText);
+
+        newDiv.appendChild(label);
+        newDiv.appendChild(newOption);
+        newDiv.appendChild(document.createTextNode(&quot; &quot;));
+        newDiv.appendChild(isDefault);
+        newDiv.appendChild(label1);        
+        newDiv.appendChild(toDelete);        
+        holder.appendChild(newDiv);
+        
+        
+        theId++
+        document.getElementById(forWhat + &quot;_option_number&quot;).value = theId;
+}
+
+function show_options(forWhat) {
+        document.getElementById(&quot;radio&quot;).style.display = &quot;none&quot;;
+        document.getElementById(&quot;selectbox&quot;).style.display = &quot;none&quot;;
+        document.getElementById(&quot;multiselectbox&quot;).style.display = &quot;none&quot;;
+        document.getElementById(&quot;checkbox&quot;).style.display = &quot;none&quot;;
+        
+        if(forWhat == &quot;radio&quot;) {
+                document.getElementById(&quot;radio&quot;).style.display = &quot;&quot;;
+        }
+        
+        if(forWhat == &quot;selectbox&quot;) {
+                document.getElementById(&quot;selectbox&quot;).style.display = &quot;&quot;;                                                
+        }
+        
+        if(forWhat == &quot;multiselectbox&quot;) {
+                document.getElementById(&quot;multiselectbox&quot;).style.display = &quot;&quot;;                                                
+        }
+        
+        if(forWhat == &quot;checkbox&quot;) {
+                document.getElementById(&quot;checkbox&quot;).style.display = &quot;&quot;;                                                
+        }
+}
+
+function hide(id) {
+        if ( !document.getElementById(id) ) return false;
+        
+        document.getElementById(id).style.display = &quot;none&quot;;
+        document.getElementById(id).value = '';
+}
+
+// Set up deleting options ajax
+jQuery(document).ready( function() {
+        
+        jQuery(&quot;a.ajax-option-delete&quot;).click( 
+                function() {
+                        var theId = this.id.split('-');
+                        theId = theId[1];
+                        
+                        jQuery.post( ajaxurl, {
+                                action: 'xprofile_delete_option',
+                                'cookie': encodeURIComponent(document.cookie),
+                                '_wpnonce': jQuery(&quot;input#_wpnonce&quot;).val(),
+                                
+                                'option_id': theId
+                        },
+                        function(response)
+                        {});
+                }
+        );                                
+});
+
+var fixHelper = function(e, ui) {
+        ui.children().each(function() {
+                jQuery(this).width( jQuery(this).width() );
+        });
+        return ui;
+};
+
+jQuery(document).ready( function() {
+        jQuery(&quot;table.field-group tbody&quot;).sortable( {
+                cursor: 'move',
+                axis: 'y',
+                helper: fixHelper,
+                distance: 1,
+                cancel: 'tr.nodrag',
+                update: function() { 
+                        jQuery.post( ajaxurl, {
+                                action: 'xprofile_reorder_fields',
+                                'cookie': encodeURIComponent(document.cookie),
+                                '_wpnonce_reorder_fields': jQuery(&quot;input#_wpnonce_reorder_fields&quot;).val(),
+                                
+                                'field_order': jQuery(this).sortable('serialize')
+                        },
+                        function(response)
+                        {});
+
+                }
+        });
+} );
</ins></span></pre></div>
<a id="trunkbpxprofilebpxprofileadminphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-xprofile/bp-xprofile-admin.php (1797 => 1798)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-xprofile/bp-xprofile-admin.php        2009-09-05 14:11:06 UTC (rev 1797)
+++ trunk/bp-xprofile/bp-xprofile-admin.php        2009-09-06 01:07:21 UTC (rev 1798)
</span><span class="lines">@@ -41,75 +41,97 @@
</span><span class="cx">                         
</span><span class="cx">                 &lt;p&gt;&lt;?php _e('NOTE: Any fields in the first group will appear on the signup page.', 'buddypress'); ?&gt;&lt;/p&gt;
</span><span class="cx">                 
</span><del>-                &lt;?php
-                        if ( $message != '' ) {
-                                $type = ( $type == 'error' ) ? 'error' : 'updated';
-                ?&gt;
-                        &lt;div id=&quot;message&quot; class=&quot;&lt;?php echo $type; ?&gt; fade&quot;&gt;
-                                &lt;p&gt;&lt;?php echo wp_specialchars( $message ); ?&gt;&lt;/p&gt;
-                        &lt;/div&gt;
-                &lt;?php }
</del><ins>+                &lt;form action=&quot;&quot; id=&quot;profile-field-form&quot; method=&quot;post&quot;&gt;
+                        
+                        &lt;?php wp_nonce_field( 'bp_reorder_fields', '_wpnonce_reorder_fields' ); ?&gt;
+                                        
+                        &lt;?php
+                                if ( $message != '' ) {
+                                        $type = ( $type == 'error' ) ? 'error' : 'updated';
+                        ?&gt;
+                                &lt;div id=&quot;message&quot; class=&quot;&lt;?php echo $type; ?&gt; fade&quot;&gt;
+                                        &lt;p&gt;&lt;?php echo wp_specialchars( attribute_escape( $message ) ); ?&gt;&lt;/p&gt;
+                                &lt;/div&gt;
+                        &lt;?php }
</ins><span class="cx">                 
</span><del>-                if ( $groups ) { ?&gt;
-                        &lt;?php 
-                        for ( $i = 0; $i &lt; count($groups); $i++ ) { // TODO: foreach
-                        ?&gt;
-                                &lt;p&gt;
-                                &lt;table id=&quot;group_&lt;?php echo $groups[$i]-&gt;id;?&gt;&quot; class=&quot;widefat&quot;&gt;
-                                        &lt;thead&gt;
-                                            &lt;tr class=&quot;nodrag&quot;&gt;
-                                                    &lt;th scope=&quot;col&quot; colspan=&quot;&lt;?php if ( $groups[$i]-&gt;can_delete ) { ?&gt;3&lt;?php } else { ?&gt;5&lt;?php } ?&gt;&quot;&gt;&lt;?php echo $groups[$i]-&gt;name; ?&gt;&lt;/th&gt;
-                                                        &lt;?php if ( $groups[$i]-&gt;can_delete ) { ?&gt;            
-                                                                &lt;th scope=&quot;col&quot;&gt;&lt;a class=&quot;edit&quot; href=&quot;admin.php?page=&lt;?php echo BP_PLUGIN_DIR ?&gt;/bp-xprofile.php&amp;amp;mode=edit_group&amp;amp;group_id=&lt;?php echo $groups[$i]-&gt;id; ?&gt;&quot;&gt;&lt;?php _e( 'Edit', 'buddypress' ) ?&gt;&lt;/a&gt;&lt;/th&gt;
-                                                            &lt;th scope=&quot;col&quot;&gt;&lt;a class=&quot;delete&quot; href=&quot;admin.php?page=&lt;?php echo BP_PLUGIN_DIR ?&gt;/bp-xprofile.php&amp;amp;mode=delete_group&amp;amp;group_id=&lt;?php echo $groups[$i]-&gt;id; ?&gt;&quot;&gt;&lt;?php _e( 'Delete', 'buddypress' ) ?&gt;&lt;/a&gt;&lt;/th&gt;
-                                                        &lt;?php } ?&gt;
-                                                &lt;/tr&gt;
-                                        &lt;/thead&gt;
-                                        &lt;tbody id=&quot;the-list&quot;&gt;
-                                           &lt;tr class=&quot;header nodrag&quot;&gt;
-                                                    &lt;td&gt;&lt;?php _e( 'Field Name', 'buddypress' ) ?&gt;&lt;/td&gt;
-                                                    &lt;td width=&quot;14%&quot;&gt;&lt;?php _e( 'Field Type', 'buddypress' ) ?&gt;&lt;/td&gt;
-                                                    &lt;td width=&quot;6%&quot;&gt;&lt;?php _e( 'Required?', 'buddypress' ) ?&gt;&lt;/td&gt;
-                                                    &lt;td colspan=&quot;2&quot; width=&quot;10%&quot; style=&quot;text-align:center;&quot;&gt;&lt;?php _e( 'Action', 'buddypress' ) ?&gt;&lt;/td&gt;
-                                            &lt;/tr&gt;
-
</del><ins>+                        if ( $groups ) { ?&gt;
+                                &lt;?php 
+                                for ( $i = 0; $i &lt; count($groups); $i++ ) { // TODO: foreach
+                                ?&gt;
+                                        &lt;p&gt;
+                                        &lt;table id=&quot;group_&lt;?php echo $groups[$i]-&gt;id;?&gt;&quot; class=&quot;widefat field-group&quot;&gt;
+                                                &lt;thead&gt;
+                                                    &lt;tr&gt;
+                                                                &lt;th scope=&quot;col&quot;&gt;&amp;nbsp;&lt;/th&gt;
+                                                            &lt;th scope=&quot;col&quot; colspan=&quot;&lt;?php if ( $groups[$i]-&gt;can_delete ) { ?&gt;3&lt;?php } else { ?&gt;5&lt;?php } ?&gt;&quot;&gt;&lt;?php echo attribute_escape( $groups[$i]-&gt;name ); ?&gt;&lt;/th&gt;
+                                                                &lt;?php if ( $groups[$i]-&gt;can_delete ) { ?&gt;            
+                                                                        &lt;th scope=&quot;col&quot;&gt;&lt;a class=&quot;edit&quot; href=&quot;admin.php?page=&lt;?php echo BP_PLUGIN_DIR ?&gt;/bp-xprofile.php&amp;amp;mode=edit_group&amp;amp;group_id=&lt;?php echo attribute_escape( $groups[$i]-&gt;id ); ?&gt;&quot;&gt;&lt;?php _e( 'Edit', 'buddypress' ) ?&gt;&lt;/a&gt;&lt;/th&gt;
+                                                                    &lt;th scope=&quot;col&quot;&gt;&lt;a class=&quot;delete&quot; href=&quot;admin.php?page=&lt;?php echo BP_PLUGIN_DIR ?&gt;/bp-xprofile.php&amp;amp;mode=delete_group&amp;amp;group_id=&lt;?php echo attribute_escape( $groups[$i]-&gt;id ); ?&gt;&quot;&gt;&lt;?php _e( 'Delete', 'buddypress' ) ?&gt;&lt;/a&gt;&lt;/th&gt;
+                                                                &lt;?php } ?&gt;
+                                                        &lt;/tr&gt;
+                                                        &lt;tr class=&quot;header&quot;&gt;
+                                                                &lt;td&gt;&amp;nbsp;&lt;/td&gt;
+                                                            &lt;td&gt;&lt;?php _e( 'Field Name', 'buddypress' ) ?&gt;&lt;/td&gt;
+                                                            &lt;td width=&quot;14%&quot;&gt;&lt;?php _e( 'Field Type', 'buddypress' ) ?&gt;&lt;/td&gt;
+                                                            &lt;td width=&quot;6%&quot;&gt;&lt;?php _e( 'Required?', 'buddypress' ) ?&gt;&lt;/td&gt;
+                                                            &lt;td colspan=&quot;2&quot; width=&quot;10%&quot; style=&quot;text-align:center;&quot;&gt;&lt;?php _e( 'Action', 'buddypress' ) ?&gt;&lt;/td&gt;
+                                                    &lt;/tr&gt;
+                                                &lt;/thead&gt;
+                                                &lt;tbody id=&quot;the-list&quot;&gt;
+                                                
</ins><span class="cx">                                                   &lt;?php if ( $groups[$i]-&gt;fields ) { ?&gt;
</span><del>-                                                    &lt;?php for ( $j = 0; $j &lt; count($groups[$i]-&gt;fields); $j++ ) { ?&gt;
-                                                                        &lt;?php if ( 0 == $j % 2 ) { $class = &quot;&quot;; } else { $class = &quot;alternate&quot;; } ?&gt;
-                                                            &lt;?php $field = new BP_XProfile_Field($groups[$i]-&gt;fields[$j]-&gt;id); ?&gt;
-                                                            &lt;?php if ( !$field-&gt;can_delete ) { $class .= ' core'; } ?&gt;
</del><span class="cx">                                                         
</span><del>-                                                                        &lt;tr id=&quot;field_&lt;?php echo $field-&gt;id; ?&gt;&quot; &lt;?php if ( $class ) { echo 'class=&quot;' . $class . '&quot;'; } ?&gt;&gt;
-                                                                    &lt;td&gt;&lt;span title=&quot;&lt;?php echo $field-&gt;desc; ?&gt;&quot;&gt;&lt;?php echo $field-&gt;name; ?&gt; &lt;?php if(!$field-&gt;can_delete) { ?&gt;(Core)&lt;?php } ?&gt;&lt;/span&gt;&lt;/td&gt;
-                                                                    &lt;td&gt;&lt;?php echo $field-&gt;type; ?&gt;&lt;/td&gt;
-                                                                    &lt;td style=&quot;text-align:center;&quot;&gt;&lt;?php if ( $field-&gt;is_required ) { echo '&lt;img src=&quot;' . $bp-&gt;profile-&gt;image_base . '/tick.gif&quot; alt=&quot;' . _e( 'Yes', 'buddypress' ) . '&quot; /&gt;'; } else { ?&gt;--&lt;?php } ?&gt;&lt;/td&gt;
-                                                                    &lt;td style=&quot;text-align:center;&quot;&gt;&lt;?php if ( !$field-&gt;can_delete ) { ?&gt;&lt;strike&gt;&lt;?php _e( 'Edit', 'buddypress' ) ?&gt;&lt;/strike&gt;&lt;?php } else { ?&gt;&lt;a class=&quot;edit&quot; href=&quot;admin.php?page=&lt;?php echo BP_PLUGIN_DIR ?&gt;/bp-xprofile.php&amp;amp;group_id=&lt;?php echo $groups[$i]-&gt;id; ?&gt;&amp;amp;field_id=&lt;?php echo $field-&gt;id; ?&gt;&amp;amp;mode=edit_field&quot;&gt;&lt;?php _e( 'Edit', 'buddypress' ) ?&gt;&lt;/a&gt;&lt;?php } ?&gt;&lt;/td&gt;
-                                                                    &lt;td style=&quot;text-align:center;&quot;&gt;&lt;?php if ( !$field-&gt;can_delete ) { ?&gt;&lt;strike&gt;&lt;?php _e( 'Delete', 'buddypress' ) ?&gt;&lt;/strike&gt;&lt;?php } else { ?&gt;&lt;a class=&quot;delete&quot; href=&quot;admin.php?page=&lt;?php echo BP_PLUGIN_DIR ?&gt;/bp-xprofile.php&amp;amp;field_id=&lt;?php echo $field-&gt;id; ?&gt;&amp;amp;mode=delete_field&quot;&gt;&lt;?php _e( 'Delete', 'buddypress' ) ?&gt;&lt;/a&gt;&lt;?php } ?&gt;&lt;/td&gt;
-                                                            &lt;/tr&gt;
</del><ins>+                                                            &lt;?php for ( $j = 0; $j &lt; count($groups[$i]-&gt;fields); $j++ ) { ?&gt;
+                                                
+                                                                        &lt;?php if ( 0 == $j % 2 ) { $class = &quot;&quot;; } else { $class = &quot;alternate&quot;; } ?&gt;            
+                                                                        &lt;?php $field = new BP_XProfile_Field($groups[$i]-&gt;fields[$j]-&gt;id); ?&gt;
+                                                                        &lt;?php if ( !$field-&gt;can_delete ) { $class .= ' core'; } ?&gt;
</ins><span class="cx">                                                         
</span><ins>+                                                                        &lt;tr id=&quot;field_&lt;?php echo attribute_escape( $field-&gt;id ); ?&gt;&quot; class=&quot;sortable&lt;?php if ( $class ) { echo ' ' . $class; } ?&gt;&quot;&gt;
+                                                                            &lt;td width=&quot;10&quot;&gt;&lt;img src=&quot;&lt;?php echo BP_PLUGIN_URL ?&gt;/bp-xprofile/admin/images/move.gif&quot; alt=&quot;&lt;?php _e( 'Drag', 'buddypress' ) ?&gt;&quot; /&gt;&lt;/td&gt;
+                                                                                &lt;td&gt;&lt;span title=&quot;&lt;?php echo $field-&gt;desc; ?&gt;&quot;&gt;&lt;?php echo attribute_escape( $field-&gt;name ); ?&gt; &lt;?php if(!$field-&gt;can_delete) { ?&gt;(Core)&lt;?php } ?&gt;&lt;/span&gt;&lt;/td&gt;
+                                                                            &lt;td&gt;&lt;?php echo attribute_escape( $field-&gt;type ); ?&gt;&lt;/td&gt;
+                                                                            &lt;td style=&quot;text-align:center;&quot;&gt;&lt;?php if ( $field-&gt;is_required ) { echo '&lt;img src=&quot;' . BP_PLUGIN_URL . '/bp-xprofile/admin/images/tick.gif&quot; alt=&quot;' . __( 'Yes', 'buddypress' ) . '&quot; /&gt;'; } else { ?&gt;--&lt;?php } ?&gt;&lt;/td&gt;
+                                                                            &lt;td style=&quot;text-align:center;&quot;&gt;&lt;?php if ( !$field-&gt;can_delete ) { ?&gt;&lt;strike&gt;&lt;?php _e( 'Edit', 'buddypress' ) ?&gt;&lt;/strike&gt;&lt;?php } else { ?&gt;&lt;a class=&quot;edit&quot; href=&quot;admin.php?page=&lt;?php echo BP_PLUGIN_DIR ?&gt;/bp-xprofile.php&amp;amp;group_id=&lt;?php echo attribute_escape( $groups[$i]-&gt;id ); ?&gt;&amp;amp;field_id=&lt;?php echo attribute_escape( $field-&gt;id ); ?&gt;&amp;amp;mode=edit_field&quot;&gt;&lt;?php _e( 'Edit', 'buddypress' ) ?&gt;&lt;/a&gt;&lt;?php } ?&gt;&lt;/td&gt;
+                                                                            &lt;td style=&quot;text-align:center;&quot;&gt;&lt;?php if ( !$field-&gt;can_delete ) { ?&gt;&lt;strike&gt;&lt;?php _e( 'Delete', 'buddypress' ) ?&gt;&lt;/strike&gt;&lt;?php } else { ?&gt;&lt;a class=&quot;delete&quot; href=&quot;admin.php?page=&lt;?php echo BP_PLUGIN_DIR ?&gt;/bp-xprofile.php&amp;amp;field_id=&lt;?php echo attribute_escape( $field-&gt;id ); ?&gt;&amp;amp;mode=delete_field&quot;&gt;&lt;?php _e( 'Delete', 'buddypress' ) ?&gt;&lt;/a&gt;&lt;?php } ?&gt;&lt;/td&gt;
+                                                                    &lt;/tr&gt;
+                                                        
+                                                                &lt;?php } ?&gt;
+                                                        
+                                                        &lt;?php } else { ?&gt;
+                                                        
+                                                                &lt;tr class=&quot;nodrag&quot;&gt;
+                                                                        &lt;td colspan=&quot;6&quot;&gt;&lt;?php _e( 'There are no fields in this group.', 'buddypress' ) ?&gt;&lt;/td&gt;
+                                                                &lt;/tr&gt;
+                                                        
</ins><span class="cx">                                                         &lt;?php } ?&gt;
</span><del>-                                                &lt;?php } else { ?&gt;
-                                                        &lt;tr class=&quot;nodrag&quot;&gt;
-                                                                &lt;td colspan=&quot;6&quot;&gt;&lt;?php _e( 'There are no fields in this group.', 'buddypress' ) ?&gt;&lt;/td&gt;
-                                                        &lt;/tr&gt;
-                                                &lt;?php } ?&gt;
-                                                        &lt;tr class=&quot;nodrag&quot;&gt;
-                                                                &lt;td colspan=&quot;6&quot;&gt;&lt;a href=&quot;admin.php?page=&lt;?php echo BP_PLUGIN_DIR ?&gt;/bp-xprofile.php&amp;amp;group_id=&lt;?php echo $groups[$i]-&gt;id; ?&gt;&amp;amp;mode=add_field&quot;&gt;&lt;?php _e( 'Add New Field', 'buddypress' ) ?&gt;&lt;/a&gt;&lt;/td&gt;
-                                                        &lt;/tr&gt;
-                                        &lt;/tbody&gt;
-                                &lt;/table&gt;
-                                &lt;/p&gt;
</del><ins>+                                        
+                                                &lt;/tbody&gt;
+                                        
+                                                &lt;tfoot&gt;
+                                                
+                                                                &lt;tr class=&quot;nodrag&quot;&gt;
+                                                                        &lt;td colspan=&quot;6&quot;&gt;&lt;a href=&quot;admin.php?page=&lt;?php echo BP_PLUGIN_DIR ?&gt;/bp-xprofile.php&amp;amp;group_id=&lt;?php echo attribute_escape( $groups[$i]-&gt;id ); ?&gt;&amp;amp;mode=add_field&quot;&gt;&lt;?php _e( 'Add New Field', 'buddypress' ) ?&gt;&lt;/a&gt;&lt;/td&gt;
+                                                                &lt;/tr&gt;
+                                                
+                                                &lt;/tfoot&gt;
+                                        
+                                        &lt;/table&gt;
+                                        &lt;/p&gt;
</ins><span class="cx">                                 
</span><del>-                        &lt;?php } /* End For */ ?&gt;
</del><ins>+                                &lt;?php } /* End For */ ?&gt;
</ins><span class="cx">                         
</span><del>-                                &lt;p&gt;
-                                        &lt;a href=&quot;admin.php?page=&lt;?php echo BP_PLUGIN_DIR ?&gt;/bp-xprofile.php&amp;amp;mode=add_group&quot;&gt;&lt;?php _e( 'Add New Group', 'buddypress' ) ?&gt;&lt;/a&gt;
-                                &lt;/p&gt;
</del><ins>+                                        &lt;p&gt;
+                                                &lt;a class=&quot;button&quot; href=&quot;admin.php?page=&lt;?php echo BP_PLUGIN_DIR ?&gt;/bp-xprofile.php&amp;amp;mode=add_group&quot;&gt;&lt;?php _e( 'Add New Field Group', 'buddypress' ) ?&gt;&lt;/a&gt;
+                                        &lt;/p&gt;
</ins><span class="cx">                                 
</span><del>-                &lt;?php } else { ?&gt;
-                        &lt;div id=&quot;message&quot; class=&quot;error&quot;&gt;&lt;p&gt;&lt;?php _e('You have no groups.', 'buddypress' ); ?&gt;&lt;/p&gt;&lt;/div&gt;
-                        &lt;p&gt;&lt;a href=&quot;admin.php?page=&lt;?php echo BP_PLUGIN_DIR ?&gt;/bp-xprofile.php&amp;amp;mode=add_group&quot;&gt;&lt;?php _e( 'Add New Group', 'buddypress' ) ?&gt;&lt;/a&gt;&lt;/p&gt;
-                &lt;?php } ?&gt;
</del><ins>+                        &lt;?php } else { ?&gt;
+                                &lt;div id=&quot;message&quot; class=&quot;error&quot;&gt;&lt;p&gt;&lt;?php _e('You have no groups.', 'buddypress' ); ?&gt;&lt;/p&gt;&lt;/div&gt;
+                                &lt;p&gt;&lt;a href=&quot;admin.php?page=&lt;?php echo BP_PLUGIN_DIR ?&gt;/bp-xprofile.php&amp;amp;mode=add_group&quot;&gt;&lt;?php _e( 'Add New Group', 'buddypress' ) ?&gt;&lt;/a&gt;&lt;/p&gt;
+                        &lt;?php } ?&gt;
+                
+                &lt;/form&gt;
+                
</ins><span class="cx">         &lt;/div&gt;
</span><span class="cx"> &lt;?php
</span><span class="cx">         }
</span><span class="lines">@@ -254,3 +276,20 @@
</span><span class="cx">         unset($_GET['mode']);
</span><span class="cx">         xprofile_admin($message, $type);
</span><span class="cx"> }
</span><ins>+
+function xprofile_ajax_reorder_fields() {
+        global $bp;
+        
+        /* Check the nonce */
+        check_admin_referer( 'bp_reorder_fields', '_wpnonce_reorder_fields' );
+        
+        if ( empty( $_POST['field_order'] ) )
+                return false;
+        
+        parse_str($_POST['field_order'], $order );
+
+        foreach ( (array) $order['field'] as $position =&gt; $field_id ) {
+                xprofile_update_field_position( (int) $field_id, (int) $position );
+        }
+}
+add_action( 'wp_ajax_xprofile_reorder_fields', 'xprofile_ajax_reorder_fields' );
</ins></span></pre></div>
<a id="trunkbpxprofilebpxprofileclassesphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-xprofile/bp-xprofile-classes.php (1797 => 1798)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-xprofile/bp-xprofile-classes.php        2009-09-05 14:11:06 UTC (rev 1797)
+++ trunk/bp-xprofile/bp-xprofile-classes.php        2009-09-06 01:07:21 UTC (rev 1798)
</span><span class="lines">@@ -81,7 +81,7 @@
</span><span class="cx">                 global $wpdb, $bp;
</span><span class="cx"> 
</span><span class="cx">                 // Get field ids for the current group.
</span><del>-                if ( !$fields = $wpdb-&gt;get_results( $wpdb-&gt;prepare(&quot;SELECT id, type FROM {$bp-&gt;profile-&gt;table_name_fields} WHERE group_id = %d AND parent_id = 0 ORDER BY id&quot;, $this-&gt;id ) ) )
</del><ins>+                if ( !$fields = $wpdb-&gt;get_results( $wpdb-&gt;prepare(&quot;SELECT id, type FROM {$bp-&gt;profile-&gt;table_name_fields} WHERE group_id = %d AND parent_id = 0 ORDER BY field_order&quot;, $this-&gt;id ) ) )
</ins><span class="cx">                         return false;
</span><span class="cx">                 
</span><span class="cx">                 return $fields;
</span><span class="lines">@@ -127,10 +127,10 @@
</span><span class="cx">                 global $message;
</span><span class="cx"> 
</span><span class="cx">                 if ( !$this-&gt;id ) {
</span><del>-                        $title = __('Add Group', 'buddypress');
</del><ins>+                        $title = __('Add New Field Group', 'buddypress');
</ins><span class="cx">                         $action = &quot;admin.php?page=&quot; . BP_PLUGIN_DIR . &quot;/bp-xprofile.php&amp;amp;mode=add_group&quot;;
</span><span class="cx">                 } else {
</span><del>-                        $title = __('Edit Group', 'buddypress');
</del><ins>+                        $title = __('Edit Field Group', 'buddypress');
</ins><span class="cx">                         $action = &quot;admin.php?page=&quot; . BP_PLUGIN_DIR . &quot;/bp-xprofile.php&amp;amp;mode=edit_group&amp;amp;group_id=&quot; . $this-&gt;id;                        
</span><span class="cx">                 }
</span><span class="cx">         ?&gt;
</span><span class="lines">@@ -151,7 +151,7 @@
</span><span class="cx">                         &lt;form action=&quot;&lt;?php echo attribute_escape( $action ); ?&gt;&quot; method=&quot;post&quot;&gt;
</span><span class="cx">                                 
</span><span class="cx">                                 &lt;div id=&quot;titlediv&quot;&gt;
</span><del>-                                        &lt;label for=&quot;group_name&quot;&gt;&lt;?php _e(&quot;Profile Group Name&quot;, 'buddypress') ?&gt;&lt;/label&gt;
</del><ins>+                                        &lt;label for=&quot;group_name&quot;&gt;&lt;?php _e( &quot;Field Group Name&quot;, 'buddypress') ?&gt;&lt;/label&gt;
</ins><span class="cx">                                         &lt;div&gt;
</span><span class="cx">                                                 &lt;input type=&quot;text&quot; name=&quot;group_name&quot; id=&quot;group_name&quot; value=&quot;&lt;?php echo attribute_escape( $this-&gt;name ) ?&gt;&quot; style=&quot;width:50%&quot; /&gt;
</span><span class="cx">                                         &lt;/div&gt;
</span><span class="lines">@@ -371,6 +371,8 @@
</span><span class="cx"> 
</span><span class="cx">                 $wpdb-&gt;query($sql);
</span><span class="cx">         }
</span><ins>+        
+        // Static Functions
</ins><span class="cx">                 
</span><span class="cx">         function get_type( $field_id ) {
</span><span class="cx">                 global $wpdb, $bp;
</span><span class="lines">@@ -412,6 +414,15 @@
</span><span class="cx">                 return $wpdb-&gt;get_var( $wpdb-&gt;prepare( &quot;SELECT id FROM {$bp-&gt;profile-&gt;table_name_fields} WHERE name = %s&quot;, $field_name ) );
</span><span class="cx">         }
</span><span class="cx">         
</span><ins>+        function update_position( $field_id, $position ) {
+                global $wpdb, $bp;
+                
+                if ( !is_numeric( $position ) )
+                        return false;
+                
+                return $wpdb-&gt;query( $wpdb-&gt;prepare( &quot;UPDATE {$bp-&gt;profile-&gt;table_name_fields} SET field_order = %d WHERE id = %d&quot;, $position, $field_id ) );
+        }
+        
</ins><span class="cx">         // ADMIN AREA HTML. TODO: Get this out of here.
</span><span class="cx">         
</span><span class="cx">         function render_admin_form_children() {
</span></span></pre></div>
<a id="trunkbpxprofilebpxprofilecssjsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-xprofile/bp-xprofile-cssjs.php (1797 => 1798)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-xprofile/bp-xprofile-cssjs.php        2009-09-05 14:11:06 UTC (rev 1797)
+++ trunk/bp-xprofile/bp-xprofile-cssjs.php        2009-09-06 01:07:21 UTC (rev 1798)
</span><span class="lines">@@ -1,16 +1,16 @@
</span><span class="cx"> &lt;?php
</span><span class="cx"> 
</span><span class="cx"> function xprofile_add_admin_css() {
</span><del>-        if ( strpos( $_GET['page'], 'xprofile' ) !== false ) {
-                echo '&lt;link rel=&quot;stylesheet&quot; href=&quot;' . BP_PLUGIN_URL . '/bp-xprofile/css/admin.css' . '&quot; type=&quot;text/css&quot; /&gt;';
-        }
</del><ins>+        wp_enqueue_style( 'xprofile-admin-css', BP_PLUGIN_URL . '/bp-xprofile/admin/css/admin.css' );
</ins><span class="cx"> }
</span><del>-add_action( 'admin_head', 'xprofile_add_admin_css' );
</del><ins>+add_action( 'admin_menu', 'xprofile_add_admin_css' );
</ins><span class="cx"> 
</span><span class="cx"> function xprofile_add_admin_js() {
</span><del>-        if ( strpos( $_GET['page'], 'xprofile' ) !== false )
-                echo '&lt;script type=&quot;text/javascript&quot; src=&quot;' . BP_PLUGIN_URL . '/bp-xprofile/js/admin.js' . '&quot;&gt;&lt;/script&gt;';
</del><ins>+        if ( strpos( $_GET['page'], 'xprofile' ) !== false ) {
+                wp_enqueue_script( array( &quot;jquery-ui-sortable&quot; ) );
+                wp_enqueue_script( 'xprofile-admin-js', BP_PLUGIN_URL . '/bp-xprofile/admin/js/admin.js', array( 'jquery' ) );
+        }
</ins><span class="cx"> }
</span><del>-add_action( 'admin_head', 'xprofile_add_admin_js' );
</del><ins>+add_action( 'admin_menu', 'xprofile_add_admin_js', 1 );
</ins><span class="cx"> 
</span><span class="cx"> ?&gt;
</span></span></pre></div>
<a id="trunkbpxprofiledeprecatedimagestickgif"></a>
<div class="binary"><h4>Deleted: trunk/bp-xprofile/deprecated/images/tick.gif</h4>
<pre class="diff"><span>
<span class="cx">(Binary files differ)
</span></span></pre></div>
</div>

</body>
</html>