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

Move global attachment settings to system setting

Settings for storage backend and general max size setting for agents
parent 7cfe37b5
No related branches found
No related tags found
No related merge requests found
......@@ -1028,6 +1028,17 @@ class OsticketConfig extends Config {
$f['default_timezone']=array('type'=>'string', 'required'=>1, 'error'=>__('Default Timezone is required'));
$f['system_language']=array('type'=>'string', 'required'=>1, 'error'=>__('A primary system language is required'));
// Make sure the selected backend is valid
$storagebk = null;
if (isset($vars['default_storage_bk'])) {
try {
$storagebk = FileStorageBackend::lookup($vars['default_storage_bk']);
} catch (Exception $ex) {
$errors['default_storage_bk'] = $ex->getMessage();
}
}
if(!Validator::process($f, $vars, $errors) || $errors)
return false;
......@@ -1039,6 +1050,10 @@ class OsticketConfig extends Config {
}
$secondary_langs = implode(',', $vars['secondary_langs']);
if ($storagebk)
$this->update('default_storage_bk', $storagebk->getBkChar());
return $this->updateAll(array(
'isonline'=>$vars['isonline'],
'helpdesk_title'=>$vars['helpdesk_title'],
......@@ -1057,6 +1072,7 @@ class OsticketConfig extends Config {
'default_locale'=>$vars['default_locale'],
'system_language'=>$vars['system_language'],
'secondary_langs'=>$secondary_langs,
'max_file_size' => $vars['max_file_size'],
));
}
......@@ -1119,9 +1135,6 @@ class OsticketConfig extends Config {
if(!Validator::process($f, $vars, $errors) || $errors)
return false;
if (isset($vars['default_storage_bk']))
$this->update('default_storage_bk', $vars['default_storage_bk']);
return $this->updateAll(array(
'ticket_number_format'=>$vars['ticket_number_format'] ?: '######',
'ticket_sequence_id'=>$vars['ticket_sequence_id'] ?: 0,
......@@ -1139,7 +1152,6 @@ class OsticketConfig extends Config {
'hide_staff_name'=>isset($vars['hide_staff_name'])?1:0,
'enable_html_thread'=>isset($vars['enable_html_thread'])?1:0,
'allow_client_updates'=>isset($vars['allow_client_updates'])?1:0,
'max_file_size'=>$vars['max_file_size'],
));
}
......
......@@ -115,3 +115,23 @@ secondary_language:
The interface will be available in these languages, and custom
content, such as thank-you pages and help topic names, will be
translatable to these languages.
# Attachments
attachments:
title: Attachment Settings and Storage
content: >
Configure how attachments are stored.
default_storage_bk:
title: File Storage Backend
content: >
Choose how attachments are stored.
<br<br>
Additional storage backends can be added by installing storage plugins
max_file_size:
title: Maximum File Size
content: >
Choose a maximum file size for attachments uploaded by agents. This
includes canned attachments, knowledge base articles, and
attachments to ticket and task replies.
......@@ -136,9 +136,3 @@ ticket_attachment_settings:
are used for all new tickets and new messages regardless of the
source channel (web portal, email, api, etc.).
max_file_size:
title: Maximum File Size
content: >
Choose a maximum file size for attachments uploaded by agents. This
includes canned attachments, knowledge base articles, and
attachments to ticket replies.
......@@ -281,6 +281,73 @@ $gmtime = Misc::gmtime();
<span class="error">&nbsp;<?php echo $errors['add_secondary_language']; ?></span>
<i class="help-tip icon-question-sign" href="#secondary_language"></i>
</td></tr>
<tr>
<th colspan="2">
<em><b><?php echo __('Attachments Storage and Settings');?></b>:<i
class="help-tip icon-question-sign" href="#attachments"></i></em>
</th>
</tr>
<tr>
<td width="180"><?php echo __('Store Attachments'); ?>:</td>
<td><select name="default_storage_bk"><?php
if (($bks = FileStorageBackend::allRegistered())) {
foreach ($bks as $char=>$class) {
$selected = $config['default_storage_bk'] == $char
? 'selected="selected"' : '';
?><option <?php echo $selected; ?> value="<?php echo $char; ?>"
><?php echo $class::$desc; ?></option><?php
}
} else {
echo sprintf('<option value="">%s</option>',
__('Select Storage Backend'));
}?>
</select>
&nbsp;<font class="error">*&nbsp;<?php echo
$errors['default_storage_bk']; ?></font>
<i class="help-tip icon-question-sign"
href="#default_storage_bk"></i>
</td>
</tr>
<tr>
<td width="180"><?php echo __(
// Maximum size for agent-uploaded files (via SCP)
'Agent Maximum File Size');?>:</td>
<td>
<select name="max_file_size">
<option value="262144">&mdash; <?php echo __('Small'); ?> &mdash;</option>
<?php $next = 512 << 10;
$max = strtoupper(ini_get('upload_max_filesize'));
$limit = (int) $max;
if (!$limit) $limit = 2 << 20; # 2M default value
elseif (strpos($max, 'K')) $limit <<= 10;
elseif (strpos($max, 'M')) $limit <<= 20;
elseif (strpos($max, 'G')) $limit <<= 30;
while ($next <= $limit) {
// Select the closest, larger value (in case the
// current value is between two)
$diff = $next - $config['max_file_size'];
$selected = ($diff >= 0 && $diff < $next / 2)
? 'selected="selected"' : ''; ?>
<option value="<?php echo $next; ?>" <?php echo $selected;
?>><?php echo Format::file_size($next);
?></option><?php
$next *= 2;
}
// Add extra option if top-limit in php.ini doesn't fall
// at a power of two
if ($next < $limit * 2) {
$selected = ($limit == $config['max_file_size'])
? 'selected="selected"' : ''; ?>
<option value="<?php echo $limit; ?>" <?php echo $selected;
?>><?php echo Format::file_size($limit);
?></option><?php
}
?>
</select>
<i class="help-tip icon-question-sign" href="#max_file_size"></i>
<div class="error"><?php echo $errors['max_file_size']; ?></div>
</td>
</tr>
</tbody>
</table>
<p style="padding-left:250px;">
......
......@@ -234,60 +234,6 @@ if(!($maxfileuploads=ini_get('max_file_uploads')))
<i class="help-tip icon-question-sign" href="#ticket_attachment_settings"></i>
</td>
</tr>
<tr>
<td width="180"><?php echo __(
// Maximum size for agent-uploaded files (via SCP)
'Agent Maximum File Size');?>:</td>
<td>
<select name="max_file_size">
<option value="262144">&mdash; <?php echo __('Small'); ?> &mdash;</option>
<?php $next = 512 << 10;
$max = strtoupper(ini_get('upload_max_filesize'));
$limit = (int) $max;
if (!$limit) $limit = 2 << 20; # 2M default value
elseif (strpos($max, 'K')) $limit <<= 10;
elseif (strpos($max, 'M')) $limit <<= 20;
elseif (strpos($max, 'G')) $limit <<= 30;
while ($next <= $limit) {
// Select the closest, larger value (in case the
// current value is between two)
$diff = $next - $config['max_file_size'];
$selected = ($diff >= 0 && $diff < $next / 2)
? 'selected="selected"' : ''; ?>
<option value="<?php echo $next; ?>" <?php echo $selected;
?>><?php echo Format::file_size($next);
?></option><?php
$next *= 2;
}
// Add extra option if top-limit in php.ini doesn't fall
// at a power of two
if ($next < $limit * 2) {
$selected = ($limit == $config['max_file_size'])
? 'selected="selected"' : ''; ?>
<option value="<?php echo $limit; ?>" <?php echo $selected;
?>><?php echo Format::file_size($limit);
?></option><?php
}
?>
</select>
<i class="help-tip icon-question-sign" href="#max_file_size"></i>
<div class="error"><?php echo $errors['max_file_size']; ?></div>
</td>
</tr>
<?php if (($bks = FileStorageBackend::allRegistered())
&& count($bks) > 1) { ?>
<tr>
<td width="180"><?php echo __('Store Attachments'); ?>:</td>
<td><select name="default_storage_bk"><?php
foreach ($bks as $char=>$class) {
$selected = $config['default_storage_bk'] == $char
? 'selected="selected"' : '';
?><option <?php echo $selected; ?> value="<?php echo $char; ?>"
><?php echo $class::$desc; ?></option><?php
} ?>
</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment