mirror of
https://github.com/YGGverse/YGGtracker.git
synced 2026-04-01 09:35:28 +00:00
update user profile module dependencies
This commit is contained in:
parent
86587db9e9
commit
c05abad02f
5 changed files with 150 additions and 39 deletions
|
|
@ -2,19 +2,103 @@
|
|||
|
||||
class AppControllerIndex
|
||||
{
|
||||
private $_user;
|
||||
private $_database;
|
||||
private $_validator;
|
||||
private $_website;
|
||||
private $_session;
|
||||
|
||||
public function __construct()
|
||||
public function __construct(
|
||||
AppModelDatabase $database,
|
||||
AppModelValidator $validator,
|
||||
AppModelWebsite $website,
|
||||
AppModelSession $session
|
||||
)
|
||||
{
|
||||
require_once __DIR__ . '/user.php';
|
||||
$this->_database = $database;
|
||||
$this->_validator = $validator;
|
||||
$this->_website = $website;
|
||||
$this->_session = $session;
|
||||
}
|
||||
|
||||
$this->_user = new AppControllerUser(
|
||||
$_SERVER['REMOTE_ADDR']
|
||||
);
|
||||
private function _initUser(string $address)
|
||||
{
|
||||
$error = [];
|
||||
if (!$this->_validator->host($address, $error))
|
||||
{
|
||||
$this->_response(
|
||||
sprintf(
|
||||
_('Error - %s'),
|
||||
$this->_website->getName()
|
||||
),
|
||||
_('406'),
|
||||
$error,
|
||||
406
|
||||
);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$this->_database->beginTransaction();
|
||||
|
||||
$user = $this->_database->getUser(
|
||||
$this->_database->initUserId(
|
||||
$address,
|
||||
$this->_website->getDefaultUserStatus(),
|
||||
$this->_website->getDefaultUserApproved(),
|
||||
time()
|
||||
)
|
||||
);
|
||||
|
||||
$this->_database->commit();
|
||||
}
|
||||
|
||||
catch (Exception $error)
|
||||
{
|
||||
$this->_database->rollback();
|
||||
|
||||
$this->_response(
|
||||
sprintf(
|
||||
_('Error - %s'),
|
||||
$this->_website->getName()
|
||||
),
|
||||
_('500'),
|
||||
$error,
|
||||
500
|
||||
);
|
||||
}
|
||||
|
||||
// Access denied
|
||||
if (!$user->status)
|
||||
{
|
||||
$this->_response(
|
||||
sprintf(
|
||||
_('Error - %s'),
|
||||
$this->_website->getName()
|
||||
),
|
||||
_('403'),
|
||||
_('Access denied'),
|
||||
403
|
||||
);
|
||||
}
|
||||
|
||||
// Require account type selection
|
||||
if (is_null($user->public))
|
||||
{
|
||||
header(
|
||||
sprintf(
|
||||
'Location: %s/welcome',
|
||||
trim($this->_website->getUrl(), '/')
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
$user = $this->_initUser(
|
||||
$this->_session->getAddress()
|
||||
);
|
||||
|
||||
$page = isset($_GET['page']) ? (int) $_GET['page'] : 1;
|
||||
|
||||
$pages = [];
|
||||
|
|
@ -26,16 +110,16 @@ class AppControllerIndex
|
|||
require_once __DIR__ . '/module/head.php';
|
||||
|
||||
$appControllerModuleHead = new AppControllerModuleHead(
|
||||
Environment::config('website')->url,
|
||||
$this->_website->getUrl(),
|
||||
$page > 1 ?
|
||||
sprintf(
|
||||
_('Page %s - BitTorrent Registry for Yggdrasil - %s'),
|
||||
$page,
|
||||
Environment::config('website')->name
|
||||
$this->_website->getName()
|
||||
) :
|
||||
sprintf(
|
||||
_('%s - BitTorrent Registry for Yggdrasil'),
|
||||
Environment::config('website')->name
|
||||
$this->_website->getName()
|
||||
),
|
||||
[
|
||||
[
|
||||
|
|
@ -60,7 +144,9 @@ class AppControllerIndex
|
|||
require_once __DIR__ . '/module/profile.php';
|
||||
|
||||
$appControllerModuleProfile = new AppControllerModuleProfile(
|
||||
$this->_user
|
||||
$this->_database,
|
||||
$this->_website,
|
||||
$this->_session
|
||||
);
|
||||
|
||||
require_once __DIR__ . '/module/header.php';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue