Is their a way to get all public items? #1041

Closed
opened 2026-02-04 23:33:12 +03:00 by OVERLORD · 2 comments
Owner

Originally created by @Nebucatnetzer on GitHub (Feb 14, 2019).

I want to have everything private and some stuff public. In order to have an overview I'm looking for something which lists all the items which are publicly readable. Does this already exist?

Originally created by @Nebucatnetzer on GitHub (Feb 14, 2019). I want to have everything private and some stuff public. In order to have an overview I'm looking for something which lists all the items which are publicly readable. Does this already exist?
Author
Owner

@ssddanbrown commented on GitHub (Mar 1, 2019):

Hi @Nebucatnetzer,
There's no built-in views to see this.

I've put together the below SQL which you could use to generate such a report. You might have to change bookstack on the first line to be the name of your database.

use bookstack;
SELECT @publicId := id FROM roles where system_name = 'public';

SELECT 
    SUBSTR(jp.entity_type,
        LOCATE('\\', jp.entity_type) + 1) AS item_type,
    jp.entity_id as item_id,
    concat_ws('', b.name, c.name, p.name, s.name) as item_name,
    jp.action as permission
FROM
    joint_permissions jp
        LEFT JOIN
    books b ON (b.id = jp.entity_id
        AND jp.entity_type = 'BookStack\\Book')
        LEFT JOIN
    pages p ON (p.id = jp.entity_id
        AND jp.entity_type = 'BookStack\\Page')
        LEFT JOIN
    chapters c ON (c.id = jp.entity_id
        AND jp.entity_type = 'BookStack\\Chapter')
        LEFT JOIN
    bookshelves s ON (s.id = jp.entity_id
        AND jp.entity_type = 'BookStack\\BookShelf')
WHERE
    jp.role_id = @publicId
        AND (jp.has_permission = 1
        OR jp.has_permission_own = 1);

Output should look something like this:

# item_type item_id item_name permission
Bookshelf 3 Another shelf view
Chapter 151 New Chapter view
Chapter 151 New Chapter update
Chapter 151 New Chapter delete
Chapter 151 New Chapter page-create
Page 763 My page name view

Let me know if that gets you what you're after.

@ssddanbrown commented on GitHub (Mar 1, 2019): Hi @Nebucatnetzer, There's no built-in views to see this. I've put together the below SQL which you could use to generate such a report. You might have to change `bookstack` on the first line to be the name of your database. ```sql use bookstack; SELECT @publicId := id FROM roles where system_name = 'public'; SELECT SUBSTR(jp.entity_type, LOCATE('\\', jp.entity_type) + 1) AS item_type, jp.entity_id as item_id, concat_ws('', b.name, c.name, p.name, s.name) as item_name, jp.action as permission FROM joint_permissions jp LEFT JOIN books b ON (b.id = jp.entity_id AND jp.entity_type = 'BookStack\\Book') LEFT JOIN pages p ON (p.id = jp.entity_id AND jp.entity_type = 'BookStack\\Page') LEFT JOIN chapters c ON (c.id = jp.entity_id AND jp.entity_type = 'BookStack\\Chapter') LEFT JOIN bookshelves s ON (s.id = jp.entity_id AND jp.entity_type = 'BookStack\\BookShelf') WHERE jp.role_id = @publicId AND (jp.has_permission = 1 OR jp.has_permission_own = 1); ``` Output should look something like this: | # item_type | item_id | item_name | permission | |-------------|----------|---------------------------------|------------------| | Bookshelf | 3 | Another shelf | view | | Chapter | 151 | New Chapter | view | | Chapter | 151 | New Chapter | update | | Chapter | 151 | New Chapter | delete | | Chapter | 151 | New Chapter | page-create | | Page | 763 | My page name | view | Let me know if that gets you what you're after.
Author
Owner

@Nebucatnetzer commented on GitHub (Mar 2, 2019):

Yes that works for me thank you! Maybe that would be something to integrate into the admin settings for less tech savvy people? Anyway the SQL works for me :)

@Nebucatnetzer commented on GitHub (Mar 2, 2019): Yes that works for me thank you! Maybe that would be something to integrate into the admin settings for less tech savvy people? Anyway the SQL works for me :)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#1041