forked from GibbonEdu/core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
preferences.php
135 lines (106 loc) · 5.53 KB
/
preferences.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
<?php
/*
Gibbon, Flexible & Open School System
Copyright (C) 2010, Ross Parker
This program 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.
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*/
use Gibbon\Domain\System\SettingGateway;
use Gibbon\Forms\Form;
use Gibbon\Forms\DatabaseFormFactory;
if (!$session->exists("username")) {
// Access denied
$page->addError(__('You do not have access to this action.'));
} else {
$page->breadcrumbs->add(__('Preferences'));
$return = $_GET['return'] ?? null;
//Deal with force reset notification
$forceReset = $_GET['forceReset'] ?? null;
if ($forceReset == 'Y' AND $return != 'successa') {
$page->addMessage(__('Your account has been flagged for a password reset. You cannot continue into the system until you change your password.'));
}
$returns = array();
$returns['errora'] = sprintf(__('Your account status could not be updated, and so you cannot continue to use the system. Please contact %1$s if you have any questions.'), "<a href='mailto:".$session->get('organisationAdministratorEmail')."'>".$session->get('organisationAdministratorName').'</a>');
$returns['error4'] = __('Your request failed due to non-matching passwords.');
$returns['error3'] = __('Your request failed due to incorrect current password.');
$returns['error6'] = __('Your request failed because your password does not meet the minimum requirements for strength.');
$returns['error7'] = __('Your request failed because your new password is the same as your current password.');
$page->return->addReturns($returns);
$data = array('gibbonPersonID' => $session->get('gibbonPersonID'));
$sql = 'SELECT * FROM gibbonPerson WHERE gibbonPersonID=:gibbonPersonID';
$result = $connection2->prepare($sql);
$result->execute($data);
if ($result->rowCount() == 1) {
$values = $result->fetch();
}
$form = Form::create('resetPassword', $session->get('absoluteURL').'/preferencesPasswordProcess.php');
$form->addRow()->addHeading(__('Reset Password'));
$policy = getPasswordPolicy($guid, $connection2);
if ($policy != false) {
$form->addRow()->addAlert($policy, 'warning');
}
$row = $form->addRow();
$row->addLabel('password', __('Current Password'));
$row->addPassword('password')
->required()
->maxLength(30);
$row = $form->addRow();
$row->addLabel('passwordNew', __('New Password'));
$row->addPassword('passwordNew')
->addPasswordPolicy($pdo)
->addGeneratePasswordButton($form)
->required()
->maxLength(30);
$row = $form->addRow();
$row->addLabel('passwordConfirm', __('Confirm New Password'));
$row->addPassword('passwordConfirm')
->addConfirmation('passwordNew')
->required()
->maxLength(30);
$row = $form->addRow();
$row->addFooter();
$row->addSubmit();
echo $form->getOutput();
if ($forceReset != 'Y') {
$staff = false;
foreach ($session->get('gibbonRoleIDAll') as $role) {
$roleCategory = getRoleCategory($role[0], $connection2);
$staff = $staff || ($roleCategory == 'Staff');
}
$form = Form::create('preferences', $session->get('absoluteURL').'/preferencesProcess.php');
$form->setFactory(DatabaseFormFactory::create($pdo));
$form->addRow()->addHeading(__('Settings'));
$row = $form->addRow();
$row->addLabel('calendarFeedPersonal', __('Personal Google Calendar ID'))->description(__('Google Calendar ID for your personal calendar.').'<br/>'.__('Only enables timetable integration when logging in via Google.'));
$password = $row->addTextField('calendarFeedPersonal');
$personalBackground = $container->get(SettingGateway::class)->getSettingByScope('User Admin', 'personalBackground');
if ($personalBackground == 'Y') {
$row = $form->addRow();
$row->addLabel('personalBackground', __('Personal Background'))->description(__('Set your own custom background image.').'<br/>'.__('Please provide URL to image.'));
$password = $row->addURL('personalBackground');
}
$row = $form->addRow();
$row->addLabel('gibbonThemeIDPersonal', __('Personal Theme'))->description(__('Override the system theme.'));
$row->addSelectTheme('gibbonThemeIDPersonal');
$row = $form->addRow();
$row->addLabel('gibboni18nIDPersonal', __('Personal Language'))->description(__('Override the system default language.'));
$row->addSelectI18n('gibboni18nIDPersonal');
$row = $form->addRow();
$row->addLabel('receiveNotificationEmails', __('Receive Email Notifications?'))->description(__('Notifications can always be viewed on screen.'));
$row->addYesNo('receiveNotificationEmails');
$row = $form->addRow();
$row->addFooter();
$row->addSubmit();
$form->loadAllValuesFrom($values);
echo $form->getOutput();
}
}
?>