Example #1
0
 public function getTotal(User $user = null)
 {
     $q = $this->_em->createQueryBuilder();
     $q->select('count(deck.id)');
     $q->from('AssuraCardBundle:Deck', 'deck');
     if (isset($user)) {
         $q->where('deck.user = :user')->setParameter('user', $user->getId());
     }
     return $q->getQuery()->getSingleScalarResult();
 }
Example #2
0
 /**
  * @Route("/{status}/{id}", name="admin_updatestatus_user",requirements={"status":"(enable|disable)"})
  */
 public function deleteAction(Request $request, User $user, $status)
 {
     if ($user->getAdmin()) {
         $request->getSession()->getFlashBag()->add('alert', "You can't disable admin user.");
         return $this->redirect($this->generateUrl('admin_list_users'));
     }
     $em = $this->getDoctrine()->getManager();
     if ($status == 'enable') {
         $request->getSession()->getFlashBag()->add('success', "The user has been enabled");
         $user->setActive(true);
     } else {
         if ($status == 'disable') {
             $request->getSession()->getFlashBag()->add('success', "The user has been disabled");
             $user->setActive(false);
         }
     }
     $em->persist($user);
     $em->flush();
     return $this->redirect($this->generateUrl('admin_list_users'));
 }