Added basic group management, with many missing features.
This commit is contained in:
@@ -23,4 +23,56 @@ class DefaultController extends Controller
|
||||
'users' => $users,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/csoport_jelentkezok", name="KekRozsakAdminBundle_groupJoinRequests")
|
||||
* @Template()
|
||||
*/
|
||||
public function groupJoinRequestsAction()
|
||||
{
|
||||
$user = $this->get('security.context')->getToken()->getUser();
|
||||
$groupRepo = $this->getDoctrine()->getRepository('KekRozsakFrontBundle:Group');
|
||||
$myGroups = $groupRepo->findByLeader($user);
|
||||
|
||||
$request = $this->getRequest();
|
||||
if ($request->getMethod() == 'POST')
|
||||
{
|
||||
if ($request->request->has('group') && $request->request->has('user'))
|
||||
{
|
||||
$userRepo = $this->getDoctrine()->getRepository('KekRozsakSecurityBundle:User');
|
||||
$aUser = $userRepo->findOneById($request->request->get('user'));
|
||||
$aGroup = $groupRepo->findOneById($request->request->get('group'));
|
||||
if ($aUser && $aGroup)
|
||||
{
|
||||
$membershipRepo = $this->getDoctrine()->getRepository('KekRozsakFrontBundle:UserGroupMembership');
|
||||
$membershipObject = $membershipRepo->findOneBy(array('user' => $aUser, 'group' => $aGroup));
|
||||
if ($membershipObject)
|
||||
{
|
||||
$membershipObject->setMembershipAcceptedAt(new \DateTime('now'));
|
||||
$membershipObject->setMembershipAcceptedBy($user);
|
||||
|
||||
$em = $this->getDoctrine()->getEntityManager();
|
||||
$em->persist($membershipObject);
|
||||
$em->flush();
|
||||
|
||||
return $this->redirect($this->generateUrl('KekRozsakAdminBundle_groupJoinRequests'));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return array(
|
||||
'groups' => $myGroups,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/csoport_jelentkezok/elutasit", name="KekRozsakAdminBundle_groupJoinDecline")
|
||||
* @Template()
|
||||
*/
|
||||
public function groupJoinDeclineAction()
|
||||
{
|
||||
return array(
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,41 @@
|
||||
{% extends '::main_template.html.twig' %}
|
||||
{% block title %} - Csoport jelentkezők {% endblock %}
|
||||
{% block content %}
|
||||
<h3>Csoport jelentkezők</h3>
|
||||
<p>Az alábbi listán az általad vezetett csoportokba frissen jelentkezőket láthatod. A mellettük lévő ikonokra kattintva hagyhatod jóvá, illetve utasísthatod el a jelentkezésüket. Amennyiben ez utóbbi mellett döntesz, egy rövid üzenetet is írnod kell az elutasítás okáról.</p>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<td colspan="2">Csoport / Jelentkező</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for group in groups %}
|
||||
<tr>
|
||||
<td class="ikon">[ikon]</td>
|
||||
<td colspan="2">{{ group.name }}</td>
|
||||
</tr>
|
||||
{% for request in group.members %}
|
||||
{% if not group.isMember(request.user) %}
|
||||
<tr>
|
||||
<td colspan="2">{{ request.user.displayName }}</td>
|
||||
<td>
|
||||
<form method="post" action="{{ path('KekRozsakAdminBundle_groupJoinRequests') }}">
|
||||
<input type="hidden" name="user" value="{{ request.user.id }}" />
|
||||
<input type="hidden" name="group" value="{{ group.id }}" />
|
||||
<button type="submit">[jóváhagyó ikon]</button>
|
||||
</form>
|
||||
<form method="post" action="{{ path('KekRozsakAdminBundle_groupJoinDecline') }}">
|
||||
<input type="hidden" name="user" value="{{ request.user.id }}" />
|
||||
<input type="hidden" name="group" value="{{ group.id }}" />
|
||||
<button type="submit">[elutasító ikon]</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% endblock content %}
|
Reference in New Issue
Block a user