Commit e5ea201d authored by User expired's avatar User expired
Browse files

fix in postgresql functions for admin. groups

parent f48671a3
......@@ -28,6 +28,10 @@ ALTER TABLE tce_users DROP CONSTRAINT ak_user_regnumber;
-- DROP FUNCTION get_admin_group(bigint, bigint);
-- 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$
......@@ -39,7 +43,10 @@ BEGIN
FROM tce_user_groups
WHERE group_id = igroup_id ) || ':owner'
AND group_type = 'B'
into xgroup_id;
INTO xgroup_id;
IF xgroup_id IS NULL THEN
xgroup_id = igroup_id;
END IF;
RETURN xgroup_id;
END;
$BODY$
......@@ -53,22 +60,33 @@ ALTER FUNCTION get_admin_group(bigint, bigint)
-- 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
CREATE OR REPLACE FUNCTION set_admin_group(itest_id bigint, igroup_id bigint)
RETURNS void 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;
IF NOT EXISTS (SELECT * FROM tce_testgroups WHERE tstgrp_group_id = (SELECT * FROM get_admin_group(itest_id, igroup_id)) AND tstgrp_test_id = itest_id)
THEN
INSERT INTO tce_testgroups (
tstgrp_test_id,
tstgrp_group_id
) VALUES ( itest_id, (SELECT * FROM get_admin_group(itest_id, igroup_id)));
END IF;
END;
$BODY$
LANGUAGE plpgsql VOLATILE SECURITY DEFINER
COST 100;
ALTER FUNCTION get_admin_group(bigint, bigint) SET search_path=tcexam, pg_temp;
ALTER FUNCTION set_admin_group(bigint, bigint) SET search_path=tcexam, pg_temp;
ALTER FUNCTION get_admin_group(bigint, bigint)
ALTER FUNCTION set_admin_group(bigint, bigint)
OWNER TO tcexam;
-- functions for tcexam esb integration
-- assign_tcexam_user_to_group
......
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