nieuws: authorise admins by edit subpermissions v4.1
authorMischa POSLAWSKY <perl@shiar.org>
Thu, 31 Oct 2019 18:26:45 +0000 (19:26 +0100)
committerMischa POSLAWSKY <perl@shiar.org>
Sat, 9 Nov 2019 06:08:13 +0000 (07:08 +0100)
Treat news maintenance like any other edit location.

edit/nieuws/tag/index.php
nieuws/index.php

index c65b81ebd810cf54d70093d7c57029d8bb888bd4..9bfb5156b7e1208106bad6c8817c813263b40082 100644 (file)
@@ -1,13 +1,13 @@
 <?php
-if (!$User or !$User->admin('news'))
-       abort("geen beheersrechten", '401 unauthorised');
-
 if (!$_POST)
        abort("niets te doen", '405 post error');
 if (!$Args)
        abort("pagina niet opgegeven", '409 input error');
 
 $pagename = ltrim($Args, '/').'.html';
+if (!$User or !$User->admin("edit $pagename"))
+       abort("geen beheersrechten", '401 unauthorised');
+
 @list ($category, $year, $article) = explode('/', $pagename);
 if (empty($article) or !file_exists($pagename))
        abort("artikel onbekend: $pagename", '404 page error');
index 53dff0de76e24400c906372abc61bd8ce0f4f55c..c6234cfae29d6c98e97a14e6b0166e18e8b42fae 100644 (file)
@@ -2,12 +2,12 @@
 $replyform = $Page == 'melding' && !empty($User);
 @list ($year, $page) = explode('/', trim($Args, '/'));
 
-if ($User and $User->admin('news')) {
+if ($User and $User->admin("edit $Page")) {
        print '<script src="/nieuws/edit.js"></script>'."\n";
 }
 
 if ($page and !is_numeric($page)) {
-       $edit = $User && $User->admin('news') ? htmlspecialchars(@$_GET['edit']) : NULL;
+       $edit = $User && $User->admin("edit $Page$Args") ? htmlspecialchars(@$_GET['edit']) : NULL;
        if ($edit) {
                $Article->title = $edit;
        }
@@ -15,7 +15,7 @@ if ($page and !is_numeric($page)) {
                $Place[1] = ' <small class="date">'.$Article->date.'</small>';
        }
        print preg_replace('{(?<=<h2>)(.*?)(?=</h2>)}', ($edit ?: '\1').' [[1]]', $Article->raw);
-       if ($User and $User->admin('news')) {
+       if ($User and $User->admin("edit $Page$Args")) {
                $taglist = [];
                foreach (glob("$Page/.tags/*") as $tagpath) {
                        $tagname = pathinfo($tagpath, PATHINFO_BASENAME);