Skip to content
Snippets Groups Projects
Commit f48671a3 authored by User expired's avatar User expired
Browse files

postgresql functions for admin. groups

parent 926d679f
No related branches found
No related tags found
No related merge requests found
......@@ -23,7 +23,51 @@ ALTER TABLE tce_tests ADD COLUMN test_group_id bigint;
-- restraint dropped because a user locked in VIS can be registered again in TCExam later, but of course keeps his matrikelnr.
ALTER TABLE tce_users DROP CONSTRAINT ak_user_regnumber;
-- functions for administrative group
-- Function: get_admin_group(bigint, bigint)
-- DROP FUNCTION get_admin_group(bigint, bigint);
CREATE OR REPLACE FUNCTION get_admin_group(itest_id bigint, igroup_id bigint)
RETURNS bigint AS
$BODY$
DECLARE xgroup_id bigint;
BEGIN
SELECT group_id FROM tce_user_groups
WHERE external_id = (
SELECT LEFT(external_id,strpos(external_id,':')-1)
FROM tce_user_groups
WHERE group_id = igroup_id ) || ':owner'
AND group_type = 'B'
into xgroup_id;
RETURN xgroup_id;
END;
$BODY$
LANGUAGE plpgsql VOLATILE SECURITY DEFINER
COST 100;
ALTER FUNCTION get_admin_group(bigint, bigint) SET search_path=tcexam, pg_temp;
ALTER FUNCTION get_admin_group(bigint, bigint)
OWNER TO tcexam;
-- Function: set_admin_group(bigint, bigint)
-- DROP FUNCTION set_admin_group(bigint, bigint);
CREATE OR REPLACE FUNCTION get_admin_group(itest_id bigint, igroup_id bigint)
RETURNS bigint AS
$BODY$
DECLARE xgroup_id bigint;
BEGIN
SELECT group_id FROM tce_user_groups WHERE external_id = ( SELECT LEFT(external_id,strpos(external_id,':')-1) FROM tce_user_groups WHERE group_id = igroup_id ) || ':owner' AND group_type = 'B' into xgroup_id;
RETURN xgroup_id;
END;
$BODY$
LANGUAGE plpgsql VOLATILE SECURITY DEFINER
COST 100;
ALTER FUNCTION get_admin_group(bigint, bigint) SET search_path=tcexam, pg_temp;
ALTER FUNCTION get_admin_group(bigint, bigint)
OWNER TO tcexam;
-- functions for tcexam esb integration
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment