function apply_icconffields($req)
{
    global $CONFIG;
    set_time_limit(0);
    //this avoids timeouts
    include $CONFIG->path . "mod/profile_manager/views/default/profile_manager/members/config.php";
    $new_indexing_req = 0;
    $fields_metadata_string = array2string(json_decode($req["fields_metadata"]));
    $fields_uses_string = array2string(json_decode($req["fields_uses"]));
    $fields_tags_string = array2string(json_decode($req["fields_tags"]));
    $classification_methods = array("Kohonen" => 1, "Aggregative" => 2, "YACA" => 3);
    $config_values = processFileForOptions($CONFIG->path . "mod/profile_manager/views/default/profile_manager/members/config.php");
    //it reads an option from the config file (it creates an array with form array["option"]=value)
    if ($req["datasource_select"] == "sesame") {
        $config_values = substituteOption($config_values, "data_source", 1);
    } elseif ($req["datasource_select"] == "elggdb") {
        $config_values = substituteOption($config_values, "data_source", 2);
    }
    if (substr($config_values["metadata_fields"], 1, -1) != $fields_metadata_string) {
        $config_values = substituteOption($config_values, "metadata_fields", $fields_metadata_string);
        $new_indexing_req = 1;
    }
    if (substr($config_values["uses_fields"], 1, -1) != $fields_uses_string) {
        $config_values = substituteOption($config_values, "uses_fields", $fields_uses_string);
        $new_indexing_req = 1;
    }
    if (substr($config_values["tags_fields"], 1, -1) != $fields_tags_string) {
        $config_values = substituteOption($config_values, "tags_fields", $fields_tags_string);
        $new_indexing_req = 1;
    }
    $config_values = substituteOption($config_values, "keywords_limit", $req["text_numkeywords"]);
    $config_values = substituteOption($config_values, "context_limit", $req["text_numcontexts"]);
    $config_values = substituteOption($config_values, "width_sliding_window", $req["text_slidingwindow_width"]);
    if ($req["idf_chkbx"] == "true") {
        $config_values = substituteOption($config_values, "enable_idf", 1);
    } else {
        $config_values = substituteOption($config_values, "enable_idf", 0);
    }
    if ($req["synonyms_chkbx"] == "true") {
        $config_values = substituteOption($config_values, "enable_synonyms", 1);
    } else {
        $config_values = substituteOption($config_values, "enable_synonyms", 0);
    }
    if (isset($req["text_syn_db_host"])) {
        $config_values = substituteOption($config_values, "syn_db_host", $req["text_syn_db_host"]);
    }
    if (isset($req["text_syn_db_user"])) {
        $config_values = substituteOption($config_values, "syn_db_user", $req["text_syn_db_user"]);
    }
    if (isset($req["text_syn_db_pass"])) {
        $config_values = substituteOption($config_values, "syn_db_pass", $req["text_syn_db_pass"]);
    }
    if (isset($req["text_syn_db_name"])) {
        $config_values = substituteOption($config_values, "syn_db_name", $req["text_syn_db_name"]);
    }
    $config_values = substituteOption($config_values, "classification_method_metadata", $classification_methods[$req["metadata_select"]]);
    $config_values = substituteOption($config_values, "classification_method_tags", $classification_methods[$req["tags_select"]]);
    $config_values = substituteOption($config_values, "classification_method_uses", $classification_methods[$req["uses_select"]]);
    $config_values = substituteOption($config_values, "classification_method_replinks", $classification_methods[$req["replinks_select"]]);
    if (isset($req["text_kohonen_output"])) {
        $config_values = substituteOption($config_values, "output_file_kohonen", $req["text_kohonen_output"]);
    }
    if (isset($req["text_yaca_threshold"])) {
        $config_values = substituteOption($config_values, "YACA_threshold", $req["text_yaca_threshold"]);
    }
    if (isset($req["text_min_threshold"])) {
        $config_values = substituteOption($config_values, "minimum_association_threshold", $req["text_min_threshold"]);
    }
    write_config_values($config_values, $CONFIG->path . "mod/profile_manager/views/default/profile_manager/members/config.php");
    //it saves the options from the array to the config file
    if ($new_indexing_req == 1) {
        $changes = unserialize(file_get_contents($IOdir . "changes"));
        //if the file doesn't exist, it doesn't matter
        $changes["new_indexing_required"] = 1;
        //mark the file new_indexing in order to force a new indexing
        file_put_contents($IOdir . "changes", serialize($changes));
    }
    //it saves all the changes in the config file of the old command-line interface
    if ($config_values["IndexingClassificationPath"] != "undefined" && file_exists(substr($config_values["IndexingClassificationPath"], 1, -1) . "config.php")) {
        $IndexingClassificationPath = substr($config_values["IndexingClassificationPath"], 1, -1);
        $config_values = array();
        $config_values = processFileForOptions($IndexingClassificationPath . "config.php");
        //it reads an option from the config file (it creates an array with form array["option"]=value)
        if ($req["datasource_select"] == "sesame") {
            $config_values = substituteOption($config_values, "data_source", 1);
        } elseif ($req["datasource_select"] == "elggdb") {
            $config_values = substituteOption($config_values, "data_source", 2);
        }
        if (substr($config_values["metadata_fields"], 1, -1) != $fields_metadata_string) {
            $config_values = substituteOption($config_values, "metadata_fields", $fields_metadata_string);
            $new_indexing_req = 1;
        }
        if (substr($config_values["uses_fields"], 1, -1) != $fields_uses_string) {
            $config_values = substituteOption($config_values, "uses_fields", $fields_uses_string);
            $new_indexing_req = 1;
        }
        if (substr($config_values["tags_fields"], 1, -1) != $fields_tags_string) {
            $config_values = substituteOption($config_values, "tags_fields", $fields_tags_string);
            $new_indexing_req = 1;
        }
        $config_values = substituteOption($config_values, "keywords_limit", $req["text_numkeywords"]);
        $config_values = substituteOption($config_values, "context_limit", $req["text_numcontexts"]);
        $config_values = substituteOption($config_values, "width_sliding_window", $req["text_slidingwindow_width"]);
        if ($req["idf_chkbx"] == "true") {
            $config_values = substituteOption($config_values, "enable_idf", 1);
        } else {
            $config_values = substituteOption($config_values, "enable_idf", 0);
        }
        if ($req["synonyms_chkbx"] == "true") {
            $config_values = substituteOption($config_values, "enable_synonyms", 1);
        } else {
            $config_values = substituteOption($config_values, "enable_synonyms", 0);
        }
        if (isset($req["text_syn_db_host"])) {
            $config_values = substituteOption($config_values, "syn_db_host", $req["text_syn_db_host"]);
        }
        if (isset($req["text_syn_db_user"])) {
            $config_values = substituteOption($config_values, "syn_db_user", $req["text_syn_db_user"]);
        }
        if (isset($req["text_syn_db_pass"])) {
            $config_values = substituteOption($config_values, "syn_db_pass", $req["text_syn_db_pass"]);
        }
        if (isset($req["text_syn_db_name"])) {
            $config_values = substituteOption($config_values, "syn_db_name", $req["text_syn_db_name"]);
        }
        $config_values = substituteOption($config_values, "classification_method_metadata", $classification_methods[$req["metadata_select"]]);
        $config_values = substituteOption($config_values, "classification_method_tags", $classification_methods[$req["tags_select"]]);
        $config_values = substituteOption($config_values, "classification_method_uses", $classification_methods[$req["uses_select"]]);
        $config_values = substituteOption($config_values, "classification_method_replinks", $classification_methods[$req["replinks_select"]]);
        if (isset($req["text_kohonen_output"])) {
            $config_values = substituteOption($config_values, "output_file_kohonen", $req["text_kohonen_output"]);
        }
        if (isset($req["text_yaca_threshold"])) {
            $config_values = substituteOption($config_values, "YACA_threshold", $req["text_yaca_threshold"]);
        }
        if (isset($req["text_min_threshold"])) {
            $config_values = substituteOption($config_values, "minimum_association_threshold", $req["text_min_threshold"]);
        }
        write_config_values($config_values, $IndexingClassificationPath . "config.php");
        //it saves the options from the array to the config file
    }
    return true;
}
function savefields($req)
{
    $fields_loms_string = array2string(json_decode($req["fields_loms_json"]));
    $fields_uses_string = array2string(json_decode($req["fields_uses_json"]));
    $fields_tags_string = array2string(json_decode($req["fields_tags_json"]));
    $config_values = processFileForOptions($req['file']);
    //it reads an option from the file specified (it creates an array with form array["option"]=value)
    $config_values = substituteOption($config_values, "loms_fields", $fields_loms_string);
    $config_values = substituteOption($config_values, "uses_fields", $fields_uses_string);
    $config_values = substituteOption($config_values, "tags_fields", $fields_tags_string);
    write_config_values($config_values, $req['file']);
    //it saves the options from the array to the file indicated
    return true;
}