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
77df040b
Commit
77df040b
authored
11 years ago
by
Peter Rotich
Browse files
Options
Downloads
Patches
Plain Diff
Add collaborator class
parent
51a45145
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
include/class.collaborator.php
+132
-0
132 additions, 0 deletions
include/class.collaborator.php
with
132 additions
and
0 deletions
include/class.collaborator.php
0 → 100644
+
132
−
0
View file @
77df040b
<?php
/*********************************************************************
class.collaborator.php
Ticket collaborator
Peter Rotich <peter@osticket.com>
Copyright (c) 2006-2013 osTicket
http://www.osticket.com
Released under the GNU General Public License WITHOUT ANY WARRANTY.
See LICENSE.TXT for details.
vim: expandtab sw=4 ts=4 sts=4:
**********************************************************************/
require_once
(
INCLUDE_DIR
.
'class.user.php'
);
class
Collaborator
{
var
$ht
;
var
$user
;
var
$ticket
;
function
__construct
(
$id
)
{
$this
->
load
(
$id
);
}
function
load
(
$id
)
{
if
(
!
$id
&&
!
(
$id
=
$this
->
getId
()))
return
;
$sql
=
'SELECT * FROM '
.
TICKET_COLLABORATOR_TABLE
.
' WHERE id='
.
db_input
(
$id
);
$this
->
ht
=
db_fetch_array
(
db_query
(
$sql
));
$this
->
ticket
=
$this
->
user
=
null
;
}
function
reload
()
{
return
$this
->
load
();
}
function
__call
(
$name
,
$args
)
{
if
(
!
(
$user
=
$this
->
getUser
())
||
!
method_exists
(
$user
,
$name
))
return
null
;
if
(
$args
)
return
call_user_func_array
(
array
(
$user
,
$name
),
$args
);
return
call_user_func
(
array
(
$user
,
$name
));
}
function
getId
()
{
return
$this
->
ht
[
'id'
];
}
function
isActive
()
{
return
(
$this
->
ht
[
'isactive'
]);
}
function
getTicketId
()
{
return
$this
->
ht
[
'ticket_id'
];
}
function
getTicket
()
{
if
(
!
$this
->
ticket
&&
$this
->
getTicketId
())
$this
->
ticket
=
Ticket
::
lookup
(
$this
->
getTicketId
());
return
$this
->
ticket
;
}
function
getUserId
()
{
return
$this
->
ht
[
'user_id'
];
}
function
getUser
()
{
if
(
!
$this
->
user
&&
$this
->
getUserId
())
$this
->
user
=
User
::
lookup
(
$this
->
getUserId
());
return
$this
->
user
;
}
static
function
add
(
$info
,
&
$errors
)
{
if
(
!
$info
||
!
$info
[
'ticketId'
]
||
!
$info
[
'userId'
])
$errors
[
'err'
]
=
'Invalid or missing information'
;
elseif
((
$c
=
self
::
lookup
(
$info
)))
$errors
[
'err'
]
=
sprintf
(
'%s is already a collaborator'
,
$c
->
getName
());
if
(
$errors
)
return
false
;
$sql
=
'INSERT INTO '
.
TICKET_COLLABORATOR_TABLE
.
' SET isactive=1, updated=NOW() '
.
' ,ticket_id='
.
db_input
(
$info
[
'ticketId'
])
.
' ,user_id='
.
db_input
(
$info
[
'userId'
]);
if
(
db_query
(
$sql
)
&&
(
$id
=
db_insert_id
()))
return
self
::
lookup
(
$id
);
$errors
[
'err'
]
=
'Unable to add collaborator. Internal error'
;
return
false
;
}
static
function
getIdByInfo
(
$info
)
{
$sql
=
'SELECT id FROM '
.
TICKET_COLLABORATOR_TABLE
.
' WHERE ticket_id='
.
db_input
(
$info
[
'ticketId'
])
.
' AND user_id='
.
db_input
(
$info
[
'userId'
]);
list
(
$id
)
=
db_fetch_row
(
db_query
(
$sql
));
return
$id
;
}
static
function
lookup
(
$criteria
)
{
$id
=
is_numeric
(
$criteria
)
?
$criteria
:
self
::
getIdByInfo
(
$criteria
);
return
(
$id
&&
(
$c
=
new
Collaborator
(
$id
))
&&
$c
->
getId
()
==
$id
)
?
$c
:
null
;
}
}
?>
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