<?php
/**
 * @copyright (c) Kufer Software GmbH, Oderstraße 7, D-84453 Mühldorf
 */

namespace Kufer\Web\KuferTools\Allgemein\PasswortAendern\PasswortAendern;

class PasswortAendernUseCase extends \Kufer\Web\KuferTools\Basis\UseCase\ToolUseCase
{
  public function __construct($request)
  {
    parent::__construct($request, new PasswortAendernResponse());
  }

  public function hasAccess($pToolSectionId = null)
  {
    if (\Kufer\Web\KuferTools\Utils\LDAP\BaseLoginLDAP::hasEinrichtungTeilnehmerLDAPLogin() && \SessionOperations::isCurrentUserLdapUser()) {
      return false;
    }
    $allgEinstell = \AllgSettingsAPI::getAllgSettings();

    return $allgEinstell->changepwd;
  }

  public static function getToolId()
  {
    return -2;
  }

  public static function getToolSectionId()
  {
    return -2;
  }

  public function action()
  {
    $user = $this->getUser();

    return $this->getResponse($user);
  }

  protected function getResponse($user)
  {
    $this->handleResponseStrategies();

    $tool0settings = \ToolSettingsAPI::getToolSettings(0);

    $this->response->pwAnzahlZeichen = $tool0settings->pwdMinLength;
    $this->response->pwZahlErforderlich = $tool0settings->pwdNumbersRequired;
    $this->response->pwGrossKleinBuchstabenErforderlich = $tool0settings->pwdLowerUpperRequired;
    $this->response->pwSonderzeichenErforderlich = $tool0settings->pwdSpecialCharsRequired;

    return $this->response;
  }

  protected function getResponseStrategies()
  {
    return array(
        new \Kufer\Web\KuferTools\Utils\ResponseStrategies\ResponseMitRahmen($this)
    );
  }
}

class PasswortAendernRequest
{
}

class PasswortAendernResponse extends \Kufer\Web\KuferTools\Basis\UseCase\ToolResponse
{
  public $user;
  public $menuPunkte = array();
  public $pwAnzahlZeichen;
  public $pwZahlErforderlich;
  public $pwGrossKleinBuchstabenErforderlich;
  public $pwSonderzeichenErforderlich;
}