Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 1441
Línea 39... Línea 39...
39
    const REDIRECT_EXCEPTION = -1;
39
    const REDIRECT_EXCEPTION = -1;
Línea 40... Línea 40...
40
 
40
 
41
    /** @var int */
41
    /** @var int */
Línea -... Línea 42...
-
 
42
    const REDIR_LOOP_THRESHOLD = 5;
-
 
43
 
-
 
44
    /** @var array These components and related fileareas will not redirect. */
-
 
45
    const ALLOWED_COMPONENTS = [
-
 
46
        'core_admin' => [
-
 
47
            'logocompact',
-
 
48
            'logo',
-
 
49
            'favicon',
-
 
50
        ],
-
 
51
        'tool_mfa' => [
-
 
52
            'guidance',
-
 
53
        ]
42
    const REDIR_LOOP_THRESHOLD = 5;
54
    ];
43
 
55
 
44
    /**
56
    /**
45
     * Displays a debug table with current factor information.
57
     * Displays a debug table with current factor information.
46
     *
58
     *
Línea 62... Línea 74...
62
            get_string('achievedweight', 'tool_mfa'),
74
            get_string('achievedweight', 'tool_mfa'),
63
            get_string('status'),
75
            get_string('status'),
64
        ];
76
        ];
65
        $table->attributes['class'] = 'admintable generaltable table table-bordered';
77
        $table->attributes['class'] = 'admintable generaltable table table-bordered';
66
        $table->colclasses = [
78
        $table->colclasses = [
67
            'text-right',
79
            'text-end',
68
            '',
80
            '',
69
            '',
81
            '',
70
            'text-right',
82
            'text-end',
71
            'text-center',
83
            'text-center',
72
        ];
84
        ];
73
        $factors = factor::get_enabled_factors();
85
        $factors = factor::get_enabled_factors();
74
        $userfactors = factor::get_active_user_factor_types();
86
        $userfactors = factor::get_active_user_factor_types();
75
        $runningtotal = 0;
87
        $runningtotal = 0;
Línea 422... Línea 434...
422
        // Unit testing based on defines is not viable.
434
        // Unit testing based on defines is not viable.
423
        if (NO_MOODLE_COOKIES && !PHPUNIT_TEST) {
435
        if (NO_MOODLE_COOKIES && !PHPUNIT_TEST) {
424
            return self::NO_REDIRECT;
436
            return self::NO_REDIRECT;
425
        }
437
        }
Línea -... Línea 438...
-
 
438
 
-
 
439
        // Ensure we have a moodle_url object if a string is provided.
-
 
440
        if (is_string($url)) {
-
 
441
            $url = new \moodle_url($url);
-
 
442
        }
-
 
443
 
-
 
444
        // Check for pluginfile.php urls.
-
 
445
        $pluginfileurl = new \moodle_url('/pluginfile.php');
-
 
446
        if ($url->compare($pluginfileurl)) {
-
 
447
            // Get the slash arguments.
-
 
448
            $args = explode('/', ltrim($url->get_slashargument(), '/'));
-
 
449
 
-
 
450
            // Remove the contextid because we do not need it for this check.
-
 
451
            array_shift($args);
-
 
452
 
-
 
453
            // Get the component and filearea.
-
 
454
            $component = clean_param(array_shift($args), PARAM_COMPONENT);
-
 
455
            $filearea = clean_param(array_shift($args), PARAM_AREA);
-
 
456
 
-
 
457
            // Check allowed components.
-
 
458
            if (!array_key_exists($component, static::ALLOWED_COMPONENTS)) {
-
 
459
                return self::REDIRECT;
-
 
460
            }
-
 
461
 
-
 
462
            // Check allowed fileareas.
-
 
463
            if (!in_array($filearea, static::ALLOWED_COMPONENTS[$component])) {
-
 
464
                return self::REDIRECT;
-
 
465
            }
-
 
466
 
-
 
467
            return self::NO_REDIRECT;
-
 
468
        }
426
 
469
 
427
        // Remove all params before comparison.
470
        // Remove all params before comparison.
Línea 428... Línea 471...
428
        $url->remove_all_params();
471
        $url->remove_all_params();
429
 
472
 
Línea 440... Línea 483...
440
            if ($url->compare($upgradesettings, URL_MATCH_BASE)) {
483
            if ($url->compare($upgradesettings, URL_MATCH_BASE)) {
441
                return self::NO_REDIRECT;
484
                return self::NO_REDIRECT;
442
            }
485
            }
443
        }
486
        }
Línea 444... Línea -...
444
 
-
 
445
        // Dont redirect logo images from pluginfile.php (for example: logo in header).
-
 
446
        $logourl = new \moodle_url('/pluginfile.php/1/core_admin/logocompact/');
-
 
447
        if ($url->compare($logourl)) {
-
 
448
            return self::NO_REDIRECT;
-
 
449
        }
-
 
450
 
487
 
451
        // Admin not setup.
488
        // Admin not setup.
452
        if (!empty($CFG->adminsetuppending)) {
489
        if (!empty($CFG->adminsetuppending)) {
453
            return self::NO_REDIRECT;
490
            return self::NO_REDIRECT;
Línea 467... Línea 504...
467
        // User not properly setup.
504
        // User not properly setup.
468
        if (user_not_fully_set_up($USER)) {
505
        if (user_not_fully_set_up($USER)) {
469
            return self::NO_REDIRECT;
506
            return self::NO_REDIRECT;
470
        }
507
        }
Línea 471... Línea -...
471
 
-
 
472
        // Enrolment.
-
 
473
        $enrol = new \moodle_url('/enrol/index.php');
-
 
474
        if ($enrol->compare($url, URL_MATCH_BASE)) {
-
 
475
            return self::NO_REDIRECT;
-
 
476
        }
-
 
477
 
508
 
478
        // Guest access.
509
        // Guest access.
479
        if (isguestuser()) {
510
        if (isguestuser()) {
480
            return self::NO_REDIRECT;
511
            return self::NO_REDIRECT;
Línea 497... Línea 528...
497
            if (!empty($policyurl) && $url->compare($policyurl, URL_MATCH_BASE)) {
528
            if (!empty($policyurl) && $url->compare($policyurl, URL_MATCH_BASE)) {
498
                return self::NO_REDIRECT;
529
                return self::NO_REDIRECT;
499
            }
530
            }
500
        }
531
        }
Línea -... Línea 532...
-
 
532
 
-
 
533
        // Site policies from tool_policy.
-
 
534
        $policyviewurl = new \moodle_url('/admin/tool/policy/view.php');
-
 
535
        $policyindexurl = new \moodle_url('/admin/tool/policy/index.php');
-
 
536
        if ($policyviewurl->compare($url, URL_MATCH_BASE) || $policyindexurl->compare($url, URL_MATCH_BASE)) {
-
 
537
            return self::NO_REDIRECT;
-
 
538
        }
501
 
539
 
502
        // WS/AJAX check.
540
        // WS/AJAX check.
503
        if (WS_SERVER || AJAX_SCRIPT) {
541
        if (WS_SERVER || AJAX_SCRIPT) {
504
            if (isset($SESSION->mfa_pending) && !empty($SESSION->mfa_pending)) {
542
            if (isset($SESSION->mfa_pending) && !empty($SESSION->mfa_pending)) {
505
                // Allow AJAX and WS, but never from auth.php.
543
                // Allow AJAX and WS, but never from auth.php.