| 1 | 2 | simandl | <?php |
| 2 | | | |
| 3 | | | namespace Phem\Libraries\Security\Model\Common; |
| 4 | | | |
| 5 | | | use Phem\Core\Object; |
| 6 | | | use Phem\Environment\EnvironmentManager; |
| 7 | | | use Phem\Libraries\Forms\Annotations\Form; |
| 8 | | | use Phem\Libraries\Forms\Annotations\Group as AnnotationGroup; |
| 9 | | | use Phem\Libraries\Forms\Annotations\Input; |
| 10 | | | use Phem\Libraries\Validation\Annotations\Validate; |
| 11 | | | |
| 12 | | | /** |
| 13 | | | * @Form(defaultGroup="newController") |
| 14 | | | */ |
| 15 | | | class Group extends Object |
| 16 | | | { |
| 17 | | | |
| 18 | | | /** |
| 19 | | | * @Input(caption="Id", type="text", maxlength=5) |
| 20 | | | */ |
| 21 | | | protected $id; |
| 22 | | | /** |
| 23 | | | * @Input(caption="NĂĄzev skupiny", type="text", maxlength=32) |
| 24 | | | * @Validate(type="alphanumericext") |
| 25 | | | */ |
| 26 | | | protected $name; |
| 27 | | | /** |
| 28 | | | * @Input(caption="Popisek", type="text", maxlength=32) |
| 29 | | | * @Validate(type="alphanumericext") |
| 30 | | | */ |
| 31 | | | protected $description; |
| 32 | | | |
| 33 | | | public function getId() |
| 34 | | | { |
| 35 | | | return $this->id; |
| 36 | | | } |
| 37 | | | |
| 38 | | | public function setId($id) |
| 39 | | | { |
| 40 | | | $this->id = $id; |
| 41 | | | } |
| 42 | | | |
| 43 | | | public function getName() |
| 44 | | | { |
| 45 | | | return $this->name; |
| 46 | | | } |
| 47 | | | |
| 48 | | | public function setName($name) |
| 49 | | | { |
| 50 | | | $this->name = $name; |
| 51 | | | } |
| 52 | | | |
| 53 | | | public function getDescription() |
| 54 | | | { |
| 55 | | | return $this->description; |
| 56 | | | } |
| 57 | | | |
| 58 | | | public function setDescription($description) |
| 59 | | | { |
| 60 | | | $this->description = $description; |
| 61 | | | } |
| 62 | | | |
| 63 | | | public function save() |
| 64 | | | { |
| 65 | | | if ($this->id == null) |
| 66 | | | EnvironmentManager::getUserManager()->addGroup($this); |
| 67 | | | else |
| 68 | | | { |
| 69 | | | EnvironmentManager::getUserManager()->modifyGroup($this); |
| 70 | | | } |
| 71 | | | } |
| 72 | | | |
| 73 | | | public function delete() |
| 74 | | | { |
| 75 | | | EnvironmentManager::getUserManager()->removeGroup($this); |
| 76 | | | } |
| 77 | | | |
| 78 | | | public function addUser(User $user) |
| 79 | | | { |
| 80 | | | EnvironmentManager::getUserManager()->addUserToGroup($this, $user); |
| 81 | | | } |
| 82 | | | |
| 83 | | | public function removeUser(User $user) |
| 84 | | | { |
| 85 | | | EnvironmentManager::getUserManager()->removeUserFromGroup($this, $user); |
| 86 | | | } |
| 87 | | | |
| 88 | | | public function getTasks() |
| 89 | | | { |
| 90 | | | return EnvironmentManager::getPermissionManager()->getTasks($this); |
| 91 | | | } |
| 92 | | | |
| 93 | | | } |