Proyectos de Subversion Moodle

Rev

Rev 1377 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
118 ariadna 1
<?php
1 efrain 2
defined('MOODLE_INTERNAL') || die();
3
 
1370 ariadna 4
// Incluir el archivo lib.php del tema padre
5
require_once($CFG->dirroot . '/theme/universe/lib.php');
6
 
1287 ariadna 7
function theme_universe_child_themedir()
1286 ariadna 8
{
9
    global $CFG;
10
 
11
    $teme_dir = '/theme';
12
 
13
    if (isset($CFG->themedir)) {
14
        $teme_dir = $CFG->themedir;
15
        $teme_dir = str_replace($CFG->dirroot, '', $CFG->themedir);
16
    }
17
 
18
    return $teme_dir;
19
}
20
 
138 ariadna 21
function theme_universe_child_get_setting($setting, $format = false)
22
{
23
    $theme = theme_config::load('universe');
24
 
25
    if (empty($theme->settings->$setting)) {
26
        return false;
27
    }
28
 
29
    if (!$format) {
30
        return $theme->settings->$setting;
31
    }
32
 
33
    if ($format === 'format_text') {
34
        return format_text($theme->settings->$setting, FORMAT_PLAIN);
35
    }
36
 
37
    if ($format === 'format_html') {
38
        return format_text($theme->settings->$setting, FORMAT_HTML, array('trusted' => true, 'noclean' => true));
39
    }
40
 
41
    return format_string($theme->settings->$setting);
42
}
43
 
118 ariadna 44
function theme_universe_child_get_pre_scss($theme)
45
{
1 efrain 46
    // Load the settings from the parent.
118 ariadna 47
    $theme = theme_config::load('universe');
1 efrain 48
    // Call the parent themes get_pre_scss function.
118 ariadna 49
    return theme_universe_get_pre_scss($theme);
1 efrain 50
}
1348 ariadna 51
 
52
function theme_universe_child_get_main_scss_content($theme)
53
{
54
    global $CFG;
1370 ariadna 55
    return theme_universe_get_main_scss_content($theme);
1348 ariadna 56
}
1370 ariadna 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
{
162
    return is_guest($context, $userid);
163
}