From 9564a330b1d7c1131e91ddeeed946292f4a75e9f Mon Sep 17 00:00:00 2001 From: DariusIII Date: Tue, 26 Dec 2017 00:04:11 +0100 Subject: [PATCH] Fix some more references to old Users class --- nntmux/Contents.php | 15 ++++++++------- nntmux/Menu.php | 9 +++++---- public/admin/content-add.php | 3 ++- public/pages/AdminPage.php | 4 ++-- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/nntmux/Contents.php b/nntmux/Contents.php index 59155e15b..7f0bd19b5 100755 --- a/nntmux/Contents.php +++ b/nntmux/Contents.php @@ -2,17 +2,18 @@ namespace nntmux; +use App\Models\User; use nntmux\db\DB; use App\Models\Content; class Contents { - const TYPEUSEFUL = 1; - const TYPEARTICLE = 2; - const TYPEINDEX = 3; + protected const TYPEUSEFUL = 1; + protected const TYPEARTICLE = 2; + protected const TYPEINDEX = 3; /** - * @var DB + * @var \nntmux\db\DB */ public $pdo; @@ -165,7 +166,7 @@ class Contents $content->url = '/'.$content->url; } - if (substr($content->url, strlen($content->url) - 1) !== '/') { + if (substr($content->url, \strlen($content->url) - 1) !== '/') { $content->url .= '/'; } @@ -331,7 +332,7 @@ class Contents */ public function data_getByID($id, $role) { - if ($role === Users::ROLE_ADMIN) { + if ($role === User::ROLE_ADMIN) { $role = ''; } else { $role = sprintf('AND (role = %d OR role = 0)', $role); @@ -378,7 +379,7 @@ class Contents */ public function data_getForMenuByTypeAndRole($id, $role): array { - if ($role === Users::ROLE_ADMIN) { + if ($role === User::ROLE_ADMIN) { $role = ''; } else { $role = sprintf('AND (role = %d OR role = 0)', $role); diff --git a/nntmux/Menu.php b/nntmux/Menu.php index 257a5bfcc..89214697d 100755 --- a/nntmux/Menu.php +++ b/nntmux/Menu.php @@ -2,6 +2,7 @@ namespace nntmux; +use App\Models\User; use nntmux\db\DB; /** @@ -31,12 +32,12 @@ class Menu public function get($role, $serverurl) { $guest = ''; - if ($role !== Users::ROLE_GUEST) { - $guest = sprintf(' AND role != %d ', Users::ROLE_GUEST); + if ($role !== User::ROLE_GUEST) { + $guest = sprintf(' AND role != %d ', User::ROLE_GUEST); } - if ($role !== Users::ROLE_ADMIN) { - $guest .= sprintf(' AND role != %d ', Users::ROLE_ADMIN); + if ($role !== User::ROLE_ADMIN) { + $guest .= sprintf(' AND role != %d ', User::ROLE_ADMIN); } $data = $this->pdo->query(sprintf('SELECT * FROM menu WHERE role <= %d %s ORDER BY ordinal', $role, $guest)); diff --git a/public/admin/content-add.php b/public/admin/content-add.php index e90adbe80..3295abace 100644 --- a/public/admin/content-add.php +++ b/public/admin/content-add.php @@ -2,6 +2,7 @@ require_once dirname(__DIR__).DIRECTORY_SEPARATOR.'smarty.php'; +use App\Models\User; use nntmux\Users; use nntmux\Contents; @@ -53,7 +54,7 @@ switch ($action) { $page->title = 'Content Edit'; $id = $_GET['id']; - $content = $contents->getByID($id, Users::ROLE_ADMIN); + $content = $contents->getByID($id, User::ROLE_ADMIN); } break; } diff --git a/public/pages/AdminPage.php b/public/pages/AdminPage.php index 9bd723a4b..282428092 100644 --- a/public/pages/AdminPage.php +++ b/public/pages/AdminPage.php @@ -1,6 +1,6 @@ userdata['user_roles_id']) || (int) $this->userdata['user_roles_id'] !== Users::ROLE_ADMIN || ! $this->users->isLoggedIn()) { + if (! isset($this->userdata['user_roles_id']) || (int) $this->userdata['user_roles_id'] !== User::ROLE_ADMIN || ! $this->users->isLoggedIn()) { $this->show403(true); }