diff options
-rw-r--r-- | app/class/art2.php | 14 | ||||
-rw-r--r-- | app/class/controllerart.php | 10 | ||||
-rw-r--r-- | app/class/modeluser.php | 14 | ||||
-rw-r--r-- | app/view/templates/edit.php | 2 | ||||
-rw-r--r-- | app/view/templates/editrightbar.php | 30 | ||||
-rw-r--r-- | app/view/templates/navart.php | 2 | ||||
-rw-r--r-- | app/view/templates/read.php | 2 |
7 files changed, 66 insertions, 8 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() diff --git a/app/view/templates/edit.php b/app/view/templates/edit.php index 32de517..415fcce 100644 --- a/app/view/templates/edit.php +++ b/app/view/templates/edit.php @@ -20,7 +20,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]) ?> + <?php $this->insert('editrightbar', ['art' => $art, 'artlist' => $artlist, 'showrightpanel' => $showrightpanel, 'templates' => $art->template(), 'tagartlist' => $tagartlist, 'lasteditedartlist' => $lasteditedartlist, 'inviteuserlist' => $inviteuserlist, 'user' => $user]) ?> </div> diff --git a/app/view/templates/editrightbar.php b/app/view/templates/editrightbar.php index 8ee402d..e42cdf1 100644 --- a/app/view/templates/editrightbar.php +++ b/app/view/templates/editrightbar.php @@ -73,7 +73,35 @@ ?> </ul> - + + <?php if($user->level() >= 4) { ?> + + <h3>Invites editors</h3> + + <label for="invites">Invites editors</label> + <select name="invites[]" id="invites"> + <option value="" selected>--select invite user--</option> + <?php + $newinviteuserlist = array_diff($inviteuserlist, $art->invites()); + foreach ($newinviteuserlist as $inviteuser) { + echo '<option value="'.$inviteuser.'" >'.$inviteuser.'</option>'; + } + ?> + </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> </div>
\ No newline at end of file diff --git a/app/view/templates/navart.php b/app/view/templates/navart.php index 9d9f3ed..be3b248 100644 --- a/app/view/templates/navart.php +++ b/app/view/templates/navart.php @@ -89,7 +89,7 @@ <?php } ?> -<?php if($user->iseditor() && $artexist) { ?> +<?php if($canedit && $artexist) { ?> <li class="drop"> <a class="button" href="<?= $this->uart('artread/', $art->id()) ?>" target="_blank">display</a> diff --git a/app/view/templates/read.php b/app/view/templates/read.php index 42fba7b..f8201cc 100644 --- a/app/view/templates/read.php +++ b/app/view/templates/read.php @@ -34,7 +34,7 @@ $this->stop(); <?php if ($readernav) { - $this->insert('navart', ['user' => $user, 'art' => $art, 'artexist' => $artexist]); + $this->insert('navart', ['user' => $user, 'art' => $art, 'artexist' => $artexist, 'canedit' => $canedit]); } ?> |