aboutsummaryrefslogtreecommitdiff
path: root/app/class
diff options
context:
space:
mode:
authorvincent-peugnet <v.peugnet@free.fr>2018-12-26 19:35:19 +0100
committervincent-peugnet <v.peugnet@free.fr>2018-12-26 19:35:19 +0100
commit3cbecb3a54fac2708774158ae65dafec6d098937 (patch)
treebf3b105f0dffe425d528f4caa4de4dc40261167b /app/class
parentb596f5d1c15ce3e2df50c756fd56080192e438ef (diff)
downloadwcms-3cbecb3a54fac2708774158ae65dafec6d098937.tar.gz
wcms-3cbecb3a54fac2708774158ae65dafec6d098937.zip
feature: invite editors
Diffstat (limited to 'app/class')
-rw-r--r--app/class/art2.php14
-rw-r--r--app/class/controllerart.php10
-rw-r--r--app/class/modeluser.php14
3 files changed, 34 insertions, 4 deletions
diff --git a/app/class/art2.php b/app/class/art2.php
index 5e0478e..b6311c0 100644
--- a/app/class/art2.php
+++ b/app/class/art2.php
@@ -36,6 +36,7 @@ class Art2
protected $favicon;
protected $thumbnail;
protected $authors;
+ protected $invites;
protected $affcount;
protected $editcount;
@@ -109,6 +110,7 @@ class Art2
$this->setfavicon('');
$this->setthumbnail('');
$this->setauthors([]);
+ $this->setinvites([]);
$this->setaffcount(0);
$this->seteditcount(0);
}
@@ -413,6 +415,11 @@ class Art2
return $this->authors;
}
+ public function invites($type = 'array')
+ {
+ return $this->invites;
+ }
+
public function affcount($type = 'int')
{
return $this->affcount;
@@ -702,6 +709,13 @@ class Art2
}
}
+ public function setinvites($invites)
+ {
+ if(is_array($invites)) {
+ $this->invites = array_values(array_filter($invites));
+ }
+ }
+
public function setaffcount($affcount)
{
if (is_int($affcount)) {
diff --git a/app/class/controllerart.php b/app/class/controllerart.php
index 9a4edbe..f292975 100644
--- a/app/class/controllerart.php
+++ b/app/class/controllerart.php
@@ -46,7 +46,7 @@ class Controllerart extends Controller
if ($this->user->iseditor()) {
return true;
} elseif ($this->user->isinvite()) {
- if ($this->user->password() === $this->art->invitepassword()) {
+ if (in_array($this->user->id(), $this->art->invites())) {
return true;
} else {
return false;
@@ -105,7 +105,7 @@ class Controllerart extends Controller
$this->art->addaffcount();
$this->artmanager->update($this->art);
}
- $data = array_merge($alerts, $page, ['art' => $this->art, 'artexist' => $artexist, 'canread' => $canread, 'readernav' => Config::showeditmenu()]);
+ $data = array_merge($alerts, $page, ['art' => $this->art, 'artexist' => $artexist, 'canread' => $canread, 'readernav' => Config::showeditmenu(), 'canedit' => $this->canedit()]);
$this->showtemplate('read', $data);
@@ -129,6 +129,8 @@ class Controllerart extends Controller
$tagartlist = $this->artmanager->tagartlist($this->art->tag('array'), $artlist);
$lasteditedartlist = $this->artmanager->lasteditedartlist(5, $artlist);
+ $inviteuserlist = $this->usermanager->getlisterbylevel(2);
+
if (isset($_SESSION['workspace'])) {
$showleftpanel = $_SESSION['workspace']['showleftpanel'];
$showrightpanel = $_SESSION['workspace']['showrightpanel'];
@@ -138,7 +140,7 @@ class Controllerart extends Controller
}
$fonts = [];
- $this->showtemplate('edit', ['art' => $this->art, 'artexist' => true, 'tablist' => $tablist, 'artlist' => $idlist, 'showleftpanel' => $showleftpanel, 'showrightpanel' => $showrightpanel, 'fonts' => $fonts, 'tagartlist' => $tagartlist, 'lasteditedartlist' => $lasteditedartlist, 'faviconlist' => $faviconlist]);
+ $this->showtemplate('edit', ['art' => $this->art, 'artexist' => true, 'tablist' => $tablist, 'artlist' => $idlist, 'showleftpanel' => $showleftpanel, 'showrightpanel' => $showrightpanel, 'fonts' => $fonts, 'tagartlist' => $tagartlist, 'lasteditedartlist' => $lasteditedartlist, 'faviconlist' => $faviconlist, 'inviteuserlist' => $inviteuserlist]);
} else {
$this->routedirect('artread/', ['art' => $this->art->id()]);
}
@@ -212,7 +214,7 @@ class Controllerart extends Controller
$date = new DateTimeImmutable($_POST['pdate'] . $_POST['ptime'], new DateTimeZone('Europe/Paris'));
$date = ['date' => $date];
- if ($this->importart() && $this->user->iseditor()) {
+ if ($this->importart() && $this->canedit()) {
$this->art->hydrate($_POST);
$this->art->hydrate($date);
$this->art->updateedited();
diff --git a/app/class/modeluser.php b/app/class/modeluser.php
index ffe04ed..7ceaecb 100644
--- a/app/class/modeluser.php
+++ b/app/class/modeluser.php
@@ -108,6 +108,20 @@ class Modeluser extends Modeldb
return $userdatalist->total();
}
+ public function getlisterbylevel(int $level)
+ {
+ $userdatalist = $this->repo->query()
+ ->where('level', '==', $level)
+ ->execute();
+
+ $userlist = [];
+ foreach ($userdatalist as $user) {
+ $userlist[] = $user->id;
+ }
+
+ return $userlist;
+ }
+
public function passwordexist(string $pass)
{
$userdatalist = $this->repo->query()