$PAGE->requires->js('/local/vmoodle/js/host_form.js');
// It must be included from 'view.php' in local/vmoodle.
if (!defined('MOODLE_INTERNAL')) {
    die('Direct access to this script is forbidden.');
}
// Confirmation message.
$message_object = new StdClass();
$message_object->message = '';
$message_object->style = 'notifyproblem';
// Execution time can take more than 30 sec (PHP default value).
$initial_max_execution_time = ini_get('max_execution_time');
if ($initial_max_execution_time > 0) {
    set_time_limit(0);
}
// For a 'block' plugin config values are autoloaded into global config but not for a 'local' plugin
vmoodle_setup_local_config();
/**************************** Make the ADD form ************/
if ($action == 'add') {
    // Test the number of templates.
    $templates = vmoodle_get_available_templates();
    if (!empty($templates)) {
        // Default configuration (automated schema).
        if (@$CFG->local_vmoodle_automatedschema) {
            $platform_form = new StdClass();
            $platform_form->vhostname = @$CFG->local_vmoodle_vmoodlehost ? $CFG->local_vmoodle_vmoodlehost : 'localhost';
            $platform_form->vdbtype = @$CFG->local_vmoodle_vdbtype ? $CFG->local_vmoodle_vdbtype : 'mysqli';
            $platform_form->vdbhost = @$CFG->local_vmoodle_vdbhost ? $CFG->local_vmoodle_vdbhost : 'localhost';
            $platform_form->vdblogin = $CFG->local_vmoodle_vdblogin;
            $platform_form->vdbpass = $CFG->local_vmoodle_vdbpass;
            $platform_form->vdbname = $CFG->local_vmoodle_vdbbasename;
            $platform_form->vdbprefix = @$CFG->local_vmoodle_vdbprefix ? $CFG->local_vmoodle_vdbprefix : 'mdl_';
Example #2
0
/**
 * Check a CSV input line format for empty or commented lines
 * Ensures compatbility to UTF-8 BOM or unBOM formats
 */
function vmoodle_is_empty_line_or_format(&$text, $resetfirst = false)
{
    global $CFG;
    vmoodle_setup_local_config();
    static $first = true;
    // We may have a risk the BOM is present on first line.
    if ($resetfirst) {
        $first = true;
    }
    if ($first && $CFG->local_vmoodle_encoding == 'UTF-8') {
        $text = core_text::trim_utf8_bom($text);
        $first = false;
    }
    $text = preg_replace("/\n?\r?/", '', $text);
    if ($CFG->local_vmoodle_encoding != 'UTF-8') {
        $text = utf8_encode($text);
    }
    // last chance
    if ('ASCII' == mb_detect_encoding($text)) {
        $text = utf8_encode($text);
    }
    // Check the text is empty or comment line and answer true if it is
    return preg_match('/^$/', $text) || preg_match('/^(\\(|\\[|-|#|\\/| )/', $text);
}