Support: Comb the code

Also, now clicking on the name of the support agent does not display "false". There should be no other visible changes
This commit is contained in:
Maxim Leshchenko 2022-01-07 00:30:49 +02:00
parent 6c23be8b2b
commit f7fbda1e3c
No known key found for this signature in database
GPG key ID: BB9C44A8733FBEEE
4 changed files with 308 additions and 324 deletions

View file

@ -31,6 +31,7 @@ final class SupportPresenter extends OpenVKPresenter
$tickets = $this->tickets->getTicketsByuId($this->user->id); $tickets = $this->tickets->getTicketsByuId($this->user->id);
if($tickets) if($tickets)
$this->template->tickets = $tickets; $this->template->tickets = $tickets;
if($_SERVER["REQUEST_METHOD"] === "POST") { if($_SERVER["REQUEST_METHOD"] === "POST") {
if(!empty($this->postParam("name")) && !empty($this->postParam("text"))) { if(!empty($this->postParam("name")) && !empty($this->postParam("text"))) {
$this->assertNoCSRF(); $this->assertNoCSRF();
@ -111,11 +112,11 @@ final class SupportPresenter extends OpenVKPresenter
if(!$ticket || $ticket->isDeleted() != 0 || $ticket->getUserId() !== $this->user->id && !$this->hasPermission('openvk\Web\Models\Entities\TicketReply', 'write', 0)) { if(!$ticket || $ticket->isDeleted() != 0 || $ticket->getUserId() !== $this->user->id && !$this->hasPermission('openvk\Web\Models\Entities\TicketReply', 'write', 0)) {
$this->notFound(); $this->notFound();
} else { } else {
header("HTTP/1.1 302 Found");
if($ticket->getUserId() !== $this->user->id && $this->hasPermission('openvk\Web\Models\Entities\TicketReply', 'write', 0)) if($ticket->getUserId() !== $this->user->id && $this->hasPermission('openvk\Web\Models\Entities\TicketReply', 'write', 0))
header("Location: /support/tickets"); $this->redirect("/support/tickets");
else else
header("Location: /support"); $this->redirect("/support");
$ticket->delete(); $ticket->delete();
} }
} }
@ -183,12 +184,11 @@ final class SupportPresenter extends OpenVKPresenter
$ticket->setType($this->postParam("status")); $ticket->setType($this->postParam("status"));
$ticket->save(); $ticket->save();
$this->assertNoCSRF();
$comment = new TicketComment; $comment = new TicketComment;
$comment->setUser_id($this->user->id); $comment->setUser_id($this->user->id);
$comment->setUser_type(1); $comment->setUser_type(1);
$comment->setText($this->postParam("text")); $comment->setText($this->postParam("text"));
$comment->setTicket_id($id); $comment->setTicket_Id($id);
$comment->setCreated(time()); $comment->setCreated(time());
$comment->save(); $comment->save();
} elseif(empty($this->postParam("text"))) { } elseif(empty($this->postParam("text"))) {

View file

@ -7,31 +7,26 @@
{block content} {block content}
<div class="post-author"> <div class="post-author">
<a href="#" style="font-size:13px;"> <a href="#" style="font-size: 13px;"><b>{$ticket->getName()}</b></a><br />
<b> {_author}: <a href="/id{$ticket->getUser()->getId()}">{$ticket->getUser()->getFullName()}</a> | {$ticket->getUser()->getRegistrationIP()} | {_status}: {$ticket->getStatus()}.
{$ticket->getName()}
</b>
</a>
<br></b>{_author}: <a href="/id{$ticket->getUser()->getId()}">{$ticket->getUser()->getFullName()}</a> | {$ticket->getUser()->getRegistrationIP()} | {_status}: {$ticket->getStatus()}.
</div> </div>
<div class="text" style="padding-top: 10px; border-bottom: #ECECEC solid 1px;"> <div class="text" style="padding-top: 10px; border-bottom: #ECECEC solid 1px;">
{$ticket->getText()|noescape} {$ticket->getText()|noescape}
<br></br> <br /><br />
</div> </div>
<div style="padding-top: 5px;"> <div style="padding-top: 5px;">
{$ticket->getTime()}&nbsp;|&nbsp; {$ticket->getTime()}&nbsp;|&nbsp;
<a href="/support/delete/{$id}?hash={$csrfToken}">{_delete}</a> <a href="/support/delete/{$id}?hash={$csrfToken}">{_delete}</a>
</div><br/>
<div>
<form action="/al_comments/create/support/reply/{$id}" method="post" style="margin:0;">
<textarea name="text" id="answer_text" style="width: 100%;resize: vertical;"></textarea>
<div>
<!-- padding to fix <br/> bug -->
</div> </div>
<br />
<div>
<form action="/al_comment/create/support/reply/{$id}" method="post" style="margin: 0;">
<textarea name="text" id="answer_text" style="width: 100%; resize: vertical;"></textarea>
<br />
<input type="hidden" name="hash" value="{$csrfToken}" /> <input type="hidden" name="hash" value="{$csrfToken}" />
<br /> <br />
<div style="float: left;"> <div style="float: left;">
<input type="submit" value="{_write}" class="button"> <input type="submit" value="{_write}" class="button" />
<select name="status" style="width: unset;"> <select name="status" style="width: unset;">
<option value="1">{_support_status_1}</option> <option value="1">{_support_status_1}</option>
<option value="2">{_support_status_2}</option> <option value="2">{_support_status_2}</option>
@ -52,7 +47,7 @@
<tr> <tr>
{if $comment->getUType() === 0} {if $comment->getUType() === 0}
<td width="54" valign="top"> <td width="54" valign="top">
<img src="{$comment->getUser()->getAvatarUrl()}" width="50"> <img src="{$comment->getUser()->getAvatarUrl()}" width="50" />
</td> </td>
{else} {else}
<td width="54" valign="top"> <td width="54" valign="top">
@ -66,16 +61,12 @@
<div class="post-author"> <div class="post-author">
<a href="{$comment->getUser()->getURL()}"><b> <a href="{$comment->getUser()->getURL()}"><b>
{$comment->getUser()->getFullName()} {$comment->getUser()->getFullName()}
</b></a> {($comment->getUser()->isFemale() ? tr("post_writes_f") : tr("post_writes_m"))}<br> </b></a> {($comment->getUser()->isFemale() ? tr("post_writes_f") : tr("post_writes_m"))}<br />
<a href="#" class="date">{$comment->getTime()}</a> <a href="#" class="date">{$comment->getTime()}</a>
</div> </div>
{elseif ($comment->getUType() === 1)} {elseif ($comment->getUType() === 1)}
<div class="post-author"> <div class="post-author">
<a href="javascript:false"> <a><b>{$comment->getAuthorName()}</b></a>
<b>
{$comment->getAuthorName()}
</b>
</a>
{if $thisUser->getChandlerUser()->can("write")->model('openvk\Web\Models\Entities\TicketReply')->whichBelongsTo(0)} {if $thisUser->getChandlerUser()->can("write")->model('openvk\Web\Models\Entities\TicketReply')->whichBelongsTo(0)}
<a href="{$comment->getUser()->getURL()}"> <a href="{$comment->getUser()->getURL()}">
<span class="nobold"> <span class="nobold">
@ -88,7 +79,7 @@
</span> </span>
</a> </a>
{/if} {/if}
{_post_writes_m}<br> {_post_writes_m}<br />
<a href="#" class="date">{$comment->getTime()}</a> <a href="#" class="date">{$comment->getTime()}</a>
</div> </div>
{/if} {/if}

View file

@ -6,7 +6,6 @@
{/block} {/block}
{block content} {block content}
{var isMain = $mode === 'faq'} {var isMain = $mode === 'faq'}
{var isNew = $mode === 'new'} {var isNew = $mode === 'new'}
{var isList = $mode === 'list'} {var isList = $mode === 'list'}
@ -23,21 +22,25 @@
<a n:attr="id => ($isNew ? 'act_tab_a' : 'ki')" href="/support?act=new">{_support_new}</a> <a n:attr="id => ($isNew ? 'act_tab_a' : 'ki')" href="/support?act=new">{_support_new}</a>
</div> </div>
</div> </div>
<br>
<br />
{if $isNew} {if $isNew}
<div class="new"> <div class="new">
<form action="/support" method="post" style="margin:0;"> <form action="/support" method="post" style="margin:0;">
<center><input name="name" style="width: 80%;resize: vertical;" placeholder="{_support_new_title}"></center><br> <center>
<center><textarea name="text" style="width: 80%;resize: vertical;" placeholder="{_support_new_content}"></textarea></center><br> <input name="name" style="width: 80%; resize: vertical;" placeholder="{_support_new_title}" /><br /><br />
<textarea name="text" style="width: 80%; resize: vertical;" placeholder="{_support_new_content}"></textarea><br /><br />
<input type="hidden" name="hash" value="{$csrfToken}" /> <input type="hidden" name="hash" value="{$csrfToken}" />
<center><input type="submit" value="{_write}" class="button" style="margin-left:70%;"></center><br> <input type="submit" value="{_write}" class="button" style="margin-left: 70%;" /><br /><br />
</center>
</form> </form>
</div> </div>
{/if}{/if} {/if}
{/if}
{if $isMain} {if $isMain}
<h4>{_support_faq}</h4><br> <h4>{_support_faq}</h4><br />
<div class="faq"> <div class="faq">
<div id="faqhead">{_support_faq_title}</div> <div id="faqhead">{_support_faq_title}</div>
<div id="faqcontent">{_support_faq_content}</div> <div id="faqcontent">{_support_faq_content}</div>
@ -49,7 +52,9 @@
<tbody> <tbody>
<tr> <tr>
<td width="54" valign="top"> <td width="54" valign="top">
<center><img src="/assets/packages/static/openvk/img/note_icon.png" alt="{_support_ticket}" style="margin-top: 17px;"></center> <center>
<img src="/assets/packages/static/openvk/img/note_icon.png" alt="{_support_ticket}" style="margin-top: 17px;" />
</center>
</td> </td>
<td width="345" valign="top"> <td width="345" valign="top">
<div class="post-author"> <div class="post-author">

View file

@ -28,38 +28,31 @@
document.getElementById("markText-" + id).innerHTML = {_error}; document.getElementById("markText-" + id).innerHTML = {_error};
} }
</script> </script>
{if $ticket->isDeleted() == 0} {if $ticket->isDeleted() == 0}
<div class="post-author"> <div class="post-author">
<a href="#" style="font-size:13px;"> <a href="#" style="font-size:13px;"><b>{$ticket->getName()}</b></a>
<b> <br />{_status}: {$ticket->getStatus()}
{$ticket->getName()}
</b>
</a>
<br></b>{_status}: {$ticket->getStatus()}
</div> </div>
<div class="text" style="padding-top: 10px; border-bottom: #ECECEC solid 1px;"> <div class="text" style="padding-top: 10px; border-bottom: #ECECEC solid 1px;">
{$ticket->getText()|noescape} {$ticket->getText()|noescape}
<br></br> <br /></br>
</div> </div>
<div style="padding-top: 5px;"> <div style="padding-top: 5px;">
{$ticket->getTime()}&nbsp;|&nbsp; {$ticket->getTime()}&nbsp;|&nbsp;
<a href="/support/delete/{$id}?hash={$csrfToken}">{_delete}</a> <a href="/support/delete/{$id}?hash={$csrfToken}">{_delete}</a>
</div> </div>
{if $ticket->getType() !== 2} {if $ticket->getType() !== 2}
<br> <br />
<div> <div>
<form action="/al_comments/create/support/{$id}" method="post" style="margin:0;"> <form action="/al_comments/create/support/{$id}" method="post" style="margin:0;">
<textarea name="text" style="width: 100%;resize: vertical;"></textarea> <textarea name="text" style="width: 100%;resize: vertical;"></textarea><br />
<div> <input type="hidden" name="hash" value="{$csrfToken}" /><br />
<!-- padding to fix <br/> bug --> <input type="submit" value="{_write}" class="button" />
</div>
<input type="hidden" name="hash" value="{$csrfToken}" />
<br>
<input type="submit" value="{_write}" class="button">
</form> </form>
</div> </div>
{/if} {/if}
</br> <br />
<p n:if="!$comments">{_no_comments}</p> <p n:if="!$comments">{_no_comments}</p>
{var $printedSupportGreeting = false} {var $printedSupportGreeting = false}
<table n:foreach="$comments as $comment" border="0" style="font-size: 11px;" class="post"> <table n:foreach="$comments as $comment" border="0" style="font-size: 11px;" class="post">
@ -67,7 +60,7 @@
<tr> <tr>
{if $comment->getUType() === 0} {if $comment->getUType() === 0}
<td width="54" valign="top"> <td width="54" valign="top">
<img src="{$comment->getUser()->getAvatarUrl()}" width="50"> <img src="{$comment->getUser()->getAvatarUrl()}" width="50" />
</td> </td>
{else} {else}
<td width="54" valign="top"> <td width="54" valign="top">
@ -79,19 +72,14 @@
<td width="645" valign="top"> <td width="645" valign="top">
{if $comment->getUType() === 0} {if $comment->getUType() === 0}
<div class="post-author"> <div class="post-author">
<a href="{$comment->getUser()->getURL()}"><b> <a href="{$comment->getUser()->getURL()}"><b>{$comment->getUser()->getFullName()}</b></a>
{$comment->getUser()->getFullName()} {($comment->getUser()->isFemale() ? tr("post_writes_f") : tr("post_writes_m"))}<br />
</b></a> {($comment->getUser()->isFemale() ? tr("post_writes_f") : tr("post_writes_m"))}<br>
<a href="#" class="date">{$comment->getTime()}</a> <a href="#" class="date">{$comment->getTime()}</a>
</div> </div>
{elseif ($comment->getUType() === 1)} {elseif ($comment->getUType() === 1)}
<div class="post-author"> <div class="post-author">
<a href="javascript:false"> <a><b>{$comment->getAuthorName()}</b></a>
<b> {_post_writes_m}<br />
{$comment->getAuthorName()}
</b>
</a>
{_post_writes_m}<br>
<a href="#" class="date">{$comment->getTime()}</a> <a href="#" class="date">{$comment->getTime()}</a>
</div> </div>
{/if} {/if}
@ -138,8 +126,8 @@
<a onClick="markAnswer({$comment->getId()}, 2)">{_support_rate_bad_answer}</a> <a onClick="markAnswer({$comment->getId()}, 2)">{_support_rate_bad_answer}</a>
{/if} {/if}
</div> </div>
{/if}
</div> </div>
{/if}
</div> </div>
</td> </td>
</tr> </tr>