mirror of
https://github.com/openvk/openvk
synced 2024-11-11 01:19:53 +03:00
Make support agents identifiable
This commit is contained in:
parent
606a61c7b3
commit
9a99aeb3fc
3 changed files with 49 additions and 6 deletions
|
@ -28,6 +28,35 @@ class TicketComment extends RowModel
|
|||
return (new Users)->get($this->getRecord()->user_id);
|
||||
}
|
||||
|
||||
function getAgentNumber(): ?string
|
||||
{
|
||||
if($this->getUType() === 0)
|
||||
return NULL;
|
||||
|
||||
$salt = "kiraMiki";
|
||||
$hash = $this->getUser()->getId() . CHANDLER_ROOT_CONF["security"]["secret"] . $salt;
|
||||
$hash = hexdec(substr(hash("adler32", $hash), 0, 3));
|
||||
$hash = ceil(($hash * 999) / 4096); # proportionalize to 0-999
|
||||
|
||||
return str_pad((string) $hash, 3, "0", STR_PAD_LEFT);
|
||||
}
|
||||
|
||||
function getColorRotation(): ?int
|
||||
{
|
||||
if(is_null($agent = $this->getAgentNumber()))
|
||||
return NULL;
|
||||
|
||||
$agent = (int) $agent;
|
||||
$rotation = $agent > 500 ? ( ($agent * 360) / 999 ) : $agent; # cap at 360deg
|
||||
$values = [0, 45, 160, 220, 310, 345]; # good looking colors
|
||||
usort($values, function($x, $y) use ($rotation) {
|
||||
# find closest
|
||||
return abs($x - $rotation) - abs($y - $rotation);
|
||||
});
|
||||
|
||||
return array_shift($values);
|
||||
}
|
||||
|
||||
function getContext(): string
|
||||
{
|
||||
return $this->getRecord()->text;
|
||||
|
|
|
@ -49,7 +49,9 @@
|
|||
</td>
|
||||
{else}
|
||||
<td width="54" valign="top">
|
||||
<img src="https://avatars.mds.yandex.net/get-zen_doc/164147/pub_5b60816e2dc67000a862253e_5b6081d4e9151400a9f48625/scale_1200" width="50">
|
||||
<img
|
||||
src="https://avatars.mds.yandex.net/get-zen_doc/164147/pub_5b60816e2dc67000a862253e_5b6081d4e9151400a9f48625/scale_1200"
|
||||
style="max-width: 50px; filter: hue-rotate({$comment->getColorRotation()}deg);" />
|
||||
</td>
|
||||
{/if}
|
||||
<td width="645" valign="top">
|
||||
|
@ -62,9 +64,19 @@
|
|||
</div>
|
||||
{elseif ($comment->getUType() === 1)}
|
||||
<div class="post-author">
|
||||
<a href="#"><b>
|
||||
{=OPENVK_ROOT_CONF["openvk"]["preferences"]["support"]["supportName"]}
|
||||
</b></a> написал<br>
|
||||
<a href="javascript:false">
|
||||
<b>
|
||||
{=OPENVK_ROOT_CONF["openvk"]["preferences"]["support"]["supportName"]} №{$comment->getAgentNumber()}
|
||||
</b>
|
||||
</a>
|
||||
{if $thisUser->getChandlerUser()->can("write")->model('openvk\Web\Models\Entities\TicketReply')->whichBelongsTo(0)}
|
||||
<a href="{$comment->getUser()->getURL()}">
|
||||
<span class="nobold">
|
||||
({$comment->getUser()->getFirstName()} {iconv_substr($comment->getUser()->getLastName(), 0, 1)}.)
|
||||
</span>
|
||||
</a>
|
||||
{/if}
|
||||
написал<br>
|
||||
<a href="#" class="date">{$comment->getTime()}</a>
|
||||
</div>
|
||||
{/if}
|
||||
|
|
|
@ -48,7 +48,9 @@
|
|||
</td>
|
||||
{else}
|
||||
<td width="54" valign="top">
|
||||
<img src="https://avatars.mds.yandex.net/get-zen_doc/164147/pub_5b60816e2dc67000a862253e_5b6081d4e9151400a9f48625/scale_1200" width="50">
|
||||
<img
|
||||
src="https://avatars.mds.yandex.net/get-zen_doc/164147/pub_5b60816e2dc67000a862253e_5b6081d4e9151400a9f48625/scale_1200"
|
||||
style="max-width: 50px; filter: hue-rotate({$comment->getColorRotation()}deg);" />
|
||||
</td>
|
||||
{/if}
|
||||
<td width="645" valign="top">
|
||||
|
@ -62,7 +64,7 @@
|
|||
{elseif ($comment->getUType() === 1)}
|
||||
<div class="post-author">
|
||||
<a href="#"><b>
|
||||
{=OPENVK_ROOT_CONF["openvk"]["preferences"]["support"]["supportName"]}
|
||||
{=OPENVK_ROOT_CONF["openvk"]["preferences"]["support"]["supportName"]} №{$comment->getAgentNumber()}
|
||||
</b></a> написал<br>
|
||||
<a href="#" class="date">{$comment->getTime()}</a>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue