Proyectos de Subversion Moodle

Rev

Rev 1348 | Rev 1377 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1348 Rev 1370
Línea 1... Línea 1...
1
<?php
1
<?php
2
defined('MOODLE_INTERNAL') || die();
2
defined('MOODLE_INTERNAL') || die();
Línea -... Línea 3...
-
 
3
 
-
 
4
// Incluir el archivo lib.php del tema padre
-
 
5
require_once($CFG->dirroot . '/theme/universe/lib.php');
3
 
6
 
4
function theme_universe_child_themedir()
7
function theme_universe_child_themedir()
5
{
8
{
Línea 6... Línea 9...
6
    global $CFG;
9
    global $CFG;
Línea 47... Línea 50...
47
}
50
}
Línea 48... Línea 51...
48
 
51
 
49
function theme_universe_child_get_main_scss_content($theme)
52
function theme_universe_child_get_main_scss_content($theme)
50
{
53
{
51
    global $CFG;
54
    global $CFG;
-
 
55
    return theme_universe_get_main_scss_content($theme);
-
 
56
}
-
 
57
 
-
 
58
/**
-
 
59
 * Obtiene la pista de acceso para invitados al curso
-
 
60
 * @param int $courseid ID del curso
-
 
61
 * @return string HTML con la pista de acceso
-
 
62
 */
-
 
63
function theme_universe_child_get_course_guest_access_hint($courseid)
-
 
64
{
-
 
65
    global $CFG;
-
 
66
    require_once($CFG->dirroot . '/enrol/self/lib.php');
-
 
67
 
-
 
68
    $html = '';
-
 
69
    $instances = enrol_get_instances($courseid, true);
-
 
70
    $plugins = enrol_get_plugins(true);
-
 
71
    foreach ($instances as $instance) {
-
 
72
        if (!isset($plugins[$instance->enrol])) {
-
 
73
            continue;
-
 
74
        }
-
 
75
        $plugin = $plugins[$instance->enrol];
-
 
76
        if ($plugin->show_enrolme_link($instance)) {
-
 
77
            $html = html_writer::tag('div', get_string(
-
 
78
                'showhintcourseguestaccesslink',
-
 
79
                'theme_universe_child',
-
 
80
                array('url' => $CFG->wwwroot . '/enrol/index.php?id=' . $courseid)
-
 
81
            ));
-
 
82
            break;
-
 
83
        }
-
 
84
    }
-
 
85
 
-
 
86
    return $html;
-
 
87
}
-
 
88
 
-
 
89
/**
-
 
90
 * Obtiene los banners de información del curso
-
 
91
 * @return string HTML con los banners de información
-
 
92
 */
-
 
93
function theme_universe_child_get_course_information_banners()
-
 
94
{
-
 
95
    global $CFG, $COURSE, $PAGE, $USER, $OUTPUT;
-
 
96
 
-
 
97
    // Require user library.
-
 
98
    require_once($CFG->dirroot . '/user/lib.php');
-
 
99
 
-
 
100
    // Initialize HTML code.
-
 
101
    $html = '';
-
 
102
 
-
 
103
    // Check if user is admin, teacher or editing teacher.
-
 
104
    if (
-
 
105
        user_has_role_assignment($USER->id, '1') ||
-
 
106
        user_has_role_assignment($USER->id, '2') ||
-
 
107
        user_has_role_assignment($USER->id, '3') ||
-
 
108
        user_has_role_assignment($USER->id, '4')
-
 
109
    ) {
-
 
110
        $allowtoshowhint = true;
-
 
111
    } else {
-
 
112
        $allowtoshowhint = false;
-
 
113
    }
-
 
114
 
-
 
115
    // Verificar acceso de invitados
-
 
116
    if (
-
 
117
        get_config('theme_universe_child', 'showhintcourseguestaccess') == 1
-
 
118
        && is_guest(\context_course::instance($COURSE->id), $USER->id)
-
 
119
        && $PAGE->has_set_url()
-
 
120
        && $PAGE->url->compare(new moodle_url('/course/view.php'), URL_MATCH_BASE)
-
 
121
        && !is_role_switched($COURSE->id)
-
 
122
    ) {
-
 
123
        // Require self enrolment library.
-
 
124
        require_once($CFG->dirroot . '/enrol/self/lib.php');
-
 
125
 
-
 
126
        // Prepare template context.
-
 
127
        $templatecontext = array(
-
 
128
            'courseid' => $COURSE->id,
-
 
129
            'role' => role_get_name(get_guest_role())
-
 
130
        );
-
 
131
 
-
 
132
        // Search for an available self enrolment link in this course.
-
 
133
        $templatecontext['showselfenrollink'] = false;
-
 
134
        $instances = enrol_get_instances($COURSE->id, true);
-
 
135
        $plugins = enrol_get_plugins(true);
-
 
136
        foreach ($instances as $instance) {
-
 
137
            if (!isset($plugins[$instance->enrol])) {
-
 
138
                continue;
-
 
139
            }
-
 
140
            $plugin = $plugins[$instance->enrol];
-
 
141
            if ($plugin->show_enrolme_link($instance)) {
-
 
142
                $templatecontext['showselfenrollink'] = true;
-
 
143
                break;
-
 
144
            }
-
 
145
        }
-
 
146
 
-
 
147
        // Render template and add it to HTML code.
-
 
148
        $html .= $OUTPUT->render_from_template('theme_universe_child/course-hint-guestaccess', $templatecontext);
-
 
149
    }
-
 
150
 
-
 
151
    return $html;
-
 
152
}
-
 
153
 
-
 
154
/**
-
 
155
 * Verifica si el usuario es invitado en el contexto del curso
-
 
156
 * @param context_course $context Contexto del curso
-
 
157
 * @param int $userid ID del usuario
-
 
158
 * @return bool True si el usuario es invitado
-
 
159
 */
-
 
160
function theme_universe_child_is_guest_in_course($context, $userid)
-
 
161
{
52
    return theme_universe_get_main_scss_content($theme); // o personalizado
162
    return is_guest($context, $userid);