Ejemplo n.º 1
0
function bb_delete_user($user_id, $reassign = 0)
{
    global $wp_users_object, $bbdb;
    if (!($user = bb_get_user($user_id))) {
        return false;
    }
    if ($reassign) {
        if (!($new_user = bb_get_user($reassign))) {
            return false;
        }
        $bbdb->update($bbdb->posts, array('poster_id' => $new_user->ID), array('poster_id' => $user->ID));
        $bbdb->update($bbdb->term_relationships, array('user_id' => $new_user->ID), array('user_id' => $user->ID));
        $bbdb->update($bbdb->topics, array('topic_poster' => $new_user->ID, 'topic_poster_name' => $new_user->user_login), array('topic_poster' => $user->ID));
        $bbdb->update($bbdb->topics, array('topic_last_poster' => $new_user->ID, 'topic_last_poster_name' => $new_user->user_login), array('topic_last_poster' => $user->ID));
        bb_update_topics_replied($new_user->ID);
        wp_cache_flush('bb_post');
        wp_cache_flush('bb_thread');
        wp_cache_flush('bb_topic_tag');
        wp_cache_flush('bb_topic');
    }
    do_action('bb_delete_user', $user->ID, $reassign);
    $wp_users_object->delete_user($user->ID);
    return true;
}
Ejemplo n.º 2
0
         foreach ((array) $forums as $forum) {
             $bbdb->query("UPDATE {$bbdb->forums} SET topics = '{$forum->topic_count}', posts = '{$forum->post_count}' WHERE forum_id = '{$forum->forum_id}'");
             unset($all_forums[$forum->forum_id]);
         }
         if ($all_forums) {
             $all_forums = implode(',', array_flip($all_forums));
             $bbdb->query("UPDATE {$bbdb->forums} SET topics = 0, posts = 0 WHERE forum_id IN ({$all_forums})");
         }
         unset($all_forums, $forums, $forum);
     }
 }
 if (isset($_POST['topics-replied']) && 1 == $_POST['topics-replied']) {
     if ($users = (array) $bbdb->get_col("SELECT ID FROM {$bbdb->users}")) {
         $messages[] = __('Counted topics to which each user has replied');
         foreach ($users as $user) {
             bb_update_topics_replied($user);
         }
         unset($users, $user);
     }
 }
 if (isset($_POST['topic-tag-count']) && 1 == $_POST['topic-tag-count']) {
     // Reset tag count to zero
     $bbdb->query("UPDATE {$bbdb->topics} SET tag_count = 0");
     // Get all tags
     $terms = $wp_taxonomy_object->get_terms('bb_topic_tag');
     if (!is_wp_error($terms) && is_array($terms)) {
         $messages[] = __('Counted topic tags');
         foreach ($terms as $term) {
             $topic_ids = bb_get_tagged_topic_ids($term->term_id);
             if (!is_wp_error($topic_ids) && is_array($topic_ids)) {
                 $bbdb->query("UPDATE {$bbdb->topics} SET tag_count = tag_count + 1 WHERE topic_id IN (" . join(',', $topic_ids) . ")");