<commit_before><?php

class Project_Issue_Controller extends Base_Controller {

	public $layout = 'layouts.project';
	
	public function __construct() {
		parent::__construct();

		$this->filter('before', 'project');
		$this->filter('before', 'issue')->except('new');
		$this->filter('before', 'permission:issue-modify')
				->only(array('edit_comment', 'delete_comment', 'reassign', 'retag', 'status', 'edit', 'upload', 'checkExt'));
	}

	/**
	 * Create a new issue
	 * /project/(:num)/issue/new
	 *
	 * @return View
	 */
	public function get_new() {
		Asset::add('tag-it-js', '/app/assets/js/tag-it.min.js', array('jquery', 'jquery-ui'));
		Asset::add('tag-it-css-base', '/app/assets/css/jquery.tagit.css');
		Asset::add('tag-it-css-zendesk', '/app/assets/css/tagit.ui-zendesk.css');

		return $this->layout->nest('content', 'project.issue.new', array(
			'project' => Project::current()
		));
	}


	public function post_new() {
		$issue = Project\Issue::create_issue(Input::all(), Project::current());

		if(!$issue['success']) {
			return Redirect::to(Project::current()->to('issue/new'))
				->with_input()
				->with_errors($issue['errors'])
				->with('notice-error', __('tinyissue.we_have_some_errors'));
		}

		//Send an email to the assignee
		$val = explode("/",$issue['issue']->to());
		$issue_num = $val[count($val)-1];
		//Search for new assignee infos
		$thisIssue = \Project\Issue::where('id', '=', $issue_num)->get('*');
		$Who = \User::where('id', '=', $thisIssue[0]->attributes["assigned_to"] )->get(array('firstname','lastname','email'));
		$WhoName = $Who[0]->attributes["firstname"].' '.$Who[0]->attributes["lastname"];
		$WhoAddr = $Who[0]->attributes["email"];
		$Issue_title = $thisIssue[0]->attributes["title"];
		$Project = \Project::where('id', '=', $thisIssue[0]->attributes["project_id"])->get(array('id', 'name'));
		$project_id = $Project[0]->attributes["id"];
		$project_nm = $Project[0]->attributes["name"];
		$project = \Project::find($project_id);
		
		//Email process
			$header = """;
			$subject  = sprintf(__('email.assignment'),$Issue_title,$project_nm);
			$text  = sprintf(__('email.assignment'),$Issue_title,$project_nm);
			$text .= "\n\n";
			$text .= sprintf(__('email.assigned_by'),\Auth::user()->firstname." ".\Auth::user()->lastname);
			$text .= "\n\n";
			$text .= sprintf(__('tinyissue.priority')." : ".__('tinyissue.priority_desc_'.$thisIssue[0]->attributes["status"]));
			$text .= "\n\n";
			$text .= __('email.more_url').Project::current()->to('issue')."/".$issue_num."";
			mail($WhoAddr, $subject,$text,$header);
		//End of email process

		return Redirect::to($issue['issue']->to())<commit_msg>Oups!<commit_after><?php

class Project_Issue_Controller extends Base_Controller {

	public $layout = 'layouts.project';
	
	public function __construct() {
		parent::__construct();

		$this->filter('before', 'project');
		$this->filter('before', 'issue')->except('new');
		$this->filter('before', 'permission:issue-modify')
				->only(array('edit_comment', 'delete_comment', 'reassign', 'retag', 'status', 'edit', 'upload', 'checkExt'));
	}

	/**
	 * Create a new issue
	 * /project/(:num)/issue/new
	 *
	 * @return View
	 */
	public function get_new() {
		Asset::add('tag-it-js', '/app/assets/js/tag-it.min.js', array('jquery', 'jquery-ui'));
		Asset::add('tag-it-css-base', '/app/assets/css/jquery.tagit.css');
		Asset::add('tag-it-css-zendesk', '/app/assets/css/tagit.ui-zendesk.css');

		return $this->layout->nest('content', 'project.issue.new', array(
			'project' => Project::current()
		));
	}


	public function post_new() {
		$issue = Project\Issue::create_issue(Input::all(), Project::current());

		if(!$issue['success']) {
			return Redirect::to(Project::current()->to('issue/new'))
				->with_input()
				->with_errors($issue['errors'])
				->with('notice-error', __('tinyissue.we_have_some_errors'));
		}

		//Send an email to the assignee
		$val = explode("/",$issue['issue']->to());
		$issue_num = $val[count($val)-1];
		//Search for new assignee infos
		$thisIssue = \Project\Issue::where('id', '=', $issue_num)->get('*');
		$Who = \User::where('id', '=', $thisIssue[0]->attributes["assigned_to"] )->get(array('firstname','lastname','email'));
		$WhoName = $Who[0]->attributes["firstname"].' '.$Who[0]->attributes["lastname"];
		$WhoAddr = $Who[0]->attributes["email"];
		$Issue_title = $thisIssue[0]->attributes["title"];
		$Project = \Project::where('id', '=', $thisIssue[0]->attributes["project_id"])->get(array('id', 'name'));
		$project_id = $Project[0]->attributes["id"];
		$project_nm = $Project[0]->attributes["name"];
		$project = \Project::find($project_id);
		
		//Email process
			$header = "";
			$subject  = sprintf(__('email.assignment'),$Issue_title,$project_nm);
			$text  = sprintf(__('email.assignment'),$Issue_title,$project_nm);
			$text .= "\n\n";
			$text .= sprintf(__('email.assigned_by'),\Auth::user()->firstname." ".\Auth::user()->lastname);
			$text .= "\n\n";
			$text .= sprintf(__('tinyissue.priority')." : ".__('tinyissue.priority_desc_'.$thisIssue[0]->attributes["status"]));
			$text .= "\n\n";
			$text .= __('email.more_url').Project::current()->to('issue')."/".$issue_num."";
			mail($WhoAddr, $subject,$text,$header);
		//End of email process

		return Redirect::to($issue['issue']->to())
{'fraction_non_alphanumeric': 0.2503303756843496, 'fraction_numerical': 0.003775722106852936, 'mean_word_length': 5.110726643598616, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 61, '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': '2357991', 'n_tokens_mistral': 1984, 'n_tokens_neox': 1801, 'n_words': 261}