partial implement (Save)
This commit is contained in:
@@ -253,6 +253,33 @@ func (d *DB) RemoveACL(id int64) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// GetACLsForSubject retrieves all ACL entries for a specific subject (user or group).
|
||||
func (d *DB) GetACLsForSubject(subjectType string, subjectID int64) ([]ACLEntry, error) {
|
||||
rows, err := d.sql.Query(`
|
||||
SELECT id, path, subject_type, subject_id, can_search, can_view, can_read, can_edit, can_create, can_delete, can_move
|
||||
FROM acl WHERE subject_type = ? AND subject_id = ?
|
||||
ORDER BY path
|
||||
`, subjectType, subjectID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
var entries []ACLEntry
|
||||
for rows.Next() {
|
||||
var e ACLEntry
|
||||
if err := rows.Scan(
|
||||
&e.ID, &e.Path, &e.SubjectType, &e.SubjectID,
|
||||
&e.CanSearch, &e.CanView, &e.CanRead, &e.CanEdit,
|
||||
&e.CanCreate, &e.CanDelete, &e.CanMove,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
entries = append(entries, e)
|
||||
}
|
||||
return entries, rows.Err()
|
||||
}
|
||||
|
||||
// GetACLsForPath retrieves all ACL definitions for a specific document or folder.
|
||||
func (d *DB) GetACLsForPath(path string) ([]ACLEntry, error) {
|
||||
rows, err := d.sql.Query(`
|
||||
|
||||
Reference in New Issue
Block a user