]> git.mxchange.org Git - friendica.git/commitdiff
Create self-only ACL template and helper method
authorHypolite Petovan <hypolite@mrpetovan.com>
Mon, 7 Sep 2020 23:27:32 +0000 (19:27 -0400)
committerHypolite Petovan <hypolite@mrpetovan.com>
Mon, 7 Sep 2020 23:27:32 +0000 (19:27 -0400)
src/Core/ACL.php
view/templates/acl/self_only.tpl [new file with mode: 0644]

index 4df15dc536906a31e6a8c64b245140830c910854..5f69d78b683921cccca5c75a9d3a3340d1bd700e 100644 (file)
@@ -83,6 +83,27 @@ class ACL
                return $o;
        }
 
+       /**
+        * Returns a minimal ACL block for self-only permissions
+        *
+        * @param int    $localUserId
+        * @param string $explanation
+        * @return string
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+        */
+       public static function getSelfOnlyHTML(int $localUserId, string $explanation)
+       {
+               $selfPublicContactId = Contact::getPublicIdByUserId($localUserId);
+
+               $tpl = Renderer::getMarkupTemplate('acl/self_only.tpl');
+               $o = Renderer::replaceMacros($tpl, [
+                       '$selfPublicContactId' => $selfPublicContactId,
+                       '$explanation' => $explanation,
+               ]);
+
+               return $o;
+       }
+
        /**
         * Return the default permission of the provided user array
         *
diff --git a/view/templates/acl/self_only.tpl b/view/templates/acl/self_only.tpl
new file mode 100644 (file)
index 0000000..d1c5a00
--- /dev/null
@@ -0,0 +1,5 @@
+<input type="hidden" name="contact_allow" value="{{$selfPublicContactId}}">
+<input type="hidden" name="group_allow" value="">
+<input type="hidden" name="contact_deny" value="">
+<input type="hidden" name="group_deny" value="">
+<div class="alert alert-info" role="alert"><p>{{$explanation}}</p></div>
\ No newline at end of file