aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvincent-peugnet <v.peugnet@free.fr>2019-10-16 02:06:46 +0200
committervincent-peugnet <v.peugnet@free.fr>2019-10-16 02:06:46 +0200
commitba126f5f7175bcefbdb16c44cf74203f0756bb1b (patch)
tree599223b5751e433cd504943f1b0d586c735744ef
parentcab6c37b88830a0b3b6dcbdcb40c240b334c3b8f (diff)
downloadwcms-ba126f5f7175bcefbdb16c44cf74203f0756bb1b.tar.gz
wcms-ba126f5f7175bcefbdb16c44cf74203f0756bb1b.zip
automatic pass ask when visitor try to edit or add
-rw-r--r--app/class/controllerart.php19
-rw-r--r--app/view/templates/connect.php12
-rw-r--r--composer.json2
3 files changed, 28 insertions, 5 deletions
diff --git a/app/class/controllerart.php b/app/class/controllerart.php
index 690b260..5a9634b 100644
--- a/app/class/controllerart.php
+++ b/app/class/controllerart.php
@@ -45,6 +45,20 @@ class Controllerart extends Controller
}
+ /**
+ * show credentials for unconnected editors for a specific page
+ *
+ * @param string $route direction to redirect after the connection form
+ * @return void
+ */
+ public function artconnect(string $route)
+ {
+ if($this->user->isvisitor()) {
+ $this->showtemplate('connect', ['route' => $route, 'id' => $this->art->id()]);
+ exit;
+ }
+ }
+
public function canedit()
{
@@ -149,6 +163,8 @@ class Controllerart extends Controller
{
$this->setart($id, 'artedit');
+ $this->artconnect('artedit');
+
if ($this->importart() && $this->canedit()) {
$tablist = ['main' => $this->art->main(), 'css' => $this->art->css(), 'header' => $this->art->header(), 'nav' => $this->art->nav(), 'aside' => $this->art->aside(), 'footer' => $this->art->footer(), 'body' => $this->art->body(), 'javascript' => $this->art->javascript()];
@@ -189,6 +205,9 @@ class Controllerart extends Controller
public function add($id)
{
$this->setart($id, 'artadd');
+
+ $this->artconnect('artadd');
+
if ($this->user->iseditor() && !$this->importart()) {
$this->art->reset();
if (!empty(Config::defaultart())) {
diff --git a/app/view/templates/connect.php b/app/view/templates/connect.php
index 608a557..82c01ec 100644
--- a/app/view/templates/connect.php
+++ b/app/view/templates/connect.php
@@ -11,16 +11,14 @@
<?php if($user->isvisitor()) { ?>
-<?= $route === 'artedit' ? '<p>Your edits have been temporary saved. You need to connect and update to store it completly</p>' : '' ?>
-
<form action="<?= $this->url('log') ?>" method="post">
<input type="hidden" name="route" value="<?= $route ?>">
<?php
-if(in_array($route, ['artedit', 'artread', 'artread/'])) {
+if(in_array($route, ['artedit', 'artread', 'artread/', 'artadd'])) {
echo '<input type="hidden" name="id" value="'. $id .'">';
}
?>
-<input type="password" name="pass" id="loginpass" placeholder="password">
+<input type="password" name="pass" id="loginpass" placeholder="password" autofocus>
<input name="log" type="submit" value="login">
</form>
@@ -35,4 +33,10 @@ if(in_array($route, ['artedit', 'artread', 'artread/'])) {
<?php } ?>
+<?php
+if(in_array($route, ['artedit', 'artread', 'artread/', 'artadd'])) {
+ echo '<p><a href="' . $this->uart('artread/', $id) . '">back to page read view</a></p>';
+}
+?>
+
<?php $this->stop() ?> \ No newline at end of file
diff --git a/composer.json b/composer.json
index 9146aee..a9a5c61 100644
--- a/composer.json
+++ b/composer.json
@@ -1,7 +1,7 @@
{
"name": "w-cms",
"description": "point'n think",
- "version": "1.5.4",
+ "version": "1.5.5",
"require": {
"michelf/php-markdown": "^1.8",
"league/plates": "3.*",