Index: openacs-4/packages/assessment/sql/oracle/assessment-actions-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/sql/oracle/assessment-actions-create.sql,v diff -u -N -r1.2 -r1.3 --- openacs-4/packages/assessment/sql/oracle/assessment-actions-create.sql 29 Jan 2005 18:28:50 -0000 1.2 +++ openacs-4/packages/assessment/sql/oracle/assessment-actions-create.sql 10 Feb 2005 21:27:00 -0000 1.3 @@ -92,3 +92,14 @@ cache 20; +-------------------------------------------------------- +-- SEQUENCE FOR PRIMARY KEY +-------------------------------------------------------- + + create sequence parameter_id_seq + minvalue 1 + maxvalue 999999999 + start with 1 + increment by 1 + cache 20; + Index: openacs-4/packages/assessment/sql/oracle/assessment-actions-package-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/sql/oracle/assessment-actions-package-create.sql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/sql/oracle/assessment-actions-package-create.sql 10 Feb 2005 21:27:00 -0000 1.1 @@ -0,0 +1,208 @@ +-- Assessment Package +-- @author annyflores@viaro.net +-- @creation-date 2005-01-06 + +begin + -- create the action object + acs_object_type.create_type ( + supertype => 'acs_object', + object_type => 'as_action', + pretty_name => 'As_action', + pretty_plural => 'As_actions', + table_name => 'as_actions', + id_column => 'action_id' +); +end; +/ +show errors; + +declare + + attr_id acs_attributes.attribute_id%TYPE; + +begin + attr_id := acs_attribute.create_attribute ( + object_type => 'as_action', + attribute_name => 'name', + pretty_name => 'Name', + pretty_plural => 'Names', + datatype => 'string' + ); + attr_id := acs_attribute.create_attribute ( + object_type => 'as_action', + attribute_name => 'description', + pretty_name => 'Description', + pretty_plural => 'Descriptions', + datatype => 'string' + ); + attr_id := acs_attribute.create_attribute ( + object_type => 'as_action', + attribute_name => 'tcl_code', + pretty_name => 'Tcl_code', + pretty_plural => 'Tcl_code', + datatype => 'integer' + ); +end; +/ +show errors; + +create or replace package as_action +as + function new ( + action_id in acs_objects.object_id%TYPE default null, + name in as_actions.name%TYPE, + description in as_actions.name%TYPE, + tcl_code in as_actions.name%TYPE, + context_id in acs_objects.context_id%TYPE, + creation_user in acs_objects.creation_user%TYPE, + package_id in acs_objects.package_id%TYPE + ) return as_actions.action_id%TYPE; + procedure delete ( + action_id in as_actions.action_id%TYPE + ); + procedure default_actions ( + context_id in acs_objects.context_id%TYPE, + creation_user in acs_objects.creation_user%TYPE, + package_id in acs_objects.package_id%TYPE + ); +end as_action; +/ +show errors; + +create or replace package body as_action +as + function new ( + action_id in acs_objects.object_id%TYPE default null, + name in as_actions.name%TYPE, + description in as_actions.name%TYPE, + tcl_code in as_actions.name%TYPE, + context_id in acs_objects.context_id%TYPE, + creation_user in acs_objects.creation_user%TYPE, + package_id in acs_objects.package_id%TYPE + ) return as_actions.action_id%TYPE + is + v_action_id as_actions.action_id%TYPE; + + begin + + v_action_id := acs_object.new ( + object_id => action_id, + object_type => 'as_action', + package_id => package_id, + creation_user => creation_user, + creation_ip => null, + context_id => context_id + ); + + insert into as_actions (action_id,name,description,tcl_code) + values (v_action_id,name,description,tcl_code); + + return v_action_id; + end new; + + + + procedure delete ( + action_id as_actions.action_id%TYPE + ) is + begin + + delete from as_action_params where action_id=action_id; + delete from as_actions where action_id = action_id; + acs_object.del(as_action.delete.action_id); + + end delete; + + + procedure default_actions ( + context_id in acs_objects.context_id%TYPE, + creation_user in acs_objects.creation_user%TYPE, + package_id in acs_objects.package_id%TYPE + ) is + v_action_id as_actions.action_id%TYPE; + + begin + + v_action_id := new ( + action_id => null, + name => 'Register User', + description => 'Register new users', + tcl_code => 'set password [ad_generate_random_string] +db_transaction { +array set user_new_info [auth::create_user -username $user_name -email $email -first_names $first_names +-last_name $last_name -password $password] +} +set admin_user_id [auth::test::get_admin_user_id] +set administration_name [db_string admin_name "select first_names || '' '' || last_name from persons where person_id + = :admin_user_id"] +set system_name [ad_system_name] +set system_url [ad_parameter -package_id [ad_acs_kernel_id] SystemURL ""]. +set admin_email [db_string unused "select email from parties where party_id = :admin_user_id"] +set message "$first_names $last_name, +You have been added as a user to $system_name +at $system_url +Login information: +Email: $email +Password: $password +(you may change your password after you log in) +Thank you, +$administration_name" +ns_sendmail "$email" "$admin_email" "You have been added as a user to [ad_system_name] at [ad_url]" "$message"', + context_id => context_id, + creation_user => creation_user, + package_id => package_id + ); + + +insert into as_action_params (parameter_id, action_id,type, varname, description) +values (parameter_id_seq.nextval,v_action_id,'n','first_names','First Names of the User'); + +insert into as_action_params (parameter_id, action_id,type, varname, description) +values (parameter_id_seq.nextval,v_action_id,'n','last_name','Last Name of the User'); + +insert into as_action_params (parameter_id, action_id,type, varname, description) +values (parameter_id_seq.nextval,v_action_id,'n','email','Email of the User'); + +insert into as_action_params (parameter_id, action_id,type, varname, description) +values (parameter_id_seq.nextval,v_action_id,'n','user_name','User name of the User'); + +v_action_id:= new ( + action_id => null, + name => 'Event Registration', + description => 'Register user to event', + tcl_code => 'set user_id [ad_conn user_id] +events::registration::new -event_id $event_id -user_id $user_id', + context_id => context_id, + creation_user => creation_user, + package_id => package_id + ); + + +insert into as_action_params (parameter_id, action_id,type, varname, description,query) +values (parameter_id_seq.nextval,v_action_id,'q','event_id','Event to add the user', 'select event_id,event_id from acs_events'); + +v_action_id:= new ( + action_id => null, + name => 'Add to Community', + description => 'Add user to a community', + tcl_code => 'set user_id [ad_conn user_id] +dotlrn_privacy::set_user_guest_p -user_id $user_id -value "t" +dotlrn::user_add -can_browse -user_id $user_id +dotlrn_community::add_user_to_community -community_id $community_id -user_id $user_id', + context_id => context_id, + creation_user => creation_user, + package_id => package_id + ); + + +insert into as_action_params (parameter_id, action_id,type, varname, description,query) +values (parameter_id_seq.nextval,v_action_id,'q','community_id','Community to add the user', +'select pretty_name,community_id from dotlrn_communities'); + + + end default_actions; + +end as_action; +/ +show errors; + Index: openacs-4/packages/assessment/sql/oracle/assessment-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/sql/oracle/assessment-create.sql,v diff -u -N -r1.4 -r1.5 --- openacs-4/packages/assessment/sql/oracle/assessment-create.sql 4 Feb 2005 18:09:43 -0000 1.4 +++ openacs-4/packages/assessment/sql/oracle/assessment-create.sql 10 Feb 2005 21:27:00 -0000 1.5 @@ -13,4 +13,3 @@ @ assessment-checks-create.sql @ assessment-actions-create.sql @ assessment-checks-package-create.sql -@ assessment-actions-insert.sql \ No newline at end of file Index: openacs-4/packages/assessment/sql/postgresql/assessment-actions-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/sql/postgresql/assessment-actions-create.sql,v diff -u -N -r1.2 -r1.3 --- openacs-4/packages/assessment/sql/postgresql/assessment-actions-create.sql 8 Feb 2005 22:55:58 -0000 1.2 +++ openacs-4/packages/assessment/sql/postgresql/assessment-actions-create.sql 10 Feb 2005 21:25:50 -0000 1.3 @@ -85,4 +85,150 @@ ); create sequence as_actions_log_action_log_id; -create sequence as_actions_params_parameter_id; \ No newline at end of file +create sequence as_action_params_parameter_id; + +select acs_object_type__create_type ( + 'as_action', + 'as_action', + 'as_actions', + 'acs_object', + 'as_actions', + 'action_id', + null, + 'f', + null, + 'as_action__name' +); + + + +create or replace function as_action__new (integer,varchar,varchar,text,integer,integer,integer) +returns integer as ' +declare + new__action_id alias for $1; + new__name alias for $2; + new__description alias for $3; + new__tcl_code alias for $4; + new__context_id alias for $5; + new__creation_user alias for $6; + new__package_id alias for $7; + v_action_id integer; +begin + v_action_id := acs_object__new ( + new__action_id, + ''as_action'', + now(), + new__creation_user, + null, + new__context_id, + ''t'', + null, + new__package_id + ); + insert into as_actions + (action_id,name,description,tcl_code) + values (v_action_id,new__name,new__description,new__tcl_code); + + return v_action_id; +end;' language 'plpgsql'; + + + +create or replace function as_action__delete (integer) +returns integer as ' +declare + del__action_id alias for $1; +begin + + + delete from as_action_params where action_id=del__action_id; + + delete from as_actions where action_id = del__action_id; + PERFORM acs_object__delete (del__action_id); + return del__action_id; + +end;' language 'plpgsql'; + + + +create or replace function as_action__default_actions (integer,integer,integer) +returns integer as ' +declare + new__context_id alias for $1; + new__creation_user alias for $2; + new__package_id alias for $3; + v_action_id integer; + v_parameter_id integer; +begin + + + v_action_id := as_action__new ( + null, + ''Register User'', + ''Register new users'', + ''set password [ad_generate_random_string] +db_transaction { +array set user_new_info [auth::create_user -username $user_name -email $email -first_names $first_names -last_name $last_name -password $password] +} +set admin_user_id [auth::test::get_admin_user_id] +set administration_name [db_string admin_name "select first_names || \'\' \'\' || last_name from +persons where person_id = :admin_user_id"] +set system_name [ad_system_name] +set system_url [ad_parameter -package_id [ad_acs_kernel_id] SystemURL ""]. +set admin_email [db_string unused "select email from parties where party_id = :admin_user_id"] +set message "$first_names $last_name, +You have been added as a user to $system_name +at $system_url +Login information: +Email: $email +Password: $password +(you may change your password after you log in) +Thank you, +$administration_name" +ns_sendmail "$email" "$admin_email" "You have been added as a user to [ad_system_name] at [ad_url]" "$message"'', + new__context_id, + new__creation_user, + new__package_id + ); + +v_parameter_id:= nextval(''as_action_params_parameter_id''); +insert into as_action_params (parameter_id, action_id,type, varname, description) values (v_parameter_id,v_action_id,''n'',''first_names'',''First Names of the User''); +v_parameter_id:= nextval(''as_action_params_parameter_id''); +insert into as_action_params (parameter_id, action_id,type, varname, description) values (v_parameter_id,v_action_id,''n'',''last_name'',''Last Name of the User''); +v_parameter_id:= nextval(''as_action_params_parameter_id''); +insert into as_action_params (parameter_id, action_id,type, varname, description) values (v_parameter_id,v_action_id,''n'',''email'',''Email of the User''); +v_parameter_id:= nextval(''as_action_params_parameter_id''); +insert into as_action_params (parameter_id, action_id,type, varname, description) values (v_parameter_id,v_action_id,''n'',''user_name'',''User name of the User''); + +v_action_id:= as_action__new ( + null, + ''Event Registration'', + ''Register user to event'', + ''set user_id [ad_conn user_id] +events::registration::new -event_id $event_id -user_id $user_id'', + new__context_id, + new__creation_user, + new__package_id + ); + +v_parameter_id:= nextval(''as_action_params_parameter_id''); +insert into as_action_params (parameter_id, action_id,type, varname, description,query) values (v_parameter_id,v_action_id,''q'',''event_id'',''Event to add the user'', ''select event_id,event_id from acs_events''); + +v_action_id:= as_action__new ( + null, + ''Add to Community'', + ''Add user to a community'', + ''set user_id [ad_conn user_id] +dotlrn_privacy::set_user_guest_p -user_id $user_id -value "t" +dotlrn::user_add -can_browse -user_id $user_id +dotlrn_community::add_user_to_community -community_id $community_id -user_id $user_id'', + new__context_id, + new__creation_user, + new__package_id + ); + +v_parameter_id:= nextval(''as_action_params_parameter_id''); +insert into as_action_params (parameter_id, action_id,type, varname, description,query) values (v_parameter_id,v_action_id,''q'',''community_id'',''Community to add the user'', ''select pretty_name,community_id from dotlrn_communities''); + + return v_action_id; +end;' language 'plpgsql'; Index: openacs-4/packages/assessment/sql/postgresql/assessment-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/sql/postgresql/assessment-create.sql,v diff -u -N -r1.17 -r1.18 --- openacs-4/packages/assessment/sql/postgresql/assessment-create.sql 4 Feb 2005 18:09:09 -0000 1.17 +++ openacs-4/packages/assessment/sql/postgresql/assessment-create.sql 10 Feb 2005 21:26:03 -0000 1.18 @@ -12,4 +12,4 @@ \i assessment-types-create.sql \i assessment-checks-create.sql \i assessment-actions-create.sql -\i assessment-actions-insert.sql + Index: openacs-4/packages/assessment/sql/postgresql/upgrade/upgrade-0.10d5-0.10d6.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/sql/postgresql/upgrade/upgrade-0.10d5-0.10d6.sql,v diff -u -N -r1.2 -r1.3 --- openacs-4/packages/assessment/sql/postgresql/upgrade/upgrade-0.10d5-0.10d6.sql 4 Feb 2005 18:09:09 -0000 1.2 +++ openacs-4/packages/assessment/sql/postgresql/upgrade/upgrade-0.10d5-0.10d6.sql 10 Feb 2005 21:26:03 -0000 1.3 @@ -8,4 +8,3 @@ -- alter table as_inter_item_checks add column assessment_id integer; -\i ../assessment-actions-insert.sql \ No newline at end of file