Ticket #5397: 5397.diff
| File 5397.diff, 12.4 KB (added by , 12 years ago) |
|---|
-
bp-activity/bp-activity-classes.php
1201 1201 1202 1202 return $wpdb->get_var( $wpdb->prepare( "UPDATE {$bp->activity->table_name} SET hide_sitewide = 1 WHERE user_id = %d", $user_id ) ); 1203 1203 } 1204 1205 /** 1206 * Get activities count detailled by types 1207 * 1208 * @param int $user_id The ID of the user. 1209 * @return array the stats 1210 */ 1211 public static function get_count_by_type( $user_id = '' ) { 1212 global $wpdb; 1213 1214 $activity_stats = array(); 1215 $total_activity = 0; 1216 1217 if ( empty( $user_id ) ) 1218 return $activity_stats; 1219 1220 $activity_table = buddypress()->activity->table_name; 1221 1222 $activity_stats = $wpdb->get_results( $wpdb->prepare( "SELECT type, COUNT(*) as sub_total FROM {$activity_table} WHERE user_id = %d AND type != 'last_activity' GROUP BY type ORDER BY type ASC", $user_id ), OBJECT_K ); 1223 1224 foreach ( $activity_stats as $activity_type ) { 1225 $total_activity += absint( $activity_type->sub_total ); 1226 } 1227 1228 return array( 'types' => $activity_stats, 'total' => $total_activity ); 1229 } 1204 1230 } 1205 1231 1206 1232 /** -
bp-activity/bp-activity-functions.php
1812 1812 function bp_embed_activity_save_cache( $cache, $cachekey, $id ) { 1813 1813 bp_activity_update_meta( $id, $cachekey, $cache ); 1814 1814 } 1815 1816 /** 1817 * Builds Activity stats by types 1818 * 1819 * If no types are set, defaults to total activities 1820 * 1821 * @since BuddyPress (?) 1822 * 1823 * @param integer $user_id 1824 * @param boolean $hide_empty should we display empty types ? 1825 * @param array $types list of available types 1826 * @return array activity stats 1827 */ 1828 function bp_activity_get_count_by_type( $user_id = 0, $hide_empty = false, $types = array() ) { 1829 $activity_stats = BP_Activity_Activity::get_count_by_type( $user_id ); 1830 1831 // no activity returns 0 1832 if ( empty( $activity_stats ) ) 1833 return array( 'total' => 0 ); 1834 1835 // no types retuns total of activities 1836 if ( empty( $types ) ) { 1837 unset( $activity_stats['types'] ); 1838 return $activity_stats; 1839 } 1840 1841 $types_stats_ordered = array(); 1842 1843 // fill the array with 0 value for each type 1844 if( empty( $hide_empty ) ) 1845 $types_stats_ordered = array_fill_keys( array_keys( $types ), 0 ); 1846 1847 // fill the type the user added activities in 1848 foreach( $types as $key => $type ) { 1849 if( ! empty( $activity_stats['types'][ $key ] ) ) { 1850 $types_stats_ordered[ $key ] = $activity_stats['types'][ $key ]->sub_total; 1851 } 1852 } 1853 1854 // Most used type first 1855 arsort( $types_stats_ordered ); 1856 1857 // keep only types the user added activities in 1858 if( ! empty( $hide_empty ) ) 1859 $types = array_intersect_key( $types, $types_stats_ordered ); 1860 1861 // We need to merge "human" description for types 1862 $activity_stats['types'] = array_merge_recursive( $types_stats_ordered, $types ); 1863 1864 return $activity_stats; 1865 } -
bp-activity/bp-activity-template.php
3265 3265 <?php 3266 3266 } 3267 3267 add_action( 'bp_head', 'bp_activity_sitewide_feed' ); 3268 3269 3270 /** Stats **********************************************************************/ 3271 3272 /** 3273 * Display the number of activities by type in user's profile. 3274 * 3275 * @since BuddyPress (?) 3276 * 3277 * @param array $args before|after|user_id 3278 * @uses bp_activity_get_profile_stats() to get the stats 3279 */ 3280 function bp_activity_profile_stats( $args = '' ) { 3281 echo bp_activity_get_profile_stats( $args ); 3282 } 3283 add_action( 'bp_members_admin_user_stats', 'bp_activity_profile_stats', 10, 1 ); 3284 3285 /** 3286 * Return the number of activities by type in user's profile. 3287 * 3288 * @since BuddyPress (?) 3289 * 3290 * @param array $args before|after|user_id|types|hide_empty 3291 * @return string HTML for stats output. 3292 */ 3293 function bp_activity_get_profile_stats( $args = '' ) { 3294 3295 // Parse the args 3296 $r = bp_parse_args( $args, array( 3297 'before' => '<li class="bp-activity-profile-stats">', 3298 'after' => '</li>', 3299 'user_id' => bp_displayed_user_id(), 3300 'types' => bp_activity_get_types(), 3301 'hide_empty' => true, 3302 'output' => '' 3303 ), 'activity_get_profile_stats' ); 3304 3305 // Allow completely overloaded output 3306 if ( empty( $r['output'] ) ) { 3307 3308 // Only proceed if a user ID was passed 3309 if ( ! empty( $r['user_id'] ) ) { 3310 3311 // Get the user activities count by type 3312 $activity_stats = bp_activity_get_count_by_type( $r['user_id'], $r['hide_empty'], $r['types'] ); 3313 $total_activities = absint( $activity_stats['total'] ); 3314 3315 $r['output'] = $r['before'] . sprintf( _n( '%s activity', '%s activities', $total_activities, 'buddypress' ), '<strong>'. $total_activities .'</strong>' ); 3316 3317 // If types exist, show some detailed output 3318 if ( ! empty( $activity_stats['types'] ) ) { 3319 $r['output'] .= '<ol>'; 3320 3321 foreach ( $activity_stats['types'] as $type ) { 3322 $r['output'] .= '<li>' . esc_html( $type[1] ) . ': ' . absint( $type[0] ) .'</li>'; 3323 } 3324 3325 $r['output'] .= '</ol>'; 3326 } 3327 3328 $r['output'] .= $r['after']; 3329 } 3330 } 3331 3332 // Filter and return 3333 return apply_filters( 'bp_activity_get_profile_stats', $r['output'], $r ); 3334 } -
bp-members/admin/css/admin.css
60 60 div#community-profile-page li.bp-friends-profile-stats:before, 61 61 div#community-profile-page li.bp-groups-profile-stats:before, 62 62 div#community-profile-page li.bp-blogs-profile-stats:before, 63 div#community-profile-page li.bp-activity-profile-stats:before, 63 64 div#community-profile-page a.bp-xprofile-avatar-user-admin:before { 64 65 font-family: 'dashicons'; 65 66 font-size: 18px; … … 83 84 content: "\f120"; 84 85 } 85 86 87 div#community-profile-page li.bp-activity-profile-stats:before { 88 content:"\f452"; 89 } 90 91 div#community-profile-page li.bp-activity-profile-stats ol li { 92 font-size:80%; 93 margin-bottom:0; 94 } 95 86 96 div#community-profile-page a.bp-xprofile-avatar-user-admin:before { 87 97 content:"\f182"; 88 98 } -
bp-members/admin/css/admin.min.css
1 div#profile-page.wrap form#your-profile{position:relative}div#profile-page.wrap form#your-profile h3:first-of-type{margin-top:6em}div#profile-page.wrap form#your-profile ul#profile-nav{position:absolute;top:-6em;border-bottom:solid 1px #ccc;width:100%}div#community-profile-page h2:first-of-type{margin-bottom:1em}div#community-profile-page h2.profile-section{border-bottom:dotted 1px #ccc}div#community-profile-page ul#profile-nav{border-bottom:solid 1px #ccc;width:100%;margin-top:1em;margin-bottom:1em;padding:1em 0;padding-bottom:0;height:2.4em}div#community-profile-page ul#profile-nav li,form#your-profile ul#profile-nav li{margin-left:.4em;float:left;font-weight:700;font-size:15px;line-height:24px}div#community-profile-page ul#profile-nav li a,form#your-profile ul#profile-nav li a{text-decoration:none;color:#888}div#community-profile-page ul#profile-nav li a:hover,div#community-profile-page ul#profile-nav li.nav-tab-active a,form#your-profile ul#profile-nav li a:hover,form#your-profile ul#profile-nav li.nav-tab-active a{text-decoration:none;color:#000}div#community-profile-page a.bp-xprofile-avatar-user-admin:before,div#community-profile-page li.bp- blogs-profile-stats:before,div#community-profile-page li.bp-friends-profile-stats:before,div#community-profile-page li.bp-groups-profile-stats:before,div#community-profile-page li.bp-members-profile-stats:before{font-family:dashicons;font-size:18px;vertical-align:bottom;margin-right:5px}div#community-profile-page li.bp-members-profile-stats:before{content:"\f130"}div#community-profile-page li.bp-friends-profile-stats:before{content:"\f454"}div#community-profile-page li.bp-groups-profile-stats:before{content:"\f456"}div#community-profile-page li.bp-blogs-profile-stats:before{content:"\f120"}div#community-profile-page a.bp-xprofile-avatar-user-admin:before{content:"\f182"}div#community-profile-page div#bp_xprofile_user_admin_avatar div.avatar{width:150px;margin:0 auto}div#community-profile-page div#bp_xprofile_user_admin_avatar a{display:block;margin:1em 0;text-decoration:none;color:#888}div#community-profile-page p.not-activated{margin:1em 1em 0;color:red}div#community-profile-page .form-table td.admin-field-visibility-td{padding:5px 5px 15px}div#community-profile-page .form-table tr.admin-field-visibility-tr{border-bottom:dotted 1px #ccc}div#community-profile-page .form-table tr.admin-field-visibility-tr:last-child{border:0}div#community-profile-page .field-visibility-settings legend,div#community-profile-page .field-visibility-settings-notoggle{font-size:14px;font-style:italic;color:#666}div#community-profile-page .field-visibility-settings ul{margin:0;font-size:13px}div#community-profile-page .field-visibility-settings ul li{display:inline-block;margin-right:1em}div#community-profile-page .form-table td.admin-field-checkbox label,div#community-profile-page .form-table td.admin-field-radio label{display:block}2 No newline at end of file 1 div#profile-page.wrap form#your-profile{position:relative}div#profile-page.wrap form#your-profile h3:first-of-type{margin-top:6em}div#profile-page.wrap form#your-profile ul#profile-nav{position:absolute;top:-6em;border-bottom:solid 1px #ccc;width:100%}div#community-profile-page h2:first-of-type{margin-bottom:1em}div#community-profile-page h2.profile-section{border-bottom:dotted 1px #ccc}div#community-profile-page ul#profile-nav{border-bottom:solid 1px #ccc;width:100%;margin-top:1em;margin-bottom:1em;padding:1em 0;padding-bottom:0;height:2.4em}div#community-profile-page ul#profile-nav li,form#your-profile ul#profile-nav li{margin-left:.4em;float:left;font-weight:700;font-size:15px;line-height:24px}div#community-profile-page ul#profile-nav li a,form#your-profile ul#profile-nav li a{text-decoration:none;color:#888}div#community-profile-page ul#profile-nav li a:hover,div#community-profile-page ul#profile-nav li.nav-tab-active a,form#your-profile ul#profile-nav li a:hover,form#your-profile ul#profile-nav li.nav-tab-active a{text-decoration:none;color:#000}div#community-profile-page a.bp-xprofile-avatar-user-admin:before,div#community-profile-page li.bp-activity-profile-stats:before,div#community-profile-page li.bp-blogs-profile-stats:before,div#community-profile-page li.bp-friends-profile-stats:before,div#community-profile-page li.bp-groups-profile-stats:before,div#community-profile-page li.bp-members-profile-stats:before{font-family:dashicons;font-size:18px;vertical-align:bottom;margin-right:5px}div#community-profile-page li.bp-members-profile-stats:before{content:"\f130"}div#community-profile-page li.bp-friends-profile-stats:before{content:"\f454"}div#community-profile-page li.bp-groups-profile-stats:before{content:"\f456"}div#community-profile-page li.bp-blogs-profile-stats:before{content:"\f120"}div#community-profile-page li.bp-activity-profile-stats:before{content:"\f452"}div#community-profile-page li.bp-activity-profile-stats ol li{font-size:80%;margin-bottom:0}div#community-profile-page a.bp-xprofile-avatar-user-admin:before{content:"\f182"}div#community-profile-page div#bp_xprofile_user_admin_avatar div.avatar{width:150px;margin:0 auto}div#community-profile-page div#bp_xprofile_user_admin_avatar a{display:block;margin:1em 0;text-decoration:none;color:#888}div#community-profile-page p.not-activated{margin:1em 1em 0;color:red}div#community-profile-page .form-table td.admin-field-visibility-td{padding:5px 5px 15px}div#community-profile-page .form-table tr.admin-field-visibility-tr{border-bottom:dotted 1px #ccc}div#community-profile-page .form-table tr.admin-field-visibility-tr:last-child{border:0}div#community-profile-page .field-visibility-settings legend,div#community-profile-page .field-visibility-settings-notoggle{font-size:14px;font-style:italic;color:#666}div#community-profile-page .field-visibility-settings ul{margin:0;font-size:13px}div#community-profile-page .field-visibility-settings ul li{display:inline-block;margin-right:1em}div#community-profile-page .form-table td.admin-field-checkbox label,div#community-profile-page .form-table td.admin-field-radio label{display:block} 2 No newline at end of file