Esempio n. 1
0
function update_set_from_form()
{
    global $msg, $charset, $dbh, $id;
    global $set_type, $set_caption;
    if (!$id) {
        //Ajout d'un nouveau set
        if (!$set_caption) {
            print $msg['admin_connecteurs_set_emptyfield'];
            show_set_form(0, stripslashes($set_type), stripslashes($set_caption));
            return false;
        }
        if (connector_out_set::caption_exists($set_caption)) {
            print $msg['admin_connecteurs_set_namealreadyexists'];
            show_set_form(0, stripslashes($set_type), stripslashes($set_caption));
            return false;
        }
        $new_set = connector_out_set::add_new();
        $new_set->type = $set_type;
        $new_set->caption = stripslashes($set_caption);
        $new_set->commit_to_db();
    } else {
        $theset = new_connector_out_set_typed($id);
        if ($theset->error) {
            return false;
        }
        $theset->type = $set_type;
        $theset->caption = stripslashes($set_caption);
        $theset->update_config_from_form();
        $theset->cache->update_from_form();
        $theset->commit_to_db();
        $theset->cache->commit_to_db();
    }
    return true;
}