Index: openacs-4/packages/curriculum-central/curriculum-central.info
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/curriculum-central.info,v
diff -u -r1.6 -r1.7
--- openacs-4/packages/curriculum-central/curriculum-central.info	9 Jan 2006 05:46:49 -0000	1.6
+++ openacs-4/packages/curriculum-central/curriculum-central.info	22 Jan 2006 08:43:14 -0000	1.7
@@ -7,14 +7,14 @@
     <initial-install-p>f</initial-install-p>
     <singleton-p>f</singleton-p>
     
-    <version name="0.2.5d" url="http://openacs.org/repository/download/apm/curriculum-central-0.2.5d.apm">
+    <version name="0.3.0d" url="http://openacs.org/repository/download/apm/curriculum-central-0.3.0d.apm">
         <owner url="mailto:ncarroll@ee.usyd.edu.au">Nick Carroll</owner>
         <summary>An application for managing the subjects comprising a course of study in a School or University.</summary>
         <vendor url="http://www.weg.ee.usyd.edu.au">WEG</vendor>
         <description format="text/html">Curriculum Central is an application for managing subjects comprising a course of study in a School or University.  The application will allow academic staff to collaborate on course syllabus and rubrics, which can then be conveyed to students using course maps.</description>
         <maturity>0</maturity>
 
-        <provides url="curriculum-central" version="0.2.5d"/>
+        <provides url="curriculum-central" version="0.3.0d"/>
         <requires url="acs-content-repository" version="5.2.0d2"/>
         <requires url="acs-kernel" version="5.2.0d2"/>
         <requires url="acs-tcl" version="5.2.0d1"/>
Index: openacs-4/packages/curriculum-central/catalog/curriculum-central.en_US.ISO-8859-1.xml
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/catalog/curriculum-central.en_US.ISO-8859-1.xml,v
diff -u -r1.30 -r1.31
--- openacs-4/packages/curriculum-central/catalog/curriculum-central.en_US.ISO-8859-1.xml	12 Jan 2006 07:15:23 -0000	1.30
+++ openacs-4/packages/curriculum-central/catalog/curriculum-central.en_US.ISO-8859-1.xml	22 Jan 2006 08:43:15 -0000	1.31
@@ -2,6 +2,48 @@
 <message_catalog package_key="curriculum-central" package_version="0.1d" locale="en_US" charset="ISO-8859-1">
 
   <msg key="uos">UoS</msg>
+  <msg key="help_enter_year_name">Enter a name for a school year.  Eg Year 1.</msg>
+  <msg key="help_select_uos_to_map">Select UoS to map to the %stream_name% degree stream.</msg>
+  <msg key="help_select_semesters_that_uos_is_offered">Select the Semesters that this UoS is offered.  Note: You can select multiple entries by holding down the CTRL key whilst selecting.</msg>
+  <msg key="help_select_years_that_uos_is_offered">Select the Years that this UoS is offered.  Note: You can select multiple entries by holding down the CTRL key whilst selecting.</msg>
+  <msg key="help_select_prerequisites_for_uos">Select prerequisite UoS for the mapped UoS.  Note: You can select multiple entries by holding down the CTRL key whilst selecting.</msg>
+  <msg key="help_select_assumed_knowledge_for_uos">Select assumed knowledge for the mapped UoS.  Note: You can select multiple entries by holding down the CTRL key whilst selecting.</msg>
+  <msg key="help_select_corequisites_for_uos">Select co-requisites for the mapped UoS.  Note: You can select multiple entries by holding down the CTRL key whilst selecting.</msg>
+  <msg key="help_select_prohibitions_for_uos">Select prohibitions for the mapped UoS.  Note: You can select multiple entries by holding down the CTRL key whilst selecting.</msg>
+  <msg key="help_select_uos_no_longer_offered">Select (prohibited) UoS that are no longer offered for the mapped UoS.  Note: You can select multiple entries by holding down the CTRL key whilst selecting.</msg>
+  <msg key="assumed_knowledge">Assumed Knowledge</msg>
+  <msg key="corequisites">Co-Requisites</msg>
+  <msg key="prohibitions">Prohibitions</msg>
+  <msg key="no_longer_offered">Units no longer offered</msg>
+  <msg key="map_uos_to_stream">Map UoS to Stream</msg>
+  <msg key="edit_uos_to_stream_mapping">Edit UoS to Stream Mapping</msg>
+  <msg key="help_select_semesters_in_a_year">Select the semesters that apply to the school year.  Note: Hold the CTRL key down to select more than one semester.</msg>
+  <msg key="help_select_years_for_this_stream">Select years that apply to this degree stream.  Note: Hold the CTRL key down to select more than one year.</msg>
+  <msg key="you_are_not_the_coordinator_for">You are not the coordinator for any degree streams.</msg>
+  <msg key="map_uos_to_this_stream">Map a Unit of Study to this stream.</msg>
+  <msg key="streams_that_you_are_the_stream_coordinator_of">You have been assigned as the Stream Coordinator for the following degree streams.</msg>
+  <msg key="your_streams">Your Streams</msg>
+  <msg key="start_date_must_be_set_before_end_date">Start date must be set before end date.</msg>
+  <msg key="start_date">Start Date</msg>
+  <msg key="end_date">End Date</msg>
+  <msg key="years">Years</msg>
+  <msg key="help_enter_semester_name">Enter the name for a semester.  Eg 1st Semester, Spring, Fall, 2nd Term, etc.</msg>
+  <msg key="help_enter_start_date">Enter a start date.</msg>
+  <msg key="help_enter_end_date">Enter an end date.</msg>
+  <msg key="view_years">View Years</msg>
+  <msg key="add_a_year">Add a Year</msg>
+  <msg key="add_year">Add Year</msg>
+  <msg key="edit_year_info">Edit Year</msg>
+  <msg key="add_year_to_list">Add year to list.</msg>
+  <msg key="view_semesters">View Semesters</msg>
+  <msg key="add_a_semester">Add a Semester</msg>
+  <msg key="add_semester">Add Semester</msg>
+  <msg key="no_semesters_created">No semesters created</msg>
+  <msg key="add_semester_to_list">Add semester to list.</msg>
+  <msg key="help_enter_semesters_per_year">Enter the number of semesters in a year.</msg>
+  <msg key="semesters_in_a_year">Semesters in a Year</msg>
+  <msg key="semesters">Semesters</msg>
+  <msg key="only_stream_coordinators_can_develop_a_stream">Only stream coordinators can develop a stream</msg>
   <msg key="view_graduate_attributes">View Graduate Attributes</msg>
   <msg key="add_a_graduate_attribute">Add a Graduate Attribute</msg>
   <msg key="help_select_textbook_ids">Select textbooks from the list that will be used for this Unit of Study.  Hold the Ctrl key down whilst selecting to add more than one selection.</msg>
@@ -62,7 +104,7 @@
   <msg key="uos_textbook_set_revision">UoS Textbook Set Revision</msg>
   <msg key="uos_textbook_set_revisions">UoS Textbook Set Revisions</msg>
   <msg key="current_assessment_total">Current Assessment Total</msg>
-  <msg key="help_assess_method_ids">Select one or more assessment methods that are used in this Unit of Study.  To select more than one item from the list, hold down the Shirt key whilst selecting an item.  If an item doesn't appear in the list, then click &lt;a href=&quot;assess-method-ae?return_url=%return_url%&quot;&gt;here&lt;/a&gt; to add it (Note: clicking on the link will redirect you to another page).</msg>
+  <msg key="help_assess_method_ids">Select one or more assessment methods that are used in this Unit of Study.  To select more than one item from the list, hold down the CTRL key whilst selecting an item.  If an item doesn't appear in the list, then click &lt;a href=&quot;assess-method-ae?return_url=%return_url%&quot;&gt;here&lt;/a&gt; to add it (Note: clicking on the link will redirect you to another page).</msg>
   <msg key="assessment_methods">Assessment Methods</msg>
   <msg key="help_enter_type_of_assess_method">Enter a name for the type of assessment.</msg>
   <msg key="help_enter_assess_identifier">Enter an identifier to distinguish this assessment method from other assessment methods that you have created.  Use something like GENERAL for generic methods, or the UoS code such as ELEC1000 for more specific assessment methods.</msg>
@@ -83,7 +125,7 @@
   <msg key="uos_assessment_revisions">Uos Assessment Revisions</msg>
   <msg key="no_graduate_attributes_created">No graduate attributes have been created</msg>
   <msg key="add_graduate_attribute_to_list">Add graduate attributes to the list.</msg>
-  <msg key="help_graduate_attributes">Select one or more graduate attributes from the list that are associated with this Unit of Study.  To select more than one item from the list, hold down the Shirt key whilst selecting an item.  If an item doesn't appear in the list, then click &lt;a href=&quot;gradattr-ae?return_url=%return_url%&quot;&gt;here&lt;/a&gt; to add it (Note: clicking on the link will redirect you to another page).</msg>
+  <msg key="help_graduate_attributes">Select one or more graduate attributes from the list that are associated with this Unit of Study.  To select more than one item from the list, hold down the CTRL key whilst selecting an item.  If an item doesn't appear in the list, then click &lt;a href=&quot;gradattr-ae?return_url=%return_url%&quot;&gt;here&lt;/a&gt; to add it (Note: clicking on the link will redirect you to another page).</msg>
   <msg key="very_low">Very Low</msg>
   <msg key="low">Low</msg>
   <msg key="moderate">Moderate</msg>
@@ -120,7 +162,7 @@
   <msg key="help_online_course_content">The URL of the Unit of Study website where students can read the course content online, or interact with web-based learning activities.</msg>
   <msg key="uos_workload">UoS Workload</msg>
   <msg key="help_activity_log">For future reference, enter a short review of changes that were made.</msg>
-  <msg key="help_tl_approach_ids">Select one or more teaching and learning approaches that are used in this Unit of Study.  To select more than one item from the list, hold down the Shirt key whilst selecting an item.  If an item doesn't appear in the list, then click &lt;a href=&quot;tl-method-ae?return_url=%return_url%&quot;&gt;here&lt;/a&gt; to add it (Note: clicking on the link will redirect you to another page).</msg>
+  <msg key="help_tl_approach_ids">Select one or more teaching and learning approaches that are used in this Unit of Study.  To select more than one item from the list, hold down the CTRL key whilst selecting an item.  If an item doesn't appear in the list, then click &lt;a href=&quot;tl-method-ae?return_url=%return_url%&quot;&gt;here&lt;/a&gt; to add it (Note: clicking on the link will redirect you to another page).</msg>
   <msg key="view_details">View Details</msg>
   <msg key="view_all">View All</msg>
   <msg key="add_tl_approach">Add T&amp;L Approach</msg>
Index: openacs-4/packages/curriculum-central/sql/postgresql/semester-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/sql/postgresql/Attic/semester-create.sql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/curriculum-central/sql/postgresql/semester-create.sql	22 Jan 2006 08:43:15 -0000	1.1
@@ -0,0 +1,162 @@
+--
+-- packages/curriculum-central/sql/postgresql/semester-create.sql
+--
+-- @author Nick Carroll (nick.c@rroll.net)
+-- @creation-date 2005-11-08
+-- @cvs-id $Id: semester-create.sql,v 1.1 2006/01/22 08:43:15 ncarroll Exp $
+--
+--
+
+
+create function inline_0 ()
+returns integer as'
+begin 
+    PERFORM acs_object_type__create_type (
+	''cc_semester'',			-- object_type
+	''#curriculum-central.semester#'',	-- pretty_name
+	''#curriculum-central.semesters#'',	-- pretty_plural
+	''acs_object'',				-- supertype
+	''cc_semester'',			-- table_name
+	''semester_id'',			-- id_column
+	null,				-- package_name
+	''f'',				-- abstract_p
+	null,				-- type_extension_table
+	''cc_semester__name''		-- name_method
+	);
+
+    return 0;
+end;' language 'plpgsql';
+
+select inline_0 ();
+drop function inline_0 ();
+
+
+create table cc_semester (
+	semester_id	integer
+                        constraint cc_semester_semester_id_fk
+                        references acs_objects(object_id)
+			constraint cc_semester_semester_id_pk primary key,
+	name 		varchar(256)
+			constraint cc_semester_name_nn not null
+			constraint cc_semester_name_un unique,
+	start_date 	timestamptz,
+	end_date	timestamptz,
+	package_id	integer
+			constraint cc_semester_package_id_fk
+			references apm_packages(package_id) on delete cascade
+);
+
+
+--
+-- Attributes for the Semester Object
+--
+create function inline_1 ()
+returns integer as '
+begin
+    PERFORM acs_attribute__create_attribute (
+	  ''cc_semester'',		-- object_type
+	  ''name'',			-- attribute_name
+	  ''string'',			-- datatype
+	  ''curriculum-central.name'',	-- pretty_name
+	  ''curriculum-central.names'',	-- pretty_plural
+	  null,				-- table_name
+	  null,				-- column_name
+	  null,				-- default_value
+	  1,				-- min_n_values
+	  1,				-- max_n_values
+	  null,				-- sort_order
+	  ''type_specific'',		-- storage
+	  ''f''				-- static_p
+	);
+
+    return 0;
+end;' 
+language 'plpgsql';
+select inline_1 ();
+drop function inline_1 ();
+
+
+select define_function_args('cc_semester__new', 'semester_id,name,start_date,end_date,creation_user,creation_ip,package_id');
+
+create function cc_semester__new(integer, varchar, timestamptz, timestamptz, integer, varchar, integer)
+returns integer as'
+
+declare
+
+	p_semester_id		alias for $1;
+	p_name			alias for $2;
+	p_start_date		alias for $3;
+	p_end_date		alias for $4;
+	p_creation_user		alias for $5;
+	p_creation_ip		alias for $6;
+	p_package_id		alias for $7;
+
+	v_semester_id		cc_semester.semester_id%TYPE;
+begin
+
+	v_semester_id := acs_object__new (
+			p_semester_id,
+			''cc_semester'',
+			now(),
+			p_creation_user,
+			p_creation_ip,
+			p_package_id
+		);
+
+	insert into cc_semester values(v_semester_id, p_name, p_start_date, p_end_date, p_package_id);
+	
+	PERFORM acs_permission__grant_permission(
+          v_semester_id,
+          p_creation_user,
+          ''read''
+    	);
+
+	PERFORM acs_permission__grant_permission(
+          v_semester_id,
+          p_creation_user,
+          ''write''
+    	);
+
+	return v_semester_id;
+
+end;
+' language plpgsql;
+
+
+select define_function_args('cc_semester__delete', 'semester_id');
+
+create function cc_semester__delete (integer)
+returns integer as '
+declare
+  p_semester_id				alias for $1;
+begin
+    delete from acs_permissions
+		   where object_id = p_semester_id;
+
+	delete from cc_semester
+		   where semester_id = p_semester_id;
+
+	raise NOTICE ''Deleting Semester...'';
+	PERFORM acs_object__delete(p_semester_id);
+
+	return 0;
+
+end;' 
+language plpgsql;
+
+
+select define_function_args('cc_semester__name', 'semester_id');
+
+create function cc_semester__name (integer)
+returns varchar as '
+declare
+    p_semester_id      alias for $1;
+    v_semester_name    cc_semester.name%TYPE;
+begin
+	select name into v_semester_name
+		from cc_semester
+		where semester_id = p_semester_id;
+
+    return v_semester_name;
+end;
+' language plpgsql;
Index: openacs-4/packages/curriculum-central/sql/postgresql/stream-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/sql/postgresql/stream-create.sql,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/curriculum-central/sql/postgresql/stream-create.sql	20 Nov 2005 23:51:10 -0000	1.1
+++ openacs-4/packages/curriculum-central/sql/postgresql/stream-create.sql	22 Jan 2006 08:43:15 -0000	1.2
@@ -45,6 +45,8 @@
 			constraint cc_stream_stream_name_nn not null
 			constraint cc_stream_stream_name_un unique,
 	stream_code 	varchar(256),
+	year_ids	varchar(256),
+	semester_ids	varchar(256),
 	department_id	integer
 			constraint cc_stream_department_id_fk
 			references cc_department(department_id)
@@ -79,7 +81,7 @@
 	);
 
     PERFORM acs_attribute__create_attribute (
-	  ''cc_stream'',			-- object_type
+	  ''cc_stream'',		-- object_type
 	  ''stream_code'',		-- attribute_name
 	  ''string'',			-- datatype
 	  ''Stream Code'',		-- pretty_name
@@ -101,9 +103,9 @@
 drop function inline_1 ();
 
 
-select define_function_args('cc_stream__new', 'stream_id,coordinator_id,object_type,stream_name,stream_code,department_id,creation_user,creation_ip,package_id');
+select define_function_args('cc_stream__new', 'stream_id,coordinator_id,object_type,stream_name,stream_code,year_ids,semester_ids,department_id,creation_user,creation_ip,package_id');
 
-create function cc_stream__new(integer, integer, varchar, varchar, varchar, integer, integer, varchar, integer)
+create function cc_stream__new(integer, integer, varchar, varchar, varchar, varchar, varchar, integer, integer, varchar, integer)
 returns integer as'
 
 declare
@@ -113,10 +115,12 @@
 	p_object_type		alias for $3;
 	p_stream_name		alias for $4;
 	p_stream_code		alias for $5;
-	p_department_id		alias for $6;
-	p_creation_user		alias for $7;
-	p_creation_ip		alias for $8;
-	p_package_id		alias for $9;
+	p_year_ids		alias for $6;
+	p_semester_ids		alias for $7;
+	p_department_id		alias for $8;
+	p_creation_user		alias for $9;
+	p_creation_ip		alias for $10;
+	p_package_id		alias for $11;
 
 	v_stream_id		cc_stream.stream_id%TYPE;
 begin
@@ -130,7 +134,7 @@
 			p_package_id
 		);
 
-	insert into cc_stream values(v_stream_id, p_coordinator_id, p_stream_name, p_stream_code, p_department_id,  p_package_id);
+	insert into cc_stream values(v_stream_id, p_coordinator_id, p_stream_name, p_stream_code, p_year_ids, p_semester_ids, p_department_id,  p_package_id);
 	
 	PERFORM acs_permission__grant_permission(
           v_stream_id,
@@ -187,3 +191,7 @@
     return v_stream_name;
 end;
 ' language plpgsql;
+
+
+-- Create Stream to UoS mapping object.
+\i stream-uos-map-create.sql
Index: openacs-4/packages/curriculum-central/sql/postgresql/stream-uos-map-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/sql/postgresql/stream-uos-map-create.sql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/curriculum-central/sql/postgresql/stream-uos-map-create.sql	22 Jan 2006 08:43:15 -0000	1.1
@@ -0,0 +1,270 @@
+--
+-- packages/curriculum-central/sql/postgresql/stream-uos-map-create.sql
+--
+-- @author Nick Carroll (nick.c@rroll.net)
+-- @creation-date 2005-11-16
+-- @cvs-id $Id: stream-uos-map-create.sql,v 1.1 2006/01/22 08:43:15 ncarroll Exp $
+--
+--
+
+
+create function inline_0 ()
+returns integer as'
+begin 
+    PERFORM acs_object_type__create_type (
+	''cc_stream_uos_map'',				-- object_type
+	''#curriculum-central.stream_uos_map#'',	-- pretty_name
+	''#curriculum-central.stream_uos_maps#'',	-- pretty_plural
+	''acs_object'',					-- supertype
+	''cc_stream_uos_map'',				-- table_name
+	''map_id'',					-- id_column
+	null,						-- package_name
+	''f'',						-- abstract_p
+	null,						-- type_extension_table
+	null						-- name_method
+	);
+
+    return 0;
+end;' language 'plpgsql';
+
+select inline_0 ();
+drop function inline_0 ();
+
+
+-- content_item subtype
+create table cc_stream_uos_map (
+	map_id			integer
+                        	constraint cc_stream_uos_map_map_id_fk
+                        	references cr_items(item_id)
+				on delete cascade
+				constraint cc_stream_uos_map_map_id_pk
+				primary key,
+	stream_id		integer,
+	uos_id			integer,
+	live_revision_id	integer,
+	latest_revision_id	integer
+);
+
+
+-- Create the content_revision
+create table cc_stream_uos_map_rev (
+	map_rev_id		integer
+				constraint cc_stream_uos_map_rev_pk
+				primary key
+				constraint cc_stream_uos_map_rev_rev_id_fk
+				references cr_revisions(revision_id)
+				on delete cascade,
+	year_ids		varchar(256),
+	semester_ids		varchar(256),
+	prerequisite_ids	varchar(256),
+	assumed_knowledge_ids	varchar(256),
+	corequisite_ids		varchar(256),
+	prohibition_ids		varchar(256),
+	no_longer_offered_ids	varchar(256)
+);
+
+-- Create the UoS revision content type.
+select content_type__create_type (
+    'cc_stream_uos_map_rev',
+    'content_revision',
+    '#curriculum-central.stream_uos_map_revision#',
+    '#curriculum-central.stream_uos_map_revisions#',
+    'cc_stream_uos_map_rev',
+    'map_rev_id',
+    'content_revision.revision_name'
+);
+
+
+select define_function_args('cc_stream_uos_map__new', 'map_id,stream_id,uos_id,year_ids,semester_ids,prerequisite_ids,assumed_knowledge_ids,corequisite_ids,prohibition_ids,no_longer_offered_ids,creation_user,creation_ip,context_id,item_subtype;cc_stream_uos_map,content_type;cc_stream_uos_map_rev,object_type,package_id');
+
+create function cc_stream_uos_map__new(
+	integer,	-- map_id
+	integer,	-- stream_id
+	integer,	-- uos_id
+	varchar,	-- year_ids
+	varchar,	-- semester_ids
+	varchar,	-- prerequisite_ids
+	varchar,	-- assumed_knowledge_ids
+	varchar,	-- corequisite_ids
+	varchar,	-- prohibition_ids
+	varchar,	-- no_longer_offered_ids
+	integer,	-- creation_user
+	varchar,	-- creation_ip
+	integer,	-- context_id
+	varchar,	-- item_subtype
+	varchar,	-- content_type
+	varchar,	-- object_type
+	integer		-- package_id
+) returns integer as'
+declare
+
+	p_map_id			alias for $1;
+	p_stream_id			alias for $2;
+	p_uos_id			alias for $3;
+	p_year_ids			alias for $4;
+	p_semester_ids			alias for $5;
+	p_prerequisite_ids		alias for $6;
+	p_assumed_knowledge_ids		alias for $7;
+	p_corequisite_ids		alias for $8;
+	p_prohibition_ids		alias for $9;
+	p_no_longer_offered_ids		alias for $10;
+	p_creation_user			alias for $11;
+	p_creation_ip			alias for $12;
+	p_context_id			alias for $13;
+	p_item_subtype			alias for $14;
+	p_content_type			alias for $15;
+	p_object_type			alias for $16;
+	p_package_id			alias for $17;
+
+	v_map_id			cc_stream_uos_map.map_id%TYPE;
+	v_folder_id			integer;
+	v_revision_id			integer;
+	v_name				varchar;
+	v_rel_id			integer;
+begin
+	-- get the content folder for this instance
+	select folder_id into v_folder_id
+	    from cc_curriculum
+	    where curriculum_id = p_package_id;
+
+	-- Create a unique name
+	v_name := ''map_uos_'' || p_uos_id || ''_to_stream_'' || p_stream_id;
+
+	-- create the content item
+	v_map_id := content_item__new (
+		v_name,			-- name
+		v_folder_Id,		-- parent_id
+		p_map_id,		-- item_id
+		null,			-- locale
+		now(),			-- creation_date
+		p_creation_user,	-- creation_user
+		v_folder_id,		-- context_id
+		p_creation_ip,		-- creation_ip
+		p_item_subtype,		-- item_subtype
+		p_content_type,		-- content_type
+		null,			-- title
+		null,			-- description
+		null,			-- mime_type
+		null,			-- nls_language
+		null,			-- data
+		p_package_id
+	);
+
+	-- create the initial revision
+	v_revision_id := cc_stream_uos_map_rev__new (
+		null,				-- revision_id
+		v_map_id,			-- map_id
+		p_year_ids,			-- year_ids
+		p_semester_ids,			-- semester_ids
+		p_prerequisite_ids,		-- requisite_ids
+		p_assumed_knowledge_ids,	-- assumed_knowledge_ids
+		p_corequisite_ids,		-- corequisite_ids
+		p_prohibition_ids,		-- prohibition_ids
+		p_no_longer_offered_ids,	-- no_longer_offered_ids
+		now(),				-- creation_date
+		p_creation_user,		-- creation_user
+		p_creation_ip			-- creation_ip
+	);
+
+	-- create the item type row
+	insert into cc_stream_uos_map (map_id, stream_id, uos_id,
+	    latest_revision_id)
+	VALUES (v_map_id, p_stream_id, p_uos_id, v_revision_id);
+
+	return v_map_id;
+
+end;
+' language plpgsql;
+
+
+select define_function_args('cc_stream_uos_map__delete', 'map_id');
+
+create function cc_stream_uos_map__delete (integer)
+returns integer as '
+declare
+	p_map_id			alias for $1;
+begin
+
+	perform content_item__delete(p_map_id);	
+
+	return 0;
+
+end;
+' language 'plpgsql';
+
+
+create or replace function cc_stream_uos_map_rev__new (
+	integer,			-- revision_id
+	integer,			-- map_id
+	varchar,			-- year_ids
+	varchar,			-- semester_ids
+	varchar,			-- prerequisite_ids
+	varchar,			-- assumed_knowledge_ids
+	varchar,			-- corequisite_ids
+	varchar,			-- prohibition_ids
+	varchar,			-- no_longer_offered_ids
+	timestamptz,			-- creation_date
+	integer,			-- creation_user
+	varchar				-- creation_ip
+) returns int
+as '
+declare
+	p_revision_id				alias for $1;
+	p_map_id				alias for $2;
+	p_year_ids				alias for $3;
+	p_semester_ids				alias for $4;
+	p_prerequisite_ids			alias for $5;
+	p_assumed_knowledge_ids			alias for $6;
+	p_corequisite_ids			alias for $7;
+	p_prohibition_ids			alias for $8;
+	p_no_longer_offered_ids			alias for $9;
+	p_creation_date				alias for $10;
+	p_creation_user				alias for $11;
+	p_creation_ip				alias for $12;
+
+	v_revision_id				integer;
+begin
+
+	-- create the initial revision
+	v_revision_id := content_revision__new (
+		''#curriculum-central.stream_uos_map#'',  -- title
+		null,					-- description
+		current_timestamp,			-- publish_date
+		null,					-- mime_type
+		null,					-- nls_language
+		null,					-- new_data
+		p_map_id,				-- item_id
+		p_revision_id,				-- revision_id
+		p_creation_date,			-- creation_date
+		p_creation_user,			-- creation_user
+		p_creation_ip				-- creation_ip
+	);
+
+	-- Insert into the uos-specific revision table
+	INSERT into cc_stream_uos_map_rev (
+		map_rev_id,
+		year_ids,
+		semester_ids,
+		prerequisite_ids,
+		assumed_knowledge_ids,
+		corequisite_ids,
+		prohibition_ids,
+		no_longer_offered_ids
+	) VALUES (
+		v_revision_id,
+		p_year_ids,
+		p_semester_ids,
+		p_prerequisite_ids,
+		p_assumed_knowledge_ids,
+		p_corequisite_ids,
+		p_prohibition_ids,
+		p_no_longer_offered_ids
+	);
+
+	-- Update the latest revision id in cc_stream_uos_map
+	UPDATE cc_stream_uos_map SET latest_revision_id = v_revision_id
+	WHERE map_id = p_map_id;
+
+	return v_revision_id;
+end;
+' language 'plpgsql';
Index: openacs-4/packages/curriculum-central/sql/postgresql/uos-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/sql/postgresql/uos-create.sql,v
diff -u -r1.12 -r1.13
--- openacs-4/packages/curriculum-central/sql/postgresql/uos-create.sql	11 Jan 2006 00:49:17 -0000	1.12
+++ openacs-4/packages/curriculum-central/sql/postgresql/uos-create.sql	22 Jan 2006 08:43:15 -0000	1.13
@@ -71,7 +71,6 @@
 	uos_name 		varchar(256)
 				constraint cc_uos_rev_uos_name_nn not null,
 	credit_value		integer,
-	semester		varchar(32),
 	unit_coordinator_id	integer
 				constraint cc_uos_rev_coordinator_id_fk
 				references users(user_id)
@@ -93,15 +92,14 @@
 );
 
 
-select define_function_args('cc_uos__new', 'uos_id,uos_code,uos_name,unit_coordinator_id,credit_value,semester,activity_log,activity_log_format,creation_user,creation_ip,context_id,item_subtype;cc_uos,content_type;cc_uos_revision,object_type,package_id');
+select define_function_args('cc_uos__new', 'uos_id,uos_code,uos_name,unit_coordinator_id,credit_value,activity_log,activity_log_format,creation_user,creation_ip,context_id,item_subtype;cc_uos,content_type;cc_uos_revision,object_type,package_id');
 
 create function cc_uos__new(
 	integer,	-- uos_id
 	varchar,	-- uos_code
 	varchar,	-- uos_name
 	integer,	-- unit_coordinator_id
 	integer,	-- credit_value
-	varchar,	-- semester
 	text,		-- activity_log
 	varchar,	-- activity_log_format
 	integer,	-- creation_user
@@ -119,16 +117,15 @@
 	p_uos_name			alias for $3;
 	p_unit_coordinator_id		alias for $4;
 	p_credit_value			alias for $5;
-	p_semester			alias for $6;
-	p_activity_log			alias for $7;
-	p_activity_log_format		alias for $8;
-	p_creation_user			alias for $9;
-	p_creation_ip			alias for $10;
-	p_context_id			alias for $11;
-	p_item_subtype			alias for $12;
-	p_content_type			alias for $13;
-	p_object_type			alias for $14;
-	p_package_id			alias for $15;
+	p_activity_log			alias for $6;
+	p_activity_log_format		alias for $7;
+	p_creation_user			alias for $8;
+	p_creation_ip			alias for $9;
+	p_context_id			alias for $10;
+	p_item_subtype			alias for $11;
+	p_content_type			alias for $12;
+	p_object_type			alias for $13;
+	p_package_id			alias for $14;
 
 	v_uos_id			cc_uos.uos_id%TYPE;
 	v_folder_id			integer;
@@ -172,7 +169,6 @@
 		p_uos_code,			-- uos_code
 		p_uos_name,			-- uos_name
 		p_credit_value,			-- credit_value
-		p_semester,			-- semester
 		p_unit_coordinator_id,		-- unit_coordinator_id
 		p_activity_log,			-- activity_log
 		p_activity_log_format,		-- activity_log_format
@@ -245,7 +241,6 @@
 	varchar,			-- uos_code
 	varchar,			-- uos_name
 	integer,			-- credit_value
-	varchar,			-- semester
 	integer,			-- unit_coordinator_id
 	text,				-- activity_log
 	varchar,			-- activity_log_format
@@ -260,13 +255,12 @@
 	p_uos_code			alias for $3;
 	p_uos_name			alias for $4;
 	p_credit_value			alias for $5;
-	p_semester			alias for $6;
-	p_unit_coordinator_id		alias for $7;
-	p_activity_log			alias for $8;
-	p_activity_log_format		alias for $9;
-	p_creation_date			alias for $10;
-	p_creation_user			alias for $11;
-	p_creation_ip			alias for $12;
+	p_unit_coordinator_id		alias for $6;
+	p_activity_log			alias for $7;
+	p_activity_log_format		alias for $8;
+	p_creation_date			alias for $9;
+	p_creation_user			alias for $10;
+	p_creation_ip			alias for $11;
 
 	v_revision_id			integer;
 begin
@@ -288,11 +282,11 @@
 	-- insert into the uos-specific revision table
 	insert into cc_uos_revisions
 		(uos_revision_id, uos_code, uos_name, credit_value,
-		semester, unit_coordinator_id, activity_log,
+		unit_coordinator_id, activity_log,
 		activity_log_format)
 	values
 		(v_revision_id, p_uos_code, p_uos_name, p_credit_value,
-		p_semester, p_unit_coordinator_id, p_activity_log,
+		p_unit_coordinator_id, p_activity_log,
 		p_activity_log_format);
 
 	return v_revision_id;
@@ -329,3 +323,9 @@
 
 -- UoS Schedule
 \i uos-schedule-create.sql
+
+-- Semester
+\i semester-create.sql
+
+-- Year: 1st Year, 2nd Year, 3rd Year or Freshman, Sophomore, etc.
+\i year-create.sql
Index: openacs-4/packages/curriculum-central/sql/postgresql/year-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/sql/postgresql/year-create.sql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/curriculum-central/sql/postgresql/year-create.sql	22 Jan 2006 08:43:15 -0000	1.1
@@ -0,0 +1,158 @@
+--
+-- packages/curriculum-central/sql/postgresql/year-create.sql
+--
+-- @author Nick Carroll (nick.c@rroll.net)
+-- @creation-date 2005-11-08
+-- @cvs-id $Id: year-create.sql,v 1.1 2006/01/22 08:43:15 ncarroll Exp $
+--
+--
+
+
+create function inline_0 ()
+returns integer as'
+begin 
+    PERFORM acs_object_type__create_type (
+	''cc_year'',			-- object_type
+	''#curriculum-central.year#'',	-- pretty_name
+	''#curriculum-central.years#'',	-- pretty_plural
+	''acs_object'',			-- supertype
+	''cc_year'',			-- table_name
+	''year_id'',			-- id_column
+	null,				-- package_name
+	''f'',				-- abstract_p
+	null,				-- type_extension_table
+	''cc_year__name''		-- name_method
+	);
+
+    return 0;
+end;' language 'plpgsql';
+
+select inline_0 ();
+drop function inline_0 ();
+
+
+create table cc_year (
+	year_id	integer
+                        constraint cc_year_year_id_fk
+                        references acs_objects(object_id)
+			constraint cc_year_year_id_pk primary key,
+	name 		varchar(256)
+			constraint cc_year_name_nn not null
+			constraint cc_year_name_un unique,
+	package_id	integer
+			constraint cc_year_package_id_fk
+			references apm_packages(package_id) on delete cascade
+);
+
+
+--
+-- Attributes for the Year Object
+--
+create function inline_1 ()
+returns integer as '
+begin
+    PERFORM acs_attribute__create_attribute (
+	  ''cc_year'',		-- object_type
+	  ''name'',			-- attribute_name
+	  ''string'',			-- datatype
+	  ''curriculum-central.name'',	-- pretty_name
+	  ''curriculum-central.names'',	-- pretty_plural
+	  null,				-- table_name
+	  null,				-- column_name
+	  null,				-- default_value
+	  1,				-- min_n_values
+	  1,				-- max_n_values
+	  null,				-- sort_order
+	  ''type_specific'',		-- storage
+	  ''f''				-- static_p
+	);
+
+    return 0;
+end;' 
+language 'plpgsql';
+select inline_1 ();
+drop function inline_1 ();
+
+
+select define_function_args('cc_year__new', 'year_id,name,creation_user,creation_ip,package_id');
+
+create function cc_year__new(integer, varchar, integer, varchar, integer)
+returns integer as'
+
+declare
+
+	p_year_id		alias for $1;
+	p_name			alias for $2;
+	p_creation_user		alias for $3;
+	p_creation_ip		alias for $4;
+	p_package_id		alias for $5;
+
+	v_year_id		cc_year.year_id%TYPE;
+begin
+
+	v_year_id := acs_object__new (
+			p_year_id,
+			''cc_year'',
+			now(),
+			p_creation_user,
+			p_creation_ip,
+			p_package_id
+		);
+
+	insert into cc_year values(v_year_id, p_name, p_package_id);
+	
+	PERFORM acs_permission__grant_permission(
+          v_year_id,
+          p_creation_user,
+          ''read''
+    	);
+
+	PERFORM acs_permission__grant_permission(
+          v_year_id,
+          p_creation_user,
+          ''write''
+    	);
+
+	return v_year_id;
+
+end;
+' language plpgsql;
+
+
+select define_function_args('cc_year__delete', 'year_id');
+
+create function cc_year__delete (integer)
+returns integer as '
+declare
+  p_year_id				alias for $1;
+begin
+    delete from acs_permissions
+		   where object_id = p_year_id;
+
+	delete from cc_year
+		   where year_id = p_year_id;
+
+	raise NOTICE ''Deleting Year...'';
+	PERFORM acs_object__delete(p_year_id);
+
+	return 0;
+
+end;' 
+language plpgsql;
+
+
+select define_function_args('cc_year__name', 'year_id');
+
+create function cc_year__name (integer)
+returns varchar as '
+declare
+    p_year_id      alias for $1;
+    v_year_name    cc_year.name%TYPE;
+begin
+	select name into v_year_name
+		from cc_year
+		where year_id = p_year_id;
+
+    return v_year_name;
+end;
+' language plpgsql;
Index: openacs-4/packages/curriculum-central/tcl/curriculum-central-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/tcl/curriculum-central-procs.tcl,v
diff -u -r1.12 -r1.13
--- openacs-4/packages/curriculum-central/tcl/curriculum-central-procs.tcl	12 Jan 2006 07:15:23 -0000	1.12
+++ openacs-4/packages/curriculum-central/tcl/curriculum-central-procs.tcl	22 Jan 2006 08:43:15 -0000	1.13
@@ -75,6 +75,11 @@
 		-content_type "cc_uos_schedule_set_rev" \
 		-include_subtypes "t"
 
+	    content::folder::register_content_type \
+		-folder_id $folder_id \
+		-content_type "cc_stream_uos_map_rev" \
+		-include_subtypes "t"
+
 	    set keyword_id [content::keyword::new -heading "$instance_name"]
 
 	    # Inserts into cc_curriculum
Index: openacs-4/packages/curriculum-central/tcl/stream-procs-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/tcl/stream-procs-postgresql.xql,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/curriculum-central/tcl/stream-procs-postgresql.xql	24 Nov 2005 23:14:36 -0000	1.2
+++ openacs-4/packages/curriculum-central/tcl/stream-procs-postgresql.xql	22 Jan 2006 08:43:15 -0000	1.3
@@ -8,4 +8,59 @@
        SELECT * FROM cc_stream WHERE package_id = :package_id LIMIT 1
      </querytext>
    </fullquery>
+
+   <fullquery name="curriculum_central::stream::years_get_options.years">
+     <querytext>
+       SELECT name, year_id FROM cc_year WHERE package_id = :package_id
+     </querytext>
+   </fullquery>
+
+   <fullquery name="curriculum_central::stream::semesters_get_options.semesters">
+     <querytext>
+       SELECT name, semester_id FROM cc_semester WHERE package_id = :package_id
+     </querytext>
+   </fullquery>
+
+   <fullquery name="curriculum_central::stream::years_for_uos_get_options.year_ids">
+     <querytext>
+       SELECT year_ids FROM cc_stream WHERE stream_id = :stream_id
+     </querytext>
+   </fullquery>
+
+   <fullquery name="curriculum_central::stream::years_for_uos_get_options.year_name">
+     <querytext>
+       SELECT name FROM cc_year WHERE year_id = :year_id
+     </querytext>
+   </fullquery>
+
+   <fullquery name="curriculum_central::stream::semesters_in_a_year_get_options.semester_ids">
+     <querytext>
+       SELECT semester_ids FROM cc_stream WHERE stream_id = :stream_id
+     </querytext>
+   </fullquery>
+
+   <fullquery name="curriculum_central::stream::semesters_in_a_year_get_options.semester_name">
+     <querytext>
+       SELECT name from cc_semester WHERE semester_id = :semester_id
+     </querytext>
+   </fullquery>
+
+   <fullquery name="curriculum_central::stream::all_uos_except_get_options.all_uos">
+     <querytext>
+       SELECT uos_code || ' ' || uos_name as name, uos_id
+           FROM cc_uos
+	   WHERE package_id = :package_id
+	   AND uos_id != :except_uos_id
+     </querytext>
+   </fullquery>
+
+   <fullquery name="curriculum_central::stream::non_mapped_uos.non_mapped_uos">
+     <querytext>
+       SELECT uos.uos_code || ' ' ||uos.uos_name AS name, uos.uos_id
+           FROM cc_uos uos
+	   WHERE uos.package_id = :package_id
+	   AND uos.uos_id NOT IN (SELECT uos_id FROM cc_stream_uos_map WHERE stream_id = :stream_id)
+     </querytext>
+   </fullquery>
+
 </queryset>
Index: openacs-4/packages/curriculum-central/tcl/stream-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/tcl/stream-procs.tcl,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/curriculum-central/tcl/stream-procs.tcl	24 Nov 2005 23:14:36 -0000	1.2
+++ openacs-4/packages/curriculum-central/tcl/stream-procs.tcl	22 Jan 2006 08:43:15 -0000	1.3
@@ -30,3 +30,161 @@
     # Return 1 if at least one stream has been created, otherwise 0.
     return [db_0or1row streams_exist {}]
 }
+
+
+ad_proc curriculum_central::stream::years_get_options {
+    {-package_id ""}
+} {
+    Returns a two-column list of years that a stream runs for.
+
+    @param package_id ID of the current package instance.
+
+    @return Returns a two-column list of registered school years.
+} {
+    if { $package_id eq ""} {
+	set package_id [ad_conn package_id]
+    }
+
+    # Create an empty option that the user can select.  The value of
+    # which is an empty string.
+    set empty_option [list [list [list [_ curriculum-central.none]] 0]]
+    set year_list [db_list_of_lists years {}]
+
+    return [concat $empty_option $year_list]
+}
+
+
+ad_proc curriculum_central::stream::semesters_get_options {
+    {-package_id ""}
+} {
+    Returns a two-column list of years that a stream runs for.
+
+    @param package_id ID of the current package instance.
+
+    @return Returns a two-column list of registered semesters.
+} {
+    if { $package_id eq ""} {
+	set package_id [ad_conn package_id]
+    }
+
+    # Create an empty option that the user can select.  The value of
+    # which is an empty string.
+    set empty_option [list [list [list [_ curriculum-central.none]] 0]]
+    set semester_list [db_list_of_lists semesters {}]
+
+    return [concat $empty_option $semester_list]
+}
+
+
+ad_proc curriculum_central::stream::years_for_uos_get_options {
+    {-package_id ""}
+    {-stream_id:required}
+} {
+    Returns a two-column list of years that a Unit of Study can be assigned to.
+
+    @param package_id ID of the current package instance.
+    @param stream_id Stream ID to retrieve valid years for.
+
+    @return Returns a two-column list of registered school years.
+} {
+    if { $package_id eq ""} {
+	set package_id [ad_conn package_id]
+    }
+
+    # Create an empty option that the user can select.  The value of
+    # which is an empty string.
+    set year_list [list [list [list [_ curriculum-central.none]] 0]]
+
+    set year_ids [db_string year_ids {} -default ""]
+
+    foreach year_id $year_ids {
+	set year_name [db_string year_name {} -default ""]
+	lappend year_list "[list $year_name] $year_id"
+    }
+
+    return $year_list
+}
+
+
+ad_proc curriculum_central::stream::semesters_in_a_year_get_options {
+    {-package_id ""}
+    {-stream_id:required}
+} {
+    Returns a two-column list of years that a stream runs for.
+
+    @param package_id ID of the current package instance.
+    @param stream_id Stream ID to retrieve valid semesters for.
+
+    @return Returns a two-column list of registered semesters.
+} {
+    if { $package_id eq ""} {
+	set package_id [ad_conn package_id]
+    }
+
+    # Create an empty option that the user can select.  The value of
+    # which is an empty string.
+    set semester_list [list [list [list [_ curriculum-central.none]] 0]]
+
+    set semester_ids [db_string semester_ids {} -default ""]
+
+    foreach semester_id $semester_ids {
+	set semester_name [db_string semester_name {} -default ""]
+	lappend semester_list "[list $semester_name] $semester_id"
+    }
+
+    return $semester_list
+}
+
+
+ad_proc curriculum_central::stream::all_uos_except_get_options {
+    {-except_uos_id:required}
+    {-package_id ""}
+    {-empty_option:boolean}
+} {
+    Returns a two-column list of the names of all UoS and their
+    corresponding UoS ID.
+
+    @param package_id ID of the current package instance.
+    @param empty_option If empty_option flag is set to true, then an empty
+    option with name set to None, and the corresponding value set to 0 will
+    be added to the options list.  This is useful for lists that allow a 
+    none value to be selected.
+
+    @return Returns a two-column list of all UoS.
+} {
+    if { $package_id eq ""} {
+	set package_id [ad_conn package_id]
+    }
+
+    set uos_list [db_list_of_lists all_uos {}]
+
+    # Create an empty option that the user can select..
+    if {$empty_option_p} {
+	set empty [list [list [list [_ curriculum-central.none]] 0]]
+	return [concat $empty $uos_list]
+    } else {
+	return $uos_list
+    }
+}
+
+
+ad_proc curriculum_central::stream::non_mapped_uos {
+    {-stream_id:required}
+    {-package_id ""}
+} {
+    Returns a two-column list of the names of all UoS and their
+    corresponding UoS ID that have not been mapped to the given
+    Stream ID.
+
+    @param stream_id Stream ID.
+    @param package_id ID of the current package instance.
+
+    @return Returns a two-column list of all UoS that have not been mapped to
+    the given Stream ID.
+} {
+    if { $package_id eq ""} {
+	set package_id [ad_conn package_id]
+    }
+
+    return [db_list_of_lists non_mapped_uos {}]
+}
Index: openacs-4/packages/curriculum-central/tcl/uos-procs-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/tcl/uos-procs-postgresql.xql,v
diff -u -r1.18 -r1.19
--- openacs-4/packages/curriculum-central/tcl/uos-procs-postgresql.xql	12 Jan 2006 07:15:23 -0000	1.18
+++ openacs-4/packages/curriculum-central/tcl/uos-procs-postgresql.xql	22 Jan 2006 08:43:15 -0000	1.19
@@ -13,6 +13,12 @@
      </querytext>
    </fullquery>
 
+   <fullquery name="curriculum_central::uos::get_pretty_name.pretty_name">
+     <querytext>
+       SELECT uos_code || ' ' ||uos_name FROM cc_uos WHERE uos_id = :uos_id
+     </querytext>
+   </fullquery>
+
    <fullquery name="curriculum_central::uos::get_details.latest_details">
      <querytext>
        SELECT d.detail_id, dr.lecturer_id, dr.objectives,
@@ -221,7 +227,6 @@
 	   :uos_code,
 	   :uos_name,
 	   :credit_value,
-	   :semester,
 	   :unit_coordinator_id,
 	   :activity_log,
 	   :activity_log_format,
Index: openacs-4/packages/curriculum-central/tcl/uos-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/tcl/uos-procs.tcl,v
diff -u -r1.25 -r1.26
--- openacs-4/packages/curriculum-central/tcl/uos-procs.tcl	12 Jan 2006 07:15:23 -0000	1.25
+++ openacs-4/packages/curriculum-central/tcl/uos-procs.tcl	22 Jan 2006 08:43:15 -0000	1.26
@@ -109,7 +109,6 @@
 			uos_name
 			role_unit_coordinator
 			credit_value
-			semester
                     }
                 }
                 edit_tl {
@@ -302,7 +301,6 @@
     -uos_code:required
     -uos_name:required
     -credit_value:required
-    -semester:required
     -unit_coordinator_id:required
     -activity_log:required
     -activity_log_format:required
@@ -332,7 +330,6 @@
 			-uos_code $uos_code \
 			-uos_name $uos_name \
 			-credit_value $credit_value \
-			-semester $semester \
 			-unit_coordinator_id $unit_coordinator_id \
 			-activity_log $activity_log \
 			-activity_log_format $activity_log_format ]
@@ -377,7 +374,6 @@
     -uos_code:required
     -uos_name:required
     -credit_value:required
-    -semester:required
     -unit_coordinator_id:required
     -activity_log:required
     -activity_log_format:required
@@ -396,7 +392,6 @@
 		       [list uos_code $uos_code] \
 		       [list uos_name $uos_name] \
 		       [list credit_value $credit_value] \
-		       [list semester $semester] \
 		       [list unit_coordinator_id $unit_coordinator_id] \
 		       [list activity_log $activity_log] \
 		       [list activity_log_format $activity_log_format] \
@@ -953,6 +948,21 @@
 }
 
 
+ad_proc -public curriculum_central::uos::get_pretty_name {
+    {-uos_id:required}
+} {
+    Get the name for a UoS.
+
+    @param uos_id The ID of the Unit of Study for which we return
+    the name for.
+
+    @return The name of the given UoS ID.  Returns an empty string
+    if a name could not be found.
+} {
+    return [db_string pretty_name {} -default ""]
+}
+
+
 ad_proc -public curriculum_central::uos::get_details {
     {-uos_id:required}
     {-array:required}
Index: openacs-4/packages/curriculum-central/www/admin/faculty-depts.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/www/admin/faculty-depts.tcl,v
diff -u -r1.5 -r1.6
--- openacs-4/packages/curriculum-central/www/admin/faculty-depts.tcl	4 Dec 2005 07:34:26 -0000	1.5
+++ openacs-4/packages/curriculum-central/www/admin/faculty-depts.tcl	22 Jan 2006 08:43:15 -0000	1.6
@@ -32,7 +32,6 @@
     }
     department_name {
 	label "#curriculum-central.dept_name#"
-	link_url_eval {[export_vars -base dept {department_id}]}
     }
     hod {
 	label "#curriculum-central.hod#"
Index: openacs-4/packages/curriculum-central/www/admin/index.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/www/admin/index.adp,v
diff -u -r1.6 -r1.7
--- openacs-4/packages/curriculum-central/www/admin/index.adp	12 Jan 2006 07:15:24 -0000	1.6
+++ openacs-4/packages/curriculum-central/www/admin/index.adp	22 Jan 2006 08:43:15 -0000	1.7
@@ -20,6 +20,18 @@
   <li><a href="staff-ae">#curriculum-central.add_staff_member#</a></li>
   </ul>
 </li>
+<li><span>#curriculum-central.years#</span>
+  <ul>
+  <li><a href="years">#curriculum-central.view_years#</a></li>
+  <li><a href="year-ae">#curriculum-central.add_a_year#</a></li>
+  </ul>
+</li>
+<li><span>#curriculum-central.semesters#</span>
+  <ul>
+  <li><a href="semesters">#curriculum-central.view_semesters#</a></li>
+  <li><a href="semester-ae">#curriculum-central.add_a_semester#</a></li>
+  </ul>
+</li>
 <li><span>#curriculum-central.streams#</span>
   <ul>
   <li><a href="streams">#curriculum-central.view_streams#</a></li>
Index: openacs-4/packages/curriculum-central/www/admin/semester-ae-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/www/admin/Attic/semester-ae-postgresql.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/curriculum-central/www/admin/semester-ae-postgresql.xql	22 Jan 2006 08:43:15 -0000	1.1
@@ -0,0 +1,32 @@
+<?xml version="1.0"?>
+
+<queryset>
+   <rdbms><type>postgresql</type><version>7.4</version></rdbms>
+
+   <fullquery name="object_new">
+     <querytext>
+       SELECT cc_semester__new (NULL, :name, $start_date, $end_date,
+           :user_id, :peeraddr, :package_id)
+     </querytext>
+   </fullquery>
+
+   <fullquery name="semester_update">
+     <querytext>
+       UPDATE cc_semester
+	   name = :name,
+	   start_date = :start_date,
+	   end_date = :end_date
+	   WHERE semester_id = :semester_id
+     </querytext>
+   </fullquery>
+
+   <fullquery name="object_update">
+     <querytext>
+       UPDATE acs_objects
+           SET modifying_user = :modifying_user,
+	   modifying_ip = :modifying_ip
+	   WHERE object_id = :semester_id
+     </querytext>
+   </fullquery>
+
+</queryset>
Index: openacs-4/packages/curriculum-central/www/admin/semester-ae.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/www/admin/Attic/semester-ae.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/curriculum-central/www/admin/semester-ae.adp	22 Jan 2006 08:43:15 -0000	1.1
@@ -0,0 +1,6 @@
+<master>
+<property name="title">@page_title;noquote@</property>
+<property name="context">@context;noquote@</property>
+<property name="focus">semester.name</property>
+
+<formtemplate id="semester"></formtemplate>
\ No newline at end of file
Index: openacs-4/packages/curriculum-central/www/admin/semester-ae.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/www/admin/Attic/semester-ae.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/curriculum-central/www/admin/semester-ae.tcl	22 Jan 2006 08:43:15 -0000	1.1
@@ -0,0 +1,66 @@
+ad_page_contract {
+    Add/Edit a semester.
+
+    @author Nick Carroll (nick.c@rroll.net)
+    @creation-date 2005-11-20
+    @cvs-id $Id: semester-ae.tcl,v 1.1 2006/01/22 08:43:15 ncarroll Exp $
+} {
+    semester_id:integer,optional
+    {return_url "semesters"}
+}
+
+if { [info exists semester_id] } {
+    set page_title [_ curriculum-central.edit_semester]
+} else {
+    set page_title [_ curriculum-central.add_semester]
+}
+
+set context [list $page_title]
+set package_id [ad_conn package_id]
+set user_id [ad_conn user_id]
+set peeraddr [ad_conn peeraddr]
+
+ad_form -name semester -cancel_url $return_url -form {
+    {semester_id:key(acs_object_id_seq)}
+    {return_url:text(hidden) {value $return_url}}
+    {name:text
+	{html {size 50}}
+	{label "#curriculum-central.name#" }
+	{help_text "[_ curriculum-central.help_enter_semester_name]"}
+    }
+    {start_date:date,to_sql(sql_date),to_html(display_date)
+	{label "#curriculum-central.start_date#" }
+	{help_text "[_ curriculum-central.help_enter_start_date]"}
+	{format "[lc_get formbuilder_date_format]"}
+    }
+    {end_date:date,to_sql(sql_date),to_html(display_date)
+	{label "#curriculum-central.end_date#"}
+	{help_text "[_ curriculum-central.help_enter_end_date]"}
+	{format "[lc_get formbuilder_date_format]"}
+    }
+} -select_query {
+       SELECT name, start_date, end_date
+	   FROM cc_semester WHERE semester_id = :semester_id
+} -validate {
+    {start_date
+        { [template::util::date::compare $start_date $end_date] <= 0 }
+        "#curriculum-central.start_date_must_be_set_before_end_date#"
+    }
+} -new_data {
+ns_log Warning "NC: start_date: $start_date end_date $end_date"
+
+    # Can't use package_instantiate_object because the underlying
+    # db_exec_plsql can't know that the contents of the start_date and
+    # end_date contain functions and not variables
+    db_exec_plsql object_new {}
+
+} -edit_data {
+    set modifying_user [ad_conn user_id]
+    set modifying_ip [ad_conn peeraddr]
+
+    db_dml semester_update {}
+    db_dml object_update {}
+} -after_submit {
+    ad_returnredirect $return_url
+    ad_script_abort
+}
Index: openacs-4/packages/curriculum-central/www/admin/semesters-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/www/admin/Attic/semesters-postgresql.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/curriculum-central/www/admin/semesters-postgresql.xql	22 Jan 2006 08:43:15 -0000	1.1
@@ -0,0 +1,15 @@
+<?xml version="1.0"?>
+
+<queryset>
+   <rdbms><type>postgresql</type><version>7.4</version></rdbms>
+
+   <fullquery name="get_semesters">
+     <querytext>
+       SELECT s.semester_id, s.name, s.start_date, s.end_date
+	   FROM cc_semester s
+	   WHERE package_id = :package_id
+	   [template::list::orderby_clause -orderby -name "semesters"]
+     </querytext>
+   </fullquery>
+
+</queryset>
Index: openacs-4/packages/curriculum-central/www/admin/semesters.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/www/admin/Attic/semesters.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/curriculum-central/www/admin/semesters.adp	22 Jan 2006 08:43:15 -0000	1.1
@@ -0,0 +1,5 @@
+<master>
+<property name="title">@page_title;noquote@</property>
+<property name="context">@context;noquote@</property>
+
+<listtemplate name="semesters"></listtemplate>
\ No newline at end of file
Index: openacs-4/packages/curriculum-central/www/admin/semesters.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/www/admin/Attic/semesters.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/curriculum-central/www/admin/semesters.tcl	22 Jan 2006 08:43:15 -0000	1.1
@@ -0,0 +1,57 @@
+ad_page_contract {
+    Page for creating semesters.
+
+    @author Nick Carroll (nick.c@rroll.net)
+    @creation-date 2005-11-15
+    @cvs-id $Id: semesters.tcl,v 1.1 2006/01/22 08:43:15 ncarroll Exp $
+} {
+    {orderby "name,asc"}
+}
+
+set page_title "[_ curriculum-central.semesters]"
+set context [list [_ curriculum-central.semesters]]
+set package_id [ad_conn package_id]
+
+set elements {
+    edit {
+	sub_class narrow
+	display_template {
+	    <img src="/shared/images/Edit16.gif" height="16" width="16" border="0">
+	}
+	link_url_eval {[export_vars -base semester-ae { semester_id }]}
+	link_html {title "#curriculum-central.edit_semester_info#"}
+    }
+    name {
+	label "#curriculum-central.name#"
+    }
+    start_date {
+	label "#curriculum-central.start_date#"
+	display_eval { [lc_time_fmt $start_date %d/%m/%y] }
+    }
+    end_date {
+	label "#curriculum-central.end_date#"
+	display_eval { [lc_time_fmt $end_date %d/%m/%y] }
+    }
+    delete {
+	sub_class narrow
+	display_template {
+	    <img src="/shared/images/Delete16.gif" height="16" width="16" border="0">
+	}
+    }
+}
+
+template::list::create \
+    -name semesters \
+    -actions [list "#curriculum-central.add_semester#" [export_vars -base semester-ae {}] "#curriculum-central.add_semester_to_list#"] \
+    -multirow semesters \
+    -no_data "#curriculum-central.no_semesters_created#" \
+    -elements $elements \
+    -orderby {
+        name {orderby {lower(name)}}
+	start_date {orderby {start_date}}
+	end_date {orderby {end_date}}
+    }
+
+db_multirow semesters get_semesters {}
+
+ad_return_template
\ No newline at end of file
Index: openacs-4/packages/curriculum-central/www/admin/stream-ae-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/www/admin/stream-ae-postgresql.xql,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/curriculum-central/www/admin/stream-ae-postgresql.xql	20 Nov 2005 23:51:11 -0000	1.1
+++ openacs-4/packages/curriculum-central/www/admin/stream-ae-postgresql.xql	22 Jan 2006 08:43:15 -0000	1.2
@@ -9,6 +9,8 @@
            SET coordinator_id = :coordinator_id,
 	   stream_name = :stream_name,
 	   stream_code = :stream_code,
+	   year_ids = :year_ids,
+	   semester_ids = :semester_ids,
 	   department_id = :department_id
 	   WHERE stream_id = :stream_id
      </querytext>
Index: openacs-4/packages/curriculum-central/www/admin/stream-ae.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/www/admin/stream-ae.tcl,v
diff -u -r1.3 -r1.4
--- openacs-4/packages/curriculum-central/www/admin/stream-ae.tcl	4 Dec 2005 07:34:26 -0000	1.3
+++ openacs-4/packages/curriculum-central/www/admin/stream-ae.tcl	22 Jan 2006 08:43:15 -0000	1.4
@@ -31,6 +31,18 @@
 	{label "#curriculum-central.stream_code#" }
 	{help_text "[_ curriculum-central.help_enter_stream_code]"}
     }
+    {year_ids:text(multiselect),multiple
+	{label "#curriculum-central.years#"}
+	{options [curriculum_central::stream::years_get_options]}
+	{html {size 5}}
+	{help_text "[_ curriculum-central.help_select_years_for_this_stream]"}
+    }
+    {semester_ids:text(multiselect),multiple
+	{label "#curriculum-central.semesters_in_a_year#"}
+	{options [curriculum_central::stream::semesters_get_options]}
+	{html {size 5}}
+	{help_text "[_ curriculum-central.help_select_semesters_in_a_year]"}
+    }
     {department_id:integer(select)
 	{label "#curriculum-central.department#" }
 	{options [curriculum_central::departments_get_options] }
@@ -43,12 +55,18 @@
     }
 } -select_query {
        SELECT coordinator_id, stream_name, stream_code,
-           department_id
+           year_ids, semester_ids, department_id
 	   FROM cc_stream WHERE stream_id = :stream_id
 } -new_data {
+    
+
     package_instantiate_object \
 	-var_list [list [list package_id $package_id] \
 		        [list object_type cc_stream] \
+		        [list stream_name $stream_name] \
+		        [list stream_code $stream_code] \
+		        [list year_ids $year_ids] \
+		        [list semester_ids $semester_ids] \
 		        [list department_id $department_id] \
 		        [list coordinator_id $coordinator_id]] \
 	-form_id stream cc_stream
Index: openacs-4/packages/curriculum-central/www/admin/streams.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/www/admin/streams.tcl,v
diff -u -r1.3 -r1.4
--- openacs-4/packages/curriculum-central/www/admin/streams.tcl	4 Dec 2005 07:34:26 -0000	1.3
+++ openacs-4/packages/curriculum-central/www/admin/streams.tcl	22 Jan 2006 08:43:15 -0000	1.4
@@ -30,6 +30,7 @@
 	label "#curriculum-central.stream_name#"
     }
     stream_code {
+	sub_class narrow
 	label "#curriculum-central.stream_code#"
     }
     department {
Index: openacs-4/packages/curriculum-central/www/admin/year-ae-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/www/admin/year-ae-postgresql.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/curriculum-central/www/admin/year-ae-postgresql.xql	22 Jan 2006 08:43:15 -0000	1.1
@@ -0,0 +1,23 @@
+<?xml version="1.0"?>
+
+<queryset>
+   <rdbms><type>postgresql</type><version>7.4</version></rdbms>
+
+   <fullquery name="year_update">
+     <querytext>
+       UPDATE cc_year
+	   name = :name
+	   WHERE year_id = :year_id
+     </querytext>
+   </fullquery>
+
+   <fullquery name="object_update">
+     <querytext>
+       UPDATE acs_objects
+           SET modifying_user = :modifying_user,
+	   modifying_ip = :modifying_ip
+	   WHERE object_id = :year_id
+     </querytext>
+   </fullquery>
+
+</queryset>
Index: openacs-4/packages/curriculum-central/www/admin/year-ae.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/www/admin/year-ae.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/curriculum-central/www/admin/year-ae.adp	22 Jan 2006 08:43:15 -0000	1.1
@@ -0,0 +1,6 @@
+<master>
+<property name="title">@page_title;noquote@</property>
+<property name="context">@context;noquote@</property>
+<property name="focus">year.name</property>
+
+<formtemplate id="year"></formtemplate>
\ No newline at end of file
Index: openacs-4/packages/curriculum-central/www/admin/year-ae.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/www/admin/year-ae.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/curriculum-central/www/admin/year-ae.tcl	22 Jan 2006 08:43:15 -0000	1.1
@@ -0,0 +1,49 @@
+ad_page_contract {
+    Add/Edit a year.
+
+    @author Nick Carroll (nick.c@rroll.net)
+    @creation-date 2005-11-20
+    @cvs-id $Id: year-ae.tcl,v 1.1 2006/01/22 08:43:15 ncarroll Exp $
+} {
+    year_id:integer,optional
+    {return_url "years"}
+}
+
+if { [info exists year_id] } {
+    set page_title [_ curriculum-central.edit_year]
+} else {
+    set page_title [_ curriculum-central.add_year]
+}
+
+set context [list $page_title]
+set package_id [ad_conn package_id]
+set user_id [ad_conn user_id]
+set peeraddr [ad_conn peeraddr]
+
+ad_form -name year -cancel_url $return_url -form {
+    {year_id:key(acs_object_id_seq)}
+    {return_url:text(hidden) {value $return_url}}
+    {name:text
+	{html {size 50}}
+	{label "#curriculum-central.name#" }
+	{help_text "[_ curriculum-central.help_enter_year_name]"}
+    }
+} -select_query {
+       SELECT name FROM cc_year WHERE year_id = :year_id
+} -new_data {
+
+    package_instantiate_object \
+	-var_list [list [list package_id $package_id] \
+		        [list name $name]] \
+	-form_id year cc_year
+
+} -edit_data {
+    set modifying_user [ad_conn user_id]
+    set modifying_ip [ad_conn peeraddr]
+
+    db_dml year_update {}
+    db_dml object_update {}
+} -after_submit {
+    ad_returnredirect $return_url
+    ad_script_abort
+}
Index: openacs-4/packages/curriculum-central/www/admin/years-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/www/admin/years-postgresql.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/curriculum-central/www/admin/years-postgresql.xql	22 Jan 2006 08:43:15 -0000	1.1
@@ -0,0 +1,15 @@
+<?xml version="1.0"?>
+
+<queryset>
+   <rdbms><type>postgresql</type><version>7.4</version></rdbms>
+
+   <fullquery name="get_years">
+     <querytext>
+       SELECT year_id, name
+	   FROM cc_year
+	   WHERE package_id = :package_id
+	   [template::list::orderby_clause -orderby -name "years"]
+     </querytext>
+   </fullquery>
+
+</queryset>
Index: openacs-4/packages/curriculum-central/www/admin/years.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/www/admin/years.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/curriculum-central/www/admin/years.adp	22 Jan 2006 08:43:15 -0000	1.1
@@ -0,0 +1,5 @@
+<master>
+<property name="title">@page_title;noquote@</property>
+<property name="context">@context;noquote@</property>
+
+<listtemplate name="years"></listtemplate>
\ No newline at end of file
Index: openacs-4/packages/curriculum-central/www/admin/years.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/www/admin/years.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/curriculum-central/www/admin/years.tcl	22 Jan 2006 08:43:15 -0000	1.1
@@ -0,0 +1,47 @@
+ad_page_contract {
+    Page for creating years.
+
+    @author Nick Carroll (nick.c@rroll.net)
+    @creation-date 2005-11-15
+    @cvs-id $Id: years.tcl,v 1.1 2006/01/22 08:43:15 ncarroll Exp $
+} {
+    {orderby "name,asc"}
+}
+
+set page_title "[_ curriculum-central.years]"
+set context [list [_ curriculum-central.years]]
+set package_id [ad_conn package_id]
+
+set elements {
+    edit {
+	sub_class narrow
+	display_template {
+	    <img src="/shared/images/Edit16.gif" height="16" width="16" border="0">
+	}
+	link_url_eval {[export_vars -base year-ae { year_id }]}
+	link_html {title "#curriculum-central.edit_year_info#"}
+    }
+    name {
+	label "#curriculum-central.name#"
+    }
+    delete {
+	sub_class narrow
+	display_template {
+	    <img src="/shared/images/Delete16.gif" height="16" width="16" border="0">
+	}
+    }
+}
+
+template::list::create \
+    -name years \
+    -actions [list "#curriculum-central.add_year#" [export_vars -base year-ae {}] "#curriculum-central.add_year_to_list#"] \
+    -multirow years \
+    -no_data "#curriculum-central.no_years_created#" \
+    -elements $elements \
+    -orderby {
+        name {orderby {lower(name)}}
+    }
+
+db_multirow years get_years {}
+
+ad_return_template
\ No newline at end of file
Index: openacs-4/packages/curriculum-central/www/coordinate/index.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/www/coordinate/index.adp,v
diff -u -r1.7 -r1.8
--- openacs-4/packages/curriculum-central/www/coordinate/index.adp	6 Jan 2006 12:37:39 -0000	1.7
+++ openacs-4/packages/curriculum-central/www/coordinate/index.adp	22 Jan 2006 08:43:15 -0000	1.8
@@ -12,12 +12,8 @@
 <ul>
 <if @stream_coordinator_p@>
 <li><a href="uos-add">#curriculum-central.add_unit_of_study#</a></li>
+<li><a href="streams">#curriculum-central.view_streams#</a></li>
 </if>
 <li><a href="uos-pending">#curriculum-central.your_pending_units_of_study#</a> (@num_users_pending@ #curriculum-central.pending#)</li>
 <li><a href="uos-all-pending">#curriculum-central.all_pending_units_of_study#</a> (@num_all_pending@ #curriculum-central.pending#)</li>
 </ul>
-
-<h3>Things To Do</h3>
-<ul>
-<li>Develop Stream - Assign Units of Study to a stream (core/recommended)</li>
-</ul>
Index: openacs-4/packages/curriculum-central/www/coordinate/stream-map-ae-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/www/coordinate/stream-map-ae-postgresql.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/curriculum-central/www/coordinate/stream-map-ae-postgresql.xql	22 Jan 2006 08:43:15 -0000	1.1
@@ -0,0 +1,49 @@
+<?xml version="1.0"?>
+
+<queryset>
+   <rdbms><type>postgresql</type><version>7.4</version></rdbms>
+
+   <fullquery name="stream_name">
+     <querytext>
+       SELECT cc_stream__name(:stream_id)
+     </querytext>
+   </fullquery>
+
+   <fullquery name="form_info">
+     <querytext>
+	SELECT map.uos_id, rev.year_ids, rev.semester_ids,
+   	    rev.prerequisite_ids, rev.assumed_knowledge_ids,
+	    rev.corequisite_ids, rev.prohibition_ids, rev.no_longer_offered_ids
+	FROM cc_stream_uos_map map, cc_stream_uos_map_rev rev
+	WHERE map.map_id = :map_id
+	AND rev.revision_id = map.latest_revision_id
+     </querytext>
+   </fullquery>
+
+   <fullquery name="new_revision">
+     <querytext>
+       SELECT cc_stream_uos_map_rev__new (
+           NULL,
+	   :map_id,
+	   :year_ids,
+	   :semester_ids,
+	   :prerequisite_ids,
+	   :assumed_knowledge_ids,
+	   :corequisite_ids,
+	   :prohibition_ids,
+	   :no_longer_offered_ids,
+	   now(),
+	   :modifying_user,
+	   :modifying_ip
+       )
+     </querytext>
+   </fullquery>
+
+   <fullquery name="set_live_revision">
+     <querytext>
+       UPDATE cc_stream_uos_map SET live_revision_id = :new_revision_id
+           WHERE map_id = :map_id
+     </querytext>
+   </fullquery>
+
+</queryset>
Index: openacs-4/packages/curriculum-central/www/coordinate/stream-map-ae.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/www/coordinate/stream-map-ae.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/curriculum-central/www/coordinate/stream-map-ae.adp	22 Jan 2006 08:43:15 -0000	1.1
@@ -0,0 +1,6 @@
+<master>
+<property name="title">@page_title;noquote@</property>
+<property name="context">@context;noquote@</property>
+
+
+<formtemplate id="stream_map"></formtemplate>
\ No newline at end of file
Index: openacs-4/packages/curriculum-central/www/coordinate/stream-map-ae.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/www/coordinate/stream-map-ae.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/curriculum-central/www/coordinate/stream-map-ae.tcl	22 Jan 2006 08:43:15 -0000	1.1
@@ -0,0 +1,149 @@
+ad_page_contract {
+    Page for developing streams.
+
+    Displays a form for mapping a Unit of Study to the given stream_id.
+
+    @author Nick Carroll (nick.c@rroll.net)
+    @creation-date 2006-01-13
+    @cvs-id $Id: stream-map-ae.tcl,v 1.1 2006/01/22 08:43:15 ncarroll Exp $
+} {
+    stream_id:integer
+    uos_id:integer,optional
+    map_id:integer,optional
+    {return_url "streams"}
+}
+
+auth::require_login
+set user_id [ad_conn user_id]
+
+# Only stream coordinators can develop a stream.
+if { ![curriculum_central::staff::stream_coordinator_p $user_id] } {
+    ad_returnredirect -message [_ curriculum-central.only_stream_coordinators_can_develop_a_stream] index
+}
+
+set stream_name [db_string stream_name {} -default ""]
+set package_id [ad_conn package_id]
+
+# If uos_id exists, then we are editing, otherwise we are creating a new
+# mapping between UoS and Stream.
+if { [info exists uos_id] } {
+    set page_title "[_ curriculum-central.edit_uos_to_stream_mapping]: $stream_name"
+
+    set requisite_uos_options \
+	[curriculum_central::stream::all_uos_except_get_options \
+	     -empty_option -except_uos_id $uos_id]
+
+    # Create form for mapping a Unit of Study to the given stream_id.
+    ad_form -name stream_map -cancel_url $return_url -form {
+	{map_id:key}
+	{stream_id:integer(hidden) {value $stream_id}}
+	{return_url:text(hidden) {value $return_url}}
+	{uos_id:integer(hidden) {value $uos_id}}
+	{uos_name:text(inform)
+	    {label "[_ curriculum-central.uos]"}
+	    {value "[curriculum_central::uos::get_pretty_name -uos_id $uos_id]"}
+	}
+	{year_ids:text(multiselect)
+	    {label "[_ curriculum-central.years]"}
+	    {options "[curriculum_central::stream::years_for_uos_get_options -stream_id $stream_id]"}
+	    {html {size 5}}
+	    {help_text "[_ curriculum-central.help_select_years_that_uos_is_offered]"}
+	}
+	{semester_ids:text(multiselect)
+	    {label "[_ curriculum-central.semesters]"}
+	    {options "[curriculum_central::stream::semesters_in_a_year_get_options -stream_id $stream_id]"}
+	    {html {size 5}}
+	    {help_text "[_ curriculum-central.help_select_semesters_that_uos_is_offered]"}
+	}
+	{prerequisite_ids:text(multiselect)
+	    {label "[_ curriculum-central.prerequisites]"}
+	    {options $requisite_uos_options}
+	    {html {size 5}}
+	    {help_text "[_ curriculum-central.help_select_prerequisites_for_uos]"}
+	}
+	{assumed_knowledge_ids:text(multiselect)
+	    {label "[_ curriculum-central.assumed_knowledge]"}
+	    {options $requisite_uos_options}
+	    {html {size 5}}
+	    {help_text "[_ curriculum-central.help_select_assumed_knowledge_for_uos]"}
+	}
+	{corequisite_ids:text(multiselect)
+	    {label "[_ curriculum-central.corequisites]"}
+	    {options $requisite_uos_options}
+	    {html {size 5}}
+	    {help_text "[_ curriculum-central.help_select_corequisites_for_uos]"}
+	}
+	{prohibition_ids:text(multiselect)
+	    {label "[_ curriculum-central.prohibitions]"}
+	    {options $requisite_uos_options}
+	    {html {size 5}}
+	    {help_text "[_ curriculum-central.help_select_prohibitions_for_uos]"}
+	}
+	{no_longer_offered_ids:text(multiselect)
+	    {label "[_ curriculum-central.no_longer_offered]"}
+	    {options $requisite_uos_options}
+	    {html {size 5}}
+	    {help_text "[_ curriculum-central.help_select_uos_no_longer_offered]"}
+	}
+    } -select_query_name {
+	form_info
+    } -new_data {
+	# Create new CR object
+	package_instantiate_object \
+	    -var_list [list \
+	        [list package_id $package_id] \
+		[list stream_id $stream_id] \
+		[list uos_id $uos_id] \
+		[list year_ids $year_ids] \
+		[list semester_ids $semester_ids] \
+		[list prerequisite_ids $prerequisite_ids] \
+		[list assumed_knowledge_ids $assumed_knowledge_ids] \
+		[list corequisite_ids $corequisite_ids] \
+		[list prohibition_ids $prohibition_ids] \
+		[list no_longer_offered_ids $no_longer_offered_ids] \
+		[list object_type "cc_stream_uos_map"]] \
+	    "cc_stream_uos_map"
+	
+    } -edit_data {
+	
+	set modifying_user [ad_conn user_id]
+	set modifying_ip [ad_conn peeraddr]
+	
+	# Create new revision
+	set new_revision_id [db_exec_plsql new_revision {}]
+	
+	# Make the new revision the live revision
+	content::item::set_live_revision -revision_id $new_revision_id
+	db_dml set_live_revision {}
+	
+    } -after_submit {
+	ad_returnredirect $return_url
+	ad_script_abort
+    }
+    
+} else {
+    # Adding a new mapping, so we want to select a value for UoS.
+    set page_title "[_ curriculum-central.map_uos_to_stream]: $stream_name"
+
+    ad_form -name stream_map -cancel_url $return_url -form {
+	{map_id:key}
+	{stream_id:integer(hidden) {value $stream_id}}
+	{return_url:text(hidden) {value $return_url}}
+	{uos_id:integer(select)
+	    {label "[_ curriculum-central.uos]"}
+	    {options "[curriculum_central::stream::non_mapped_uos -stream_id $stream_id]"}
+	    {help_text "[_ curriculum-central.help_select_uos_to_map]"}
+	    {mode edit}
+	}
+    } -after_submit {
+	ad_returnredirect [export_vars \
+			       -base stream-map-ae {stream_id uos_id map_id}]
+	ad_script_abort
+    }
+}
+
+set context [list [list . [_ curriculum-central.coordinate]] \
+		 [list streams [_ curriculum-central.your_streams]] \
+		 $page_title]
+
+ad_return_template
Index: openacs-4/packages/curriculum-central/www/coordinate/streams-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/www/coordinate/streams-postgresql.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/curriculum-central/www/coordinate/streams-postgresql.xql	22 Jan 2006 08:43:15 -0000	1.1
@@ -0,0 +1,18 @@
+<?xml version="1.0"?>
+
+<queryset>
+   <rdbms><type>postgresql</type><version>7.4</version></rdbms>
+
+   <fullquery name="get_streams">
+     <querytext>
+       SELECT s.stream_id, s.stream_name, s.stream_code,
+           (SELECT d.department_name FROM cc_department d
+               WHERE d.department_id = s.department_id) as department
+	   FROM cc_stream s
+	   WHERE package_id = :package_id
+	   AND s.coordinator_id = :user_id
+	   [template::list::orderby_clause -orderby -name "streams"]
+     </querytext>
+   </fullquery>
+
+</queryset>
Index: openacs-4/packages/curriculum-central/www/coordinate/streams.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/www/coordinate/streams.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/curriculum-central/www/coordinate/streams.adp	22 Jan 2006 08:43:15 -0000	1.1
@@ -0,0 +1,8 @@
+<master>
+<property name="title">@page_title;noquote@</property>
+<property name="context">@context;noquote@</property>
+
+#curriculum-central.streams_that_you_are_the_stream_coordinator_of#
+<p />
+
+<listtemplate name="streams"></listtemplate>
\ No newline at end of file
Index: openacs-4/packages/curriculum-central/www/coordinate/streams.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/www/coordinate/streams.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/curriculum-central/www/coordinate/streams.tcl	22 Jan 2006 08:43:15 -0000	1.1
@@ -0,0 +1,55 @@
+ad_page_contract {
+    Displays a list of streams that the stream coordinator is responsible
+    for.
+
+    @author Nick Carroll (nick.c@rroll.net)
+    @creation-date 2005-11-15
+    @cvs-id $Id: streams.tcl,v 1.1 2006/01/22 08:43:15 ncarroll Exp $
+} {
+    {orderby "stream_name,asc"}
+}
+
+set page_title "[_ curriculum-central.your_streams]"
+set context [list [list . [_ curriculum-central.coordinate]] $page_title]
+set package_id [ad_conn package_id]
+set user_id [ad_conn user_id]
+
+# Only stream coordinators can develop a stream.
+if { ![curriculum_central::staff::stream_coordinator_p $user_id] } {
+    ad_returnredirect -message [_ curriculum-central.only_stream_coordinators_can_develop_a_stream] index
+}
+
+set elements {
+    edit {
+	sub_class narrow
+	display_template {
+	    <img src="/shared/images/Edit16.gif" height="16" width="16" border="0">
+	}
+	link_url_eval {[export_vars -base stream-map-ae { stream_id }]}
+	link_html {title "#curriculum-central.map_uos_to_this_stream#"}
+    }
+    stream_name {
+	label "#curriculum-central.stream_name#"
+    }
+    stream_code {
+	label "#curriculum-central.stream_code#"
+    }
+    department {
+	label "#curriculum-central.department#"
+    }
+}
+
+template::list::create \
+    -name streams \
+    -multirow streams \
+    -no_data "#curriculum-central.you_are_not_the_coordinator_for#" \
+    -elements $elements \
+    -orderby {
+	stream_name {orderby {lower(stream_name)}}
+	stream_code {orderby {lower(stream_code)}}
+	department {orderby {department_id}}
+    }
+
+db_multirow streams get_streams {}
+
+ad_return_template
\ No newline at end of file
Index: openacs-4/packages/curriculum-central/www/coordinate/uos-add.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/www/coordinate/uos-add.tcl,v
diff -u -r1.6 -r1.7
--- openacs-4/packages/curriculum-central/www/coordinate/uos-add.tcl	3 Jan 2006 03:23:28 -0000	1.6
+++ openacs-4/packages/curriculum-central/www/coordinate/uos-add.tcl	22 Jan 2006 08:43:15 -0000	1.7
@@ -36,7 +36,6 @@
 set context [list [list . [_ curriculum-central.coordinate]] $page_title]
 
 # Create the form.
-# TODO: Fix up form.  Can use drop-down boxes for some of the fields.
 ad_form -name uos -cancel_url $return_url -form {
     {uos_id:key(acs_object_id_seq)}
 
@@ -52,10 +51,6 @@
 	{label "#curriculum-central.credit_value#"}
 	{html {size 50}}	
     }
-    {semester:integer
-	{label "#curriculum-central.semester_offering#"}
-	{html {size 50}}
-    }
     {unit_coordinator_id:integer(select)
 	{label "#curriculum-central.unit_coordinator#"}
 	{options [curriculum_central::staff_get_options] }
@@ -78,7 +73,6 @@
 	-uos_code $uos_code \
 	-uos_name $uos_name \
 	-credit_value $credit_value \
-	-semester $semester \
 	-unit_coordinator_id $unit_coordinator_id \
 	-activity_log [template::util::richtext::get_property contents $activity_log] \
 	-activity_log_format [template::util::richtext::get_property format $activity_log]
Index: openacs-4/packages/curriculum-central/www/coordinate/uos-edit.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/www/coordinate/uos-edit.tcl,v
diff -u -r1.15 -r1.16
--- openacs-4/packages/curriculum-central/www/coordinate/uos-edit.tcl	11 Jan 2006 03:52:21 -0000	1.15
+++ openacs-4/packages/curriculum-central/www/coordinate/uos-edit.tcl	22 Jan 2006 08:43:15 -0000	1.16
@@ -94,12 +94,6 @@
         {html {size 3}}
 	{mode display}
     }
-    {semester:integer
-	{label "[_ curriculum-central.semester_offering]"}
-	{value $uos(semester)}
-        {html {size 3}}
-	{mode display}
-    }
 }