aboutsummaryrefslogtreecommitdiff
path: root/app/class
diff options
context:
space:
mode:
authorvincent-peugnet <v.peugnet@free.fr>2019-01-30 14:29:05 +0100
committervincent-peugnet <v.peugnet@free.fr>2019-01-30 14:29:05 +0100
commit3309bd722454fa8696ce2415075f401e444c9910 (patch)
treea96f73782faf66c715504de78172328d6347fe57 /app/class
parent5e1ca86211da0439003303cf3e0741edf31bced4 (diff)
downloadwcms-3309bd722454fa8696ce2415075f401e444c9910.tar.gz
wcms-3309bd722454fa8696ce2415075f401e444c9910.zip
author and user management
Diffstat (limited to 'app/class')
-rw-r--r--app/class/controllerart.php10
-rw-r--r--app/class/modeluser.php5
-rw-r--r--app/class/user.php5
3 files changed, 13 insertions, 7 deletions
diff --git a/app/class/controllerart.php b/app/class/controllerart.php
index 2ef3e90..ef720a1 100644
--- a/app/class/controllerart.php
+++ b/app/class/controllerart.php
@@ -50,10 +50,10 @@ class Controllerart extends Controller
public function canedit()
{
- if ($this->user->iseditor()) {
+ if ($this->user->issupereditor()) {
return true;
- } elseif ($this->user->isinvite()) {
- if (in_array($this->user->id(), $this->art->invites())) {
+ } elseif ($this->user->isinvite() || $this->user->iseditor()) {
+ if (in_array($this->user->id(), $this->art->authors())) {
return true;
} else {
return false;
@@ -160,7 +160,7 @@ class Controllerart extends Controller
$tagartlist = $this->artmanager->tagartlist($this->art->tag('array'), $artlist);
$lasteditedartlist = $this->artmanager->lasteditedartlist(5, $artlist);
- $inviteuserlist = $this->usermanager->getlisterbylevel(2);
+ $editorlist = $this->usermanager->getlisterbylevel(2, '>=');
if (isset($_SESSION['workspace'])) {
$showleftpanel = $_SESSION['workspace']['showleftpanel'];
@@ -171,7 +171,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, 'inviteuserlist' => $inviteuserlist]);
+ $this->showtemplate('edit', ['art' => $this->art, 'artexist' => true, 'tablist' => $tablist, 'artlist' => $idlist, 'showleftpanel' => $showleftpanel, 'showrightpanel' => $showrightpanel, 'fonts' => $fonts, 'tagartlist' => $tagartlist, 'lasteditedartlist' => $lasteditedartlist, 'faviconlist' => $faviconlist, 'editorlist' => $editorlist]);
} else {
$this->routedirect('artread/', ['art' => $this->art->id()]);
}
diff --git a/app/class/modeluser.php b/app/class/modeluser.php
index 6e39702..453e503 100644
--- a/app/class/modeluser.php
+++ b/app/class/modeluser.php
@@ -3,6 +3,7 @@
class Modeluser extends Modeldb
{
const ADMIN = 10;
+ const SUPEREDITOR = 4;
const EDITOR = 3;
const INVITE = 2;
const READ = 1;
@@ -91,10 +92,10 @@ class Modeluser extends Modeldb
return $userdatalist->total();
}
- public function getlisterbylevel(int $level)
+ public function getlisterbylevel(int $level, $comp = '==')
{
$userdatalist = $this->repo->query()
- ->where('level', '==', $level)
+ ->where('level', $comp, $level)
->execute();
$userlist = [];
diff --git a/app/class/user.php b/app/class/user.php
index 2e451a9..645f73e 100644
--- a/app/class/user.php
+++ b/app/class/user.php
@@ -169,6 +169,11 @@ class User
return $this->level >= Modeluser::EDITOR;
}
+ public function issupereditor()
+ {
+ return $this->level >= Modeluser::SUPEREDITOR;
+ }
+
public function isinvite()
{
return $this->level >= Modeluser::INVITE;