<commit_before><?php

namespace console\controllers;

use common\models\user\Customer;
use common\models\user\User;
use common\models\user\Worker;
use common\rbac\OwnModelRule;
use Exception;
use Yii;
use yii\base\InvalidArgumentException;
use yii\console\Controller;
use yii\helpers\Console;
use yii\rbac\Item;
use yii\rbac\Permission;
use yii\rbac\Role;

/**
 * Class RbacController
 *
 * @author <NAME> <<EMAIL>>
 */
class RbacController extends Controller {

	public array $roles = [
		Worker::ROLE_AGENT,
		Worker::ROLE_CO_AGENT,
		Worker::ROLE_BOOKKEEPER,
		Worker::ROLE_CUSTOMER_SERVICE,
		Worker::ROLE_LAWYER,
		Worker::ROLE_LAWYER_ASSISTANT,
		Worker::ROLE_TELEMARKETER,
		Customer::ROLE_CUSTOMER,
		Customer::ROLE_VICTIM,
		Customer::ROLE_SHAREHOLDER,
		Customer::ROLE_HANDICAPPED,
		User::ROLE_RECCOMENDING,
	];

	public array $permissions = [
		User::PERMISSION_ARCHIVE,
		Worker::PERMISSION_COST => [
			Worker::ROLE_BOOKKEEPER,
		],
		Worker::PERMISSION_COST_DEBT => [
			Worker::ROLE_BOOKKEEPER,
		],
		Worker::PERMISSION_CALCULATION_TO_CREATE => [
			Worker::ROLE_BOOKKEEPER,
		],
		Worker::PERMISSION_CALCULATION_UPDATE => [
			Worker::ROLE_BOOKKEEPER,
		],
		Worker::PERMISSION_CALCULATION_PAYS => [
			Worker::ROLE_BOOKKEEPER,
		],
		Worker::PERMISSION_CALCULATION_PROBLEMS => [
			Worker::ROLE_BOOKKEEPER,
		],
		User::PERMISSION_EXPORT,
		User::PERMISSION_ISSUE,
		Worker::PERMISSION_ISSUE_LINK_USER,
		Worker::PERMISSION_ISSUE_DELETE,
		Worker::PERMISSION_ISSUE_STAGE_CHANGE,
		Worker::PERMISSION_HINT,
		User::PERMISSION_LOGS,
		Worker::PERMISSION_MEET,
		User::PERMISSION_NEWS,
		User::PERMISSION_NOTE,
		Worker::PERMISSION_NOTE_TEMPLATE,
		User::PERMISSION_PROVISION,
		Worker::PERMISSION_PAY => [
			Worker::ROLE_BOOKKEEPER,
		],
		Worker::PERMISSION_PAYS_DELAYED => [
			Worker::ROLE_BOOKKEEPER,
		],
		Worker::PERMISSION_PAY_PART_PAYED => [
			Worker::ROLE_BOOKKEEPER,
		],
		Worker::PERMISSION_PAY_RECEIVED => [
			Worker::ROLE_BOOKKEEPER,
		],
		Worker::PERMISSION_PAY_PAID => [
			Worker::ROLE_BOOKKEEPER,
		],
		Worker::PERMISSION_PAY_UPDATE => [
			Worker::ROLE_BOOKKEEPER,
			Worker::ROLE_AGENT,
		],
		Worker::PERMISSION_PAY_ALL_PAID => [
			Worker::ROLE_BOOKKEEPER,
		],
		Worker::PERMISSION_SUMMON => [
			Worker::ROLE_AGENT,
		],
		Worker::PERMISSION_SUMMON_MANAGER,
		Worker::PERMISSION_SUMMON_CREATE,
		Worker::PERMISSION_SMS,
		Worker::PERMISSION_MULTIPLE_SMS,
		Worker::PERMISSION_WORKERS,
		Worker::PERMISSION_LEAD,
		Worker::PERMISSION_LEAD_DIALER,
		Worker::PERMISSION_LEAD_DIALER_MANAGER,
		Worker::PERMISSION_LEAD_DUPLICATE,
		Worker::PERMISSION_LEAD_IMPORT,
		Worker::PERMISSION_LEAD_STATUS,
		Worker::PERMISSION_MESSAGE_TEMPLATE,
		Worker::PERMISSION_PROVISION_CHILDREN_VISIBLE,
	];

	public function actionInit(): void {
		$auth = Yii::$app->authManager;
		$auth->removeAll();

		$user = $auth->createRole(User::ROLE_USER);
		$auth->add($user);

		// own model rule
		$ownModelRule = new OwnModelRule();
		$auth->add($ownModelRule);

		$manager = $auth->createRole(User::ROLE_MANAGER);
		$auth->add($manager);
		$auth->addChild($manager, $user);

		$loginToBackend = $auth->createPermission('loginToBackend');
		$auth->add($loginToBackend);
		$auth->addChild($manager, $loginToBackend);
<commit_msg>feat: add lead.dialer permission to RbacController.<commit_after><?php

namespace console\controllers;

use common\models\user\Customer;
use common\models\user\User;
use common\models\user\Worker;
use common\rbac\OwnModelRule;
use Exception;
use Yii;
use yii\base\InvalidArgumentException;
use yii\console\Controller;
use yii\helpers\Console;
use yii\rbac\Item;
use yii\rbac\Permission;
use yii\rbac\Role;

/**
 * Class RbacController
 *
 * @author <NAME> <<EMAIL>>
 */
class RbacController extends Controller {

	public array $roles = [
		Worker::ROLE_AGENT,
		Worker::ROLE_CO_AGENT,
		Worker::ROLE_BOOKKEEPER,
		Worker::ROLE_CUSTOMER_SERVICE,
		Worker::ROLE_LAWYER,
		Worker::ROLE_LAWYER_ASSISTANT,
		Worker::ROLE_TELEMARKETER,
		Customer::ROLE_CUSTOMER,
		Customer::ROLE_VICTIM,
		Customer::ROLE_SHAREHOLDER,
		Customer::ROLE_HANDICAPPED,
		User::ROLE_RECCOMENDING,
	];

	public array $permissions = [
		User::PERMISSION_ARCHIVE,
		Worker::PERMISSION_COST => [
			Worker::ROLE_BOOKKEEPER,
		],
		Worker::PERMISSION_COST_DEBT => [
			Worker::ROLE_BOOKKEEPER,
		],
		Worker::PERMISSION_CALCULATION_TO_CREATE => [
			Worker::ROLE_BOOKKEEPER,
		],
		Worker::PERMISSION_CALCULATION_UPDATE => [
			Worker::ROLE_BOOKKEEPER,
		],
		Worker::PERMISSION_CALCULATION_PAYS => [
			Worker::ROLE_BOOKKEEPER,
		],
		Worker::PERMISSION_CALCULATION_PROBLEMS => [
			Worker::ROLE_BOOKKEEPER,
		],
		User::PERMISSION_EXPORT,
		User::PERMISSION_ISSUE,
		Worker::PERMISSION_ISSUE_LINK_USER,
		Worker::PERMISSION_ISSUE_DELETE,
		Worker::PERMISSION_ISSUE_STAGE_CHANGE,
		Worker::PERMISSION_HINT,
		User::PERMISSION_LOGS,
		Worker::PERMISSION_MEET,
		User::PERMISSION_NEWS,
		User::PERMISSION_NOTE,
		Worker::PERMISSION_NOTE_TEMPLATE,
		User::PERMISSION_PROVISION,
		Worker::PERMISSION_PAY => [
			Worker::ROLE_BOOKKEEPER,
		],
		Worker::PERMISSION_PAYS_DELAYED => [
			Worker::ROLE_BOOKKEEPER,
		],
		Worker::PERMISSION_PAY_PART_PAYED => [
			Worker::ROLE_BOOKKEEPER,
		],
		Worker::PERMISSION_PAY_RECEIVED => [
			Worker::ROLE_BOOKKEEPER,
		],
		Worker::PERMISSION_PAY_PAID => [
			Worker::ROLE_BOOKKEEPER,
		],
		Worker::PERMISSION_PAY_UPDATE => [
			Worker::ROLE_BOOKKEEPER,
			Worker::ROLE_AGENT,
		],
		Worker::PERMISSION_PAY_ALL_PAID => [
			Worker::ROLE_BOOKKEEPER,
		],
		Worker::PERMISSION_SUMMON => [
			Worker::ROLE_AGENT,
		],
		Worker::PERMISSION_SUMMON_MANAGER,
		Worker::PERMISSION_SUMMON_CREATE,
		Worker::PERMISSION_SMS,
		Worker::PERMISSION_MULTIPLE_SMS,
		Worker::PERMISSION_WORKERS,
		Worker::PERMISSION_LEAD,
		Worker::PERMISSION_LEAD_DELETE,
		Worker::PERMISSION_LEAD_DIALER,
		Worker::PERMISSION_LEAD_DIALER_MANAGER,
		Worker::PERMISSION_LEAD_DUPLICATE,
		Worker::PERMISSION_LEAD_IMPORT,
		Worker::PERMISSION_LEAD_STATUS,
		Worker::PERMISSION_MESSAGE_TEMPLATE,
		Worker::PERMISSION_PROVISION_CHILDREN_VISIBLE,
	];

	public function actionInit(): void {
		$auth = Yii::$app->authManager;
		$auth->removeAll();

		$user = $auth->createRole(User::ROLE_USER);
		$auth->add($user);

		// own model rule
		$ownModelRule = new OwnModelRule();
		$auth->add($ownModelRule);

		$manager = $auth->createRole(User::ROLE_MANAGER);
		$auth->add($manager);
		$auth->addChild($manager, $user);

		$loginToBackend = $auth->createPermission('loginToBackend');
		$auth->add($loginToBackend);
		$auth->addChild($manager, $loginToBackend);

{'fraction_non_alphanumeric': 0.13059360730593608, 'fraction_numerical': 0.0, 'mean_word_length': 6.088457389428263, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 59, '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': '4317414', 'n_tokens_mistral': 2886, 'n_tokens_neox': 2643, 'n_words': 278}