Skip to content

Commit

Permalink
Move User class to User\User
Browse files Browse the repository at this point in the history
  • Loading branch information
carlbennett committed Dec 1, 2024
1 parent 0f4109e commit 1dd440d
Show file tree
Hide file tree
Showing 59 changed files with 90 additions and 89 deletions.
2 changes: 1 addition & 1 deletion src/Controllers/Comment/Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function __construct()
public function invoke(?array $args): bool
{
$this->model->acl_allowed = $this->model->active_user
&& $this->model->active_user->getOption(\BNETDocs\Libraries\User::OPTION_ACL_COMMENT_CREATE);
&& $this->model->active_user->getOption(\BNETDocs\Libraries\User\User::OPTION_ACL_COMMENT_CREATE);

if (!$this->model->acl_allowed)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Controllers/Comment/Delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function invoke(?array $args): bool
catch (\UnexpectedValueException) { $this->model->comment = null; }

$this->model->acl_allowed = ($this->model->active_user && (
$this->model->active_user->getOption(\BNETDocs\Libraries\User::OPTION_ACL_COMMENT_DELETE) ||
$this->model->active_user->getOption(\BNETDocs\Libraries\User\User::OPTION_ACL_COMMENT_DELETE) ||
($this->model->comment && $this->model->active_user->getId() == $this->model->comment->getUserId())
));

Expand Down
2 changes: 1 addition & 1 deletion src/Controllers/Comment/Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function invoke(?array $args): bool
catch (\UnexpectedValueException) { $this->model->comment = null; }

$this->model->acl_allowed = $this->model->active_user && (
$this->model->active_user->getOption(\BNETDocs\Libraries\User::OPTION_ACL_COMMENT_MODIFY) ||
$this->model->active_user->getOption(\BNETDocs\Libraries\User\User::OPTION_ACL_COMMENT_MODIFY) ||
($this->model->comment && $this->model->active_user->getId() === $this->model->comment->getUserId())
);

Expand Down
2 changes: 1 addition & 1 deletion src/Controllers/Document/Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function __construct()
public function invoke(?array $args): bool
{
$this->model->acl_allowed = $this->model->active_user
&& $this->model->active_user->getOption(\BNETDocs\Libraries\User::OPTION_ACL_DOCUMENT_CREATE);
&& $this->model->active_user->getOption(\BNETDocs\Libraries\User\User::OPTION_ACL_DOCUMENT_CREATE);

if (!$this->model->acl_allowed)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Controllers/Document/Delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function __construct()
public function invoke(?array $args): bool
{
$this->model->acl_allowed = $this->model->active_user
&& $this->model->active_user->getOption(\BNETDocs\Libraries\User::OPTION_ACL_DOCUMENT_DELETE);
&& $this->model->active_user->getOption(\BNETDocs\Libraries\User\User::OPTION_ACL_DOCUMENT_DELETE);

if (!$this->model->acl_allowed)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Controllers/Document/Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function __construct()
public function invoke(?array $args): bool
{
$this->model->acl_allowed = $this->model->active_user
&& $this->model->active_user->getOption(\BNETDocs\Libraries\User::OPTION_ACL_DOCUMENT_MODIFY);
&& $this->model->active_user->getOption(\BNETDocs\Libraries\User\User::OPTION_ACL_DOCUMENT_MODIFY);

if (!$this->model->acl_allowed)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Controllers/EventLog/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function __construct()
public function invoke(?array $args): bool
{
$this->model->acl_allowed = $this->model->active_user
&& $this->model->active_user->getOption(\BNETDocs\Libraries\User::OPTION_ACL_EVENT_LOG_VIEW);
&& $this->model->active_user->getOption(\BNETDocs\Libraries\User\User::OPTION_ACL_EVENT_LOG_VIEW);

if (!$this->model->acl_allowed)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Controllers/EventLog/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function __construct()
public function invoke(?array $args): bool
{
$this->model->acl_allowed = $this->model->active_user
&& $this->model->active_user->getOption(\BNETDocs\Libraries\User::OPTION_ACL_EVENT_LOG_VIEW);
&& $this->model->active_user->getOption(\BNETDocs\Libraries\User\User::OPTION_ACL_EVENT_LOG_VIEW);

if (!$this->model->acl_allowed)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Controllers/News.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace BNETDocs\Controllers;

use \BNETDocs\Libraries\User;
use \BNETDocs\Libraries\User\User;

class News extends Base
{
Expand Down
2 changes: 1 addition & 1 deletion src/Controllers/News/Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function __construct()
public function invoke(?array $args): bool
{
$this->model->acl_allowed = $this->model->active_user
&& $this->model->active_user->getOption(\BNETDocs\Libraries\User::OPTION_ACL_NEWS_CREATE);
&& $this->model->active_user->getOption(\BNETDocs\Libraries\User\User::OPTION_ACL_NEWS_CREATE);

if (!$this->model->acl_allowed)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Controllers/News/Delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function __construct()
public function invoke(?array $args): bool
{
$this->model->acl_allowed = $this->model->active_user
&& $this->model->active_user->getOption(\BNETDocs\Libraries\User::OPTION_ACL_NEWS_DELETE);
&& $this->model->active_user->getOption(\BNETDocs\Libraries\User\User::OPTION_ACL_NEWS_DELETE);

if (!$this->model->acl_allowed)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Controllers/News/Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function __construct()
public function invoke(?array $args): bool
{
$this->model->acl_allowed = $this->model->active_user
&& $this->model->active_user->getOption(\BNETDocs\Libraries\User::OPTION_ACL_NEWS_MODIFY);
&& $this->model->active_user->getOption(\BNETDocs\Libraries\User\User::OPTION_ACL_NEWS_MODIFY);

if (!$this->model->acl_allowed)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Controllers/News/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use \BNETDocs\Libraries\Comment;
use \BNETDocs\Libraries\Core\HttpCode;
use \BNETDocs\Libraries\News\Post as NewsPost;
use \BNETDocs\Libraries\User;
use \BNETDocs\Libraries\User\User;

class View extends \BNETDocs\Controllers\Base
{
Expand Down
2 changes: 1 addition & 1 deletion src/Controllers/Packet/Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function __construct()

public function invoke(?array $args): bool
{
if (!$this->model->active_user || !$this->model->active_user->getOption(\BNETDocs\Libraries\User::OPTION_ACL_PACKET_CREATE))
if (!$this->model->active_user || !$this->model->active_user->getOption(\BNETDocs\Libraries\User\User::OPTION_ACL_PACKET_CREATE))
{
$this->model->_responseCode = HttpCode::HTTP_UNAUTHORIZED;
$this->model->error = FormModel::ERROR_ACL_DENIED;
Expand Down
2 changes: 1 addition & 1 deletion src/Controllers/Packet/Delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function __construct()
public function invoke(?array $args): bool
{
$this->model->acl_allowed = $this->model->active_user
&& $this->model->active_user->getOption(\BNETDocs\Libraries\User::OPTION_ACL_PACKET_DELETE);
&& $this->model->active_user->getOption(\BNETDocs\Libraries\User\User::OPTION_ACL_PACKET_DELETE);

if (!$this->model->acl_allowed)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Controllers/Packet/Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function __construct()

public function invoke(?array $args): bool
{
if (!$this->model->active_user || !$this->model->active_user->getOption(\BNETDocs\Libraries\User::OPTION_ACL_PACKET_MODIFY))
if (!$this->model->active_user || !$this->model->active_user->getOption(\BNETDocs\Libraries\User\User::OPTION_ACL_PACKET_MODIFY))
{
$this->model->error = FormModel::ERROR_ACL_DENIED;
$this->model->_responseCode = HttpCode::HTTP_UNAUTHORIZED;
Expand Down
2 changes: 1 addition & 1 deletion src/Controllers/PhpInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function __construct()
*/
public function invoke(?array $args): bool
{
if (!($this->model->active_user && $this->model->active_user->getOption(\BNETDocs\Libraries\User::OPTION_ACL_PHPINFO)))
if (!($this->model->active_user && $this->model->active_user->getOption(\BNETDocs\Libraries\User\User::OPTION_ACL_PHPINFO)))
{
$this->model->phpinfo = null;
$this->model->_responseCode = HttpCode::HTTP_UNAUTHORIZED;
Expand Down
2 changes: 1 addition & 1 deletion src/Controllers/Server/Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function invoke(?array $args): bool
{
$this->model->server_edit = false;

if (!($this->model->active_user && $this->model->active_user->getOption(\BNETDocs\Libraries\User::OPTION_ACL_SERVER_CREATE)))
if (!($this->model->active_user && $this->model->active_user->getOption(\BNETDocs\Libraries\User\User::OPTION_ACL_SERVER_CREATE)))
{
$this->model->_responseCode = HttpCode::HTTP_FORBIDDEN;
$this->model->error = FormModel::ERROR_ACCESS_DENIED;
Expand Down
2 changes: 1 addition & 1 deletion src/Controllers/Server/Delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function __construct()

public function invoke(?array $args): bool
{
if (!($this->model->active_user && $this->model->active_user->getOption(\BNETDocs\Libraries\User::OPTION_ACL_SERVER_DELETE)))
if (!($this->model->active_user && $this->model->active_user->getOption(\BNETDocs\Libraries\User\User::OPTION_ACL_SERVER_DELETE)))
{
$this->model->_responseCode = HttpCode::HTTP_FORBIDDEN;
$this->model->error = DeleteModel::ERROR_ACCESS_DENIED;
Expand Down
2 changes: 1 addition & 1 deletion src/Controllers/Server/Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function invoke(?array $args): bool
{
$this->model->server_edit = true;

if (!($this->model->active_user && $this->model->active_user->getOption(\BNETDocs\Libraries\User::OPTION_ACL_SERVER_MODIFY)))
if (!($this->model->active_user && $this->model->active_user->getOption(\BNETDocs\Libraries\User\User::OPTION_ACL_SERVER_MODIFY)))
{
$this->model->_responseCode = HttpCode::HTTP_FORBIDDEN;
$this->model->error = FormModel::ERROR_ACCESS_DENIED;
Expand Down
2 changes: 1 addition & 1 deletion src/Controllers/User/CreatePassword.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function invoke(?array $args): bool
$q = \BNETDocs\Libraries\Core\Router::query();
$this->model->_responseCode = \BNETDocs\Libraries\Core\HttpCode::HTTP_OK;
$this->model->input = $q['input'] ?? null;
$this->model->output = empty($this->model->input) ? null : \BNETDocs\Libraries\User::createPassword($this->model->input);
$this->model->output = empty($this->model->input) ? null : \BNETDocs\Libraries\User\User::createPassword($this->model->input);
return true;
}
}
3 changes: 2 additions & 1 deletion src/Controllers/User/Index.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?php

namespace BNETDocs\Controllers\User;

use \BNETDocs\Libraries\User;
use \BNETDocs\Libraries\User\User;

class Index extends \BNETDocs\Controllers\Base
{
Expand Down
2 changes: 1 addition & 1 deletion src/Controllers/User/Login.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use \BNETDocs\Libraries\Core\HttpCode;
use \BNETDocs\Libraries\Core\Router;
use \BNETDocs\Libraries\EventLog\Logger;
use \BNETDocs\Libraries\User;
use \BNETDocs\Libraries\User\User;
use \BNETDocs\Models\User\Login as LoginModel;
use \CarlBennett\MVC\Libraries\Common;

Expand Down
2 changes: 1 addition & 1 deletion src/Controllers/User/Register.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use \BNETDocs\Libraries\Core\Template;
use \BNETDocs\Libraries\EventLog\EventTypes;
use \BNETDocs\Libraries\EventLog\Logger;
use \BNETDocs\Libraries\User;
use \BNETDocs\Libraries\User\User;
use \CarlBennett\MVC\Libraries\Common;
use \PHPMailer\PHPMailer\PHPMailer;

Expand Down
2 changes: 1 addition & 1 deletion src/Controllers/User/ResetPassword.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use \BNETDocs\Libraries\Core\Template;
use \BNETDocs\Libraries\EventLog\EventTypes;
use \BNETDocs\Libraries\EventLog\Logger;
use \BNETDocs\Libraries\User;
use \BNETDocs\Libraries\User\User;
use \BNETDocs\Models\User\ResetPassword as ResetPasswordModel;
use \CarlBennett\MVC\Libraries\Common;
use \PHPMailer\PHPMailer\PHPMailer;
Expand Down
2 changes: 1 addition & 1 deletion src/Controllers/User/Update.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use \BNETDocs\Libraries\Core\Router;
use \BNETDocs\Libraries\EventLog\Logger;
use \BNETDocs\Libraries\User;
use \BNETDocs\Libraries\User\User;
use \CarlBennett\MVC\Libraries\Common;
use \Throwable;
use \UnexpectedValueException;
Expand Down
2 changes: 1 addition & 1 deletion src/Controllers/User/Verify.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function invoke(?array $args): bool

if (is_numeric($this->model->user_id))
{
try { $this->model->user = new \BNETDocs\Libraries\User((int) $this->model->user_id); }
try { $this->model->user = new \BNETDocs\Libraries\User\User((int) $this->model->user_id); }
catch (\UnexpectedValueException) { $this->model->user = null; }
}

Expand Down
2 changes: 1 addition & 1 deletion src/Controllers/User/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use \BNETDocs\Libraries\Document;
use \BNETDocs\Libraries\Packet\Packet;
use \BNETDocs\Libraries\Server\Server;
use \BNETDocs\Libraries\User;
use \BNETDocs\Libraries\User\User;

class View extends \BNETDocs\Controllers\Base
{
Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/UserNotFoundException.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class UserNotFoundException extends DatabaseObjectNotFoundException
{
public function __construct(\BNETDocs\Libraries\User|int $value, \Throwable $previous = null)
public function __construct(\BNETDocs\Libraries\User\User|int $value, \Throwable $previous = null)
{
$v = is_int($value) ? $value : $value->getId();
parent::__construct(\sprintf('User not found: %d', $v), 0, $previous);
Expand Down
2 changes: 1 addition & 1 deletion src/Libraries/Comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use \BNETDocs\Libraries\Core\DateTimeImmutable;
use \BNETDocs\Libraries\Db\MariaDb;
use \BNETDocs\Libraries\EventLog\EventTypes;
use \BNETDocs\Libraries\User;
use \BNETDocs\Libraries\User\User;
use \CarlBennett\MVC\Libraries\Common;
use \DateTimeInterface;
use \DateTimeZone;
Expand Down
2 changes: 1 addition & 1 deletion src/Libraries/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use \BNETDocs\Libraries\Core\DateTimeImmutable;
use \BNETDocs\Libraries\Db\MariaDb;
use \BNETDocs\Libraries\User;
use \BNETDocs\Libraries\User\User;
use \CarlBennett\MVC\Libraries\Common;
use \DateTimeInterface;
use \DateTimeZone;
Expand Down
2 changes: 1 addition & 1 deletion src/Libraries/EventLog/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use \BNETDocs\Libraries\Core\DateTimeImmutable;
use \BNETDocs\Libraries\Db\MariaDb;
use \BNETDocs\Libraries\EventLog\EventTypes;
use \BNETDocs\Libraries\User;
use \BNETDocs\Libraries\User\User;
use \DateTimeInterface;
use \DateTimeZone;
use \LengthException;
Expand Down
2 changes: 1 addition & 1 deletion src/Libraries/EventLog/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use \BNETDocs\Libraries\Discord\Embed as DiscordEmbed;
use \BNETDocs\Libraries\Discord\Webhook as DiscordWebhook;
use \BNETDocs\Libraries\EventLog\Event;
use \BNETDocs\Libraries\User;
use \BNETDocs\Libraries\User\User;
use \CarlBennett\MVC\Libraries\Common;

class Logger
Expand Down
2 changes: 1 addition & 1 deletion src/Libraries/News/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use \BNETDocs\Libraries\Core\DateTimeImmutable;
use \BNETDocs\Libraries\Db\MariaDb;
use \BNETDocs\Libraries\News\Category as NewsCategory;
use \BNETDocs\Libraries\User;
use \BNETDocs\Libraries\User\User;
use \CarlBennett\MVC\Libraries\Common;
use \DateTimeInterface;
use \DateTimeZone;
Expand Down
2 changes: 1 addition & 1 deletion src/Libraries/Packet/Packet.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use \BNETDocs\Libraries\Packet\Application as ApplicationLayer;
use \BNETDocs\Libraries\Packet\Transport as TransportLayer;
use \BNETDocs\Libraries\Product;
use \BNETDocs\Libraries\User;
use \BNETDocs\Libraries\User\User;
use \CarlBennett\MVC\Libraries\Common;
use \DateTimeInterface;
use \DateTimeZone;
Expand Down
2 changes: 1 addition & 1 deletion src/Libraries/Server/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use \BNETDocs\Libraries\Core\DateTimeImmutable;
use \BNETDocs\Libraries\Db\MariaDb;
use \BNETDocs\Libraries\Server\Type as ServerType;
use \BNETDocs\Libraries\User;
use \BNETDocs\Libraries\User\User;
use \CarlBennett\MVC\Libraries\Common;
use \DateTimeInterface;
use \DateTimeZone;
Expand Down
2 changes: 1 addition & 1 deletion src/Libraries/User/Authentication.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use \BNETDocs\Interfaces\DatabaseObject;
use \BNETDocs\Libraries\Core\DateTimeImmutable;
use \BNETDocs\Libraries\Db\MariaDb;
use \BNETDocs\Libraries\User;
use \BNETDocs\Libraries\User\User;
use \CarlBennett\MVC\Libraries\Common;
use \DateTimeZone;
use \InvalidArgumentException;
Expand Down
2 changes: 1 addition & 1 deletion src/Libraries/User/Profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace BNETDocs\Libraries\User;

use \BNETDocs\Libraries\Db\MariaDb;
use \BNETDocs\Libraries\User;
use \BNETDocs\Libraries\User\User;
use \StdClass;
use \UnexpectedValueException;

Expand Down
2 changes: 1 addition & 1 deletion src/Libraries/User.php → src/Libraries/User/User.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php /* vim: set colorcolumn= expandtab shiftwidth=2 softtabstop=2 tabstop=4 smarttab: */

namespace BNETDocs\Libraries;
namespace BNETDocs\Libraries\User;

use \BNETDocs\Libraries\Core\DateTimeImmutable;
use \BNETDocs\Libraries\Db\MariaDb;
Expand Down
2 changes: 1 addition & 1 deletion src/Models/ActiveUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class ActiveUser extends Errorable implements \JsonSerializable
*
* @var \BNETDocs\Libraries\User|null
*/
public ?\BNETDocs\Libraries\User $active_user = null;
public ?\BNETDocs\Libraries\User\User $active_user = null;

/**
* When constructed, sets the $active_user to that of the Authentication::$user value.
Expand Down
4 changes: 2 additions & 2 deletions src/Models/Email/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

abstract class Base implements \BNETDocs\Interfaces\Model
{
public ?\BNETDocs\Libraries\User $active_user;
public $mail;
public ?\BNETDocs\Libraries\User\User $active_user;
public $mail;
}
10 changes: 5 additions & 5 deletions src/Models/News/Delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

class Delete extends \BNETDocs\Models\ActiveUser
{
public bool $acl_allowed = false;
public ?int $id = null;
public ?\BNETDocs\Libraries\News\Post $news_post = null;
public string $title = '';
public ?\BNETDocs\Libraries\User $user = null;
public bool $acl_allowed = false;
public ?int $id = null;
public ?\BNETDocs\Libraries\News\Post $news_post = null;
public string $title = '';
public ?\BNETDocs\Libraries\User\User $user = null;
}
Loading

0 comments on commit 1dd440d

Please sign in to comment.