summaryrefslogtreecommitdiff
path: root/src/application/templates/old/components/post.twig
blob: 6b04bcaeb1e9c8e54ace0cfa583c80a472b540e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
{%- set fileAttachments = attachments|filter(a => not (a.mimeType starts with "image/" or a.mimeType starts with "video/")) -%}
{%- set imageAttachments = attachments|filter(a => a.mimeType starts with "image/" or a.mimeType starts with "video/") -%}

{%- set canReply =
    not post.deleted
    and not topic.isLocked
    and currentUser is not null
    and currentUser.hasPermission(permission("CREATE_OWN_POST"))
-%}

{%- set canEdit =
    not post.deleted
    and not topic.isLocked
    and currentUser is not null
    and (
        (
            postAuthor is not null
            and postAuthor.id == currentUser.id
            and postAuthor.hasPermission(permission("EDIT_OWN_POST"))
        )
        or currentUser.hasPermission(permission("EDIT_OTHER_POST"))
    ) -%}

{%- set canDelete =
    not post.deleted
    and currentUser is not null
    and (
        (
            postAuthor is not null
            and postAuthor.id == currentUser.id
            and postAuthor.hasPermission(permission("DELETE_OWN_POST"))
        )
        or currentUser.hasPermission(permission("DELETE_OTHER_POST"))
    ) -%}

{%- set canViewAttachments = currentUser is not null -%}

{%- set your_are_the_author =
    currentUser is not null
    and postAuthor is not null
    and currentUser.id == postAuthor.id
-%}

{%- set is_op =
    topicAuthor is not null
    and postAuthor is not null
    and postAuthor.id == topicAuthor.id
-%}

{%- set hasOtherAttachments = (fileAttachments|length > 0) -%}

{% if post.deleted %}
    <tr>
        <td width="64"></td>
        <td>
            <a id="post-{{ post.id }}"></a>
            <table cellspacing="0" cellpadding="4" bgcolor="pink" border="1" bordercolor="red">
            <tr><td>
                <img src="/ui/theme-files/old/delete.gif" border="0" alt="" width="16" height="16" draggable="false" class="inline-icon">&nbsp;{#
                #}{{ __("This post has been deleted") }}
            </td></tr>
            </table>
        </td>
    </tr>
{% else %}
    <tr>
        <td width="64" rowspan="{{ hasOtherAttachments ? "3" : "2" }}" valign="top">
            {% if not hide_pfp %}
                {% if postAuthor %}
                    {% if hide_actions %}
                        <img class="media-object" alt="{{ __("Profile picture") }}" src="?_action=profilepicture&amp;user={{ postAuthor.id|url_encode }}" width="64" height="64">
                    {% else %}
                        <a href="?_action=viewuser&amp;user={{ postAuthor.id|url_encode }}">
                            <img border="0" class="media-object" alt="{{ __("Profile picture") }}" src="?_action=profilepicture&amp;user={{ postAuthor.id|url_encode }}" width="64" height="64">
                        </a>
                    {% endif %}
                {% else %}
                    <div class="media-object" style="width:64px;height:64px"></div>
                {% endif %}
            {% endif %}
        </td>
        <th align="left" height="1" class="no-bold">
            <a id="post-{{ post.id }}" data-text="{{ post.content }}"></a>
            {% if not hide_actions %}
                <div class="pull-right">{#
                    #}<a href="#post-{{ post.id }}" class="seamless m-r"><img class="inline-icon" src="/ui/theme-files/old/link.gif" alt="{{ __("Permalink") }}" width="16" height="16" border="0" draggable="false"></a>
                    {%- if canReply -%}
                        <button data-post-id="{{ post.id }}" class="seamless m-r js-only _reply-post"><img class="inline-icon" src="/ui/theme-files/old/message.gif" alt="{{ __("Reply to post") }}" width="16" height="16" border="0" draggable="false"></button>
                    {%- endif -%}
                    {%- if canEdit -%}
                        <form action="?_action=editpost" method="post" class="inline">{#
                            #}<input type="hidden" name="post" value="{{ post.id }}">{#
                            #}<button type="submit" class="seamless m-r"><img class="inline-icon" src="/ui/theme-files/old/message_edit.gif" alt="{{ __("Edit post") }}" width="16" height="16" border="0" draggable="false"></button>{#
                        #}</form>
                    {%- endif -%}
                    {%- if canDelete -%}
                        <form action="?_action=deletepost" method="post" class="inline">{#
                            #}<input type="hidden" name="post" value="{{ post.id }}">{#
                            #}<button type="submit" class="seamless m-r"><img class="inline-icon" src="/ui/theme-files/old/message_delete.gif" alt="{{ __("Delete post") }}" width="16" height="16" border="0" draggable="false"></button>{#
                        #}</form>
                    {%- endif -%}
                </div>
            {% endif %}
            {% if postAuthor %}
                {% if hide_actions %}
                    <b>{{ postAuthor.displayName }}</b>
                {% else %}
                    <a href="?_action=viewuser&amp;user={{ postAuthor.id|url_encode }}"><b>{{ postAuthor.displayName }}</b></a>
                {% endif %}
                {% if your_are_the_author %}
                    <font color="red"><small>[{{ __("You") }}]</small></font>
                {% endif %}
                {% if is_op %}
                    <img alt="{{ __("Created this topic") }}" title="{{ __("Created this topic") }}" class="m-l inline-icon" width="16" height="16" draggable="false" src="/ui/theme-files/old/microphone.gif">
                {% endif %}
            {% else %}
                <font color="gray"><i>{{ __("(deleted)") }}</i></font>
            {% endif %}
            <br>
            <span class="_time">{{ post.postDate.format("c") }}</span>
            {% if post.edited %}
                <font color="gray"><i>{{ __("(edited)") }}</i></font>
            {% endif %}
        </th>
    </tr>
    <tr>
        <td>
            {{ renderPost(post.content) }}
            {% if imageAttachments|length > 0 %}
                <div class="post-images clearfix">
                    {% for attachment in imageAttachments %}
                        {% if hide_actions %}
                            <span class="image-attachment" title="{{ attachment.name }}">
                                <img border="0" class="image-attachment-image" src="?_action=thumb&amp;attachment={{ attachment.id|url_encode }}" alt="" width="100">
                            </span>
                        {% else %}
                            <a class="image-attachment attachment" href="?_action=attachment&amp;attachment={{ attachment.id|url_encode }}" title="{{ attachment.name }}">
                                <img border="0" class="image-attachment-image" src="?_action=thumb&amp;attachment={{ attachment.id|url_encode }}" alt="" width="100">
                                {% if canViewAttachments %}
                                    <img alt="" border="0" class="attachment-icon" width="18" height="18" draggable="false" src="/ui/theme-files/old/{{ attachment.mimeType starts with "video/" ? "film" : "photo" }}.gif">
                                {% else %}
                                    <img alt="" border="0" class="attachment-icon" width="18" height="18" draggable="false" src="/ui/theme-files/old/attachment_forbidden.gif">
                                {% endif %}
                            </a>
                        {% endif %}
                    {% endfor %}
                </div>
            {% endif %}
        </td>
    </tr>
    {% if hasOtherAttachments %}
        <tr>
            <td>
                {% for attachment in fileAttachments %}
                    {% if hide_actions %}
                        <u>{{ attachment.name }}</u>
                    {% else %}
                        <a class="attachment" href="?_action=attachment&amp;attachment={{ attachment.id|url_encode }}">
                            {% if not canViewAttachments %}
                                <img alt="" class="inline-icon" width="16" height="16" border="0" draggable="false" src="/ui/theme-files/old/forbidden.gif">
                            {% endif %}
                            {{ attachment.name }}
                        </a>
                    {% endif %}
                {% endfor %}
            </td>
        </tr>
    {% endif %}
{% endif %}