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
b9a4ff0d
Commit
b9a4ff0d
authored
5 years ago
by
Justus Dieckmann
Committed by
Tobias Reischmann
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Delays: Implement bulk deletion
parent
7b34570b
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
delayedcourses.php
+66
-2
66 additions, 2 deletions
delayedcourses.php
with
66 additions
and
2 deletions
delayedcourses.php
+
66
−
2
View file @
b9a4ff0d
...
@@ -34,11 +34,12 @@ require_capability('moodle/site:config', context_system::instance());
...
@@ -34,11 +34,12 @@ require_capability('moodle/site:config', context_system::instance());
admin_externalpage_setup
(
'tool_lifecycle_delayed_courses'
);
admin_externalpage_setup
(
'tool_lifecycle_delayed_courses'
);
// Action handling (delete, bulk-delete).
$action
=
optional_param
(
'action'
,
null
,
PARAM_ALPHANUMEXT
);
$action
=
optional_param
(
'action'
,
null
,
PARAM_ALPHANUMEXT
);
if
(
$action
)
{
if
(
$action
)
{
if
(
$action
==
'delete'
)
{
global
$DB
;
global
$DB
;
require_sesskey
();
require_sesskey
();
if
(
$action
==
'delete'
)
{
$cid
=
required_param
(
'cid'
,
PARAM_INT
);
$cid
=
required_param
(
'cid'
,
PARAM_INT
);
$workflow
=
optional_param
(
'workflow'
,
null
,
PARAM_ALPHANUM
);
$workflow
=
optional_param
(
'workflow'
,
null
,
PARAM_ALPHANUM
);
if
(
$workflow
)
{
if
(
$workflow
)
{
...
@@ -46,11 +47,73 @@ if ($action) {
...
@@ -46,11 +47,73 @@ if ($action) {
$DB
->
delete_records
(
'tool_lifecycle_delayed_workf'
,
array
(
'courseid'
=>
$cid
,
'workflowid'
=>
$workflow
));
$DB
->
delete_records
(
'tool_lifecycle_delayed_workf'
,
array
(
'courseid'
=>
$cid
,
'workflowid'
=>
$workflow
));
}
else
if
(
$workflow
==
'global'
)
{
}
else
if
(
$workflow
==
'global'
)
{
$DB
->
delete_records
(
'tool_lifecycle_delayed'
,
array
(
'courseid'
=>
$cid
));
$DB
->
delete_records
(
'tool_lifecycle_delayed'
,
array
(
'courseid'
=>
$cid
));
}
else
{
throw
new
\coding_exception
(
'workflow has to be "global" or a int value'
);
}
}
}
else
{
}
else
{
$DB
->
delete_records
(
'tool_lifecycle_delayed'
,
array
(
'courseid'
=>
$cid
));
$DB
->
delete_records
(
'tool_lifecycle_delayed'
,
array
(
'courseid'
=>
$cid
));
$DB
->
delete_records
(
'tool_lifecycle_delayed_workf'
,
array
(
'courseid'
=>
$cid
));
$DB
->
delete_records
(
'tool_lifecycle_delayed_workf'
,
array
(
'courseid'
=>
$cid
));
}
}
}
else
if
(
$action
==
'bulk-delete'
)
{
$workflow
=
optional_param
(
'workflow'
,
null
,
PARAM_ALPHANUM
);
$deleteglobal
=
true
;
$deleteseperate
=
true
;
$workflowfilterid
=
null
;
if
(
$workflow
)
{
if
(
$workflow
==
'global'
)
{
$deleteseperate
=
false
;
}
else
if
(
is_number
(
$workflow
))
{
$deleteglobal
=
false
;
$workflowfilterid
=
$workflow
;
}
else
{
throw
new
\coding_exception
(
'workflow has to be "global" or a int value'
);
}
}
$coursename
=
optional_param
(
'coursename'
,
null
,
PARAM_TEXT
);
$categoryid
=
optional_param
(
'catid'
,
null
,
PARAM_INT
);
$params
=
[];
$where_course
=
[];
if
(
$coursename
)
{
$where_course
[]
=
'c.fullname LIKE :cname'
;
$params
[
'cname'
]
=
'%'
.
$DB
->
sql_like_escape
(
$coursename
)
.
'%'
;
}
if
(
$categoryid
)
{
$where_course
[]
=
'cat.id = :catid'
;
$params
[
'catid'
]
=
$categoryid
;
}
$where_course
=
implode
(
' AND '
,
$where_course
);
if
(
$deleteglobal
)
{
$sql
=
'DELETE FROM {tool_lifecycle_delayed} d '
;
if
(
$where_course
)
{
$sql
.
=
'WHERE d.courseid IN ( '
.
'SELECT c.id FROM {course} c '
.
'JOIN {course_categories} cat ON c.category = cat.id '
.
'WHERE '
.
$where_course
.
')'
;
}
$DB
->
execute
(
$sql
,
$params
);
}
if
(
$deleteseperate
)
{
$sql
=
'DELETE FROM {tool_lifecycle_delayed_workf} dw '
.
'WHERE TRUE '
;
if
(
$where_course
)
{
$sql
.
=
'AND dw.courseid IN ( '
.
'SELECT c.id FROM {course} c '
.
'JOIN {course_categories} cat ON c.category = cat.id '
.
'WHERE '
.
$where_course
.
')'
;
}
if
(
$workflowfilterid
)
{
$sql
.
=
'AND dw.workflowid = :workflowid'
;
$params
[
'workflowid'
]
=
$workflowfilterid
;
}
$DB
->
execute
(
$sql
,
$params
);
}
}
}
redirect
(
$PAGE
->
url
);
redirect
(
$PAGE
->
url
);
}
}
...
@@ -91,5 +154,6 @@ if ($data) {
...
@@ -91,5 +154,6 @@ if ($data) {
$button
=
new
single_button
(
new
moodle_url
(
$PAGE
->
url
,
$params
),
$button
=
new
single_button
(
new
moodle_url
(
$PAGE
->
url
,
$params
),
get_string
(
'delete_all_delays'
,
'tool_lifecycle'
));
get_string
(
'delete_all_delays'
,
'tool_lifecycle'
));
echo
"<br>"
;
echo
$OUTPUT
->
render
(
$button
);
echo
$OUTPUT
->
render
(
$button
);
echo
$OUTPUT
->
footer
();
echo
$OUTPUT
->
footer
();
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