Proyectos de Subversion Moodle

Rev

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

Rev Autor Línea Nro. Línea
533 ariadna 1
<?php
2
// This file is part of Moodle - http://moodle.org/
3
//
4
// Moodle is free software: you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation, either version 3 of the License, or
7
// (at your option) any later version.
8
//
9
// Moodle is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
// GNU General Public License for more details.
13
//
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/>.
16
 
17
/**
18
 * A two column layout for the universe theme.
19
 *
20
 * @package   theme_universe
21
 * @copyright 2023 Marcin Czaja (https://rosea.io)
22
 * @license   Commercial https://themeforest.net/licenses
23
 */
24
 
1115 efrain 25
 
533 ariadna 26
defined('MOODLE_INTERNAL') || die();
27
 
1143 efrain 28
global $CFG, $PAGE, $OUTPUT, $USER;
1119 efrain 29
 
1143 efrain 30
 
533 ariadna 31
require_once($CFG->libdir . '/behat/lib.php');
32
require_once($CFG->dirroot . '/course/lib.php');
33
 
1126 efrain 34
 
1146 efrain 35
$searchURL = false;
36
$linkURL = '';
37
if (!empty($PAGE->course->id)) {
1126 efrain 38
    $course = get_course($PAGE->course->id);
39
    $course_context = context_course::instance($course->id);
1167 ariadna 40
 
1221 ariadna 41
    $notifyeditingon  = empty($_GET['notifyeditingon']) ? 0 : intval($_GET['notifyeditingon'], 10);
1167 ariadna 42
 
1302 ariadna 43
    $isinvited = isguestuser($USER);
44
 
45
    if (
46
        has_capability('moodle/course:manageactivities', $course_context, $USER->id) ||
47
        has_capability('moodle/course:viewhiddenactivities', $course_context, $USER->id) ||
48
        $notifyeditingon
49
    ) {
1233 ariadna 50
        $searchURL = false;
1302 ariadna 51
    } else if ($isinvited) {
52
        $searchURL = true; // permitir redirección al módulo visible
1233 ariadna 53
    } else {
54
        $searchURL = true;
1146 efrain 55
    }
1167 ariadna 56
 
57
    if ($searchURL) {
1146 efrain 58
        $completioninfo = new \completion_info($course);
1167 ariadna 59
 
60
 
1146 efrain 61
        $modules = get_fast_modinfo($course->id)->get_cms();
62
        if (!empty($modules)) {
63
            foreach ($modules as $module) {
64
                if (!$module->uservisible || $module->is_stealth() || empty($module->url)) {
65
                    continue;
66
                }
67
                $linkURL = new \moodle_url($module->url, array('forceview' => 1));
1167 ariadna 68
 
1146 efrain 69
                $completiondata = $completioninfo->get_data($module, true);
70
                if ($completiondata &&  $completiondata->completionstate == COMPLETION_COMPLETE || $completiondata->completionstate == COMPLETION_COMPLETE_PASS) {
71
                    continue;
72
                }
73
                break;
1139 ariadna 74
            }
1119 efrain 75
        }
1146 efrain 76
    }
1126 efrain 77
}
1119 efrain 78
 
1165 efrain 79
if (!empty($linkURL)) {
80
    redirect($linkURL);
1126 efrain 81
    exit;
1167 ariadna 82
}
1116 efrain 83
 
84
 
533 ariadna 85
$draweropenright = false;
86
$extraclasses = [];
87
 
88
$courseindexopen = false;
89
$blockdraweropen = false;
90
 
91
// Moodle 4. - Add block button in editing mode.
92
$addblockbutton = $OUTPUT->addblockbutton();
93
if (isloggedin()) {
94
    $courseindexopen = (get_user_preferences('drawer-open-index', true) == true);
95
    $blockdraweropen = (get_user_preferences('drawer-open-block') == true);
96
} else {
97
    $courseindexopen = false;
98
    $blockdraweropen = false;
99
}
100
 
101
if (defined('BEHAT_SITE_RUNNING')) {
102
    $blockdraweropen = true;
103
}
104
 
105
$extraclasses = ['uses-drawers'];
106
// End.
107
 
108
// Dark mode.
109
if (isloggedin()) {
110
    $navdraweropen = get_user_preferences('drawer-open-nav', true);
111
    $draweropenright = (get_user_preferences('sidepre-open', 'true') == 'true');
112
 
113
    if (theme_universe_get_setting('darkmodetheme') == '1') {
114
        $darkmodeon = get_user_preferences('darkmode-on');
115
        if ($darkmodeon) {
116
            $extraclasses[] = 'theme-dark';
117
        }
118
        $darkmodetheme = true;
119
    } else {
120
        $darkmodeon = false;
121
    }
122
} else {
123
    $navdraweropen = false;
124
}
125
 
126
if (theme_universe_get_setting('darkmodefirst') == '1') {
127
    $extraclasses[] = 'theme-dark';
128
    $darkmodetheme = false;
129
    $darkmodeon = true;
130
}
131
 
132
$siteurl = $CFG->wwwroot;
133
 
134
$blockshtml = $OUTPUT->blocks('side-pre');
135
$hasblocks = (strpos($blockshtml, 'data-block=') !== false || !empty($addblockbutton));
136
if (!$hasblocks) {
137
    $blockdraweropen = false;
138
}
139
 
140
if (theme_universe_get_setting('hidecourseindexnav') == true) {
141
    $hidecourseindexnav = true;
142
} else {
143
    $hidecourseindexnav = false;
144
}
145
 
146
if (theme_universe_get_setting('hidecourseindexnav') == false) {
147
    $courseindex = core_course_drawer();
148
    if (!$courseindex) {
149
        $courseindexopen = false;
150
    }
151
    if ($courseindexopen == false) {
152
        $extraclasses[] = 'drawer-open-index--closed';
153
    } else {
154
        $extraclasses[] = 'drawer-open-index--open';
155
    }
156
} else {
157
    $courseindex = false;
158
    $courseindexopen = false;
159
}
160
 
161
$sidecourseblocks = $OUTPUT->blocks('sidecourseblocks');
162
$hassidecourseblocks = strpos($sidecourseblocks, 'data-block=') !== false;
163
 
164
 
165
if ($draweropenright && $hasblocks) {
166
    $extraclasses[] = 'drawer-open-right';
167
}
168
 
169
$ctopbl = $OUTPUT->blocks('ctopbl');
170
$cbottombl = $OUTPUT->blocks('cbottombl');
171
$cstopbl = $OUTPUT->blocks('cstopbl');
172
$csbottombl = $OUTPUT->blocks('csbottombl');
173
$coursetab1 = $OUTPUT->blocks('coursetab-a');
174
$coursetab2 = $OUTPUT->blocks('coursetab-b');
175
$coursetab3 = $OUTPUT->blocks('coursetab-c');
176
$coursetab4 = $OUTPUT->blocks('coursetab-d');
177
$coursetab5 = $OUTPUT->blocks('coursetab-e');
178
 
179
// Moodle 4.
180
$forceblockdraweropen = $OUTPUT->firstview_fakeblocks();
181
 
182
$secondarynavigation = false;
183
$overflow = '';
184
if ($PAGE->has_secondary_navigation()) {
185
    $tablistnav = $PAGE->has_tablist_secondary_navigation();
186
    $moremenu = new \core\navigation\output\more_menu($PAGE->secondarynav, 'nav-tabs', true, $tablistnav);
187
    $secondarynavigation = $moremenu->export_for_template($OUTPUT);
188
    $overflowdata = $PAGE->secondarynav->get_overflow_menu_data();
189
    if (!is_null($overflowdata)) {
190
        $overflow = $overflowdata->export_for_template($OUTPUT);
191
    }
192
}
193
 
194
$primary = new core\navigation\output\primary($PAGE);
195
$renderer = $PAGE->get_renderer('core');
196
$primarymenu = $primary->export_for_template($renderer);
197
$buildregionmainsettings = !$PAGE->include_region_main_settings_in_header_actions() && !$PAGE->has_secondary_navigation();
198
// If the settings menu will be included in the header then don't add it here.
199
$regionmainsettingsmenu = $buildregionmainsettings ? $OUTPUT->region_main_settings_menu() : false;
200
 
201
$header = $PAGE->activityheader;
202
$headercontent = $header->export_for_template($renderer);
203
 
204
// RUI.
205
$iscoursepage = true;
206
 
207
if ($hassidecourseblocks) {
208
    $extraclasses[] = 'page-has-blocks';
209
}
210
 
211
if (!isloggedin() || isguestuser()) {
212
    $isnotloggedin = true;
213
} else {
214
    $isnotloggedin = false;
215
}
216
 
217
// Check if guest user.
218
if (isguestuser()) {
219
    $extraclasses[] = 'moodle-guest-user';
220
}
221
 
222
// Start - Course Image Position (theme settings).
223
$courseimage = theme_universe_get_setting('ipcourseimage');
224
 
225
if ($hassidecourseblocks) {
226
    $extraclasses[] = 'page-has-blocks';
227
}
228
 
229
if ($PAGE->course->enablecompletion == '1') {
230
    $extraclasses[] = 'rui-course--enablecompletion';
231
}
232
 
233
if ($PAGE->course->showactivitydates == '1') {
234
    $extraclasses[] = 'rui-course--showactivitydates';
235
}
236
 
237
if ($PAGE->course->visible == '1') {
238
    $extraclasses[] = 'rui-course--visible';
239
}
240
 
241
$iscoursepage = true;
242
 
243
if (theme_universe_get_setting('backtotop') == '1') {
244
    $extraclasses[] = 'back-to-top-on';
245
}
246
 
247
$bodyattributes = $OUTPUT->body_attributes($extraclasses);
248
 
249
$templatecontext = [
250
    'sitename' => format_string($SITE->shortname, true, ['context' => context_course::instance(SITEID), "escape" => false]),
251
    'output' => $OUTPUT,
252
    'bodyattributes' => $bodyattributes,
253
    'darkmodeon' => !empty($darkmodeon),
254
    'darkmodetheme' => !empty($darkmodetheme),
255
    'siteurl' => $siteurl,
256
    'sidepreblocks' => $blockshtml,
257
    'hasblocks' => $hasblocks,
258
    'navdraweropen' => $navdraweropen,
259
    'draweropenright' => $draweropenright,
260
    'isnotloggedin' => $isnotloggedin,
261
    'ctopbl' => $ctopbl,
262
    'cbottombl' => $cbottombl,
263
    'cstopbl' => $cstopbl,
264
    'csbottombl' => $csbottombl,
265
    'coursetab-a' => $coursetab1,
266
    'coursetab-b' => $coursetab2,
267
    'coursetab-c' => $coursetab3,
268
    'coursetab-d' => $coursetab4,
269
    'coursetab-e' => $coursetab5,
270
    'hasctopbl' => !empty($ctopbl),
271
    'hascbottombl' => !empty($cbottombl),
272
    'hascstopbl' => !empty($cstopbl),
273
    'hascsbottombl' => !empty($csbottombl),
274
    'sidecourseblocks' => $sidecourseblocks,
275
    'hassidecourseblocks' => $hassidecourseblocks,
276
    'ipcourseimage' => $courseimage,
277
    'iscoursepage' => $iscoursepage,
278
    // Moodle 4.
279
    'courseindexopen' => $courseindexopen,
280
    'blockdraweropen' => $blockdraweropen,
281
    'courseindex' => $courseindex,
282
    'primarymoremenu' => $primarymenu['moremenu'],
283
    'secondarymoremenu' => $secondarynavigation ?: false,
284
    'headercontent' => $headercontent,
285
    'forceblockdraweropen' => $forceblockdraweropen,
286
    'regionmainsettingsmenu' => $regionmainsettingsmenu,
287
    'hasregionmainsettingsmenu' => !empty($regionmainsettingsmenu),
288
    'overflow' => $overflow,
289
    'addblockbutton' => $addblockbutton,
290
    'hidecourseindexnav' => $hidecourseindexnav,
291
];
292
 
293
// Get and use the course page information banners HTML code, if any course page hints are configured.
294
$coursepageinformationbannershtml = theme_universe_get_course_information_banners();
295
if ($coursepageinformationbannershtml) {
296
    $templatecontext['coursepageinformationbanners'] = $coursepageinformationbannershtml;
297
}
298
// End.
299
 
300
// Load theme settings.
301
$themesettings = new \theme_universe\util\theme_settings();
302
 
303
$templatecontext = array_merge($templatecontext, $themesettings->global_settings());
304
$templatecontext = array_merge($templatecontext, $themesettings->course_settings());
305
 
544 ariadna 306
$PAGE->requires->js_call_amd('theme_universe/rui', 'init');
533 ariadna 307
if (theme_universe_get_setting('backtotop') == '1') {
544 ariadna 308
    $PAGE->requires->js_call_amd('theme_universe/backtotop', 'init');
533 ariadna 309
}
310
 
311
echo $OUTPUT->render_from_template('theme_universe_child/tmpl-course', $templatecontext);