123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- <?php
-
- namespace Muzich\MynetworkBundle\Controller;
-
- use Muzich\CoreBundle\lib\Controller;
- use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
- use Muzich\CoreBundle\Searcher\UserAndGroupSearcher;
-
- class MynetworkController extends Controller
- {
-
- /**
- * Page listant les personnes et groupes que l'on suit, ainsi que les
- * personnes qui nous duivent.
- *
- * @Template()
- */
- public function indexAction($event_id)
- {
- $user = $this->getUser(true, array('join' => array(
- 'followers_users'//, 'followeds_users', 'followeds_groups'
- )));
-
- //$followeds_users = $user->getFollowedsUsers();
- //$followeds_groups = $user->getFollowedGroups();
- $followers_users = $user->getFollowersUsers();
-
- if ($event_id)
- {
- if (!($event = $this->getDoctrine()->getRepository('MuzichCoreBundle:Event')
- ->findOneById($event_id)))
- {
- return $this->redirect($this->generateUrl('mynetwork_index'));
- }
-
- if ($event->getUser()->getId() != $this->getUserId())
- {
- throw $this->createNotFoundException();
- }
- $followers_users = $this->proceedForEvent($event, $followers_users, $event_id);
- }
-
- return array(
- //'followeds_users' => $followeds_users,
- //'followeds_groups' => $followeds_groups,
- 'followers_users' => $followers_users
- );
- }
-
- private function proceedForEvent($event, $followers_users, $event_id)
- {
- $ids = $event->getIds();
-
- $this->getDoctrine()->getManager()->remove($event);
- $this->getDoctrine()->getManager()->flush();
-
- $followers_users_new = array();
- foreach ($followers_users as $user)
- {
- if (in_array($user->getId(), $ids))
- {
- $followers_users_new[] = $user;
- }
- }
-
- return $followers_users_new;
- }
-
- }
|