diff options
author | vincent-peugnet <v.peugnet@free.fr> | 2019-01-30 14:29:05 +0100 |
---|---|---|
committer | vincent-peugnet <v.peugnet@free.fr> | 2019-01-30 14:29:05 +0100 |
commit | 3309bd722454fa8696ce2415075f401e444c9910 (patch) | |
tree | a96f73782faf66c715504de78172328d6347fe57 /app | |
parent | 5e1ca86211da0439003303cf3e0741edf31bced4 (diff) | |
download | wcms-3309bd722454fa8696ce2415075f401e444c9910.tar.gz wcms-3309bd722454fa8696ce2415075f401e444c9910.zip |
author and user management
Diffstat (limited to 'app')
-rw-r--r-- | app/class/controllerart.php | 10 | ||||
-rw-r--r-- | app/class/modeluser.php | 5 | ||||
-rw-r--r-- | app/class/user.php | 5 | ||||
-rw-r--r-- | app/view/templates/edit.php | 2 | ||||
-rw-r--r-- | app/view/templates/editrightbar.php | 53 | ||||
-rw-r--r-- | app/view/templates/navart.php | 2 |
6 files changed, 39 insertions, 38 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; diff --git a/app/view/templates/edit.php b/app/view/templates/edit.php index e01846e..7c6610a 100644 --- a/app/view/templates/edit.php +++ b/app/view/templates/edit.php @@ -16,7 +16,7 @@ <?php $this->insert('editleftbar', ['art' => $art, 'tablist' => $tablist, 'artlist' => $artlist, 'showleftpanel' => $showleftpanel, 'faviconlist' => $faviconlist]) ?> <?php $this->insert('edittabs', ['tablist' => $tablist, 'opentab' => $art->interface(), 'templates' => $art->template()]) ?> - <?php $this->insert('editrightbar', ['art' => $art, 'artlist' => $artlist, 'showrightpanel' => $showrightpanel, 'templates' => $art->template(), 'tagartlist' => $tagartlist, 'lasteditedartlist' => $lasteditedartlist, 'inviteuserlist' => $inviteuserlist, 'user' => $user]) ?> + <?php $this->insert('editrightbar', ['art' => $art, 'artlist' => $artlist, 'showrightpanel' => $showrightpanel, 'templates' => $art->template(), 'tagartlist' => $tagartlist, 'lasteditedartlist' => $lasteditedartlist, 'editorlist' => $editorlist, 'user' => $user]) ?> </div> diff --git a/app/view/templates/editrightbar.php b/app/view/templates/editrightbar.php index a081aac..15cef7f 100644 --- a/app/view/templates/editrightbar.php +++ b/app/view/templates/editrightbar.php @@ -65,42 +65,37 @@ </details> <h3>Authors</h3> - <ul> - <?php - foreach ($art->authors() as $author) { - echo '<li>⬖ ' . $author .'</li>'; - } - - ?> - </ul> + <?php if($user->level() >= 4) { ?> - <h3>Invites editors</h3> - <label for="invites">Invites editors</label> - <select name="invites[]" id="invites"> - <option value="" selected>--add invite user--</option> - <?php - $newinviteuserlist = array_diff($inviteuserlist, $art->invites()); - foreach ($newinviteuserlist as $inviteuser) { - echo '<option value="'.$inviteuser.'" >'.$inviteuser.'</option>'; + <label for="authors">Invites editors</label> + <select name="authors[]" id="authors"> + <option value="" selected>--add author--</option> + <?php + $notyetauthorlist = array_diff($editorlist, $art->authors()); + foreach ($notyetauthorlist as $author) { + echo '<option value="'.$author.'" >'.$author.'</option>'; + } + } + ?> + + </select> + <?php + $alreadyauthorlist = array_intersect($editorlist, $art->authors()); + foreach ($alreadyauthorlist as $author) { + ?> + <div class="checkexternal"> + <?php if($user->level() >= 4) { ?> + <input type="checkbox" name="authors[]" id="<?= $author ?>" value="<?= $author ?>" checked> + <?php } ?> + <label for="<?= $author ?>" >⬗ <?= $author ?></label> + </div> + <?php } - ?> - </select> - <?php - $validateinviteusers = array_intersect($inviteuserlist, $art->invites()); - foreach ($validateinviteusers as $invite) { - ?> - <div class="checkexternal"> - <input type="checkbox" name="invites[]" id="<?= $invite ?>" value="<?= $invite ?>" checked> - <label for="<?= $invite ?>" >⬗ <?= $invite ?></label> - </div> - <?php - } ?> - <?php } ?> </div> diff --git a/app/view/templates/navart.php b/app/view/templates/navart.php index 1e6b551..0e690c2 100644 --- a/app/view/templates/navart.php +++ b/app/view/templates/navart.php @@ -60,7 +60,7 @@ <ul> <li class="drop"> - <span class="button" style="font-family: monospace; background-color: #7b97b9;" >User lvl : <?= $user->level() ?></span> + <span class="button" style="font-family: monospace; background-color: #7b97b9;" ><?= $user->id() ?> (<?= $user->level() ?>)</span> </li> <li class="drop"> <a class="button" href="<?= $this->url('home') ?>">home</a> |