first working version

This commit is contained in:
ston1th 2018-09-14 00:14:49 +02:00
commit 85f93bae69
32 changed files with 863 additions and 571 deletions

View file

@ -21,6 +21,18 @@ func ParsePerm(p int) Permission {
return Invalid
}
func ParsePermString(p string) Permission {
switch p {
case "1":
return Public
case "2":
return Internal
case "3":
return Private
}
return Invalid
}
func ReadPerm(username string, p *Page) bool {
switch p.Perm {
case Public:
@ -33,7 +45,14 @@ func ReadPerm(username string, p *Page) bool {
return false
}
func WritePerm(username string, p *Page) bool {
func WritePerm(username, section string, p *Page) bool {
if section != WikiSection && section != username {
return false
}
return writePerm(username, p)
}
func writePerm(username string, p *Page) bool {
switch p.Perm {
case Public, Internal:
if p.Owner == "" {