145 | | |
| 145 | |
| 146 | function get_activity_for_group($group, $limit = 15 ) { |
| 147 | global $wpdb, $bp; |
| 148 | |
| 149 | if ( $limit ) |
| 150 | $limit_sql = $wpdb->prepare( " LIMIT %d", $limit ); |
| 151 | |
| 152 | $group_link = bp_group_permalink( $group, false); |
| 153 | |
| 154 | $activities = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM " . $bp->activity->table_name_sitewide . " WHERE component_name = %s AND primary_link = %s ORDER BY date_recorded DESC $limit_sql", BP_GROUPS_SLUG, $group_link ) ); |
| 155 | |
| 156 | for ( $i = 0; $i < count( $activities ); $i++ ) { |
| 157 | $activities_formatted[$i]['content'] = $activities[$i]->content; |
| 158 | $activities_formatted[$i]['primary_link'] = $activities[$i]->primary_link; |
| 159 | $activities_formatted[$i]['date_recorded'] = $activities[$i]->date_recorded; |
| 160 | $activities_formatted[$i]['component_name'] = $activities[$i]->component_name; |
| 161 | $activities_formatted[$i]['component_action'] = $activities[$i]->component_action; |
| 162 | } |
| 163 | |
| 164 | return $activities_formatted; |
| 165 | } |
| 166 | |