Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
<?php
2
// This file is part of the Local welcome plugin
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
 * This plugin sends users a welcome message after logging in
19
 * and notify a moderator a new user has been added
20
 * it has a settings page that allow you to configure the messages
21
 * send.
22
 *
23
 * @package    local
24
 * @subpackage welcome
25
 * @copyright  2017 Bas Brands, basbrands.nl, bas@sonsbeekmedia.nl
26
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
27
 */
28
 
29
require_once('../../config.php');
30
 
31
$context = context_system::instance();
32
 
33
require_login();
34
if (!is_siteadmin()) {
35
    return '';
36
}
37
$welcome = new \local_welcome\message();
38
 
39
$PAGE->set_context($context);
40
$PAGE->set_url('/local/welcome/index.php.php');
41
$PAGE->set_heading($SITE->fullname);
42
$PAGE->set_pagelayout('admin');
43
$PAGE->set_title(get_string('pluginname', 'local_welcome'));
44
$PAGE->navbar->add(get_string('pluginname', 'local_welcome'));
45
 
46
$tableheader = array(
47
    get_string('fieldname', 'local_welcome'),
48
    get_string('yourvalue', 'local_welcome'));
49
 
50
$customfields = $welcome->customfields;
51
$customvalues = $welcome->get_user_custom_values($USER);
52
 
53
// Custom profile Fields.
54
$tablecustom = new html_table();
55
$tablecustom->head = $tableheader;
56
 
57
foreach ($customfields as $field) {
58
    $tablecustom->data[] = array('[['.$field.']]', $customvalues[$field]);
59
}
60
 
61
// Moodle welcome template Fields.
62
$tablewelcome = new html_table();
63
$tablecustom->head = $tableheader;
64
 
65
foreach ($welcome->welcomefields as $field) {
66
    $tablewelcome->data[] = array('[['.$field.']]', $welcome->welcomevalues[$field]);
67
}
68
 
69
// Moodle default user template Fields.
70
$tabledefault = new html_table();
71
$tabledefault->head = $tableheader;
72
$userdefaultvalues = $welcome->get_user_default_values($USER);
73
 
74
foreach ($welcome->defaultfields as $field) {
75
    $tabledefault->data[] = array('[['.$field.']]', $userdefaultvalues[$field]);
76
}
77
 
78
$editurl = new moodle_url('/admin/settings.php', array('section' => 'local_welcome'));
79
 
80
echo $OUTPUT->header();
81
 
82
echo html_writer::tag('h2', get_string('pluginname', 'local_welcome'));
83
echo html_writer::tag('p', get_string('globalhelp', 'local_welcome'));
84
echo $OUTPUT->single_button($editurl, get_string('configure', 'local_welcome'));
85
 
86
echo html_writer::tag('h2', get_string('customprofilefields', 'local_welcome'));
87
echo html_writer::table($tablecustom);
88
 
89
echo html_writer::tag('h2', get_string('welcomefields', 'local_welcome'));
90
echo html_writer::table($tablewelcome);
91
 
92
echo html_writer::tag('h2', get_string('defaultprofilefields', 'local_welcome'));
93
echo html_writer::table($tabledefault);
94
echo $OUTPUT->footer();