Loading doc/release-notes/v9/9.3.0/02_privilege.sql 0 → 100644 +94 −0 Original line number Diff line number Diff line -- -- 9.3.0 -- create or replace function privilege__grant_privilege_to_profile(categorycode character varying, privilegecode character varying, profileroleid character varying) returns void language plpgsql as $$ BEGIN -- insertion dans 'profil_privilege' (si pas déjà fait) insert into profil_privilege (privilege_id, profil_id) select p.id as privilege_id, profil.id as profil_id from profil join unicaen_privilege_categorie cp on cp.code = categoryCode join unicaen_privilege_privilege p on p.categorie_id = cp.id and p.code = privilegeCode where profil.role_id = profileroleid and not exists( select * from profil_privilege where privilege_id = p.id and profil_id = profil.id ); perform privilege__update_role_privilege(); END; $$; create or replace function privilege__grant_privileges_to_profiles(categorycode character varying, privilegecodes character varying[], profileroleids character varying[]) returns void language plpgsql as $$declare v_priv_code varchar; v_prof_role_id varchar; BEGIN foreach v_priv_code in ARRAY privilegecodes loop foreach v_prof_role_id in ARRAY profileroleids loop insert into profil_privilege (privilege_id, profil_id) select p.id as privilege_id, profil.id as profil_id from profil join unicaen_privilege_categorie cp on cp.code = categoryCode join unicaen_privilege_privilege p on p.categorie_id = cp.id and p.code = v_priv_code where profil.role_id = v_prof_role_id on conflict do nothing; end loop; end loop; perform privilege__update_role_privilege(); END; $$; create or replace function privilege__revoke_privilege_to_profile(categorycode character varying, privilegecode character varying, profileroleid character varying) returns void language plpgsql as $$ BEGIN delete from profil_privilege pp1 where exists( select * from profil_privilege pp join profil on pp.profil_id = profil.id and role_id = profileRoleId join unicaen_privilege_privilege p on pp.privilege_id = p.id join unicaen_privilege_categorie cp on p.categorie_id = cp.id where p.code = privilegeCode and cp.code = categoryCode and pp.profil_id = pp1.profil_id and pp.privilege_id = pp1.privilege_id ); perform privilege__update_role_privilege(); END; $$; create or replace function privilege__revoke_privileges_to_profiles(categorycode character varying, privilegecodes character varying[], profileroleids character varying[]) returns void language plpgsql as $$declare v_priv_code varchar; v_prof_role_id varchar; BEGIN foreach v_priv_code in ARRAY privilegecodes loop foreach v_prof_role_id in ARRAY profileroleids loop delete from profil_privilege pp1 where exists( select * from profil_privilege pp join profil on pp.profil_id = profil.id and role_id = v_prof_role_id join unicaen_privilege_privilege p on pp.privilege_id = p.id join unicaen_privilege_categorie cp on p.categorie_id = cp.id where p.code = v_priv_code and cp.code = categoryCode and pp.profil_id = pp1.profil_id and pp.privilege_id = pp1.privilege_id ); end loop; end loop; perform privilege__update_role_privilege(); END; $$; doc/release-notes/v9/9.3.0/03_these.sql 0 → 100644 +30 −0 Original line number Diff line number Diff line -- -- 9.3.0 -- drop materialized view mv_recherche_these; create materialized view mv_recherche_these as WITH acteurs AS ( SELECT a_1.these_id, i.nom_usuel, a_1.individu_id FROM individu i JOIN acteur a_1 ON i.id = a_1.individu_id JOIN these t_1 ON t_1.id = a_1.these_id JOIN role r ON a_1.role_id = r.id AND (r.code::text = ANY (ARRAY['D'::character varying::text, 'K'::character varying::text])) ) SELECT 'now'::text::timestamp without time zone AS date_creation, t.source_code AS code_these, d.source_code AS code_doctorant, ed.source_code AS code_ecole_doct, btrim(str_reduce(((((((((((((((((((((('code-ed{'::text || COALESCE(eds.code::text, ''::text)) || '} '::text) || 'code-ur{'::text) || COALESCE(urs.code::text, ''::text)) || '} '::text) || 'titre{'::text) || t.titre::text) || '} '::text) || 'doctorant-numero{'::text) || substr(d.source_code::text, "position"(d.source_code::text, '::'::text) + 2)) || '} '::text) || 'doctorant-nom{'::text) || id.nom_patronymique::text) || ' '::text) || id.nom_usuel::text) || '} '::text) || 'doctorant-prenom{'::text) || id.prenom1::text) || '} '::text) || 'directeur-nom{'::text) || COALESCE(ia.nom_usuel::text, ''::text)) || '} '::text)) AS haystack FROM these t JOIN doctorant d ON d.id = t.doctorant_id JOIN individu id ON id.id = d.individu_id LEFT JOIN ecole_doct ed ON t.ecole_doct_id = ed.id LEFT JOIN structure eds ON ed.structure_id = eds.id LEFT JOIN unite_rech ur ON t.unite_rech_id = ur.id LEFT JOIN structure urs ON ur.structure_id = urs.id LEFT JOIN acteurs a ON a.these_id = t.id LEFT JOIN individu ia ON ia.id = a.individu_id; Loading
doc/release-notes/v9/9.3.0/02_privilege.sql 0 → 100644 +94 −0 Original line number Diff line number Diff line -- -- 9.3.0 -- create or replace function privilege__grant_privilege_to_profile(categorycode character varying, privilegecode character varying, profileroleid character varying) returns void language plpgsql as $$ BEGIN -- insertion dans 'profil_privilege' (si pas déjà fait) insert into profil_privilege (privilege_id, profil_id) select p.id as privilege_id, profil.id as profil_id from profil join unicaen_privilege_categorie cp on cp.code = categoryCode join unicaen_privilege_privilege p on p.categorie_id = cp.id and p.code = privilegeCode where profil.role_id = profileroleid and not exists( select * from profil_privilege where privilege_id = p.id and profil_id = profil.id ); perform privilege__update_role_privilege(); END; $$; create or replace function privilege__grant_privileges_to_profiles(categorycode character varying, privilegecodes character varying[], profileroleids character varying[]) returns void language plpgsql as $$declare v_priv_code varchar; v_prof_role_id varchar; BEGIN foreach v_priv_code in ARRAY privilegecodes loop foreach v_prof_role_id in ARRAY profileroleids loop insert into profil_privilege (privilege_id, profil_id) select p.id as privilege_id, profil.id as profil_id from profil join unicaen_privilege_categorie cp on cp.code = categoryCode join unicaen_privilege_privilege p on p.categorie_id = cp.id and p.code = v_priv_code where profil.role_id = v_prof_role_id on conflict do nothing; end loop; end loop; perform privilege__update_role_privilege(); END; $$; create or replace function privilege__revoke_privilege_to_profile(categorycode character varying, privilegecode character varying, profileroleid character varying) returns void language plpgsql as $$ BEGIN delete from profil_privilege pp1 where exists( select * from profil_privilege pp join profil on pp.profil_id = profil.id and role_id = profileRoleId join unicaen_privilege_privilege p on pp.privilege_id = p.id join unicaen_privilege_categorie cp on p.categorie_id = cp.id where p.code = privilegeCode and cp.code = categoryCode and pp.profil_id = pp1.profil_id and pp.privilege_id = pp1.privilege_id ); perform privilege__update_role_privilege(); END; $$; create or replace function privilege__revoke_privileges_to_profiles(categorycode character varying, privilegecodes character varying[], profileroleids character varying[]) returns void language plpgsql as $$declare v_priv_code varchar; v_prof_role_id varchar; BEGIN foreach v_priv_code in ARRAY privilegecodes loop foreach v_prof_role_id in ARRAY profileroleids loop delete from profil_privilege pp1 where exists( select * from profil_privilege pp join profil on pp.profil_id = profil.id and role_id = v_prof_role_id join unicaen_privilege_privilege p on pp.privilege_id = p.id join unicaen_privilege_categorie cp on p.categorie_id = cp.id where p.code = v_priv_code and cp.code = categoryCode and pp.profil_id = pp1.profil_id and pp.privilege_id = pp1.privilege_id ); end loop; end loop; perform privilege__update_role_privilege(); END; $$;
doc/release-notes/v9/9.3.0/03_these.sql 0 → 100644 +30 −0 Original line number Diff line number Diff line -- -- 9.3.0 -- drop materialized view mv_recherche_these; create materialized view mv_recherche_these as WITH acteurs AS ( SELECT a_1.these_id, i.nom_usuel, a_1.individu_id FROM individu i JOIN acteur a_1 ON i.id = a_1.individu_id JOIN these t_1 ON t_1.id = a_1.these_id JOIN role r ON a_1.role_id = r.id AND (r.code::text = ANY (ARRAY['D'::character varying::text, 'K'::character varying::text])) ) SELECT 'now'::text::timestamp without time zone AS date_creation, t.source_code AS code_these, d.source_code AS code_doctorant, ed.source_code AS code_ecole_doct, btrim(str_reduce(((((((((((((((((((((('code-ed{'::text || COALESCE(eds.code::text, ''::text)) || '} '::text) || 'code-ur{'::text) || COALESCE(urs.code::text, ''::text)) || '} '::text) || 'titre{'::text) || t.titre::text) || '} '::text) || 'doctorant-numero{'::text) || substr(d.source_code::text, "position"(d.source_code::text, '::'::text) + 2)) || '} '::text) || 'doctorant-nom{'::text) || id.nom_patronymique::text) || ' '::text) || id.nom_usuel::text) || '} '::text) || 'doctorant-prenom{'::text) || id.prenom1::text) || '} '::text) || 'directeur-nom{'::text) || COALESCE(ia.nom_usuel::text, ''::text)) || '} '::text)) AS haystack FROM these t JOIN doctorant d ON d.id = t.doctorant_id JOIN individu id ON id.id = d.individu_id LEFT JOIN ecole_doct ed ON t.ecole_doct_id = ed.id LEFT JOIN structure eds ON ed.structure_id = eds.id LEFT JOIN unite_rech ur ON t.unite_rech_id = ur.id LEFT JOIN structure urs ON ur.structure_id = urs.id LEFT JOIN acteurs a ON a.these_id = t.id LEFT JOIN individu ia ON ia.id = a.individu_id;