check if we're restoring from the same moodle site

check if we're restoring from the same moodle site

by Martin H -
Number of replies: 4

Dear all,

I'm trying to develop a restore procedure for a module. Is there a way to check whether the backup file that we're restoring has been created on the same Moodle site?

I mean for example in the process_MODULENAME($data) function.

Average of ratings: -
In reply to Martin H

Re: check if we're restoring from the same moodle site

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

There is a function backup_is_same_site in backup/lib.php.

In reply to Tim Hunt

Re: check if we're restoring from the same moodle site

by Martin H -

Thanks for the quick reply.

Suppose that I'm inside the restore_MODULENAME_stepslib.php and in the process_MODULENAME method. Can I use backup_is_same_site here? If so, what should I pass as the parameter to it?

In reply to Martin H

Re: check if we're restoring from the same moodle site

by sam marshall -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

I had to do the same thing last week, so:

    protected function process_oucontent($data) {
        if (!$this->get_task()->is_samesite()) {

There you go smile

--sam

Average of ratings: Useful (1)
In reply to sam marshall

Re: check if we're restoring from the same moodle site [Solved]

by Martin H -

Thanks Sam.

This is exactly what I needed.