Skip to content
Snippets Groups Projects
Commit b8e52d91 authored by Peter Rotich's avatar Peter Rotich
Browse files

Merge pull request #2701 from protich/feature/avatar+optional

Make Avatars optional on thread view
parents 637c222a 536cf883
Branches
Tags
No related merge requests found
...@@ -162,6 +162,7 @@ class OsticketConfig extends Config { ...@@ -162,6 +162,7 @@ class OsticketConfig extends Config {
'allow_pw_reset' => true, 'allow_pw_reset' => true,
'pw_reset_window' => 30, 'pw_reset_window' => 30,
'enable_richtext' => true, 'enable_richtext' => true,
'enable_avatars' => true,
'allow_attachments' => true, 'allow_attachments' => true,
'agent_name_format' => 'full', # First Last 'agent_name_format' => 'full', # First Last
'client_name_format' => 'original', # As entered 'client_name_format' => 'original', # As entered
...@@ -380,6 +381,10 @@ class OsticketConfig extends Config { ...@@ -380,6 +381,10 @@ class OsticketConfig extends Config {
return $this->get('enable_richtext'); return $this->get('enable_richtext');
} }
function isAvatarsEnabled() {
return $this->get('enable_avatars');
}
function getClientTimeout() { function getClientTimeout() {
return $this->getClientSessionTimeout(); return $this->getClientSessionTimeout();
} }
...@@ -1112,6 +1117,7 @@ class OsticketConfig extends Config { ...@@ -1112,6 +1117,7 @@ class OsticketConfig extends Config {
'secondary_langs'=>$secondary_langs, 'secondary_langs'=>$secondary_langs,
'max_file_size' => $vars['max_file_size'], 'max_file_size' => $vars['max_file_size'],
'autolock_minutes' => $vars['autolock_minutes'], 'autolock_minutes' => $vars['autolock_minutes'],
'enable_avatars' => isset($vars['enable_avatars']) ? 1 : 0,
'enable_richtext' => isset($vars['enable_richtext']) ? 1 : 0, 'enable_richtext' => isset($vars['enable_richtext']) ? 1 : 0,
)); ));
} }
......
...@@ -1610,15 +1610,18 @@ class ThreadEvent extends VerySimpleModel { ...@@ -1610,15 +1610,18 @@ class ThreadEvent extends VerySimpleModel {
} }
function template($description) { function template($description) {
global $thisstaff; global $thisstaff, $cfg;
$self = $this; $self = $this;
return preg_replace_callback('/\{(<(?P<type>([^>]+))>)?(?P<key>[^}.]+)(\.(?P<data>[^}]+))?\}/', return preg_replace_callback('/\{(<(?P<type>([^>]+))>)?(?P<key>[^}.]+)(\.(?P<data>[^}]+))?\}/',
function ($m) use ($self, $thisstaff) { function ($m) use ($self, $thisstaff, $cfg) {
switch ($m['key']) { switch ($m['key']) {
case 'assignees': case 'assignees':
$assignees = array(); $assignees = array();
if ($S = $self->staff) { if ($S = $self->staff) {
$avatar = $S->getAvatar(); $avatar = '';
if ($cfg->isAvatarsEnabled())
$avatar = $S->getAvatar();
$assignees[] = $assignees[] =
$avatar.$S->getName(); $avatar.$S->getName();
} }
...@@ -1628,7 +1631,8 @@ class ThreadEvent extends VerySimpleModel { ...@@ -1628,7 +1631,8 @@ class ThreadEvent extends VerySimpleModel {
return implode('/', $assignees); return implode('/', $assignees);
case 'somebody': case 'somebody':
$name = $self->getUserName(); $name = $self->getUserName();
if ($avatar = $self->getAvatar()) if ($cfg->isAvatarsEnabled()
&& ($avatar = $self->getAvatar()))
$name = $avatar.$name; $name = $avatar.$name;
return $name; return $name;
case 'timestamp': case 'timestamp':
...@@ -1651,7 +1655,8 @@ class ThreadEvent extends VerySimpleModel { ...@@ -1651,7 +1655,8 @@ class ThreadEvent extends VerySimpleModel {
); );
case 'agent': case 'agent':
$name = $self->agent->getName(); $name = $self->agent->getName();
if ($avatar = $self->getAvatar()) if ($cfg->isAvatarsEnabled()
&& ($avatar = $self->getAvatar()))
$name = $avatar.$name; $name = $avatar.$name;
return $name; return $name;
case 'dept': case 'dept':
......
<?php <?php
global $cfg;
$entryTypes = array('M'=>'message', 'R'=>'response', 'N'=>'note'); $entryTypes = array('M'=>'message', 'R'=>'response', 'N'=>'note');
$user = $entry->getUser() ?: $entry->getStaff(); $user = $entry->getUser() ?: $entry->getStaff();
$name = $user ? $user->getName() : $entry->poster; $name = $user ? $user->getName() : $entry->poster;
$avatar = ''; $avatar = '';
if ($user) if ($cfg->isAvatarsEnabled() && $user)
$avatar = $user->getAvatar(); $avatar = $user->getAvatar();
?> ?>
......
...@@ -72,6 +72,19 @@ enable_richtext: ...@@ -72,6 +72,19 @@ enable_richtext:
If enabled, this will permit the use of rich text formatting between If enabled, this will permit the use of rich text formatting between
Clients and Agents. Clients and Agents.
enable_avatars:
title: Enable Avatars on Thread View
content: >
Enable this to show <span class="doc-desc-title">Avatars</span> on thread correspondence.
<br><br>
The <span class="doc-desc-title">Avatar Source</span> can be set in Agents' and Users' settings pages.
links:
- title: Agents Settings
href: /scp/settings.php?t=agents
- title: Users Settings
href: /scp/settings.php?t=users
collision_avoidance: collision_avoidance:
title: Agent Collision Avoidance title: Agent Collision Avoidance
content: > content: >
......
...@@ -69,16 +69,6 @@ $gmtime = Misc::gmtime(); ...@@ -69,16 +69,6 @@ $gmtime = Misc::gmtime();
&nbsp;<i class="help-tip icon-question-sign" href="#collision_avoidance"></i> &nbsp;<i class="help-tip icon-question-sign" href="#collision_avoidance"></i>
</td> </td>
</tr> </tr>
<tr>
<td><?php echo __('Enable Rich Text'); ?>:</td>
<td>
<input type="checkbox" name="enable_richtext" <?php
echo $config['enable_richtext']?'checked="checked"':''; ?>>
<?php echo __('Enable html in thread entries and email correspondence.'); ?>
<i class="help-tip icon-question-sign" href="#enable_richtext"></i>
</td>
</tr>
<tr><td><?php echo __('Default Page Size');?>:</td> <tr><td><?php echo __('Default Page Size');?>:</td>
<td> <td>
<select name="max_page_size"> <select name="max_page_size">
...@@ -123,6 +113,24 @@ $gmtime = Misc::gmtime(); ...@@ -123,6 +113,24 @@ $gmtime = Misc::gmtime();
<i class="help-tip icon-question-sign" href="#purge_logs"></i> <i class="help-tip icon-question-sign" href="#purge_logs"></i>
</td> </td>
</tr> </tr>
<tr>
<td><?php echo __('Show Avatars'); ?>:</td>
<td>
<input type="checkbox" name="enable_avatars" <?php
echo $config['enable_avatars'] ? 'checked="checked"' : ''; ?>>
<?php echo __('Show Avatars on thread view.'); ?>
<i class="help-tip icon-question-sign" href="#enable_avatars"></i>
</td>
</tr>
<tr>
<td><?php echo __('Enable Rich Text'); ?>:</td>
<td>
<input type="checkbox" name="enable_richtext" <?php
echo $config['enable_richtext'] ? 'checked="checked"' : ''; ?>>
<?php echo __('Enable html in thread entries and email correspondence.'); ?>
<i class="help-tip icon-question-sign" href="#enable_richtext"></i>
</td>
</tr>
<tr> <tr>
<th colspan="2"> <th colspan="2">
<em><b><?php echo __('Date and Time Options'); ?></b>&nbsp; <em><b><?php echo __('Date and Time Options'); ?></b>&nbsp;
......
<?php <?php
global $thisstaff; global $thisstaff, $cfg;
$timeFormat = null; $timeFormat = null;
if ($thisstaff && !strcasecmp($thisstaff->datetime_format, 'relative')) { if ($thisstaff && !strcasecmp($thisstaff->datetime_format, 'relative')) {
$timeFormat = function($datetime) { $timeFormat = function($datetime) {
...@@ -11,7 +11,7 @@ $entryTypes = array('M'=>'message', 'R'=>'response', 'N'=>'note'); ...@@ -11,7 +11,7 @@ $entryTypes = array('M'=>'message', 'R'=>'response', 'N'=>'note');
$user = $entry->getUser() ?: $entry->getStaff(); $user = $entry->getUser() ?: $entry->getStaff();
$name = $user ? $user->getName() : $entry->poster; $name = $user ? $user->getName() : $entry->poster;
$avatar = ''; $avatar = '';
if ($user) if ($user && $cfg->isAvatarsEnabled())
$avatar = $user->getAvatar(); $avatar = $user->getAvatar();
?> ?>
<div class="thread-entry <?php <div class="thread-entry <?php
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment