Example #1
0
 // Submit the poll
 if ($auth->acl_get('u_blog_create_poll')) {
     submit_blog_poll($poll, $blog_id, 'edit');
 }
 // Handle the subscriptions
 add_blog_subscriptions($blog_id, 'subscription_');
 // Insert into the categories list
 if (sizeof($category_ary) > 1 || isset($category_ary[0]) && $category_ary[0] != 0) {
     $category_list = get_blog_categories('category_id');
     foreach ($category_ary as $i => $cat_id) {
         if (!isset($category_list[$cat_id])) {
             unset($category_ary[$i]);
         }
     }
 }
 put_blogs_in_cats($blog_id, $category_ary, blog_data::$blog[$blog_id]['blog_approved'] == 1 || $auth->acl_get('u_blognoapprove') ? true : false);
 // If it needs reapproval...
 if (blog_data::$blog[$blog_id]['blog_approved'] == 0 && !$auth->acl_get('u_blognoapprove')) {
     $sql = 'UPDATE ' . USERS_TABLE . ' SET blog_count = blog_count - 1 WHERE user_id = ' . $user->data['user_id'];
     $db->sql_query($sql);
     set_config('num_blogs', --$config['num_blogs'], true);
     inform_approve_report('blog_approve', $blog_id);
 }
 handle_blog_cache('edit_blog', $user_id);
 $message = (!$sql_data['blog_approved'] ? $user->lang['BLOG_NEED_APPROVE'] . '<br /><br />' : $user->lang['BLOG_EDIT_SUCCESS']) . '<br /><br />';
 $message .= '<a href="' . $blog_urls['view_blog'] . '">' . $user->lang['VIEW_BLOG'] . '</a><br /><br />';
 if ($user->data['user_id'] == $user_id) {
     $message .= sprintf($user->lang['RETURN_BLOG_OWN'], '<a href="' . $blog_urls['view_user'] . '">', '</a>');
 } else {
     $message .= sprintf($user->lang['RETURN_BLOG_MAIN'], '<a href="' . $blog_urls['view_user'] . '">', blog_data::$user[$user_id]['username'], '</a>');
 }
/**
* Delete user
*
* This function deletes the needed stuff when a user is deleted
*/
function blog_delete_user($user_id)
{
    global $config, $db, $phpbb_root_path, $phpEx;
    $user_id = (int) $user_id;
    include "{$phpbb_root_path}blog/includes/constants.{$phpEx}";
    if (!function_exists('setup_blog_search')) {
        include "{$phpbb_root_path}blog/includes/functions.{$phpEx}";
    }
    if (!function_exists('put_blogs_in_cats')) {
        include "{$phpbb_root_path}blog/includes/functions_categories.{$phpEx}";
    }
    $blog_search = setup_blog_search();
    $num_blogs = $num_blog_replies = 0;
    $result = $db->sql_query('SELECT * FROM ' . BLOGS_TABLE . ' WHERE user_id = ' . $user_id);
    while ($row = $db->sql_fetchrow($result)) {
        $num_blogs++;
        $num_blog_replies += $row['blog_real_reply_count'];
        $blog_search->index_remove($row['blog_id']);
        put_blogs_in_cats($row['blog_id'], array(), true, 'soft_delete');
        // Delete the Attachments
        $rids = array();
        $sql = 'SELECT reply_id FROM ' . BLOGS_REPLY_TABLE . ' WHERE blog_id = ' . $row['blog_id'];
        $result1 = $db->sql_query($sql);
        while ($row1 = $db->sql_fetchrow($result1)) {
            $rids[] = $row1['reply_id'];
        }
        $db->sql_freeresult($result1);
        if (sizeof($rids)) {
            $sql = 'SELECT physical_filename FROM ' . BLOGS_ATTACHMENT_TABLE . ' WHERE blog_id = ' . $row['blog_id'] . ' OR ' . $db->sql_in_set('reply_id', $rids);
        } else {
            $sql = 'SELECT physical_filename FROM ' . BLOGS_ATTACHMENT_TABLE . ' WHERE blog_id = ' . $row['blog_id'];
        }
        $result1 = $db->sql_query($sql);
        while ($row1 = $db->sql_fetchrow($result1)) {
            @unlink($phpbb_root_path . $config['upload_path'] . '/blog_mod/' . $row1['physical_filename']);
        }
        $db->sql_freeresult($result1);
        if (sizeof($rids)) {
            $db->sql_query('DELETE FROM ' . BLOGS_ATTACHMENT_TABLE . ' WHERE blog_id = ' . $row['blog_id'] . ' OR ' . $db->sql_in_set('reply_id', $rids));
        } else {
            $db->sql_query('DELETE FROM ' . BLOGS_ATTACHMENT_TABLE . ' WHERE blog_id = ' . $row['blog_id']);
        }
        // delete the blog
        $db->sql_query('DELETE FROM ' . BLOGS_TABLE . ' WHERE blog_id = ' . $row['blog_id']);
        // delete the replies
        $db->sql_query('DELETE FROM ' . BLOGS_REPLY_TABLE . ' WHERE blog_id = ' . $row['blog_id']);
        // delete from the blogs_in_categories
        $db->sql_query('DELETE FROM ' . BLOGS_IN_CATEGORIES_TABLE . ' WHERE blog_id = ' . $row['blog_id']);
        // delete from the blogs_ratings
        $db->sql_query('DELETE FROM ' . BLOGS_RATINGS_TABLE . ' WHERE blog_id = ' . $row['blog_id']);
        // Delete the subscriptions
        $db->sql_query('DELETE FROM ' . BLOGS_SUBSCRIPTION_TABLE . ' WHERE blog_id = ' . $row['blog_id']);
        // Delete the Polls
        $db->sql_query('DELETE FROM ' . BLOGS_POLL_OPTIONS_TABLE . ' WHERE blog_id = ' . $row['blog_id']);
        $db->sql_query('DELETE FROM ' . BLOGS_POLL_VOTES_TABLE . ' WHERE blog_id = ' . $row['blog_id']);
    }
    $db->sql_freeresult($result);
    $result = $db->sql_query('SELECT * FROM ' . BLOGS_REPLY_TABLE . ' WHERE user_id = ' . $user_id);
    while ($row = $db->sql_fetchrow($result)) {
        $num_blog_replies++;
        $blog_search->index_remove(false, $row['reply_id']);
        // Delete the Attachments
        $sql = 'SELECT physical_filename FROM ' . BLOGS_ATTACHMENT_TABLE . ' WHERE reply_id = ' . $row['reply_id'];
        $result1 = $db->sql_query($sql);
        while ($row1 = $db->sql_fetchrow($result1)) {
            @unlink($phpbb_root_path . $config['upload_path'] . '/blog_mod/' . $row1['physical_filename']);
        }
        $db->sql_freeresult($result1);
        $db->sql_query('DELETE FROM ' . BLOGS_ATTACHMENT_TABLE . ' WHERE reply_id = ' . $row['reply_id']);
        // delete the reply
        $db->sql_query('DELETE FROM ' . BLOGS_REPLY_TABLE . ' WHERE reply_id = ' . $row['reply_id']);
    }
    $db->sql_freeresult($result);
    $sql = 'UPDATE ' . USERS_TABLE . ' SET blog_count = 0
		WHERE user_id = ' . $user_id;
    $db->sql_query($sql);
    // Resync reply counts
    resync_blog('reply_count');
    resync_blog('real_reply_count');
    set_config('num_blogs', $config['num_blogs'] - $num_blogs, true);
    set_config('num_blog_replies', $config['num_blog_replies'] - $num_blog_replies, true);
}
Example #3
0
        $sql = 'UPDATE ' . BLOGS_TABLE . '
			SET blog_approved = 1
			WHERE blog_id = ' . intval($blog_id);
        $db->sql_query($sql);
        // Update the blog_count for the user
        $sql = 'UPDATE ' . USERS_TABLE . ' SET blog_count = blog_count + 1 WHERE user_id = ' . intval($user_id);
        $db->sql_query($sql);
        set_config('num_blogs', ++$config['num_blogs'], true);
        // Update the blog_count for all the categories it is in.
        $category_ids = array();
        $sql = 'SELECT category_id FROM ' . BLOGS_IN_CATEGORIES_TABLE . ' WHERE blog_id = ' . intval($blog_id);
        $result = $db->sql_query($sql);
        while ($row = $db->sql_fetchrow($result)) {
            $category_ids[] = $row['category_id'];
        }
        put_blogs_in_cats($blog_id, $category_ids, true, 'approve');
        handle_blog_cache('approve_blog', $user_id);
        handle_subscription('new_blog', censor_text(blog_data::$blog[$blog_id]['blog_subject']));
        blog_meta_refresh(3, $blog_urls['view_blog']);
        $message = $user->lang['APPROVE_BLOG_SUCCESS'];
        $message .= '<br /><br /><a href="' . $blog_urls['view_blog'] . '">' . $user->lang['VIEW_BLOG'] . '</a><br />';
        if ($user_id == $user->data['user_id']) {
            $message .= sprintf($user->lang['RETURN_BLOG_OWN'], '<a href="' . $blog_urls['view_user'] . '">', '</a>');
        } else {
            $message .= sprintf($user->lang['RETURN_BLOG_MAIN'], '<a href="' . $blog_urls['view_user'] . '">', blog_data::$user[$user_id]['username'], '</a>') . '<br />';
            $message .= sprintf($user->lang['RETURN_BLOG_OWN'], '<a href="' . $blog_urls['view_user_self'] . '">', '</a>');
        }
        trigger_error($message);
    } else {
        confirm_box(false, 'APPROVE_BLOG');
    }
Example #4
0
     // delete the blog
     $db->sql_query('DELETE FROM ' . BLOGS_TABLE . ' WHERE blog_id = ' . intval($blog_id));
     // delete the replies
     $db->sql_query('DELETE FROM ' . BLOGS_REPLY_TABLE . ' WHERE blog_id = ' . intval($blog_id));
     // delete from the blogs_in_categories
     $db->sql_query('DELETE FROM ' . BLOGS_IN_CATEGORIES_TABLE . ' WHERE blog_id = ' . intval($blog_id));
     // delete from the blogs_ratings
     $db->sql_query('DELETE FROM ' . BLOGS_RATINGS_TABLE . ' WHERE blog_id = ' . intval($blog_id));
     // Delete the subscriptions
     $db->sql_query('DELETE FROM ' . BLOGS_SUBSCRIPTION_TABLE . ' WHERE blog_id = ' . intval($blog_id));
     // Delete the Polls
     $db->sql_query('DELETE FROM ' . BLOGS_POLL_OPTIONS_TABLE . ' WHERE blog_id = ' . intval($blog_id));
     $db->sql_query('DELETE FROM ' . BLOGS_POLL_VOTES_TABLE . ' WHERE blog_id = ' . intval($blog_id));
 } else {
     // Update the blog_count for all the categories it is in.
     put_blogs_in_cats($blog_id, array(), true, 'soft_delete');
     // Remove the search index
     $blog_search->index_remove($blog_id);
     // soft delete the blog
     $sql = 'UPDATE ' . BLOGS_TABLE . ' SET blog_deleted = ' . $user->data['user_id'] . ', blog_deleted_time = ' . time() . ' WHERE blog_id = ' . intval($blog_id);
     $db->sql_query($sql);
     // Update the blog_count for the user
     $sql = 'UPDATE ' . USERS_TABLE . ' SET blog_count = blog_count - 1 WHERE user_id = ' . intval($user_id) . ' AND blog_count > 0';
     $db->sql_query($sql);
     set_config('num_blogs', --$config['num_blogs'], true);
     set_config('num_blog_replies', $config['num_blog_replies'] - blog_data::$blog[$blog_id]['blog_real_reply_count'], true);
     // Update the blog_count for all the categories it is in.
     $sql = 'SELECT category_id FROM ' . BLOGS_IN_CATEGORIES_TABLE . ' WHERE blog_id = ' . intval($blog_id);
     $result = $db->sql_query($sql);
     while ($row = $db->sql_fetchrow($result)) {
         $sql = 'UPDATE ' . BLOGS_CATEGORIES_TABLE . ' SET blog_count = blog_count - 1 WHERE category_id = ' . $row['category_id'] . ' AND blog_count > 0';
Example #5
0
    // undelete the blog
    $sql = 'UPDATE ' . BLOGS_TABLE . ' SET blog_deleted = 0, blog_deleted_time = 0 WHERE blog_id = ' . intval($blog_id);
    $db->sql_query($sql);
    // Update the blog_count for the user
    $sql = 'UPDATE ' . USERS_TABLE . ' SET blog_count = blog_count + 1 WHERE user_id = ' . intval($user_id);
    $db->sql_query($sql);
    set_config('num_blogs', ++$config['num_blogs'], true);
    set_config('num_blog_replies', $config['num_blog_replies'] + blog_data::$blog[$blog_id]['blog_real_reply_count'], true);
    // Update the blog_count for all the categories it is in.
    $category_ids = array();
    $sql = 'SELECT category_id FROM ' . BLOGS_IN_CATEGORIES_TABLE . ' WHERE blog_id = ' . intval($blog_id);
    $result = $db->sql_query($sql);
    while ($row = $db->sql_fetchrow($result)) {
        $category_ids[] = $row['category_id'];
    }
    put_blogs_in_cats($blog_id, $category_ids, true, 'undelete');
    handle_blog_cache('undelete_blog', $user_id);
    blog_meta_refresh(3, $blog_urls['view_blog']);
    $message = $user->lang['BLOG_UNDELETED'] . '<br /><br />';
    $message .= '<a href="' . $blog_urls['view_blog'] . '">' . $user->lang['VIEW_BLOG'] . '</a><br />';
    if ($user_id == $user->data['user_id']) {
        $message .= sprintf($user->lang['RETURN_BLOG_OWN'], '<a href="' . $blog_urls['view_user'] . '">', '</a>');
    } else {
        $message .= sprintf($user->lang['RETURN_BLOG_MAIN'], '<a href="' . $blog_urls['view_user'] . '">', blog_data::$user[$user_id]['username'], '</a>') . '<br />';
        $message .= sprintf($user->lang['RETURN_BLOG_OWN'], '<a href="' . $blog_urls['view_user_self'] . '">', '</a>');
    }
    trigger_error($message);
} else {
    confirm_box(false, 'UNDELETE_BLOG');
}
blog_meta_refresh(0, $blog_urls['view_blog']);
Example #6
0
 $blog_attachment->update_attachment_data($blog_id);
 // Submit the poll
 if ($auth->acl_get('u_blog_create_poll')) {
     submit_blog_poll($poll, $blog_id);
 }
 // Handle the subscriptions
 add_blog_subscriptions($blog_id, 'subscription_');
 // Insert into the categories list
 if (sizeof($category_ary) > 1 || isset($category_ary[0]) && $category_ary[0] != 0) {
     $category_list = get_blog_categories('category_id');
     foreach ($category_ary as $i => $cat_id) {
         if (!isset($category_list[$cat_id])) {
             unset($category_ary[$i]);
         }
     }
     put_blogs_in_cats($blog_id, $category_ary, $auth->acl_get('u_blognoapprove') ? true : false);
 }
 // regenerate the urls to include the blog_id
 generate_blog_urls();
 blog_plugins::plugin_do_arg('blog_add_after_sql', $blog_id);
 handle_blog_cache('new_blog', $user->data['user_id']);
 if ($sql_data['blog_approved']) {
     // Update the blog_count for the user
     $sql = 'UPDATE ' . USERS_TABLE . ' SET blog_count = blog_count + 1 WHERE user_id = ' . $user->data['user_id'];
     $db->sql_query($sql);
     set_config('num_blogs', ++$config['num_blogs'], true);
     handle_subscription('new_blog', censor_text($blog_subject), $user->data['user_id'], $blog_id);
 } else {
     inform_approve_report('blog_approve', $blog_id);
 }
 $message = !$sql_data['blog_approved'] ? $user->lang['BLOG_NEED_APPROVE'] : $user->lang['BLOG_SUBMIT_SUCCESS'];