Getting started adding custom field descriptions
This commit is contained in:
parent
6d632be7b8
commit
745ecd42aa
@ -166,7 +166,31 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php');
|
|||||||
</div>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
$descriptions = hesk_SESSION(array('new_cf','descriptions')); ?>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="description[]" class="col-sm-3 control-label">
|
||||||
|
<?php echo $hesklang['description']; ?>
|
||||||
|
</label>
|
||||||
|
<?php if ($hesk_settings['can_sel_lang'] && count($hesk_settings['languages']) > 1): ?>
|
||||||
|
<table border="0">
|
||||||
|
<?php foreach ($hesk_settings['languages'] as $lang => $info): ?>
|
||||||
|
<tr>
|
||||||
|
<td><?php echo $lang; ?></td>
|
||||||
|
<td>
|
||||||
|
<textarea class="form-control"
|
||||||
|
name="description[<?php echo $lang; ?>]"><?php echo (isset($descriptions[$lang]) ? $descriptions[$lang] : ''); ?></textarea>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</table>
|
||||||
|
<?php else: ?>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<textarea class="form-control"
|
||||||
|
name="description[<?php echo $hesk_settings['language']; ?>]"><?php echo (isset($descriptions[$hesk_settings['language']]) ? $descriptions[$hesk_settings['language']] : ''); ?></textarea>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="name[]" class="col-sm-3 control-label">
|
<label for="name[]" class="col-sm-3 control-label">
|
||||||
@ -772,7 +796,16 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php');
|
|||||||
?>
|
?>
|
||||||
<tr>
|
<tr>
|
||||||
<td><?php echo $tmp_id; ?></td>
|
<td><?php echo $tmp_id; ?></td>
|
||||||
<td><?php echo $cf['name']; ?></td>
|
<td>
|
||||||
|
<?php
|
||||||
|
echo $cf['name'];
|
||||||
|
if ($cf['mfh_description'] !== null && trim($cf['mfh_description']) !== '') {
|
||||||
|
echo ' <i class="fa fa-info-circle" data-toggle="popover"
|
||||||
|
data-title="' . htmlspecialchars($hesklang['description']) . '"
|
||||||
|
data-content="' . htmlspecialchars($cf['mfh_description']) . '"></i>';
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</td>
|
||||||
<td><?php echo $cf['type']; ?></td>
|
<td><?php echo $cf['type']; ?></td>
|
||||||
<td><?php echo $cf['use']; ?></td>
|
<td><?php echo $cf['use']; ?></td>
|
||||||
<td><?php echo $cf['req']; ?></td>
|
<td><?php echo $cf['req']; ?></td>
|
||||||
@ -916,6 +949,9 @@ function edit_cf()
|
|||||||
$cf['names'] = json_decode($cf['name'], true);
|
$cf['names'] = json_decode($cf['name'], true);
|
||||||
unset($cf['name']);
|
unset($cf['name']);
|
||||||
|
|
||||||
|
$cf['descriptions'] = json_decode($cf['mfh_description'], true);
|
||||||
|
unset($cf['mfh_description']);
|
||||||
|
|
||||||
if (strlen($cf['category']))
|
if (strlen($cf['category']))
|
||||||
{
|
{
|
||||||
$cf['categories'] = json_decode($cf['category'], true);
|
$cf['categories'] = json_decode($cf['category'], true);
|
||||||
@ -1057,6 +1093,27 @@ function cf_validate()
|
|||||||
$hesk_error_buffer[] = $hesklang['err_custname'];
|
$hesk_error_buffer[] = $hesklang['err_custname'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Descriptions
|
||||||
|
$cf['descriptions'] = hesk_POST_array('descriptions');
|
||||||
|
|
||||||
|
// Make sure only non-empty descriptions pass
|
||||||
|
foreach ($cf['descriptions'] as $key => $description) {
|
||||||
|
if (!isset($hesk_settings['languages'][$key])) {
|
||||||
|
unset($cf['descriptions'][$key]);
|
||||||
|
} else {
|
||||||
|
$description = is_array($description) ? '' : hesk_input($description, 0, 0, HESK_SLASH);
|
||||||
|
|
||||||
|
if (strlen($description) < 1)
|
||||||
|
{
|
||||||
|
unset($cf['descriptions'][$key]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$cf['descriptions'][$key] = stripslashes($description);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Get type and values
|
// Get type and values
|
||||||
$cf['type'] = hesk_POST('type');
|
$cf['type'] = hesk_POST('type');
|
||||||
switch ($cf['type'])
|
switch ($cf['type'])
|
||||||
@ -1264,6 +1321,7 @@ function cf_validate()
|
|||||||
}
|
}
|
||||||
|
|
||||||
$cf['names'] = addslashes(json_encode($cf['names']));
|
$cf['names'] = addslashes(json_encode($cf['names']));
|
||||||
|
$cf['descriptions'] = addslashes(json_encode($cf['descriptions']));
|
||||||
$cf['value'] = $cf['type'] == 'date' ? json_encode($cf['value']) : addslashes(json_encode($cf['value']));
|
$cf['value'] = $cf['type'] == 'date' ? json_encode($cf['value']) : addslashes(json_encode($cf['value']));
|
||||||
|
|
||||||
return $cf;
|
return $cf;
|
||||||
@ -1305,6 +1363,7 @@ function new_cf()
|
|||||||
`req` = '{$cf['req']}',
|
`req` = '{$cf['req']}',
|
||||||
`category` = ".(count($cf['categories']) ? "'".json_encode($cf['categories'])."'" : 'NULL').",
|
`category` = ".(count($cf['categories']) ? "'".json_encode($cf['categories'])."'" : 'NULL').",
|
||||||
`name` = '".hesk_dbEscape($cf['names'])."',
|
`name` = '".hesk_dbEscape($cf['names'])."',
|
||||||
|
`mfh_description` = '".hesk_dbEscape($cf['mfh_description'])."',
|
||||||
`value` = ".(strlen($cf['value']) ? "'".hesk_dbEscape($cf['value'])."'" : 'NULL').",
|
`value` = ".(strlen($cf['value']) ? "'".hesk_dbEscape($cf['value'])."'" : 'NULL').",
|
||||||
`order` = 990
|
`order` = 990
|
||||||
WHERE `id`={$_SESSION['cford']}");
|
WHERE `id`={$_SESSION['cford']}");
|
||||||
|
@ -77,6 +77,12 @@ function hesk_load_custom_fields($category=0, $use_cache=1)
|
|||||||
// Decode options
|
// Decode options
|
||||||
$row['value'] = json_decode($row['value'], true);
|
$row['value'] = json_decode($row['value'], true);
|
||||||
|
|
||||||
|
// Description
|
||||||
|
$descriptions = strlen($row['mfh_description']) ? json_decode($row['mfh_description'], true) : array();
|
||||||
|
$row['mfh_description'] = (isset($descriptions[$hesk_settings['language']])) ?
|
||||||
|
$descriptions[$hesk_settings['language']] :
|
||||||
|
reset($descriptions);
|
||||||
|
|
||||||
// Add to custom_fields array
|
// Add to custom_fields array
|
||||||
$hesk_settings['custom_fields'][$id] = $row;
|
$hesk_settings['custom_fields'][$id] = $row;
|
||||||
}
|
}
|
||||||
|
@ -1138,6 +1138,14 @@ function execute320Scripts() {
|
|||||||
|
|
||||||
executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "categories`
|
executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "categories`
|
||||||
ADD COLUMN `mfh_description` VARCHAR(255)");
|
ADD COLUMN `mfh_description` VARCHAR(255)");
|
||||||
|
executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "custom_fields`
|
||||||
|
ADD COLUMN `mfh_description` VARCHAR(255)");
|
||||||
|
|
||||||
|
// Purge the custom field caches as we're adding a new field
|
||||||
|
foreach ($hesk_settings['languages'] as $key => $value) {
|
||||||
|
$language_hash = sha1($key);
|
||||||
|
hesk_unlink(HESK_PATH . "cache/cf_{$language_hash}.cache.php");
|
||||||
|
}
|
||||||
|
|
||||||
updateVersion('3.2.0');
|
updateVersion('3.2.0');
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user