Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
osticket
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
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
564b0540
Commit
564b0540
authored
7 years ago
by
Peter Rotich
Browse files
Options
Downloads
Patches
Plain Diff
Agents Access Export
Add ability to export agents access in CSV format
parent
ca442132
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
include/class.export.php
+32
-0
32 additions, 0 deletions
include/class.export.php
include/class.staff.php
+32
-15
32 additions, 15 deletions
include/class.staff.php
include/staff/staffmembers.inc.php
+6
-0
6 additions, 0 deletions
include/staff/staffmembers.inc.php
scp/staff.php
+4
-1
4 additions, 1 deletion
scp/staff.php
with
74 additions
and
16 deletions
include/class.export.php
+
32
−
0
View file @
564b0540
...
...
@@ -258,6 +258,38 @@ class Export {
return
false
;
}
static
function
agents
(
$agents
,
$filename
=
''
,
$how
=
'csv'
)
{
// Filename or stream to export agents to
$filename
=
$filename
?:
sprintf
(
'Agents-%s.csv'
,
strftime
(
'%Y%m%d'
));
Http
::
download
(
$filename
,
"text/
$how
"
);
$depts
=
Dept
::
getDepartments
();
echo
self
::
dumpQuery
(
$agents
,
array
(
'::getName'
=>
'Name'
,
'::getUsername'
=>
'Username'
,
'::getStatus'
=>
'Status'
,
'permissions'
=>
'Permissions'
,
'::getDept'
=>
'Primary Department'
,
)
+
$depts
,
$how
,
array
(
'modify'
=>
function
(
&
$record
,
$keys
,
$obj
)
use
(
$depts
)
{
if
((
$i
=
array_search
(
'permissions'
,
$keys
)))
$record
[
$i
]
=
implode
(
","
,
array_keys
(
$obj
->
getPermission
()
->
getInfo
()));
$roles
=
$obj
->
getRoles
();
foreach
(
$depts
as
$k
=>
$v
)
{
if
(
is_numeric
(
$k
)
&&
(
$i
=
array_search
(
$k
,
$keys
))
!==
false
)
{
$record
[
$i
]
=
$roles
[
$k
]
?:
''
;
}
}
return
$record
;
})
);
exit
;
}
}
class
ResultSetExporter
{
...
...
This diff is collapsed.
Click to expand it.
include/class.staff.php
+
32
−
15
View file @
564b0540
...
...
@@ -432,23 +432,27 @@ implements AuthenticatedUser, EmailContact, TemplateVariable {
return
isset
(
$this
->
locale
)
?
$this
->
locale
:
0
;
}
function
getRoles
()
{
if
(
!
isset
(
$this
->
_roles
))
{
$this
->
_roles
=
array
(
$this
->
dept_id
=>
$this
->
role
);
foreach
(
$this
->
dept_access
as
$da
)
$this
->
_roles
[
$da
->
dept_id
]
=
$da
->
role
;
}
return
$this
->
_roles
;
}
function
getRole
(
$dept
=
null
)
{
$deptId
=
is_object
(
$dept
)
?
$dept
->
getId
()
:
$dept
;
if
(
$deptId
&&
$deptId
!=
$this
->
dept_id
)
{
if
(
isset
(
$this
->
_roles
[
$deptId
]))
return
$this
->
_roles
[
$deptId
];
if
(
$access
=
$this
->
dept_access
->
findFirst
(
array
(
'dept_id'
=>
$deptId
)))
return
$this
->
_roles
[
$deptId
]
=
$access
->
role
;
$roles
=
$this
->
getRoles
();
if
(
isset
(
$roles
[
$deptId
]))
return
$roles
[
$deptId
];
if
(
!
$this
->
usePrimaryRoleOnAssignment
())
// View only access
return
new
Role
(
array
());
if
(
$this
->
usePrimaryRoleOnAssignment
())
return
$this
->
role
;
// Fall through to primary role
}
// For the primary department, use the primary role
return
$this
->
role
;
// View only access
return
new
Role
(
array
());
}
function
hasPerm
(
$perm
,
$global
=
true
)
{
...
...
@@ -477,10 +481,14 @@ implements AuthenticatedUser, EmailContact, TemplateVariable {
return
TRUE
;
}
function
is
a
ctive
()
{
function
is
A
ctive
()
{
return
$this
->
isactive
;
}
function
getStatus
()
{
return
$this
->
isActive
()
?
__
(
'Active'
)
:
__
(
'Locked'
);
}
function
isVisible
()
{
return
$this
->
isvisible
;
}
...
...
@@ -490,7 +498,7 @@ implements AuthenticatedUser, EmailContact, TemplateVariable {
}
function
isAvailable
()
{
return
(
$this
->
is
a
ctive
()
&&
!
$this
->
onVacation
());
return
(
$this
->
is
A
ctive
()
&&
!
$this
->
onVacation
());
}
function
showAssignedOnly
()
{
...
...
@@ -1137,6 +1145,15 @@ implements AuthenticatedUser, EmailContact, TemplateVariable {
return
true
;
}
static
function
export
(
$criteria
=
null
,
$filename
=
''
)
{
include_once
(
INCLUDE_DIR
.
'class.error.php'
);
$agents
=
Staff
::
objects
();
// Sort based on name formating
$agents
=
self
::
nsort
(
$agents
);
Export
::
agents
(
$agents
,
$filename
);
}
}
interface
RestrictedAccess
{
...
...
This diff is collapsed.
Click to expand it.
include/staff/staffmembers.inc.php
+
6
−
0
View file @
564b0540
...
...
@@ -143,6 +143,12 @@ $agents->limit($pageNav->getLimit())->offset($pageNav->getStart());
<?php
echo
__
(
'Change Department'
);
?>
</a>
</li>
<li>
<a
class=
"no-pjax"
href=
"staff.php?a=export"
>
<i
class=
"icon-download-alt icon-fixed-width"
></i>
<?php
echo
__
(
'Export Agents'
);
?>
</a>
</li>
<!-- TODO: Implement "Reset Access" mass action
<li><a class="dialog-first" href="#staff/reset-access">
<i class="icon-puzzle-piece icon-fixed-width"></i>
...
...
This diff is collapsed.
Click to expand it.
scp/staff.php
+
4
−
1
View file @
564b0540
...
...
@@ -171,8 +171,11 @@ if($_POST){
$page
=
'staffmembers.inc.php'
;
$tip_namespace
=
'staff.agent'
;
if
(
$staff
||
(
$_REQUEST
[
'a'
]
&&
!
strcasecmp
(
$_REQUEST
[
'a'
],
'add'
)))
{
if
(
$staff
||
(
$_REQUEST
[
'a'
]
&&
!
strcasecmp
(
$_REQUEST
[
'a'
],
'add'
)))
{
$page
=
'staff.inc.php'
;
}
elseif
(
$_REQUEST
[
'a'
]
&&
!
strcasecmp
(
$_REQUEST
[
'a'
],
'export'
))
{
if
(
!
Staff
::
export
())
$errors
[
'err'
]
=
sprintf
(
__
(
'Unable to export %s.'
),
__
(
'Agents'
));
}
$nav
->
setTabActive
(
'staff'
);
...
...
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