Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Projets publics
Ravada-Mirror
Commits
5c576718
Commit
5c576718
authored
May 29, 2019
by
Francesc Guasch
Browse files
wip(grants): grant new permissions to admins
issue #265
parent
a7e6edfc
Changes
1
Hide whitespace changes
Inline
Side-by-side
lib/Ravada.pm
View file @
5c576718
...
...
@@ -945,6 +945,7 @@ sub _add_grant($self, $grant, $allowed, $description) {
}
return
if
$id
;
warn
"
INFO: Addging grant type
$grant
\n
";
$sth
=
$CONNECTOR
->
dbh
->
prepare
("
INSERT INTO grant_types (name, description)
"
.
"
VALUES (?,?)
");
$sth
->
execute
(
$grant
,
$description
);
...
...
@@ -958,11 +959,13 @@ sub _add_grant($self, $grant, $allowed, $description) {
my
$sth_insert
=
$CONNECTOR
->
dbh
->
prepare
(
"
INSERT INTO grants_user (id_user, id_grant, allowed) VALUES(?,?,?)
");
$sth
=
$CONNECTOR
->
dbh
->
prepare
("
SELECT id,name FROM users WHERE is_temporary = 0
");
$sth
=
$CONNECTOR
->
dbh
->
prepare
("
SELECT id,name
,is_admin
FROM users WHERE is_temporary = 0
");
$sth
->
execute
;
while
(
my
(
$id_user
,
$name
)
=
$sth
->
fetchrow
)
{
eval
{
$sth_insert
->
execute
(
$id_user
,
$id_grant
,
$allowed
)
};
while
(
my
(
$id_user
,
$name
,
$is_admin
)
=
$sth
->
fetchrow
)
{
my
$allowed_current
=
$allowed
;
$allowed_current
=
1
if
$is_admin
;
eval
{
$sth_insert
->
execute
(
$id_user
,
$id_grant
,
$allowed_current
)
};
die
$@
if
$@
&&
$@
!~
/Duplicate entry /
;
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment