diff --git a/src/Entity/Group.php b/src/Entity/Group.php new file mode 100644 index 00000000..8d074ff2 --- /dev/null +++ b/src/Entity/Group.php @@ -0,0 +1,72 @@ +getID()); + } +} \ No newline at end of file diff --git a/src/Entity/User.php b/src/Entity/User.php index a18f373a..c969a006 100644 --- a/src/Entity/User.php +++ b/src/Entity/User.php @@ -36,6 +36,9 @@ use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Security\Core\User\UserInterface; /** + * This entity represents a user, which can log in and have permissions. + * Also this entity is able to save some informations about the user, like the names, email-address and other info. + * * @ORM\Entity(repositoryClass="App\Repository\UserRepository") * @ORM\Table("users") */ @@ -68,44 +71,51 @@ class User extends NamedDBElement implements UserInterface * @var string The first name of the User * @ORM\Column(type="string", length=255) */ - protected $first_name; + protected $first_name = ""; /** * @var string The last name of the User * @ORM\Column(type="string", length=255) */ - protected $last_name; + protected $last_name = ""; /** * @var string The department the user is working * @ORM\Column(type="string", length=255) */ - protected $department; + protected $department = ""; /** * @var string The email address of the user * @ORM\Column(type="string", length=255) */ - protected $email; + protected $email = ""; /** * @var string The language/locale the user prefers * @ORM\Column(type="string", name="config_language") */ - protected $language; + protected $language = ""; /** * @var string The timezone the user prefers * @ORM\Column(type="string", name="config_timezone") */ - protected $timezone; + protected $timezone = ""; /** * @var string The theme * @ORM\Column(type="string", name="config_theme") */ - protected $theme; + protected $theme = ""; + + /** + * @var Group|null The group this user belongs to. + * @ORM\ManyToOne(targetEntity="Group", inversedBy="users") + * @ORM\JoinColumn(name="group_id", referencedColumnName="id") + */ + protected $group; /** @@ -177,7 +187,7 @@ class User extends NamedDBElement implements UserInterface */ public function getIDString(): string { - return "U" . $this->getID(); + return 'U' . sprintf('%06d', $this->getID()); } @@ -311,4 +321,15 @@ class User extends NamedDBElement implements UserInterface return $this; } + public function getGroup(): ?Group + { + return $this->group; + } + + public function setGroup(?Group $group): self + { + $this->group = $group; + return $this; + } + } diff --git a/templates/Users/user_info.html.twig b/templates/Users/user_info.html.twig index 56505d71..31c9e401 100644 --- a/templates/Users/user_info.html.twig +++ b/templates/Users/user_info.html.twig @@ -52,7 +52,7 @@
TODO
+{{ user.group.fullPath }}