Index: openacs-4/packages/curriculum-central/sql/postgresql/uos-tl-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/sql/postgresql/uos-tl-create.sql,v diff -u -r1.2 -r1.3 --- openacs-4/packages/curriculum-central/sql/postgresql/uos-tl-create.sql 4 Jan 2006 23:32:35 -0000 1.2 +++ openacs-4/packages/curriculum-central/sql/postgresql/uos-tl-create.sql 1 Jun 2006 05:33:56 -0000 1.3 @@ -12,6 +12,46 @@ returns integer as' begin PERFORM acs_object_type__create_type ( + ''cc_uos_tl_name'', -- object_type + ''#curriculum-central.uos_tl_name#'', -- pretty_name + ''#curriculum-central.uos_tl_names#'', -- pretty_plural + ''acs_object'', -- supertype + ''cc_uos_tl_name'', -- table_name + ''name_id'', -- id_column + null, -- package_name + ''f'', -- abstract_p + null, -- type_extension_table + ''cc_uos_tl_name__name'' -- name_method + ); + + return 0; +end;' language 'plpgsql'; + +select inline_0 (); +drop function inline_0 (); + + +-- Table storing the names of admin defined teaching and learning approaches +-- that can be used globally. Used for consistency. +-- Names include: Tutorial, Seminar, Lecture, etc. +create table cc_uos_tl_name ( + name_id integer + constraint cc_uos_tl_name_fk + references acs_objects(object_id) + on delete cascade + constraint cc_uos_tl_name_pk + primary key, + name varchar(256), + general_description text, + package_id integer +); + + + +create function inline_0 () +returns integer as' +begin + PERFORM acs_object_type__create_type ( ''cc_uos_tl'', -- object_type ''#curriculum-central.uos_teaching_and_learning#'', -- pretty_name ''#curriculum-central.uos_teaching_and_learning#'', -- pretty_plural @@ -143,6 +183,97 @@ -- -- +-- Create the functions for cc_uos_tl_name +-- +-- + +select define_function_args('cc_uos_tl_name__new','name_id,name,general_description,creation_date;now,creation_user,creation_ip,package_id,context_id'); + +create function cc_uos_tl_name__new ( + integer, -- name_id + varchar, -- name + text, -- general_description + timestamptz, -- creation_date + integer, -- creation_user + varchar, -- creation_ip + integer, -- package_id + integer -- context_id +) returns integer as ' +declare + p_name_id alias for $1; -- default null + p_name alias for $2; + p_general_description alias for $3; + p_creation_date alias for $4; -- default now() + p_creation_user alias for $5; -- default null + p_creation_ip alias for $6; -- default null + p_package_id alias for $7; + p_context_id alias for $8; -- default null + + v_name_id cc_uos_tl_name.name_id%TYPE; +begin + + v_name_id := acs_object__new ( + p_name_id, + ''cc_uos_tl_name'', + p_creation_date, + p_creation_user, + p_creation_ip, + p_context_id, + p_name, + p_package_id + ); + + INSERT INTO cc_uos_tl_name ( + name_id, name, general_description, package_id + ) + VALUES ( + v_name_id, p_name, p_general_description, p_package_id + ); + + return v_name_id; + +end;' language 'plpgsql'; + + +select define_function_args('cc_uos_tl_name__del','name_id'); + +create function cc_uos_tl_name__del (integer) +returns integer as ' +declare + p_name_id alias for $1; +begin + DELETE FROM acs_permissions WHERE object_id = p_name_id; + + DELETE FROM cc_uos_tl_name WHERE name_id = p_name_id; + + RAISE NOTICE ''Deleting graduate attribute name...''; + PERFORM acs_object__delete(p_name_id); + + return 0; + +end;' language 'plpgsql'; + + +select define_function_args('cc_uos_tl_name__name','name_id'); + +create function cc_uos_tl_name__name (integer) +returns varchar as ' +declare + p_name_id alias for $1; + + v_tl_name cc_uos_tl_name.name%TYPE; +begin + SELECT name INTO v_tl_name + FROM cc_uos_tl_name + WHERE name_id = p_name_id; + + return v_tl_name; +end; +' language 'plpgsql'; + + +-- +-- -- Create the functions for the tl content item and revisions. -- -- @@ -313,11 +444,11 @@ -- -- -select define_function_args('cc_uos_tl_method__new','method_id,name,identifier,description,creation_date;now,creation_user,creation_ip,package_id,context_id'); +select define_function_args('cc_uos_tl_method__new','method_id,name_id,identifier,description,creation_date;now,creation_user,creation_ip,package_id,context_id'); create function cc_uos_tl_method__new ( integer, -- method_id - varchar, -- name + integer, -- name_id varchar, -- identifier text, -- description timestamptz, -- creation_date @@ -328,7 +459,7 @@ ) returns integer as ' declare p_method_id alias for $1; -- default null - p_name alias for $2; + p_name_id alias for $2; p_identifier alias for $3; p_description alias for $4; p_creation_date alias for $5; -- default now() @@ -340,7 +471,8 @@ v_method_id cc_uos_tl_method.method_id%TYPE; v_title varchar; begin - v_title := p_name || '' ('' || p_identifier || '')''; + v_title := cc_uos_tl_name__name(p_name_id) || + '' ('' || p_identifier || '')''; v_method_id := acs_object__new ( p_method_id, @@ -354,10 +486,10 @@ ); INSERT INTO cc_uos_tl_method ( - method_id, name, identifier, description + method_id, name_id, identifier, description ) VALUES ( - v_method_id, p_name, p_identifier, p_description + v_method_id, p_name_id, p_identifier, p_description ); return v_method_id;