-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsettings.php
More file actions
98 lines (85 loc) · 4.34 KB
/
settings.php
File metadata and controls
98 lines (85 loc) · 4.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Attestoodle plug-in settings.
*
* @package tool_attestoodle
* @copyright 2018 Pole de Ressource Numerique de l'Université du Mans
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
global $DB, $USER, $PAGE;
if ($hassiteconfig) {
$ADMIN->add('courses', new admin_category('attestoodle', 'Attestoodle'));
$ADMIN->add('attestoodle',
new admin_externalpage('toolattestoodle1', get_string('add_training', 'tool_attestoodle'), "$CFG->wwwroot/course/"));
$ADMIN->add('attestoodle',
new admin_externalpage('toolattestoodle2', get_string('training_list_link', 'tool_attestoodle'),
"$CFG->wwwroot/$CFG->admin/tool/attestoodle/index.php"));
$ADMIN->add('attestoodle', new admin_externalpage('toolattestoodle3', get_string('template_certificate', 'tool_attestoodle'),
"$CFG->wwwroot/$CFG->admin/tool/attestoodle/classes/gabarit/listtemplate.php"));
}
// If there aren't any entries in the table then we need to prepare them!
if (!$DB->record_exists('tool_attestoodle_template', ['name' => 'Site'])) {
$model = new stdClass();
$model->name = 'Site';
$model->timecreated = usergetdate(time())[0];
$model->userid = $USER->id;
$idtemplate = $DB->insert_record('tool_attestoodle_template', $model);
$object = new stdClass();
$object->templateid = $idtemplate;
$object->type = 'background';
$object->data = '{ "filename": "attest_background.png" } ';
$DB->insert_record('tool_attestoodle_tpl_detail', $object);
$object = new stdClass();
$object->templateid = $idtemplate;
$object->type = 'learnername';
$object->data = '{ "font": {"family":"helvetica","emphasis":"","size":"14"}, "location": {"x":"66","y":"33"}, "align":"L"} ';
$DB->insert_record('tool_attestoodle_tpl_detail', $object);
$object = new stdClass();
$object->templateid = $idtemplate;
$object->type = 'trainingname';
$object->data = '{ "font": {"family":"helvetica","emphasis":"","size":"14"}, "location": {"x":"66","y":"39"}, "align":"L"} ';
$DB->insert_record('tool_attestoodle_tpl_detail', $object);
$object = new stdClass();
$object->templateid = $idtemplate;
$object->type = 'period';
$object->data = '{ "font": {"family":"helvetica","emphasis":"B","size":"14"}, "location": {"x":"110","y":"18"}, "align":"L"} ';
$DB->insert_record('tool_attestoodle_tpl_detail', $object);
$object = new stdClass();
$object->templateid = $idtemplate;
$object->type = 'totalminutes';
$object->data = '{ "font": {"family":"helvetica","emphasis":"B","size":"14"}, "location": {"x":"86","y":"45"}, "align":"L"} ';
$DB->insert_record('tool_attestoodle_tpl_detail', $object);
$object = new stdClass();
$object->templateid = $idtemplate;
$object->type = 'activities';
$object->data = '{ "font": {"family":"helvetica","emphasis":"","size":"10"}, "location": {"x":"50","y":"60"}, "align":"C"} ';
$DB->insert_record('tool_attestoodle_tpl_detail', $object);
try {
// Enreg image background in file storage.
$fs = get_file_storage();
$file = $fs->get_file(1, 'tool_attestoodle', 'fichier', $idtemplate, '/', 'attest_background.png');
if (!$file) {
$filerecord = ['contextid' => 1, 'component' => 'tool_attestoodle', 'filearea' => 'fichier',
'itemid' => $idtemplate, 'filepath' => '/'];
$url = "$CFG->wwwroot/admin/tool/attestoodle/pix/attest_background.png";
$fs->create_file_from_url($filerecord, $url, null, true);
}
} catch (Exception $e) {
\core\notification::info('repertoire pix inacessible, modele par défaut sans image');
}
}