diff --git a/controllers/d.poi.php b/controllers/d.poi.php index d92963b..8b363a7 100755 --- a/controllers/d.poi.php +++ b/controllers/d.poi.php @@ -18,11 +18,13 @@ switch ($controller->splitted_url[1]) { $poi->lon = $_POST['lon']; $poi->ele = $_POST['ele']; $poi->author = $user->id; - $poi->source = "k"; + $poi->source = "kab"; + $poi->is_commentable = isset($_POST['is_commentable'])?'t':'f'; + $poi->parameters = ''; if(!$poi->checkPermalink($_POST['permalink'],1)) { $poi->permalink = $_POST['permalink']; $poi->insert(); - header('Location: '.$config['rel_root_folder']."blog/".$poi->permalink); + header('Location: '.$config['rel_root_folder']."poi/".$poi->permalink); } else { $head['title'] = $poi->name; diff --git a/models/d.poi.php b/models/d.poi.php index df3d8f3..b08a04e 100755 --- a/models/d.poi.php +++ b/models/d.poi.php @@ -109,15 +109,17 @@ class Poi $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 (is_public, permalink, creation_date, name, type, poi_type) VALUES - (TRUE, $1, $2, $3, $4, $5) RETURNING id"; + pg_query($con, "BEGIN"); + + $query = "INSERT INTO contents (is_commentable, is_public, permalink, creation_date, name, type, poi_type) VALUES + ($1, TRUE, $2, $3, $4, $5, $6) RETURNING id"; pg_prepare($con, "prepare1", $query) or die ("Cannot prepare statement\n"); - $result = pg_execute($con, "prepare1", array($this->permalink, date('r'), $this->name, $this->type, $this->poi_type)) + $result = pg_execute($con, "prepare1", array($this->is_commentable, $this->permalink, date('r'), $this->name, $this->type, $this->poi_type)) or die ("Cannot execute statement\n"); - $this->poi_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"; @@ -151,11 +153,13 @@ class Poi $query = "INSERT INTO content_contributors (content, contributor) VALUES ($1, $2)"; - pg_prepare($con, "prepare4", $query) + pg_prepare($con, "prepare5", $query) or die ("Cannot prepare statement\n"); - $result = pg_execute($con, "prepare4", array($this->locale_id, $user->id)) + $result = pg_execute($con, "prepare5", array($this->locale_id, $user->id)) or die ("Cannot execute statement\n"); + pg_query($con, "COMMIT"); + pg_close($con); error_log( diff --git a/views/css/d.poi.css b/views/css/d.poi.css index f877b9f..c403f93 100755 --- a/views/css/d.poi.css +++ b/views/css/d.poi.css @@ -162,6 +162,30 @@ form.form input[type=radio]+label img { font-style: italic; } +form.form input[type="checkbox"] { + display:none; +} + +form.form input[type="checkbox"] + span:before { + font-family: "Font Awesome 5 Free"; + font-weight: 400; + vertical-align: middle; + padding: 2px 5px 2px 4px; + margin-right: 10px; + display: inline-block; + width: 21px; + background: #ddd; + font-size: 25px; +} + +form.form input[type="checkbox"] + span:before { + content: "\f0c8"; /* check-empty */ +} + +form.form input[type="checkbox"]:checked + span:before { + content: "\f14a"; /* check */ +} + #permalink_container { position: relative; margin: 2px 0; diff --git a/views/d.poi.edit.html b/views/d.poi.edit.html index 0e2d8bc..b176371 100755 --- a/views/d.poi.edit.html +++ b/views/d.poi.edit.html @@ -123,10 +123,15 @@
+ + if(isset($new) AND $new==1) { ?>