Location: PHPKode > projects > DIY Blog > diy-blog/classes/diy-blog/backend/controller/forms/CreateUserForm.class.php
<?php

/**
 * Abstracts user creation request parameters.
 * @package diy-blog.backend.controller.forms
 * @author	Martynas Jusevicius <hide@address.com>
 * @link	http://www.xml.lt
 */

class CreateUserForm extends Form
{
	private $name = null;
	private $password = null;
	private $type = null;
	
	public function __construct(Request $request)
	{
		$this->name = $request->getParameter("name");
		$this->password = $request->getParameter("password");
		$this->type = $request->getParameter("type");
	}
	
	public function getName()
	{
		return $this->name;
	}

	public function getPassword()
	{
		return $this->password;
	}

	public function getType()
	{
		return $this->type;
	}

	public function validate()
	{
		$errors = array();

		if ($this->name == null) $errors[] = new Error("noName");
		if ($this->password == null) $errors[] = new Error("noPassword");
		if (!in_array($this->type, array("admin", "limited"))) $errors[] = new Error("wrongType");

		return $errors;
	}
}

?>
Return current item: DIY Blog