профиль пользака
This commit is contained in:
1 parent
a2fe36227b
commit
0b31f06efb
5 files changed
+58
-34
No files matched your search
@@ -197,7 +197,14 @@
|
|||||||
<div class="leftpanel">
|
<div class="leftpanel">
|
||||||
<div class="media profile-left">
|
<div class="media profile-left">
|
||||||
<a class="pull-left profile-thumb" href="profile.php">
|
<a class="pull-left profile-thumb" href="profile.php">
|
||||||
<img class="img-circle" src="<?=$arUser['image']; ?>" alt="">
|
<img class="img-circle" src="<?php
|
||||||
|
$image = $USER->getImage();
|
||||||
|
if (!empty($image)) {
|
||||||
|
echo $image['path'];
|
||||||
|
} else {
|
||||||
|
echo '/uploads/users/system.png';
|
||||||
|
}
|
||||||
|
?>" alt="">
|
||||||
</a>
|
</a>
|
||||||
<div class="media-body">
|
<div class="media-body">
|
||||||
<h4 class="media-heading"><?=$arUser['name']; ?></h4>
|
<h4 class="media-heading"><?=$arUser['name']; ?></h4>
|
||||||
|
|||||||
+6
-2
@@ -5,7 +5,7 @@
|
|||||||
require_once __DIR__ . '/inc/header.php';
|
require_once __DIR__ . '/inc/header.php';
|
||||||
|
|
||||||
use Core\Models\File;
|
use Core\Models\File;
|
||||||
|
use Core\Helpers\Thumbs;
|
||||||
global $USER;
|
global $USER;
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@@ -33,7 +33,11 @@
|
|||||||
if (isset($_FILES['image']) && $_FILES['image']['error'] === UPLOAD_ERR_OK) {
|
if (isset($_FILES['image']) && $_FILES['image']['error'] === UPLOAD_ERR_OK) {
|
||||||
$File = new File();
|
$File = new File();
|
||||||
$File->saveFile($_FILES['image']['tmp_name'], $_FILES['image']['name'], true);
|
$File->saveFile($_FILES['image']['tmp_name'], $_FILES['image']['name'], true);
|
||||||
$newUserFields['image'] = $File->getPath();
|
$newUserFields['image_id'] = $File->getId();
|
||||||
|
|
||||||
|
$image = new Thumbs($_SERVER['DOCUMENT_ROOT'] . $File->getPath());
|
||||||
|
$image->thumb(300, 300);
|
||||||
|
$image->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
$USER->update($newUserFields);
|
$USER->update($newUserFields);
|
||||||
|
|||||||
+21
-15
@@ -1,8 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Core\Models\User;
|
use Core\Models\User;
|
||||||
|
|
||||||
require_once __DIR__ . '/inc/header.php';
|
require_once __DIR__ . '/inc/header.php';
|
||||||
?>
|
?>
|
||||||
<div class="pageheader">
|
<div class="pageheader">
|
||||||
<div class="media">
|
<div class="media">
|
||||||
<div class="pageicon pull-left">
|
<div class="pageicon pull-left">
|
||||||
@@ -19,7 +20,7 @@
|
|||||||
</div><!-- pageheader -->
|
</div><!-- pageheader -->
|
||||||
|
|
||||||
<div class="contentpanel">
|
<div class="contentpanel">
|
||||||
<!-- table -->
|
<!-- table -->
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12r">
|
<div class="col-md-12r">
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
@@ -42,27 +43,32 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
<?php
|
<?php
|
||||||
$arUsers = User::getUsers();
|
$arUsers = User::getUsers();
|
||||||
foreach($arUsers as $elUser){
|
foreach ($arUsers as $elUser) {
|
||||||
$userObject = new User($elUser['id']);
|
$userObject = new User($elUser['id']);
|
||||||
?>
|
?>
|
||||||
<tr>
|
<tr>
|
||||||
<td><?=$elUser['id'];?></td>
|
<td><?= $elUser['id']; ?></td>
|
||||||
<td><?=$elUser['login'];?></td>
|
<td><?= $elUser['login']; ?></td>
|
||||||
<td><?=$elUser['password'];?></td>
|
<td><?= $elUser['password']; ?></td>
|
||||||
<td><?=$elUser['name'];?></td>
|
<td><?= $elUser['name']; ?></td>
|
||||||
<td><?=$elUser['email'];?></td>
|
<td><?= $elUser['email']; ?></td>
|
||||||
<td><?=$elUser['image'] ? '<img src="'.$elUser['image'].'" width="50px">' : ''; ?></td>
|
<td><?php
|
||||||
|
$image = $userObject->getImage();
|
||||||
|
if (!empty($image)) {
|
||||||
|
echo '<img src="' . $image['path'] . '" alt="' . $image['name'] . '" width="50px">';
|
||||||
|
}
|
||||||
|
?></td>
|
||||||
<td><?php
|
<td><?php
|
||||||
$arRoles = [];
|
$arRoles = [];
|
||||||
foreach($userObject->getRolesObject()->getFullRoles() as $userRole) {
|
foreach ($userObject->getRolesObject()->getFullRoles() as $userRole) {
|
||||||
$arRoles[] = $userRole['name'] . ' (' . $userRole['id'] . ')';
|
$arRoles[] = $userRole['name'] . ' (' . $userRole['id'] . ')';
|
||||||
}
|
}
|
||||||
echo implode(', ', $arRoles);
|
echo implode(', ', $arRoles);
|
||||||
?></td>
|
?></td>
|
||||||
<td><?=$elUser['token'];?></td>
|
<td><?= $elUser['token']; ?></td>
|
||||||
<td><?=date('d.m.Y H:i:s', $elUser['last_active']);?></td>
|
<td><?= date('d.m.Y H:i:s', $elUser['last_active']); ?></td>
|
||||||
<td><?=$elUser['date_created'] ? date('d.m.Y H:i:s', strtotime($elUser['date_created'])) : '-';?></td>
|
<td><?= $elUser['date_created'] ? date('d.m.Y H:i:s', strtotime($elUser['date_created'])) : '-'; ?></td>
|
||||||
<td><?=$elUser['date_updated'] ? date('d.m.Y H:i:s', strtotime($elUser['date_updated'])) : '-';?></td>
|
<td><?= $elUser['date_updated'] ? date('d.m.Y H:i:s', strtotime($elUser['date_updated'])) : '-'; ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
@@ -72,6 +78,6 @@
|
|||||||
</div><!-- table-responsive -->
|
</div><!-- table-responsive -->
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- end table -->
|
<!-- end table -->
|
||||||
</div><!-- contentpanel -->
|
</div><!-- contentpanel -->
|
||||||
<?php require_once __DIR__ . '/inc/footer.php'; ?>
|
<?php require_once __DIR__ . '/inc/footer.php'; ?>
|
||||||
@@ -135,13 +135,11 @@
|
|||||||
/**
|
/**
|
||||||
* Получение файла по идентификатору
|
* Получение файла по идентификатору
|
||||||
*
|
*
|
||||||
* @param int $id Идентификатор
|
|
||||||
*
|
|
||||||
* @return array|null
|
* @return array|null
|
||||||
*/
|
*/
|
||||||
public function getById(int $id): ?array
|
public function getAllProps(): ?array
|
||||||
{
|
{
|
||||||
return $this->DB->query('SELECT * FROM ' . self::TABLE . ' WHERE id="' . $id . '"');
|
return $this->DB->query('SELECT * FROM ' . self::TABLE . ' WHERE id="' . $this->id . '"')[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -154,7 +152,6 @@
|
|||||||
{
|
{
|
||||||
$this->DB->update(self::TABLE, ['id' => $this->id], ['name' => $this->name, 'path' => $this->path]);
|
$this->DB->update(self::TABLE, ['id' => $this->id], ['name' => $this->name, 'path' => $this->path]);
|
||||||
return $this;
|
return $this;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -178,7 +175,7 @@
|
|||||||
}
|
}
|
||||||
$storageFullPath = $this->folder . '/' . $storageFileName;
|
$storageFullPath = $this->folder . '/' . $storageFileName;
|
||||||
|
|
||||||
if($useMove) {
|
if ($useMove) {
|
||||||
if (!move_uploaded_file($filePath, $storageFullPath)) {
|
if (!move_uploaded_file($filePath, $storageFullPath)) {
|
||||||
throw new CoreException('Не удалось скопировать загруженный файл', CoreException::ERROR_FILE_COPY);
|
throw new CoreException('Не удалось скопировать загруженный файл', CoreException::ERROR_FILE_COPY);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,6 +57,26 @@
|
|||||||
$this->id = $id;
|
$this->id = $id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Получение аватара пользователя
|
||||||
|
*
|
||||||
|
* @return array|null
|
||||||
|
*/
|
||||||
|
public function getImage(): ?array
|
||||||
|
{
|
||||||
|
$result = null;
|
||||||
|
$imageId = $this->getAllUserData()['image_id'];
|
||||||
|
|
||||||
|
if (!empty($imageId)) {
|
||||||
|
try {
|
||||||
|
$result = (new File($imageId))->getAllProps();
|
||||||
|
} catch (CoreException $e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Получение всех полей пользователя
|
* Получение всех полей пользователя
|
||||||
*
|
*
|
||||||
@@ -109,16 +129,6 @@
|
|||||||
return $this->getAllUserData() ? $this->getAllUserData()['name'] : null;
|
return $this->getAllUserData() ? $this->getAllUserData()['name'] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Получение аватарки текущего пользователя
|
|
||||||
*
|
|
||||||
* @return string|null
|
|
||||||
*/
|
|
||||||
public function getImage(): ?string
|
|
||||||
{
|
|
||||||
return $this->getAllUserData() ? $this->getAllUserData()['image'] : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Получение токена текущего пользователя
|
* Получение токена текущего пользователя
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in new issue
Block a user