<commit_before><?php

namespace Intranet\MainBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;
use Intranet\MainBundle\Entity\Task;

class TaskController extends Controller
{
    public function addTaskAction(Request $request, $office_id)
    {
    	$em = $this->getDoctrine()->getManager();
    	$office = $em->getRepository('IntranetMainBundle:Office')->find($office_id);
    	if ($office == null)
    		return new Response('Office not found!');
    	
    	if ($request->getMethod() == 'POST')
    	{
    		$name = $request->request->get('name');
    		$priority = $request->request->get('priority');
    		$status = $request->request->get('status');
    		$members = ($request->request->get('members')) ? $request->request->get('members') : array();
    		$topics = ($request->request->get('topics')) ? $request->request->get('topics') : array();
    		$backUrl = $request->request->get('backUrl');
    		
    		$task = new Task();
    		$task->setOfficeid($office_id);
    		$task->setOffice($office);
    		$task->setName($name);
    		$task->setPriority($priority);
    		$task->setStatus($status);
    		$usersAdded = $task->addUsers($em, $members);
    		$topicsAdded = $task->addTopics($em, $topics);
    		
    		$em->persist($task);
    		$em->flush();
    		
    		//fire notifications
    		
    		return $this->redirect($backUrl);
    	}
    	return new Response('Office not found!');
    	$topics = $office->getTopTopics($em);
    	$users = $this->getUser()->getAllUsers($em, false);
    	$backUrl = $request->query->get('backUrl');
        return $this->render('IntranetMainBundle:Task:addTask.html.twig', array("topics" => $topics, "users" => $users, "office" => $office, "backUrl" => $backUrl));
    }
    
    public function editTaskAction(Request $request, $office_id, $task_id)
    {
    	$em = $this->getDoctrine()->getManager();
    	$office = $em->getRepository('IntranetMainBundle:Office')->find($office_id);
    	if ($office == null)
    		return new Response('Office not found!');
    	
    	$task = $em->getRepository('IntranetMainBundle:Task')->find($task_id);
    	if ($task == null)
    		return new Response('Task not found!');
    	
    	if ($request->getMethod() == 'POST')
    	{
    		$name = $request->request->get('name');
    		$priority = $request->request->get('priority');
    		$status = $request->request->get('status');
    		$members = ($request->request->get('members')) ? $request->request->get('members') : array();
    		$topics = ($request->request->get('topics')) ? $request->request->get('topics') : array();
    		$backUrl = $request->request->get('backUrl');
    		
    		$task->setName($name);
    		$task->setPriority($priority);
    		$task->setStatus($status);<commit_msg>test 3<commit_after><?php

namespace Intranet\MainBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;
use Intranet\MainBundle\Entity\Task;

class TaskController extends Controller
{
    public function addTaskAction(Request $request, $office_id)
    {
    	$em = $this->getDoctrine()->getManager();
    	$office = $em->getRepository('IntranetMainBundle:Office')->find($office_id);
    	if ($office == null)
    		return new Response('Office not found!');
    	
    	if ($request->getMethod() == 'POST')
    	{
    		$name = $request->request->get('name');
    		$priority = $request->request->get('priority');
    		$status = $request->request->get('status');
    		$members = ($request->request->get('members')) ? $request->request->get('members') : array();
    		$topics = ($request->request->get('topics')) ? $request->request->get('topics') : array();
    		$backUrl = $request->request->get('backUrl');
    		
    		$task = new Task();
    		$task->setOfficeid($office_id);
    		$task->setOffice($office);
    		$task->setName($name);
    		$task->setPriority($priority);
    		$task->setStatus($status);
    		$usersAdded = $task->addUsers($em, $members);
    		$topicsAdded = $task->addTopics($em, $topics);
    		
    		$em->persist($task);
    		$em->flush();
    		
    		//fire notifications
    		
    		return $this->redirect($backUrl);
    	}
    	
    	$topics = $office->getTopTopics($em);
    	return new Response('Office not found!');
    	$users = $this->getUser()->getAllUsers($em, false);
    	$backUrl = $request->query->get('backUrl');
        return $this->render('IntranetMainBundle:Task:addTask.html.twig', array("topics" => $topics, "users" => $users, "office" => $office, "backUrl" => $backUrl));
    }
    
    public function editTaskAction(Request $request, $office_id, $task_id)
    {
    	$em = $this->getDoctrine()->getManager();
    	$office = $em->getRepository('IntranetMainBundle:Office')->find($office_id);
    	if ($office == null)
    		return new Response('Office not found!');
    	
    	$task = $em->getRepository('IntranetMainBundle:Task')->find($task_id);
    	if ($task == null)
    		return new Response('Task not found!');
    	
    	if ($request->getMethod() == 'POST')
    	{
    		$name = $request->request->get('name');
    		$priority = $request->request->get('priority');
    		$status = $request->request->get('status');
    		$members = ($request->request->get('members')) ? $request->request->get('members') : array();
    		$topics = ($request->request->get('topics')) ? $request->request->get('topics') : array();
    		$backUrl = $request->request->get('backUrl');
    		
    		$task->setName($name);
    		$task->setPriority($priority);
    		$task->setStatus($status);
{'fraction_non_alphanumeric': 0.19596844872918492, 'fraction_numerical': 0.00017528483786152498, 'mean_word_length': 3.53577106518283, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 137, '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': '6738980', 'n_tokens_mistral': 1950, 'n_tokens_neox': 1886, 'n_words': 286}