Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
moodle-tool_lifecycle
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elc
moodle-tool_lifecycle
Commits
c5b09e2b
Unverified
Commit
c5b09e2b
authored
8 years ago
by
Tobias Reischmann
Browse files
Options
Downloads
Patches
Plain Diff
Added basic functionality for bulk sending mails
parent
ece340e1
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
classes/manager/step_manager.php
+14
-0
14 additions, 0 deletions
classes/manager/step_manager.php
classes/task/process_cleanup.php
+1
-1
1 addition, 1 deletion
classes/task/process_cleanup.php
step/email/lib.php
+27
-0
27 additions, 0 deletions
step/email/lib.php
with
42 additions
and
1 deletion
classes/manager/step_manager.php
+
14
−
0
View file @
c5b09e2b
...
...
@@ -104,6 +104,20 @@ class step_manager extends subplugin_manager {
return
$steps
;
}
/**
* Gets the list of step instances for a specific subpluginname.
* @return step_subplugin[] array of step instances.
*/
public
static
function
get_step_instances_by_subpluginname
(
$subpluginname
)
{
global
$DB
;
$records
=
$DB
->
get_records
(
'tool_cleanupcourses_step'
,
array
(
'subpluginname'
=>
$subpluginname
));
$steps
=
array
();
foreach
(
$records
as
$id
=>
$record
)
{
$steps
[
$id
]
=
step_subplugin
::
from_record
(
$record
);
}
return
$steps
;
}
/**
* Gets a specific step instance.
* @param int $instanceid id of the instance
...
...
This diff is collapsed.
Click to expand it.
classes/task/process_cleanup.php
+
1
−
1
View file @
c5b09e2b
...
...
@@ -39,7 +39,7 @@ class process_cleanup extends \core\task\scheduled_task {
$processor
->
call_trigger
();
$steps
=
step_manager
::
get_step_types
();
/*
*
@var \tool_cleanupcourses\step\base[] $steplibs stores the lib classes of all step subplugins.*/
/* @var \tool_cleanupcourses\step\base[] $steplibs stores the lib classes of all step subplugins.*/
$steplibs
=
array
();
foreach
(
$steps
as
$id
=>
$step
)
{
$steplibs
[
$id
]
=
lib_manager
::
get_step_lib
(
$id
);
...
...
This diff is collapsed.
Click to expand it.
step/email/lib.php
+
27
−
0
View file @
c5b09e2b
...
...
@@ -25,7 +25,9 @@
*/
namespace
tool_cleanupcourses\step
;
use
tool_cleanupcourses\manager\settings_manager
;
use
tool_cleanupcourses\response\step_response
;
use
tool_cleanupcourses\manager\step_manager
;
defined
(
'MOODLE_INTERNAL'
)
||
die
();
...
...
@@ -58,6 +60,31 @@ class email extends base {
return
step_response
::
waiting
();
}
public
function
post_processing_bulk_operation
()
{
global
$DB
;
$stepinstances
=
step_manager
::
get_step_instances_by_subpluginname
(
$this
->
get_subpluginname
());
foreach
(
$stepinstances
as
$step
)
{
$settings
=
settings_manager
::
get_settings
(
$step
->
id
);
$subject
=
$settings
[
'subject'
];
$content
=
$settings
[
'content'
];
$userstobeinformed
=
$DB
->
get_records
(
'cleanupcoursesstep_email'
,
array
(
'instanceid'
=>
$step
->
id
),
''
,
'distinct touser'
);
foreach
(
$userstobeinformed
as
$user
)
{
$transaction
=
$DB
->
start_delegated_transaction
();
$mailentries
=
$DB
->
get_records
(
'cleanupcoursesstep_email'
,
array
(
'instanceid'
=>
$step
->
id
,
'touser'
=>
$user
->
touser
));
// TODO: use course info to parse content template!
email_to_user
(
\core_user
::
get_user
(
$user
->
touser
),
\core_user
::
get_noreply_user
(),
$subject
,
$content
);
$DB
->
delete_records
(
'cleanupcoursesstep_email'
,
array
(
'instanceid'
=>
$step
->
id
,
'touser'
=>
$user
->
touser
));
$transaction
->
allow_commit
();
}
}
}
public
function
instance_settings
()
{
return
array
(
new
instance_setting
(
'subject'
,
PARAM_TEXT
),
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment