<commit_before><?php namespace Xivic\UserBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Xivic\UserBundle\Entity\User;
use Xivic\UserBundle\Form\Type\UserFormType;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use Symfony\Component\Security\Core\Exception\AccountStatusException;
use FOS\UserBundle\Model\UserInterface;

class AdminUsersController extends Controller
{
	public function indexAction(Request $request)
    {
		$role_filter = (int)$request->query->get('role');
		
		$user = $this->get('security.context')->getToken()->getUser();
		$user_manager = $this->get('fos_user.user_manager');
		if($role_filter == 0){
			$users = $user_manager->findUsers();
			/*foreach($users as $item){
				echo "<p>".$item->getRoles().'</p>';
			}*/
		} else {
			$roles_array = array(
				'1' => 'ROLE_USER',
				'2' => 'ROLE_ADMIN',
				'3' => 'ROLE_SUPERADMIN'
			);
			$target = $roles_array[$role_filter];
			$users = $this->getDoctrine()->getEntityManager()
            ->createQuery(
                'SELECT u FROM XivicUserBundle:User u WHERE u.roles LIKE :role'
            )->setParameter('role', '%'.$target.'%')->getResult();
		}
        
		/*$users = $this->getDoctrine()->getEntityManager()
            ->createQuery(
                'SELECT u FROM XivicUserBundle:User u WHERE u.roles LIKE :role'
            )->setParameter('role', '%"ROLE_USER"%')->getResult();*/
		/*echo "<pre>";
		var_dump($users);
		echo "</pre>";
		die;*/
        return $this->render('XivicUserBundle:AdminUsers:show.html.twig', array('users' => $users));
    }
	
	public function createAction(Request $request){
		$user = $this->get('security.context')->getToken()->getUser();
		$user_manager = $this->get('fos_user.user_manager');
		$users = $user_manager->findUsers();
		//$new_user = $user_manager->createUser();
		//echo "<pre>";
		//var_dump($new_user);
		//die;
		$form = $this->createForm(new UserFormType());
		if ($request->isMethod('POST')) {<commit_msg>new user role<commit_after><?php namespace Xivic\UserBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Xivic\UserBundle\Entity\User;
use Xivic\UserBundle\Form\Type\UserFormType;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use Symfony\Component\Security\Core\Exception\AccountStatusException;
use FOS\UserBundle\Model\UserInterface;

class AdminUsersController extends Controller
{
	public function indexAction(Request $request)
    {
		$role_filter = (int)$request->query->get('role');
		
		$user = $this->get('security.context')->getToken()->getUser();
		$user_manager = $this->get('fos_user.user_manager');
		if($role_filter == 0){
			$users = $user_manager->findUsers();
			/*foreach($users as $item){
				echo "<p>".$item->getRoles().'</p>';
			}*/
		} else {
			$roles_array = array(
				'1' => 'ROLE_USER',
				'2' => 'ROLE_ADMIN',
				'3' => 'ROLE_SUPER_ADMIN'
			);
			$target = $roles_array[$role_filter];
			$users = $this->getDoctrine()->getEntityManager()
            ->createQuery(
                'SELECT u FROM XivicUserBundle:User u WHERE u.roles LIKE :role'
            )->setParameter('role', '%'.$target.'%')->getResult();
		}
        
		/*$users = $this->getDoctrine()->getEntityManager()
            ->createQuery(
                'SELECT u FROM XivicUserBundle:User u WHERE u.roles LIKE :role'
            )->setParameter('role', '%"ROLE_USER"%')->getResult();*/
		/*echo "<pre>";
		var_dump($users);
		echo "</pre>";
		die;*/
        return $this->render('XivicUserBundle:AdminUsers:show.html.twig', array('users' => $users));
    }
	
	public function createAction(Request $request){
		$user = $this->get('security.context')->getToken()->getUser();
		$user_manager = $this->get('fos_user.user_manager');
		$users = $user_manager->findUsers();
		//$new_user = $user_manager->createUser();
		//echo "<pre>";
		//var_dump($new_user);
		//die;
		$form = $this->createForm(new UserFormType());
		if ($request->isMethod('POST')) {
{'fraction_non_alphanumeric': 0.18492315198828982, 'fraction_numerical': 0.0019516955354964625, 'mean_word_length': 3.9696969696969697, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 75, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3952481', 'n_tokens_mistral': 1440, 'n_tokens_neox': 1329, 'n_words': 222}