Habari\Comment::remove_type PHP Method

remove_type() public static method

Remove a comment type from the database
public static remove_type ( integer | string $type, boolean $delete = false )
$type integer | string The type of the comment
$delete boolean If true, delete the type and all comments of that type instead of deactivating it
    public static function remove_type($type, $delete = false)
    {
        if ($delete) {
            // Delete comments of this type, delete type
            $type_id = Comment::type($type);
            DB::delete(DB::table('comments'), array('type' => $type_id));
            DB::exec('DELETE FROM {commentinfo} WHERE comment_id IN (SELECT {commentinfo}.comment_id FROM {commentinfo} LEFT JOIN {comments} ON {commentinfo}.comment_id = {comments}.id WHERE {comments}.id IS NULL)');
            DB::delete(DB::table('commenttype'), array('name' => Comment::type_name($type)));
        } else {
            DB::update(DB::table('commenttype'), array('name' => Comment::type_name($type), 'active' => 0), array('name'));
        }
    }