<?php
/**
 * @copyright (c) Kufer Software GmbH, Loisachstrasse 4, D-84453 Mühldorf
 */

namespace Kufer\KuferTools\Allgemein\PasswortAendern\PasswortAendern;

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

  public function hasAccess($pToolSectionId = null)
  {
    if (\Kufer\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\KuferTools\Utils\ResponseStrategies\ResponseMitRahmen($this)
    );
  }
}

class PasswortAendernRequest
{
}

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