mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 01:25:55 +02:00
Added page to show user informations.
This commit is contained in:
parent
fd4fa7f58d
commit
218eec874d
6 changed files with 231 additions and 1 deletions
|
@ -8,6 +8,7 @@ parameters:
|
|||
locale: 'en' # Set the default language to use her
|
||||
partdb_title: 'Part-DB' # The title shown inside of Part-DB (e.g. in the navbar and on homepage)
|
||||
banner: '' # The info text shown in the homepage
|
||||
use_gravatar: true # Set to false, if no Gravatar images should be used for user profiles.
|
||||
|
||||
services:
|
||||
# default configuration for services in *this* file
|
||||
|
|
96
src/Controller/UserController.php
Normal file
96
src/Controller/UserController.php
Normal file
|
@ -0,0 +1,96 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* part-db version 0.1
|
||||
* Copyright (C) 2005 Christoph Lechner
|
||||
* http://www.cl-projects.de/
|
||||
*
|
||||
* part-db version 0.2+
|
||||
* Copyright (C) 2009 K. Jacobs and others (see authors.php)
|
||||
* http://code.google.com/p/part-db/
|
||||
*
|
||||
* Part-DB Version 0.4+
|
||||
* Copyright (C) 2016 - 2019 Jan Böhmer
|
||||
* https://github.com/jbtronics
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*
|
||||
*/
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
|
||||
use App\Entity\User;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\Asset\Packages;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
|
||||
class UserController extends AbstractController
|
||||
{
|
||||
|
||||
/**
|
||||
* @Route("/user/info", name="user_info_self")
|
||||
* @Route("/user/{id}/info")
|
||||
*/
|
||||
public function userInfo(?User $user, Packages $packages)
|
||||
{
|
||||
|
||||
//If no user id was passed, then we show info about the current user
|
||||
if($user == null) {
|
||||
$user = $this->getUser();
|
||||
}
|
||||
|
||||
if($this->getParameter("use_gravatar")) {
|
||||
$avatar = $this->getGravatar($user->getEmail(), 200, 'identicon');
|
||||
} else {
|
||||
$avatar = $packages->getUrl("/img/default_avatar.png");
|
||||
}
|
||||
|
||||
|
||||
return $this->render('Users/user_info.html.twig', [
|
||||
'user' => $user,
|
||||
'avatar' => $avatar
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get either a Gravatar URL or complete image tag for a specified email address.
|
||||
*
|
||||
* @param string $email The email address
|
||||
* @param string $s Size in pixels, defaults to 80px [ 1 - 2048 ]
|
||||
* @param string $d Default imageset to use [ 404 | mm | identicon | monsterid | wavatar ]
|
||||
* @param string $r Maximum rating (inclusive) [ g | pg | r | x ]
|
||||
* @param bool $img True to return a complete IMG tag False for just the URL
|
||||
* @param array $atts Optional, additional key/value attributes to include in the IMG tag
|
||||
* @return String containing either just a URL or a complete image tag
|
||||
* @source https://gravatar.com/site/implement/images/php/
|
||||
*/
|
||||
public function getGravatar(string $email, int $s = 80, string $d = 'mm', string $r = 'g', bool $img = false, array $atts = array())
|
||||
{
|
||||
$url = 'https://www.gravatar.com/avatar/';
|
||||
$url .= md5(strtolower(trim($email)));
|
||||
$url .= "?s=$s&d=$d&r=$r";
|
||||
if ($img) {
|
||||
$url = '<img src="' . $url . '"';
|
||||
foreach ($atts as $key => $val) {
|
||||
$url .= ' ' . $key . '="' . $val . '"';
|
||||
}
|
||||
$url .= ' />';
|
||||
}
|
||||
return $url;
|
||||
}
|
||||
|
||||
}
|
61
templates/Users/user_info.html.twig
Normal file
61
templates/Users/user_info.html.twig
Normal file
|
@ -0,0 +1,61 @@
|
|||
{% extends "main_card.html.twig" %}
|
||||
|
||||
{% block title %}{% trans %}user.info.label{% endtrans %}{% endblock %}
|
||||
|
||||
{% block card_title %}<i class="fas fa-info-circle fa-fw" aria-hidden="true"></i>
|
||||
{% trans %}user.info.label{% endtrans %}{% endblock %}
|
||||
|
||||
{% block card_content %}
|
||||
<div class="card-body row">
|
||||
<div class="col-md-2">
|
||||
<div class="img-thumbnail">
|
||||
<img class="img-fluid img-rounded" src="{{ avatar }}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-5">
|
||||
<div class="form form-horizontal">
|
||||
<div class="form-group row">
|
||||
<label class="col-form-label col-md-4">{% trans %}user.firstName.label{% endtrans %}</label>
|
||||
<div class="col-md-8">
|
||||
<p class="form-control-plaintext">{{ user.firstName }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label class="col-form-label col-md-4">{% trans %}user.lastName.label{% endtrans %}</label>
|
||||
<div class="col-md-8">
|
||||
<p class="form-control-plaintext">{{ user.lastName }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label class="col-form-label col-md-4">{% trans %}user.email.label{% endtrans %}</label>
|
||||
<div class="col-md-8">
|
||||
{# <p class="form-control-plaintext">{{ user.email }}</p>#}
|
||||
<a class="form-control-link" href="mailto:{{ user.email }}">{{ user.email }}</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label class="col-form-label col-md-4">{% trans %}user.department.label{% endtrans %}</label>
|
||||
<div class="col-md-8">
|
||||
<p class="form-control-plaintext">{{ user.department }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-5">
|
||||
<div class="form form-horizontal">
|
||||
<div class="form-group row">
|
||||
<label class="col-form-label col-md-4">{% trans %}user.username.label{% endtrans %}</label>
|
||||
<div class="col-md-8">
|
||||
<p class="form-control-plaintext">{{ user.name }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label class="col-form-label col-md-4">{% trans %}group.label{% endtrans %}</label>
|
||||
<div class="col-md-8">
|
||||
<p class="form-control-plaintext">TODO</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
|
@ -86,7 +86,7 @@
|
|||
{% if app.user %}
|
||||
<a class="dropdown-item disabled" href="#" >{% trans %}user.loggedin.label{% endtrans %} {{ app.user.firstName }} {{app.user.lastName}} ({{app.user.name}})</a>
|
||||
<a class="dropdown-item" href="user_settings.php"><i class="fa fa-cogs fa-fw" aria-hidden="true"></i> {% trans %}user.settings.label{% endtrans %}</a>
|
||||
<a class="dropdown-item" href="user_info.php"><i class="fa fa-info-circle fa-fw" aria-hidden="true"></i> {% trans %}user.info.label{% endtrans %}</a>
|
||||
<a class="dropdown-item" href="{{ path("user_info_self") }}"><i class="fa fa-info-circle fa-fw" aria-hidden="true"></i> {% trans %}user.info.label{% endtrans %}</a>
|
||||
<li role="separator" class="dropdown-divider"></li>
|
||||
<a class="dropdown-item" href="{{ path('logout') }}"><i class="fa fa-sign-out-alt fa-fw" aria-hidden="true"></i> {% trans %}user.logout{% endtrans %}</a>
|
||||
{% else %}
|
||||
|
|
|
@ -565,5 +565,41 @@
|
|||
<target>Eingeloggt bleiben (nicht empfohlen auf geteilten Computern)</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="PwI64fM" name="user.firstName.label">
|
||||
<segment>
|
||||
<source>user.firstName.label</source>
|
||||
<target>Vorname</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="u2ayBIA" name="user.lastName.label">
|
||||
<segment>
|
||||
<source>user.lastName.label</source>
|
||||
<target>Nachname</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="cDu6Rok" name="user.email.label">
|
||||
<segment>
|
||||
<source>user.email.label</source>
|
||||
<target>Email</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="8GGUFm1" name="user.department.label">
|
||||
<segment>
|
||||
<source>user.department.label</source>
|
||||
<target>Abteilung</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="oX4P2rM" name="user.username.label">
|
||||
<segment>
|
||||
<source>user.username.label</source>
|
||||
<target>Benutzername</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="QK5x4IY" name="group.label">
|
||||
<segment>
|
||||
<source>group.label</source>
|
||||
<target>Group</target>
|
||||
</segment>
|
||||
</unit>
|
||||
</file>
|
||||
</xliff>
|
||||
|
|
|
@ -523,5 +523,41 @@
|
|||
<target>Remember me (should not be used on shared computers)</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="PwI64fM" name="user.firstName.label">
|
||||
<segment>
|
||||
<source>user.firstName.label</source>
|
||||
<target>First name</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="u2ayBIA" name="user.lastName.label">
|
||||
<segment>
|
||||
<source>user.lastName.label</source>
|
||||
<target>Last name</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="cDu6Rok" name="user.email.label">
|
||||
<segment>
|
||||
<source>user.email.label</source>
|
||||
<target>Email</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="8GGUFm1" name="user.department.label">
|
||||
<segment>
|
||||
<source>user.department.label</source>
|
||||
<target>Department</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="oX4P2rM" name="user.username.label">
|
||||
<segment>
|
||||
<source>user.username.label</source>
|
||||
<target>User name</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="QK5x4IY" name="group.label">
|
||||
<segment>
|
||||
<source>group.label</source>
|
||||
<target>Gruppe:</target>
|
||||
</segment>
|
||||
</unit>
|
||||
</file>
|
||||
</xliff>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue