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
de9b8e0a
Unverified
Commit
de9b8e0a
authored
8 years ago
by
Tobias Reischmann
Browse files
Options
Downloads
Patches
Plain Diff
Added a table to store information about course backups
parent
ffff7a24
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/backup_manager.php
+20
-2
20 additions, 2 deletions
classes/manager/backup_manager.php
db/install.xml
+13
-0
13 additions, 0 deletions
db/install.xml
version.php
+1
-1
1 addition, 1 deletion
version.php
with
34 additions
and
3 deletions
classes/manager/backup_manager.php
+
20
−
2
View file @
de9b8e0a
...
...
@@ -35,10 +35,18 @@ class backup_manager {
* @return bool tells if the backup was completed successfully.
*/
public
static
function
create_course_backup
(
$courseid
)
{
global
$CFG
;
global
$CFG
,
$DB
;
try
{
$course
=
get_course
(
$courseid
);
$record
=
new
\stdClass
();
$record
->
courseid
=
$courseid
;
$record
->
fullname
=
$course
->
fullname
;
$record
->
shortname
=
$course
->
shortname
;
$recordid
=
$DB
->
insert_record
(
'tool_cleanupcourses_backups'
,
$record
,
true
);
$record
->
id
=
$recordid
;
// Build filename.
$archivefile
=
date
(
"Y-m-d"
)
.
"-ID-
{
$courseid
}
.mbz"
;
$archivefile
=
date
(
"Y-m-d"
)
.
"-ID-
{
$
recordid
}
-COURSE-
{
$
courseid
}
.mbz"
;
// Path of backup folder.
$path
=
$CFG
->
dataroot
.
'/cleanupcourses_backups'
;
...
...
@@ -61,6 +69,16 @@ class backup_manager {
}
$bc
->
destroy
();
unset
(
$bc
);
// First check if the file was created.
if
(
!
file_exists
(
$path
.
'/'
.
$archivefile
))
{
return
false
;
}
$record
->
backupfile
=
$archivefile
;
$record
->
backupcreated
=
time
();
$DB
->
update_record
(
'tool_cleanupcourses_backups'
,
$record
,
true
);
return
true
;
}
catch
(
\moodle_exception
$e
)
{
debugging
(
'There was a problem during backup!'
);
...
...
This diff is collapsed.
Click to expand it.
db/install.xml
+
13
−
0
View file @
de9b8e0a
...
...
@@ -76,5 +76,18 @@
<KEY
NAME=
"stepid_fk"
TYPE=
"foreign"
FIELDS=
"stepid"
REFTABLE=
"tool_cleanupcourses_step"
REFFIELDS=
"id"
COMMENT=
"Foreign key on step table"
/>
</KEYS>
</TABLE>
<TABLE
NAME=
"tool_cleanupcourses_backups"
COMMENT=
"Saves the location of course backups and the relevant information of the course."
>
<FIELDS>
<FIELD
NAME=
"id"
TYPE=
"int"
LENGTH=
"10"
NOTNULL=
"true"
SEQUENCE=
"true"
/>
<FIELD
NAME=
"courseid"
TYPE=
"int"
LENGTH=
"20"
NOTNULL=
"true"
SEQUENCE=
"false"
COMMENT=
"id of the course the backup belongs to"
/>
<FIELD
NAME=
"fullname"
TYPE=
"char"
LENGTH=
"255"
NOTNULL=
"true"
SEQUENCE=
"false"
COMMENT=
"The fullname of the course"
/>
<FIELD
NAME=
"shortname"
TYPE=
"char"
LENGTH=
"255"
NOTNULL=
"true"
SEQUENCE=
"false"
COMMENT=
"Shortname of the course"
/>
<FIELD
NAME=
"backupfile"
TYPE=
"char"
LENGTH=
"120"
NOTNULL=
"false"
SEQUENCE=
"false"
COMMENT=
"Name of the backup file"
/>
<FIELD
NAME=
"backupcreated"
TYPE=
"int"
LENGTH=
"10"
NOTNULL=
"false"
SEQUENCE=
"false"
COMMENT=
"timestamp the backup was created"
/>
</FIELDS>
<KEYS>
<KEY
NAME=
"primary"
TYPE=
"primary"
FIELDS=
"id"
/>
</KEYS>
</TABLE>
</TABLES>
</XMLDB>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
version.php
+
1
−
1
View file @
de9b8e0a
...
...
@@ -23,5 +23,5 @@
defined
(
'MOODLE_INTERNAL'
)
||
die
;
$plugin
->
version
=
201706190
2
;
$plugin
->
version
=
201706190
3
;
$plugin
->
component
=
'tool_cleanupcourses'
;
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