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
abb9f17e
Commit
abb9f17e
authored
Jul 2, 2021
by
Justus Dieckmann
Browse files
Options
Downloads
Patches
Plain Diff
Make course backups table searchable
parent
8eee4e1d
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/local/form/form_backups_filter.php
+54
-0
54 additions, 0 deletions
classes/local/form/form_backups_filter.php
classes/local/table/course_backups_table.php
+20
-3
20 additions, 3 deletions
classes/local/table/course_backups_table.php
coursebackups.php
+24
-1
24 additions, 1 deletion
coursebackups.php
with
98 additions
and
4 deletions
classes/local/form/form_backups_filter.php
0 → 100644
+
54
−
0
View file @
abb9f17e
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* A moodle form for filtering the course backups table
*
* @package tool_lifecycle
* @copyright 2021 Justus Dieckmann WWU
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace
tool_lifecycle\local\form
;
defined
(
'MOODLE_INTERNAL'
)
||
die
();
require_once
(
$CFG
->
libdir
.
'/formslib.php'
);
/**
* A moodle form for filtering the course backups table
*
* @package tool_lifecycle
* @copyright 2021 Justus Dieckmann WWU
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class
form_backups_filter
extends
\moodleform
{
/**
* Defines forms elements
*/
public
function
definition
()
{
$mform
=
$this
->
_form
;
$mform
->
addElement
(
'text'
,
'shortname'
,
get_string
(
'shortname'
));
$mform
->
setType
(
'shortname'
,
PARAM_TEXT
);
$mform
->
addElement
(
'text'
,
'fullname'
,
get_string
(
'fullname'
));
$mform
->
setType
(
'fullname'
,
PARAM_TEXT
);
$this
->
add_action_buttons
(
true
,
get_string
(
'apply'
,
'tool_lifecycle'
));
}
}
This diff is collapsed.
Click to expand it.
classes/local/table/course_backups_table.php
+
20
−
3
View file @
abb9f17e
...
@@ -39,14 +39,31 @@ class course_backups_table extends \table_sql {
...
@@ -39,14 +39,31 @@ class course_backups_table extends \table_sql {
/**
/**
* Constructor for course_backups_table.
* Constructor for course_backups_table.
* @param int $uniqueid Unique id of this table.
* @param int $uniqueid Unique id of this table.
* @param \stdClass|null $filterdata
*/
*/
public
function
__construct
(
$uniqueid
)
{
public
function
__construct
(
$uniqueid
,
$filterdata
)
{
parent
::
__construct
(
$uniqueid
);
parent
::
__construct
(
$uniqueid
);
global
$PAGE
;
global
$PAGE
,
$DB
;
$this
->
set_attribute
(
'class'
,
$this
->
attributes
[
'class'
]
.
' '
.
$uniqueid
);
$this
->
set_attribute
(
'class'
,
$this
->
attributes
[
'class'
]
.
' '
.
$uniqueid
);
$where
=
[
'TRUE'
];
$params
=
[];
if
(
$filterdata
)
{
if
(
$filterdata
&&
$filterdata
->
shortname
)
{
$where
[]
=
$DB
->
sql_like
(
'b.shortname'
,
':shortname'
,
false
,
false
);
$params
[
'shortname'
]
=
'%'
.
$DB
->
sql_like_escape
(
$filterdata
->
shortname
)
.
'%'
;
}
if
(
$filterdata
&&
$filterdata
->
fullname
)
{
$where
[]
=
$DB
->
sql_like
(
'b.fullname'
,
':fullname'
,
false
,
false
);
$params
[
'fullname'
]
=
'%'
.
$DB
->
sql_like_escape
(
$filterdata
->
fullname
)
.
'%'
;
}
}
$this
->
set_sql
(
'b.id, b.courseid, b.shortname as courseshortname, b.fullname as coursefullname, b.backupcreated'
,
$this
->
set_sql
(
'b.id, b.courseid, b.shortname as courseshortname, b.fullname as coursefullname, b.backupcreated'
,
'{tool_lifecycle_backups} b'
,
'{tool_lifecycle_backups} b'
,
"TRUE"
);
join
(
" AND "
,
$where
),
$params
);
$this
->
no_sorting
(
'download'
);
$this
->
no_sorting
(
'download'
);
$this
->
no_sorting
(
'restore'
);
$this
->
no_sorting
(
'restore'
);
$this
->
define_baseurl
(
$PAGE
->
url
);
$this
->
define_baseurl
(
$PAGE
->
url
);
...
...
...
...
This diff is collapsed.
Click to expand it.
coursebackups.php
+
24
−
1
View file @
abb9f17e
...
@@ -32,7 +32,23 @@ admin_externalpage_setup('tool_lifecycle_coursebackups');
...
@@ -32,7 +32,23 @@ admin_externalpage_setup('tool_lifecycle_coursebackups');
$PAGE
->
set_url
(
new
\moodle_url
(
'/admin/tool/lifecycle/coursebackups.php'
));
$PAGE
->
set_url
(
new
\moodle_url
(
'/admin/tool/lifecycle/coursebackups.php'
));
$table
=
new
tool_lifecycle\local\table\course_backups_table
(
'tool_lifecycle_course_backups'
);
$mform
=
new
\tool_lifecycle\local\form\form_backups_filter
();
// Cache handling.
$cache
=
cache
::
make
(
'tool_lifecycle'
,
'mformdata'
);
if
(
$mform
->
is_cancelled
())
{
$cache
->
delete
(
'coursebackups_filter'
);
redirect
(
$PAGE
->
url
);
}
else
if
(
$data
=
$mform
->
get_data
())
{
$cache
->
set
(
'coursebackups_filter'
,
$data
);
}
else
{
$data
=
$cache
->
get
(
'coursebackups_filter'
);
if
(
$data
)
{
$mform
->
set_data
(
$data
);
}
}
$table
=
new
tool_lifecycle\local\table\course_backups_table
(
'tool_lifecycle_course_backups'
,
$data
);
$PAGE
->
set_title
(
get_string
(
'course_backups_list_header'
,
'tool_lifecycle'
));
$PAGE
->
set_title
(
get_string
(
'course_backups_list_header'
,
'tool_lifecycle'
));
$PAGE
->
set_heading
(
get_string
(
'course_backups_list_header'
,
'tool_lifecycle'
));
$PAGE
->
set_heading
(
get_string
(
'course_backups_list_header'
,
'tool_lifecycle'
));
...
@@ -40,6 +56,13 @@ $PAGE->set_heading(get_string('course_backups_list_header', 'tool_lifecycle'));
...
@@ -40,6 +56,13 @@ $PAGE->set_heading(get_string('course_backups_list_header', 'tool_lifecycle'));
$renderer
=
$PAGE
->
get_renderer
(
'tool_lifecycle'
);
$renderer
=
$PAGE
->
get_renderer
(
'tool_lifecycle'
);
echo
$renderer
->
header
();
echo
$renderer
->
header
();
echo
'<br>'
;
$mform
->
display
();
echo
'<br>'
;
$table
->
out
(
50
,
false
);
$table
->
out
(
50
,
false
);
echo
$renderer
->
footer
();
echo
$renderer
->
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
sign in
to comment