<commit_before><?php

$acl_migrations = '<?php if (!defined(\'BASEPATH\')) exit(\'No direct script access allowed\');

class Migration_Install_'.$module_name_lower.'_permissions extends Migration {

	// permissions to migrate
	private $permission_values = array(';

foreach($contexts as $context)
{
	if ($context != 'public')
	{
		$permission = '';
		$permission = ucfirst($module_name).".";
		$permission .= ucfirst($context).".";
		foreach($action_names as $action_name) {
			$action_permission = '';
			$action_name = ucfirst($action_name);
			if($action_name == 'Index') {
				$action_name = 'View';
			}
			$action_permission = $permission . $action_name;
			$action_status = 'active';
			$action_description = '';

			$acl_migrations .= '
		array(\'name\' => \''.$action_permission.'\', \'description\' => \''.$action_description.'\', \'status\' => \''.$action_status.'\',),';
		}
	}
}

$acl_migrations .= '
	);

	//--------------------------------------------------------------------

	public function up()
	{
		$prefix = $this->db->dbprefix;

		// permissions
		foreach ($this->permission_values as $permission_value)
		{
			$permissions_data = $permission_value;
			$this->db->insert("{$prefix}permissions", $permissions_data);
			$role_permissions_data = array(\'role_id\' => \''.$role_id.'\', \'permission_id\' => $this->db->insert_id(),);
			$this->db->insert("{$prefix}role_permissions", $role_permissions_data);
		}
	}

	//--------------------------------------------------------------------

	public function down()
	{
		$prefix = $this->db->dbprefix;

        // permissions
		foreach ($this->permission_values as $permission_value)
		{
			$query = $this->db->select(\'permission_id\')->get_where("{$prefix}permissions", array(\'name\' => $permission_value[\'name\'],));
			foreach ($query->result_array() as $row)
			{
				$permission_id = $row[\'permission_id\'];
				$this->db->delete("{$prefix}role_permissions", array(\'permission_id\' => $permission_id));
			}
			$this->db->delete("{$prefix}permissions", array(\'name\' => $permission_value[\'name\']));

		}
	}

	//--------------------------------------------------------------------

}';

echo $acl_migrations;
?>
<commit_msg>ModuleBuilder: improve readability of the acl view<commit_after><?php

$acl_migrations = '<?php if (!defined(\'BASEPATH\')) exit(\'No direct script access allowed\');

class Migration_Install_'.$module_name_lower.'_permissions extends Migration {

	// permissions to migrate
	private $permission_values = array(';

foreach($contexts as $context)
{
	if ($context != 'public')
	{
		$permission = '';
		$permission = ucfirst($module_name).".";
		$permission .= ucfirst($context).".";
		foreach($action_names as $action_name) {
			$action_permission = '';
			$action_name = ucfirst($action_name);
			if($action_name == 'Index') {
				$action_name = 'View';
			}
			$action_permission = $permission . $action_name;
			$action_status = 'active';
			$action_description = '';

			$acl_migrations .= "
		array('name' => '".$action_permission."', 'description' => '".$action_description."', 'status' => '".$action_status."',),";
		}
	}
}

$acl_migrations .= '
	);

	//--------------------------------------------------------------------

	public function up()
	{
		$prefix = $this->db->dbprefix;

		// permissions
		foreach ($this->permission_values as $permission_value)
		{
			$permissions_data = $permission_value;
			$this->db->insert("{$prefix}permissions", $permissions_data);
			$role_permissions_data = array(\'role_id\' => \''.$role_id.'\', \'permission_id\' => $this->db->insert_id(),);
			$this->db->insert("{$prefix}role_permissions", $role_permissions_data);
		}
	}

	//--------------------------------------------------------------------

	public function down()
	{
		$prefix = $this->db->dbprefix;

        // permissions
		foreach ($this->permission_values as $permission_value)
		{
			$query = $this->db->select(\'permission_id\')->get_where("{$prefix}permissions", array(\'name\' => $permission_value[\'name\'],));
			foreach ($query->result_array() as $row)
			{
				$permission_id = $row[\'permission_id\'];
				$this->db->delete("{$prefix}role_permissions", array(\'permission_id\' => $permission_id));
			}
			$this->db->delete("{$prefix}permissions", array(\'name\' => $permission_value[\'name\']));

		}
	}

	//--------------------------------------------------------------------

}';

echo $acl_migrations;
?>

{'fraction_non_alphanumeric': 0.28303591597018296, 'fraction_numerical': 0.0, 'mean_word_length': 2.7749360613810743, 'pattern_counts': {'":': 0, '<': 7, '<?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': '984905', 'n_tokens_mistral': 1501, 'n_tokens_neox': 1354, 'n_words': 214}