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
f049d487
Commit
f049d487
authored
9 years ago
by
Peter Rotich
Browse files
Options
Downloads
Patches
Plain Diff
Task assignment on create
Check to make sure staff has perm to assign task in target dept.
parent
a8fc7225
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.forms.php
+8
-7
8 additions, 7 deletions
include/class.forms.php
include/class.task.php
+25
-7
25 additions, 7 deletions
include/class.task.php
with
33 additions
and
14 deletions
include/class.forms.php
+
8
−
7
View file @
f049d487
...
...
@@ -2257,6 +2257,11 @@ class AssigneeField extends ChoiceField {
$id
=
key
(
$id
);
}
if
(
$id
[
0
]
==
's'
)
return
Staff
::
lookup
(
substr
(
$id
,
1
));
elseif
(
$id
[
0
]
==
't'
)
return
Team
::
lookup
(
substr
(
$id
,
1
));
return
$id
;
}
...
...
@@ -3941,13 +3946,8 @@ class AssignmentForm extends Form {
function
getAssignee
()
{
if
(
!
isset
(
$this
->
_assignee
))
{
$value
=
$this
->
getField
(
'assignee'
)
->
getClean
();
if
(
$value
[
0
]
==
's'
)
$this
->
_assignee
=
Staff
::
lookup
(
substr
(
$value
,
1
));
elseif
(
$value
[
0
]
==
't'
)
$this
->
_assignee
=
Team
::
lookup
(
substr
(
$value
,
1
));
}
if
(
!
isset
(
$this
->
_assignee
))
$this
->
_assignee
=
$this
->
getField
(
'assignee'
)
->
getClean
();
return
$this
->
_assignee
;
}
...
...
@@ -3958,6 +3958,7 @@ class AssignmentForm extends Form {
return
array
(
'dept_id'
=>
$dept
);
};
}
}
class
TransferForm
extends
Form
{
...
...
This diff is collapsed.
Click to expand it.
include/class.task.php
+
25
−
7
View file @
f049d487
...
...
@@ -1129,9 +1129,11 @@ class Task extends TaskModel implements RestrictedAccess, Threadable {
}
static
function
create
(
$vars
=
false
)
{
global
$cfg
;
global
$thisstaff
,
$cfg
;
if
(
!
is_array
(
$vars
))
if
(
!
is_array
(
$vars
)
||
!
$thisstaff
||
!
$thisstaff
->
hasPerm
(
Task
::
PERM_CREATE
,
false
))
return
null
;
$task
=
parent
::
create
(
array
(
...
...
@@ -1142,15 +1144,14 @@ class Task extends TaskModel implements RestrictedAccess, Threadable {
'created'
=>
new
SqlFunction
(
'NOW'
),
'updated'
=>
new
SqlFunction
(
'NOW'
),
));
// Save internal fields.
if
(
$vars
[
'internal_formdata'
][
'staff_id'
])
$task
->
staff_id
=
$vars
[
'internal_formdata'
][
'staff_id'
];
if
(
$vars
[
'internal_formdata'
][
'dept_id'
])
$task
->
dept_id
=
$vars
[
'internal_formdata'
][
'dept_id'
];
if
(
$vars
[
'internal_formdata'
][
'duedate'
])
$task
->
duedate
=
$vars
[
'internal_formdata'
][
'duedate'
];
$task
->
save
(
true
);
if
(
!
$task
->
save
(
true
))
return
false
;
// Add dynamic data
$task
->
addDynamicData
(
$vars
[
'default_formdata'
]);
...
...
@@ -1158,6 +1159,23 @@ class Task extends TaskModel implements RestrictedAccess, Threadable {
// Create a thread + message.
$thread
=
TaskThread
::
create
(
$task
);
$thread
->
addDescription
(
$vars
);
$task
->
logEvent
(
'created'
,
null
,
$thisstaff
);
// Get role for the dept
$role
=
$thisstaff
->
getRole
(
$task
->
dept_id
);
// Assignment
if
(
$vars
[
'internal_formdata'
][
'assignee'
]
// skip assignment if the user doesn't have perm.
&&
$role
->
hasPerm
(
Task
::
PERM_ASSIGN
))
{
$_errors
=
array
();
$form
=
AssignmentForm
::
instantiate
(
array
(
'assignee'
=>
$vars
[
'internal_formdata'
][
'assignee'
]));
$task
->
assign
(
$form
,
$_errors
);
}
Signal
::
send
(
'task.created'
,
$task
);
return
$task
;
...
...
@@ -1348,7 +1366,7 @@ extends AbstractForm {
'required'
=>
true
,
'layout'
=>
new
GridFluidCell
(
6
),
)),
'
staff_id
'
=>
new
AssigneeField
(
array
(
'
assignee
'
=>
new
AssigneeField
(
array
(
'id'
=>
2
,
'label'
=>
__
(
'Assignee'
),
'required'
=>
false
,
...
...
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