protected function add_missing_fields(array $record)
{
if (!isset($record['enable_bbcode'], $record['enable_smilies'], $record['enable_magic_url'])) {
if (isset($record['options'])) {
$record += array('enable_bbcode' => (bool) ($record['options'] & OPTION_FLAG_BBCODE), 'enable_smilies' => (bool) ($record['options'] & OPTION_FLAG_SMILIES), 'enable_magic_url' => (bool) ($record['options'] & OPTION_FLAG_LINKS));
} else {
$record += array('enable_bbcode' => $this->guess_bbcodes($record), 'enable_smilies' => $this->guess_smilies($record), 'enable_magic_url' => $this->guess_magic_url($record));
}
}
// Those BBCodes are disabled based on context and user permissions and that value is never
// stored in the database. Here we test whether they were used in the original text.
$bbcodes = array('flash', 'img', 'quote', 'url');
foreach ($bbcodes as $bbcode) {
$field_name = 'enable_' . $bbcode . '_bbcode';
$record[$field_name] = $this->guess_bbcode($record, $bbcode);
}
// Magic URLs are tied to the URL BBCode, that's why if magic URLs are enabled we make sure
// that the URL BBCode is also enabled
if ($record['enable_magic_url']) {
$record['enable_url_bbcode'] = true;
}
return $record;
}