Skip to content

Commit 94b3697

Browse files
committed
Show edit and delete buttons on packet viewer
1 parent c972ddd commit 94b3697

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/templates/Packet/View.phtml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@ if ($object) {
5252

5353
$this->opengraph->attach(new Pair("url", $url));
5454

55+
$edit_url = Common::relativeUrlToAbsolute("/packet/edit?id=" . urlencode($object_id));
56+
$delete_url = Common::relativeUrlToAbsolute("/packet/delete?id=" . urlencode($object_id));
57+
$edit_visible = ($logged_in && ($logged_in->getOptionsBitmask()
58+
& User::OPTION_ACL_PACKET_MODIFY));
59+
$delete_visible = ($logged_in && ($logged_in->getOptionsBitmask()
60+
& User::OPTION_ACL_PACKET_DELETE));
61+
5562
$this->additional_css[] = "/a/packet.css";
5663
$this->additional_css[] = "/a/comments.css";
5764
if ($logged_in) $this->additional_css[] = "/a/forms.css";
@@ -62,6 +69,12 @@ require("./header.inc.phtml");
6269
<a href="https://plus.google.com/share?url=<?php echo urlencode($url); ?>" rel="external" data-popup="1"><img class="header-button float-right" src="<?php echo Common::relativeUrlToAbsolute("/a/social-gplus-24px.png"); ?>"/></a>
6370
<a href="https://twitter.com/share?text=<?php echo urlencode($packet_id . " " . $object->getPacketName()); ?>&amp;url=<?php echo urlencode($url); ?>" rel="external" data-popup="1"><img class="header-button float-right" src="<?php echo Common::relativeUrlToAbsolute("/a/social-twitter-24px.png"); ?>"/></a>
6471
<a href="https://facebook.com/sharer/sharer.php?u=<?php echo urlencode($url); ?>" rel="external" data-popup="1"><img class="header-button float-right" src="<?php echo Common::relativeUrlToAbsolute("/a/social-facebook-24px.png"); ?>"/></a>
72+
<?php if ($edit_visible) { ?>
73+
<a href="<?php echo $edit_url; ?>" class="header-button float-right">Edit</a>
74+
<?php } ?>
75+
<?php if ($delete_visible) { ?>
76+
<a href="<?php echo $delete_url; ?>" class="header-button float-right">Delete</a>
77+
<?php } ?>
6578
<header><a href="<?php echo $url; ?>"><?php echo filter_var($title, FILTER_SANITIZE_STRING); ?></a></header>
6679
<section>
6780
<table class="info"><tbody>

0 commit comments

Comments
 (0)