Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
taskonsite-архив-перенесен
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dmitry Korolev
taskonsite-архив-перенесен
Commits
7323ebe8
Commit
7323ebe8
authored
Apr 26, 2016
by
Shakarim Sapa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Добавили метод рассылки по расписанию
parent
bf722066
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
0 deletions
+30
-0
common/modules/blog/controllers/BlogBidController.php
common/modules/blog/controllers/BlogBidController.php
+30
-0
No files found.
common/modules/blog/controllers/BlogBidController.php
View file @
7323ebe8
...
@@ -5,6 +5,8 @@ namespace common\modules\blog\controllers;
...
@@ -5,6 +5,8 @@ namespace common\modules\blog\controllers;
use
common\components\BaseController
;
use
common\components\BaseController
;
use
common\modules\blog\models\BlogBids
;
use
common\modules\blog\models\BlogBids
;
use
common\modules\blog\models\BlogSchedule
;
use
common\modules\triggers\models\TriggerSchedule
;
use
Yii
;
use
Yii
;
use
yii\widgets\ActiveForm
;
use
yii\widgets\ActiveForm
;
use
yii\web\NotFoundHttpException
;
use
yii\web\NotFoundHttpException
;
...
@@ -15,9 +17,37 @@ class BlogBidController extends BaseController {
...
@@ -15,9 +17,37 @@ class BlogBidController extends BaseController {
{
{
return
[
return
[
'Add'
=>
'Subscribe to blog'
,
'Add'
=>
'Subscribe to blog'
,
'Sendbyschedule'
=>
'Рассылка по расписанию блога'
];
];
}
}
public
function
actionSendbyschedule
(){
// Тут хранится идентификатор шаблона для отправки по блогам
$template_id
=
1
;
// Получили текущую дату и время
$date
=
new
\DateTime
();
// Получили все записи в расписании на текущую дату
$schedule
=
BlogSchedule
::
find
()
->
where
([
'date'
=>
$date
->
format
(
'Y-m-d'
)])
->
all
();
// В цикле перебираем записи
foreach
(
$schedule
as
$record
)
{
// Сформировали массив для шаблона
$templateData
=
[];
// Пытаемся произвести отправку
$sended
=
TriggerSchedule
::
sendMessage
(
$record
->
email
,
$template_id
,
$templateData
,
null
);
// Если отправка успешна
if
(
$sended
===
true
)
{
// Получаем запись
/** @var BlogSchedule $model */
$model
=
BlogSchedule
::
findOne
(
$record
->
id
);
// Переключаем параметр sent в состояние 1 (отправлено)
$model
->
sent
=
1
;
// Сохраняем модель
if
(
!
$model
->
save
())
echo
current
(
current
(
$model
->
getErrors
()));
}
}
}
public
function
actionAdd
(){
public
function
actionAdd
(){
Yii
::
$app
->
response
->
format
=
Response
::
FORMAT_JSON
;
Yii
::
$app
->
response
->
format
=
Response
::
FORMAT_JSON
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment