]>
git.datanom.net - webcal.git/blob - utils/configure.php
3 require_once 'config.inc.php';
4 require_once 'user_validate.php';
5 require_once 'timezone.php';
6 require_once 'helper.php';
10 if (! defined($_SESSION['__ROOT__']) && empty($_SESSION['__ROOT__'])) {
13 header('Location: ' . WEB_ROOT
. 'error.html');
17 require_once 'persistens.php';
19 $user = $_SESSION['user_settings'];
21 if (count($_POST) > 0 && isset($_POST['action'])) {
22 $db = Persistens
::getInstance(DBDRIVER
);
24 if ($_POST['action'] == "password") {
25 if ($_POST['pwd1'] == $_POST['pwd2']) {
26 $res = $db->changePassword($user->getUid(), sha1($_POST['pwd1']));
28 header("Location: " . WEB_ROOT
. "logout.php");
32 // $res = "uid: ".$user->getUid()." ".$_POST['pwd1']." ".$_POST['pwd2']." -> $res";
36 $res = "Passwords did not compare";
38 $pageView = "<p style=\"text-align: center\">$res</p>";
40 else if ($_POST['action'] == "settings") {
41 file_put_contents('/tmp/davical.log',
42 __FILE__
. ": " . var_export($_POST, TRUE), FILE_APPEND
);
44 if ($_POST['endDay'] > $_POST['startDay']) {
45 $conf['daystart'] = $_POST['startDay'];
46 $conf['dayend'] = $_POST['endDay'];
49 $conf['daystart'] = $user->getStartHour();
50 $conf['dayend'] = $user->getEndHour();
53 ($_POST['timeout'] > 0) ?
$_POST['timeout'] * 60 :
54 $user->getTimeout() / 60;
55 $conf['userview'] = $_POST['viewStyle'];
56 $conf['weekstart'] = ($_POST['startWeek'] == 'SU') ?
1 : 0;
57 $conf['timezone'] = $_POST['timezone'];
58 $conf['userrole'] = $user->getRole();
59 $res = $db->setUserSettings($user->getUid(), $conf);
61 $user->setSettings(array($conf));
62 header("Location: " . $_SERVER['PHP_SELF']);
65 $pageView = "<p style=\"text-align: center\">$res</p>";
69 $timeout = $user->getTimeout() / 60;
70 $viewStyle = $user->getViewStyle();
73 $viewStyle = <<<_SELECT
74 <select name="viewStyle">
75 <option value="day" selected="true">Day</option>
76 <option value="week">Week</option>
77 <option value="month">Month</option>
82 $viewStyle = <<<_SELECT
83 <select name
="viewStyle">
84 <option value
="day">Day
</option
>
85 <option value
="week" selected
="true">Week
</option
>
86 <option value
="month">Month
</option
>
91 $viewStyle = <<<_SELECT
92 <select name="viewStyle">
93 <option value="day">Day</option>
94 <option value="week">Week</option>
95 <option value="month" selected="true">Month</option>
100 $weekStart = $user->getStartWeek();
102 $weekStart = <<<_SELECT
103 <select name
="startWeek">
104 <option value
="SU" selected
="true">Sunday
</option
>
105 <option value
="MO">Monday
</option
>
109 $weekStart = <<<_SELECT
110 <select name="startWeek">
111 <option value="SU">Sunday</option>
112 <option value="MO" selected="true">Monday</option>
116 $dayStart = (int) $user->getStartHour();
117 $start = '<select name="startDay">';
118 for ($i = 0; $i < 25; $i++) {
119 $hour = ($i < 10) ? "0$i:00" : "$i:00";
120 $start .= "<option value=\"$i\"";
122 $start .= " selected=\"true\"";
123 $start .= ">$hour</option>";
125 $start .= '</select>';
126 $dayEnd = (int) $user->getEndHour();
127 $end = '<select name="endDay">';
128 for ($i = 0; $i < 25; $i++) {
129 $hour = ($i < 10) ? "0$i:00" : "$i:00";
130 $end .= "<option value=\"$i\"";
132 $end .= " selected=\"true\"";
133 $end .= ">$hour</option>";
137 $current = $user->getTimezone();
138 foreach ($timezones as $timezone) {
139 $tz .= "<option value=\"$timezone\"";
140 if ($current == $timezone)
141 $tz .= ' selected="true"';
142 $tz .= ">$timezone</option>";
145 $url = getServerUrl();
146 if ($url[strlen($url)-1] == '/')
147 $url = substr($url, 0, -1);
149 $pageView = <<< __EOF
151 <form action="{$_SERVER['PHP_SELF']}" method="post">
152 <table class="config">
154 <th>Setting</th><th>Current</th>
157 <td class="config">Session timeout in minuts</td>
159 <input size="6" name="timeout" type="text" value="$timeout"/>
163 <td class="config">Default view</td><td>$viewStyle</td>
166 <td class="config">Timezone</td>
168 <select name="timezone">
174 <td class="config">Week start on</td><td>$weekStart</td>
177 <td class="config">Day start</td>
178 <td class="config">$start</td>
181 <td class="config">Day end</td>
182 <td class="config">$end</td>
185 <input type="hidden" name="action" value="settings"/>
186 <td class="config" colspan="2" style="text-align: center">
187 <input type="submit" name="setting" value="Submit changes"/>
194 if (strtoupper($user->getUid()) != 'ADMIN') {
195 $pageView .= <<< __EOF
196 <p style="text-align: center">
197 <button type="button" id="calconfig"
198 onclick="document.location.href='$url/utils/calendar.php'">
204 if ($user->getRole() === 0) {
205 $pageView .= <<<__EOF
206 <p style="text-align: center">
207 <button type="button" id="useradm"
208 onclick="document.location.href='$url/utils/users.php'">
212 <button type="button" id="ldapadm"
213 onclick="document.location.href='$url/utils/ldap.php'">
219 $pageView .= <<<__EOF
221 <form action="{$_SERVER['PHP_SELF']}" method="post">
222 <table class="config">
224 <th colspan="2" style="text-align: center">Change password</th>
227 <td colspan="2"><span style="background: red; font-weight: bold;">
228 After changing the password a relogin is required
232 <td class="config">New Password</td>
233 <td class="config"><input name="pwd1" type="password"/></td>
236 <td class="config">Repeat Password</td>
237 <td class="config"><input name="pwd2" type="password"/></td>
240 <input type="hidden" name="action" value="password"/>
241 <td class="config" colspan="2" style="text-align: center">
242 <input type="submit" name="password" value="Submit"/>
251 include TOP_FOLDER.'/include/header.inc.php';
252 include TOP_FOLDER.'/include/menu.inc.php';
254 print "<div id=\"ui\">$pageView</div>";
256 include TOP_FOLDER.'/include/footer.inc.php';
This page took 0.086081 seconds and 6 git commands to generate.