Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
osticket
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
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
docker
osticket
Commits
166e5fed
Commit
166e5fed
authored
11 years ago
by
Jared Hancock
Browse files
Options
Downloads
Patches
Plain Diff
Simplify header detection logic with outdent
parent
35b5d27b
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
include/class.user.php
+30
-31
30 additions, 31 deletions
include/class.user.php
with
30 additions
and
31 deletions
include/class.user.php
+
30
−
31
View file @
166e5fed
...
@@ -332,43 +332,42 @@ class User extends UserModel {
...
@@ -332,43 +332,42 @@ class User extends UserModel {
if
(
$f
->
get
(
'name'
))
if
(
$f
->
get
(
'name'
))
$named_fields
[]
=
$f
;
$named_fields
[]
=
$f
;
if
((
$data
=
fgetcsv
(
$stream
,
1000
,
","
)))
{
if
(
!
(
$data
=
fgetcsv
(
$stream
,
1000
,
","
)))
if
(
Validator
::
is_email
(
$data
[
1
]))
{
return
'Whoops. Perhaps you meant to send some CSV records'
;
$has_header
=
false
;
// We don't have an header!
}
if
(
Validator
::
is_email
(
$data
[
1
]))
{
else
{
$has_header
=
false
;
// We don't have an header!
$headers
=
array
();
}
foreach
(
$data
as
$h
)
{
else
{
$found
=
false
;
$headers
=
array
();
foreach
(
$all_fields
as
$f
)
{
foreach
(
$data
as
$h
)
{
if
(
in_array
(
mb_strtolower
(
$h
),
array
(
$found
=
false
;
mb_strtolower
(
$f
->
get
(
'name'
)),
mb_strtolower
(
$f
->
get
(
'label'
)))))
{
foreach
(
$all_fields
as
$f
)
{
$found
=
true
;
if
(
in_array
(
mb_strtolower
(
$h
),
array
(
if
(
!
$f
->
get
(
'name'
))
mb_strtolower
(
$f
->
get
(
'name'
)),
mb_strtolower
(
$f
->
get
(
'label'
)))))
{
return
$h
.
': Field must have `variable` set to be imported'
;
$found
=
true
;
if
(
!
$f
->
get
(
'name'
))
return
$h
.
': Field must have `variable` set to be imported'
;
$headers
[
$f
->
get
(
'name'
)]
=
$f
->
get
(
'label'
);
break
;
}
}
if
(
!
$found
)
{
$has_header
=
false
;
if
(
count
(
$data
)
==
count
(
$named_fields
))
{
// Number of fields in the user form matches the number
// of fields in the data. Assume things line up
$headers
=
array
();
foreach
(
$named_fields
as
$f
)
$headers
[
$f
->
get
(
'name'
)]
=
$f
->
get
(
'label'
);
$headers
[
$f
->
get
(
'name'
)]
=
$f
->
get
(
'label'
);
break
;
break
;
}
}
}
if
(
!
$found
)
{
else
{
$has_header
=
false
;
return
$h
.
': Unable to map header to a user field'
;
if
(
count
(
$data
)
==
count
(
$named_fields
))
{
// Number of fields in the user form matches the number
// of fields in the data. Assume things line up
$headers
=
array
();
foreach
(
$named_fields
as
$f
)
$headers
[
$f
->
get
(
'name'
)]
=
$f
->
get
(
'label'
);
break
;
}
else
{
return
$h
.
': Unable to map header to a user field'
;
}
}
}
}
}
}
}
}
}
else
return
'Whoops. Perhaps you meant to send some CSV records'
;
// 'name' and 'email' MUST be in the headers
// 'name' and 'email' MUST be in the headers
if
(
!
isset
(
$headers
[
'name'
])
||
!
isset
(
$headers
[
'email'
]))
if
(
!
isset
(
$headers
[
'name'
])
||
!
isset
(
$headers
[
'email'
]))
...
...
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