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
768f4ad8
Commit
768f4ad8
authored
9 years ago
by
Peter Rotich
Browse files
Options
Downloads
Patches
Plain Diff
thread: Make thread view template generic
This will allow for any threadable object to render the thread.
parent
8e67a014
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
include/class.thread.php
+9
-0
9 additions, 0 deletions
include/class.thread.php
include/staff/templates/thread-entries.tmpl.php
+83
-0
83 additions, 0 deletions
include/staff/templates/thread-entries.tmpl.php
include/staff/ticket-view.inc.php
+2
-96
2 additions, 96 deletions
include/staff/ticket-view.inc.php
with
94 additions
and
96 deletions
include/class.thread.php
+
9
−
0
View file @
768f4ad8
...
@@ -89,6 +89,15 @@ class Thread extends VerySimpleModel {
...
@@ -89,6 +89,15 @@ class Thread extends VerySimpleModel {
return
$base
;
return
$base
;
}
}
function
render
(
$type
=
false
)
{
$entries
=
$this
->
getEntries
();
if
(
$type
&&
is_array
(
$type
))
$entries
->
filter
(
array
(
'type__in'
=>
$type
));
include
STAFFINC_DIR
.
'templates/thread-entries.tmpl.php'
;
}
function
getEntry
(
$id
)
{
function
getEntry
(
$id
)
{
return
ThreadEntry
::
lookup
(
$id
,
$this
->
getId
());
return
ThreadEntry
::
lookup
(
$id
,
$this
->
getId
());
}
}
...
...
This diff is collapsed.
Click to expand it.
include/staff/templates/thread-entries.tmpl.php
0 → 100644
+
83
−
0
View file @
768f4ad8
<?php
$entryTypes
=
array
(
'M'
=>
'message'
,
'R'
=>
'response'
,
'N'
=>
'note'
);
if
(
$entries
)
{
foreach
(
$entries
as
$entry
)
{
?>
<table
class=
"thread-entry
<?php
echo
$entryTypes
[
$entry
->
type
];
?>
"
cellspacing=
"0"
cellpadding=
"1"
width=
"940"
border=
"0"
>
<tr>
<th
colspan=
"4"
width=
"100%"
>
<div>
<span
class=
"pull-left"
>
<span
style=
"display:inline-block"
>
<?php
echo
Format
::
datetime
(
$entry
->
created
);
?>
</span>
<span
style=
"display:inline-block;padding:0 1em;max-width: 500px"
class=
"faded title truncate"
>
<?php
echo
$entry
->
title
;
?>
</span>
</span>
<div
class=
"pull-right"
>
<?php
if
(
$entry
->
hasActions
())
{
$actions
=
$entry
->
getActions
();
?>
<span
class=
"action-button pull-right"
data-dropdown=
"#entry-action-more-
<?php
echo
$entry
->
getId
();
?>
"
>
<i
class=
"icon-caret-down"
></i>
<span
><i
class=
"icon-cog"
></i></span>
</span>
<div
id=
"entry-action-more-
<?php
echo
$entry
->
getId
();
?>
"
class=
"action-dropdown anchor-right"
>
<ul
class=
"title"
>
<?php
foreach
(
$actions
as
$group
=>
$list
)
{
foreach
(
$list
as
$id
=>
$action
)
{
?>
<li>
<a
class=
"no-pjax"
href=
"#"
onclick=
"javascript:
<?php
echo
str_replace
(
'"'
,
'\\"'
,
$action
->
getJsStub
());
?>
; return false;"
>
<i
class=
"
<?php
echo
$action
->
getIcon
();
?>
"
></i>
<?php
echo
$action
->
getName
();
?>
</a></li>
<?php
}
}
?>
</ul>
</div>
<?php
}
?>
<span
style=
"vertical-align:middle"
>
<span
style=
"vertical-align:middle;"
class=
"textra"
></span>
<span
style=
"vertical-align:middle;"
class=
"tmeta faded title"
>
<?php
echo
Format
::
htmlchars
(
$entry
->
getName
());
?>
</span>
</span>
</div>
</th>
</tr>
<tr><td
colspan=
"4"
class=
"thread-body"
id=
"thread-id-
<?php
echo
$entry
->
getId
();
?>
"
><div>
<?php
echo
$entry
->
getBody
()
->
toHtml
();
?>
</div></td></tr>
<?php
$urls
=
null
;
if
(
$entry
->
has_attachments
&&
(
$urls
=
$entry
->
getAttachmentUrls
()))
{
?>
<tr>
<td
class=
"info"
colspan=
"4"
>
<?php
foreach
(
$entry
->
attachments
as
$A
)
{
if
(
$A
->
inline
)
continue
;
$size
=
''
;
if
(
$A
->
file
->
size
)
$size
=
sprintf
(
'<em>(%s)</em>'
,
Format
::
file_size
(
$A
->
file
->
size
));
?>
<a
class=
"Icon file no-pjax"
href=
"
<?php
echo
$A
->
file
->
getDownloadUrl
();
?>
"
target=
"_blank"
>
<?php
echo
Format
::
htmlchars
(
$A
->
file
->
name
);
?>
</a>
<?php
echo
$size
;
?>
<?php
}
?>
</td>
</tr>
<?php
}
if
(
$urls
)
{
?>
<script
type=
"text/javascript"
>
$
(
'
#thread-id-
<?php
echo
$entry
->
getId
();
?>
'
)
.
data
(
'
urls
'
,
<?php
echo
JsonDataEncoder
::
encode
(
$urls
);
?>
)
.
data
(
'
id
'
,
<?php
echo
$entry
->
getId
();
?>
);
</script>
<?php
}
?>
</table>
<?php
}
}
else
{
echo
'<p><em>'
.
__
(
'No entries have been posted to this thread.'
)
.
'</em></p>'
;
}
?>
This diff is collapsed.
Click to expand it.
include/staff/ticket-view.inc.php
+
2
−
96
View file @
768f4ad8
...
@@ -396,102 +396,8 @@ $tcount = $ticket->getThreadEntries($types)->count();
...
@@ -396,102 +396,8 @@ $tcount = $ticket->getThreadEntries($types)->count();
<div
id=
"ticket_tabs_container"
>
<div
id=
"ticket_tabs_container"
>
<div
id=
"ticket_thread"
data-thread-id=
"
<?php
echo
$ticket
->
getThread
()
->
getId
();
?>
"
class=
"tab_content"
>
<div
id=
"ticket_thread"
data-thread-id=
"
<?php
echo
$ticket
->
getThread
()
->
getId
();
?>
"
class=
"tab_content"
>
<?php
<?php
$threadTypes
=
array
(
'M'
=>
'message'
,
'R'
=>
'response'
,
'N'
=>
'note'
);
$ticket
->
getThread
()
->
render
(
array
(
'M'
,
'R'
,
'N'
));
/* -------- Messages & Responses & Notes (if inline)-------------*/
?>
$types
=
array
(
'M'
,
'R'
,
'N'
);
if
((
$thread
=
$ticket
->
getThreadEntries
(
$types
)))
{
foreach
(
$thread
as
$entry
)
{
?>
<table
class=
"thread-entry
<?php
echo
$threadTypes
[
$entry
->
type
];
?>
"
cellspacing=
"0"
cellpadding=
"1"
width=
"940"
border=
"0"
>
<tr>
<th
colspan=
"4"
width=
"100%"
>
<div>
<span
class=
"pull-left"
>
<span
style=
"display:inline-block"
>
<?php
echo
Format
::
datetime
(
$entry
->
created
);
?>
</span>
<span
style=
"display:inline-block;padding:0 1em;max-width: 500px"
class=
"faded title truncate"
>
<?php
echo
$entry
->
title
;
?>
</span>
</span>
<div
class=
"pull-right"
>
<?php
if
(
$entry
->
hasActions
())
{
$actions
=
$entry
->
getActions
();
?>
<span
class=
"action-button pull-right"
data-dropdown=
"#entry-action-more-
<?php
echo
$entry
->
getId
();
?>
"
>
<i
class=
"icon-caret-down"
></i>
<span
><i
class=
"icon-cog"
></i></span>
</span>
<div
id=
"entry-action-more-
<?php
echo
$entry
->
getId
();
?>
"
class=
"action-dropdown anchor-right"
>
<ul
class=
"title"
>
<?php
foreach
(
$actions
as
$group
=>
$list
)
{
foreach
(
$list
as
$id
=>
$action
)
{
?>
<li>
<a
class=
"no-pjax
<?php
if
(
!
$action
->
isEnabled
())
echo
'disabled'
;
?>
"
href=
"#"
onclick=
"javascript:
if ($(this).hasClass('disabled')) return false;
<?php
echo
str_replace
(
'"'
,
'\\"'
,
$action
->
getJsStub
());
?>
; return false;"
>
<i
class=
"icon-fixed-width
<?php
echo
$action
->
getIcon
();
?>
"
></i>
<?php
echo
$action
->
getName
();
?>
</a></li>
<?php
}
}
?>
</ul>
</div>
<?php
}
?>
<span
style=
"vertical-align:middle"
>
<span
style=
"vertical-align:middle;"
class=
"textra"
>
<?php
if
(
$entry
->
flags
&
ThreadEntry
::
FLAG_EDITED
)
{
?>
<span
class=
"label label-bare"
title=
"
<?php
echo
sprintf
(
__
(
'Edited on %s by %s'
),
Format
::
datetime
(
$entry
->
updated
),
'You'
);
?>
"
>
<?php
echo
__
(
'Edited'
);
?>
</span>
<?php
}
?>
</span>
<span
style=
"vertical-align:middle;"
class=
"tmeta faded title"
>
<?php
echo
Format
::
htmlchars
(
$entry
->
getName
());
?>
</span>
</span>
</div>
</th>
</tr>
<tr><td
colspan=
"4"
class=
"thread-body"
id=
"thread-id-
<?php
echo
$entry
->
getId
();
?>
"
><div>
<?php
echo
$entry
->
getBody
()
->
toHtml
();
?>
</div></td></tr>
<?php
$urls
=
null
;
if
(
$entry
->
has_attachments
&&
(
$urls
=
$entry
->
getAttachmentUrls
()))
{
?>
<tr>
<td
class=
"info"
colspan=
"4"
>
<?php
foreach
(
$entry
->
attachments
as
$A
)
{
if
(
$A
->
inline
)
continue
;
$size
=
''
;
if
(
$A
->
file
->
size
)
$size
=
sprintf
(
'<em>(%s)</em>'
,
Format
::
file_size
(
$A
->
file
->
size
));
?>
<a
class=
"Icon file no-pjax"
href=
"
<?php
echo
$A
->
file
->
getDownloadUrl
();
?>
"
target=
"_blank"
>
<?php
echo
Format
::
htmlchars
(
$A
->
file
->
name
);
?>
</a>
<?php
echo
$size
;
?>
<?php
}
?>
</td>
</tr>
<?php
}
if
(
$urls
)
{
?>
<script
type=
"text/javascript"
>
$
(
'
#thread-id-
<?php
echo
$entry
->
getId
();
?>
'
)
.
data
(
'
urls
'
,
<?php
echo
JsonDataEncoder
::
encode
(
$urls
);
?>
)
.
data
(
'
id
'
,
<?php
echo
$entry
->
getId
();
?>
);
</script>
<?php
}
?>
</table>
<?php
if
(
$entry
->
type
==
'M'
)
$msgId
=
$entry
->
getId
();
}
}
else
{
echo
'<p><em>'
.
__
(
'No entries have been posted to this ticket.'
)
.
'</em></p>'
;
}
?>
<div
class=
"clear"
style=
"padding-bottom:10px;"
></div>
<div
class=
"clear"
style=
"padding-bottom:10px;"
></div>
<?php
if
(
$errors
[
'err'
])
{
?>
<?php
if
(
$errors
[
'err'
])
{
?>
<div
id=
"msg_error"
>
<?php
echo
$errors
[
'err'
];
?>
</div>
<div
id=
"msg_error"
>
<?php
echo
$errors
[
'err'
];
?>
</div>
...
...
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