<?php defined('SYSPATH') or die('No direct script access.');
class Controller_Signup extends Controller_Template {
public function action_index()
{
$errors = null;
if($_POST) {
$_POST = Arr::map('trim', $_POST);
$post = Validation::factory($_POST);
$post->rule('login', 'not_empty');
$post->rule('login', 'alpha_dash', array(':value', TRUE));
$post->rule('login', 'min_length', array(':value', 3));
$post->rule('login', 'max_length', array(':value', 20));
$post->rule('email', 'not_empty');
$post->rule('email', 'email');
$post->rule('password', 'not_empty');
$post->rule('password', 'min_length', array(':value', 8));
$post->rule('confirm', 'not_empty');
$post->rule('confirm', 'matches', array(':validation', 'confirm', 'password'));
if($post->check()) {
/* тут вызвать модель для записи юзера */
return true;
} else $errors = $post->errors('signup');
}
$content = View::factory('signup');
$content->errors = $errors;
$this->template->title = 'Регистрация';
$this->template->content = $content;
}
}