diff options
| author | Jonas Kohl | 2024-09-13 23:10:34 +0200 | 
|---|---|---|
| committer | Jonas Kohl | 2024-09-13 23:10:34 +0200 | 
| commit | 948cead0f11d33adbcf0d08773c716e1b6ebb101 (patch) | |
| tree | 527067829595305d0e1bfa87557aa8f5065b7caa /src/application/views/view_topic_start.php | |
| parent | 93817fef3ead7cfd4fcde25ea2bcec02d01310a4 (diff) | |
More changes
Diffstat (limited to 'src/application/views/view_topic_start.php')
| -rw-r--r-- | src/application/views/view_topic_start.php | 39 | 
1 files changed, 36 insertions, 3 deletions
| diff --git a/src/application/views/view_topic_start.php b/src/application/views/view_topic_start.php index 84a29de..4006982 100644 --- a/src/application/views/view_topic_start.php +++ b/src/application/views/view_topic_start.php @@ -3,13 +3,19 @@ use mystic\forum\orm\UserPermissions;  $canReply = $GLOBALS["currentUser"]?->hasPermission(UserPermissions::CREATE_OWN_POST) ?? false; +$canEdit = ($GLOBALS["currentUser"]?->id === $topicAuthor->id && $topicAuthor->hasPermission(UserPermissions::EDIT_OWN_TOPIC)) +          || ($GLOBALS["currentUser"]?->hasPermission(UserPermissions::EDIT_OTHER_TOPIC)); +  $canDelete = ($GLOBALS["currentUser"]?->id === $topicAuthor->id && $topicAuthor->hasPermission(UserPermissions::DELETE_OWN_TOPIC))            || ($GLOBALS["currentUser"]?->hasPermission(UserPermissions::DELETE_OTHER_TOPIC));  ?> -<div class="page-header margin-top-0"> -    <div role="heading" class="h1 margin-top-0"> +<div class="page-header margin-top-0 clearfix"> +    <div role="heading" class="h1 margin-top-0" id="displayHeading">          <?= htmlentities($topic->title) ?>          <div class="pull-right"> +            <?php if ($canEdit): ?> +                <button id="btn-edit-title" class="btn btn-default js-only"><span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> Edit title</button> +            <?php endif; ?>              <?php if ($canReply): ?>                  <button id="btn-reply" class="btn btn-default js-only"><span class="glyphicon glyphicon-share-alt" aria-hidden="true"></span> Reply</button>              <?php endif; ?> @@ -21,6 +27,20 @@ $canDelete = ($GLOBALS["currentUser"]?->id === $topicAuthor->id && $topicAuthor-              <?php endif; ?>          </div>      </div> +    <?php if ($canEdit): ?> +        <form action="?_action=updatetopic" method="post" id="editHeading" style="display: none;" class="form-inline seamless-inline" style="display: block"> +            <input type="hidden" name="topic" value="<?= htmlentities(urlencode($topic->id)) ?>"> +            <div class="row"> +                <div class="col-md-8"> +                    <input type="text" class="form-control" name="title" id="i_edit_title" value="<?= htmlentities($topic->title) ?>" style="box-sizing: border-box; width: 100%"> +                </div> +                <div class="col-md-4 text-right"> +                    <button type="button" id="topicTitleEditCancel" class="btn btn-default"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span> Cancel</button> +                    <button type="submit" class="btn btn-success"><span class="glyphicon glyphicon-floppy-disk" aria-hidden="true"></span> Save changes</button> +                </div> +            </div> +        </form> +    <?php endif; ?>  </div>  <p>  Started by @@ -31,8 +51,21 @@ Started by  <?php endif; ?>  on <span class="_time"><?= htmlentities($topic->creationDate->format("c")) ?></span>  </p> -<?php if ($canReply): ?>  <script> +<?php if ($canEdit): ?> +$(function() { +    $("#btn-edit-title").click(function() { +        $("#displayHeading").hide(); +        $("#editHeading").show(); +        $("#i_edit_title").focus(); +    }); +    $("#topicTitleEditCancel").click(function() { +        $("#displayHeading").show(); +        $("#editHeading").hide(); +    }); +}); +<?php endif; ?> +<?php if ($canReply): ?>  $(function() {      function focusReplyBox() {          var msgInput = $("#i_message"); |