From 3ad4a6d08e07e910302d6a5b7bb650b330146571 Mon Sep 17 00:00:00 2001 From: leosw Date: Mon, 5 Nov 2018 22:31:20 +0100 Subject: [PATCH] Store author as contributor in wiki/blog --- models/d.blog.php | 12 ++++++++++-- models/d.wiki.php | 12 ++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/models/d.blog.php b/models/d.blog.php index ca84edf..bd329c6 100755 --- a/models/d.blog.php +++ b/models/d.blog.php @@ -179,10 +179,18 @@ class BlogArticle $result = pg_execute($con, "prepare1", array($this->permalink, $this->locale, date('r'), date('r'), $user->id, $this->is_commentable, $this->name, $this->content)) or die ("Cannot execute statement\n"); - pg_close($con); - $this->id = pg_fetch_assoc($result)['id']; + $query = "INSERT INTO content_contributors (content, contributor) VALUES + ($1, $2)"; + + pg_prepare($con, "prepare2", $query) + or die ("Cannot prepare statement\n"); + $result = pg_execute($con, "prepare2", 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", 3, diff --git a/models/d.wiki.php b/models/d.wiki.php index 128d1cb..8f17632 100755 --- a/models/d.wiki.php +++ b/models/d.wiki.php @@ -204,10 +204,18 @@ class WikiPage $result = pg_execute($con, "prepare1", array($this->permalink, $this->locale, date('r'), date('r'), $user->id, $this->name, $this->content)) or die ("Cannot execute statement\n"); - pg_close($con); - $this->id = pg_fetch_assoc($result)['id']; + $query = "INSERT INTO content_contributors (content, contributor) VALUES + ($1, $2)"; + + pg_prepare($con, "prepare2", $query) + or die ("Cannot prepare statement\n"); + $result = pg_execute($con, "prepare2", 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 wiki page '".$this->permalink."'\r\n", 3,