<?php
require_once DAO . 'ManagerDao.php';
require_once DTO . 'LoginDto.php';
final class Login extends Action {
  private $dto;
  public function __construct() {
    $this->dto = new LoginDto();
  }
  protected function getDto() {
    return $this->dto;
  }
  public function index() {
    return new Forward();
  }
  public function apply() {
    $dao = new ManagerDao();
    if (mysql_num_rows($dao->getByPk(array($this->dto->loginId, $this->dto->password))) == 0) {
      $this->setError('ログインIDまたはパスワードが違います。');
      return new Forward();
    }
    session_start();
    $_SESSION['LOGIN'] = 'OK';
    return new Redirect('back/menu');
  }
}
// EOF.
