<!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] [1920] trunk:
  Added new css classes to profile edit fields also.</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd>1920</dd>
<dt>Author</dt> <dd>apeatling</dd>
<dt>Date</dt> <dd>2009-09-22 18:01:55 +0000 (Tue, 22 Sep 2009)</dd>
</dl>

<h3>Log Message</h3>
<pre>Added new css classes to profile edit fields also.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkbpgroupsbpgroupsclassesphp">trunk/bp-groups/bp-groups-classes.php</a></li>
<li><a href="#trunkbpgroupsbpgroupstemplatetagsphp">trunk/bp-groups/bp-groups-templatetags.php</a></li>
<li><a href="#trunkbpgroupsphp">trunk/bp-groups.php</a></li>
<li><a href="#trunkbpthemesbpsnparentprofileeditphp">trunk/bp-themes/bp-sn-parent/profile/edit.php</a></li>
<li><a href="#trunkbpxprofilebpxprofiletemplatetagsphp">trunk/bp-xprofile/bp-xprofile-templatetags.php</a></li>
</ul>

<h3>Property Changed</h3>
<ul>
<li><a href="#trunkbpforums">trunk/bp-forums/</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkbpforums"></a>
<div class="propset"><h4>Property changes: trunk/bp-forums</h4>
<pre class="diff"><span>
<span class="cx">Name: svn:ignore
</span><span class="cx">   + ./bbpress/bb-includes/backpress/
</span></span></pre></div>
<a id="trunkbpgroupsbpgroupsclassesphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-groups/bp-groups-classes.php (1919 => 1920)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-groups/bp-groups-classes.php        2009-09-22 17:55:13 UTC (rev 1919)
+++ trunk/bp-groups/bp-groups-classes.php        2009-09-22 18:01:55 UTC (rev 1920)
</span><span class="lines">@@ -366,6 +366,19 @@
</span><span class="cx">                 return array( 'groups' =&gt; $paged_groups, 'total' =&gt; $total_groups );
</span><span class="cx">         }
</span><span class="cx">         
</span><ins>+        function get_by_most_forum_posts( $limit = null, $page = null ) {
+                global $wpdb, $bp;
+                
+                if ( $limit &amp;&amp; $page ) {
+                        $pag_sql = $wpdb-&gt;prepare( &quot; LIMIT %d, %d&quot;, intval( ( $page - 1 ) * $limit), intval( $limit ) );
+                }
+                        
+                $paged_groups = $wpdb-&gt;get_results( $wpdb-&gt;prepare( &quot;SELECT gm.group_id FROM {$bp-&gt;groups-&gt;table_name_groupmeta} gm, {$bp-&gt;groups-&gt;table_name} g WHERE g.id = gm.group_id AND g.status != 'hidden' AND gm.meta_key = 'total_member_count' ORDER BY CONVERT(gm.meta_value, SIGNED) DESC {$pag_sql}&quot;, $limit ) );
+                $total_groups = count( $wpdb-&gt;get_results( $wpdb-&gt;prepare( &quot;SELECT gm.group_id FROM {$bp-&gt;groups-&gt;table_name_groupmeta} gm, {$bp-&gt;groups-&gt;table_name} g WHERE g.id = gm.group_id AND g.status != 'hidden' AND gm.meta_key = 'total_member_count' ORDER BY CONVERT(gm.meta_value, SIGNED) DESC&quot;, $limit ) ) );
+
+                return array( 'groups' =&gt; $paged_groups, 'total' =&gt; $total_groups );                
+        }
+        
</ins><span class="cx">         function get_all( $limit = null, $page = null, $only_public = true, $sort_by = false, $order = false ) {
</span><span class="cx">                 global $wpdb, $bp;
</span><span class="cx">                 
</span><span class="lines">@@ -422,7 +435,6 @@
</span><span class="cx">                 return array( 'groups' =&gt; $paged_groups, 'total' =&gt; $total_groups );
</span><span class="cx">         }
</span><span class="cx">         
</span><del>-        
</del><span class="cx">         function get_random( $limit = null, $page = null ) {
</span><span class="cx">                 global $wpdb, $bp;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkbpgroupsbpgroupstemplatetagsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-groups/bp-groups-templatetags.php (1919 => 1920)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-groups/bp-groups-templatetags.php        2009-09-22 17:55:13 UTC (rev 1919)
+++ trunk/bp-groups/bp-groups-templatetags.php        2009-09-22 18:01:55 UTC (rev 1920)
</span><span class="lines">@@ -1803,31 +1803,38 @@
</span><span class="cx">         
</span><span class="cx">         function bp_groups_site_groups_template( $type, $per_page, $max ) {
</span><span class="cx">                 global $bp;
</span><del>-
</del><ins>+                
+                /* TODO: Move $_REQUEST vars out of here */
+                
</ins><span class="cx">                 $this-&gt;pag_page = isset( $_REQUEST['gpage'] ) ? intval( $_REQUEST['gpage'] ) : 1;
</span><span class="cx">                 $this-&gt;pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
</span><del>-                                
</del><ins>+
</ins><span class="cx">                 if ( isset( $_REQUEST['s'] ) &amp;&amp; '' != $_REQUEST['s'] &amp;&amp; $type != 'random' ) {
</span><span class="cx">                         $this-&gt;groups = BP_Groups_Group::search_groups( $_REQUEST['s'], $this-&gt;pag_num, $this-&gt;pag_page );
</span><span class="cx">                 } else if ( isset( $_REQUEST['letter'] ) &amp;&amp; '' != $_REQUEST['letter'] ) {
</span><span class="cx">                         $this-&gt;groups = BP_Groups_Group::get_by_letter( $_REQUEST['letter'], $this-&gt;pag_num, $this-&gt;pag_page );
</span><ins>+                
</ins><span class="cx">                 } else {
</span><span class="cx">                         switch ( $type ) {
</span><del>-                                case 'random':
-                                        $this-&gt;groups = BP_Groups_Group::get_random( $this-&gt;pag_num, $this-&gt;pag_page );
</del><ins>+                                case 'active': default:
+                                        $this-&gt;groups = groups_get_active( $this-&gt;pag_num, $this-&gt;pag_page );
+                                        break;        
+                                
+                                case 'random':                
+                                        $this-&gt;groups = groups_get_random_groups( $this-&gt;pag_num, $this-&gt;pag_page );
</ins><span class="cx">                                         break;
</span><span class="cx">                                 
</span><span class="cx">                                 case 'newest':
</span><del>-                                        $this-&gt;groups = BP_Groups_Group::get_newest( $this-&gt;pag_num, $this-&gt;pag_page );
</del><ins>+                                        $this-&gt;groups = groups_get_newest( $this-&gt;pag_num, $this-&gt;pag_page );
</ins><span class="cx">                                         break;
</span><span class="cx"> 
</span><span class="cx">                                 case 'popular':
</span><del>-                                        $this-&gt;groups = BP_Groups_Group::get_popular( $this-&gt;pag_num, $this-&gt;pag_page );
</del><ins>+                                        $this-&gt;groups = groups_get_popular( $this-&gt;pag_num, $this-&gt;pag_page );
</ins><span class="cx">                                         break;        
</span><del>-                                
-                                case 'active': default:
-                                        $this-&gt;groups = BP_Groups_Group::get_active( $this-&gt;pag_num, $this-&gt;pag_page );
-                                        break;                                        
</del><ins>+
+                                case 'most-forum-posts':
+                                        $this-&gt;groups = groups_get_by_most_forum_posts( $this-&gt;pag_num, $this-&gt;pag_page );
+                                        break;                
</ins><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">                 
</span></span></pre></div>
<a id="trunkbpgroupsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-groups.php (1919 => 1920)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-groups.php        2009-09-22 17:55:13 UTC (rev 1919)
+++ trunk/bp-groups.php        2009-09-22 18:01:55 UTC (rev 1920)
</span><span class="lines">@@ -307,7 +307,30 @@
</span><span class="cx"> }
</span><span class="cx"> add_action( 'wp', 'groups_directory_groups_setup', 2 );
</span><span class="cx"> 
</span><ins>+function groups_setup_adminbar_menu() {
+        global $bp;
+        
+        if ( !$bp-&gt;groups-&gt;current_group )
+                return false;
</ins><span class="cx"> 
</span><ins>+        /* Don't show this menu to non site admins or if you're viewing your own profile */
+        if ( !is_site_admin() )
+                return false;
+        ?&gt;
+        &lt;li id=&quot;bp-adminbar-adminoptions-menu&quot;&gt;
+                &lt;a href=&quot;&quot;&gt;&lt;?php _e( 'Admin Options', 'buddypress' ) ?&gt;&lt;/a&gt;
+                
+                &lt;ul&gt;
+                        &lt;li&gt;&lt;a class=&quot;confirm&quot; href=&quot;&lt;?php echo wp_nonce_url( bp_get_group_permalink( $bp-&gt;groups-&gt;current_group ) . '/admin/delete-group/', 'groups_delete_group' ) ?&gt;&amp;amp;delete-group-button=1&amp;amp;delete-group-understand=1&quot;&gt;&lt;?php _e( &quot;Delete Group&quot;, 'buddypress' ) ?&gt;&lt;/a&gt;&lt;/li&gt;
+                        
+                        &lt;?php do_action( 'groups_adminbar_menu_items' ) ?&gt;
+                &lt;/ul&gt;
+        &lt;/li&gt;
+        &lt;?php
+}
+add_action( 'bp_adminbar_menus', 'groups_setup_adminbar_menu', 20 );
+
+
</ins><span class="cx"> /********************************************************************************
</span><span class="cx">  * Screen Functions
</span><span class="cx">  *
</span><span class="lines">@@ -1235,18 +1258,18 @@
</span><span class="cx">                 if ( !$bp-&gt;is_item_admin &amp;&amp; !is_site_admin() )
</span><span class="cx">                         return false;
</span><span class="cx">                 
</span><del>-                if ( isset( $_POST['delete-group-button'] ) &amp;&amp; isset( $_POST['delete-group-understand'] ) ) {
</del><ins>+                if ( isset( $_REQUEST['delete-group-button'] ) &amp;&amp; isset( $_REQUEST['delete-group-understand'] ) ) {
</ins><span class="cx">                         /* Check the nonce first. */
</span><span class="cx">                         if ( !check_admin_referer( 'groups_delete_group' ) )
</span><span class="cx">                                 return false;
</span><span class="cx">                 
</span><span class="cx">                         // Group admin has deleted the group, now do it.
</span><del>-                        if ( !groups_delete_group( $_POST['group-id'] ) ) {
</del><ins>+                        if ( !groups_delete_group( $bp-&gt;groups-&gt;current_group-&gt;id ) ) {
</ins><span class="cx">                                 bp_core_add_message( __( 'There was an error deleting the group, please try again.', 'buddypress' ), 'error' );
</span><span class="cx">                         } else {
</span><span class="cx">                                 bp_core_add_message( __( 'The group was deleted successfully', 'buddypress' ) );
</span><span class="cx"> 
</span><del>-                                do_action( 'groups_group_deleted', $_POST['group-id'] );
</del><ins>+                                do_action( 'groups_group_deleted', $bp-&gt;groups-&gt;current_group-&gt;id );
</ins><span class="cx"> 
</span><span class="cx">                                 bp_core_redirect( $bp-&gt;loggedin_user-&gt;domain . $bp-&gt;groups-&gt;slug . '/' );
</span><span class="cx">                         }
</span><span class="lines">@@ -1369,7 +1392,7 @@
</span><span class="cx">         global $bp, $wpdb;
</span><span class="cx">         
</span><span class="cx">         if ( $bp-&gt;current_component == $bp-&gt;groups-&gt;slug &amp;&amp; isset( $_GET['random-group'] ) ) {
</span><del>-                $group = groups_get_random_group();
</del><ins>+                $group = groups_get_random_groups( 1, 1 );
</ins><span class="cx"> 
</span><span class="cx">                 bp_core_redirect( $bp-&gt;root_domain . '/' . $bp-&gt;groups-&gt;slug . '/' . $group['groups'][0]-&gt;slug );
</span><span class="cx">         }
</span><span class="lines">@@ -1821,6 +1844,10 @@
</span><span class="cx"> 
</span><span class="cx"> /*** Group Fetching, Filtering &amp; Searching  *************************************/
</span><span class="cx"> 
</span><ins>+function groups_get_all( $limit = null, $page = 1, $only_public = false, $sort_by = false, $order = false ) {
+        return BP_Groups_Group::get_all( $limit, $page, $only_public, $sort_by, $order );
+}
+
</ins><span class="cx"> function groups_get_newest( $limit = null, $page = 1 ) {
</span><span class="cx">         return BP_Groups_Group::get_newest( $limit, $page );
</span><span class="cx"> }
</span><span class="lines">@@ -1833,12 +1860,12 @@
</span><span class="cx">         return BP_Groups_Group::get_popular( $limit, $page );
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-function groups_get_all( $limit = null, $page = 1, $only_public = false, $sort_by = false, $order = false ) {
-        return BP_Groups_Group::get_all( $limit, $page, $only_public, $sort_by, $order );
</del><ins>+function groups_get_random_groups( $limit = null, $page = 1 ) {
+        return BP_Groups_Group::get_random( $limit, $page );
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-function groups_get_random_group() {
-        return BP_Groups_Group::get_random();
</del><ins>+function groups_get_by_most_forum_posts( $limit = null, $page = 1 ) {
+        return BP_Groups_Group::get_by_most_forum_posts( $limit, $page );
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> function groups_get_user_groups( $user_id = false, $pag_num = false, $pag_page = false ) {
</span><span class="lines">@@ -1850,6 +1877,8 @@
</span><span class="cx">         return BP_Groups_Member::get_group_ids( $user_id, $pag_num, $pag_page );
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+/* TODO: These user group functions could be merged with the above with an optional user ID param */
+
</ins><span class="cx"> function groups_get_recently_joined_for_user( $user_id = false, $pag_num = false, $pag_page = false, $filter = false ) {
</span><span class="cx">         global $bp;
</span><span class="cx">         
</span></span></pre></div>
<a id="trunkbpthemesbpsnparentprofileeditphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-themes/bp-sn-parent/profile/edit.php (1919 => 1920)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-themes/bp-sn-parent/profile/edit.php        2009-09-22 17:55:13 UTC (rev 1919)
+++ trunk/bp-themes/bp-sn-parent/profile/edit.php        2009-09-22 18:01:55 UTC (rev 1920)
</span><span class="lines">@@ -24,7 +24,7 @@
</span><span class="cx">                         
</span><span class="cx">                                 &lt;?php while ( bp_profile_fields() ) : bp_the_profile_field(); ?&gt;
</span><span class="cx">                                 
</span><del>-                                        &lt;div class=&quot;editfield&quot;&gt;
</del><ins>+                                        &lt;div&lt;?php bp_field_css_class( 'editfield' ) ?&gt;&gt;
</ins><span class="cx">                                         
</span><span class="cx">                                                 &lt;?php if ( 'textbox' == bp_get_the_profile_field_type() ) : ?&gt;
</span><span class="cx">                                         
</span></span></pre></div>
<a id="trunkbpxprofilebpxprofiletemplatetagsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-xprofile/bp-xprofile-templatetags.php (1919 => 1920)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-xprofile/bp-xprofile-templatetags.php        2009-09-22 17:55:13 UTC (rev 1919)
+++ trunk/bp-xprofile/bp-xprofile-templatetags.php        2009-09-22 18:01:55 UTC (rev 1920)
</span><span class="lines">@@ -200,14 +200,17 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-function bp_field_css_class() {
-        echo bp_get_field_css_class();
</del><ins>+function bp_field_css_class( $class = false ) {
+        echo bp_get_field_css_class( $class );
</ins><span class="cx"> }
</span><del>-        function bp_get_field_css_class() {
</del><ins>+        function bp_get_field_css_class( $class = false ) {
</ins><span class="cx">                 global $profile_template;
</span><span class="cx">         
</span><span class="cx">                 $css_classes = array();
</span><span class="cx">                 
</span><ins>+                if ( $class )
+                        $css_classes[] = sanitize_title( attribute_escape( $class ) );
+                
</ins><span class="cx">                 /* Set a class with the field ID */
</span><span class="cx">                 $css_classes[] = 'field_' . $profile_template-&gt;field-&gt;id;
</span><span class="cx">                 
</span></span></pre>
</div>
</div>

</body>
</html>