mirror of
https://github.com/Oreolek/kangana.git
synced 2024-06-26 03:40:56 +03:00
Email module
This commit is contained in:
parent
bb0ce9bcbc
commit
0f6ddf60f8
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,5 +1,6 @@
|
||||||
application/config/database.php
|
application/config/database.php
|
||||||
application/config/stats.php
|
application/config/stats.php
|
||||||
|
application/config/email.php
|
||||||
application/config/sphinxql.php
|
application/config/sphinxql.php
|
||||||
application/cache
|
application/cache
|
||||||
application/logs
|
application/logs
|
||||||
|
|
3
.gitmodules
vendored
3
.gitmodules
vendored
|
@ -19,3 +19,6 @@
|
||||||
[submodule "modules/kostache"]
|
[submodule "modules/kostache"]
|
||||||
path = modules/kostache
|
path = modules/kostache
|
||||||
url = git://github.com/zombor/KOstache.git
|
url = git://github.com/zombor/KOstache.git
|
||||||
|
[submodule "modules/email"]
|
||||||
|
path = modules/email
|
||||||
|
url = git@github.com:shadowhand/email.git
|
||||||
|
|
|
@ -112,6 +112,7 @@ Kohana::modules(array(
|
||||||
'less' => MODPATH.'less', // LEaner CSS
|
'less' => MODPATH.'less', // LEaner CSS
|
||||||
'debug-toolbar' => MODPATH.'debug-toolbar', // Debug toolbar
|
'debug-toolbar' => MODPATH.'debug-toolbar', // Debug toolbar
|
||||||
'kostache' => MODPATH.'kostache', // Logic-less Mustache views
|
'kostache' => MODPATH.'kostache', // Logic-less Mustache views
|
||||||
|
'email' => MODPATH.'email', // Electronic mail class
|
||||||
));
|
));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -8,6 +8,7 @@ class Controller_Letter extends Controller_Layout {
|
||||||
'index','create', 'edit', 'delete'
|
'index','create', 'edit', 'delete'
|
||||||
);
|
);
|
||||||
protected $controls = array(
|
protected $controls = array(
|
||||||
|
'subject' => 'input',
|
||||||
'text' => 'textarea',
|
'text' => 'textarea',
|
||||||
'order' => 'input',
|
'order' => 'input',
|
||||||
);
|
);
|
||||||
|
@ -57,18 +58,4 @@ class Controller_Letter extends Controller_Layout {
|
||||||
$this->redirect('/');
|
$this->redirect('/');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public function action_view()
|
|
||||||
{
|
|
||||||
$this->template = new View_Letter_Index;
|
|
||||||
$id = $this->request->param('id');
|
|
||||||
$model = ORM::factory('Subscription', $id)->with('letters');
|
|
||||||
if (!$model->loaded())
|
|
||||||
{
|
|
||||||
$this->redirect('error/404');
|
|
||||||
}
|
|
||||||
$this->template->title = __('Subscription').' '.$model->title;
|
|
||||||
$this->template->items = $model->letters
|
|
||||||
->filter_by_page($this->request->param('page'))
|
|
||||||
->find_all();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,10 @@ class Model_Letter extends ORM {
|
||||||
public function rules()
|
public function rules()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
|
'subject' => array(
|
||||||
|
array('not_empty'),
|
||||||
|
array('max_length', array(':value', 128)),
|
||||||
|
),
|
||||||
'text' => array(
|
'text' => array(
|
||||||
array('not_empty'),
|
array('not_empty'),
|
||||||
array('min_length', array(':value', 20)),
|
array('min_length', array(':value', 20)),
|
||||||
|
@ -32,6 +36,7 @@ class Model_Letter extends ORM {
|
||||||
**/
|
**/
|
||||||
protected $_labels = array(
|
protected $_labels = array(
|
||||||
'text' => 'Message text',
|
'text' => 'Message text',
|
||||||
|
'subject' => 'Message subject',
|
||||||
'order' => 'Message order'
|
'order' => 'Message order'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -43,4 +48,17 @@ class Model_Letter extends ORM {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function to send a email to a specified address.
|
||||||
|
* Not suitable for a large-scale use.
|
||||||
|
* @param email $address email address
|
||||||
|
* TODO: render text in HTML template
|
||||||
|
**/
|
||||||
|
public function send($address)
|
||||||
|
{
|
||||||
|
$sender = Kohana::$config->load('email')->get('sender');
|
||||||
|
$email = Email::factory($this->subject, $this->text)->to($address)->from($sender);
|
||||||
|
return $email->send();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ class View_Letter_Index extends View_Index {
|
||||||
|
|
||||||
$output = array(
|
$output = array(
|
||||||
'description' => $item->text,
|
'description' => $item->text,
|
||||||
'view_link' => HTML::anchor(Route::url('default', array('controller' => 'Letter', 'action' => 'view','id' => $item->id)),__('View'), array('class' => 'link_view')),
|
'view_link' => $item->subject,//HTML::anchor(Route::url('default', array('controller' => 'Letter', 'action' => 'view','id' => $item->id)), $item->subject, array('class' => 'link_view')),
|
||||||
'edit_link' => HTML::anchor(Route::url('default', array('controller' => 'Letter', 'action' => 'edit','id' => $item->id)), __('Edit'), array('class' => 'link_edit')),
|
'edit_link' => HTML::anchor(Route::url('default', array('controller' => 'Letter', 'action' => 'edit','id' => $item->id)), __('Edit'), array('class' => 'link_edit')),
|
||||||
'delete_link' => HTML::anchor(Route::url('default', array('controller' => 'Letter', 'action' => 'delete','id' => $item->id)), __('Delete'), array('class' => 'link_delete')),
|
'delete_link' => HTML::anchor(Route::url('default', array('controller' => 'Letter', 'action' => 'delete','id' => $item->id)), __('Delete'), array('class' => 'link_delete')),
|
||||||
);
|
);
|
||||||
|
|
12
application/config/email.php.example
Normal file
12
application/config/email.php.example
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
<?php defined('SYSPATH') OR die('No direct access allowed.');
|
||||||
|
return array(
|
||||||
|
'driver' => 'smtp',
|
||||||
|
'sender' => array('sender@example.com', 'Sender Name'),
|
||||||
|
'options' => array(
|
||||||
|
'hostname' => '',
|
||||||
|
'username' => '',
|
||||||
|
'password' => '',
|
||||||
|
'port' => '465',
|
||||||
|
'encryption' => 'tls'
|
||||||
|
),
|
||||||
|
);
|
|
@ -32,5 +32,6 @@ return array(
|
||||||
'New letter' => 'Новое письмо',
|
'New letter' => 'Новое письмо',
|
||||||
'Letter editing' => 'Редактирование письма',
|
'Letter editing' => 'Редактирование письма',
|
||||||
'Delete letter' => 'Удалить письмо',
|
'Delete letter' => 'Удалить письмо',
|
||||||
'View' => 'Просмотреть'
|
'View' => 'Просмотреть',
|
||||||
|
'Message subject' => 'Тема письма',
|
||||||
);
|
);
|
||||||
|
|
1
modules/email
Submodule
1
modules/email
Submodule
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 6005b3965b395b7fae5ac50e9fa58452bfcf6453
|
Loading…
Reference in a new issue