Skip to content

Commit

Permalink
read-only mode in silverbullet interface
Browse files Browse the repository at this point in the history
  • Loading branch information
twoln committed May 25, 2024
1 parent 2fa23b5 commit aa7022a
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions web/admin/edit_silverbullet.php
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,9 @@ function clipboardCopy(user) {
</script>
<link rel='stylesheet' type='text/css' href='../external/jquery/jquery-ui.css' />
<link rel='stylesheet' type='text/css' href='css/silverbullet.css.php' />
if ($editMode == 'readonly') {
print('<style>.admin_only {visibility: hidden}</style>');
}
</head>

<body>
Expand Down Expand Up @@ -472,7 +475,7 @@ function clipboardCopy(user) {
. "<button type='submit' "
. "name='command' "
. "value='" . \web\lib\common\FormElements::BUTTON_REVOKECREDENTIAL . "' "
. "class='delete' "
. "class='delete admin_only' "
. "onclick='return confirm(\"" . sprintf(_("The device in question will stop functioning with %s. The revocation cannot be undone. Are you sure you want to do this?"), \config\ConfAssistant::CONSORTIUM['display_name']) . "\")'>"
. _("Revoke")
. "</button>"
Expand Down Expand Up @@ -512,7 +515,7 @@ function clipboardCopy(user) {
case core\SilverbulletInvitation::SB_TOKENSTATUS_VALID:
case core\SilverbulletInvitation::SB_TOKENSTATUS_PARTIALLY_REDEEMED:
$hasOnePendingInvite = TRUE;
$tokenHtmlBuffer .= "<tr class='sb-certificate-row_id'><td></td>";
$tokenHtmlBuffer .= "<tr class='sb-certificate-row_id admin_only'><td></td>";
$jsEncodedBody = str_replace('\n', '%0D%0A', str_replace('"', '', json_encode($invitationObject->invitationMailBody())));
$tokenHtmlBuffer .= "<td>";
$tokenHtmlBuffer .= sprintf(_("The invitation token %s is ready for sending! Choose how to send it:"), "<input type='text' readonly='readonly' style='background-color:lightgrey;' size='60' value='" . $invitationObject->link() . "' name='token' class='identifiedtokenarea-" . $invitationObject->identifier . "'>(…)<br/>");
Expand All @@ -533,7 +536,7 @@ function clipboardCopy(user) {
</form>
</td></tr>
<tr><td style='vertical-align:bottom;'>" . _("Manual:") . "</td><td>
<button type='button' class='clipboardButton' onclick='clipboardCopy(" . $invitationObject->identifier . ");'>" . _("Copy to Clipboard") . "</button>
<button type='button' class='clipboardButton admin_only' onclick='clipboardCopy(" . $invitationObject->identifier . ");'>" . _("Copy to Clipboard") . "</button>
<form style='display:inline-block;' method='post' action='inc/displayQRcode.inc.php' onsubmit='popupQRWindow(this); return false;' accept-charset='UTF-8'>
<input type='hidden' value='" . $invitationObject->invitationTokenString . "' name='token'><br/>
<button type='submit'>" . _("Display QR code") . "</button>
Expand Down Expand Up @@ -565,7 +568,7 @@ function clipboardCopy(user) {
<span><input type='text' maxlength='19' class='sb-date-picker' name='userexpiry' value='" . $profile->getUserExpiryDate($oneUserId) . "'>&nbsp;(UTC)</span>
</div>
<input type='hidden' name='userid' value='$oneUserId'/>
<button type='submit' name='command' value='" . \web\lib\common\FormElements::BUTTON_CHANGEUSEREXPIRY . "'>" . _("Update") . "</button>
<button type='submit' class='admin_only' name='command' value='" . \web\lib\common\FormElements::BUTTON_CHANGEUSEREXPIRY . "'>" . _("Update") . "</button>
</form>
</td>
<td>
Expand All @@ -578,7 +581,7 @@ function clipboardCopy(user) {
<button type='submit' "
. "name='command' "
. "value='" . \web\lib\common\FormElements::BUTTON_DEACTIVATEUSER . "' "
. "class='delete' "
. "class='delete admin_only' "
. ( count($validCerts) > 0 ? "onclick='return confirm(\"" . $deletionText . "\")' " : "" )
. ">"
. _("Deactivate User")
Expand All @@ -591,15 +594,15 @@ function clipboardCopy(user) {
if (new DateTime() < new DateTime($expiryDate)) { // current user, allow sending new token
${$outputBuffer} .= $formtext . "
<input type='hidden' name='userid' value='$oneUserId'/>
<button type='submit' name='command' value='" . \web\lib\common\FormElements::BUTTON_NEWINVITATION . "'>" . _("New Invitation") . "</button>
<button type='submit' name='command' class='admin_only' value='" . \web\lib\common\FormElements::BUTTON_NEWINVITATION . "'>" . _("New Invitation") . "</button>
<label>" . _("Activations:") . "
<input type='text' name='invitationsquantity' value='5' maxlength='3' style='width: 30px;'/>
</label>
</form>";
} elseif (count($profile->getUserAuthRecords($oneUserId, true)) == 0) { // previous user; if there are NO authentication records, allow full deletion - otherwise, need to keep user trace for abuse handling
${$outputBuffer} .= $formtext . "
<input type='hidden' name='userid' value='$oneUserId'/>
<button type='submit' class='delete' name='command' value='" . \web\lib\common\FormElements::BUTTON_DELETE . "'>" . _("Delete User") . "</button>
<button type='submit' class='delete admin_only' name='command' value='" . \web\lib\common\FormElements::BUTTON_DELETE . "'>" . _("Delete User") . "</button>
</form>";
}
${$outputBuffer} .= "</div>
Expand Down Expand Up @@ -644,7 +647,7 @@ function clipboardCopy(user) {
</fieldset>
</div>
<!--Add new user and user import forms -->
<div class="tabbed" id="tabs">
<div class="tabbed admin_only" id="tabs">
<ul>
<li>
<a href="#tabs-3"><?php echo _("Add new user"); ?></a>
Expand Down

0 comments on commit aa7022a

Please sign in to comment.