mirror of
https://github.com/Oreolek/kangana.git
synced 2024-06-28 20:55:09 +03:00
DAR-15: instant message subscriptions
This commit is contained in:
parent
f421dc7884
commit
09fc6bb843
|
@ -10,13 +10,13 @@ class Controller_Instant extends Controller_Layout {
|
||||||
protected $controls = array(
|
protected $controls = array(
|
||||||
'subject' => 'input',
|
'subject' => 'input',
|
||||||
'text' => 'textarea',
|
'text' => 'textarea',
|
||||||
'is_draft' => 'checkbox'
|
|
||||||
);
|
);
|
||||||
public function action_create()
|
public function action_create()
|
||||||
{
|
{
|
||||||
$this->template = new View_Edit;
|
$this->template = new View_Edit;
|
||||||
$id = $this->request->param('id');
|
$id = $this->request->param('id');
|
||||||
if (!Model_Course::exists($id))
|
$subscription = ORM::factory('Subscription', $id);
|
||||||
|
if (!$subscription->loaded())
|
||||||
{
|
{
|
||||||
$this->redirect('error/500');
|
$this->redirect('error/500');
|
||||||
}
|
}
|
||||||
|
@ -54,4 +54,24 @@ class Controller_Instant extends Controller_Layout {
|
||||||
}
|
}
|
||||||
$this->_edit($model);
|
$this->_edit($model);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function action_send()
|
||||||
|
{
|
||||||
|
$this->template = new View_Message;
|
||||||
|
$this->template->title = __('Send instant to all subscribers');
|
||||||
|
$id = $this->request->param('id');
|
||||||
|
$model = ORM::factory('Instant', $id);
|
||||||
|
if (!$model->loaded())
|
||||||
|
{
|
||||||
|
$this->redirect('error/404');
|
||||||
|
}
|
||||||
|
$subscription = ORM::factory('Subscription', $model->subscription_id)->with('clients');
|
||||||
|
$clients = $subscription->clients->find_all();
|
||||||
|
foreach ($clients as $client)
|
||||||
|
{
|
||||||
|
$model->send($client->email, $client->token);
|
||||||
|
}
|
||||||
|
$model->save();
|
||||||
|
$this->template->message = __('The instant has been sent.');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,6 @@ class Controller_Subscription extends Controller_Layout {
|
||||||
protected $controls = array(
|
protected $controls = array(
|
||||||
'title' => 'input',
|
'title' => 'input',
|
||||||
'description' => 'textarea',
|
'description' => 'textarea',
|
||||||
'welcome' => 'textarea'
|
|
||||||
// 'price' => 'input'
|
// 'price' => 'input'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -24,9 +24,6 @@ class Model_Instant extends ORM {
|
||||||
array('not_empty'),
|
array('not_empty'),
|
||||||
array('min_length', array(':value', 20)),
|
array('min_length', array(':value', 20)),
|
||||||
),
|
),
|
||||||
'is_draft' => array(
|
|
||||||
array('numeric')
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +34,7 @@ class Model_Instant extends ORM {
|
||||||
protected $_labels = array(
|
protected $_labels = array(
|
||||||
'text' => 'Message text',
|
'text' => 'Message text',
|
||||||
'subject' => 'Message subject',
|
'subject' => 'Message subject',
|
||||||
'is_draft' => 'Is a draft?'
|
'sent' => 'Is sent?'
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -47,6 +44,7 @@ class Model_Instant extends ORM {
|
||||||
**/
|
**/
|
||||||
public function send($address, $token = '')
|
public function send($address, $token = '')
|
||||||
{
|
{
|
||||||
|
$this->sent = TRUE;
|
||||||
return self::_send($address, $this->text, $this->subject, $token);
|
return self::_send($address, $this->text, $this->subject, $token);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
**/
|
**/
|
||||||
class Model_Subscription extends ORM {
|
class Model_Subscription extends ORM {
|
||||||
protected $_has_many = array(
|
protected $_has_many = array(
|
||||||
'client' => array(
|
'clients' => array(
|
||||||
'model' => 'Client',
|
'model' => 'Client',
|
||||||
'through' => 'clients_subscriptions'
|
'through' => 'clients_subscriptions'
|
||||||
),
|
),
|
||||||
|
|
|
@ -22,8 +22,15 @@ class View_Instant_Index extends View_Index {
|
||||||
$output = array(
|
$output = array(
|
||||||
'description' => $item->text,
|
'description' => $item->text,
|
||||||
'view_link' => $item->subject,//HTML::anchor(Route::url('default', array('controller' => 'Letter', 'action' => 'view','id' => $item->id)), $item->subject, 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' => 'Instant', 'action' => 'edit','id' => $item->id)), __('Edit'), array('class' => 'link_edit')),
|
'is_sent' => __('Sent'),
|
||||||
|
'edit_link' => FALSE,
|
||||||
|
'send_button' => HTML::anchor(Route::url('default', array('controller' => 'Instant', 'action' => 'send','id' => $item->id)), Form::btn('send', 'Send to subscribers')),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if ($item->sent == 0)
|
||||||
|
{
|
||||||
|
$output['edit_link'] = HTML::anchor(Route::url('default', array('controller' => 'Instant', 'action' => 'edit','id' => $item->id)), __('Edit'), array('class' => 'link_edit'));
|
||||||
|
}
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,5 +58,8 @@ return array(
|
||||||
'Page drafts' => 'Черновики страниц',
|
'Page drafts' => 'Черновики страниц',
|
||||||
'Page index' => 'Список страниц',
|
'Page index' => 'Список страниц',
|
||||||
'Delete page' => 'Удалить страницу',
|
'Delete page' => 'Удалить страницу',
|
||||||
'Welcome message' => 'Приветственное сообщение'
|
'Welcome message' => 'Приветственное сообщение',
|
||||||
|
'Sent' => 'Отправлено',
|
||||||
|
'Send instant to all subscribers' => 'Отослать мгновенное всем подписчикам',
|
||||||
|
'The instant has been sent.' => 'Мгновенное было выслано.'
|
||||||
);
|
);
|
||||||
|
|
|
@ -12,6 +12,10 @@
|
||||||
{{#edit_link}}
|
{{#edit_link}}
|
||||||
<td>{{{edit_link}}}</td>
|
<td>{{{edit_link}}}</td>
|
||||||
{{/edit_link}}
|
{{/edit_link}}
|
||||||
|
{{^edit_link}}
|
||||||
|
<td>{{is_sent}}</td>
|
||||||
|
{{/edit_link}}
|
||||||
|
<td>{{{send_button}}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{{/get_items}}
|
{{/get_items}}
|
||||||
</table>
|
</table>
|
||||||
|
|
Loading…
Reference in a new issue