Можно логиниться и регистрироваться (хотя валидация ещё глючит).
Есть несколько заглушек.
This commit is contained in:
parent
89b42198c9
commit
d77d8abeb3
|
@ -115,6 +115,6 @@ Kohana::modules(array(
|
|||
*/
|
||||
Route::set('default', '(<controller>(/<action>(/<id>)))')
|
||||
->defaults(array(
|
||||
'controller' => 'login',
|
||||
'controller' => 'copyright',
|
||||
'action' => 'view',
|
||||
));
|
||||
|
|
8
application/classes/controller/copyright.php
Normal file
8
application/classes/controller/copyright.php
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?php defined('SYSPATH') or die('No direct script access.');
|
||||
|
||||
class Controller_Copyright extends Controller_Template {
|
||||
public $template = 'copyright';
|
||||
public function action_view() {
|
||||
$this->template->year = date("Y",strtotime("-70 years", mktime(0, 0, 0, 1, 1, date("Y"))));
|
||||
}
|
||||
}
|
17
application/classes/controller/games.php
Normal file
17
application/classes/controller/games.php
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?php defined('SYSPATH') or die('No direct script access.');
|
||||
|
||||
class Controller_Games extends Controller_Template {
|
||||
public $template = 'games/add';
|
||||
public function action_add() {
|
||||
//$this->template = 'games/add';
|
||||
if ($_POST){
|
||||
$user = ORM::factory('user');
|
||||
if (Auth::instance()->login('author')){
|
||||
$game = ORM::factory('game');
|
||||
$game->values($this->request->post());
|
||||
$game->create();
|
||||
}
|
||||
else $this->template->error = "Недостаточно прав для добавления игры. Обратитесь за помощью к администратору сервиса.";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,7 +5,7 @@ class Controller_Navigation extends Controller_Template {
|
|||
public function action_actions() {
|
||||
$this->template = new View('navigation/actions');
|
||||
$login_or_logout = HTML::anchor('login', 'Вход');
|
||||
if (Kohana::config('common.vote_opens') > new DateTime('now')) $login_or_logout .= "</li><li>".HTML::anchor('register', 'Регистрация');
|
||||
if (Kohana::config('common.vote_opens') > date("Y-m-d")) $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', 'Выход');
|
||||
|
|
|
@ -4,18 +4,24 @@ 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 (Kohana::config('common.vote_opens') <= date("Y-m-d")) $this->template = 'registration/closed';
|
||||
if ($_POST){
|
||||
if (Kohana::config('common.vote_opens') <= new DateTime('now')){
|
||||
if (Kohana::config('common.vote_opens') <= date("Y-m-d")){
|
||||
$this->template->error = "Регистрация закрыта.";
|
||||
return;
|
||||
}
|
||||
$user = ORM::factory('user');
|
||||
$status = Auth::instance()->login($_POST['login'], $_POST['password']);
|
||||
if ($status){
|
||||
return $this->request->redirect('');
|
||||
$data = arr::extract($_POST, array('username', 'password', 'email', 'password_confirm'));
|
||||
$user = ORM::factory('user')->values($data);
|
||||
if ($user->check()){
|
||||
$user->create();
|
||||
$login_role = new Model_Role(array('name' =>'login'));
|
||||
$author_role = new Model_Role(array('name' =>'author'));
|
||||
$user->add('roles',$login_role);
|
||||
$user->add('roles',$author_role);
|
||||
Auth::instance()->login($data['login'], $data['password']);
|
||||
$this->request->redirect('');
|
||||
}
|
||||
else $this->template->error = "Ошибка регистрации.";
|
||||
else $this->template->error = $post->errors('register');//"Ошибка валидации.";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
14
application/classes/model/game.php
Normal file
14
application/classes/model/game.php
Normal file
|
@ -0,0 +1,14 @@
|
|||
<?php defined('SYSPATH') or die('No direct script access.');
|
||||
|
||||
class Model_Game extends ORM {
|
||||
protected $_table_columns = array(
|
||||
'id' => array('data_type' => 'int', 'is_nullable' => FALSE),
|
||||
'name' => array('data_type' => 'string', 'is_nullable' => FALSE),
|
||||
'description' => array('data_type' => 'mediumtext', 'is_nullable' => FALSE),
|
||||
'file' => array('data_type' => 'file', 'is_nullable' => FALSE),
|
||||
'group' => array('data_type' => 'int', 'is_nullable' => TRUE),
|
||||
);
|
||||
protected $has_many = array(
|
||||
'author' => array('model'=>'user')
|
||||
);
|
||||
}
|
12
application/classes/model/rating.php
Normal file
12
application/classes/model/rating.php
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?php defined('SYSPATH') or die('No direct script access.');
|
||||
|
||||
class Model_Rating extends ORM {
|
||||
protected $_table_columns = array(
|
||||
'id' => array('data_type' => 'int', 'is_nullable' => FALSE),
|
||||
'value' => array('data_type' => 'int', 'is_nullable' => FALSE),
|
||||
);
|
||||
protected $has_many = array(
|
||||
'author' => array('model'=>'user'),
|
||||
'game' => array('model'=>'game'),
|
||||
);
|
||||
}
|
42
application/classes/model/user.php
Normal file
42
application/classes/model/user.php
Normal file
|
@ -0,0 +1,42 @@
|
|||
<?php defined('SYSPATH') OR die('No direct access allowed.');
|
||||
class Model_User extends Model_Auth_User {
|
||||
protected $_rules = array(
|
||||
'username' => array(
|
||||
'not_empty' => NULL,
|
||||
'min_length' => array(4),
|
||||
'max_length' => array(32),
|
||||
'regex' => array('/^[-\pL\pN_.]++$/uD')
|
||||
),
|
||||
'password' => array(
|
||||
'not_empty' => NULL,
|
||||
'min_length' => array(5),
|
||||
'max_length' => array(42)
|
||||
),
|
||||
'email' => array(
|
||||
'not_empty' => NULL,
|
||||
'min_length' => array(5),
|
||||
'max_length' => array(127),
|
||||
'validate::email' => NULL
|
||||
)
|
||||
);
|
||||
|
||||
protected $_callbacks = array(
|
||||
'username' => array('username_available'),
|
||||
'email' => array('email_available')
|
||||
);
|
||||
|
||||
public function validate_create(&$array){
|
||||
$array = Validate::factory($array)
|
||||
->filter(TRUE, 'trim')
|
||||
->rules('username', $this->_rules['username'])
|
||||
->rules('password', $this->_rules['password'])
|
||||
->rules('email', $this->_rules['email']);
|
||||
|
||||
foreach ($this->_callbacks as $field => $callbacks){
|
||||
foreach ($callbacks as $callback){
|
||||
$array->callback($field, array($this, $callback));
|
||||
}
|
||||
}
|
||||
return $array;
|
||||
}
|
||||
}
|
23
application/views/copyright.php
Normal file
23
application/views/copyright.php
Normal file
|
@ -0,0 +1,23 @@
|
|||
<?php echo Request::factory('header/standard')->post('title',"Краткая справка по вопросам авторского права")->post('styles','main.css')->execute() ?>
|
||||
|
||||
<h2>Краткая справка по вопросам авторского права</h2>
|
||||
|
||||
<p>Авторские права истекают через 70 лет после смерти автора. В общественном достоянии находятся произведения, автор которых умер до 1 января <?php echo $year ?> года или произведения, опубликованные анонимно до 1 января <?php echo $year ?> года.</p>
|
||||
|
||||
<p>Кроме того, если автор умер до 1 января 1943 года или произведение опубликовано анонимно до 1 января 1943 года, то произведение находится в общественном достоянии, при условии, что:.</p>
|
||||
|
||||
<ol><li>автор не работал во время ВОВ и не участвовал в ней</li>
|
||||
<li>автор не был реабилитирован после репрессирования</li>
|
||||
<li>произведения были опубликованы при жизни</li>
|
||||
</ol>
|
||||
|
||||
<p>Просим вас проверить свои игры перед отправкой. К объектам авторского права относятся не только литературные произведения, а также картинки и музыка.</p>
|
||||
|
||||
<p>Общественное достояние — это классика. Авторы давно умерли, и если их творение живёт — это хорошо. Иначе авторское право всё ещё действительно и находится у соответствующих правообладателей.
|
||||
Которые и должны решать, можно ли использовать эти работы в ваших играх.</p>
|
||||
|
||||
<p>В качестве альтернативы можно посмотреть в сторону работ, лицензированных по <a href="http://creativecommons.org/licenses/by/3.0/deed.ru">Creative Commons</a>.</p>
|
||||
|
||||
<p>Присуждать призы за нелегальное использование чужих работ — это нечестно. Давайте уважать других авторов!</p>
|
||||
|
||||
<?php echo Request::factory('footer/standard')->execute() ?>
|
13
application/views/games/add.php
Normal file
13
application/views/games/add.php
Normal file
|
@ -0,0 +1,13 @@
|
|||
<?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>
|
||||
<h2>Добавление игры</h2>
|
||||
|
||||
<?php echo form::open('games/add', array('enctype' => 'multipart/form-data')) ?>
|
||||
<p><?php echo form::label('name','Название: '); echo form::input('name','') ?></p>
|
||||
<p><?php echo form::label('description','Описание: '); echo form::input('description','') ?></p>
|
||||
<p><?php echo form::label('file','Файл с игрой: '); echo form::file('file'); ?></p>
|
||||
<p><?php echo form::submit('submit','Отправить') ?></p>
|
||||
<?php echo form::close() ?>
|
||||
<?php echo Request::factory('footer/standard')->execute() ?>
|
|
@ -0,0 +1 @@
|
|||
<li><?php echo HTML::anchor('games', 'Игры'); ?></li>
|
|
@ -4,7 +4,7 @@
|
|||
<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('username','Логин: '); echo form::input('username','') ?></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>
|
||||
|
|
Reference in a new issue