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
be3b6894
Commit
be3b6894
authored
12 years ago
by
Peter Rotich
Browse files
Options
Downloads
Plain Diff
Merge pull request #323 from protich/feature/locks-revisited
Feature/locks revisited
parents
aebdda7c
3c8b1111
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/ajax.tickets.php
+8
-14
8 additions, 14 deletions
include/ajax.tickets.php
include/class.lock.php
+1
-1
1 addition, 1 deletion
include/class.lock.php
include/staff/ticket-view.inc.php
+1
-0
1 addition, 0 deletions
include/staff/ticket-view.inc.php
scp/js/ticket.js
+10
-8
10 additions, 8 deletions
scp/js/ticket.js
with
20 additions
and
23 deletions
include/ajax.tickets.php
+
8
−
14
View file @
be3b6894
...
...
@@ -181,12 +181,10 @@ class TicketsAjaxAPI extends AjaxController {
function
acquireLock
(
$tid
)
{
global
$cfg
,
$thisstaff
;
if
(
!
$tid
or
!
is_numeric
(
$tid
)
or
!
$thisstaff
or
!
$cfg
)
if
(
!
$tid
or
!
is_numeric
(
$tid
)
or
!
$thisstaff
or
!
$cfg
or
!
$cfg
->
getLockTime
()
)
return
0
;
$ticket
=
Ticket
::
lookup
(
$tid
);
if
(
!
$ticket
||
!
$ticket
->
checkStaffAccess
(
$thisstaff
))
if
(
!
(
$ticket
=
Ticket
::
lookup
(
$tid
))
||
!
$ticket
->
checkStaffAccess
(
$thisstaff
))
return
$this
->
json_encode
(
array
(
'id'
=>
0
,
'retry'
=>
false
,
'msg'
=>
'Lock denied!'
));
//is the ticket already locked?
...
...
@@ -198,17 +196,13 @@ class TicketsAjaxAPI extends AjaxController {
//Ticket already locked by staff...try renewing it.
$lock
->
renew
();
//New clock baby!
return
$this
->
json_encode
(
array
(
'id'
=>
$lock
->
getId
(),
'time'
=>
$lock
->
getTime
()));
}
elseif
(
!
(
$lock
=
$ticket
->
acquireLock
(
$thisstaff
->
getId
(),
$cfg
->
getLockTime
())))
{
//unable to obtain the lock..for some really weired reason!
//Client should watch for possible loop on retries. Max attempts?
return
$this
->
json_encode
(
array
(
'id'
=>
0
,
'retry'
=>
true
));
}
//Ticket is not locked or the lock is expired...try locking it...
if
(
$lock
=
$ticket
->
acquireLock
(
$thisstaff
->
getId
(),
$cfg
->
getLockTime
()))
//Set the lock.
return
$this
->
json_encode
(
array
(
'id'
=>
$lock
->
getId
(),
'time'
=>
$lock
->
getTime
()));
//unable to obtain the lock..for some really weired reason!
//Client should watch for possible loop on retries. Max attempts?
return
$this
->
json_encode
(
array
(
'id'
=>
0
,
'retry'
=>
true
));
return
$this
->
json_encode
(
array
(
'id'
=>
$lock
->
getId
(),
'time'
=>
$lock
->
getTime
()));
}
function
renewLock
(
$tid
,
$id
)
{
...
...
This diff is collapsed.
Click to expand it.
include/class.lock.php
+
1
−
1
View file @
be3b6894
...
...
@@ -88,7 +88,7 @@ class TicketLock {
function
renew
(
$lockTime
=
0
)
{
if
(
!
$lockTime
||
!
is_numeric
(
$lockTime
))
//XXX: test to make it works.
$lockTime
=
'(TIME_TO_SEC(TIMEDIFF(created
,expire
))/60)'
;
$lockTime
=
'(TIME_TO_SEC(TIMEDIFF(
expire,
created))/60)'
;
$sql
=
'UPDATE '
.
TICKET_LOCK_TABLE
...
...
This diff is collapsed.
Click to expand it.
include/staff/ticket-view.inc.php
+
1
−
0
View file @
be3b6894
...
...
@@ -366,6 +366,7 @@ if(!$cfg->showNotesInline()) { ?>
<?php
csrf_token
();
?>
<input
type=
"hidden"
name=
"id"
value=
"
<?php
echo
$ticket
->
getId
();
?>
"
>
<input
type=
"hidden"
name=
"msgId"
value=
"
<?php
echo
$msgId
;
?>
"
>
<input
type=
"hidden"
name=
"locktime"
value=
"
<?php
echo
$cfg
->
getLockTime
();
?>
"
>
<input
type=
"hidden"
name=
"a"
value=
"reply"
>
<span
class=
"error"
></span>
<table
border=
"0"
cellspacing=
"0"
cellpadding=
"3"
>
...
...
This diff is collapsed.
Click to expand it.
scp/js/ticket.js
+
10
−
8
View file @
be3b6894
...
...
@@ -93,13 +93,18 @@ var autoLock = {
Init
:
function
(
config
)
{
//make sure we are on ticket view page!
void
(
autoLock
.
form
=
document
.
forms
[
'
reply
'
]);
if
(
!
autoLock
.
form
||
!
autoLock
.
form
.
id
.
value
)
{
return
;
//make sure we are on ticket view page & locking is enabled!
var
fObj
=
$
(
'
form#reply
'
);
if
(
!
fObj
||
!
$
(
'
:input[name=id]
'
,
fObj
).
length
||
!
$
(
'
:input[name=locktime]
'
,
fObj
).
length
||
$
(
'
:input[name=locktime]
'
,
fObj
).
val
()
==
0
)
{
return
;
}
void
(
autoLock
.
tid
=
parseInt
(
autoLock
.
form
.
id
.
value
));
void
(
autoLock
.
tid
=
parseInt
(
$
(
'
:input[name=id]
'
,
fObj
).
val
()));
void
(
autoLock
.
lockTime
=
parseInt
(
$
(
'
:input[name=locktime]
'
,
fObj
).
val
()));
autoLock
.
lockId
=
0
;
autoLock
.
timerId
=
0
;
autoLock
.
lasteventTime
=
0
;
...
...
@@ -108,9 +113,6 @@ var autoLock = {
autoLock
.
renewTime
=
0
;
autoLock
.
renewFreq
=
0
;
//renewal frequency in seconds...based on returned lock time.
autoLock
.
time
=
0
;
if
(
config
&&
config
.
ticket_lock_time
)
autoLock
.
timeTime
=
config
.
ticket_lock_time
autoLock
.
lockAttempts
=
0
;
//Consecutive lock attempt errors
autoLock
.
maxattempts
=
2
;
//Maximum failed lock attempts before giving up.
autoLock
.
warn
=
true
;
...
...
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