From 30576a94c2be2e09af79bc19bb6426e07c8bca86 Mon Sep 17 00:00:00 2001 From: Polonkai Gergely Date: Thu, 30 Aug 2012 10:58:52 +0200 Subject: [PATCH] Finished ajaxUserData template Signed-off-by: Gergely Polonkai --- src/KekRozsak/FrontBundle/Entity/Group.php | 2 +- src/KekRozsak/SecurityBundle/Entity/User.php | 41 ++++++++++++++++++ .../views/Default/ajaxUserdata.html.twig | 42 ++++++++++++++++++- 3 files changed, 83 insertions(+), 2 deletions(-) diff --git a/src/KekRozsak/FrontBundle/Entity/Group.php b/src/KekRozsak/FrontBundle/Entity/Group.php index f260510..4f07be8 100644 --- a/src/KekRozsak/FrontBundle/Entity/Group.php +++ b/src/KekRozsak/FrontBundle/Entity/Group.php @@ -48,7 +48,7 @@ class Group /** * @var KekRozsak\SecurityBundle\Entity\User $leader - * @ORM\ManyToOne(targetEntity="KekRozsak\SecurityBundle\Entity\User") + * @ORM\ManyToOne(targetEntity="KekRozsak\SecurityBundle\Entity\User", inversedBy="ledGroups") */ protected $leader; diff --git a/src/KekRozsak/SecurityBundle/Entity/User.php b/src/KekRozsak/SecurityBundle/Entity/User.php index 00c8a5b..7b649cd 100644 --- a/src/KekRozsak/SecurityBundle/Entity/User.php +++ b/src/KekRozsak/SecurityBundle/Entity/User.php @@ -27,6 +27,7 @@ class User implements UserInterface, AdvancedUserInterface { $this->groups = new ArrayCollection(); $this->roles = new ArrayCollection(); + $this->ledGroups = new ArrayCollection(); } /** @@ -348,6 +349,46 @@ class User implements UserInterface, AdvancedUserInterface return $this->groups; } + /** + * Get all groups, including led groups (which are sometimes not included + * in $groups) + * + * @return Doctrine\Common\Collections\ArrayCollection + */ + public function getAllGroups() + { + $groups = $this->ledGroups; + + $this->getGroups()->forAll(function($i, $membership) use ($groups) { + $group = $membership->getGroup(); + if ($groups->contains($group)) { + return true; + } + $groups->add($group); + return true; + }); + return $groups; + } + + /** + * Groups led by this User + * + * @var Doctrine\Common\Collections\ArrayCollection $ledGroups + * + * @ORM\OneToMany(targetEntity="KekRozsak\FrontBundle\Entity\Group", mappedBy="leader", fetch="LAZY") + */ + protected $ledGroups; + + /** + * Get ledGroups + * + * @return Doctrine\Common\Collections\ArrayCollection + */ + public function getLedGroups() + { + return $this->ledGroups; + } + /** * The Roles belonging to this User * diff --git a/src/KekRozsak/SecurityBundle/Resources/views/Default/ajaxUserdata.html.twig b/src/KekRozsak/SecurityBundle/Resources/views/Default/ajaxUserdata.html.twig index ed39943..4e87060 100644 --- a/src/KekRozsak/SecurityBundle/Resources/views/Default/ajaxUserdata.html.twig +++ b/src/KekRozsak/SecurityBundle/Resources/views/Default/ajaxUserdata.html.twig @@ -5,6 +5,46 @@ {{ user.displayName }} - Tagság kezdete: {{ user.registeredAt|date('Y-m-d') }} + Tagság kezdete: {{ user.registeredAt|date('Y-m-d') }}
+{% if is_granted('ROLE_ADMIN') %} + Felhasználónév: {{ user.username }}
+{% endif %} +{% if is_granted('ROLE_ADMIN') or (user.userData and user.userData.emailPublic) %} + E-mail: {{ user.email }}
+{% endif %} +{% if user.userData and (is_granted('ROLE_ADMIN') or (user.userData.realNamePublic and (user.userData.realName == ''))) %} + Valódi név: {{ user.userData.realName }}
+{% endif %} +{% if user.userData and user.userData.msnAddress != '' and (is_granted('ROLE_ADMIN') or user.userData.msnAddressPublic) %} + MSN cím: {{ user.userData.msnAddress }}
+{% endif %} +{% if user.userData and user.userData.googleTalk != '' and (is_granted('ROLE_ADMIN') or user.userData.googleTalkPublic) %} + Google Talk cím: {{ user.userData.googleTalk }} +{% endif %} +{% if user.userData and user.userData.skype != '' and (is_granted('ROLE_ADMIN') or user.userData.skypePublic) %} + Skype név: {{ user.userData.skypePublic }} +{% endif %} +{% if user.userData and user.userData.phoneNumber != '' and (is_granted('ROLE_ADMIN') or user.userData.phoneNumberPublic) %} + Telefonszám: {{ user.userData.phoneNumber }}
+{% endif %} +{% if user.userData and user.userData.selfDescription != '' %} + Leírás: {{ user.userData.selfDescription }}
+{% endif %} + Csoportok:
+{% set groupCount = 0 %} +{% for group in user.allGroups %} +{#% if is_granted('ROLE_ADMIN') or group.isMember(app.user) or group.open %#} +{% set groupCount = groupCount + 1 %} +{{ group.name }}
+{#% endif %#} +{% endfor %} +{% if groupCount == 0 %} +Egy csoportnak sem tagja.
+{% endif %} +{% if is_granted('ROLE_ADMIN') %} + Jóváhagyta: {{ user.acceptedBy.displayName }}
+ Utolsó bejelentkezés: {{ user.lastLoginAt|date('Y-m-d H:i') }}
+ Jogok: +{% endif %}