Compare commits

...

21 Commits

Author SHA1 Message Date
Léo Serre b41d768cca Fix comment creation in archived articles 2019-01-30 21:09:43 +01:00
Léo Serre fa8f50a3d9 Restore blog behavior with three tables 2019-01-30 21:03:48 +01:00
Léo Serre 2e2a79ed76 Rename SQL id field in contents 2019-01-30 20:49:32 +01:00
Léo Serre 50e8552059 Restore wiki behavior with three tables 2019-01-30 19:49:26 +01:00
Léo Serre 55ed7db3c4 Add sequences on new content tables ids 2019-01-30 19:02:09 +01:00
Léo Serre 35275d217b Change SQL schema to add more hierarchy in contents: content -> localized -> version 2019-01-29 19:33:57 +01:00
Léo Serre c6d69666bb Fix exampleweb URL with trailing / 2019-01-29 19:33:07 +01:00
leosw 2aa41e692d Fix blog RSS list page 2019-01-23 13:42:34 +01:00
leosw f215a6cf08 Fix blog list page 2019-01-23 13:32:54 +01:00
Léo Serre 2258aa3fe0 Fix blog comment management 2018-11-18 21:59:55 +01:00
Léo Serre f32e528d01 Remove trailing dot in blog/wiki name view page 2018-11-05 22:51:13 +01:00
Léo Serre 6356faa9ca Fix blog article deletion/restoration 2018-11-05 22:39:06 +01:00
Léo Serre 41c1ea61b6 Fix blog history view 2018-11-05 22:34:48 +01:00
Léo Serre 3ad4a6d08e Store author as contributor in wiki/blog 2018-11-05 22:31:20 +01:00
Léo Serre b5115182d5 fix blog edition 2018-11-05 22:29:14 +01:00
Léo Serre 7a29f0825f fix blog view page 2018-11-05 22:05:42 +01:00
Léo Serre 9aa7498db7 fix blog creation page 2018-11-05 21:35:21 +01:00
Léo Serre 7d3a00fd68 Start rewrite model for new article page 2018-11-04 19:01:10 +01:00
Léo Serre 1f7a77e0d6 Fix blog view page using new sql scheme 2018-11-04 18:55:48 +01:00
Léo Serre 19b5cec9b5 Fix FA in blog edit view 2018-11-04 18:51:54 +01:00
Léo Serre a3d964e9c5 First work on article list 2018-11-04 08:35:56 +01:00
12 changed files with 753 additions and 458 deletions

View File

@ -2,10 +2,8 @@
-- PostgreSQL database dump
--
-- Dumped from database version 10.5
-- Dumped by pg_dump version 10.5
-- Started on 2018-10-17 20:33:22 CEST
-- Dumped from database version 11.1
-- Dumped by pg_dump version 11.1
SET statement_timeout = 0;
SET lock_timeout = 0;
@ -18,7 +16,6 @@ SET client_min_messages = warning;
SET row_security = off;
--
-- TOC entry 7 (class 2615 OID 17905)
-- Name: topology; Type: SCHEMA; Schema: -; Owner: kabano
--
@ -28,8 +25,6 @@ CREATE SCHEMA topology;
ALTER SCHEMA topology OWNER TO kabano;
--
-- TOC entry 3890 (class 0 OID 0)
-- Dependencies: 7
-- Name: SCHEMA topology; Type: COMMENT; Schema: -; Owner: kabano
--
@ -37,24 +32,6 @@ COMMENT ON SCHEMA topology IS 'PostGIS Topology schema';
--
-- TOC entry 1 (class 3079 OID 12281)
-- Name: plpgsql; Type: EXTENSION; Schema: -; Owner:
--
CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
--
-- TOC entry 3891 (class 0 OID 0)
-- Dependencies: 1
-- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner:
--
COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
--
-- TOC entry 3 (class 3079 OID 16398)
-- Name: postgis; Type: EXTENSION; Schema: -; Owner:
--
@ -62,8 +39,6 @@ CREATE EXTENSION IF NOT EXISTS postgis WITH SCHEMA public;
--
-- TOC entry 3892 (class 0 OID 0)
-- Dependencies: 3
-- Name: EXTENSION postgis; Type: COMMENT; Schema: -; Owner:
--
@ -71,7 +46,6 @@ COMMENT ON EXTENSION postgis IS 'PostGIS geometry, geography, and raster spatial
--
-- TOC entry 2 (class 3079 OID 17906)
-- Name: postgis_topology; Type: EXTENSION; Schema: -; Owner:
--
@ -79,8 +53,6 @@ CREATE EXTENSION IF NOT EXISTS postgis_topology WITH SCHEMA topology;
--
-- TOC entry 3893 (class 0 OID 0)
-- Dependencies: 2
-- Name: EXTENSION postgis_topology; Type: COMMENT; Schema: -; Owner:
--
@ -88,7 +60,6 @@ COMMENT ON EXTENSION postgis_topology IS 'PostGIS topology spatial types and fun
--
-- TOC entry 2036 (class 1247 OID 18254)
-- Name: content_type_enum; Type: TYPE; Schema: public; Owner: kabano
--
@ -102,7 +73,6 @@ CREATE TYPE public.content_type_enum AS ENUM (
ALTER TYPE public.content_type_enum OWNER TO kabano;
--
-- TOC entry 2021 (class 1247 OID 18166)
-- Name: poi_key_enum; Type: TYPE; Schema: public; Owner: kabano
--
@ -115,7 +85,6 @@ CREATE TYPE public.poi_key_enum AS ENUM (
ALTER TYPE public.poi_key_enum OWNER TO kabano;
--
-- TOC entry 2007 (class 1247 OID 18088)
-- Name: poi_type_enum; Type: TYPE; Schema: public; Owner: kabano
--
@ -132,7 +101,6 @@ CREATE TYPE public.poi_type_enum AS ENUM (
ALTER TYPE public.poi_type_enum OWNER TO kabano;
--
-- TOC entry 2001 (class 1247 OID 18057)
-- Name: user_rank_enum; Type: TYPE; Schema: public; Owner: kabano
--
@ -149,7 +117,6 @@ CREATE TYPE public.user_rank_enum AS ENUM (
ALTER TYPE public.user_rank_enum OWNER TO kabano;
--
-- TOC entry 237 (class 1259 OID 18332)
-- Name: content_comments_sequence; Type: SEQUENCE; Schema: public; Owner: kabano
--
@ -168,13 +135,11 @@ SET default_tablespace = '';
SET default_with_oids = false;
--
-- TOC entry 229 (class 1259 OID 18288)
-- Name: content_comments; Type: TABLE; Schema: public; Owner: kabano
--
CREATE TABLE public.content_comments (
id integer DEFAULT nextval('public.content_comments_sequence'::regclass) NOT NULL,
permalink character varying(255),
version integer,
creation_date timestamp without time zone,
update_date timestamp without time zone,
@ -190,7 +155,6 @@ CREATE TABLE public.content_comments (
ALTER TABLE public.content_comments OWNER TO kabano;
--
-- TOC entry 236 (class 1259 OID 18330)
-- Name: content_contributors_sequence; Type: SEQUENCE; Schema: public; Owner: kabano
--
@ -205,7 +169,6 @@ CREATE SEQUENCE public.content_contributors_sequence
ALTER TABLE public.content_contributors_sequence OWNER TO kabano;
--
-- TOC entry 228 (class 1259 OID 18271)
-- Name: content_contributors; Type: TABLE; Schema: public; Owner: kabano
--
@ -219,7 +182,65 @@ CREATE TABLE public.content_contributors (
ALTER TABLE public.content_contributors OWNER TO kabano;
--
-- TOC entry 235 (class 1259 OID 18328)
-- Name: content_locales_sequence; Type: SEQUENCE; Schema: public; Owner: kabano
--
CREATE SEQUENCE public.content_locales_sequence
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.content_locales_sequence OWNER TO kabano;
--
-- Name: content_locales; Type: TABLE; Schema: public; Owner: kabano
--
CREATE TABLE public.content_locales (
id integer DEFAULT nextval('public.content_locales_sequence'::regclass) NOT NULL,
content_id integer NOT NULL,
locale character varying(32) NOT NULL,
author integer NOT NULL
);
ALTER TABLE public.content_locales OWNER TO kabano;
--
-- Name: content_versions_sequence; Type: SEQUENCE; Schema: public; Owner: kabano
--
CREATE SEQUENCE public.content_versions_sequence
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.content_versions_sequence OWNER TO kabano;
--
-- Name: content_versions; Type: TABLE; Schema: public; Owner: kabano
--
CREATE TABLE public.content_versions (
id integer DEFAULT nextval('public.content_versions_sequence'::regclass) NOT NULL,
version integer DEFAULT 0 NOT NULL,
update_date timestamp without time zone NOT NULL,
is_archive boolean DEFAULT false NOT NULL,
name character varying(255),
content text,
locale_id integer NOT NULL
);
ALTER TABLE public.content_versions OWNER TO kabano;
--
-- Name: contents_sequence; Type: SEQUENCE; Schema: public; Owner: kabano
--
@ -234,31 +255,22 @@ CREATE SEQUENCE public.contents_sequence
ALTER TABLE public.contents_sequence OWNER TO kabano;
--
-- TOC entry 227 (class 1259 OID 18230)
-- Name: contents; Type: TABLE; Schema: public; Owner: kabano
--
CREATE TABLE public.contents (
id integer DEFAULT nextval('public.contents_sequence'::regclass) NOT NULL,
permalink character varying(255) NOT NULL,
version integer DEFAULT 0 NOT NULL,
locale character varying(32) NOT NULL,
creation_date timestamp without time zone NOT NULL,
update_date timestamp without time zone NOT NULL,
author integer NOT NULL,
is_public boolean DEFAULT true NOT NULL,
is_archive boolean DEFAULT false NOT NULL,
is_commentable boolean DEFAULT true NOT NULL,
type public.content_type_enum NOT NULL,
name character varying(255),
content text
type public.content_type_enum NOT NULL
);
ALTER TABLE public.contents OWNER TO kabano;
--
-- TOC entry 221 (class 1259 OID 18067)
-- Name: locales; Type: TABLE; Schema: public; Owner: kabano
--
@ -272,7 +284,6 @@ CREATE TABLE public.locales (
ALTER TABLE public.locales OWNER TO kabano;
--
-- TOC entry 234 (class 1259 OID 18326)
-- Name: poi_comments_sequence; Type: SEQUENCE; Schema: public; Owner: kabano
--
@ -287,7 +298,6 @@ CREATE SEQUENCE public.poi_comments_sequence
ALTER TABLE public.poi_comments_sequence OWNER TO kabano;
--
-- TOC entry 226 (class 1259 OID 18203)
-- Name: poi_comments; Type: TABLE; Schema: public; Owner: kabano
--
@ -309,7 +319,6 @@ CREATE TABLE public.poi_comments (
ALTER TABLE public.poi_comments OWNER TO kabano;
--
-- TOC entry 233 (class 1259 OID 18324)
-- Name: poi_contributors_sequence; Type: SEQUENCE; Schema: public; Owner: kabano
--
@ -324,7 +333,6 @@ CREATE SEQUENCE public.poi_contributors_sequence
ALTER TABLE public.poi_contributors_sequence OWNER TO kabano;
--
-- TOC entry 225 (class 1259 OID 18186)
-- Name: poi_contributors; Type: TABLE; Schema: public; Owner: kabano
--
@ -338,7 +346,6 @@ CREATE TABLE public.poi_contributors (
ALTER TABLE public.poi_contributors OWNER TO kabano;
--
-- TOC entry 232 (class 1259 OID 18322)
-- Name: poi_localised_sequence; Type: SEQUENCE; Schema: public; Owner: kabano
--
@ -353,7 +360,6 @@ CREATE SEQUENCE public.poi_localised_sequence
ALTER TABLE public.poi_localised_sequence OWNER TO kabano;
--
-- TOC entry 224 (class 1259 OID 18160)
-- Name: poi_localised; Type: TABLE; Schema: public; Owner: kabano
--
@ -369,7 +375,6 @@ CREATE TABLE public.poi_localised (
ALTER TABLE public.poi_localised OWNER TO kabano;
--
-- TOC entry 222 (class 1259 OID 18109)
-- Name: poi_sources; Type: TABLE; Schema: public; Owner: kabano
--
@ -386,7 +391,6 @@ CREATE TABLE public.poi_sources (
ALTER TABLE public.poi_sources OWNER TO kabano;
--
-- TOC entry 231 (class 1259 OID 18320)
-- Name: pois_sequence; Type: SEQUENCE; Schema: public; Owner: kabano
--
@ -401,7 +405,6 @@ CREATE SEQUENCE public.pois_sequence
ALTER TABLE public.pois_sequence OWNER TO kabano;
--
-- TOC entry 223 (class 1259 OID 18119)
-- Name: pois; Type: TABLE; Schema: public; Owner: kabano
--
@ -428,7 +431,6 @@ CREATE TABLE public.pois (
ALTER TABLE public.pois OWNER TO kabano;
--
-- TOC entry 230 (class 1259 OID 18317)
-- Name: users_id_sequence; Type: SEQUENCE; Schema: public; Owner: kabano
--
@ -443,7 +445,6 @@ CREATE SEQUENCE public.users_id_sequence
ALTER TABLE public.users_id_sequence OWNER TO kabano;
--
-- TOC entry 220 (class 1259 OID 18047)
-- Name: users; Type: TABLE; Schema: public; Owner: kabano
--
@ -467,16 +468,209 @@ CREATE TABLE public.users (
ALTER TABLE public.users OWNER TO kabano;
--
-- TOC entry 3717 (class 2606 OID 18297)
-- Name: content_comments content_comments_permalink_version_key; Type: CONSTRAINT; Schema: public; Owner: kabano
-- Data for Name: content_comments; Type: TABLE DATA; Schema: public; Owner: kabano
--
ALTER TABLE ONLY public.content_comments
ADD CONSTRAINT content_comments_permalink_version_key UNIQUE (permalink, version);
COPY public.content_comments (id, version, creation_date, update_date, author, is_public, is_archive, content, comment, locale) FROM stdin;
\.
--
-- Data for Name: content_contributors; Type: TABLE DATA; Schema: public; Owner: kabano
--
COPY public.content_contributors (id, content, contributor) FROM stdin;
31 1 1
32 2 1
\.
--
-- Data for Name: content_locales; Type: TABLE DATA; Schema: public; Owner: kabano
--
COPY public.content_locales (id, content_id, locale, author) FROM stdin;
1 29 fr_FR 1
2 32 fr_FR 1
\.
--
-- Data for Name: content_versions; Type: TABLE DATA; Schema: public; Owner: kabano
--
COPY public.content_versions (id, version, update_date, is_archive, name, content, locale_id) FROM stdin;
2 0 2019-01-30 18:33:36 f Ceci est un test héhé Encore 2
1 0 2019-01-30 18:10:51 t 404 Erreur 404 1
3 1 2019-01-30 18:47:44 t 404 Erreur 404s 1
4 2 2019-01-30 18:48:51 f 404 Erreur 404sd 1
\.
--
-- Data for Name: contents; Type: TABLE DATA; Schema: public; Owner: kabano
--
COPY public.contents (id, permalink, creation_date, is_public, is_commentable, type) FROM stdin;
32 403 2019-01-30 18:33:36 t f wiki
29 404 2019-01-30 18:10:51 t f wiki
\.
--
-- Data for Name: locales; Type: TABLE DATA; Schema: public; Owner: kabano
--
COPY public.locales (name, display_name, flag_name) FROM stdin;
fr_FR Français fr
\.
--
-- Data for Name: poi_comments; Type: TABLE DATA; Schema: public; Owner: kabano
--
COPY public.poi_comments (id, permalink, version, creation_date, update_date, author, is_public, is_archive, poi, comment, locale) FROM stdin;
\.
--
-- Data for Name: poi_contributors; Type: TABLE DATA; Schema: public; Owner: kabano
--
COPY public.poi_contributors (id, poi, contributor) FROM stdin;
\.
--
-- Data for Name: poi_localised; Type: TABLE DATA; Schema: public; Owner: kabano
--
COPY public.poi_localised (id, poi, locale, key, value) FROM stdin;
\.
--
-- Data for Name: poi_sources; Type: TABLE DATA; Schema: public; Owner: kabano
--
COPY public.poi_sources (id, display_name, icon_name, website, license_name, license_url) FROM stdin;
\.
--
-- Data for Name: pois; Type: TABLE DATA; Schema: public; Owner: kabano
--
COPY public.pois (id, permalink, version, creation_date, update_date, author, is_public, is_archive, type, is_detroyed, name, alt_names, source, source_id, "position", parameters) FROM stdin;
\.
--
-- Data for Name: spatial_ref_sys; Type: TABLE DATA; Schema: public; Owner: kabano
--
COPY public.spatial_ref_sys (srid, auth_name, auth_srid, srtext, proj4text) FROM stdin;
\.
--
-- Data for Name: users; Type: TABLE DATA; Schema: public; Owner: kabano
--
COPY public.users (id, name, version, email, password, website, is_avatar_present, is_archive, rank, locale, timezone, visit_date, register_date) FROM stdin;
4 leosw2 0 leo@leo.fr b36982d19ecde5eabbd83f964c6fe560050fe4bd f f moderator fr_FR CEST 2018-11-04 07:12:11 2018-10-17 18:14:11
1 leosw 1 leo@lstronic.com b36982d19ecde5eabbd83f964c6fe560050fe4bd https://lstronic.com t f administrator fr_FR CEST 2019-01-30 18:49:01 2018-09-03 21:27:13
\.
--
-- Data for Name: topology; Type: TABLE DATA; Schema: topology; Owner: kabano
--
COPY topology.topology (id, name, srid, "precision", hasz) FROM stdin;
\.
--
-- Data for Name: layer; Type: TABLE DATA; Schema: topology; Owner: kabano
--
COPY topology.layer (topology_id, layer_id, schema_name, table_name, feature_column, feature_type, level, child_id) FROM stdin;
\.
--
-- Name: content_comments_sequence; Type: SEQUENCE SET; Schema: public; Owner: kabano
--
SELECT pg_catalog.setval('public.content_comments_sequence', 3, true);
--
-- Name: content_contributors_sequence; Type: SEQUENCE SET; Schema: public; Owner: kabano
--
SELECT pg_catalog.setval('public.content_contributors_sequence', 34, true);
--
-- Name: content_locales_sequence; Type: SEQUENCE SET; Schema: public; Owner: kabano
--
SELECT pg_catalog.setval('public.content_locales_sequence', 2, true);
--
-- Name: content_versions_sequence; Type: SEQUENCE SET; Schema: public; Owner: kabano
--
SELECT pg_catalog.setval('public.content_versions_sequence', 4, true);
--
-- Name: contents_sequence; Type: SEQUENCE SET; Schema: public; Owner: kabano
--
SELECT pg_catalog.setval('public.contents_sequence', 32, true);
--
-- Name: poi_comments_sequence; Type: SEQUENCE SET; Schema: public; Owner: kabano
--
SELECT pg_catalog.setval('public.poi_comments_sequence', 1, false);
--
-- Name: poi_contributors_sequence; Type: SEQUENCE SET; Schema: public; Owner: kabano
--
SELECT pg_catalog.setval('public.poi_contributors_sequence', 1, false);
--
-- Name: poi_localised_sequence; Type: SEQUENCE SET; Schema: public; Owner: kabano
--
SELECT pg_catalog.setval('public.poi_localised_sequence', 1, false);
--
-- Name: pois_sequence; Type: SEQUENCE SET; Schema: public; Owner: kabano
--
SELECT pg_catalog.setval('public.pois_sequence', 1, false);
--
-- Name: users_id_sequence; Type: SEQUENCE SET; Schema: public; Owner: kabano
--
SELECT pg_catalog.setval('public.users_id_sequence', 4, true);
--
-- TOC entry 3719 (class 2606 OID 18295)
-- Name: content_comments content_comments_pkey; Type: CONSTRAINT; Schema: public; Owner: kabano
--
@ -485,7 +679,6 @@ ALTER TABLE ONLY public.content_comments
--
-- TOC entry 3711 (class 2606 OID 18275)
-- Name: content_contributors content_contributors_pkey; Type: CONSTRAINT; Schema: public; Owner: kabano
--
@ -494,7 +687,6 @@ ALTER TABLE ONLY public.content_contributors
--
-- TOC entry 3713 (class 2606 OID 18277)
-- Name: content_contributors content_contributors_unique; Type: CONSTRAINT; Schema: public; Owner: kabano
--
@ -503,16 +695,46 @@ ALTER TABLE ONLY public.content_contributors
--
-- TOC entry 3707 (class 2606 OID 18262)
-- Name: contents contents_permalink_unique; Type: CONSTRAINT; Schema: public; Owner: kabano
-- Name: content_locales content_locales_pkey; Type: CONSTRAINT; Schema: public; Owner: kabano
--
ALTER TABLE ONLY public.content_locales
ADD CONSTRAINT content_locales_pkey PRIMARY KEY (id);
--
-- Name: content_locales content_locales_unique; Type: CONSTRAINT; Schema: public; Owner: kabano
--
ALTER TABLE ONLY public.content_locales
ADD CONSTRAINT content_locales_unique UNIQUE (content_id, locale);
--
-- Name: content_versions content_versions_pkey; Type: CONSTRAINT; Schema: public; Owner: kabano
--
ALTER TABLE ONLY public.content_versions
ADD CONSTRAINT content_versions_pkey PRIMARY KEY (id);
--
-- Name: content_versions content_versions_version_locale_key; Type: CONSTRAINT; Schema: public; Owner: kabano
--
ALTER TABLE ONLY public.content_versions
ADD CONSTRAINT content_versions_version_locale_key UNIQUE (version, locale_id);
--
-- Name: contents contents_permalink_type_key; Type: CONSTRAINT; Schema: public; Owner: kabano
--
ALTER TABLE ONLY public.contents
ADD CONSTRAINT contents_permalink_unique UNIQUE (permalink, version, locale);
ADD CONSTRAINT contents_permalink_type_key UNIQUE (permalink, type);
--
-- TOC entry 3709 (class 2606 OID 18238)
-- Name: contents contents_pkey; Type: CONSTRAINT; Schema: public; Owner: kabano
--
@ -521,7 +743,6 @@ ALTER TABLE ONLY public.contents
--
-- TOC entry 3673 (class 2606 OID 18073)
-- Name: locales locales_display_name_unique; Type: CONSTRAINT; Schema: public; Owner: kabano
--
@ -530,7 +751,6 @@ ALTER TABLE ONLY public.locales
--
-- TOC entry 3675 (class 2606 OID 18075)
-- Name: locales locales_flag_name_unique; Type: CONSTRAINT; Schema: public; Owner: kabano
--
@ -539,7 +759,6 @@ ALTER TABLE ONLY public.locales
--
-- TOC entry 3677 (class 2606 OID 18071)
-- Name: locales locales_pkey; Type: CONSTRAINT; Schema: public; Owner: kabano
--
@ -548,7 +767,6 @@ ALTER TABLE ONLY public.locales
--
-- TOC entry 3701 (class 2606 OID 18212)
-- Name: poi_comments poi_comments_permalink_version_key; Type: CONSTRAINT; Schema: public; Owner: kabano
--
@ -557,7 +775,6 @@ ALTER TABLE ONLY public.poi_comments
--
-- TOC entry 3703 (class 2606 OID 18210)
-- Name: poi_comments poi_comments_pkey; Type: CONSTRAINT; Schema: public; Owner: kabano
--
@ -566,7 +783,6 @@ ALTER TABLE ONLY public.poi_comments
--
-- TOC entry 3695 (class 2606 OID 18190)
-- Name: poi_contributors poi_contributors_pkey; Type: CONSTRAINT; Schema: public; Owner: kabano
--
@ -575,7 +791,6 @@ ALTER TABLE ONLY public.poi_contributors
--
-- TOC entry 3697 (class 2606 OID 18192)
-- Name: poi_contributors poi_contributors_unique; Type: CONSTRAINT; Schema: public; Owner: kabano
--
@ -584,7 +799,6 @@ ALTER TABLE ONLY public.poi_contributors
--
-- TOC entry 3691 (class 2606 OID 18164)
-- Name: poi_localised poi_localised_pkey; Type: CONSTRAINT; Schema: public; Owner: kabano
--
@ -593,7 +807,6 @@ ALTER TABLE ONLY public.poi_localised
--
-- TOC entry 3693 (class 2606 OID 18185)
-- Name: poi_localised poi_localised_unique; Type: CONSTRAINT; Schema: public; Owner: kabano
--
@ -602,7 +815,6 @@ ALTER TABLE ONLY public.poi_localised
--
-- TOC entry 3679 (class 2606 OID 18118)
-- Name: poi_sources poi_sources_display_name_unique; Type: CONSTRAINT; Schema: public; Owner: kabano
--
@ -611,7 +823,6 @@ ALTER TABLE ONLY public.poi_sources
--
-- TOC entry 3681 (class 2606 OID 18116)
-- Name: poi_sources poi_sources_pkey; Type: CONSTRAINT; Schema: public; Owner: kabano
--
@ -620,7 +831,6 @@ ALTER TABLE ONLY public.poi_sources
--
-- TOC entry 3686 (class 2606 OID 18145)
-- Name: pois pois_permalink_unique; Type: CONSTRAINT; Schema: public; Owner: kabano
--
@ -629,7 +839,6 @@ ALTER TABLE ONLY public.pois
--
-- TOC entry 3688 (class 2606 OID 18124)
-- Name: pois pois_pkey; Type: CONSTRAINT; Schema: public; Owner: kabano
--
@ -638,7 +847,6 @@ ALTER TABLE ONLY public.pois
--
-- TOC entry 3665 (class 2606 OID 18079)
-- Name: users users_email_unique; Type: CONSTRAINT; Schema: public; Owner: kabano
--
@ -647,7 +855,6 @@ ALTER TABLE ONLY public.users
--
-- TOC entry 3668 (class 2606 OID 18077)
-- Name: users users_name_unique; Type: CONSTRAINT; Schema: public; Owner: kabano
--
@ -656,7 +863,6 @@ ALTER TABLE ONLY public.users
--
-- TOC entry 3670 (class 2606 OID 18055)
-- Name: users users_pkey; Type: CONSTRAINT; Schema: public; Owner: kabano
--
@ -665,7 +871,6 @@ ALTER TABLE ONLY public.users
--
-- TOC entry 3714 (class 1259 OID 18313)
-- Name: content_comments_is_archive_index; Type: INDEX; Schema: public; Owner: kabano
--
@ -673,7 +878,6 @@ CREATE INDEX content_comments_is_archive_index ON public.content_comments USING
--
-- TOC entry 3715 (class 1259 OID 18314)
-- Name: content_comments_is_public_index; Type: INDEX; Schema: public; Owner: kabano
--
@ -681,15 +885,6 @@ CREATE INDEX content_comments_is_public_index ON public.content_comments USING b
--
-- TOC entry 3704 (class 1259 OID 18251)
-- Name: contents_is_archive_index; Type: INDEX; Schema: public; Owner: kabano
--
CREATE INDEX contents_is_archive_index ON public.contents USING btree (is_archive);
--
-- TOC entry 3705 (class 1259 OID 18252)
-- Name: contents_is_public_index; Type: INDEX; Schema: public; Owner: kabano
--
@ -697,7 +892,20 @@ CREATE INDEX contents_is_public_index ON public.contents USING btree (is_public)
--
-- TOC entry 3698 (class 1259 OID 18229)
-- Name: fki_content_contributors_content_fkey; Type: INDEX; Schema: public; Owner: kabano
--
CREATE INDEX fki_content_contributors_content_fkey ON public.content_contributors USING btree (content);
--
-- Name: fki_content_contributors_contributor_fkey; Type: INDEX; Schema: public; Owner: kabano
--
CREATE INDEX fki_content_contributors_contributor_fkey ON public.content_contributors USING btree (contributor);
--
-- Name: poi_comments_is_archive_index; Type: INDEX; Schema: public; Owner: kabano
--
@ -705,7 +913,6 @@ CREATE INDEX poi_comments_is_archive_index ON public.poi_comments USING btree (i
--
-- TOC entry 3699 (class 1259 OID 18228)
-- Name: poi_comments_is_public_index; Type: INDEX; Schema: public; Owner: kabano
--
@ -713,7 +920,6 @@ CREATE INDEX poi_comments_is_public_index ON public.poi_comments USING btree (is
--
-- TOC entry 3682 (class 1259 OID 18157)
-- Name: pois_is_archive_index; Type: INDEX; Schema: public; Owner: kabano
--
@ -721,7 +927,6 @@ CREATE INDEX pois_is_archive_index ON public.pois USING btree (is_archive);
--
-- TOC entry 3683 (class 1259 OID 18159)
-- Name: pois_is_destroyed_index; Type: INDEX; Schema: public; Owner: kabano
--
@ -729,7 +934,6 @@ CREATE INDEX pois_is_destroyed_index ON public.pois USING btree (is_detroyed);
--
-- TOC entry 3684 (class 1259 OID 18156)
-- Name: pois_is_public_index; Type: INDEX; Schema: public; Owner: kabano
--
@ -737,7 +941,6 @@ CREATE INDEX pois_is_public_index ON public.pois USING btree (is_public);
--
-- TOC entry 3689 (class 1259 OID 18158)
-- Name: pois_type_index; Type: INDEX; Schema: public; Owner: kabano
--
@ -745,7 +948,6 @@ CREATE INDEX pois_type_index ON public.pois USING btree (type);
--
-- TOC entry 3666 (class 1259 OID 18080)
-- Name: users_is_archive_index; Type: INDEX; Schema: public; Owner: kabano
--
@ -753,7 +955,6 @@ CREATE INDEX users_is_archive_index ON public.users USING btree (is_archive);
--
-- TOC entry 3671 (class 1259 OID 18081)
-- Name: users_register_date_index; Type: INDEX; Schema: public; Owner: kabano
--
@ -761,7 +962,6 @@ CREATE INDEX users_register_date_index ON public.users USING btree (register_dat
--
-- TOC entry 3734 (class 2606 OID 18298)
-- Name: content_comments content_comments_author_fkey; Type: FK CONSTRAINT; Schema: public; Owner: kabano
--
@ -770,7 +970,6 @@ ALTER TABLE ONLY public.content_comments
--
-- TOC entry 3736 (class 2606 OID 18308)
-- Name: content_comments content_comments_content_fkey; Type: FK CONSTRAINT; Schema: public; Owner: kabano
--
@ -779,7 +978,6 @@ ALTER TABLE ONLY public.content_comments
--
-- TOC entry 3735 (class 2606 OID 18303)
-- Name: content_comments content_comments_locale_fkey; Type: FK CONSTRAINT; Schema: public; Owner: kabano
--
@ -788,16 +986,14 @@ ALTER TABLE ONLY public.content_comments
--
-- TOC entry 3733 (class 2606 OID 18283)
-- Name: content_contributors content_contributors_content_fkey; Type: FK CONSTRAINT; Schema: public; Owner: kabano
--
ALTER TABLE ONLY public.content_contributors
ADD CONSTRAINT content_contributors_content_fkey FOREIGN KEY (content) REFERENCES public.contents(id);
ADD CONSTRAINT content_contributors_content_fkey FOREIGN KEY (content) REFERENCES public.content_locales(id);
--
-- TOC entry 3732 (class 2606 OID 18278)
-- Name: content_contributors content_contributors_contributor_fkey; Type: FK CONSTRAINT; Schema: public; Owner: kabano
--
@ -806,25 +1002,38 @@ ALTER TABLE ONLY public.content_contributors
--
-- TOC entry 3730 (class 2606 OID 18241)
-- Name: contents contents_author_fkey; Type: FK CONSTRAINT; Schema: public; Owner: kabano
-- Name: content_locales content_locales_author; Type: FK CONSTRAINT; Schema: public; Owner: kabano
--
ALTER TABLE ONLY public.contents
ADD CONSTRAINT contents_author_fkey FOREIGN KEY (author) REFERENCES public.users(id);
ALTER TABLE ONLY public.content_locales
ADD CONSTRAINT content_locales_author FOREIGN KEY (author) REFERENCES public.users(id);
--
-- TOC entry 3731 (class 2606 OID 18263)
-- Name: contents contents_locale_fkey; Type: FK CONSTRAINT; Schema: public; Owner: kabano
-- Name: content_locales content_locales_content; Type: FK CONSTRAINT; Schema: public; Owner: kabano
--
ALTER TABLE ONLY public.contents
ADD CONSTRAINT contents_locale_fkey FOREIGN KEY (locale) REFERENCES public.locales(name);
ALTER TABLE ONLY public.content_locales
ADD CONSTRAINT content_locales_content FOREIGN KEY (content_id) REFERENCES public.contents(id);
--
-- Name: content_locales content_locales_locale; Type: FK CONSTRAINT; Schema: public; Owner: kabano
--
ALTER TABLE ONLY public.content_locales
ADD CONSTRAINT content_locales_locale FOREIGN KEY (locale) REFERENCES public.locales(name);
--
-- Name: content_versions content_versions_locale; Type: FK CONSTRAINT; Schema: public; Owner: kabano
--
ALTER TABLE ONLY public.content_versions
ADD CONSTRAINT content_versions_locale FOREIGN KEY (locale_id) REFERENCES public.content_locales(id);
--
-- TOC entry 3727 (class 2606 OID 18213)
-- Name: poi_comments poi_comments_author_fkey; Type: FK CONSTRAINT; Schema: public; Owner: kabano
--
@ -833,7 +1042,6 @@ ALTER TABLE ONLY public.poi_comments
--
-- TOC entry 3728 (class 2606 OID 18218)
-- Name: poi_comments poi_comments_locale_fkey; Type: FK CONSTRAINT; Schema: public; Owner: kabano
--
@ -842,7 +1050,6 @@ ALTER TABLE ONLY public.poi_comments
--
-- TOC entry 3729 (class 2606 OID 18223)
-- Name: poi_comments poi_comments_poi_fkey; Type: FK CONSTRAINT; Schema: public; Owner: kabano
--
@ -851,7 +1058,6 @@ ALTER TABLE ONLY public.poi_comments
--
-- TOC entry 3725 (class 2606 OID 18193)
-- Name: poi_contributors poi_contributors_contributor_fkey; Type: FK CONSTRAINT; Schema: public; Owner: kabano
--
@ -860,7 +1066,6 @@ ALTER TABLE ONLY public.poi_contributors
--
-- TOC entry 3726 (class 2606 OID 18198)
-- Name: poi_contributors poi_contributors_poi_fkey; Type: FK CONSTRAINT; Schema: public; Owner: kabano
--
@ -869,7 +1074,6 @@ ALTER TABLE ONLY public.poi_contributors
--
-- TOC entry 3724 (class 2606 OID 18179)
-- Name: poi_localised poi_localised_locale_fkey; Type: FK CONSTRAINT; Schema: public; Owner: kabano
--
@ -878,7 +1082,6 @@ ALTER TABLE ONLY public.poi_localised
--
-- TOC entry 3723 (class 2606 OID 18174)
-- Name: poi_localised poi_localised_poi_fkey; Type: FK CONSTRAINT; Schema: public; Owner: kabano
--
@ -887,7 +1090,6 @@ ALTER TABLE ONLY public.poi_localised
--
-- TOC entry 3721 (class 2606 OID 18146)
-- Name: pois pois_author_fkey; Type: FK CONSTRAINT; Schema: public; Owner: kabano
--
@ -896,7 +1098,6 @@ ALTER TABLE ONLY public.pois
--
-- TOC entry 3722 (class 2606 OID 18151)
-- Name: pois pois_source_fkey; Type: FK CONSTRAINT; Schema: public; Owner: kabano
--
@ -905,7 +1106,6 @@ ALTER TABLE ONLY public.pois
--
-- TOC entry 3720 (class 2606 OID 18082)
-- Name: users users_locale_fkey; Type: FK CONSTRAINT; Schema: public; Owner: kabano
--
@ -913,7 +1113,25 @@ ALTER TABLE ONLY public.users
ADD CONSTRAINT users_locale_fkey FOREIGN KEY (locale) REFERENCES public.locales(name);
-- Completed on 2018-10-17 20:33:23 CEST
--
-- Name: SCHEMA public; Type: ACL; Schema: -; Owner: kabano
--
REVOKE ALL ON SCHEMA public FROM postgres;
REVOKE ALL ON SCHEMA public FROM PUBLIC;
GRANT ALL ON SCHEMA public TO PUBLIC;
GRANT ALL ON SCHEMA public TO kabano;
--
-- Name: TABLE spatial_ref_sys; Type: ACL; Schema: public; Owner: kabano
--
REVOKE ALL ON TABLE public.spatial_ref_sys FROM postgres;
REVOKE SELECT ON TABLE public.spatial_ref_sys FROM PUBLIC;
GRANT ALL ON TABLE public.spatial_ref_sys TO kabano;
GRANT SELECT ON TABLE public.spatial_ref_sys TO PUBLIC;
--
-- PostgreSQL database dump complete

View File

@ -31,25 +31,21 @@ switch ($controller->splitted_url[1]) {
case "list":
$blogArticles = new Kabano\BlogArticles();
$blogArticles->number(($user->role >= 600));
$blogArticles->number(($user->rankIsHigher("premium")));
// In case the wanted page is too big
if($articles_per_pages * $page >= $blogArticles->number)
$page = 0;
$blogArticles->listArticles($page*$articles_per_pages,$articles_per_pages,($user->role >= 600));
$blogArticles->listArticles($page*$articles_per_pages,$articles_per_pages,($user->rankIsHigher("premium")));
$i = 0;
$blogArticles_list = array();
foreach ($blogArticles->ids as $row) {
$blogArticles_list[$i] = new Kabano\BlogArticle();
$blogArticles_list[$i]->id = $row;
$blogArticles_list[$i]->populate();
$blogArticles_list[$i]->md2txt();
foreach ($blogArticles->objs as $row) {
$row->md2txt();
$tempUser = new Kabano\User();
$tempUser->id = $blogArticles_list[$i]->author;
$tempUser->populate();
$blogArticles_list[$i]->author_name = $tempUser->name;
$tempUser->checkId($row->author);
$row->author_name = $tempUser->name;
unset($tempUser);
$i++;
}
@ -64,79 +60,80 @@ switch ($controller->splitted_url[1]) {
}
break;
case "new":
if($user->role >= 800) {
if($user->rankIsHigher("moderator")) {
if(isset($_POST['submit'])) {
$blogArticle->content = $_POST['content'];
$blogArticle->locale = $_POST['locale'];
$blogArticle->title = $_POST['title'];
$blogArticle->comments = isset($_POST['comments'])?'t':'f';
$blogArticle->name = $_POST['name'];
$blogArticle->is_commentable = isset($_POST['is_commentable'])?'t':'f';
$blogArticle->author = $user->id;
if(!$blogArticle->checkUrl($_POST['url'],1)) {
if(!$blogArticle->checkPermalink($_POST['permalink'],1)) {
$blogArticle->permalink = $_POST['permalink'];
$blogArticle->insert();
header('Location: '.$config['rel_root_folder']."blog/".$blogArticle->url);
header('Location: '.$config['rel_root_folder']."blog/".$blogArticle->permalink);
}
else {
$head['title'] = $blogArticle->title;
$error = "url";
$new = 1;
include ($config['views_folder']."d.blog.edit.html");
$head['title'] = $blogArticle->name;
$error = "permalink";
}
}
else {
$head['title'] = "Nouvel article";
$new = 1;
include ($config['views_folder']."d.blog.edit.html");
}
$locales = new Kabano\Locales();
$locales->getAll();
$new = 1;
include ($config['views_folder']."d.blog.edit.html");
break;
}
default:
// If the page exists
if ($blogArticle->checkUrl($controller->splitted_url[1],$user->role >= 600)) {
if (isset($controller->splitted_url[2]) && $controller->splitted_url[2] == "delete" && $user->role >= 800) {
if ($blogArticle->checkPermalink($controller->splitted_url[1],$user->rankIsHigher("premium"))) {
if (isset($controller->splitted_url[2]) && $controller->splitted_url[2] == "delete" && $user->rankIsHigher("moderator")) {
$blogArticle->delete();
header('Location: '.$config['rel_root_folder']."blog/".$blogArticle->url);
header('Location: '.$config['rel_root_folder']."blog/".$blogArticle->permalink);
}
else if (isset($controller->splitted_url[2]) && $controller->splitted_url[2] == "edit" && $user->role >= 800) {
else if (isset($controller->splitted_url[2]) && $controller->splitted_url[2] == "restore" && $user->rankIsHigher("moderator")) {
$blogArticle->restore();
header('Location: '.$config['rel_root_folder']."blog/".$blogArticle->permalink);
}
else if (isset($controller->splitted_url[2]) && $controller->splitted_url[2] == "edit" && $user->rankIsHigher("moderator")) {
if(isset($_POST['submit'])) {
$blogArticle->content = $_POST['content'];
$blogArticle->locale = $_POST['locale'];
$blogArticle->title = $_POST['title'];
$blogArticle->comments = isset($_POST['comments'])?'t':'f';
$blogArticle->name = $_POST['name'];
$blogArticle->is_commentable = isset($_POST['is_commentable'])?'t':'f';
$blogArticle->author = $user->id;
$blogArticle->update();
header('Location: '.$config['rel_root_folder']."blog/".$blogArticle->url);
header('Location: '.$config['rel_root_folder']."blog/".$blogArticle->permalink);
}
else {
$blogArticle->populate();
$head['title'] = $blogArticle->title;
$locales = new Kabano\Locales();
$locales->getAll();
$head['title'] = $blogArticle->name;
include ($config['views_folder']."d.blog.edit.html");
}
}
else {
// Manage history of an article
if($user->role >= 600) {
$blogArticles_history = new Kabano\BlogArticles();
$blogArticles_history->getHistory($controller->splitted_url[1]);
$i = 0;
foreach ($blogArticles_history->ids as $row) {
$blogArticles_history_list[$i] = new Kabano\BlogArticle();
$blogArticles_history_list[$i]->id = $row;
$blogArticles_history_list[$i]->populate();
$i++;
}
if($user->rankIsHigher("premium")) {
$blogHistory = new Kabano\BlogArticles();
$blogHistory->getHistory($controller->splitted_url[1]);
}
if (isset($controller->splitted_url[2]) && is_numeric($controller->splitted_url[2]))
$blogArticle->checkUrl($controller->splitted_url[1],$user->role>=600,$controller->splitted_url[2]);
$blogArticle->checkPermalink($controller->splitted_url[1],$user->rankIsHigher("premium"),$controller->splitted_url[2]);
// Manage comment creation
if (isset($controller->splitted_url[2]) && $controller->splitted_url[2]=="new_comment") {
if (isset($_POST['submit']) && $user->role > 0) {
if (isset($_POST['submit']) && $user->rankIsHigher("registered")) {
$blogComment = new Kabano\BlogComment();
$blogComment->locale = $user->locale;
$blogComment->author = $user->id;
$blogComment->article = $blogArticle->id;
$blogComment->content = $_POST['comment'];
$blogComment->content = $blogArticle->content_id;
$blogComment->comment = $_POST['comment'];
$blogComment->insert();
}
}
@ -145,53 +142,44 @@ switch ($controller->splitted_url[1]) {
if (isset($controller->splitted_url[2]) && $controller->splitted_url[2]=="delete_comment") {
if (isset($controller->splitted_url[3]) && is_numeric($controller->splitted_url[3])) {
$blogComment = new Kabano\BlogComment();
$blogComment->id = $controller->splitted_url[3];
$blogComment->populate();
if ($user->role >= 800 || $user->id == $blogComment->author)
$blogComment->delete();
if($blogComment->checkId($controller->splitted_url[3]))
if ($user->rankIsHigher("moderator") || $user->id == $blogComment->author)
$blogComment->delete();
}
}
// Manage comment undeletion
if (isset($controller->splitted_url[2]) && $controller->splitted_url[2]=="undelete_comment") {
// Manage comment restoration
if (isset($controller->splitted_url[2]) && $controller->splitted_url[2]=="restore_comment") {
if (isset($controller->splitted_url[3]) && is_numeric($controller->splitted_url[3])) {
$blogComment = new Kabano\BlogComment();
$blogComment->id = $controller->splitted_url[3];
$blogComment->populate();
if ($user->role >= 800 || $user->id == $blogComment->author)
$blogComment->undelete();
if($blogComment->checkId($controller->splitted_url[3]))
if ($user->rankIsHigher("moderator") || $user->id == $blogComment->author)
$blogComment->restore();
}
}
$blogArticle->populate();
$blogArticle->md2html();
// Manage comments
if ($blogArticle->comments == "t") {
if ($blogArticle->is_commentable == "t") {
$blogArticles_comments = new Kabano\BlogComments();
$blogArticles_comments->listComments($blogArticle->id, ($user->role>400));
$blogArticles_comments->listComments($blogArticle->content_id, ($user->rankIsHigher("premium")));
$i = 0;
foreach ($blogArticles_comments->ids as $row) {
$blogArticles_comments_list[$i] = new Kabano\BlogComment();
$blogArticles_comments_list[$i]->id = $row;
$blogArticles_comments_list[$i]->populate();
$blogArticles_comments_list[$i]->md2html();
$blogArticles_comments_list[$i]->author_obj = new Kabano\User();
$blogArticles_comments_list[$i]->author_obj->id = $blogArticles_comments_list[$i]->author;
$blogArticles_comments_list[$i]->author_obj->populate();
$i++;
foreach ($blogArticles_comments->objs as $comment) {
$comment->md2html();
$comment->author_obj = new Kabano\User();
$comment->author_obj->checkId($comment->author);
}
}
$tempUser = new Kabano\User();
$tempUser->id = $blogArticle->author;
$tempUser->populate();
$tempUser->checkId($blogArticle->author);
$blogArticle->author_name = $tempUser->name;
unset($tempUser);
$head['title'] = $blogArticle->title;
$head['title'] = $blogArticle->name;
include ($config['views_folder']."d.blog.view.html");
}
}

View File

@ -15,6 +15,7 @@ $config['include_folder']=basename(__DIR__);
$config['abs_root_folder']=str_replace($config['include_folder'],"",__DIR__);
// This is the relative folder to the root of the website from the DocumentRoot (can also be called subfolder)
$config['rel_root_folder']=str_replace($_SERVER['DOCUMENT_ROOT'],"",$config['abs_root_folder']);
$config['web_root_folder']="kabano.test/";
if($config['rel_root_folder']=="") $config['rel_root_folder']="/";
// Here all the absolute paths to specific folders

View File

@ -14,46 +14,50 @@ require_once($config['third_folder']."Md/MarkdownExtra.inc.php");
class BlogArticle
{
public $id = 0;
public $title = NULL;
public $url = NULL;
public $content_id = NULL;
public $locale_id = NULL;
public $version_id = NULL;
public $permalink = NULL;
public $version = 0;
public $locale = NULL;
public $lastedit = NULL;
public $archive = NULL;
public $content = NULL;
public $creation_date = NULL;
public $update_date = NULL;
public $author = NULL;
public $comments = NULL;
public $is_public = NULL;
public $is_archive = NULL;
public $is_commentable = NULL;
public $type = "blog";
public $name = NULL;
public $content = NULL;
/*****
** Checks if a page at this URL exists and return the ID
*****/
public function checkUrl($url, $withArchive=0, $elementNb=0) {
public function checkPermalink($permalink, $withArchive=0, $elementNb=0) {
global $config;
$con = pg_connect("host=".$config['SQL_host']." dbname=".$config['SQL_db']." user=".$config['SQL_user']." password=".$config['SQL_pass'])
or die ("Could not connect to server\n");
$query = "SELECT id FROM blog_articles WHERE url=$1";
$query = "SELECT content_versions.id AS version_id, * FROM contents INNER JOIN content_locales ON contents.id = content_locales.content_id INNER JOIN content_versions ON content_locales.id = content_versions.locale_id WHERE permalink=$1 AND type='blog'";
if($withArchive==0) {
$query .= " AND archive=FALSE";
$query .= " AND is_archive=FALSE AND is_public=TRUE";
}
$query .= " ORDER BY lastedit DESC LIMIT 1 OFFSET $2";
$query .= " ORDER BY update_date DESC LIMIT 1 OFFSET $2";
pg_prepare($con, "prepare1", $query)
or die ("Cannot prepare statement\n");
$result = pg_execute($con, "prepare1", array($url, $elementNb))
$result = pg_execute($con, "prepare1", array($permalink, $elementNb))
or die ("Cannot execute statement\n");
pg_close($con);
if(pg_num_rows($result) == 1) {
$article = pg_fetch_assoc($result);
$this->id = $article['id'];
$this->url = $url;
$row = pg_fetch_assoc($result);
$this->populate($row);
return 1;
}
else {
$this->url = $url;
return 0;
}
}
@ -61,36 +65,22 @@ class BlogArticle
/*****
** Populate the object using its ID
*****/
public function populate() {
global $config;
if($this->id != 0) {
$con = pg_connect("host=".$config['SQL_host']." dbname=".$config['SQL_db']." user=".$config['SQL_user']." password=".$config['SQL_pass'])
or die ("Could not connect to server\n");
$query = "SELECT * FROM blog_articles WHERE id=$1";
pg_prepare($con, "prepare1", $query)
or die ("Cannot prepare statement\n");
$result = pg_execute($con, "prepare1", array($this->id))
or die ("Cannot execute statement\n");
pg_close($con);
$blog_article = pg_fetch_assoc($result);
$this->title = $blog_article['title'];
$this->url = $blog_article['url'];
$this->locale = $blog_article['locale'];
$this->lastedit = $blog_article['lastedit'];
$this->archive = $blog_article['archive'];
$this->content = $blog_article['content'];
$this->author = $blog_article['author'];
$this->comments = $blog_article['comments'];
}
else {
die("Cannot populate a blog article without ID");
}
public function populate($row) {
$this->content_id = $row['content_id'];
$this->locale_id = $row['locale_id'];
$this->version_id = $row['version_id'];
$this->permalink = $row['permalink'];
$this->version = $row['version'];
$this->locale = $row['locale'];
$this->creation_date = $row['creation_date'];
$this->update_date = $row['update_date'];
$this->author = $row['author'];
$this->is_public = $row['is_public'];
$this->is_archive = $row['is_archive'];
$this->is_commentable = $row['is_commentable'];
$this->type = $row['type'];
$this->name = $row['name'];
$this->content = $row['content'];
}
/*****
@ -99,43 +89,44 @@ class BlogArticle
public function update() {
global $config;
global $user;
if($this->content_id == 0 || $this->locale_id == 0 || $this->version_id == 0)
die("Cannot update entry without giving ID");
$this->version++;
$con = pg_connect("host=".$config['SQL_host']." dbname=".$config['SQL_db']." user=".$config['SQL_user']." password=".$config['SQL_pass'])
or die ("Could not connect to server\n");
// Archive previous article
$query = "UPDATE blog_articles SET archive = TRUE WHERE url = $1";
$query = "UPDATE content_versions SET is_archive = TRUE WHERE locale_id = $1";
pg_prepare($con, "prepare1", $query)
or die ("Cannot prepare statement\n");
$result = pg_execute($con, "prepare1", array($this->url))
$result = pg_execute($con, "prepare1", array($this->locale_id))
or die ("Cannot execute statement\n");
// Publish the new one
$query = "INSERT INTO blog_articles (url, title, content, lastedit, archive, locale, author, comments) VALUES
($1, $2, $3, $4, FALSE, $5, $6, $7) RETURNING id";
$query = "INSERT INTO content_versions (version, update_date, is_archive, name, content, locale_id) VALUES
($1, $2, FALSE, $3, $4, $5) RETURNING id";
pg_prepare($con, "prepare2", $query)
or die ("Cannot prepare statement\n");
$result = pg_execute($con, "prepare2", array($this->url, $this->title, $this->content, date('r'), $this->locale, $this->author, $this->comments))
$result = pg_execute($con, "prepare2", array($this->version, date('r'), $this->name, $this->content, $this->locale_id))
or die ("Cannot execute statement\n");
$this->id = pg_fetch_assoc($result)['id'];
$this->version_id = pg_fetch_assoc($result)['id'];
// Move all comments to the new one
$query = "UPDATE blog_comments bc SET article = $1 FROM blog_articles ba WHERE bc.article = ba.id AND ba.url = $2";
$query = "INSERT INTO content_contributors (content, contributor) VALUES
($1, $2) ON CONFLICT (content, contributor) DO NOTHING";
pg_prepare($con, "prepare3", $query)
or die ("Cannot prepare statement\n");
$result = pg_execute($con, "prepare3", array($this->id, $this->url))
$result = pg_execute($con, "prepare3", array($this->locale_id, $user->id))
or die ("Cannot execute statement\n");
pg_close($con);
error_log(
date('r')." \t".$user->name." (".$user->id.") \tUPDATE \tEdit blog article '".$this->url."'\r\n",
date('r')." \t".$user->name." (".$user->id.") \tUPDATE \tEdit blog article '".$this->permalink."'\r\n",
3,
$config['logs_folder'].'blog.articles.log');
}
@ -150,17 +141,42 @@ class BlogArticle
$con = pg_connect("host=".$config['SQL_host']." dbname=".$config['SQL_db']." user=".$config['SQL_user']." password=".$config['SQL_pass'])
or die ("Could not connect to server\n");
$query = "UPDATE blog_articles SET archive = TRUE WHERE url = $1";
$query = "UPDATE contents SET is_public=FALSE WHERE permalink=$1 AND type='blog'";
pg_prepare($con, "prepare1", $query)
or die ("Cannot prepare statement\n");
$result = pg_execute($con, "prepare1", array($this->url))
$result = pg_execute($con, "prepare1", array($this->permalink))
or die ("Cannot execute statement\n");
pg_close($con);
error_log(
date('r')." \t".$user->name." (".$user->id.") \tDELETE \tArchive blog article '".$this->url."'\r\n",
date('r')." \t".$user->name." (".$user->id.") \tDELETE \tArchive blog article '".$this->permalink."'\r\n",
3,
$config['logs_folder'].'blog.articles.log');
}
/*****
** Restore a page from unpublishing it
*****/
public function restore() {
global $config;
global $user;
$con = pg_connect("host=".$config['SQL_host']." dbname=".$config['SQL_db']." user=".$config['SQL_user']." password=".$config['SQL_pass'])
or die ("Could not connect to server\n");
$query = "UPDATE contents SET is_public=TRUE WHERE permalink=$1 AND type='blog'";
pg_prepare($con, "prepare1", $query)
or die ("Cannot prepare statement\n");
$result = pg_execute($con, "prepare1", array($this->permalink))
or die ("Cannot execute statement\n");
pg_close($con);
error_log(
date('r')." \t".$user->name." (".$user->id.") \tRESTORE \tPublish blog article '".$this->permalink."'\r\n",
3,
$config['logs_folder'].'blog.articles.log');
}
@ -175,18 +191,48 @@ class BlogArticle
$con = pg_connect("host=".$config['SQL_host']." dbname=".$config['SQL_db']." user=".$config['SQL_user']." password=".$config['SQL_pass'])
or die ("Could not connect to server\n");
$query = "INSERT INTO blog_articles (url, title, content, lastedit, archive, locale, author, comments) VALUES
($1, $2, $3, $4, FALSE, $5, $6, $7)";
$query = "INSERT INTO contents (permalink, creation_date, is_public, is_commentable, type) VALUES
($1, $2, TRUE, $3, 'blog') RETURNING id";
pg_prepare($con, "prepare1", $query)
or die ("Cannot prepare statement\n");
$result = pg_execute($con, "prepare1", array($this->permalink, date('r'), $this->is_commentable))
or die ("Cannot execute statement\n");
$this->content_id = pg_fetch_assoc($result)['id'];
$query = "INSERT INTO content_locales (content_id, locale, author) VALUES
($1, $2, $3) RETURNING id";
pg_prepare($con, "prepare2", $query)
or die ("Cannot prepare statement\n");
$result = pg_execute($con, "prepare2", array($this->url, $this->title, $this->content, date('r'), $this->locale, $this->author, $this->comments))
$result = pg_execute($con, "prepare2", array($this->content_id, $this->locale, $user->id))
or die ("Cannot execute statement\n");
$this->locale_id = pg_fetch_assoc($result)['id'];
$query = "INSERT INTO content_versions (version, update_date, is_archive, name, content, locale_id) VALUES
('0', $1, FALSE, $2, $3, $4) RETURNING id";
pg_prepare($con, "prepare3", $query)
or die ("Cannot prepare statement\n");
$result = pg_execute($con, "prepare3", array(date('r'), $this->name, $this->content, $this->locale_id))
or die ("Cannot execute statement\n");
$this->version_id = pg_fetch_assoc($result)['id'];
$query = "INSERT INTO content_contributors (content, contributor) VALUES
($1, $2)";
pg_prepare($con, "prepare4", $query)
or die ("Cannot prepare statement\n");
$result = pg_execute($con, "prepare4", array($this->id, $user->id))
or die ("Cannot execute statement\n");
pg_close($con);
error_log(
date('r')." \t".$user->name." (".$user->id.") \tINSERT \tCreate new blog article '".$this->url."'\r\n",
date('r')." \t".$user->name." (".$user->id.") \tINSERT \tCreate new blog article '".$this->permalink."'\r\n",
3,
$config['logs_folder'].'blog.articles.log');
}
@ -218,7 +264,7 @@ class BlogArticle
class BlogArticles
{
public $ids = array();
public $objs = array();
public $number = NULL;
/*****
@ -230,13 +276,10 @@ class BlogArticles
$con = pg_connect("host=".$config['SQL_host']." dbname=".$config['SQL_db']." user=".$config['SQL_user']." password=".$config['SQL_pass'])
or die ("Could not connect to server\n");
if ($archive == 1) {
// You just want one per url and the criteria is ORDER BY archives = true, time DES=C
$query = "SELECT id FROM (SELECT a.id, a.lastedit , ROW_NUMBER() OVER (PARTITION BY a.url ORDER BY CASE WHEN a.archive IS TRUE THEN 1 ELSE 0 END, a.lastedit DESC) AS r FROM blog_articles AS a) AS b WHERE r = 1 ORDER BY lastedit DESC";
}
else {
$query = "SELECT id FROM blog_articles WHERE archive IS NOT TRUE ORDER BY lastedit DESC";
}
$query = "SELECT content_versions.id AS version_id, * FROM contents INNER JOIN content_locales ON contents.id = content_locales.content_id INNER JOIN content_versions ON content_locales.id = content_versions.locale_id WHERE is_archive=FALSE ";
if ($archive == 1)
$query .= "AND is_public=TRUE ";
$query .= "AND type='blog' ORDER BY update_date DESC";
$query .= " LIMIT $1 OFFSET $2";
pg_prepare($con, "prepare1", $query)
@ -248,9 +291,11 @@ class BlogArticles
for($i = 0; $i < pg_num_rows($result); $i++) {
$row = pg_fetch_assoc($result, $i);
$this->ids[$i] = $row['id'];
$this->objs[$i] = new BlogArticle;
$this->objs[$i]->populate($row);
}
}
/*****
** Return the number of articles
*****/
@ -260,13 +305,10 @@ class BlogArticles
$con = pg_connect("host=".$config['SQL_host']." dbname=".$config['SQL_db']." user=".$config['SQL_user']." password=".$config['SQL_pass'])
or die ("Could not connect to server\n");
if ($archive == 1) {
// You just want one per url and the criteria is ORDER BY archives = true, time DES=C
$query = "SELECT id FROM (SELECT a.id, a.lastedit , ROW_NUMBER() OVER (PARTITION BY a.url ORDER BY CASE WHEN a.archive IS TRUE THEN 1 ELSE 0 END, a.lastedit DESC) AS r FROM blog_articles AS a) AS b WHERE r = 1 ORDER BY lastedit DESC";
}
else {
$query = "SELECT id FROM blog_articles WHERE archive IS NOT TRUE ORDER BY lastedit DESC";
}
$query = "SELECT content_versions.id AS version_id, * FROM contents INNER JOIN content_locales ON contents.id = content_locales.content_id INNER JOIN content_versions ON content_locales.id = content_versions.locale_id WHERE is_archive=FALSE ";
if ($archive == 1)
$query .= "AND is_public=TRUE ";
$query .= "AND type='blog' ORDER BY update_date DESC";
pg_prepare($con, "prepare1", $query)
or die ("Cannot prepare statement\n");
@ -277,6 +319,7 @@ class BlogArticles
$this->number = pg_num_rows($result);
}
/*****
** Return the list of archived version of a blog article
*****/
@ -286,7 +329,7 @@ class BlogArticles
$con = pg_connect("host=".$config['SQL_host']." dbname=".$config['SQL_db']." user=".$config['SQL_user']." password=".$config['SQL_pass'])
or die ("Could not connect to server\n");
$query = "SELECT id FROM blog_articles WHERE url=$1 ORDER BY lastedit DESC";
$query = "SELECT content_versions.id AS version_id, * FROM contents INNER JOIN content_locales ON contents.id = content_locales.content_id INNER JOIN content_versions ON content_locales.id = content_versions.locale_id WHERE permalink=$1 AND type='blog' ORDER BY update_date DESC";
pg_prepare($con, "prepare1", $query)
or die ("Cannot prepare statement\n");
@ -299,12 +342,12 @@ class BlogArticles
for($i = 0; $i < $this->number; $i++) {
$row = pg_fetch_assoc($result, $i);
$this->ids[$i] = $row['id'];
$this->objs[$i] = new BlogArticle;
$this->objs[$i]->populate($row);
}
}
}
/**********************************************************
***********************************************************
**
@ -315,45 +358,60 @@ class BlogArticles
class BlogComment
{
public $id = 0;
public $locale = NULL;
public $lastedit = NULL;
public $archive = NULL;
public $content = NULL;
public $id = NULL;
public $version = 0;
public $creation_date = NULL;
public $update_date = NULL;
public $author = NULL;
public $article = NULL;
public $is_public = NULL;
public $is_archive = NULL;
public $content = NULL;
public $comment = NULL;
public $locale = NULL;
/*****
** Connect to correct account using ID and stores its ID
*****/
public function checkID($id) {
global $config;
$con = pg_connect("host=".$config['SQL_host']." dbname=".$config['SQL_db']." user=".$config['SQL_user']." password=".$config['SQL_pass'])
or die ("Could not connect to server\n");
$query = "SELECT * FROM content_comments WHERE id=$1";
pg_prepare($con, "prepare1", $query)
or die ("Cannot prepare statement\n");
$result = pg_execute($con, "prepare1", array($id))
or die ("Cannot execute statement\n");
pg_close($con);
if(pg_num_rows($result) == 1) {
$row = pg_fetch_assoc($result);
$this->populate($row);
return 1;
}
else {
return 0;
}
}
/*****
** Populate the object using its ID
*****/
public function populate() {
global $config;
if($this->id != 0) {
$con = pg_connect("host=".$config['SQL_host']." dbname=".$config['SQL_db']." user=".$config['SQL_user']." password=".$config['SQL_pass'])
or die ("Could not connect to server\n");
$query = "SELECT * FROM blog_comments WHERE id=$1";
pg_prepare($con, "prepare1", $query)
or die ("Cannot prepare statement\n");
$result = pg_execute($con, "prepare1", array($this->id))
or die ("Cannot execute statement\n");
pg_close($con);
$blog_comment = pg_fetch_assoc($result);
$this->locale = $blog_comment['locale'];
$this->lastedit = $blog_comment['lastedit'];
$this->archive = $blog_comment['archive'];
$this->content = $blog_comment['content'];
$this->author = $blog_comment['author'];
$this->article = $blog_comment['article'];
}
else {
die("Cannot populate a blog article without ID");
}
public function populate($row) {
$this->id = $row['id'];
$this->version = $row['version'];
$this->creation_date = $row['creation_date'];
$this->update_date = $row['update_date'];
$this->author = $row['author'];
$this->is_public = $row['is_public'];
$this->is_archive = $row['is_archive'];
$this->content = $row['content'];
$this->comment = $row['comment'];
$this->locale = $row['locale'];
}
/*****
@ -365,14 +423,16 @@ class BlogComment
$con = pg_connect("host=".$config['SQL_host']." dbname=".$config['SQL_db']." user=".$config['SQL_user']." password=".$config['SQL_pass'])
or die ("Could not connect to server\n");
$query = "INSERT INTO blog_comments (content, lastedit, archive, locale, author, article) VALUES
($1, $2, FALSE, $3, $4, $5)";
$query = "INSERT INTO content_comments (version, creation_date, update_date, author, is_public, is_archive, content, comment, locale) VALUES
('0', $1, $2, $3, TRUE, FALSE, $4, $5, $6) RETURNING id";
pg_prepare($con, "prepare2", $query)
pg_prepare($con, "prepare1", $query)
or die ("Cannot prepare statement\n");
$result = pg_execute($con, "prepare2", array($this->content, date('r'), $this->locale, $this->author, $this->article))
$result = pg_execute($con, "prepare1", array(date('r'), date('r'), $this->author, $this->content, $this->comment, $this->locale))
or die ("Cannot execute statement\n");
$this->id = pg_fetch_assoc($result)['id'];
pg_close($con);
}
@ -386,11 +446,11 @@ class BlogComment
$con = pg_connect("host=".$config['SQL_host']." dbname=".$config['SQL_db']." user=".$config['SQL_user']." password=".$config['SQL_pass'])
or die ("Could not connect to server\n");
$query = "UPDATE blog_comments SET archive = TRUE WHERE id = $1";
$query = "UPDATE content_comments SET is_public = FALSE WHERE id = $1";
pg_prepare($con, "prepare2", $query)
pg_prepare($con, "prepare1", $query)
or die ("Cannot prepare statement\n");
$result = pg_execute($con, "prepare2", array($this->id))
$result = pg_execute($con, "prepare1", array($this->id))
or die ("Cannot execute statement\n");
pg_close($con);
@ -402,20 +462,20 @@ class BlogComment
}
/*****
** DeArchive a comment
** Restore a comment
*****/
public function undelete() {
public function restore() {
global $config;
global $user;
$con = pg_connect("host=".$config['SQL_host']." dbname=".$config['SQL_db']." user=".$config['SQL_user']." password=".$config['SQL_pass'])
or die ("Could not connect to server\n");
$query = "UPDATE blog_comments SET archive = FALSE WHERE id = $1";
$query = "UPDATE content_comments SET is_public = TRUE WHERE id = $1";
pg_prepare($con, "prepare2", $query)
pg_prepare($con, "prepare1", $query)
or die ("Cannot prepare statement\n");
$result = pg_execute($con, "prepare2", array($this->id))
$result = pg_execute($con, "prepare1", array($this->id))
or die ("Cannot execute statement\n");
pg_close($con);
@ -427,18 +487,18 @@ class BlogComment
}
/*****
** Converts the Markdown content to HTML
** Converts the Markdown comment to HTML
*****/
public function md2html() {
$this->content_html = \Michelf\MarkdownExtra::defaultTransform($this->content);
$this->comment_html = \Michelf\MarkdownExtra::defaultTransform($this->comment);
}
/*****
** Converts the Markdown content to text
** Converts the Markdown comment to text
*****/
public function md2txt() {
$this->md2html();
$this->content_txt = strip_tags($this->content_html);
$this->comment_txt = strip_tags($this->comment_html);
}
}
@ -453,7 +513,7 @@ class BlogComment
class BlogComments
{
public $ids = array();
public $objs = array();
public $number = NULL;
/*****
@ -465,10 +525,10 @@ class BlogComments
$con = pg_connect("host=".$config['SQL_host']." dbname=".$config['SQL_db']." user=".$config['SQL_user']." password=".$config['SQL_pass'])
or die ("Could not connect to server\n");
$query = "SELECT id FROM blog_comments WHERE article = $1 ";
$query = "SELECT * FROM content_comments WHERE content = $1 ";
if ($archive == 0)
$query .= "AND archive IS FALSE ";
$query .= "ORDER BY lastedit DESC";
$query .= "AND is_archive IS FALSE AND is_public IS TRUE ";
$query .= "ORDER BY update_date DESC";
pg_prepare($con, "prepare1", $query)
or die ("Cannot prepare statement\n");
@ -481,7 +541,8 @@ class BlogComments
for($i = 0; $i < pg_num_rows($result); $i++) {
$row = pg_fetch_assoc($result, $i);
$this->ids[$i] = $row['id'];
$this->objs[$i] = new BlogComment;
$this->objs[$i]->populate($row);
}
}
}

View File

@ -14,8 +14,10 @@ require_once($config['third_folder']."Md/MarkdownExtra.inc.php");
class WikiPage
{
public $id = 0;
public $permalink = 0;
public $content_id = NULL;
public $locale_id = NULL;
public $version_id = NULL;
public $permalink = NULL;
public $version = 0;
public $locale = NULL;
public $creation_date = NULL;
@ -37,7 +39,7 @@ class WikiPage
$con = pg_connect("host=".$config['SQL_host']." dbname=".$config['SQL_db']." user=".$config['SQL_user']." password=".$config['SQL_pass'])
or die ("Could not connect to server\n");
$query = "SELECT * FROM contents WHERE permalink=$1 AND type='wiki'";
$query = "SELECT content_versions.id AS version_id, * FROM contents INNER JOIN content_locales ON contents.id = content_locales.content_id INNER JOIN content_versions ON content_locales.id = content_versions.locale_id WHERE permalink=$1 AND type='wiki'";
if($withArchive==0) {
$query .= " AND is_archive=FALSE AND is_public=TRUE";
}
@ -64,7 +66,9 @@ class WikiPage
** Populate the object using raw data from SQL
*****/
public function populate($row) {
$this->id = $row['id'];
$this->content_id = $row['content_id'];
$this->locale_id = $row['locale_id'];
$this->version_id = $row['version_id'];
$this->permalink = $row['permalink'];
$this->version = $row['version'];
$this->locale = $row['locale'];
@ -86,46 +90,37 @@ class WikiPage
global $config;
global $user;
if($this->id == 0)
if($this->content_id == 0 || $this->locale_id == 0 || $this->version_id == 0)
die("Cannot update entry without giving ID");
$oldId = $this->id;
$this->version++;
$con = pg_connect("host=".$config['SQL_host']." dbname=".$config['SQL_db']." user=".$config['SQL_user']." password=".$config['SQL_pass'])
or die ("Could not connect to server\n");
$query = "UPDATE contents SET is_archive = TRUE WHERE permalink = $1 AND type='wiki'";
$query = "UPDATE content_versions SET is_archive = TRUE WHERE locale_id = $1";
pg_prepare($con, "prepare1", $query)
or die ("Cannot prepare statement\n");
$result = pg_execute($con, "prepare1", array($this->permalink))
$result = pg_execute($con, "prepare1", array($this->locale_id))
or die ("Cannot execute statement\n");
$query = "INSERT INTO contents (permalink, version, locale, creation_date, update_date, author, is_public, is_archive, is_commentable, type, name, content) VALUES
($1, $2, $3, $4, $5, $6, TRUE, FALSE, FALSE, 'wiki', $7, $8) RETURNING id";
$query = "INSERT INTO content_versions (version, update_date, is_archive, name, content, locale_id) VALUES
($1, $2, FALSE, $3, $4, $5) RETURNING id";
pg_prepare($con, "prepare2", $query)
or die ("Cannot prepare statement\n");
$result = pg_execute($con, "prepare2", array($this->permalink, $this->version, $this->locale, $this->creation_date, date('r'), $this->author, $this->name, $this->content))
$result = pg_execute($con, "prepare2", array($this->version, date('r'), $this->name, $this->content, $this->locale_id))
or die ("Cannot execute statement\n");
$this->id = pg_fetch_assoc($result)['id'];
$query = "INSERT INTO content_contributors (content, contributor) SELECT $1, contributor FROM content_contributors AS old WHERE old.content = $2";
pg_prepare($con, "prepare3", $query)
or die ("Cannot prepare statement\n");
$result = pg_execute($con, "prepare3", array($this->id, $oldId))
or die ("Cannot execute statement\n");
$this->version_id = pg_fetch_assoc($result)['id'];
$query = "INSERT INTO content_contributors (content, contributor) VALUES
($1, $2) ON CONFLICT (content, contributor) DO NOTHING";
pg_prepare($con, "prepare4", $query)
pg_prepare($con, "prepare3", $query)
or die ("Cannot prepare statement\n");
$result = pg_execute($con, "prepare4", array($this->id, $user->id))
$result = pg_execute($con, "prepare3", array($this->locale_id, $user->id))
or die ("Cannot execute statement\n");
pg_close($con);
@ -196,15 +191,43 @@ class WikiPage
$con = pg_connect("host=".$config['SQL_host']." dbname=".$config['SQL_db']." user=".$config['SQL_user']." password=".$config['SQL_pass'])
or die ("Could not connect to server\n");
$query = "INSERT INTO contents (permalink, version, locale, creation_date, update_date, author, is_public, is_archive, is_commentable, type, name, content) VALUES
($1, '0', $2, $3, $4, $5, TRUE, FALSE, FALSE, 'wiki', $6, $7) RETURNING id";
$query = "INSERT INTO contents (permalink, creation_date, is_public, is_commentable, type) VALUES
($1, $2, TRUE, FALSE, 'wiki') RETURNING id";
pg_prepare($con, "prepare1", $query)
or die ("Cannot prepare statement\n");
$result = pg_execute($con, "prepare1", array($this->permalink, $this->locale, date('r'), date('r'), $user->id, $this->name, $this->content))
$result = pg_execute($con, "prepare1", array($this->permalink, date('r')))
or die ("Cannot execute statement\n");
$this->id = pg_fetch_assoc($result)['id'];
$this->content_id = pg_fetch_assoc($result)['id'];
$query = "INSERT INTO content_locales (content_id, locale, author) VALUES
($1, $2, $3) RETURNING id";
pg_prepare($con, "prepare2", $query)
or die ("Cannot prepare statement\n");
$result = pg_execute($con, "prepare2", array($this->content_id, $this->locale, $user->id))
or die ("Cannot execute statement\n");
$this->locale_id = pg_fetch_assoc($result)['id'];
$query = "INSERT INTO content_versions (version, update_date, is_archive, name, content, locale_id) VALUES
('0', $1, FALSE, $2, $3, $4) RETURNING id";
pg_prepare($con, "prepare3", $query)
or die ("Cannot prepare statement\n");
$result = pg_execute($con, "prepare3", array(date('r'), $this->name, $this->content, $this->locale_id))
or die ("Cannot execute statement\n");
$this->version_id = pg_fetch_assoc($result)['id'];
$query = "INSERT INTO content_contributors (content, contributor) VALUES
($1, $2)";
pg_prepare($con, "prepare4", $query)
or die ("Cannot prepare statement\n");
$result = pg_execute($con, "prepare4", array($this->locale_id, $user->id))
or die ("Cannot execute statement\n");
pg_close($con);
@ -244,7 +267,7 @@ class WikiPages
$con = pg_connect("host=".$config['SQL_host']." dbname=".$config['SQL_db']." user=".$config['SQL_user']." password=".$config['SQL_pass'])
or die ("Could not connect to server\n");
$query = "SELECT * FROM contents WHERE permalink=$1 AND type='wiki' ORDER BY update_date DESC";
$query = "SELECT content_versions.id AS version_id, * FROM contents INNER JOIN content_locales ON contents.id = content_locales.content_id INNER JOIN content_versions ON content_locales.id = content_versions.locale_id WHERE permalink=$1 AND type='wiki' ORDER BY update_date DESC";
pg_prepare($con, "prepare1", $query)
or die ("Cannot prepare statement\n");

View File

@ -40,7 +40,7 @@
<li class="on-bar has-sub"><a class="on-bar" href="#"><i class="icon fas fa-question"></i></a>
<ul>
<li><a href="<?=$config['rel_root_folder']?>wiki/help">Aide</a></li>
<!--<li><a href="<?=$config['rel_root_folder']?>blog">Blog</a></li>-->
<li><a href="<?=$config['rel_root_folder']?>blog">Blog</a></li>
<li><a href="<?=$config['rel_root_folder']?>contact">Contact</a></li>
<li><a href="<?=$config['rel_root_folder']?>wiki/api">API Développeurs</a></li>
<li><a href="<?=$config['rel_root_folder']?>wiki/about">À propos</a></li>

View File

@ -184,9 +184,10 @@ form.form input[type="checkbox"] {
}
form.form input[type="checkbox"] + span:before {
font-family: 'FontAwesome';
font-family: "Font Awesome 5 Free";
font-weight: 400;
vertical-align: middle;
padding: 2px 4px 0px 5px;
padding: 2px 5px 2px 4px;
margin-right: 10px;
display: inline-block;
width: 21px;
@ -195,11 +196,11 @@ form.form input[type="checkbox"] + span:before {
}
form.form input[type="checkbox"] + span:before {
content: "\f096"; /* check-empty */
content: "\f0c8"; /* check-empty */
}
form.form input[type="checkbox"]:checked + span:before {
content: "\f046"; /* check */
content: "\f14a"; /* check */
}
/* Also used for new comment form in the view page */
@ -229,7 +230,7 @@ form.form label {
float: right;
font-size: 17px;
}
#url {
#permalink {
width: calc(100% - 20px);
}

View File

@ -12,31 +12,31 @@
<form class="form" action="<?=$config['rel_root_folder']?>blog/new" method="post">
<? }
else { ?>
<form class="form" action="<?=$config['rel_root_folder']?>blog/<?=$blogArticle->url?>/edit" method="post">
<form class="form" action="<?=$config['rel_root_folder']?>blog/<?=$blogArticle->permalink?>/edit" method="post">
<? } ?>
<h1>
<select name="locale" id="locale">
<? foreach($config['locales'] as $locale) { ?>
<option <?=$blogArticle->locale==$locale[0]?'selected':''?> value="<?=$locale[0]?>"><?=$locale[5]?></option>
<? foreach($locales->objs as $locale) { ?>
<option <?=$blogArticle->locale==$locale->name?'selected':''?> value="<?=$locale->name?>"><?=$locale->display_name?></option>
<? } ?>
</select>
<input type="text" value="<?=$blogArticle->title?>" name="title" id="title" placeholder="Titre">
<input type="text" value="<?=$blogArticle->name?>" name="name" id="name" placeholder="Titre">
</h1>
<? if(isset($error) AND $error=="url") { ?>
<? if(isset($error) AND $error=="permalink") { ?>
<p style="color: red;">L'URL sélectionnée est déjà prise.</p>
<? } ?>
<textarea rows="30" name="content" id="content" placeholder="Contenu de la page"><?=$blogArticle->content?></textarea>
<textarea rows="30" name="content" id="content" placeholder="Contenu de l'article"><?=$blogArticle->content?></textarea>
<? if(isset($new) AND $new==1) { ?>
<input type="text" value="<?=$blogArticle->url?>" name="url" id="url" placeholder="URL">
<input type="text" value="<?=$blogArticle->permalink?>" name="permalink" id="permalink" placeholder="URL">
<? } ?>
<label for="comments">
<input type="checkbox" name="comments" id="comments" value="comments"
<? if($blogArticle->comments == 't') { ?>
<label for="is_commentable">
<input type="checkbox" name="is_commentable" id="is_commentable"
<? if($blogArticle->is_commentable == 't') { ?>
checked
<? } ?>
/>
@ -48,21 +48,21 @@
</section>
<script type="text/javascript">
$( "#title" ).keyup(function() {
url = $( "#title" ).val();
url = url.replace(/ /g,'_');
url = url.toLowerCase();
url = url.replace(/[^a-z0-9_]/g,'-');
url = url.replace(/[_$]/g,'-');
$( "#url" ).val(url);
$( "#name" ).keyup(function() {
permalink = $( "#name" ).val();
permalink = permalink.replace(/ /g,'_');
permalink = permalink.toLowerCase();
permalink = permalink.replace(/[^a-z0-9_]/g,'-');
permalink = permalink.replace(/[_-]+$/g,'');
$( "#permalink" ).val(permalink);
});
$( "#title" ).change(function() {
url = $( "#title" ).val();
url = url.replace(/ /g,'_');
url = url.toLowerCase();
url = url.replace(/[^a-z0-9_]/g,'-');
url = url.replace(/[_$]/g,'-');
$( "#url" ).val(url);
$( "#name" ).change(function() {
permalink = $( "#name" ).val();
permalink = permalink.replace(/ /g,'_');
permalink = permalink.toLowerCase();
permalink = permalink.replace(/[^a-z0-9_]/g,'-');
permalink = permalink.replace(/[_-]+$/g,'');
$( "#permalink" ).val(permalink);
});
</script>

View File

@ -10,25 +10,25 @@
<section id="blog_list">
<h1>Blog.</h1>
<p class="subtitle">
<? if ($user->role >= 800) { ?>
<a href="<?=$config['rel_root_folder']?>blog/new"><i class="fa fa-plus"></i> Nouvel article</a> &mdash;
<? if ($user->rankIsHigher("moderator")) { ?>
<a href="<?=$config['rel_root_folder']?>blog/new"><i class="fas fa-plus"></i> Nouvel article</a> &mdash;
<? } ?>
<a href="<?=$config['rel_root_folder']?>blog/rss"><i class="fa fa-rss" aria-hidden="true"></i> Flux RSS</a> &mdash;
<a href="<?=$config['rel_root_folder']?>blog/rss"><i class="fas fa-rss" aria-hidden="true"></i> Flux RSS</a> &mdash;
Articles <?=$first?> à <?=$last?> sur <?=$blogArticles->number?>
</p>
<div id="articles_list">
<? foreach ($blogArticles_list as $row) { ?>
<? foreach ($blogArticles->objs as $row) { ?>
<article <? if($row->archive == 't') echo 'class="article_archive" '; ?>>
<h2 class="article_title"><?=$row->title?>.</h2>
<article <? if($row->is_archive == 't') echo 'class="article_archive" '; ?>>
<h2 class="article_title"><?=$row->name?>.</h2>
<div class="article_content"><?=mb_substr($row->content_txt,0,200)?>...</div>
<p class="article_legend">
<a class="article_link" href="<?=$config['rel_root_folder']?>blog/<?=$row->url?>">Lire la suite...</a>
<a class="article_link" href="<?=$config['rel_root_folder']?>blog/<?=$row->permalink?>">Lire la suite...</a>
<span class="article_infos">
Le <? echo strftime('%e %B %G',strtotime($row->lastedit)) ?> par
<? if ($user->role > 0) { ?>
Le <? echo strftime('%e %B %G',strtotime($row->update_date)) ?> par
<? if ($user->rankIsHigher("registered")) { ?>
<a href="<?=$config['rel_root_folder']?>user/p/<?=$row->author?>"><?=$row->author_name?></a>
<? }
else { ?>
@ -43,8 +43,8 @@
</div>
<div class="pagebuttons">
<? if ($page != 0) { ?><a class="previous" href="<?=$config['rel_root_folder']?>blog/<?=$page?>"><i class="fa fa-chevron-left fa-fw"></i></a><? }
if (($page+1)*$articles_per_pages < $blogArticles->number) { ?><a class="next" href="<?=$config['rel_root_folder']?>blog/<?=$page+2?>"><i class="fa fa-chevron-right fa-fw"></i></a><? } ?>
<? if ($page != 0) { ?><a class="previous" href="<?=$config['rel_root_folder']?>blog/<?=$page?>"><i class="fas fa-chevron-left fa-fw"></i></a><? }
if (($page+1)*$articles_per_pages < $blogArticles->number) { ?><a class="next" href="<?=$config['rel_root_folder']?>blog/<?=$page+2?>"><i class="fas fa-chevron-right fa-fw"></i></a><? } ?>
</div>
</section>

View File

@ -14,25 +14,25 @@ echo ('<?xml version="1.0" encoding="UTF-8"?>'); ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>Kabano</title>
<link><?=$config['rel_root_folder']?></link>
<atom:link href="<?=$config['rel_root_folder']?>blog/rss" rel="self" type="application/rss+xml" />
<link><?=$config['web_root_folder']?></link>
<atom:link href="<?=$config['web_root_folder']?>blog/rss" rel="self" type="application/rss+xml" />
<description>L'actualité du blog officiel de Kabano : Plateforme collaborative de recensement de cabanes et refuges.</description>
<language>fr</language>
<image>
<url><?=$config['views_url']?>img/header_rss.svg</url>
<url><?=$config['web_root_folder']?>views/img/header_rss.svg</url>
<title>Kabano</title>
<link><?=$config['rel_root_folder']?></link>
<link><?=$config['web_root_folder']?></link>
<height>44</height>
<width>154</width>
</image>
<? foreach ($blogArticles_list as $row) { ?>
<? foreach ($blogArticles->objs as $row) { ?>
<item>
<title><?=$row->title?></title>
<link><?=$config['rel_root_folder']?>blog/<?=$row->url?></link>
<guid><?=$config['rel_root_folder']?>blog/<?=$row->url?></guid>
<pubDate><?=$row->lastedit?></pubDate>
<title><?=$row->name?></title>
<link><?=$config['web_root_folder']?>blog/<?=$row->permalink?></link>
<guid><?=$config['web_root_folder']?>blog/<?=$row->permalink?></guid>
<pubDate><?=gmdate(DATE_RFC822, strtotime($row->update_date))?></pubDate>
<description><![CDATA[
<?=$row->content_html?>
]]></description>

View File

@ -7,27 +7,28 @@
<? include('blocks/d.nav.html'); ?>
<section id="blog_article" <?=$blogArticle->archive=="t"?'class="archive"':''?>>
<h1><?=$blogArticle->title?>.</h1>
<? if($user->role >= 600) { ?>
<section id="blog_article" <?=$blogArticle->is_archive=="t"||$blogArticle->is_public=="f"?'class="archive"':''?>>
<h1><?=$blogArticle->name?></h1>
<? if($user->rankIsHigher('premium')) { ?>
<span class="subtitle">
<? if(isset($blogArticles_history_list)) { ?>
<? if(isset($blogHistory)) { ?>
<select id="bloghistory">
<? $i = 0;
foreach ($blogArticles_history_list as $row) { ?>
<option <?=$row->id==$blogArticle->id?'selected':''?> value="<?=$i?>"><?=$row->archive=="f"?'&bull; ':''?><? echo strftime('%d/%m/%Y %H:%M:%S',strtotime($row->lastedit)) ?></option>
foreach ($blogHistory->objs as $row) { ?>
<option <?=$row->version_id==$blogArticle->version_id?'selected':''?> value="<?=$i?>"><?=$row->is_archive=="f"?'&bull; ':''?><? echo strftime('%d/%m/%Y %H:%M:%S',strtotime($row->update_date)) ?></option>
<? $i++;
} ?>
</select>
<? }
if ($user->role >= 800 && isset($blogArticles_history_list)) { ?>
if ($user->rankIsHigher('moderator') && isset($blogHistory)) { ?>
&mdash;
<? }
if ($user->role >= 800) { ?>
<a href="<?=$config['rel_root_folder']?>blog/<?=$blogArticle->url?>/edit"><i class="fa fa-pencil"></i> Éditer l'article</a>
<? if ($blogArticle->archive == 'f') { ?>
&mdash;
<a href="<?=$config['rel_root_folder']?>blog/<?=$blogArticle->url?>/delete"><i class="fa fa-trash"></i> Effacer l'article</a>
if ($user->rankIsHigher("moderator")) { ?>
<a href="<?=$config['rel_root_folder']?>blog/<?=$blogArticle->permalink?>/edit"><i class="fas fa-pencil-alt"></i> Éditer l'article</a> &mdash;
<? if ($blogArticle->is_public == 't') { ?>
<a href="<?=$config['rel_root_folder']?>blog/<?=$blogArticle->permalink?>/delete"><i class="fas fa-trash"></i> Effacer l'article</a>
<? } else { ?>
<a href="<?=$config['rel_root_folder']?>blog/<?=$blogArticle->permalink?>/restore"><i class="fas fa-eye"></i> Restaurer l'article</a>
<? } ?>
<? } ?>
</span>
@ -38,21 +39,23 @@
</div>
<p id="blogTimestamp">Article écrit par
<? if ($user->role > 0) { ?>
<? if ($user->rankIsHigher("blocked")) { ?>
<a href="<?=$config['rel_root_folder']?>user/p/<?=$blogArticle->author?>"><?=$blogArticle->author_name?></a>
<? }
else { ?>
<?=$blogArticle->author_name?>
<? } ?>
le <? echo strftime('%e %B %G, %kh%Mm%Ss',strtotime($blogArticle->lastedit)) ?> <small><abbr title="Temps Universel Coordonné">UTC</abbr></small></p>
le <? echo strftime('%e %B %G, %kh%Mm%Ss',strtotime($blogArticle->creation_date)) ?> <small><abbr title="Temps Universel Coordonné">UTC</abbr></small></p>
<!-- COMMENTS -->
<? if ($blogArticle->comments == "t" && $blogArticle->archive == "f") { ?>
<? if ($blogArticle->is_commentable == "t") { ?>
<div id="new_comment">
<form class="form" action="<?=$config['rel_root_folder']?>blog/<?=$blogArticle->url?>/new_comment" method="post">
<div id="new_comment_label" <?=$user->role==0?"class='sent' ":""?>>
<? if ($user->role > 0) { ?>
<form class="form" action="<?=$config['rel_root_folder']?>blog/<?=$blogArticle->permalink?>/new_comment" method="post">
<div id="new_comment_label" <?=$user->rank=="visitor"?"class='sent' ":""?>>
<? if ($blogArticle->is_archive == "t" || $blogArticle->is_public == "f") { ?>
<p>Impossible de commenter un article non publié</p>
<? } else if ($user->rankIsHigher("registered")) { ?>
<input name="submit" type="submit" value="Envoyer">
<p>Ajouter un nouveau commentaire</p>
<? } else { ?>
@ -65,31 +68,31 @@
</form>
</div>
<? if(isset($blogArticles_comments_list)) {
foreach ($blogArticles_comments_list as $row) { ?>
<? if($blogArticle->is_commentable == 't') {
foreach ($blogArticles_comments->objs as $comment) { ?>
<article <? if($row->archive == 't') echo 'class="comment_archive" '; ?>>
<article <? if($comment->is_archive == 't' || $comment->is_public == 'f') echo 'class="comment_archive" '; ?>>
<div class="comment_title">
<? if ($row->author_obj->avatar=='t') { ?>
<img alt="Avatar" class="icon avatar" src="<?=$config['rel_root_folder']?>medias/avatars/<?=$row->author_obj->id?>_s.jpg">
<? if ($comment->author_obj->is_avatar_present=='t') { ?>
<img alt="Avatar" class="icon avatar" src="<?=$config['rel_root_folder']?>medias/avatars/<?=$comment->author_obj->id?>_s.jpg">
<? } else { ?>
<i class="icon fa fa-user-secret"></i>
<i class="icon fas fa-user-secret"></i>
<? } ?>
<? if ($user->role > 0) { ?>
<a class="username" href="<?=$config['rel_root_folder']?>user/p/<?=$row->author_obj->id?>"><?=$row->author_obj->name?></a>
<? if ($user->rankIsHigher("blocked")) { ?>
<a class="username" href="<?=$config['rel_root_folder']?>user/p/<?=$comment->author_obj->id?>"><?=$comment->author_obj->name?></a>
<? } else { ?>
<?=$row->author_obj->name?>
<?=$comment->author_obj->name?>
<? } ?>
le <? echo strftime('%e %B %G, %kh%Mm%Ss',strtotime($row->lastedit)) ?> <small><abbr title="Temps Universel Coordonné">UTC</abbr></small>
<? if (($user->role >= 800 || $user->id == $row->author) && $row->archive == 'f') { ?>
<span class="delete_link"><a href="<?=$config['rel_root_folder']?>blog/<?=$blogArticle->url?>/delete_comment/<?=$row->id?>"><i class="fa fa-trash"></i> Effacer le commentaire</a></span>
le <? echo strftime('%e %B %G, %kh%Mm%Ss',strtotime($comment->update_date)) ?> <small><abbr title="Temps Universel Coordonné">UTC</abbr></small>
<? if (($user->rankIsHigher("moderator") || $user->id == $comment->author) && $comment->is_public == 't') { ?>
<span class="delete_link"><a href="<?=$config['rel_root_folder']?>blog/<?=$blogArticle->permalink?>/delete_comment/<?=$comment->id?>"><i class="fas fa-trash"></i> Effacer le commentaire</a></span>
<? } ?>
<? if (($user->role >= 800 || $user->id == $row->author) && $row->archive == 't') { ?>
<span class="delete_link"><a href="<?=$config['rel_root_folder']?>blog/<?=$blogArticle->url?>/undelete_comment/<?=$row->id?>"><i class="fa fa-eye"></i> Réafficher le commentaire</a></span>
<? if (($user->rankIsHigher("moderator") || $user->id == $comment->author) && $comment->is_public == 'f') { ?>
<span class="delete_link"><a href="<?=$config['rel_root_folder']?>blog/<?=$blogArticle->permalink?>/restore_comment/<?=$comment->id?>"><i class="fas fa-eye"></i> Restaurer le commentaire</a></span>
<? } ?>
</div>
<div class="comment_content">
<?=$row->content_html?>
<?=$comment->comment_html?>
</div>
</article>
@ -102,14 +105,14 @@
<div style="clear: both;"> </div>
</section>
<? if($user->role >= 600) { ?>
<? if($user->rankIsHigher("premium")) { ?>
<script type="text/javascript">
$( "#bloghistory" ).change(function() {
window.location.href = "<?=$config['rel_root_folder']?>blog/<?=$blogArticle->url?>/"+$( this ).val();
window.location.href = "<?=$config['rel_root_folder']?>blog/<?=$blogArticle->permalink?>/"+$( this ).val();
});
</script>
<? } ?>
<? if($user->role > 0) { ?>
<? if($user->rankIsHigher("registered") && $blogArticle->is_archive == "f" && $blogArticle->is_public == "t") { ?>
<script type="text/javascript">
$( "#new_comment_label" ).click(function() {
$( "#new_comment_form" ).show(400);

View File

@ -8,14 +8,14 @@
<? include('blocks/d.nav.html'); ?>
<section id="wiki_page" <?=$wikiPage->is_archive=="t"||$wikiPage->is_public=="f"?'class="archive"':''?>>
<h1><?=$wikiPage->name?>.</h1>
<h1><?=$wikiPage->name?></h1>
<? if($user->rankIsHigher('premium')) { ?>
<span class="subtitle">
<? if(isset($wikiHistory)) { ?>
<select id="wikihistory">
<? $i = 0;
foreach ($wikiHistory->objs as $row) { ?>
<option <?=$row->id==$wikiPage->id?'selected':''?> value="<?=$i?>"><?=$row->is_archive=="f"?'&bull; ':''?><? echo strftime('%d/%m/%Y %H:%M:%S',strtotime($row->update_date)) ?></option>
<option <?=$row->version_id==$wikiPage->version_id?'selected':''?> value="<?=$i?>"><?=$row->is_archive=="f"?'&bull; ':''?><? echo strftime('%d/%m/%Y %H:%M:%S',strtotime($row->update_date)) ?></option>
<? $i++;
} ?>
</select>