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
4fb0a8f0
Commit
4fb0a8f0
authored
12 years ago
by
Peter Rotich
Browse files
Options
Downloads
Patches
Plain Diff
Add ability to manage groups (access) on department add/edit.
parent
801e89a6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/class.dept.php
+52
-8
52 additions, 8 deletions
include/class.dept.php
include/staff/department.inc.php
+25
-0
25 additions, 0 deletions
include/staff/department.inc.php
with
77 additions
and
8 deletions
include/class.dept.php
+
52
−
8
View file @
4fb0a8f0
...
...
@@ -19,6 +19,9 @@ class Dept {
var
$email
;
var
$sla
;
var
$manager
;
var
$members
;
var
$groups
;
var
$ht
;
function
Dept
(
$id
){
...
...
@@ -47,7 +50,7 @@ class Dept {
$this
->
id
=
$this
->
ht
[
'dept_id'
];
$this
->
email
=
$this
->
sla
=
$this
->
manager
=
null
;
$this
->
getEmail
();
//Auto load email struct.
$this
->
members
=
array
();
$this
->
members
=
$this
->
groups
=
array
();
return
true
;
}
...
...
@@ -113,7 +116,6 @@ class Dept {
}
function
getSLAId
(){
return
$this
->
ht
[
'sla_id'
];
}
...
...
@@ -202,14 +204,53 @@ class Dept {
return
$this
->
getHashtable
();
}
function
update
(
$vars
,
&
$errors
){
if
(
$this
->
save
(
$this
->
getId
(),
$vars
,
$errors
))
{
$this
->
reload
();
return
true
;
function
getAllowedGroups
()
{
if
(
$this
->
groups
)
return
$this
->
groups
;
$sql
=
'SELECT group_id FROM '
.
GROUP_DEPT_TABLE
.
' WHERE dept_id='
.
db_input
(
$this
->
getId
());
if
((
$res
=
db_query
(
$sql
))
&&
db_num_rows
(
$res
))
{
while
(
list
(
$id
)
=
db_fetch_row
(
$res
))
$this
->
groups
[]
=
$id
;
}
return
false
;
return
$this
->
groups
;
}
function
updateAllowedGroups
(
$groups
)
{
if
(
$groups
)
{
foreach
(
$groups
as
$k
=>
$id
)
{
$sql
=
'INSERT IGNORE INTO '
.
GROUP_DEPT_TABLE
.
' SET dept_id='
.
db_input
(
$this
->
getId
())
.
', group_id='
.
db_input
(
$id
);
db_query
(
$sql
);
}
}
$sql
=
'DELETE FROM '
.
GROUP_DEPT_TABLE
.
' WHERE dept_id='
.
db_input
(
$this
->
getId
());
if
(
$groups
)
$sql
.
=
' AND group_id NOT IN('
.
implode
(
','
,
db_input
(
$groups
))
.
')'
;
db_query
(
$sql
);
return
true
;
}
function
update
(
$vars
,
&
$errors
){
if
(
!
$this
->
save
(
$this
->
getId
(),
$vars
,
$errors
))
return
false
;
$this
->
updateAllowedGroups
(
$vars
[
'groups'
]);
$this
->
reload
();
return
true
;
}
function
delete
()
{
...
...
@@ -282,7 +323,10 @@ class Dept {
}
function
create
(
$vars
,
&
$errors
)
{
return
Dept
::
save
(
0
,
$vars
,
$errors
);
if
((
$id
=
self
::
save
(
0
,
$vars
,
$errors
))
&&
(
$dept
=
self
::
lookup
(
$id
)))
$dept
->
updateAllowedGroups
(
$vars
[
'groups'
]);
return
$id
;
}
function
save
(
$id
,
$vars
,
&
$errors
)
{
...
...
This diff is collapsed.
Click to expand it.
include/staff/department.inc.php
+
25
−
0
View file @
4fb0a8f0
...
...
@@ -9,6 +9,8 @@ if($dept && $_REQUEST['a']!='add') {
$submit_text
=
'Save Changes'
;
$info
=
$dept
->
getInfo
();
$info
[
'id'
]
=
$dept
->
getId
();
$info
[
'groups'
]
=
$dept
->
getAllowedGroups
();
$qstr
.
=
'&id='
.
$dept
->
getId
();
}
else
{
$title
=
'Add New Department'
;
...
...
@@ -201,6 +203,29 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info);
<span
class=
"error"
>
<?php
echo
$errors
[
'autoresp_email_id'
];
?>
</span>
</td>
</tr>
<tr>
<th
colspan=
"2"
>
<em><strong>
Department Access
</strong>
: Check all groups allowed to access department.
</em>
</th>
</tr>
<tr><td
colspan=
2
><em>
Primary department members and manager will always have access regarless of group selection or assignment.
</em></td></tr>
<?php
$sql
=
'SELECT group_id, group_name, count(staff.staff_id) as members '
.
' FROM '
.
GROUP_TABLE
.
' grp '
.
' LEFT JOIN '
.
STAFF_TABLE
.
' staff USING(group_id) '
.
' GROUP by grp.group_id '
.
' ORDER BY group_name'
;
if
((
$res
=
db_query
(
$sql
))
&&
db_num_rows
(
$res
)){
while
(
list
(
$id
,
$name
,
$members
)
=
db_fetch_row
(
$res
))
{
if
(
$members
>
0
)
$members
=
sprintf
(
'<a href="staff.php?a=filter&gid=%d">%d</a>'
,
$id
,
$members
);
$ck
=
(
$info
[
'groups'
]
&&
in_array
(
$id
,
$info
[
'groups'
]))
?
'checked="checked"'
:
''
;
echo
sprintf
(
'<tr><td colspan=2> <label><input type="checkbox" name="groups[]" value="%d" %s> %s</label> (%s)</td></tr>'
,
$id
,
$ck
,
$name
,
$members
);
}
}
?>
<tr>
<th
colspan=
"2"
>
<em><strong>
Department Signature
</strong>
: Optional signature used on outgoing emails.
<span
class=
"error"
>
<?php
echo
$errors
[
'signature'
];
?>
</span></em>
...
...
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