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
daffca07
Commit
daffca07
authored
6 years ago
by
Justus Dieckmann
Browse files
Options
Downloads
Patches
Plain Diff
Add functionality to download course backups
parent
3de9d628
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/table/course_backups_table.php
+17
-4
17 additions, 4 deletions
classes/table/course_backups_table.php
downloadbackup.php
+41
-0
41 additions, 0 deletions
downloadbackup.php
lang/en/tool_lifecycle.php
+2
-1
2 additions, 1 deletion
lang/en/tool_lifecycle.php
with
60 additions
and
5 deletions
classes/table/course_backups_table.php
+
17
−
4
View file @
daffca07
...
@@ -41,13 +41,14 @@ class course_backups_table extends \table_sql {
...
@@ -41,13 +41,14 @@ class course_backups_table extends \table_sql {
}
}
public
function
init
()
{
public
function
init
()
{
$this
->
define_columns
([
'courseid'
,
'courseshortname'
,
'coursefullname'
,
'backupcreated'
,
'
tools
'
]);
$this
->
define_columns
([
'courseid'
,
'courseshortname'
,
'coursefullname'
,
'backupcreated'
,
'
download'
,
'restore
'
]);
$this
->
define_headers
([
$this
->
define_headers
([
get_string
(
'course'
),
get_string
(
'course'
),
get_string
(
'shortnamecourse'
),
get_string
(
'shortnamecourse'
),
get_string
(
'fullnamecourse'
),
get_string
(
'fullnamecourse'
),
get_string
(
'backupcreated'
,
'tool_lifecycle'
),
get_string
(
'backupcreated'
,
'tool_lifecycle'
),
get_string
(
'tools'
,
'tool_lifecycle'
)]);
get_string
(
'download'
,
'tool_lifecycle'
),
get_string
(
'restore'
,
'tool_lifecycle'
)]);
$this
->
setup
();
$this
->
setup
();
}
}
...
@@ -100,11 +101,23 @@ class course_backups_table extends \table_sql {
...
@@ -100,11 +101,23 @@ class course_backups_table extends \table_sql {
}
}
/**
/**
* Render tools column.
* Render download column.
* @param $row
* @return string action buttons for downloading a backup.
*/
public
function
col_download
(
$row
)
{
return
\html_writer
::
link
(
new
\moodle_url
(
'/admin/tool/lifecycle/downloadbackup.php'
,
array
(
'backupid'
=>
$row
->
id
)),
get_string
(
'download'
,
'tool_lifecycle'
)
);
}
/**
* Render restore column.
* @param $row
* @param $row
* @return string action buttons for restoring a course.
* @return string action buttons for restoring a course.
*/
*/
public
function
col_
tools
(
$row
)
{
public
function
col_
restore
(
$row
)
{
return
\html_writer
::
link
(
return
\html_writer
::
link
(
new
\moodle_url
(
'/admin/tool/lifecycle/restore.php'
,
array
(
'backupid'
=>
$row
->
id
)),
new
\moodle_url
(
'/admin/tool/lifecycle/restore.php'
,
array
(
'backupid'
=>
$row
->
id
)),
get_string
(
'restore'
,
'tool_lifecycle'
)
get_string
(
'restore'
,
'tool_lifecycle'
)
...
...
This diff is collapsed.
Click to expand it.
downloadbackup.php
0 → 100644
+
41
−
0
View file @
daffca07
<?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/>.
/**
* Provides download for backup
*
* @package tool_lifecycle
* @copyright 2019 Justus Dieckmann WWU
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once
(
__DIR__
.
'/../../../config.php'
);
require_once
(
$CFG
->
libdir
.
'/adminlib.php'
);
require_login
(
null
,
false
);
require_capability
(
'moodle/site:config'
,
context_system
::
instance
());
$backupid
=
required_param
(
'backupid'
,
PARAM_INT
);
$backuprecord
=
$DB
->
get_record
(
'tool_lifecycle_backups'
,
array
(
'id'
=>
$backupid
),
'*'
,
MUST_EXIST
);
$source
=
$CFG
->
dataroot
.
'/lifecycle_backups/'
.
$backuprecord
->
backupfile
;
if
(
!
file_exists
(
$source
))
{
throw
new
\moodle_exception
(
'errorbackupfiledoesnotexist'
,
'tool_lifecycle'
,
$source
);
}
header
(
"Content-Type: application/zip"
);
header
(
"Content-Disposition: attachment; filename=
\"
backup-
$backuprecord->backupfile
\"
"
);
readfile
(
$source
);
\ No newline at end of file
This diff is collapsed.
Click to expand it.
lang/en/tool_lifecycle.php
+
2
−
1
View file @
daffca07
...
@@ -132,7 +132,8 @@ $string['nocoursestodisplay'] = 'There are currently no courses which require yo
...
@@ -132,7 +132,8 @@ $string['nocoursestodisplay'] = 'There are currently no courses which require yo
$string
[
'course_backups_list_header'
]
=
'Course Backups'
;
$string
[
'course_backups_list_header'
]
=
'Course Backups'
;
$string
[
'backupcreated'
]
=
'Created at'
;
$string
[
'backupcreated'
]
=
'Created at'
;
$string
[
'restore'
]
=
'restore'
;
$string
[
'restore'
]
=
'Restore'
;
$string
[
'download'
]
=
'Download'
;
$string
[
'workflownotfound'
]
=
'Workflow with id {$a} could not be found'
;
$string
[
'workflownotfound'
]
=
'Workflow with id {$a} could not be found'
;
...
...
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