Skip to content

Commit

Permalink
add a comment while enabling / disabling accounts (#125)
Browse files Browse the repository at this point in the history
  • Loading branch information
David Coutadeur committed Oct 25, 2024
1 parent 68d639f commit 8905bfa
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 21 deletions.
6 changes: 6 additions & 0 deletions conf/config.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,12 @@
$use_disableaccount = false;
$show_enablestatus = false;

$use_enablecomment = false;
$use_enablecomment_required = false;
$use_disablecomment = false;
$use_disablecomment_required = false;


# Local password policy
# This is applied before directory password policy
# Minimal length
Expand Down
4 changes: 4 additions & 0 deletions htdocs/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,10 @@
$smarty->assign('use_enableaccount',$use_enableaccount);
$smarty->assign('use_disableaccount',$use_disableaccount);
$smarty->assign('show_enablestatus',$show_enablestatus);
$smarty->assign('use_enablecomment',$use_enablecomment);
$smarty->assign('use_enablecomment_required',$use_enablecomment_required);
$smarty->assign('use_disablecomment',$use_disablecomment);
$smarty->assign('use_disablecomment_required',$use_disablecomment_required);


# Assign messages
Expand Down
8 changes: 7 additions & 1 deletion templates/comment.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@
<h1 class="modal-title fs-5" id="CommentModal">{$title}</h1>
</div>
<div class="modal-body">
<textarea class="form-control" name="comment" id="comment-{$method}" rows="3" placeholder="{$msg_insert_comment}"{if $use_lockcomment_required || $use_unlockcomment_required}required{/if}></textarea>
<textarea class="form-control" name="comment" id="comment-{$method}" rows="3" placeholder="{$msg_insert_comment}"
{if $method eq 'lock' || $method eq 'unlock'}
{if $use_lockcomment_required || $use_unlockcomment_required}required{/if}
{elseif $method eq 'enable' || $method eq 'disable'}
{if $use_disablecomment_required || $use_enablecomment_required}required{/if}
{/if}
></textarea>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">
Expand Down
55 changes: 36 additions & 19 deletions templates/display.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,6 @@
{if $unlockaccountresult eq 'ldaperror'}
<div class="alert alert-danger"><i class="fa fa-fw fa-exclamation-triangle"></i> {$msg_accountnotunlocked}</div>
{/if}
{if $enableaccountresult eq 'ldaperror'}
<div class="alert alert-danger"><i class="fa fa-fw fa-exclamation-triangle"></i> {$msg_accountnotenabled}</div>
{/if}
{if $use_unlockcomment}
<button type="button" class="btn btn-success" data-bs-toggle="modal" data-bs-target="#commentModal">
<i class="fa fa-fw fa-unlock me-2"></i>{$msg_unlockaccount}
Expand Down Expand Up @@ -325,15 +322,25 @@
</div>
{if $use_disableaccount}
<div class="card-body">
<form id="disableaccount" method="post" action="index.php?page=disableaccount">
{if $disableaccountresult eq 'ldaperror' or $disableaccountresult eq 'actionforbidden'}
<div class="alert alert-danger"><i class="fa fa-fw fa-exclamation-triangle"></i> {$msg_accountnotdisabled}</div>
{/if}
<input type="hidden" name="dn" value="{$dn}" />
<button type="submit" class="btn btn-success">
<i class="fa fa-fw fa-user-slash"></i> {$msg_disableaccount}
{if $disableaccountresult eq 'ldaperror' or $disableaccountresult eq 'actionforbidden'}
<div class="alert alert-danger"><i class="fa fa-fw fa-exclamation-triangle"></i> {$msg_accountnotdisabled}</div>
{/if}
{if $use_disablecomment}
<button type="button" class="btn btn-success" data-bs-toggle="modal" data-bs-target="#commentModal">
<i class="fa fa-fw fa-user-slash me-2"></i>{$msg_disableaccount}
<i class="fa fa-fw fa-info-circle text-body-tertiary ms-2" title="{$msg_comment_needed}"></i>
</button>
</form>
<div>
{include 'comment.tpl' method=disable page=disableaccount title=$msg_lockaccount}
</div>
{else}
<form id="disableaccount" method="post" action="index.php?page=disableaccount">
<input type="hidden" name="dn" value="{$dn}" />
<button type="submit" class="btn btn-success">
<i class="fa fa-fw fa-user-slash"></i> {$msg_disableaccount}
</button>
</form>
{/if}
</div>
{/if}
</div>
Expand All @@ -347,15 +354,25 @@
</div>
{if $use_enableaccount}
<div class="card-body">
<form id="disableaccount" method="post" action="index.php?page=enableaccount">
{if $enableaccountresult eq 'ldaperror' or $enableaccountresult eq 'actionforbidden'}
<div class="alert alert-danger"><i class="fa fa-fw fa-exclamation-triangle"></i> {$msg_accountnotenabled}</div>
{/if}
<input type="hidden" name="dn" value="{$dn}" />
<button type="submit" class="btn btn-success">
<i class="fa fa-fw fa-user-check"></i> {$msg_enableaccount}
{if $enableaccountresult eq 'ldaperror' or $enableaccountresult eq 'actionforbidden'}
<div class="alert alert-danger"><i class="fa fa-fw fa-exclamation-triangle"></i> {$msg_accountnotenabled}</div>
{/if}
{if $use_enablecomment}
<button type="button" class="btn btn-success" data-bs-toggle="modal" data-bs-target="#commentModal">
<i class="fa fa-fw fa-user-check me-2"></i>{$msg_enableaccount}
<i class="fa fa-fw fa-info-circle text-body-tertiary ms-2" title="{$msg_comment_needed}"></i>
</button>
</form>
<div>
{include 'comment.tpl' method=enable page=enableaccount title=$msg_enableaccount}
</div>
{else}
<form id="disableaccount" method="post" action="index.php?page=enableaccount">
<input type="hidden" name="dn" value="{$dn}" />
<button type="submit" class="btn btn-success">
<i class="fa fa-fw fa-user-check"></i> {$msg_enableaccount}
</button>
</form>
{/if}
</div>
{/if}
</div>
Expand Down
2 changes: 1 addition & 1 deletion templates/listing_table.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
{if $display_enable_button}
<a href="index.php?page=enableaccount&dn={$entry.dn|escape:'url'}&returnto=searchdisabled"
class="btn btn-success btn-sm" role="button" title="{$msg_enableaccount}">
<i class="fa fa-fw fa-person-circle-check"></i>
<i class="fa fa-fw fa-user-check"></i>
</a>
{/if}
</th>
Expand Down

0 comments on commit 8905bfa

Please sign in to comment.