function bp_wire_posts_template($item_id, $component_slug, $can_post, $per_page, $max)
 {
     global $bp;
     if ($bp->current_component == $bp->wire->slug) {
         $this->table_name = $bp->profile->table_name_wire;
         // If the user is viewing their own wire, delete the notifications.
         if ('all-posts' == $bp->current_action && bp_is_home()) {
             bp_core_delete_notifications_for_user_by_type($bp->loggedin_user->id, 'xprofile', 'new_wire_post');
         }
     } else {
         $this->table_name = $bp->{$component_slug}->table_name_wire;
     }
     $this->pag_page = isset($_REQUEST['wpage']) ? intval($_REQUEST['wpage']) : 1;
     $this->pag_num = isset($_REQUEST['num']) ? intval($_REQUEST['num']) : $per_page;
     $this->wire_posts = BP_Wire_Post::get_all_for_item($item_id, $this->table_name, $this->pag_page, $this->pag_num);
     $this->total_wire_post_count = (int) $this->wire_posts['count'];
     $this->wire_posts = $this->wire_posts['wire_posts'];
     $this->wire_post_count = count($this->wire_posts);
     if ((int) get_site_option('non-friend-wire-posting') && ($bp->current_component == $bp->profile->slug || $bp->current_component == $bp->wire->slug)) {
         $this->can_post = 1;
     } else {
         $this->can_post = $can_post;
     }
     $this->pag_links = paginate_links(array('base' => add_query_arg('wpage', '%#%', $bp->displayed_user->domain), 'format' => '', 'total' => ceil($this->total_wire_post_count / $this->pag_num), 'current' => $this->pag_page, 'prev_text' => '«', 'next_text' => '»', 'mid_size' => 1));
 }
Ejemplo n.º 2
0
 function delete()
 {
     global $wpdb, $bp;
     // Delete groupmeta for the group
     groups_delete_groupmeta($this->id);
     // Modify group count usermeta for members
     for ($i = 0; $i < count($this->user_dataset); $i++) {
         $user = $this->user_dataset[$i];
         $total_count = get_usermeta($user->user_id, 'total_group_count');
         if ($total_count != '') {
             update_usermeta($user->user_id, 'total_group_count', (int) $total_count - 1);
         }
         // Now delete the group member record
         BP_Groups_Member::delete($user->user_id, $this->id, false);
     }
     // Delete the wire posts for this group if the wire is installed
     if (function_exists('bp_wire_install')) {
         BP_Wire_Post::delete_all_for_item($this->id, $bp->groups->table_name_wire);
     }
     // Finally remove the group entry from the DB
     if (!$wpdb->query($wpdb->prepare("DELETE FROM {$bp->groups->table_name} WHERE id = %d", $this->id))) {
         return false;
     }
     return true;
 }
Ejemplo n.º 3
0
function bp_wire_delete_post($wire_post_id, $component_name, $table_name = null)
{
    global $bp;
    if (!is_user_logged_in()) {
        return false;
    }
    if (!$table_name) {
        $table_name = $bp->{$component_name}->table_name_wire;
    }
    $wire_post = new BP_Wire_Post($table_name, $wire_post_id);
    if (!is_site_admin()) {
        if (!$bp->is_item_admin) {
            if ($wire_post->user_id != $bp->loggedin_user->id) {
                return false;
            }
        }
    }
    if (!$wire_post->delete()) {
        return false;
    }
    // Delete activity stream items
    bp_wire_delete_activity(array('user_id' => $wire_post->user_id, 'item_id' => $wire_post->id, 'component_name' => $component_name, 'component_action' => 'new_wire_post'));
    do_action('bp_wire_post_deleted', $wire_post->id, $wire_post->item_id, $wire_post->user_id);
    return true;
}