<commit_before><?php
class AccessC extends Controller {
	public function index($params) {
		$this->_access_type('html');
		global $session;
		$this->_register('accesses', Access::selection(array(
			'@order' => 'name',
		)));
		if($session) {
			$current_user = $session->User;
			$this->_register('current_user', $current_user);
		}
		$this->_display('index');
		new LayoutC('html');
	}

	public function edit($params) {
		$this->_access_type('html');
		global $session;
		if($session == null || !$session->User->has_access('access_editor')) {
			Message::add_error("Du har inte access att redigera rättigheter");
			URL::redirect('');
		}
		$access = Access::from_id(ClientData::post(array_shift($access)));
		if(!$access) {
			Message::add_error("Rättigheten du försöker redigera finns inte");
			URL::redirect('/Access/index');
		}
		$this->_register('access', $access);
		$this->_display('edit');
		new LayoutC('html');
	}

	public function create($params) {
		$this->_access_type('html');
		global $session;
		if($session == null) {
			Message::add_error("Du måste vara inloggad för att skapa nya rättigheter");
			URL::redirect('');
		}
		$current_user = $session->User;
		if(!$current_user->has_access('access_editor')) {
			Message::add_error("Du har inte access att skapa nya rättigheter");
			URL::redirect('');
		}
		$this->_register('current_user', $current_user);
		$this->_display('create');
		new LayoutC('html');
	}

	public function make($params) {
		$this->_access_type('script');
		global $session;
		if($session == null || !$session->User->has_access('access_editor')) {
			Message::add_error("Du har inte access att skapa nya rättigheter");
			URL::redirect('');
		}
		try{
			$setting = new Access();
			$setting->name = ClientData::post('name');
			$setting->commit();
			URL::redirect('/Access/index');
		} catch(Exception $e) {
			Message::add_error($e->getMessage());
			URL::redirect('/Access/create');
		}
	}

	public function modify($params) {
		$this->_access_type('script');
		global $session;
		if($session == null || !$session->User->has_access('access_editor')) {
			Message::add_error("Du har inte access att redigera rättigheter");
			URL::redirect('');
		}
		$access = Access::from_id(ClientData::post('access_id'));
		if(!$access) {
			Message::add_error("Rättigheten du försöker redigera finns inte");
			URL::redirect('/Access/index');
		}
		try {
			$access->name= ClientData::post('name');
			$access->commit();
			Message::add_notice("Rättigheten updaterad");
			URL::redirect('/Access/index');
		} catch(Exception $e) {
			Message::add_error($e);
			URL::redirect();
		}
	}
}
?>
<commit_msg>Fixing bug with missing code_name for created access.<commit_after><?php
class AccessC extends Controller {
	public function index($params) {
		$this->_access_type('html');
		global $session;
		$this->_register('accesses', Access::selection(array(
			'@order' => 'name',
		)));
		if($session) {
			$current_user = $session->User;
			$this->_register('current_user', $current_user);
		}
		$this->_display('index');
		new LayoutC('html');
	}

	public function edit($params) {
		$this->_access_type('html');
		global $session;
		if($session == null || !$session->User->has_access('access_editor')) {
			Message::add_error("Du har inte access att redigera rättigheter");
			URL::redirect('');
		}
		$access = Access::from_id(ClientData::post(array_shift($access)));
		if(!$access) {
			Message::add_error("Rättigheten du försöker redigera finns inte");
			URL::redirect('/Access/index');
		}
		$this->_register('access', $access);
		$this->_display('edit');
		new LayoutC('html');
	}

	public function create($params) {
		$this->_access_type('html');
		global $session;
		if($session == null) {
			Message::add_error("Du måste vara inloggad för att skapa nya rättigheter");
			URL::redirect('');
		}
		$current_user = $session->User;
		if(!$current_user->has_access('access_editor')) {
			Message::add_error("Du har inte access att skapa nya rättigheter");
			URL::redirect('');
		}
		$this->_register('current_user', $current_user);
		$this->_display('create');
		new LayoutC('html');
	}

	public function make($params) {
		$this->_access_type('script');
		global $session;
		if($session == null || !$session->User->has_access('access_editor')) {
			Message::add_error("Du har inte access att skapa nya rättigheter");
			URL::redirect('');
		}
		try{
			$setting = new Access();
			$setting->name = ClientData::post('name');
			$setting->code_name = ClientData::post('code_name');
			$setting->commit();
			URL::redirect('/Access/index');
		} catch(Exception $e) {
			Message::add_error($e->getMessage());
			URL::redirect('/Access/create');
		}
	}

	public function modify($params) {
		$this->_access_type('script');
		global $session;
		if($session == null || !$session->User->has_access('access_editor')) {
			Message::add_error("Du har inte access att redigera rättigheter");
			URL::redirect('');
		}
		$access = Access::from_id(ClientData::post('access_id'));
		if(!$access) {
			Message::add_error("Rättigheten du försöker redigera finns inte");
			URL::redirect('/Access/index');
		}
		try {
			$access->name= ClientData::post('name');
			$access->commit();
			Message::add_notice("Rättigheten updaterad");
			URL::redirect('/Access/index');
		} catch(Exception $e) {
			Message::add_error($e);
			URL::redirect();
		}
	}
}
?>

{'fraction_non_alphanumeric': 0.19523099850968703, 'fraction_numerical': 0.0, 'mean_word_length': 5.046171171171171, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 60, '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': '2604902', 'n_tokens_mistral': 2005, 'n_tokens_neox': 1778, 'n_words': 325}