src/Entity/UserSettings.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Enum\User\Permission;
  4. use App\Enum\User\PermissionGroup;
  5. use App\Repository\UserSettingsRepository;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Entity(repositoryClass=UserSettingsRepository::class)
  9.  */
  10. class UserSettings
  11. {
  12.     /**
  13.      * @ORM\Id
  14.      * @ORM\GeneratedValue
  15.      * @ORM\Column(type="integer")
  16.      */
  17.     private $id;
  18.     /**
  19.      * @ORM\Column(type="boolean", nullable=true)
  20.      */
  21.     private $canEditCalendarEvents;
  22.     /**
  23.      * @ORM\Column(type="boolean", nullable=true)
  24.      */
  25.     private $canEditStudents;
  26.     /**
  27.      * @ORM\Column(type="boolean", nullable=true)
  28.      */
  29.     private $canViewCandidates;
  30.     /**
  31.      * @ORM\Column(type="boolean", nullable=true)
  32.      */
  33.     private $canEditPayments;
  34.     /**
  35.      * @ORM\Column(type="boolean", nullable=true)
  36.      */
  37.     private $canReviewCandidates;
  38.     /**
  39.      * @ORM\Column(type="boolean", nullable=true)
  40.      */
  41.     private $canViewStudents;
  42.     /**
  43.      * @ORM\Column(type="boolean", nullable=true)
  44.      */
  45.     private $canViewCalendarEvents;
  46.     /**
  47.      * @ORM\Column(type="boolean", nullable=true)
  48.      */
  49.     private $canViewZoomReport;
  50.     /**
  51.      * @ORM\Column(type="boolean", nullable=true)
  52.      */
  53.     private $canViewPaymentsReport;
  54.     /**
  55.      * @ORM\Column(type="boolean", nullable=true)
  56.      */
  57.     private $canViewStudentsPersonalData;
  58.     /**
  59.      * @ORM\Column(type="boolean", nullable=true)
  60.      */
  61.     private $canViewPayments;
  62.     /**
  63.      * @ORM\Column(type="boolean", nullable=true)
  64.      */
  65.     private $canEditCandidates;
  66.     /**
  67.      * @ORM\Column(type="boolean", nullable=true)
  68.      */
  69.     private $canViewCampaigns;
  70.     /**
  71.      * @ORM\Column(type="boolean", nullable=true)
  72.      */
  73.     private $canViewPaymentRequisites;
  74.     /**
  75.      * @ORM\Column(type="boolean", nullable=true)
  76.      */
  77.     private $canSendCampaigns;
  78.     /**
  79.      * @ORM\Column(type="boolean", nullable=true)
  80.      */
  81.     private $canUseTestFeatures;
  82.     /**
  83.      * @ORM\Column(type="boolean", nullable=true)
  84.      */
  85.     private $canRemovePayments;
  86.     /**
  87.      * @ORM\Column(type="boolean", nullable=true)
  88.      */
  89.     private $canCompareTable;
  90.     public function getId(): ?int
  91.     {
  92.         return $this->id;
  93.     }
  94.     public function isCanEditCalendarEvents(): ?bool
  95.     {
  96.         return $this->canEditCalendarEvents;
  97.     }
  98.     public function setCanEditCalendarEvents(?bool $canEditCalendarEvents): self
  99.     {
  100.         $this->canEditCalendarEvents $canEditCalendarEvents;
  101.         return $this;
  102.     }
  103.     public function isCanEditStudents(): ?bool
  104.     {
  105.         return $this->canEditStudents;
  106.     }
  107.     public function setCanEditStudents(?bool $canEditStudents): self
  108.     {
  109.         $this->canEditStudents $canEditStudents;
  110.         return $this;
  111.     }
  112.     public function isCanViewCandidates(): ?bool
  113.     {
  114.         return $this->canViewCandidates;
  115.     }
  116.     public function setCanViewCandidates(?bool $canViewCandidates): self
  117.     {
  118.         $this->canViewCandidates $canViewCandidates;
  119.         return $this;
  120.     }
  121.     public function isCanEditPayments(): ?bool
  122.     {
  123.         return $this->canEditPayments;
  124.     }
  125.     public function setCanEditPayments(?bool $canEditPayments): self
  126.     {
  127.         $this->canEditPayments $canEditPayments;
  128.         return $this;
  129.     }
  130.     public function isCanReviewCandidates(): ?bool
  131.     {
  132.         return $this->canReviewCandidates;
  133.     }
  134.     public function setCanReviewCandidates(?bool $canReviewCandidates): self
  135.     {
  136.         $this->canReviewCandidates $canReviewCandidates;
  137.         return $this;
  138.     }
  139.     public function isCanViewStudents(): ?bool
  140.     {
  141.         return $this->canViewStudents;
  142.     }
  143.     public function setCanViewStudents(?bool $canViewStudents): self
  144.     {
  145.         $this->canViewStudents $canViewStudents;
  146.         return $this;
  147.     }
  148.     public function isCanViewCalendarEvents(): ?bool
  149.     {
  150.         return $this->canViewCalendarEvents;
  151.     }
  152.     public function setCanViewCalendarEvents(?bool $canViewCalendarEvents): self
  153.     {
  154.         $this->canViewCalendarEvents $canViewCalendarEvents;
  155.         return $this;
  156.     }
  157.     public function isCanViewZoomReport(): ?bool
  158.     {
  159.         return $this->canViewZoomReport;
  160.     }
  161.     public function setCanViewZoomReport(?bool $canViewZoomReport): self
  162.     {
  163.         $this->canViewZoomReport $canViewZoomReport;
  164.         return $this;
  165.     }
  166.     public function isCanViewPaymentsReport(): ?bool
  167.     {
  168.         return $this->canViewPaymentsReport;
  169.     }
  170.     public function setCanViewPaymentsReport(?bool $canViewPaymentsReport): self
  171.     {
  172.         $this->canViewPaymentsReport $canViewPaymentsReport;
  173.         return $this;
  174.     }
  175.     public function isCanViewStudentsPersonalData(): ?bool
  176.     {
  177.         return $this->canViewStudentsPersonalData;
  178.     }
  179.     public function setCanViewStudentsPersonalData(?bool $canViewStudentsPersonalData): self
  180.     {
  181.         $this->canViewStudentsPersonalData $canViewStudentsPersonalData;
  182.         return $this;
  183.     }
  184.     public function isCanViewPayments(): ?bool
  185.     {
  186.         return $this->canViewPayments;
  187.     }
  188.     public function setCanViewPayments(?bool $canViewPayments): self
  189.     {
  190.         $this->canViewPayments $canViewPayments;
  191.         return $this;
  192.     }
  193.     public function setPermission(string $keybool $value): self
  194.     {
  195.         $this->$key $value;
  196.         return $this;
  197.     }
  198.     public function getPermission(string $key): bool
  199.     {
  200.         return $this->$key ?? false;
  201.     }
  202.     public function getAllPermissionsGrouped(array $options null): array
  203.     {
  204.         $options array_merge([
  205.             'grantedOnly' => false,
  206.         ], $options ?? []);
  207.         $data = [];
  208.         foreach (PermissionGroup::getAsArray() as $group) {
  209.             $data[$group] = [
  210.                 "text" => PermissionGroup::getText($group),
  211.                 "permissions" => [],
  212.             ];
  213.             foreach (Permission::getAsArray() as $permission) {
  214.                 if (PermissionGroup::getGroup($permission) === $group) {
  215.                     if ($options['grantedOnly'] && !$this->getPermission($permission)) {
  216.                         continue;
  217.                     }
  218.                     $data[$group]["permissions"][$permission] = [
  219.                         "text" => Permission::getText($permission),
  220.                         "value" => $this->getPermission($permission),
  221.                         "shortText" => Permission::getShortText($permission),
  222.                     ];
  223.                 }
  224.             }
  225.         }
  226.         return $data;
  227.     }
  228.     public function isCanEditCandidates(): ?bool
  229.     {
  230.         return $this->canEditCandidates;
  231.     }
  232.     public function setCanEditCandidates(?bool $canEditCandidates): self
  233.     {
  234.         $this->canEditCandidates $canEditCandidates;
  235.         return $this;
  236.     }
  237.     public function isCanViewCampaigns(): ?bool
  238.     {
  239.         return $this->canViewCampaigns;
  240.     }
  241.     public function setCanViewCampaigns(?bool $canViewCampaigns): self
  242.     {
  243.         $this->canViewCampaigns $canViewCampaigns;
  244.         return $this;
  245.     }
  246.     public function isCanViewPaymentRequisites(): ?bool
  247.     {
  248.         return $this->canViewPaymentRequisites;
  249.     }
  250.     public function setCanViewPaymentRequisites(?bool $canViewPaymentRequisites): self
  251.     {
  252.         $this->canViewPaymentRequisites $canViewPaymentRequisites;
  253.         return $this;
  254.     }
  255.     public function isCanSendCampaigns(): ?bool
  256.     {
  257.         return $this->canSendCampaigns;
  258.     }
  259.     public function setCanSendCampaigns(?bool $canSendCampaigns): self
  260.     {
  261.         $this->canSendCampaigns $canSendCampaigns;
  262.         return $this;
  263.     }
  264.     public function isCanUseTestFeatures(): ?bool
  265.     {
  266.         return $this->canUseTestFeatures;
  267.     }
  268.     public function setCanUseTestFeatures(?bool $canUseTestFeatures): self
  269.     {
  270.         $this->canUseTestFeatures $canUseTestFeatures;
  271.         return $this;
  272.     }
  273.     public function isCanRemovePayments(): ?bool
  274.     {
  275.         return $this->canRemovePayments;
  276.     }
  277.     public function setCanRemovePayments(?bool $canRemovePayments): self
  278.     {
  279.         $this->canRemovePayments $canRemovePayments;
  280.         return $this;
  281.     }
  282.     public function isCanCompareTable(): ?bool
  283.     {
  284.         return $this->canCompareTable;
  285.     }
  286.     public function setCanCompareTable(?bool $canCompareTable): self
  287.     {
  288.         $this->canCompareTable $canCompareTable;
  289.         return $this;
  290.     }
  291. }