Example #1
0
/**
 * Update the configuration for this database activity.
 *
 * @param   stdClass    $database   The object returned from the database for this instance
 * @param   string      $key        The name of the key to set
 * @param   mixed       $value      The value to set for the key
 */
function data_set_config(&$database, $key, $value)
{
    // Note: We must pass $database by reference because there may be subsequent calls to update_record and these should
    // not overwrite the configuration just set.
    global $DB;
    $config = data_get_config($database);
    if (!isset($config->{$key}) || $config->{$key} !== $value) {
        $config->{$key} = $value;
        $database->config = json_encode($config);
        $DB->set_field('data', 'config', $database->config, ['id' => $database->id]);
    }
}
Example #2
0
/// If everything is empty then generate some defaults
if (empty($data->addtemplate) and empty($data->singletemplate) and empty($data->listtemplate) and empty($data->rsstemplate)) {
    data_generate_default_template($data, 'singletemplate');
    data_generate_default_template($data, 'listtemplate');
    data_generate_default_template($data, 'addtemplate');
    data_generate_default_template($data, 'asearchtemplate');
    //Template for advanced searches.
    data_generate_default_template($data, 'rsstemplate');
}
editors_head_setup();
// Determine whether to use HTML editors.
if ($mode === 'csstemplate' || $mode === 'jstemplate') {
    // The CSS and JS templates aren't HTML.
    $usehtmleditor = false;
} else {
    $usehtmleditor = data_get_config($data, "editor_{$mode}", true);
}
if ($usehtmleditor) {
    $format = FORMAT_HTML;
} else {
    $format = FORMAT_PLAIN;
}
$editor = editors_get_preferred_editor($format);
$strformats = format_text_menu();
$formats = $editor->get_supported_formats();
foreach ($formats as $fid) {
    $formats[$fid] = $strformats[$fid];
}
$options = array();
$options['trusttext'] = false;
$options['forcehttps'] = false;