blob: e1d977ca6c14a51d22164e290fe646c63ee44390 (
plain)
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
|
<%pre>
#include "exception.h"
#include "tools.h"
#include "users.h"
#include "livefeatures.h"
#include "setup.h"
using namespace std;
using namespace vdrlive;
</%pre>
<%args>
// input parameters
string userid;
// form parameters
string username;
string password;
bool ur_editsetup = false;
bool ur_addtimers = false;
bool ur_deltimers = false;
bool ur_delrecs = false;
bool ur_useremote = false;
bool ur_startreplay = false;
bool ur_switchchnl = false;
bool ur_addstimers = false;
bool ur_delstimers = false;
bool ur_editrecs = false;
</%args>
<%session scope="global">
bool logged_in(false);
</%session>
<%request scope="page">
cUser* editUser;
</%request>
<%include>page_init.eh</%include>
<%cpp>
if (!logged_in && LiveSetup().UseAuth()) return reply.redirect("login.html");
#define CHECKIF(x) reply.out() << ( (x) ? "checked=\"checked\"" : "" );
editUser = NULL;
if (request.getMethod() == "POST") {
if (!userid.empty()) {
editUser = Users.GetByUserId( userid );
if ( editUser == 0 )
throw HtmlError( tr("Couldn't find user. Maybe you mistyped your request?") );
editUser->SetName(username);
if (password != std::string(editUser->GetPasswordLength(), '*'))
editUser->SetPassword(password);
}
else
{
if (Users.GetByUserName( username ))
throw HtmlError( tr("This user name is already in use!") );
editUser = new cUser(Users.GetNewId(), username, password);
Users.Add(editUser);
}
editUser->SetUserrights(0);
if (ur_editsetup) editUser->SetRight(UR_EDITSETUP);
if (ur_addtimers) editUser->SetRight(UR_EDITTIMERS);
if (ur_deltimers) editUser->SetRight(UR_DELTIMERS);
if (ur_delrecs) editUser->SetRight(UR_DELRECS);
if (ur_useremote) editUser->SetRight(UR_USEREMOTE);
if (ur_startreplay) editUser->SetRight(UR_STARTREPLAY);
if (ur_switchchnl) editUser->SetRight(UR_SWITCHCHNL);
if (ur_addstimers) editUser->SetRight(UR_EDITSTIMERS);
if (ur_delstimers) editUser->SetRight(UR_DELSTIMERS);
if (ur_editrecs) editUser->SetRight(UR_EDITRECS);
Users.Save();
return reply.redirect("users.html");
}
pageTitle = !userid.empty() ? tr("Edit user") : tr("New user");
if ( !userid.empty() ) {
cUser* User = Users.GetByUserId( userid );
if ( User == 0 )
throw HtmlError( tr("Couldn't find user. Maybe you mistyped your request?") );
username = User->Name();
password = std::string(User->GetPasswordLength(), '*');
ur_editsetup = User->HasRightTo(UR_EDITSETUP);
ur_addtimers = User->HasRightTo(UR_EDITTIMERS);
ur_deltimers = User->HasRightTo(UR_DELTIMERS);
ur_delrecs = User->HasRightTo(UR_DELRECS);
ur_useremote = User->HasRightTo(UR_USEREMOTE);
ur_startreplay = User->HasRightTo(UR_STARTREPLAY);
ur_switchchnl = User->HasRightTo(UR_SWITCHCHNL);
ur_addstimers = User->HasRightTo(UR_EDITSTIMERS);
ur_delstimers = User->HasRightTo(UR_DELSTIMERS);
ur_editrecs = User->HasRightTo(UR_EDITRECS);
editUser = User;
}
else
{
ur_editsetup = true;
ur_addtimers = true;
ur_deltimers = true;
ur_delrecs = true;
ur_useremote = true;
ur_startreplay = true;
ur_switchchnl = true;
ur_addstimers = true;
ur_delstimers = true;
ur_editrecs = true;
}
</%cpp>
<& pageelems.doc_type &>
<html>
<head>
<title>VDR Live - <$ pageTitle $></title>
<& pageelems.stylesheets &>
<& pageelems.ajax_js &>
</head>
<body>
<& pageelems.logo &>
<& menu active=("users") &>
<div class="inhalt">
<form method="post" name="edit_user" action="edit_user.ecpp">
<input type="hidden" name="userid" value="<$ userid $>"/>
<table class="formular" cellpadding="0" cellspacing="0">
<tr class="head">
<td class="toprow leftcol rightcol" colspan="2"><div class="boxheader"><div><div class="caption"><$ pageTitle $></div></div></div></td>
</tr>
<tr>
<td class="label leftcol"><div class="withmargin"><$ tr("Name" ) $>:</div></td>
<td class="rightcol"><input type="text" name="username" value="<$ username $>" size="80" /></td>
</tr>
<tr>
<td class="label leftcol"><div class="withmargin"><$ tr("Password" ) $>:</div></td>
<td class="rightcol"><input type="password" name="password" value="<$ password $>" size="80" /></td>
</tr>
<!-- user rights -->
<tr>
<td class="label leftcol"><div class="withmargin"><$ tr("User rights") $>:</div></td>
<td class="rightcol">
<input type="checkbox" name="ur_editsetup" value="1" <{ CHECKIF(ur_editsetup) }> />
<label for="ur_editsetup"><$ tr("Edit setup") $></label><br>
<input type="checkbox" name="ur_addtimers" value="1" <{ CHECKIF(ur_addtimers) }> />
<label for="ur_addtimers"><$ tr("Add or edit timers") $></label><br>
<input type="checkbox" name="ur_deltimers" value="1" <{ CHECKIF(ur_deltimers) }> />
<label for="ur_deltimers"><$ tr("Delete timers") $></label><br>
<input type="checkbox" name="ur_delrecs" value="1" <{ CHECKIF(ur_delrecs) }> />
<label for="ur_delrecs"><$ tr("Delete recordings") $></label><br>
<input type="checkbox" name="ur_useremote" value="1" <{ CHECKIF(ur_useremote) }> />
<label for="ur_useremote"><$ tr("Use remote menu") $></label><br>
<input type="checkbox" name="ur_startreplay" value="1" <{ CHECKIF(ur_startreplay) }> />
<label for="ur_startreplay"><$ tr("Start replay") $></label><br>
<input type="checkbox" name="ur_switchchnl" value="1" <{ CHECKIF(ur_switchchnl) }> />
<label for="ur_switchchnl"><$ tr("Switch channel") $></label><br>
<%cpp>
if (LiveFeatures< features::epgsearch >().Recent()) {
</%cpp>
<input type="checkbox" name="ur_addstimers" value="1" <{ CHECKIF(ur_addstimers) }> />
<label for="ur_addstimers"><$ tr("Add or edit search timers") $></label><br>
<input type="checkbox" name="ur_delstimers" value="1" <{ CHECKIF(ur_delstimers) }> />
<label for="ur_delstimers"><$ tr("Delete search timers") $></label><br>
<%cpp>
}
</%cpp>
<input type="checkbox" name="ur_editrecs" value="1" <{ CHECKIF(ur_editrecs) }> />
<label for="ur_editrecs"><$ tr("Edit recordings") $></label><br>
</td>
</tr>
<tr>
<td class="buttonpanel leftcol rightcol bottomrow" colspan="2">
<div class="withmargin">
<button class="green" type="submit" name="save"><$ tr("Save") $></button>
<button type="button" class="red" onclick="history.back()"><$ tr("Cancel") $></button>
</div>
</td>
</tr>
</table>
</form>
</div>
</body>
</html>
<%include>page_exit.eh</%include>
|