create language plpgsql;
CREATE OR REPLACE FUNCTION atualiza_phpgw_config() RETURNS VOID AS
$$
BEGIN

        BEGIN
        insert into phpgw_config (config_app,config_name,config_value) values('phpgwapi','site_title','Expresso Livre -  SERPRO');
        EXCEPTION WHEN unique_violation THEN
            update phpgw_config set config_value='Expresso Livre - SERPRO' where config_app='phpgwapi' and config_name='site_title';
        END;
	
        BEGIN
        insert into phpgw_config (config_app,config_name,config_value) values('phpgwapi','login_logo_url','http://www.serpro.gov.br');
        EXCEPTION WHEN unique_violation THEN
            update phpgw_config set config_value='http://www.serpro.gov.br' where config_app='phpgwapi' and config_name='login_logo_url';
        END;
	
        BEGIN
        insert into phpgw_config (config_app,config_name,config_value) values('phpgwapi','login_logo_title','Serviço Federal de Processamento de Dados - SERPRO');
        EXCEPTION WHEN unique_violation THEN
            update phpgw_config set config_value='Serviço Federal de Processamento de Dados - SERPRO' where config_app='phpgwapi' and config_name='login_logo_title';
        END;	
	
        BEGIN
        insert into phpgw_config (config_app,config_name,config_value) values('phpgwapi','login_logo_file','logo.png');
        EXCEPTION WHEN unique_violation THEN
            update phpgw_config set config_value='logo.png' where config_app='phpgwapi' and config_name='login_logo_file';
        END;		

        BEGIN
        insert into phpgw_config (config_app,config_name,config_value) values('phpgwapi','login_bg_color','FFFFFF');
        EXCEPTION WHEN unique_violation THEN
            update phpgw_config set config_value='FFFFFF' where config_app='phpgwapi' and config_name='login_bg_color';
        END;		
	
        BEGIN
        insert into phpgw_config (config_app,config_name,config_value) values('phpgwapi','login_caixa_bg_color','FFFFFF');
        EXCEPTION WHEN unique_violation THEN
            update phpgw_config set config_value='FFFFFF' where config_app='phpgwapi' and config_name='login_caixa_bg_color';
        END;		
	
        BEGIN
        insert into phpgw_config (config_app,config_name,config_value) values('phpgwapi','imagem_de_fundo_exibicao','background-repeat:repeat-x; overflow:auto;overflow-x:hidden;');
        EXCEPTION WHEN unique_violation THEN
            update phpgw_config set config_value='background-repeat:repeat-x; overflow:auto;overflow-x:hidden;' where config_app='phpgwapi' and config_name='imagem_de_fundo_exibicao';
        END;		

        BEGIN
        insert into phpgw_config (config_app,config_name,config_value) values('phpgwapi','imagem_de_fundo','back.jpg');
        EXCEPTION WHEN unique_violation THEN
            update phpgw_config set config_value='back.jpg' where config_app='phpgwapi' and config_name='imagem_de_fundo';
        END;		

        BEGIN
        insert into phpgw_config (config_app,config_name,config_value) values('phpgwapi','image_navbar_left','inicio.jpg');
        EXCEPTION WHEN unique_violation THEN
            update phpgw_config set config_value='inicio.jpg' where config_app='phpgwapi' and config_name='image_navbar_left';
        END;		

        BEGIN
        insert into phpgw_config (config_app,config_name,config_value) values('phpgwapi','image_navbar_right','logo_expresso_transparente.png');
        EXCEPTION WHEN unique_violation THEN
            update phpgw_config set config_value='logo_expresso_transparente.png' where config_app='phpgwapi' and config_name='image_navbar_right';
        END;		
	
        BEGIN
        insert into phpgw_config (config_app,config_name,config_value) values('phpgwapi','image_navbar_bg','fundo_topo.gif');
        EXCEPTION WHEN unique_violation THEN
            update phpgw_config set config_value='fundo_topo.gif' where config_app='phpgwapi' and config_name='image_navbar_bg';
        END;			
	
END;
$$
LANGUAGE plpgsql;

select atualiza_phpgw_config();

drop function atualiza_phpgw_config();

VACUUM phpgw_config;


