<?php
/**
* Abstracts user editing request parameters.
* @package diy-blog.backend.controller.forms
* @author Martynas Jusevicius <hide@address.com>
* @link http://www.xml.lt
*/
class EditUserForm extends Form
{
private $password = null;
private $newPassword = null;
private $type = null;
public function __construct(Request $request)
{
$this->password = $request->getParameter("password");
$this->newPassword = $request->getParameter("new-password");
$this->type = $request->getParameter("type");
}
public function getPassword()
{
return $this->password;
}
public function getNewPassword()
{
return $this->newPassword;
}
public function getType()
{
return $this->type;
}
public function validate()
{
$errors = array();
if ($this->password == null) $errors[] = new Error("noPassword");
if ($this->newPassword == null) $errors[] = new Error("noNewPassword");
if ($this->type != null && !in_array($this->type, array("admin", "limited"))) $errors[] = new Error("wrongType");
return $errors;
}
}
?>