mirror of
https://github.com/Oreolek/kangana.git
synced 2024-06-16 15:01:09 +03:00
Database and models
This commit is contained in:
parent
17b5de1e7d
commit
061d026cad
|
@ -1,3 +1,46 @@
|
|||
<?php defined('SYSPATH') OR die('No direct access allowed.');
|
||||
/**
|
||||
* Client model.
|
||||
* Client is just a subscriber at the moment.
|
||||
* @package Models
|
||||
* @author Oreolek
|
||||
**/
|
||||
class Model_Client extends ORM {
|
||||
protected $has_many = array(
|
||||
'subscription'
|
||||
);
|
||||
|
||||
/**
|
||||
* @return array validation rules
|
||||
**/
|
||||
public function rules()
|
||||
{
|
||||
return array(
|
||||
'email' => array(
|
||||
array('not_empty'),
|
||||
array('email'),
|
||||
array('min_length', array(':value', 5)),
|
||||
),
|
||||
'name' => array(
|
||||
array('not_empty'),
|
||||
array('min_length', array(':value', 5)),
|
||||
),
|
||||
'token' => array(
|
||||
array('not_empty'),
|
||||
array('numeric')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of field labels.
|
||||
* Used in forms.
|
||||
**/
|
||||
protected $_labels = array(
|
||||
'email' => 'Email',
|
||||
'name' => 'Name',
|
||||
'token' => 'Subscription token'
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,3 +1,38 @@
|
|||
<?php defined('SYSPATH') OR die('No direct access allowed.');
|
||||
/**
|
||||
* Electronic letter model.
|
||||
* Stores HTML to be placed in e-mail template.
|
||||
* @package Models
|
||||
* @author Oreolek
|
||||
**/
|
||||
class Model_Letter extends ORM {
|
||||
protected $belongs_to = array(
|
||||
'subscription'
|
||||
);
|
||||
|
||||
/**
|
||||
* @return array validation rules
|
||||
**/
|
||||
public function rules()
|
||||
{
|
||||
return array(
|
||||
'text' => array(
|
||||
array('not_empty'),
|
||||
array('min_length', array(':value', 20)),
|
||||
),
|
||||
'order' => array(
|
||||
array('numeric')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of field labels.
|
||||
* Used in forms.
|
||||
**/
|
||||
protected $_labels = array(
|
||||
'text' => 'Message text',
|
||||
'order' => 'Message order'
|
||||
);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,3 +1,45 @@
|
|||
<?php defined('SYSPATH') OR die('No direct access allowed.');
|
||||
/**
|
||||
* Subscription model.
|
||||
* Subscription is an ordered collection of letters.
|
||||
* It has a period in days. Every <period> days a client receives a letter from the collection.
|
||||
* @package Models
|
||||
* @author Oreolek
|
||||
**/
|
||||
class Model_Subscription extends ORM {
|
||||
|
||||
/**
|
||||
* @return array validation rules
|
||||
**/
|
||||
public function rules()
|
||||
{
|
||||
return array(
|
||||
'title' => array(
|
||||
array('not_empty'),
|
||||
array('min_length', array(':value', 4)),
|
||||
array('max_length', array(':value', 100)),
|
||||
)
|
||||
'description' => array(
|
||||
array('not_empty'),
|
||||
array('min_length', array(':value', 20)),
|
||||
),
|
||||
'period' => array(
|
||||
array('numeric')
|
||||
),
|
||||
'price' => array(
|
||||
array('numeric')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of field labels.
|
||||
* Used in forms.
|
||||
**/
|
||||
protected $_labels = array(
|
||||
'title' => 'Title',
|
||||
'price' => 'Subscription price',
|
||||
'period' => 'Mailing period (in days)',
|
||||
'description' => 'Description (for the clients)'
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,3 +1,43 @@
|
|||
<?php defined('SYSPATH') OR die('No direct access allowed.');
|
||||
/**
|
||||
* Task model.
|
||||
* Task is a job to send the next letter in a subscription.
|
||||
* @package Models
|
||||
* @author Oreolek
|
||||
**/
|
||||
class Model_Task extends ORM {
|
||||
const STATUS_UNKNOWN = 0;
|
||||
const STATUS_PENDING = 1;
|
||||
const STATUS_SENDING = 2;
|
||||
const STATUS_SENT = 3;
|
||||
|
||||
protected $has_many = array(
|
||||
'letter',
|
||||
'client'
|
||||
);
|
||||
|
||||
/**
|
||||
* @return array validation rules
|
||||
**/
|
||||
public function rules()
|
||||
{
|
||||
return array(
|
||||
'date' => array(
|
||||
array('not_empty'),
|
||||
array('date'),
|
||||
),
|
||||
'status' => array(
|
||||
array('numeric')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of field labels.
|
||||
* Used in forms.
|
||||
**/
|
||||
protected $_labels = array(
|
||||
'date' => 'Mailing date',
|
||||
'status' => 'Status'
|
||||
);
|
||||
}
|
||||
|
|
|
@ -4,5 +4,15 @@ return array(
|
|||
'User login' => 'Вход пользователя',
|
||||
'Authorization error. Please check user login and password.' => 'Ошибка авторизации. Проверьте правильность имени пользователя и пароля.',
|
||||
'Username' => 'Имя пользователя',
|
||||
'Password' => 'Пароль'
|
||||
'Password' => 'Пароль',
|
||||
'Message text' => 'Текст сообщения',
|
||||
'Message order' => 'Порядок сообщения',
|
||||
'Title' => 'Название',
|
||||
'Subscription price' => 'Цена подписки',
|
||||
'Mailing period (in days)' => 'Период рассылки (в днях)',
|
||||
'Description (for the clients)' => 'Описание (для клиентов)',
|
||||
'Email' => 'Email',
|
||||
'Subscription token' => 'Токен подписки',
|
||||
'Mailing date' => 'Дата отправки',
|
||||
'Status' => 'Статус'
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue