@@ 24-65 (lines=42) @@ | ||
21 | * |
|
22 | * @property User $record |
|
23 | */ |
|
24 | class ActivateOperation extends Operation |
|
25 | { |
|
26 | /** |
|
27 | * @inheritdoc |
|
28 | */ |
|
29 | protected function get_controls() |
|
30 | { |
|
31 | return [ |
|
32 | ||
33 | self::CONTROL_PERMISSION => Module::PERMISSION_ADMINISTER, |
|
34 | self::CONTROL_RECORD => true, |
|
35 | self::CONTROL_OWNERSHIP => true |
|
36 | ||
37 | ] + parent::get_controls(); |
|
38 | } |
|
39 | ||
40 | /** |
|
41 | * @inheritdoc |
|
42 | */ |
|
43 | protected function validate(ErrorCollection $errors) |
|
44 | { |
|
45 | return true; |
|
46 | } |
|
47 | ||
48 | /** |
|
49 | * @inheritdoc |
|
50 | */ |
|
51 | protected function process() |
|
52 | { |
|
53 | $record = $this->record; |
|
54 | $record->is_activated = true; |
|
55 | $record->save(); |
|
56 | ||
57 | $this->response->message = $this->format('!name account is active.', [ |
|
58 | ||
59 | '!name' => $record->name |
|
60 | ||
61 | ]); |
|
62 | ||
63 | return true; |
|
64 | } |
|
65 | } |
|
66 |
@@ 25-66 (lines=42) @@ | ||
22 | * |
|
23 | * @property User $record |
|
24 | */ |
|
25 | class DeactivateOperation extends Operation |
|
26 | { |
|
27 | /** |
|
28 | * @inheritdoc |
|
29 | */ |
|
30 | protected function get_controls() |
|
31 | { |
|
32 | return [ |
|
33 | ||
34 | self::CONTROL_PERMISSION => Module::PERMISSION_ADMINISTER, |
|
35 | self::CONTROL_RECORD => true, |
|
36 | self::CONTROL_OWNERSHIP => true |
|
37 | ||
38 | ] + parent::get_controls(); |
|
39 | } |
|
40 | ||
41 | /** |
|
42 | * @inheritdoc |
|
43 | */ |
|
44 | protected function validate(ErrorCollection $errors) |
|
45 | { |
|
46 | return true; |
|
47 | } |
|
48 | ||
49 | /** |
|
50 | * @inheritdoc |
|
51 | */ |
|
52 | protected function process() |
|
53 | { |
|
54 | $record = $this->record; |
|
55 | $record->is_activated = false; |
|
56 | $record->save(); |
|
57 | ||
58 | $this->response->message = $this->format('!name account is deactivated.', [ |
|
59 | ||
60 | '!name' => $record->name |
|
61 | ||
62 | ]); |
|
63 | ||
64 | return true; |
|
65 | } |
|
66 | } |
|
67 |