--
-- PostgreSQL database dump
--

SET client_encoding = 'UTF8';
SET check_function_bodies = false;
SET client_min_messages = warning;

SET search_path = public, pg_catalog;

SET default_tablespace = '';

SET default_with_oids = false;


--
-- Release Notes
-- Version : B.6Aa 
-- Updated : 2010/03/02
--


--
-- Data for Name: versionmatch; Type: TABLE DATA; Schema: public; Owner: postgres
--

DELETE FROM versionmatch WHERE read_only = 0;

UPDATE versionmatch SET client_version='B.6Aa' WHERE read_only = 1;


--
-- Data for Name: serverinf; Type: TABLE DATA; Schema: public; Owner: postgres
--

UPDATE serverinf SET "version"='B.6Aa';

ALTER TABLE serverinf ADD COLUMN firewall_ipv4_address character varying(50);
ALTER TABLE serverinf ADD COLUMN firewall_ipv6_address character varying(50);


--
-- Data for Name: ucuser_profile; Type: TABLE DATA; Schema: public; Owner: postgres
--

ALTER TABLE ucuser_profile ADD COLUMN access_through_server_firewall boolean DEFAULT false;


--
-- Data for Name: serverstatus; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY serverstatus (name, ip_address, status, relay_count) FROM stdin;
Web Server	127.0.0.1	0	\N
\.


--
-- Data for Name: versionmatch; Type: TABLE DATA; Schema: public; Owner: postgres
--

UPDATE limitrestriction SET spec=15000 WHERE property='115';
UPDATE limitrestriction SET spec=15000 WHERE property='117';
UPDATE limitrestriction SET spec=15000 WHERE property='103';


--
-- Name: schedule_datalist; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE schedule_datalist ADD COLUMN recurrence_state integer DEFAULT 0;


--
-- Function: get_schedule_data(character varying, character varying, integer)
--

DROP FUNCTION get_schedule_data(character varying, character varying, integer);


--
-- Name: schedule_data; Type: VIEW; Schema: public; Owner: postgres
--

DROP VIEW schedule_data;

CREATE OR REPLACE VIEW schedule_data AS 
 SELECT sch.serial_key, sch.folder_name, sch.folder_key, sch.creator_key, sch.created_dateinf, sch.created_timeinf, sch.start_dateinf, sch.start_timeinf, sch.end_dateinf, sch.end_timeinf, sch.subject, sch.schedule_location, sch.contents, sch.attendees, sch.notify_flag, sch.notify_type, sch.notify_timegap, sch.open_to_others, sch.outlook_id, sch.public_flag, sch.scenario_key, imr.destination_type, imr.destination_id, sch.recurrence_state
   FROM ( SELECT sd.serial_key, sf.folder_name, sd.folder_key, sd.creator_key, sd.created_dateinf, sd.created_timeinf, sd.start_dateinf, sd.start_timeinf, sd.end_dateinf, sd.end_timeinf, sd.subject, sd.schedule_location, sd.contents, sd.attendees, sd.notify_flag::integer AS notify_flag, sd.notify_type, sd.notify_timegap, sd.open_to_others::integer AS open_to_others, sd.outlook_id, sf.public_flag::integer AS public_flag, sd.scenario_key, sd.recurrence_state
           FROM schedule_datalist sd, schedule_folderlist sf
          WHERE sd.folder_key = sf.serial_key) sch
   LEFT JOIN imr_usergroup imr ON sch.scenario_key = imr.scenario_key;

ALTER TABLE schedule_data OWNER TO postgres;


--
-- Function: get_schedule_data(character varying, character varying, integer)
--

CREATE OR REPLACE FUNCTION get_schedule_data(start_day character varying, end_day character varying, creator integer)
  RETURNS SETOF schedule_data AS
$BODY$DECLARE

    start_day ALIAS FOR $1;
    end_day ALIAS FOR $2;
    creator ALIAS FOR $3;
    r RECORD;
    f RECORD;
    sinf_r schedule_data%ROWTYPE;
    sinf_f schedule_folderlist%ROWTYPE;
    
BEGIN

    FOR f IN 
	SELECT 	* 
	FROM 	schedule_folderlist
	WHERE 	public_flag = true or (public_flag = false and creator_key = creator)
    LOOP

	    FOR r IN 
		SELECT 	* 
		FROM 	schedule_data
		WHERE 	folder_key = f.serial_key AND (end_dateinf::date >= start_day::date and end_day::date >= start_dateinf::date)
		LOOP
		
			sinf_r = r;
		        RETURN NEXT sinf_r; 

		END LOOP; 

    END LOOP; 

    RETURN; 

END;$BODY$
  LANGUAGE 'plpgsql' VOLATILE
  COST 100
  ROWS 1000;
ALTER FUNCTION get_schedule_data(character varying, character varying, integer) OWNER TO postgres;


--
-- Release Notes
-- Version : 2.6Ac 
-- Updated : 2010/03/12
--


--
-- Data for Name: versionmatch; Type: TABLE DATA; Schema: public; Owner: postgres
--

DELETE FROM versionmatch WHERE read_only = 0;

UPDATE versionmatch SET client_version='2.6Ac' WHERE read_only = 1;


--
-- Data for Name: serverinf; Type: TABLE DATA; Schema: public; Owner: postgres
--

UPDATE serverinf SET "version"='2.6Ac';


--
-- Data for Name: versionmatch; Type: TABLE DATA; Schema: public; Owner: postgres
--

UPDATE limitrestriction SET spec=15000 WHERE property='115';
UPDATE limitrestriction SET spec=15000 WHERE property='117';
UPDATE limitrestriction SET spec=15000 WHERE property='103';


--
-- Release Notes
-- Version : 2.6Ad 
-- Updated : 2010/03/23
--


--
-- Data for Name: versionmatch; Type: TABLE DATA; Schema: public; Owner: postgres
--

DELETE FROM versionmatch WHERE read_only = 0;

UPDATE versionmatch SET client_version='2.6Ad' WHERE read_only = 1;


--
-- Data for Name: serverinf; Type: TABLE DATA; Schema: public; Owner: postgres
--

UPDATE serverinf SET "version"='2.6Ad';


--
-- Data for Name: protocol; Type: TABLE DATA; Schema: public; Owner: postgres
--

UPDATE protocol
   SET lvalue=0, dvalue=0
 WHERE property_key='302';


--
-- Name: schedule_datalist; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE schedule_datalist ADD COLUMN original_dateinf character varying(20);


--
-- Release Notes
-- Version : 2.6Ae 
-- Updated : 2010/03/30
--


--
-- Data for Name: versionmatch; Type: TABLE DATA; Schema: public; Owner: postgres
--

DELETE FROM versionmatch WHERE read_only = 0;

UPDATE versionmatch SET client_version='2.6Ae' WHERE read_only = 1;


--
-- Data for Name: serverinf; Type: TABLE DATA; Schema: public; Owner: postgres
--

UPDATE serverinf SET "version"='2.6Ae';


--
-- Release Notes
-- Version : 2.6Af 
-- Updated : 2010/04/06
--


--
-- Data for Name: versionmatch; Type: TABLE DATA; Schema: public; Owner: postgres
--

DELETE FROM versionmatch WHERE read_only = 0;

UPDATE versionmatch SET client_version='2.6Af' WHERE read_only = 1;


--
-- Data for Name: serverinf; Type: TABLE DATA; Schema: public; Owner: postgres
--

UPDATE serverinf SET "version"='2.6Af';


--
-- Data for Name: protocol; Type: TABLE DATA; Schema: public; Owner: postgres
--

UPDATE protocol
   SET lvalue=0, dvalue=0
 WHERE property_key='305';


COPY protocol (lvalue, dvalue, property_key, property, min_value, max_value) FROM stdin;
0	0	501	FLAG_IM_SESSION_RELAY	0	1
\.


--
-- Release Notes
-- Version : 2.6Ag 
-- Updated : 2010/07/05
--


--
-- Data for Name: versionmatch; Type: TABLE DATA; Schema: public; Owner: postgres
--

DELETE FROM versionmatch WHERE read_only = 0;

UPDATE versionmatch SET client_version='2.6Ag' WHERE read_only = 1;


--
-- Data for Name: serverinf; Type: TABLE DATA; Schema: public; Owner: postgres
--

UPDATE serverinf SET "version"='2.6Ag';


--
-- PostgreSQL database dump complete
--