Интерфейс и немного логики регистрации.
Сама регистрация не работает, так как ещё не прикручены юзеры.
This commit is contained in:
parent
a0877cde9f
commit
491c2321da
|
@ -4,7 +4,9 @@ class Controller_Navigation extends Controller_Template {
|
|||
public $template = 'navigation/actions';
|
||||
public function action_actions() {
|
||||
$this->template = new View('navigation/actions');
|
||||
$this->template->login_or_logout = HTML::anchor('login', 'Вход');
|
||||
$login_or_logout = HTML::anchor('login', 'Вход');
|
||||
if (Kohana::config('common.vote_opens') > new DateTime('now')) $login_or_logout .= "</li><li>".HTML::anchor('register', 'Регистрация');
|
||||
$this->template->login_or_logout = $login_or_logout;
|
||||
if (Auth::instance()->logged_in()){
|
||||
$this->template->login_or_logout = HTML::anchor('logout', 'Выход');
|
||||
}
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
<?php defined('SYSPATH') or die('No direct script access.');
|
||||
|
||||
class Controller_Register extends Controller_Template {
|
||||
public $template = 'registration/opened';
|
||||
public function action_view() {
|
||||
if(Auth::instance()->logged_in()) return $this->request->redirect('');
|
||||
if (Kohana::config('common.vote_opens') <= new DateTime('now')) $this->$template = 'registration/closed';
|
||||
if ($_POST){
|
||||
if (Kohana::config('common.vote_opens') <= new DateTime('now')){
|
||||
$this->template->error = "Регистрация закрыта.";
|
||||
return;
|
||||
}
|
||||
$user = ORM::factory('user');
|
||||
$status = Auth::instance()->login($_POST['login'], $_POST['password']);
|
||||
if ($status){
|
||||
return $this->request->redirect('');
|
||||
}
|
||||
else $this->template->error = "Ошибка регистрации.";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,5 +2,6 @@
|
|||
|
||||
return array(
|
||||
'this_year' => "2011",
|
||||
'title' => "Конкурс быстрого программирования «Поихаил!»"
|
||||
);
|
||||
'title' => "Конкурс быстрого программирования «Поихаил!»",
|
||||
'vote_opens' => new DateTime('2011-07-01')
|
||||
);
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
<?php echo Request::factory('header/standard')->post('title',"Регистрация закрыта")->post('styles','main.css')->execute() ?>
|
||||
|
||||
<p>К сожалению, голосование уже началось, а значит, регистрация закрыта.</p>
|
||||
<p>Желаем удачи в следующем конкурсе!</p>
|
||||
|
||||
<?php echo Request::factory('footer/standard')->execute() ?>
|
|
@ -0,0 +1,15 @@
|
|||
<?php echo Request::factory('header/standard')->post('title',"Регистрация")->post('styles','main.css')->execute() ?>
|
||||
|
||||
<div id="error"><?php if(!empty($error)) echo $error;?></div>
|
||||
<div id="message"><?php if(!empty($message)) echo $message;?></div>
|
||||
<p>Введите логин, пароль и e-mail.</p>
|
||||
<?php echo form::open('register') ?>
|
||||
<p><?php echo form::label('login','Логин: '); echo form::input('login','') ?></p>
|
||||
<p><?php echo form::label('email','Электропочта: '); echo form::input('email','') ?></p>
|
||||
<p><?php echo form::label('password','Пароль: '); echo form::password('password','') ?></p>
|
||||
<p><?php echo form::label('password_confirm','Подтверждение пароля: '); echo form::password('password_confirm','') ?></p>
|
||||
<p><?php echo form::submit('submit','Отправить') ?>
|
||||
</p>
|
||||
<?php echo form::close() ?>
|
||||
|
||||
<?php echo Request::factory('footer/standard')->execute() ?>
|
|
@ -42,4 +42,11 @@ img { border: none; }
|
|||
|
||||
.hidden{
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
input[type="text"],input[type="password"]{
|
||||
margin-right: 40%;
|
||||
float: right;
|
||||
}
|
||||
input[type="submit"]{
|
||||
margin-left: 3em;
|
||||
}
|
||||
|
|
Reference in New Issue