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
91d2dfc4
Unverified
Commit
91d2dfc4
authored
6 years ago
by
Peter Rotich
Committed by
GitHub
6 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #4613 from JediKev/feature/complete-thread-variable
feature: Complete Thread Variable
parents
ef915213
ffcd4b5e
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.file.php
+12
-0
12 additions, 0 deletions
include/class.file.php
include/class.thread.php
+19
-0
19 additions, 0 deletions
include/class.thread.php
include/client/templates/thread-export.tmpl.php
+93
-0
93 additions, 0 deletions
include/client/templates/thread-export.tmpl.php
with
124 additions
and
0 deletions
include/class.file.php
+
12
−
0
View file @
91d2dfc4
...
@@ -197,6 +197,18 @@ class AttachmentFile extends VerySimpleModel {
...
@@ -197,6 +197,18 @@ class AttachmentFile extends VerySimpleModel {
$options
);
$options
);
}
}
// Generates full download URL for external sources.
// e.g. https://domain.tld/file.php?args=123
function
getExternalDownloadUrl
(
$options
=
array
())
{
global
$cfg
;
$download
=
self
::
getDownloadUrl
(
$options
);
// Separate URL handle and args
list
(
$handle
,
$args
)
=
explode
(
'file.php?'
,
$download
);
return
(
string
)
rtrim
(
$cfg
->
getBaseUrl
(),
'/'
)
.
'/file.php?'
.
$args
;
}
static
function
generateDownloadUrl
(
$id
,
$key
,
$hash
,
$options
=
array
())
{
static
function
generateDownloadUrl
(
$id
,
$key
,
$hash
,
$options
=
array
())
{
// Expire at the nearest midnight, allow at least12 hrs access
// Expire at the nearest midnight, allow at least12 hrs access
...
...
This diff is collapsed.
Click to expand it.
include/class.thread.php
+
19
−
0
View file @
91d2dfc4
...
@@ -2964,6 +2964,14 @@ implements TemplateVariable {
...
@@ -2964,6 +2964,14 @@ implements TemplateVariable {
return
$resp
;
return
$resp
;
}
}
function
__toString
()
{
return
$this
->
asVar
();
}
function
asVar
()
{
return
$this
->
getVar
(
'complete'
);
}
function
getVar
(
$name
)
{
function
getVar
(
$name
)
{
switch
(
$name
)
{
switch
(
$name
)
{
case
'original'
:
case
'original'
:
...
@@ -2983,12 +2991,23 @@ implements TemplateVariable {
...
@@ -2983,12 +2991,23 @@ implements TemplateVariable {
if
(
$entry
)
if
(
$entry
)
return
$entry
->
getBody
();
return
$entry
->
getBody
();
break
;
case
'complete'
:
$content
=
''
;
$thread
=
$this
;
ob_start
();
include
INCLUDE_DIR
.
'client/templates/thread-export.tmpl.php'
;
$content
=
ob_get_contents
();
ob_end_clean
();
return
$content
;
break
;
break
;
}
}
}
}
static
function
getVarScope
()
{
static
function
getVarScope
()
{
return
array
(
return
array
(
'complete'
=>
__
(
'Thread Correspondence'
),
'original'
=>
array
(
'class'
=>
'MessageThreadEntry'
,
'desc'
=>
__
(
'Original Message'
)),
'original'
=>
array
(
'class'
=>
'MessageThreadEntry'
,
'desc'
=>
__
(
'Original Message'
)),
'lastmessage'
=>
array
(
'class'
=>
'MessageThreadEntry'
,
'desc'
=>
__
(
'Last Message'
)),
'lastmessage'
=>
array
(
'class'
=>
'MessageThreadEntry'
,
'desc'
=>
__
(
'Last Message'
)),
);
);
...
...
This diff is collapsed.
Click to expand it.
include/client/templates/thread-export.tmpl.php
0 → 100644
+
93
−
0
View file @
91d2dfc4
<?php
global
$cfg
;
$entryTypes
=
array
(
'M'
=>
array
(
'color'
=>
'#0088cc'
),
'R'
=>
array
(
'color'
=>
'#e65524'
),
);
AttachmentFile
::
objects
()
->
filter
(
array
(
'attachments__thread_entry__thread__id'
=>
$thread
->
getId
(),
'attachments__thread_entry__type__in'
=>
array_keys
(
$entryTypes
)
))
->
all
();
$entries
=
$thread
->
getEntries
();
$entries
->
filter
(
array
(
'type__in'
=>
array_keys
(
$entryTypes
)));
?>
<style
type=
"text/css"
>
div
{
font-family
:
sans-serif
;}
</style>
<div
style=
"width: 100%; margin: 0; padding: 0;"
>
<div
style=
"padding:10px;"
>
<p
style=
"font-family: sans-serif; font-size:12px; color:#999;"
>
</p>
</div>
<table
width=
"100%"
cellpadding=
"0"
cellspacing=
"0"
border=
"0"
>
<tbody>
<tr>
<td></td>
</tr>
<?php
foreach
(
$entries
as
$entry
)
{
$user
=
$entry
->
getUser
()
?:
$entry
->
getStaff
();
$name
=
$user
?
$user
->
getName
()
:
$entry
->
poster
;
$color
=
$entryTypes
[
$entry
->
type
][
'color'
];
?>
<tr>
<td
style=
" border-top: 1px dashed #999;"
>
<div
style=
"background-color:#f7f7f7; padding:10px 20px;"
>
<p
style=
"font-family: sans-serif; padding:0; margin:0; color:
<?php
echo
$color
;
?>
;"
>
<strong>
<?php
echo
$name
;
?>
</strong>
<span
style=
"color:#888; font-size:12px; padding-left: 20px;"
>
<?php
echo
$entry
->
title
;
?>
</span>
</p>
<p
style=
"font-family: sans-serif; padding:0; margin:0; color:#888; font-size:12px;"
>
<?php
echo
Format
::
daydatetime
(
$entry
->
created
);
?>
</p>
</div>
<div
style=
"padding:2px 20px;"
>
<p
style=
"font-family: sans-serif; font-size:14px; color:#555;"
>
<?php
echo
$entry
->
getBody
()
->
display
(
'email'
);
?>
</p>
<?php
if
(
$entry
->
has_attachments
)
{
?>
<p
style=
"font-family: sans-serif; font-size:12px; line-height:20px; color:#888;"
>
<?php
echo
__
(
'Attachments'
);
?>
<br
/>
<?php
foreach
(
$entry
->
attachments
as
$a
)
{
if
(
$a
->
inline
)
continue
;
$size
=
''
;
if
(
$a
->
file
->
size
)
$size
=
sprintf
(
'<small style="color:#ccc;"> (%s)</small>'
,
Format
::
file_size
(
$a
->
file
->
size
));
$filename
=
Format
::
htmlchars
(
$a
->
getFilename
());
echo
sprintf
(
'<a href="%s" download="%s"
style="font-size:11px; color:#0088cc;"
target="_blank">%s</a> %s<br/>'
,
$a
->
file
->
getExternalDownloadUrl
(),
$filename
,
$filename
,
$size
);
}
?>
</p>
<?php
}
?>
</div>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
<div
style=
"font-family: sans-serif; margin: 2px 0 14px 0; padding: 10px ; border-top: 1px solid #999; font-size:12px; color:#888;"
>
</div>
</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