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
1e8203a4
Commit
1e8203a4
authored
Apr 25, 2016
by
Shakarim Sapa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Добавлена модель для подписок на блоги
parent
48c8eeae
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
106 additions
and
0 deletions
+106
-0
common/modules/blog/models/BlogBids.php
common/modules/blog/models/BlogBids.php
+106
-0
No files found.
common/modules/blog/models/BlogBids.php
0 → 100644
View file @
1e8203a4
<?php
namespace
common\modules\blog\models
;
use
common\models\Settings
;
use
common\modules\users\models\User
;
use
Yii
;
use
\common\modules\testings\models\Session
;
/**
* This is the model class for table "blog_bids".
*
* @property integer $id
* @property string $email
* @property string $date
*/
class
BlogBids
extends
\yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public
static
function
tableName
()
{
return
'blog_bids'
;
}
/**
* @inheritdoc
*/
public
function
rules
()
{
return
[
[[
'email'
,
'date'
],
'required'
],
[[
'email'
],
'unique'
,
'message'
=>
'Вы уже подписаны на новости блога'
],
[[
'date'
],
'safe'
],
[[
'email'
],
'string'
,
'max'
=>
255
],
];
}
/**
* @inheritdoc
*/
public
function
attributeLabels
()
{
return
[
'id'
=>
'ID'
,
'email'
=>
'Email'
,
'date'
=>
'Date'
,
];
}
/**
* @param bool $insert
* @param array $changedAttributes
* @return bool
*/
public
function
afterSave
(
$insert
,
$changedAttributes
)
{
parent
::
afterSave
(
$insert
,
$changedAttributes
);
if
(
!
is_null
(
$this
->
email
))
{
/** @var User $user */
$user
=
User
::
find
()
->
where
([
'email'
=>
$this
->
email
])
->
one
();
if
(
!
is_null
(
$user
))
{
if
(
$this
->
blog
===
false
)
$user
->
afterSubscribe
([
'email'
=>
$this
->
email
],
true
);
else
$user
->
afterSubscribeToBlog
([
'email'
=>
$this
->
email
],
true
);
}
Yii
::
$app
->
cache
->
set
(
'user_email'
,
$this
->
email
);
}
}
public
function
send
()
{
try
{
$session
=
null
;
if
(
Yii
::
$app
->
session
->
has
(
'SessionId'
))
{
$session
=
Session
::
findOne
(
Yii
::
$app
->
session
->
get
(
'SessionId'
));
}
$email
=
Settings
::
getValue
(
'bids-support-email'
);
$message
=
Yii
::
$app
->
controller
->
view
->
render
(
'@common/modules/bids/views/bid/mail-all'
,
[
'model'
=>
$this
,
'session'
=>
$session
,
]);
$headers
=
"MIME-Version: 1.0
\r\n
"
.
"Content-Transfer-Encoding: 8bit
\r\n
"
.
"Content-Type: text/html; charset=
\"
UTF-8
\"\r\n
"
.
"X-Mailer: PHP v."
.
phpversion
()
.
"
\r\n
"
.
"From: Заявка с сайта TaskOn <"
.
Settings
::
getValue
(
'bids-support-email-from'
)
.
">
\r\n
"
;
$subject
=
"Заявка №"
.
$this
->
id
.
". С сайта task-on.com поступила заявка на подписку на блог."
;
@
mail
(
$email
,
$subject
,
$message
,
$headers
);
}
catch
(
Exception
$e
)
{
}
}
}
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