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
36128716
Commit
36128716
authored
Jan 29, 2016
by
Олег Гиммельшпах
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix Session model
parent
a1417a55
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
199 deletions
+0
-199
common/modules/testings/models/Session.php
common/modules/testings/models/Session.php
+0
-199
No files found.
common/modules/testings/models/Session.php
View file @
36128716
...
@@ -189,203 +189,4 @@ class Session extends \common\components\ActiveRecordModel
...
@@ -189,203 +189,4 @@ class Session extends \common\components\ActiveRecordModel
unlink
(
$this
->
file
);
unlink
(
$this
->
file
);
}
}
}
}
public
function
sendMailByList
(
$users
)
{
for
(
$i
=
0
;
$i
<
count
(
$users
);
$i
++
)
{
$dublicates
=
array
(
$users
[
$i
]);
$email
=
$users
[
$i
]
->
email
;
$users
[
$i
]
=
null
;
for
(
$j
=
0
;
$j
<
count
(
$users
);
$j
++
)
{
if
(
$users
[
$j
]
&&
$email
==
$users
[
$j
]
->
email
)
{
array_push
(
$dublicates
,
$users
[
$j
]);
$users
[
$j
]
=
null
;
}
}
if
(
isset
(
$dublicates
[
0
]))
{
$this
->
sendMessage
(
$dublicates
);
}
}
}
private
function
sendMessage
(
$users
)
{
if
(
!
is_array
(
$users
)
||
count
(
$users
)
==
1
)
{
if
(
is_array
(
$users
))
{
$model
=
$users
[
0
];
}
$tests
=
$model
->
assignedTestsForSession
(
$this
->
id
);
if
(
$tests
)
{
if
(
count
(
$tests
)
>
1
)
{
$this
->
sendEmailToUser_MultipleTest
(
$model
,
$tests
,
$this
->
id
);
}
else
{
$this
->
sendEmailToUser_SingleTest
(
$model
,
$tests
,
$this
->
id
);
}
}
unset
(
$tests
);
}
else
{
$this
->
sendEmailToUser_MultipleUser
(
$users
,
$this
->
id
);
}
}
public
function
sendEmailToUser_MultipleTest
(
$user
,
$tests
,
$session_id
,
$notified
=
false
)
{
if
(
$notified
)
{
$body
=
Setting
::
getValue
(
'email_testing_passing_tracking_body'
);
$subject
=
Setting
::
getValue
(
'email_testing_passing_tracking_subject'
);
}
else
{
$body
=
Setting
::
getValue
(
'email_multiple_test_notice_body'
);
$subject
=
Setting
::
getValue
(
'email_test_notice_head'
);
}
$test_list
=
'<ul>'
;
$test_time_list
=
'<ul>'
;
$test_pass_limit_list
=
'<ul>'
;
foreach
(
$tests
as
$test
)
{
if
(
$test
->
name
!=
'.'
)
$test_list
.=
'<li>"'
.
$test
->
name
.
'"</li>'
;
$test_time_list
.=
'<li>"'
.
$test
->
name
.
'" - не более '
.
$test
->
minutes
.
' минут</li>'
;
$test_pass_limit_list
.=
'<li>"'
.
$test
->
name
.
'" - '
.
$test
->
pass_percent
.
'% правильных ответов от предложенных вопросов</li>'
;
}
$test_list
.=
'</ul>'
;
$test_time_list
.=
'</ul>'
;
$test_pass_limit_list
.=
'</ul>'
;
$history
=
TestingSendHistory
::
model
()
->
findByAttributes
(
array
(
'session_id'
=>
$session_id
,
'user_id'
=>
$user
->
id
));
if
(
!
$history
)
{
$history
=
new
TestingSendHistory
();
}
$history
->
session_id
=
$session_id
;
$history
->
email
=
$user
->
email
;
$history
->
user_id
=
$user
->
id
;
$history
->
unisender_status
=
TestingSendHistory
::
STATUS_NOT_SENT
;
$history
->
save
();
$mailer_letter
=
MailerLetter
::
model
();
$body
=
$mailer_letter
->
compileText
(
$body
,
array
(
'polite'
=>
(
$user
->
sex
==
TestingUser
::
MAN
)
?
'уважаемый'
:
'уважаемая'
,
'user'
=>
$user
,
'password'
=>
$user
->
password
,
'test_list'
=>
$test_list
,
'test_time_list'
=>
$test_time_list
,
'test_pass_limit_list'
=>
$test_pass_limit_list
,
'session'
=>
TestingSession
::
model
()
->
findByPk
(
$session_id
),
'test_info_link'
=>
CHtml
::
link
(
Yii
::
app
()
->
request
->
hostInfo
.
Yii
::
app
()
->
urlManager
->
createUrl
(
'/testings/testingTest'
),
Yii
::
app
()
->
request
->
hostInfo
.
Yii
::
app
()
->
urlManager
->
createUrl
(
'/testings/testingTest'
)),
'test_link'
=>
CHtml
::
link
(
Yii
::
app
()
->
request
->
hostInfo
.
Yii
::
app
()
->
urlManager
->
createUrl
(
'/testings/testingTest'
),
Yii
::
app
()
->
request
->
hostInfo
.
Yii
::
app
()
->
urlManager
->
createUrl
(
'/testings/testingTest'
)),
));
unset
(
$mailer_letter
);
MailerModule
::
sendMailUniSender
(
$user
->
email
,
$subject
,
$body
,
$history
);
}
public
function
sendEmailToUser_SingleTest
(
$user
,
$tests
,
$session_id
,
$notified
=
false
)
{
if
(
$notified
)
{
$body
=
Setting
::
getValue
(
'email_testing_passing_tracking_body'
);
$subject
=
Setting
::
getValue
(
'email_testing_passing_tracking_subject'
);
}
else
{
$body
=
Setting
::
getValue
(
'email_single_test_notice_body'
);
$subject
=
Setting
::
getValue
(
'email_test_notice_head'
);
}
$test_list
=
''
;
$test_time_list
=
''
;
$test_pass_limit_list
=
''
;
foreach
(
$tests
as
$test
)
{
$test_list
=
$test
->
name
;
$test_time_list
=
$test
->
minutes
;
$test_pass_limit_list
=
$test
->
pass_percent
;
}
$history
=
TestingSendHistory
::
model
()
->
findByAttributes
(
array
(
'session_id'
=>
$session_id
,
'user_id'
=>
$user
->
id
));
if
(
!
$history
)
{
$history
=
new
TestingSendHistory
();
}
$history
->
session_id
=
$session_id
;
$history
->
user_id
=
$user
->
id
;
$history
->
email
=
$user
->
email
;
$history
->
unisender_status
=
TestingSendHistory
::
STATUS_NOT_SENT
;
$history
->
save
();
$mailer_letter
=
MailerLetter
::
model
();
$body
=
$mailer_letter
->
compileText
(
$body
,
array
(
'polite'
=>
(
$user
->
sex
==
TestingUser
::
MAN
)
?
'уважаемый'
:
'уважаемая'
,
'user'
=>
$user
,
'password'
=>
$user
->
password
,
'test_list'
=>
$test_list
,
'test_time_list'
=>
$test_time_list
,
'test_pass_limit_list'
=>
$test_pass_limit_list
,
'session'
=>
TestingSession
::
model
()
->
findByPk
(
$session_id
),
'test_info_link'
=>
CHtml
::
link
(
Yii
::
app
()
->
request
->
hostInfo
.
Yii
::
app
()
->
urlManager
->
createUrl
(
'/testings/testingTest'
),
Yii
::
app
()
->
request
->
hostInfo
.
Yii
::
app
()
->
urlManager
->
createUrl
(
'/testings/testingTest'
)),
'test_link'
=>
CHtml
::
link
(
Yii
::
app
()
->
request
->
hostInfo
.
Yii
::
app
()
->
urlManager
->
createUrl
(
'/testings/testingTest'
),
Yii
::
app
()
->
request
->
hostInfo
.
Yii
::
app
()
->
urlManager
->
createUrl
(
'/testings/testingTest'
)),
));
unset
(
$mailer_letter
);
MailerModule
::
sendMailUniSender
(
$user
->
email
,
$subject
,
$body
,
$history
);
}
private
function
sendEmailToUser_MultipleUser
(
$users
,
$session_id
)
{
foreach
(
$users
as
$user
)
{
$body
=
Setting
::
getValue
(
'email_multiple_user_test_notice_body'
);
$subject
=
Setting
::
getValue
(
'email_test_notice_head'
);
$history
=
TestingSendHistory
::
model
()
->
findByAttributes
(
array
(
'session_id'
=>
$session_id
,
'user_id'
=>
$user
->
id
));
if
(
!
$history
)
{
$history
=
new
TestingSendHistory
();
}
$filename
=
$history
->
generateFile
(
$users
,
$session_id
);
$history
->
session_id
=
$session_id
;
$history
->
email
=
$user
->
email
;
$history
->
user_id
=
$user
->
id
;
$history
->
unisender_status
=
TestingSendHistory
::
STATUS_NOT_SENT
;
$history
->
save
();
$attachments
=
array
(
$filename
=>
$history
->
getFilePath
()
);
$mailer_letter
=
MailerLetter
::
model
();
$body
=
$mailer_letter
->
compileText
(
$body
,
array
(
'test_link'
=>
CHtml
::
link
(
Yii
::
app
()
->
controller
->
createAbsoluteUrl
(
'/testings/testingTest'
),
Yii
::
app
()
->
controller
->
createAbsoluteUrl
(
'/testings/testingTest'
)),
));
unset
(
$mailer_letter
);
MailerModule
::
sendMailUniSender
(
$users
[
0
]
->
email
,
$subject
,
$body
,
$history
,
$attachments
);
}
}
}
}
\ No newline at end of file
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