<!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' => $paged_groups, 'total' => $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 && $page ) {
+                        $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
+                }
+                        
+                $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT gm.group_id FROM {$bp->groups->table_name_groupmeta} gm, {$bp->groups->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}", $limit ) );
+                $total_groups = count( $wpdb->get_results( $wpdb->prepare( "SELECT gm.group_id FROM {$bp->groups->table_name_groupmeta} gm, {$bp->groups->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", $limit ) ) );
+
+                return array( 'groups' => $paged_groups, 'total' => $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' => $paged_groups, 'total' => $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->pag_page = isset( $_REQUEST['gpage'] ) ? intval( $_REQUEST['gpage'] ) : 1;
</span><span class="cx">                 $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
</span><del>-                                
</del><ins>+
</ins><span class="cx">                 if ( isset( $_REQUEST['s'] ) && '' != $_REQUEST['s'] && $type != 'random' ) {
</span><span class="cx">                         $this->groups = BP_Groups_Group::search_groups( $_REQUEST['s'], $this->pag_num, $this->pag_page );
</span><span class="cx">                 } else if ( isset( $_REQUEST['letter'] ) && '' != $_REQUEST['letter'] ) {
</span><span class="cx">                         $this->groups = BP_Groups_Group::get_by_letter( $_REQUEST['letter'], $this->pag_num, $this->pag_page );
</span><ins>+                
</ins><span class="cx">                 } else {
</span><span class="cx">                         switch ( $type ) {
</span><del>-                                case 'random':
-                                        $this->groups = BP_Groups_Group::get_random( $this->pag_num, $this->pag_page );
</del><ins>+                                case 'active': default:
+                                        $this->groups = groups_get_active( $this->pag_num, $this->pag_page );
+                                        break;        
+                                
+                                case 'random':                
+                                        $this->groups = groups_get_random_groups( $this->pag_num, $this->pag_page );
</ins><span class="cx">                                         break;
</span><span class="cx">                                 
</span><span class="cx">                                 case 'newest':
</span><del>-                                        $this->groups = BP_Groups_Group::get_newest( $this->pag_num, $this->pag_page );
</del><ins>+                                        $this->groups = groups_get_newest( $this->pag_num, $this->pag_page );
</ins><span class="cx">                                         break;
</span><span class="cx">
</span><span class="cx">                                 case 'popular':
</span><del>-                                        $this->groups = BP_Groups_Group::get_popular( $this->pag_num, $this->pag_page );
</del><ins>+                                        $this->groups = groups_get_popular( $this->pag_num, $this->pag_page );
</ins><span class="cx">                                         break;        
</span><del>-                                
-                                case 'active': default:
-                                        $this->groups = BP_Groups_Group::get_active( $this->pag_num, $this->pag_page );
-                                        break;                                        
</del><ins>+
+                                case 'most-forum-posts':
+                                        $this->groups = groups_get_by_most_forum_posts( $this->pag_num, $this->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->groups->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;
+        ?>
+        <li id="bp-adminbar-adminoptions-menu">
+                <a href=""><?php _e( 'Admin Options', 'buddypress' ) ?></a>
+                
+                <ul>
+                        <li><a class="confirm" href="<?php echo wp_nonce_url( bp_get_group_permalink( $bp->groups->current_group ) . '/admin/delete-group/', 'groups_delete_group' ) ?>&amp;delete-group-button=1&amp;delete-group-understand=1"><?php _e( "Delete Group", 'buddypress' ) ?></a></li>
+                        
+                        <?php do_action( 'groups_adminbar_menu_items' ) ?>
+                </ul>
+        </li>
+        <?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->is_item_admin && !is_site_admin() )
</span><span class="cx">                         return false;
</span><span class="cx">                 
</span><del>-                if ( isset( $_POST['delete-group-button'] ) && isset( $_POST['delete-group-understand'] ) ) {
</del><ins>+                if ( isset( $_REQUEST['delete-group-button'] ) && 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->groups->current_group->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->groups->current_group->id );
</ins><span class="cx">
</span><span class="cx">                                 bp_core_redirect( $bp->loggedin_user->domain . $bp->groups->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->current_component == $bp->groups->slug && 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->root_domain . '/' . $bp->groups->slug . '/' . $group['groups'][0]->slug );
</span><span class="cx">         }
</span><span class="lines">@@ -1821,6 +1844,10 @@
</span><span class="cx">
</span><span class="cx"> /*** Group Fetching, Filtering & 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">                                 <?php while ( bp_profile_fields() ) : bp_the_profile_field(); ?>
</span><span class="cx">                                 
</span><del>-                                        <div class="editfield">
</del><ins>+                                        <div<?php bp_field_css_class( 'editfield' ) ?>>
</ins><span class="cx">                                         
</span><span class="cx">                                                 <?php if ( 'textbox' == bp_get_the_profile_field_type() ) : ?>
</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->field->id;
</span><span class="cx">                 
</span></span></pre>
</div>
</div>
</body>
</html>