UPDATE gui_element_vars set 
var_value =
'{"A4 landscape": "A4_landscape_template.json","A4 portrait": "A4_portrait_template.json","A4 landscape": "A4_landscape_template.json",
"A4 landscape official": "A4_landscape_official_template.json",
"A4 portrait official": "A4_portrait_official_template.json",
"A4 portrait (map only)": "A4_portrait_template_pure_map.json",
"A3 landscape": "A3_landscape_template.json","A3 portrait": "A3_portrait_template.json",
"A3 landscape official": "A3_landscape_official_template.json",
"A3 portrait official": "A3_portrait_official_template.json",
"A3 portrait (map only)": "A3_portrait_template_pure_map.json",
"A2 landscape": "A2_landscape_template.json",
"A1 landscape": "A1_landscape_template.json",
"A0 landscape": "A0_landscape_template.json"
}'
where fkey_gui_id = 'template_print' and fkey_e_id = 'printPDF' and var_name = 'mbPrintConfig';

UPDATE gui_element set e_width = 28, e_height = 28
where fkey_gui_id = 'template_print' and e_id ='printButton' ;

UPDATE gui_element  SET e_more_styles = '' WHERE e_id = 'showCoords_div'  AND e_more_styles LIKE 'background-color:white%';

-- replace too many ' in definition
UPDATE gui_element set e_attributes = replace(e_attributes,'''"','"') where e_id IN ('updateWMSs','owsproxy','editGUI_WMS');

--add possibility to edit cyclic update in inspire metadata addon editor (admin_wms_metadata):
-- Column: update_frequency

-- ALTER TABLE mb_metadata DROP COLUMN update_frequency;

ALTER TABLE mb_metadata ADD COLUMN update_frequency character varying(100);



-- new option for metadata publishing in Administration_DE GUI

INSERT INTO gui_element (fkey_gui_id, e_id, e_pos, e_public, e_comment, e_title, e_element,e_src, e_attributes, e_left, e_top, e_width, e_height, e_z_index, e_more_styles, e_content, e_closetag, e_js_file, e_mb_mod, e_target, e_requires,e_url) VALUES ('Administration_DE','allowPublishMetadata_collection',2,1,'Put existing divs in new div object. List the elements comma-separated under target, and make sure they have a title.','','div','','',0,115,200,30,NULL ,'','','div','../plugins/mb_div_collection.js','','allowPublishMetadata,allowPublishMetadata_icon','','');

INSERT INTO gui_element (fkey_gui_id, e_id, e_pos, e_public, e_comment, e_title, e_element,e_src, e_attributes, e_left, e_top, e_width, e_height, e_z_index, e_more_styles, e_content, e_closetag, e_js_file, e_mb_mod, e_target, e_requires,e_url) VALUES ('Administration_DE','allowPublishMetadata',2,1,'Einrichtungen erlauben im Auftrag <br>Metadaten zu veröffentlichen','Einrichtungen erlauben im Auftrag <br>Metadaten zu veröffentlichen','a','','href = "../geoportal/mod_allow_publishing_metadata.php?sessionID&e_id_css=allowPublishMetadata" ',80,15,200,20,NULL ,'font-family: Arial, Helvetica, sans-serif; font-size : 12px; text-decoration : none; color: #808080;','Einrichtungen erlauben im Auftrag <br>Metadaten zu veröffentlichen','a','','','','AdminFrame','http://www.mapbender.org/index.php/user');
INSERT INTO gui_element_vars(fkey_gui_id, fkey_e_id, var_name, var_value, context, var_type) VALUES ('Administration_DE','allowPublishMetadata','adminGroupId','25','','php_var');
INSERT INTO gui_element_vars(fkey_gui_id, fkey_e_id, var_name, var_value, context, var_type) VALUES ('Administration_DE','allowPublishMetadata','authorizeRoleId','3','','php_var');
INSERT INTO gui_element_vars(fkey_gui_id, fkey_e_id, var_name, var_value, context, var_type) VALUES ('Administration_DE','allowPublishMetadata','file css','../css/allow_publishing_metadata.css','file css','file/css');
INSERT INTO gui_element (fkey_gui_id, e_id, e_pos, e_public, e_comment, e_title, e_element,e_src, e_attributes, e_left, e_top, e_width, e_height, e_z_index, e_more_styles, e_content, e_closetag, e_js_file, e_mb_mod, e_target, e_requires,e_url) VALUES ('Administration_DE','allowPublishMetadata_icon',2,1,'icon','','img','../img/gnome/emblem-shared.png','',0,0,NULL ,NULL,2,'','','','','','','','');

UPDATE gui_element SET e_target = 'filteredGui_user_collection,filteredGui_group_collection,filteredGui_filteredGroup_collection,gui_owner_collection,allowPublishMetadata_collection' WHERE fkey_gui_id = 'Administration_DE' AND e_id = 'menu_auth'; 

-- set width and height of body element to NULL for Gui admin2_de, otherwise this gui is not displayed correctly in IE8
UPDATE gui_element set e_width = NULL, e_height = NULL
where fkey_gui_id = 'admin2_de' and e_id ='body' ;

-- delete old entries from old treeConfiguration
DELETE FROM gui_treegde WHERE my_layer_title ILIKE 'new' AND wms_id IS NULL;

UPDATE gui_element set e_attributes = 'href = "../php/mod_category_filteredGUI.php?sessionID&e_id_css=category_filteredGUI"' where fkey_gui_id = 'Administration_DE' and e_id ='category_filteredGUI' ;

UPDATE gui_element set e_attributes = 'href = "../php/mod_category_filteredGUI.php?sessionID&e_id_css=category_filteredGUI"' where fkey_gui_id = 'Administration' and e_id ='category_filteredGUI' ;

--
-- refers to #786: after update the applications with savewmc and load wmc do not work as jq_ui_dialog and button are missing
--
INSERT INTO gui_element(fkey_gui_id, e_id, e_pos, e_public, e_comment, e_title, 
e_element, e_src, e_attributes, e_left, e_top, e_width, e_height, e_z_index, e_more_styles, 
e_content, e_closetag, e_js_file, e_mb_mod, e_target, e_requires, e_url) 
Select fkey_gui_id, foo.* from (
SELECT 'jq_ui_button',e_pos,e_public,e_comment,e_title,e_element, e_src, e_attributes, 
e_left, e_top, e_width, e_height, e_z_index, e_more_styles, e_content, e_closetag, 
e_js_file, e_mb_mod, e_target, e_requires, e_url FROM gui_element 
WHERE e_id = 'jq_ui_button' AND fkey_gui_id = 'gui1' 
) as foo , gui_element where e_id = 'loadwmc' AND fkey_gui_id IN 
 (SELECT fkey_gui_id FROM gui_element WHERE e_id = 'loadwmc' AND fkey_gui_id NOT IN (
	SELECT fkey_gui_id FROM gui_element WHERE e_id = 'jq_ui_button'
 ));


INSERT INTO gui_element(fkey_gui_id, e_id, e_pos, e_public, e_comment, e_title, 
e_element, e_src, e_attributes, e_left, e_top, e_width, e_height, e_z_index, e_more_styles, 
e_content, e_closetag, e_js_file, e_mb_mod, e_target, e_requires, e_url) 
Select fkey_gui_id, foo.* from (
SELECT 'jq_ui_dialog',e_pos,e_public,e_comment,e_title,e_element, e_src, e_attributes, 
e_left, e_top, e_width, e_height, e_z_index, e_more_styles, e_content, e_closetag, 
e_js_file, e_mb_mod, e_target, e_requires, e_url FROM gui_element 
WHERE e_id = 'jq_ui_dialog' AND fkey_gui_id = 'gui1' 
) as foo , gui_element where e_id = 'loadwmc' AND fkey_gui_id IN 
 (SELECT fkey_gui_id FROM gui_element WHERE e_id = 'loadwmc' AND fkey_gui_id NOT IN (
	SELECT fkey_gui_id FROM gui_element WHERE e_id = 'jq_ui_dialog'
 ));

-- Bugfix for ie9 startup problem. problem with dialogs remain - they cannot be dragged
UPDATE gui_element SET e_mb_mod = '../../lib/printbox.js,../extensions/jquery-ui-1.7.2.custom/development-bundle/external/bgiframe/jquery.bgiframe.js,../extensions/jquery.form.min.js,../extensions/wz_jsgraphics.js' 
WHERE e_id = 'printPDF' AND e_js_file = '../plugins/mb_print.php';

-- new element var unlink for gui element template printPDF
INSERT INTO gui_element_vars(fkey_gui_id, fkey_e_id, var_name, var_value, context, var_type)
SELECT gui_element.fkey_gui_id, 'printPDF', 'unlink', 'true', 'delete print pngs after pdf creation' ,'php_var'
FROM gui_element WHERE gui_element.e_id = 'printPDF' AND gui_element.e_js_file = '../plugins/mb_print.php' AND gui_element.fkey_gui_id
NOT IN (SELECT fkey_gui_id FROM gui_element_vars
WHERE var_name = 'unlink' AND fkey_e_id = 'printPDF');

-- new element var logRequests for gui element template printPDF
INSERT INTO gui_element_vars(fkey_gui_id, fkey_e_id, var_name, var_value, context, var_type)
SELECT gui_element.fkey_gui_id, 'printPDF', 'logRequests', 'false', 'log wms requests for debugging' ,'php_var'
FROM gui_element WHERE gui_element.e_id = 'printPDF' AND gui_element.e_js_file = '../plugins/mb_print.php' AND gui_element.fkey_gui_id
NOT IN (SELECT fkey_gui_id FROM gui_element_vars
WHERE var_name = 'logRequests' AND fkey_e_id = 'printPDF');

-- new element var logType for gui element template printPDF
INSERT INTO gui_element_vars(fkey_gui_id, fkey_e_id, var_name, var_value, context, var_type)
SELECT gui_element.fkey_gui_id, 'printPDF', 'logType', 'file', 'log mode can be set to file or db' ,'php_var'
FROM gui_element WHERE gui_element.e_id = 'printPDF' AND gui_element.e_js_file = '../plugins/mb_print.php' AND gui_element.fkey_gui_id
NOT IN (SELECT fkey_gui_id FROM gui_element_vars
WHERE var_name = 'logType' AND fkey_e_id = 'printPDF');

-- new element var timeout for gui element template printPDF
INSERT INTO gui_element_vars(fkey_gui_id, fkey_e_id, var_name, var_value, context, var_type)
SELECT gui_element.fkey_gui_id, 'printPDF', 'timeout', '90000', 'define maximum seconds to wait for print request finished' ,'var'
FROM gui_element WHERE gui_element.e_id = 'printPDF' AND gui_element.e_js_file = '../plugins/mb_print.php' AND gui_element.fkey_gui_id
NOT IN (SELECT fkey_gui_id FROM gui_element_vars
WHERE var_name = 'timeout' AND fkey_e_id = 'printPDF');


--
-- mb_metadata
-- new column responsible_party_name
-- 
ALTER TABLE mb_metadata ADD COLUMN responsible_party_name character varying(100);
