Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 12... Línea 12...
12
// GNU General Public License for more details.
12
// GNU General Public License for more details.
13
//
13
//
14
// You should have received a copy of the GNU General Public License
14
// You should have received a copy of the GNU General Public License
15
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
15
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
Línea -... Línea 16...
-
 
16
 
-
 
17
use core\di;
-
 
18
use core\hook\manager;
-
 
19
use core_backup\hook\copy_helper_process_formdata;
16
 
20
 
17
defined('MOODLE_INTERNAL') || die();
21
defined('MOODLE_INTERNAL') || die();
Línea 18... Línea 22...
18
require_once($CFG->dirroot . '/backup/util/includes/restore_includes.php');
22
require_once($CFG->dirroot . '/backup/util/includes/restore_includes.php');
19
 
23
 
Línea 44... Línea 48...
44
            'enddate', // Integer timestamp of the end of the destination course.
48
            'enddate', // Integer timestamp of the end of the destination course.
45
            'idnumber', // ID of the destination course.
49
            'idnumber', // ID of the destination course.
46
            'userdata', // Integer to determine if the copied course will contain user data.
50
            'userdata', // Integer to determine if the copied course will contain user data.
47
        ];
51
        ];
Línea -... Línea 52...
-
 
52
 
-
 
53
        // Use hook to expand field list.
-
 
54
        $hook = new copy_helper_process_formdata();
-
 
55
        di::get(manager::class)->dispatch($hook);
-
 
56
        $requiredfields = array_merge($requiredfields, $hook->get_extrafields());
48
 
57
 
49
        $missingfields = array_diff($requiredfields, array_keys((array)$formdata));
58
        $missingfields = array_diff($requiredfields, array_keys((array)$formdata));
50
        if ($missingfields) {
59
        if ($missingfields) {
51
            throw new \moodle_exception('copyfieldnotfound', 'backup', '', null, implode(", ", $missingfields));
60
            throw new \moodle_exception('copyfieldnotfound', 'backup', '', null, implode(", ", $missingfields));
Línea 222... Línea 231...
222
     *
231
     *
223
     * @param array $backuprecords An array of records from {backup_controllers}
232
     * @param array $backuprecords An array of records from {backup_controllers}
224
     * @return array An array of mappings between backup ids and restore controllers
233
     * @return array An array of mappings between backup ids and restore controllers
225
     */
234
     */
226
    private static function map_backupids_to_restore_controller(array $backuprecords): array {
235
    private static function map_backupids_to_restore_controller(array $backuprecords): array {
227
        // Needed for PHP 7.3 - array_merge only accepts 0 parameters in PHP >= 7.4.
-
 
228
        if (empty($backuprecords)) {
-
 
229
            return [];
-
 
230
        }
-
 
231
 
-
 
232
        return array_merge(
236
        return array_merge(
233
            ...array_map(
237
            ...array_map(
234
                function (\stdClass $backuprecord): array {
238
                function (\stdClass $backuprecord): array {
235
                    $iscopyrestore = $backuprecord->operation == \backup::OPERATION_RESTORE &&
239
                    $iscopyrestore = $backuprecord->operation == \backup::OPERATION_RESTORE &&
236
                            $backuprecord->purpose == \backup::MODE_COPY;
240
                            $backuprecord->purpose == \backup::MODE_COPY;