| @@ 480-497 (lines=18) @@ | ||
| 477 | * If null, use global setting Module::$enableBlockingEmail |
|
| 478 | * @return bool return false if user already blocked or not confirmed |
|
| 479 | */ |
|
| 480 | public function block($sendMail = null) |
|
| 481 | { |
|
| 482 | if ($this->isBlocked() || !$this->isConfirmed()) { |
|
| 483 | return false; |
|
| 484 | } |
|
| 485 | if ($sendMail === null) { |
|
| 486 | $sendMail = $this->module->enableBlockingEmail; |
|
| 487 | } |
|
| 488 | $this->updateAttributes([ |
|
| 489 | 'status' => self::STATUS_BLOCKED |
|
| 490 | ]); |
|
| 491 | if ($sendMail) { |
|
| 492 | $this->module->sendMessage('block', [ |
|
| 493 | 'user' => $this, |
|
| 494 | ]); |
|
| 495 | } |
|
| 496 | return true; |
|
| 497 | } |
|
| 498 | ||
| 499 | /** |
|
| 500 | * Unblock user |
|
| @@ 505-522 (lines=18) @@ | ||
| 502 | * If null, use global setting Module::$enableUnblockingEmail |
|
| 503 | * @return bool return false if user not blocked |
|
| 504 | */ |
|
| 505 | public function unblock($sendMail = null) |
|
| 506 | { |
|
| 507 | if (!$this->isBlocked()) { |
|
| 508 | return false; |
|
| 509 | } |
|
| 510 | if ($sendMail === null) { |
|
| 511 | $sendMail = $this->module->enableBlockingEmail; |
|
| 512 | } |
|
| 513 | $this->updateAttributes([ |
|
| 514 | 'status' => self::STATUS_ACTIVE |
|
| 515 | ]); |
|
| 516 | if ($sendMail) { |
|
| 517 | $this->module->sendMessage('unblock', [ |
|
| 518 | 'user' => $this, |
|
| 519 | ]); |
|
| 520 | } |
|
| 521 | return true; |
|
| 522 | } |
|
| 523 | ||
| 524 | /** |
|
| 525 | * Change the user password |
|