Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
smradius
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
shail
smradius
Commits
1f13b074
Commit
1f13b074
authored
15 years ago
by
Robert Anderson
Browse files
Options
Downloads
Patches
Plain Diff
Add attributes and groups for multiple users
parent
50de4557
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
webgui/include/ajax/functions/WiSPUsers.php
+65
-1
65 additions, 1 deletion
webgui/include/ajax/functions/WiSPUsers.php
with
65 additions
and
1 deletion
webgui/include/ajax/functions/WiSPUsers.php
+
65
−
1
View file @
1f13b074
...
...
@@ -340,7 +340,7 @@ function createWiSPUser($params) {
);
# If there are no rows we may continue
if
(
$res
->
rowCount
()
==
0
&&
!
defined
(
$wispUser
[
$thisUsername
]))
{
if
(
$res
->
rowCount
()
==
0
&&
!
isset
(
$wispUser
[
$thisUsername
]))
{
$usernameReserved
=
0
;
# Generate random username
...
...
@@ -364,6 +364,70 @@ function createWiSPUser($params) {
array
(
$id
,
'User-Password'
,
'=='
,
$password
)
);
# Grab each attribute and add it's details to the database
if
(
$res
!==
FALSE
&&
isset
(
$params
[
0
][
'Attributes'
]))
{
foreach
(
$params
[
0
][
'Attributes'
]
as
$attr
)
{
# Default value without modifier
$attrValue
=
$attr
[
'Value'
];
if
(
$attr
[
'Name'
]
==
'SMRadius-Capping-Traffic-Limit'
||
$attr
[
'Name'
]
==
'SMRadius-Capping-Uptime-Limit'
)
{
# If modifier is set we need to work out attribute value
if
(
isset
(
$attr
[
'Modifier'
]))
{
switch
(
$attr
[
'Modifier'
])
{
case
"Seconds"
:
$attrValue
=
$attr
[
'Value'
]
/
60
;
case
"Minutes"
:
$attrValue
=
$attr
[
'Value'
];
case
"Hours"
:
$attrValue
=
$attr
[
'Value'
]
*
60
;
case
"Days"
:
$attrValue
=
$attr
[
'Value'
]
*
1440
;
case
"Weeks"
:
$attrValue
=
$attr
[
'Value'
]
*
10080
;
case
"Months"
:
$attrValue
=
$attr
[
'Value'
]
*
44640
;
case
"MBytes"
:
$attrValue
=
$attr
[
'Value'
];
case
"GBytes"
:
$attrValue
=
$attr
[
'Value'
]
*
1024
;
case
"TBytes"
:
$attrValue
=
$attr
[
'Value'
]
*
1048576
;
}
}
}
# Add attribute
$res
=
DBDo
(
"
INSERT INTO
user_attributes (UserID,Name,Operator,Value)
VALUES
(?,?,?,?)"
,
array
(
$id
,
$attr
[
'Name'
],
$attr
[
'Operator'
],
$attrValue
)
);
}
}
# Link user to groups if any selected
if
(
$res
!==
FALSE
&&
isset
(
$params
[
0
][
'Groups'
]))
{
$refinedGroups
=
array
();
# Filter out unique group ID's
foreach
(
$params
[
0
][
'Groups'
]
as
$group
)
{
foreach
(
$group
as
$ID
=>
$value
)
{
$refinedGroups
[
$value
]
=
$value
;
}
}
# Loop through groups
foreach
(
$refinedGroups
as
$groupID
)
{
$res
=
DBDo
(
"INSERT INTO users_to_groups (UserID,GroupID) VALUES (?,?)"
,
array
(
$id
,
$groupID
));
}
}
# Link to wisp users
if
(
$res
!==
FALSE
)
{
$res
=
DBDo
(
"INSERT INTO wisp_userdata (UserID) VALUES (?)"
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment