-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathregistration.php
192 lines (172 loc) · 7.77 KB
/
registration.php
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
<?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/>.
// @TODO this file is obsolete once edm6 is published.
/**
* Links and settings
* @package localedumessenger
* @copyright 2017 Digital Education Society (http://www.dibig.at)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once('../../config.php');
require_login();
require_once('registration_form.php');
require_once($CFG->libdir . '/adminlib.php');
require_once($CFG->dirroot . '/webservice/lib.php');
require_once($CFG->dirroot . '/local/edumessenger/lib.php');
$PAGE->set_context(context_system::instance());
$PAGE->set_pagelayout('admin');
$PAGE->set_url('/local/edumessenger/registration.php', array());
$PAGE->set_title('eduMessenger Registration');
$PAGE->set_heading('eduMessenger Registration');
echo $OUTPUT->header();
if (!has_capability('local/edumessenger:manage', context_system::instance())) {
echo "<p class=\"alert alert-error\">" . get_string('missing_capability', 'local_edumessenger') . "</p>";
echo $OUTPUT->footer();
exit;
}
$edm = new local_edumessenger();
$regform = new edumessenger_registration_form();
if ($formdata = $regform->get_data()) {
if ($regform->store($edm, $formdata)) {
echo "<p class=\"alert alert-success\">" . get_string('changes_saved', 'local_edumessenger') . "</p>";
} else {
echo "<p class=\"alert alert-error\">" . get_string('changes_note_saved', 'local_edumessenger') . "</p>";
}
}
$auth = $edm->site_auth();
$devmode = optional_param('developermode', -1, PARAM_INT);
if ($devmode > -1) {
$edm->set('developermode', $devmode);
echo "<p class=\"alert alert-success\">Developermode " . (($devmode == '0') ? 'disabled' : 'enabled') . "</p>";
}
$createtoken = optional_param('create_token', -1, PARAM_INT);
if ($createtoken == 1) {
if ($edm->site_register()) {
echo "<p class=\"alert alert-success\">" . get_string('token:changed', 'local_edumessenger') . "</p>";
$auth = $edm->site_auth();
} else {
echo "<p class=\"alert alert-error\">" . get_string('token:failed', 'local_edumessenger') . "</p>";
}
}
$communicationtocentral = (@$auth->status == 'ok' && $edm->secret() != '') ? 1 : 0;
$communicationtomoodle = ($edm->servicetoken != '') ? 1 : 0;
$communicationimage = $CFG->wwwroot . '/local/edumessenger/img/' . $communicationtocentral . $communicationtomoodle . ".gif";
?>
<h3><?php echo get_string('step1:head', 'local_edumessenger'); ?></h3>
<p><?php echo get_string('step1:p1', 'local_edumessenger'); ?></p>
<p><?php echo get_string('step1:p2', 'local_edumessenger'); ?></p>
<table border="0" width="100%" cellpadding="3"
style="background-color: #f5f5f5; border: 1px solid rgba(0, 0, 0, 0.15);border-radius: 4px;padding: 9.5px;">
<tr>
<td align="center"><?php echo get_string('lbl:justclick', 'local_edumessenger'); ?></td>
<td align="center"> </td>
<td align="center"><?php echo str_replace('{wwwroot}', $CFG->wwwroot, get_string('lbl:createwebservicetoken', 'local_edumessenger')); ?></td>
</tr>
<tr>
<td width="40%" style="margin: 0px; text-align: center"
class="alert <?php echo ($communicationtocentral) ? 'alert-success' : 'alert-error'; ?>">
<input type="button"
value="<?php echo get_string((($communicationtocentral) ? 'renew_token' : 'create_token'), 'local_edumessenger'); ?>"
onclick="top.location.href='<?php echo $CFG->wwwroot; ?>/local/edumessenger/registration.php?create_token=1'" />
</td>
<td><img src="<?php echo $communicationimage; ?>" style="width: 100%;" /></td>
<td width="40%" style="margin: 0px; text-align: center;"
class="alert <?php echo ($communicationtomoodle) ? 'alert-success' : 'alert-error'; ?>">
<input type="button" value="<?php echo get_string('control_token', 'local_edumessenger'); ?>"
onclick="top.location.href='<?php echo $CFG->wwwroot; ?>/admin/webservice/tokens.php?action=create'"/>
</td>
</tr>
</table>
<?php
switch(@$auth->status) {
case 'not_registered':
?>
<p>
<?php echo get_string('step1:not_registered', 'local_edumessenger'); ?>
</p>
<?php
break;
case 'wrong_pwd':
?>
<p>
<?php echo get_string('step1:wrong_pwd', 'local_edumessenger'); ?>
</p>
<?php
break;
case 'ok':
if ($edm->servicetoken != "") {
?>
<h3><?php echo get_string('step2:head', 'local_edumessenger'); ?></h3>
<div class="alert alert-<?php echo ($auth->instance->active) ? 'success' : 'error'; ?>">
<p><?php
if ($auth->instance->active) {
echo get_string('step2:p0' . (($auth->instance->active == 1) ? 'active' : 'inactive'), 'local_edumessenger');
} else {
echo get_string('step2:p1', 'local_edumessenger');
}
?></p>
<input type="button" onclick="location.href='<?php echo $edm->regtool(); ?>'"
value="<?php echo get_string('step2:ptool', 'local_edumessenger'); ?>" style="width: 100%;" />
</div>
<?php
} // End if edm->servicetoken!="".
?>
<p>
<?php echo get_string('step2:p2', 'local_edumessenger'); ?>
</p>
<img src="<?php echo $edm->url . "/profile/" . $auth->instance->logo . ".png"; ?>"
alt="Your Logo" style="position: absolute; right: 30px; max-height: 5em;" />
<table border="0" width="100%">
<tr>
<th valign="top"><?php echo get_string('Title', 'local_edumessenger'); ?></th>
<td valign="top"><?php echo $auth->instance->title; ?></td>
</tr>
<tr>
<th valign="top"><?php echo get_string('Contact', 'local_edumessenger'); ?></th>
<td valign="top"><?php echo $auth->instance->contact; ?></td>
</tr>
<tr>
<th valign="top"><?php echo get_string('Webauth', 'local_edumessenger'); ?></th>
<td valign="top">
<?php echo ($auth->instance->webauth) ? get_string('yes', 'local_edumessenger') : get_string('no', 'local_edumessenger'); ?>
</td>
</tr>
<tr>
<th valign="top"><?php echo get_string('Contingent', 'local_edumessenger'); ?></th>
<td valign="top">
<?php
echo $auth->instance->contingent . ' '
. get_string('user' . (($auth->instance->contingent > 0) ? 's' : ''), 'local_edumessenger');
?>
<sup>1)</sup></td>
</tr>
<tr>
<th valign="top"><?php echo get_string('Description', 'local_edumessenger'); ?></th>
<td valign="top"><?php echo $auth->instance->description; ?></td>
</tr>
</table>
<p><sup>1) <?php echo get_string('contingent:info', 'local_edumessenger'); ?></sup></p>
<?php
break;
}
?>
<p><?php echo get_string('step1:p3', 'local_edumessenger'); ?></p>
<div style="background-color: #f5f5f5; border: 1px solid rgba(0, 0, 0, 0.15);border-radius: 4px;padding: 9.5px;">
<?php $regform->display(); ?>
</div>
<?php
$edm->messages_show();
echo $OUTPUT->footer();