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
5e3bdb07
Commit
5e3bdb07
authored
9 years ago
by
Jared Hancock
Committed by
Peter Rotich
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
queue: Refuse to set queue a descendent of itself
Also, fix queue paths created at installation time.
parent
ace9b520
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/class.queue.php
+24
-4
24 additions, 4 deletions
include/class.queue.php
include/staff/queue.inc.php
+5
-2
5 additions, 2 deletions
include/staff/queue.inc.php
with
29 additions
and
6 deletions
include/class.queue.php
+
24
−
4
View file @
5e3bdb07
...
@@ -749,8 +749,8 @@ class CustomQueue extends VerySimpleModel {
...
@@ -749,8 +749,8 @@ class CustomQueue extends VerySimpleModel {
if
(
!
$this
->
id
)
if
(
!
$this
->
id
)
return
;
return
;
$path
=
$this
->
parent
?
$this
->
parent
->
get
Path
()
:
''
;
$path
=
$this
->
parent
?
$this
->
parent
->
build
Path
()
:
''
;
return
$path
.
"/
{
$this
->
id
}
"
;
return
rtrim
(
$path
,
"/"
)
.
"/
{
$this
->
id
}
/
"
;
}
}
function
getFullName
()
{
function
getFullName
()
{
...
@@ -800,6 +800,14 @@ class CustomQueue extends VerySimpleModel {
...
@@ -800,6 +800,14 @@ class CustomQueue extends VerySimpleModel {
if
(
$this
->
parent_id
&&
!
$this
->
parent
)
if
(
$this
->
parent_id
&&
!
$this
->
parent
)
$errors
[
'parent_id'
]
=
__
(
'Select a valid queue'
);
$errors
[
'parent_id'
]
=
__
(
'Select a valid queue'
);
// Try to avoid infinite recursion determining ancestry
if
(
$this
->
parent_id
&&
isset
(
$this
->
id
))
{
$P
=
$this
;
while
(
$P
=
$P
->
parent
)
if
(
$P
->
parent_id
==
$this
->
id
)
$errors
[
'parent_id'
]
=
__
(
'Cannot be a descendent of itself'
);
}
// Configure quick filter options
// Configure quick filter options
$this
->
filter
=
$vars
[
'filter'
];
$this
->
filter
=
$vars
[
'filter'
];
if
(
$vars
[
'sort_id'
])
{
if
(
$vars
[
'sort_id'
])
{
...
@@ -925,17 +933,29 @@ class CustomQueue extends VerySimpleModel {
...
@@ -925,17 +933,29 @@ class CustomQueue extends VerySimpleModel {
}
}
function
save
(
$refetch
=
false
)
{
function
save
(
$refetch
=
false
)
{
$wasnew
=
!
isset
(
$this
->
id
);
$nopath
=
!
isset
(
$this
->
path
);
$path_changed
=
isset
(
$this
->
dirty
[
'parent_id'
]);
if
(
$this
->
dirty
)
if
(
$this
->
dirty
)
$this
->
updated
=
SqlFunction
::
NOW
();
$this
->
updated
=
SqlFunction
::
NOW
();
if
(
!
(
$rv
=
parent
::
save
(
$refetch
||
$this
->
dirty
)))
if
(
!
(
$rv
=
parent
::
save
(
$refetch
||
$this
->
dirty
)))
return
$rv
;
return
$rv
;
if
(
$
wasnew
)
{
if
(
$
nopath
)
{
$this
->
path
=
$this
->
buildPath
();
$this
->
path
=
$this
->
buildPath
();
$this
->
save
();
$this
->
save
();
}
}
if
(
$path_changed
)
{
$this
->
children
->
reset
();
$move_children
=
function
(
$q
)
use
(
&
$move_children
)
{
foreach
(
$q
->
children
as
$qq
)
{
$qq
->
path
=
$qq
->
buildPath
();
$qq
->
save
();
$move_children
(
$qq
);
}
};
$move_children
(
$this
);
}
return
$this
->
columns
->
saveAll
()
return
$this
->
columns
->
saveAll
()
&&
$this
->
sorts
->
saveAll
();
&&
$this
->
sorts
->
saveAll
();
}
}
...
...
This diff is collapsed.
Click to expand it.
include/staff/queue.inc.php
+
5
−
2
View file @
5e3bdb07
...
@@ -89,8 +89,11 @@ else {
...
@@ -89,8 +89,11 @@ else {
==
<?php
echo
$queue
->
parent_id
?:
0
;
?>
);"
>
==
<?php
echo
$queue
->
parent_id
?:
0
;
?>
);"
>
<option
value=
"0"
>
—
<?php
echo
__
(
'Top-Level Queue'
);
?>
—
</option>
<option
value=
"0"
>
—
<?php
echo
__
(
'Top-Level Queue'
);
?>
—
</option>
<?php
foreach
(
CustomQueue
::
queues
()
as
$cq
)
{
<?php
foreach
(
CustomQueue
::
queues
()
as
$cq
)
{
if
(
$cq
->
getId
()
==
$queue
->
getId
())
// Queue cannot be a descendent of itself
continue
;
if
(
$cq
->
id
==
$queue
->
id
)
continue
;
if
(
strpos
(
$cq
->
path
,
"/
{
$queue
->
id
}
/"
)
!==
false
)
continue
;
?>
?>
<option
value=
"
<?php
echo
$cq
->
id
;
?>
"
<option
value=
"
<?php
echo
$cq
->
id
;
?>
"
<?php
if
(
$cq
->
getId
()
==
$queue
->
parent_id
)
echo
'selected="selected"'
;
?>
<?php
if
(
$cq
->
getId
()
==
$queue
->
parent_id
)
echo
'selected="selected"'
;
?>
...
...
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