Commit b94f7fd1 authored by Frank Bergmann's avatar Frank Bergmann

- Added missing OpenACS 5.9.1 upgrade scripts

parent dade9ebc
insert into cr_mime_types(label, mime_type, file_extension)
select 'Microsoft Office Word macro enabled', 'application/vnd.ms-word.document.macroenabled.12', 'docm' from dual
where not exists (select 1 from cr_mime_types where mime_type = 'application/vnd.ms-word.document.macroenabled.12');
insert into cr_mime_types(label, mime_type, file_extension)
select 'Microsoft Office Word Template macro enabled', 'application/vnd.ms-word.template.macroenabled.12', 'dotm' from dual
where not exists (select 1 from cr_mime_types where mime_type = 'application/vnd.ms-word.template.macroenabled.12');
insert into cr_mime_types(label, mime_type, file_extension)
select 'Microsoft Office Excel macro enabled', 'application/vnd.ms-excel.sheet.macroenabled.12', 'xlsm' from dual
where not exists (select 1 from cr_mime_types where mime_type = 'application/vnd.ms-excel.sheet.macroenabled.12');
insert into cr_mime_types(label, mime_type, file_extension)
select 'Microsoft Office Excel Template macro enabled', 'application/vnd.ms-excel.template.macroenabled.12', 'xltm' from dual
where not exists (select 1 from cr_mime_types where mime_type = 'application/vnd.ms-excel.template.macroenabled.12');
insert into cr_mime_types(label, mime_type, file_extension)
select 'Microsoft Office Excel Addin macro enabled', 'application/vnd.ms-excel.addin.macroenabled.12', 'xlam' from dual
where not exists (select 1 from cr_mime_types where mime_type = 'application/vnd.ms-excel.addin.macroenabled.12');
insert into cr_mime_types(label, mime_type, file_extension)
select 'Microsoft Office Excel Sheet binary macro enabled', 'application/vnd.ms-excel.sheet.binary.macroenabled.12', 'xlsb' from dual
where not exists (select 1 from cr_mime_types where mime_type = 'application/vnd.ms-excel.sheet.binary.macroenabled.12');
insert into cr_mime_types(label, mime_type, file_extension)
select 'Microsoft Office PowerPoint Addin macro enabled', 'application/vnd.ms-powerpoint.addin.macroenabled.12', 'ppam' from dual
where not exists (select 1 from cr_mime_types where mime_type = 'application/vnd.ms-powerpoint.addin.macroenabled.12');
insert into cr_mime_types(label, mime_type, file_extension)
select 'Microsoft Office PowerPoint Presentation macro enabled', 'application/vnd.ms-powerpoint.presentation.macroenabled.12', 'pptm' from dual
where not exists (select 1 from cr_mime_types where mime_type = 'application/vnd.ms-powerpoint.presentation.macroenabled.12');
insert into cr_mime_types(label, mime_type, file_extension)
select 'Microsoft Office PowerPoint Template macro enabled', 'application/vnd.ms-powerpoint.template.macroenabled.12', 'potm' from dual
where not exists (select 1 from cr_mime_types where mime_type = 'application/vnd.ms-powerpoint.template.macroenabled.12');
insert into cr_mime_types(label, mime_type, file_extension)
select 'Microsoft Office PowerPoint Slideshow macro enabled', 'application/vnd.ms-powerpoint.slideshow.macroenabled.12', 'ppsm' from dual
where not exists (select 1 from cr_mime_types where mime_type = 'application/vnd.ms-powerpoint.slideshow.macroenabled.12');
This diff is collapsed.
This diff is collapsed.
--
-- Update mime_type to official content type as registered by IANA.
-- The changes have to be performed in a transaction, therefore the inline function.
--
create or replace function inline_0 (
p_label in varchar,
p_extension in varchar,
p_old_mime_type in varchar,
p_new_mime_type in varchar
)
return integer
as
begin
delete from cr_extension_mime_type_map where mime_type = p_old_mime_type;
insert into cr_mime_types(label, mime_type, file_extension)
select p_label, p_new_mime_type, p_extension from dual
where not exists (select 1 from cr_mime_types where mime_type = p_new_mime_type);
update cr_content_mime_type_map set mime_type = p_new_mime_type where mime_type = p_old_mime_type;
update cr_revisions set mime_type = p_new_mime_type where mime_type = p_old_mime_type;
insert into cr_extension_mime_type_map (extension, mime_type)
select p_extension, p_new_mime_type from dual
where not exists (select 1 from cr_extension_mime_type_map where mime_type = p_new_mime_type);
delete from cr_mime_types where mime_type = p_old_mime_type;
return 1;
end;
/
select inline_0('Macromedia Shockwave','swf','application/x-shockwave-flash','application/vnd.adobe.flash-movie') from dual;
drop function inline_0;
--
-- Update mime_type to official content type as registered by IANA.
-- The changes have to be performed in a transaction, therefore the inline function.
--
create or replace function inline_0 (
p_label in varchar,
p_extension in varchar,
p_old_mime_type in varchar,
p_new_mime_type in varchar
)
return integer
as
begin
delete from cr_extension_mime_type_map where mime_type = p_old_mime_type;
insert into cr_mime_types(label, mime_type, file_extension)
select p_label, p_new_mime_type, p_extension from dual
where not exists (select 1 from cr_mime_types where mime_type = p_new_mime_type);
update cr_content_mime_type_map set mime_type = p_new_mime_type where mime_type = p_old_mime_type;
update cr_revisions set mime_type = p_new_mime_type where mime_type = p_old_mime_type;
insert into cr_extension_mime_type_map (extension, mime_type)
select p_extension, p_new_mime_type from dual
where not exists (select 1 from cr_extension_mime_type_map where mime_type = p_new_mime_type);
delete from cr_mime_types where mime_type = p_old_mime_type;
return 1;
end;
/
select inline_0('Javascript','js','application/x-javascript','application/javascript') from dual;
select inline_0('JSON','json','-- dummy --','application/json') from dual;
drop function inline_0;
--
-- Update mime_type to official content type as registered by IANA.
-- The changes have to be performed in a transaction, therefore the inline function.
--
create or replace function inline_0 (
p_label in varchar,
p_extension in varchar,
p_old_mime_type in varchar,
p_new_mime_type in varchar
)
return integer
as
begin
delete from cr_extension_mime_type_map where mime_type = p_old_mime_type;
insert into cr_mime_types(label, mime_type, file_extension)
select p_label, p_new_mime_type, p_extension from dual
where not exists (select 1 from cr_mime_types where mime_type = p_new_mime_type);
update cr_content_mime_type_map set mime_type = p_new_mime_type where mime_type = p_old_mime_type;
update cr_revisions set mime_type = p_new_mime_type where mime_type = p_old_mime_type;
insert into cr_extension_mime_type_map (extension, mime_type)
select p_extension, p_new_mime_type from dual
where not exists (select 1 from cr_extension_mime_type_map where mime_type = p_new_mime_type);
delete from cr_mime_types where mime_type = p_old_mime_type;
return 1;
end;
/
select inline_0('Archive gzip compressed','gz','application/x-gzip','application/gzip') from dual;
select inline_0('Archive gzip compressed','gzip','application/x-gzip','application/gzip') from dual;
drop function inline_0;
--
-- Update mime_type to official content type as registered by IANA.
-- The changes have to be performed in a transaction, therefore the inline function.
--
create or replace function inline_0 (
p_label in varchar,
p_extension in varchar,
p_old_mime_type in varchar,
p_new_mime_type in varchar
)
return integer
as
begin
delete from cr_extension_mime_type_map where mime_type = p_old_mime_type;
insert into cr_mime_types(label, mime_type, file_extension)
select p_label, p_new_mime_type, p_extension from dual
where not exists (select 1 from cr_mime_types where mime_type = p_new_mime_type);
update cr_content_mime_type_map set mime_type = p_new_mime_type where mime_type = p_old_mime_type;
update cr_revisions set mime_type = p_new_mime_type where mime_type = p_old_mime_type;
insert into cr_extension_mime_type_map (extension, mime_type)
select p_extension, p_new_mime_type from dual
where not exists (select 1 from cr_extension_mime_type_map where mime_type = p_new_mime_type);
delete from cr_mime_types where mime_type = p_old_mime_type;
return 1;
end;
/
select inline_0('Comma separated value','csv','application/csv','text/csv') from dual;
select inline_0('VCard','vcf','application/vcard','text/vcard') from dual;
select inline_0('iCalendar','ics','-- dummy --','text/calendar') from dual;
drop function inline_0;
UPDATE cr_mime_types set label = 'Unknown' where label = 'Unknown';
--
-- Update mime types.
-- The changes have to be performed in a transaction, therefore the inline function.
--
create or replace function inline_0 (
p_label in varchar,
p_extension in varchar,
p_old_mime_type in varchar,
p_new_mime_type in varchar
)
return integer
as
begin
v_extension_exists integer default 0;
delete from cr_extension_mime_type_map where mime_type = p_old_mime_type;
insert into cr_mime_types(label, mime_type, file_extension)
select p_label, p_new_mime_type, p_extension from dual
where not exists (select 1 from cr_mime_types where mime_type = p_new_mime_type);
update cr_content_mime_type_map set mime_type = p_new_mime_type where mime_type = p_old_mime_type;
update cr_revisions set mime_type = p_new_mime_type where mime_type = p_old_mime_type;
select 1 into v_extension_exists
from cr_extension_mime_type_map
where extension = p_extension;
if v_extension_exists = 1 then
update cr_extension_mime_type_map set mime_type = p_new_mime_type where extension = p_extension;
else
insert into cr_extension_mime_type_map (extension, mime_type)
select p_extension, p_new_mime_type from dual
where not exists (select 1 from cr_extension_mime_type_map where mime_type = p_new_mime_type);
end if;
delete from cr_mime_types where mime_type = p_old_mime_type;
return 1;
end;
/
select inline_0('Microsoft Office Excel Template' ,'xltx' ,'application/vnd.openxmlformats-officedocument.spreadsheetml.template' ,'application/vnd.openxmlformats-officedocument.spreadsheetml-template') from dual;
select inline_0('Microsoft Office PowerPoint Template' ,'potx' ,'application/vnd.openxmlformats-officedocument.presentationml.template' ,'application/vnd.openxmlformats-officedocument.presentationml-template') from dual;
select inline_0('Microsoft Office Word Template' ,'dotx' ,'application/vnd.openxmlformats-officedocument.wordprocessingml.template' ,'application/vnd.openxmlformats-officedocument.wordprocessingml-template') from dual;
select inline_0('Video FLASH' ,'flv' ,'' ,'video/x-flv') from dual;
select inline_0('Microsoft Portable Executable' ,'exe' ,'' ,'application/vnd.microsoft.portable-executable') from dual;
select inline_0('Virtue MTS' ,'mts' ,'' ,'model/vnd.mts') from dual;
select inline_0('Microsoft Document Imaging Format' ,'mdi' ,'' ,'image/vnd.ms-modi') from dual;
select inline_0('WSDL - Web Services Description Language' ,'wsdl' ,'' ,'application/wsdl+xml') from dual;
select inline_0('VPIM voice message' ,'vpm' ,'' ,'multipart/voice-message') from dual;
select inline_0('Mathematica Notebook Player' ,'nbp' ,'' ,'application/vnd.wolfram.player') from dual;
select inline_0('SMART Notebook' ,'notebook' ,'' ,'application/vnd.smart.notebook') from dual;
select inline_0('Novadigm RADIA and EDM products' ,'ext' ,'' ,'application/vnd.novadigm.ext') from dual;
select inline_0('Novadigm RADIA and EDM products' ,'edx' ,'' ,'application/vnd.novadigm.edx') from dual;
select inline_0('Microsoft XML Paper Specification' ,'xps' ,'' ,'application/vnd.ms-xpsdocument') from dual;
select inline_0('Microsoft Windows Media Player Playlist' ,'wpl' ,'' ,'application/vnd.ms-wpl') from dual;
select inline_0('Microsoft Office System Release Theme' ,'thmx' ,'' ,'application/vnd.ms-officetheme') from dual;
select inline_0('Lotus Wordpro' ,'lwp' ,'' ,'application/vnd.lotus-wordpro') from dual;
select inline_0('GeoGebra' ,'ggb' ,'' ,'application/vnd.geogebra.file') from dual;
select inline_0('Forms Data Format' ,'fdf' ,'' ,'application/vnd.fdf') from dual;
select inline_0('Solids' ,'sol' ,'' ,'application/solids') from dual;
select inline_0('Synchronized Multimedia Integration Language' ,'smi' ,'' ,'application/smil+xml') from dual;
select inline_0('PKCS #10 - Certification Request Standard' ,'p' ,'' ,'application/pkcs10') from dual;
select inline_0('OpenXPS' ,'oxps' ,'' ,'application/oxps') from dual;
select inline_0('Mathematica Notebooks' ,'nb' ,'' ,'application/mathematica') from dual;
select inline_0('' ,'mm' ,'' ,'application/base64') from dual;
select inline_0('BioPAX OWL' ,'owl' ,'' ,'application/vnd.biopax.rdf+xml') from dual;
select inline_0('Tcpdump Packet Capture' ,'pcap' ,'' ,'application/vnd.tcpdump.pcap') from dual;
drop function inline_0;
This diff is collapsed.
This diff is collapsed.
CREATE OR REPLACE FUNCTION content_item__get_path(
get_path__item_id integer,
get_path__root_folder_id integer -- default null
) RETURNS varchar AS $$
DECLARE
v_count integer;
v_resolved_root_id integer;
v_path text default '';
v_rec record;
v_current_item_id integer;
v_current_name text;
BEGIN
-- check that the item exists
select count(*) into v_count from cr_items where item_id = get_path__item_id;
if v_count = 0 then
raise EXCEPTION '-20000: Invalid item ID: %', get_path__item_id;
end if;
-- begin walking down the path to the item (from the repository root)
-- if the root folder is not null then prepare for a relative path
if get_path__root_folder_id is not null then
-- if root_folder_id is a symlink, resolve it (child items will point
-- to the actual folder, not the symlink)
v_resolved_root_id := content_symlink__resolve(get_path__root_folder_id);
-- check to see if the item is under or out side the root_id
PERFORM 1 from cr_items i,
(select tree_sortkey from cr_items where item_id = v_resolved_root_id) a
where tree_ancestor_p(a.tree_sortkey, i.tree_sortkey) and i.item_id = get_path__item_id;
if NOT FOUND then
-- if not found then we need to go up the folder and append ../ until we have common ancestor
for v_rec in select i1.name, i1.parent_id, tree_level(i1.tree_sortkey) as tree_level
from cr_items i1, (select tree_ancestor_keys(tree_sortkey) as tree_sortkey from cr_items where item_id = v_resolved_root_id) i2,
(select tree_sortkey from cr_items where item_id = get_path__item_id) i3
where
i1.parent_id <> 0
and i2.tree_sortkey = i1.tree_sortkey
and not tree_ancestor_p(i2.tree_sortkey, i3.tree_sortkey)
order by tree_level desc
LOOP
v_path := v_path || '../';
end loop;
-- lets now assign the new root_id to be the last parent_id on the loop
v_resolved_root_id := v_rec.parent_id;
end if;
-- go downwards the tree and append the name and /
for v_rec in select i1.name, i1.item_id, tree_level(i1.tree_sortkey) as tree_level
from cr_items i1, (select tree_sortkey from cr_items where item_id = v_resolved_root_id) i2,
(select tree_ancestor_keys(tree_sortkey) as tree_sortkey from cr_items where item_id = get_path__item_id) i3
where
i1.tree_sortkey = i3.tree_sortkey
and i1.tree_sortkey > i2.tree_sortkey
order by tree_level
LOOP
v_path := v_path || v_rec.name;
if v_rec.item_id <> get_path__item_id then
-- put a / if we are still going down
v_path := v_path || '/';
end if;
end loop;
else
-- this is an absolute path so prepend a '/'
-- loop over the absolute path
v_current_item_id := get_path__item_id;
while v_current_item_id <> 0
LOOP
select parent_id, name into v_current_item_id, v_current_name from cr_items where item_id = v_current_item_id;
if FOUND then
v_path := '/' || v_current_name || v_path;
end if;
end loop;
end if;
return v_path;
END;
$$ LANGUAGE plpgsql;
begin;
drop FUNCTION if exists content_folder__copy(
copy__folder_id integer,
copy__target_folder_id integer,
copy__creation_user integer,
copy__creation_ip varchar
);
drop FUNCTION if exists content_folder__copy(
copy__folder_id integer,
copy__target_folder_id integer,
copy__creation_user integer,
copy__creation_ip varchar,
copy__name varchar
);
-- added
select define_function_args('content_folder__copy','folder_id,target_folder_id,creation_user,creation_ip;null,name;null,label;null');
--
-- procedure content_folder__copy/6
--
CREATE OR REPLACE FUNCTION content_folder__copy(
copy__folder_id integer,
copy__target_folder_id integer,
copy__creation_user integer,
copy__creation_ip varchar default null,
copy__name cr_items.name%TYPE default null,
copy__label cr_folders.label%TYPE default null
) RETURNS integer AS $$
DECLARE
v_valid_folders_p integer;
v_current_folder_id cr_folders.folder_id%TYPE;
v_name cr_items.name%TYPE;
v_label cr_folders.label%TYPE;
v_description cr_folders.description%TYPE;
v_new_folder_id cr_folders.folder_id%TYPE;
v_folder_contents_val record;
BEGIN
if copy__folder_id = content_item__get_root_folder(null)
or copy__folder_id = content_template__get_root_folder() then
raise EXCEPTION '-20000: content_folder.copy - Not allowed to copy root folder';
end if;
select
count(*)
into
v_valid_folders_p
from
cr_folders
where
folder_id = copy__target_folder_id
or
folder_id = copy__folder_id;
if v_valid_folders_p != 2 then
raise EXCEPTION '-20000: content_folder.copy - Invalid folder(s)';
end if;
if copy__target_folder_id = copy__folder_id then
raise EXCEPTION '-20000: content_folder.copy - Cannot copy folder to itself';
end if;
if content_folder__is_sub_folder(copy__folder_id, copy__target_folder_id) = 't' then
raise EXCEPTION '-20000: content_folder.copy - Destination folder is subfolder';
end if;
if content_folder__is_registered(copy__target_folder_id,'content_folder','f') != 't' then
raise EXCEPTION '-20000: content_folder.copy - Destination folder does not allow subfolders';
end if;
-- get the source folder info
select
name, label, description, parent_id
into
v_name, v_label, v_description, v_current_folder_id
from
cr_items i, cr_folders f
where
f.folder_id = i.item_id
and
f.folder_id = copy__folder_id;
-- would be better to check if the copy__name alredy exists in the destination folder.
if v_current_folder_id = copy__target_folder_id and (v_name = copy__name or copy__name is null) then
raise EXCEPTION '-20000: content_folder.copy - Destination folder is parent folder and folder alredy exists';
end if;
-- create the new folder
v_new_folder_id := content_folder__new(
coalesce (copy__name, v_name),
coalesce (copy__label, v_label),
v_description,
copy__target_folder_id,
copy__target_folder_id,
null,
now(),
copy__creation_user,
copy__creation_ip,
't',
null
);
-- copy attributes of original folder
insert into cr_folder_type_map
select
v_new_folder_id as folder_id, content_type
from
cr_folder_type_map map
where
folder_id = copy__folder_id
and
-- do not register content_type if it is already registered
not exists ( select 1 from cr_folder_type_map
where folder_id = v_new_folder_id
and content_type = map.content_type ) ;
-- for each item in the folder, copy it
for v_folder_contents_val in select
item_id
from
cr_items
where
parent_id = copy__folder_id
LOOP
PERFORM content_item__copy(
v_folder_contents_val.item_id,
v_new_folder_id,
copy__creation_user,
copy__creation_ip,
null
);
end loop;
return 0;
END;
$$ LANGUAGE plpgsql;
end;
DROP FUNCTION IF EXISTS content_item__set_live_revision(integer);
DROP FUNCTION IF EXISTS content_item__set_live_revision(integer, character varying);
select define_function_args('content_item__set_live_revision','revision_id,publish_status;ready,publish_date;now()');
--
-- procedure content_item__set_live_revision/2
--
CREATE OR REPLACE FUNCTION content_item__set_live_revision(
set_live_revision__revision_id integer,
set_live_revision__publish_status varchar default 'ready',
set_live_revision__publish_date timestamptz default now()
) RETURNS integer AS $$
DECLARE
BEGIN
update
cr_items
set
live_revision = set_live_revision__revision_id,
publish_status = set_live_revision__publish_status
where
item_id = (select
item_id
from
cr_revisions
where
revision_id = set_live_revision__revision_id);
update
cr_revisions
set
publish_date = set_live_revision__publish_date
where
revision_id = set_live_revision__revision_id;
return 0;
END;
$$ LANGUAGE plpgsql;
--
-- Update mime_type to official content type as registered by IANA.
-- The changes have to be performed in a transaction, therefore the inline function.
--
create or replace function inline_0 (
p_label varchar,
p_extension varchar,
p_old_mime_type varchar,
p_new_mime_type varchar
)
returns integer as $$
begin
SET CONSTRAINTS ALL DEFERRED;
delete from cr_extension_mime_type_map where mime_type = p_old_mime_type;
insert into cr_mime_types(label, mime_type, file_extension)
select p_label, p_new_mime_type, p_extension from dual
where not exists (select 1 from cr_mime_types where mime_type = p_new_mime_type);
update cr_content_mime_type_map set mime_type = p_new_mime_type where mime_type = p_old_mime_type;
update cr_revisions set mime_type = p_new_mime_type where mime_type = p_old_mime_type;
insert into cr_extension_mime_type_map (extension, mime_type)
select p_extension, p_new_mime_type from dual
where not exists (select 1 from cr_extension_mime_type_map where mime_type = p_new_mime_type);
delete from cr_mime_types where mime_type = p_old_mime_type;
return 0;
end;
$$ language 'plpgsql';
select inline_0('Macromedia Shockwave','swf','application/x-shockwave-flash','application/vnd.adobe.flash-movie');
drop function inline_0(varchar,varchar,varchar,varchar);
--
-- Update mime_type to official content type as registered by IANA.
-- The changes have to be performed in a transaction, therefore the inline function.
--
create or replace function inline_0 (
p_label varchar,
p_extension varchar,
p_old_mime_type varchar,
p_new_mime_type varchar
)
returns integer as $$
begin
SET CONSTRAINTS ALL DEFERRED;
delete from cr_extension_mime_type_map where mime_type = p_old_mime_type;
insert into cr_mime_types(label, mime_type, file_extension)
select p_label, p_new_mime_type, p_extension from dual
where not exists (select 1 from cr_mime_types where mime_type = p_new_mime_type);
update cr_content_mime_type_map set mime_type = p_new_mime_type where mime_type = p_old_mime_type;
update cr_revisions set mime_type = p_new_mime_type where mime_type = p_old_mime_type;
insert into cr_extension_mime_type_map (extension, mime_type)
select p_extension, p_new_mime_type from dual
where not exists (select 1 from cr_extension_mime_type_map where mime_type = p_new_mime_type);
delete from cr_mime_types where mime_type = p_old_mime_type;
return 0;
end;
$$ language 'plpgsql';
select inline_0('Javascript','js','application/x-javascript','application/javascript');
select inline_0('JSON','json','-- dummy --','application/json');
drop function inline_0(varchar,varchar,varchar,varchar);
--
-- Update mime_type to official content type as registered by IANA.
-- The changes have to be performed in a transaction, therefore the inline function.
--
create or replace function inline_0 (
p_label varchar,
p_extension varchar,
p_old_mime_type varchar,
p_new_mime_type varchar
)
returns integer as $$
begin
SET CONSTRAINTS ALL DEFERRED;
delete from cr_extension_mime_type_map where mime_type = p_old_mime_type;
insert into cr_mime_types(label, mime_type, file_extension)
select p_label, p_new_mime_type, p_extension from dual
where not exists (select 1 from cr_mime_types where mime_type = p_new_mime_type);
update cr_content_mime_type_map set mime_type = p_new_mime_type where mime_type = p_old_mime_type;
update cr_revisions set mime_type = p_new_mime_type where mime_type = p_old_mime_type;
insert into cr_extension_mime_type_map (extension, mime_type)
select p_extension, p_new_mime_type from dual
where not exists (select 1 from cr_extension_mime_type_map where mime_type = p_new_mime_type);
delete from cr_mime_types where mime_type = p_old_mime_type;
return 0;
end;
$$ language 'plpgsql';
select inline_0('Archive gzip compressed','gz','application/x-gzip','application/gzip');
select inline_0('Archive gzip compressed','gzip','application/x-gzip','application/gzip');
drop function inline_0(varchar,varchar,varchar,varchar);
This diff is collapsed.
--
-- Update mime_type to official content type as registered by IANA.
-- The changes have to be performed in a transaction, therefore the inline function.
--
create or replace function inline_0 (
p_label varchar,
p_extension varchar,
p_old_mime_type varchar,
p_new_mime_type varchar
)
returns integer as $$
begin
SET CONSTRAINTS ALL DEFERRED;
delete from cr_extension_mime_type_map where mime_type = p_old_mime_type;
insert into cr_mime_types(label, mime_type, file_extension)
select p_label, p_new_mime_type, p_extension from dual
where not exists (select 1 from cr_mime_types where mime_type = p_new_mime_type);
update cr_content_mime_type_map set mime_type = p_new_mime_type where mime_type = p_old_mime_type;
update cr_revisions set mime_type = p_new_mime_type where mime_type = p_old_mime_type;
insert into cr_extension_mime_type_map (extension, mime_type)
select p_extension, p_new_mime_type from dual
where not exists (select 1 from cr_extension_mime_type_map where mime_type = p_new_mime_type);
delete from cr_mime_types where mime_type = p_old_mime_type;
return 0;
end;
$$ language 'plpgsql';
select inline_0('Comma separated value','csv','application/csv','text/csv');
select inline_0('VCard','vcf','application/vcard','text/vcard');
select inline_0('iCalendar','ics','-- dummy --','text/calendar');
drop function inline_0(varchar,varchar,varchar,varchar);
--
-- procedure content_template__new/6
--
CREATE OR REPLACE FUNCTION content_template__new(
new__name varchar,
new__parent_id integer, -- default null
new__template_id integer, -- default null
new__creation_date timestamptz, -- default now()
new__creation_user integer, -- default null
new__creation_ip varchar -- default null
) RETURNS integer AS $$
--
-- content_template__new/6 maybe obsolete, when we define proper defaults for /8
--
DECLARE
v_template_id cr_templates.template_id%TYPE;
v_parent_id cr_items.parent_id%TYPE;
BEGIN
if new__parent_id is null then
select c_root_folder_id into v_parent_id from content_template_globals;
else
v_parent_id := new__parent_id;
end if;
-- make sure we're allowed to create a template in this folder
if content_folder__is_folder(new__parent_id) = 't' and
content_folder__is_registered(new__parent_id,'content_template','f') = 'f' then
raise EXCEPTION '-20000: This folder does not allow templates to be created';
else
v_template_id := content_item__new (
new__name,
v_parent_id,
new__template_id,
null,
new__creation_date,
new__creation_user,
null,
new__creation_ip,
'content_item',
'content_template',
null, -- title
null, -- description
'text/plain',
null, -- nls_language
null, -- text
null, -- data
null, -- relation_tag
'f', -- is_live
'text', -- storage_type
null, -- package_id
't' -- with_child_rels
);
insert into cr_templates (
template_id
) values (
v_template_id
);
return v_template_id;
end if;
END;
$$ LANGUAGE plpgsql;
--
-- procedure content_extlink__new/10
--
CREATE OR REPLACE FUNCTION content_extlink__new(
new__name varchar, -- default null
new__url varchar,
new__label varchar, -- default null
new__description varchar, -- default null
new__parent_id integer,
new__extlink_id integer, -- default null
new__creation_date timestamptz, -- default now() -- default 'now'
new__creation_user integer, -- default null
new__creation_ip varchar, -- default null
new__package_id integer -- default null
) RETURNS integer AS $$
DECLARE
v_extlink_id cr_extlinks.extlink_id%TYPE;
v_package_id acs_objects.package_id%TYPE;
v_label cr_extlinks.label%TYPE;
v_name cr_items.name%TYPE;
BEGIN
if new__label is null then
v_label := new__url;
else
v_label := new__label;
end if;
if new__name is null then
select nextval('t_acs_object_id_seq') into v_extlink_id from dual;
v_name := 'link' || v_extlink_id;
else
v_name := new__name;
end if;
if new__package_id is null then
v_package_id := acs_object__package_id(new__parent_id);
else
v_package_id := new__package_id;
end if;
v_extlink_id := content_item__new(
v_name,
new__parent_id,
new__extlink_id,
null,
new__creation_date,
new__creation_user,
null,
new__creation_ip,
'content_item',
'content_extlink',
null,
null,
'text/plain',
null,
null,
null, -- data
null, -- relation_tag
'f', -- is_live
'text',
v_package_id,
't' -- with_child_rels
);
insert into cr_extlinks
(extlink_id, url, label, description)
values
(v_extlink_id, new__url, v_label, new__description);
update acs_objects
set title = v_label
where object_id = v_extlink_id;
return v_extlink_id;
END;
$$ LANGUAGE plpgsql;
--
-- procedure content_item__new/17 (accepts 16-17 args)
--
CREATE OR REPLACE FUNCTION content_item__new(
new__name varchar,
new__parent_id integer, -- default null
new__item_id integer, -- default null
new__locale varchar, -- default null
new__creation_date timestamptz, -- default now()
new__creation_user integer, -- default null
new__context_id integer, -- default null
new__creation_ip varchar, -- default null
new__item_subtype varchar, -- default 'content_item'
new__content_type varchar, -- default 'content_revision'
new__title varchar, -- default null
new__description varchar, -- default null
new__mime_type varchar, -- default 'text/plain'
new__nls_language varchar, -- default null
new__text varchar, -- default null
new__storage_type cr_items.storage_type%TYPE,
new__package_id integer default null
) RETURNS integer AS $$
--
-- content_item__new/17 is deprecated, one should call /20
--
DECLARE
BEGIN
raise NOTICE 'content_item__new/17 is deprecated, call content_item__new/21 instead';
return content_item__new(new__name,
new__parent_id,
new__item_id,
new__locale,
new__creation_date,
new__creation_user,
new__context_id,
new__creation_ip,
new__item_subtype,
new__content_type,
new__title,
new__description,
new__mime_type,
new__nls_language,
new__text,
null, -- data
null, -- relation_tag
'f', -- is_live
new__storage_type,
new__package_id,
't' -- with_child_rels
);
END;
$$ LANGUAGE plpgsql;
drop function if exists content_item__new(new__name character varying, new__parent_id integer, new__item_id integer, new__locale character varying, new__creation_date timestamp with time zone, new__creation_user integer, new__context_id integer, new__creation_ip character varying, new__item_subtype character varying, new__content_type character varying, new__title character varying, new__description character varying, new__mime_type character varying, new__nls_language character varying, new__text character varying, new__storage_type character varying, new__package_id integer);
--
-- Changes induced by the type discrepancy cleanup in 5.9.1d8-5.9.1d9:
-- Using consistently varchar(1000) for object types.
--
ALTER TABLE cr_content_mime_type_map ALTER COLUMN content_type TYPE varchar(1000);
ALTER TABLE cr_folder_type_map ALTER COLUMN content_type TYPE varchar(1000);
-- ALTER TABLE cr_items ALTER COLUMN content_type TYPE varchar(1000);
ALTER TABLE cr_type_children ALTER COLUMN child_type TYPE varchar(1000);
ALTER TABLE cr_type_children ALTER COLUMN parent_type TYPE varchar(1000);
ALTER TABLE cr_type_relations ALTER COLUMN target_type TYPE varchar(1000);
ALTER TABLE cr_type_relations ALTER COLUMN content_type TYPE varchar(1000);
ALTER TABLE cr_type_template_map ALTER COLUMN content_type TYPE varchar(1000);
--
-- ALTER TABLE cr_items ALTER COLUMN content_type TYPE varchar(1000); --deps
--
WITH RECURSIVE dependent_views AS (
SELECT c.oid::REGCLASS AS view_name
FROM pg_class c
WHERE c.relname = 'cr_items'
UNION ALL
SELECT DISTINCT r.ev_class::REGCLASS AS view_name
FROM pg_depend d
JOIN pg_rewrite r ON (r.oid = d.objid)
JOIN dependent_views ON (dependent_views.view_name = d.refobjid)
WHERE d.refobjsubid != 0
)
UPDATE pg_attribute
SET atttypmod = 1000 + 4
FROM dependent_views
WHERE pg_attribute.attrelid = dependent_views.view_name
AND pg_attribute.attname = 'content_type';
UPDATE cr_mime_types set label = 'Unknown' where label = 'Unknown';
CREATE OR REPLACE FUNCTION content_item_search__utrg () RETURNS trigger AS $$
BEGIN
if new.live_revision is not null and coalesce(old.live_revision,0) <> new.live_revision
and (select publish_date from cr_revisions where revision_id=new.live_revision) <= current_timestamp then
perform search_observer__enqueue(new.live_revision,'INSERT');
end if;
if old.live_revision is not null and old.live_revision <> coalesce(new.live_revision,0)
and (select publish_date from cr_revisions where revision_id=old.live_revision) <= current_timestamp then
perform search_observer__enqueue(old.live_revision,'DELETE');
end if;
if old.live_revision is not null and new.publish_status = 'expired' then
perform search_observer__enqueue(old.live_revision,'DELETE');
end if;
return new;
END;
$$ LANGUAGE plpgsql;
--
-- Update mime types.
-- The changes have to be performed in a transaction, therefore the inline function.
--
create or replace function inline_0 (
p_label varchar,
p_extension varchar,
p_old_mime_type varchar,
p_new_mime_type varchar
)
returns integer as $$
begin
SET CONSTRAINTS ALL DEFERRED;
delete from cr_extension_mime_type_map where mime_type = p_old_mime_type;
insert into cr_mime_types(label, mime_type, file_extension)
select p_label, p_new_mime_type, p_extension from dual
where not exists (select 1 from cr_mime_types where mime_type = p_new_mime_type);
update cr_content_mime_type_map set mime_type = p_new_mime_type where mime_type = p_old_mime_type;
update cr_revisions set mime_type = p_new_mime_type where mime_type = p_old_mime_type;
if exists (select 1 from cr_extension_mime_type_map where extension = p_extension) then
update cr_extension_mime_type_map set mime_type = p_new_mime_type where extension = p_extension;
else
insert into cr_extension_mime_type_map (extension, mime_type)
select p_extension, p_new_mime_type from dual
where not exists (select 1 from cr_extension_mime_type_map where mime_type = p_new_mime_type);
end if;
delete from cr_mime_types where mime_type = p_old_mime_type;
return 0;
end;
$$ language 'plpgsql';
select inline_0('Microsoft Office Excel Template' ,'xltx' ,'application/vnd.openxmlformats-officedocument.spreadsheetml.template' ,'application/vnd.openxmlformats-officedocument.spreadsheetml-template');
select inline_0('Microsoft Office PowerPoint Template' ,'potx' ,'application/vnd.openxmlformats-officedocument.presentationml.template' ,'application/vnd.openxmlformats-officedocument.presentationml-template');
select inline_0('Microsoft Office Word Template' ,'dotx' ,'application/vnd.openxmlformats-officedocument.wordprocessingml.template' ,'application/vnd.openxmlformats-officedocument.wordprocessingml-template');
select inline_0('Video FLASH' ,'flv' ,'' ,'video/x-flv');
select inline_0('Microsoft Portable Executable' ,'exe' ,'' ,'application/vnd.microsoft.portable-executable');
select inline_0('Virtue MTS' ,'mts' ,'' ,'model/vnd.mts');
select inline_0('Microsoft Document Imaging Format' ,'mdi' ,'' ,'image/vnd.ms-modi');
select inline_0('WSDL - Web Services Description Language' ,'wsdl' ,'' ,'application/wsdl+xml');
select inline_0('VPIM voice message' ,'vpm' ,'' ,'multipart/voice-message');
select inline_0('Mathematica Notebook Player' ,'nbp' ,'' ,'application/vnd.wolfram.player');
select inline_0('SMART Notebook' ,'notebook' ,'' ,'application/vnd.smart.notebook');
select inline_0('Novadigm RADIA and EDM products' ,'ext' ,'' ,'application/vnd.novadigm.ext');
select inline_0('Novadigm RADIA and EDM products' ,'edx' ,'' ,'application/vnd.novadigm.edx');
select inline_0('Microsoft XML Paper Specification' ,'xps' ,'' ,'application/vnd.ms-xpsdocument');
select inline_0('Microsoft Windows Media Player Playlist' ,'wpl' ,'' ,'application/vnd.ms-wpl');
select inline_0('Microsoft Office System Release Theme' ,'thmx' ,'' ,'application/vnd.ms-officetheme');
select inline_0('Lotus Wordpro' ,'lwp' ,'' ,'application/vnd.lotus-wordpro');
select inline_0('GeoGebra' ,'ggb' ,'' ,'application/vnd.geogebra.file');
select inline_0('Forms Data Format' ,'fdf' ,'' ,'application/vnd.fdf');
select inline_0('Solids' ,'sol' ,'' ,'application/solids');
select inline_0('Synchronized Multimedia Integration Language' ,'smi' ,'' ,'application/smil+xml');
select inline_0('PKCS #10 - Certification Request Standard' ,'p' ,'' ,'application/pkcs10');
select inline_0('OpenXPS' ,'oxps' ,'' ,'application/oxps');
select inline_0('Mathematica Notebooks' ,'nb' ,'' ,'application/mathematica');
select inline_0('' ,'mm' ,'' ,'application/base64');
select inline_0('BioPAX OWL' ,'owl' ,'' ,'application/vnd.biopax.rdf+xml');
select inline_0('Tcpdump Packet Capture' ,'pcap' ,'' ,'application/vnd.tcpdump.pcap');
drop function inline_0(varchar,varchar,varchar,varchar);
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment