@@ 491-508 (lines=18) @@ | ||
488 | * If null, use global setting Module::$enableBlockingEmail |
|
489 | * @return bool return false if user already blocked or not confirmed |
|
490 | */ |
|
491 | public function block($sendMail = null) |
|
492 | { |
|
493 | if ($this->isBlocked() || !$this->isConfirmed()) { |
|
494 | return false; |
|
495 | } |
|
496 | if ($sendMail === null) { |
|
497 | $sendMail = $this->module->enableBlockingEmail; |
|
498 | } |
|
499 | $this->updateAttributes([ |
|
500 | 'status' => self::STATUS_BLOCKED |
|
501 | ]); |
|
502 | if ($sendMail) { |
|
503 | $this->module->sendMessage('block', [ |
|
504 | 'user' => $this, |
|
505 | ]); |
|
506 | } |
|
507 | return true; |
|
508 | } |
|
509 | ||
510 | /** |
|
511 | * Unblock user |
|
@@ 516-533 (lines=18) @@ | ||
513 | * If null, use global setting Module::$enableUnblockingEmail |
|
514 | * @return bool return false if user not blocked |
|
515 | */ |
|
516 | public function unblock($sendMail = null) |
|
517 | { |
|
518 | if (!$this->isBlocked()) { |
|
519 | return false; |
|
520 | } |
|
521 | if ($sendMail === null) { |
|
522 | $sendMail = $this->module->enableBlockingEmail; |
|
523 | } |
|
524 | $this->updateAttributes([ |
|
525 | 'status' => self::STATUS_ACTIVE |
|
526 | ]); |
|
527 | if ($sendMail) { |
|
528 | $this->module->sendMessage('unblock', [ |
|
529 | 'user' => $this, |
|
530 | ]); |
|
531 | } |
|
532 | return true; |
|
533 | } |
|
534 | ||
535 | /** |
|
536 | * Change the user password |