Skip to content

Commit

Permalink
Adjustments for announcements (#2972) (#3257)
Browse files Browse the repository at this point in the history
* Announcements fixes

* Fixed indenting
  • Loading branch information
Shade- authored and euantorano committed Jun 2, 2019
1 parent 7ddeca3 commit 85f8101
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 44 deletions.
4 changes: 3 additions & 1 deletion inc/functions_modcp.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,13 @@ function fetch_forum_announcements($pid=0, $depth=1)
}
}

$bgcolor = alt_trow();
$announcements_forum .= \MyBB\template('modcp/announcements/forum.twig', [
'announcements' => $currentAnnouncements,
'depth' => $depth,
'forum' => $forum,
'moderate' => $moderate
'moderate' => $moderate,
'bgcolor' => $bgcolor
]);

// Build the list for any sub forums of this forum
Expand Down
30 changes: 15 additions & 15 deletions inc/views/base/announcements/announcements.twig
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,24 @@
{% block body %}

<table border="0" cellspacing="{{ theme.borderwidth }}" cellpadding="{{ theme.tablespace }}" class="tborder tfixed clear no_bottom_border">
<tr>
<td class="thead">
<strong>{{ lang.forum_announcement }}</strong>
</td>
</tr>
<tr>
<td id="posts_container">
<div id="posts">
{{ announcement|raw }}
</div>
</td>
</tr>
<tr>
<td class="thead">
<strong>{{ lang.forum_announcement }}</strong>
</td>
</tr>
<tr>
<td id="posts_container">
<div id="posts">
{{ announcement|raw }}
</div>
</td>
</tr>
</table>

<script type="text/javascript">
$(".author_avatar img").error(function () {
$(this).unbind("error").closest('.author_avatar').remove();
});
$(".author_avatar img").error(function () {
$(this).unbind("error").closest('.author_avatar').remove();
});
</script>

{% endblock body %}
13 changes: 7 additions & 6 deletions inc/views/base/modcp/announcements.twig
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% extends 'layouts/master.twig' %}

{% block head %}
<title>{{ mybb.settings.bburl }} - {{ lang.manage_announcement }}</title>
<title>{{ mybb.settings.bbname }} - {{ lang.manage_announcement }}</title>
{% endblock head %}

{% block body %}
Expand All @@ -22,8 +22,9 @@
</tr>
{% if globalAnnouncements %}
{% for aid, announcement in globalAnnouncements %}
{% set bgcolor = alt_trow() %}
<tr>
<td>
<td class="{{ bgcolor }}">
{% if announcement.startdate > 'now'|date('U') or ('now'|date('U') > announcement.enddate and announcement.enddate) %}
{% set title = lang.expired_announcement %}
{% else %}
Expand All @@ -32,8 +33,8 @@
<div class="subforumicon subforum_minioff" title="{{ title }}"></div>
<a href="announcements.php?aid={{ aid }}">{{ announcement.subject }}</a>
</td>
<td align="center"><a href="modcp.php?action=edit_announcement&amp;aid={{ aid }}">{{ lang.edit }}</a></td>
<td align="center"><a href="modcp.php?action=delete_announcement&amp;aid={{ aid }}">{{ lang.delete }}</a></td>
<td class="{{ bgcolor }}" align="center"><a href="modcp.php?action=edit_announcement&amp;aid={{ aid }}">{{ lang.edit }}</a></td>
<td class="{{ bgcolor }}" align="center"><a href="modcp.php?action=delete_announcement&amp;aid={{ aid }}">{{ lang.delete }}</a></td>
</tr>
{% endfor %}
{% else %}
Expand All @@ -54,9 +55,9 @@
<td class="tcat" width="200" colspan="2" align="center"><span class="smalltext"><strong>{{ lang.controls }}</strong></span></td>
</tr>
{% if forumAnnouncements %}
{{ forumAnnouncements|raw }}
{{ forumAnnouncements|raw }}
{% else %}
<tr>
<tr>
<td class="trow1" colspan="3">{$lang->no_forum_announcements}</td>
</tr>
{% endif %}
Expand Down
15 changes: 10 additions & 5 deletions inc/views/base/modcp/announcements/forum.twig
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
<tr>
<td><div style="padding-left: {{ 40*(depth - 1) }}px"><strong>{{ forum.name }}</strong></div></td>
<td colspan="2" align="center">
<td class="{{ bgcolor }}">
<div style="padding-left: {{ 40*(depth - 1) }}px">
<strong>{{ forum.name }}</strong>
</div>
</td>
<td class="{{ bgcolor }}" colspan="2" align="center">
{% if moderate %}
<a href="modcp.php?action=new_announcement&amp;fid={{ forum.fid }}">{{ lang.add_announcement }}</a>
{% endif %}
</td>
</tr>
{% for aid, announcement in announcements %}
{% set bgcolor = alt_trow() %}
<tr>
<td>
<td class="{{ bgcolor }}">
<div style="padding-left: {{ 40*(depth - 1) }}px">
<div class="subforumicon subforum_minioff" title="{{ lang[announcement.icon ~ '_announcement'] }}"></div>
<a href="announcements.php?aid={{ aid }}">{{ announcement.subject }}</a>
</div>
</td>
<td align="center"><a href="modcp.php?action=edit_announcement&amp;aid={{ aid }}">{{ lang.edit }}</a></td>
<td align="center"><a href="modcp.php?action=delete_announcement&amp;aid={{ aid }}">{{ lang.delete }}</a></td>
<td class="{{ bgcolor }}" align="center"><a href="modcp.php?action=edit_announcement&amp;aid={{ aid }}">{{ lang.edit }}</a></td>
<td class="{{ bgcolor }}" align="center"><a href="modcp.php?action=delete_announcement&amp;aid={{ aid }}">{{ lang.delete }}</a></td>
</tr>
{% endfor %}
44 changes: 29 additions & 15 deletions inc/views/base/modcp/announcements_add.twig
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% extends 'layouts/master.twig' %}

{% block head %}
<title>{{ mybb.settings.bburl }} - {{ lang.add_announcement }}</title>
<title>{{ mybb.settings.bbname }} - {{ lang.add_announcement }}</title>
{% endblock head %}

{% block body %}
Expand All @@ -14,19 +14,33 @@
{# Modcp nav #}
<td valign="top">
{{ errors|raw }}
{# Preview post to be included when ready. Requires $postbit to be defined #}
{# include 'post/preview.twig' #}
{# Preview #}
{% if postbit %}
<table border="0" cellspacing="{{ theme.borderwidth }}" cellpadding="{{ theme.tablespace }}" class="tborder tfixed clear no_bottom_border">
<tr>
<td class="thead"><strong>{{ lang.post_preview }}</strong></td>
</tr>
<tr>
<td id="posts_container">
<div id="posts">
{{ postbit|raw }}
</div>
</td>
</tr>
</table>
<br />
{% endif %}
<table border="0" cellspacing="{{ theme.borderwidth }}" cellpadding="{{ theme.tablespace }}" class="tborder">
<tr>
<td class="thead" colspan="6"><strong>{{ lang.add_announcement }}</strong></td>
</tr>
<tr>
<td valign="top" width="25%"><strong>{{ lang.title }}</strong></td>
<td valign="top" width="75%"><input type="text" class="textbox" name="title" size="40" value="{{ announcement.subject }}" /></td>
<td class="trow1" valign="top" width="25%"><strong>{{ lang.title }}</strong></td>
<td class="trow1" valign="top" width="75%"><input type="text" class="textbox" name="title" size="40" value="{{ announcement.subject }}" /></td>
</tr>
<tr>
<td colspan="1" valign="top" width="25%"><strong>{{ lang.start_date }}</strong></td>
<td valign="top" width="75%">
<td class="trow2" colspan="1" valign="top" width="25%"><strong>{{ lang.start_date }}</strong></td>
<td class="trow2" valign="top" width="75%">
<select name="starttime_day">
{% for day in 1..31 %}
<option value="{{ day }}"{% if mybb.input.starttime_day == day %} selected{% endif %}>{{ day }}</option>
Expand All @@ -42,8 +56,8 @@
</td>
</tr>
<tr>
<td colspan="1" valign="top" width="25%"><strong>{{ lang.end_date }}</strong></td>
<td valign="top" width="75%">
<td class="trow1" colspan="1" valign="top" width="25%"><strong>{{ lang.end_date }}</strong></td>
<td class="trow1" valign="top" width="75%">
<input type="radio" name="endtime_type" value="1"{% if mybb.input.endtime_type != 2 or mybb.input.endtime_type is defined %} checked{% endif %} />
<select name="endtime_day">
{% for day in 1..31 %}
Expand All @@ -61,8 +75,8 @@
</td>
</tr>
<tr>
<td valign="top" width="25%"><strong>{{ lang.announcement }}</strong><br />{{ smilieinserter|raw }}</td>
<td valign="top" width="75%"><textarea id="message" name="message" rows="20" cols="70">{{ announcement.message }}</textarea>{{ codebuttons|raw }}</td>
<td class="trow2" valign="top" width="25%"><strong>{{ lang.announcement }}</strong><br />{{ smilieinserter|raw }}</td>
<td class="trow2" valign="top" width="75%"><textarea id="message" name="message" rows="20" cols="70">{{ announcement.message }}</textarea>{{ codebuttons|raw }}</td>
</tr>
{% if mybb.settings.announcementshtml %}
<tr>
Expand All @@ -78,8 +92,8 @@
</tr>
{% endif %}
<tr>
<td valign="top" width="25%"><strong>{{ lang.allow_mycode }}</strong></td>
<td valign="top" width="75%">
<td class="trow2" valign="top" width="25%"><strong>{{ lang.allow_mycode }}</strong></td>
<td class="trow2" valign="top" width="75%">
<label>
<input type="radio" name="allowmycode" value="1"{% if announcement.allowmycode %} checked{% endif %} /> {{ lang.yes }}
</label>
Expand All @@ -89,8 +103,8 @@
</td>
</tr>
<tr>
<td valign="top" width="25%"><strong>{{ lang.allow_smilies }}</strong></td>
<td valign="top" width="75%">
<td class="trow1" valign="top" width="25%"><strong>{{ lang.allow_smilies }}</strong></td>
<td class="trow1" valign="top" width="75%">
<label>
<input type="radio" name="allowsmilies" value="1"{% if announcement.allowsmilies %} checked{% endif %} /> {{ lang.yes }}
</label>
Expand Down
6 changes: 4 additions & 2 deletions modcp.php
Original file line number Diff line number Diff line change
Expand Up @@ -1093,6 +1093,7 @@
$announcement['allowhtml'] = $allowhtml;
$announcement['allowmycode'] = $allowmycode;
$announcement['allowsmilies'] = $allowsmilies;
$announcement['fid'] = $announcement_fid;

$dates['start']['month'] = $mybb->input['starttime_month'];
$dates['start']['year'] = $mybb->input['starttime_year'];
Expand All @@ -1116,7 +1117,8 @@
'message' => '',
'allowhtml' => 0,
'allowmycode' => 1,
'allowsmilies' => 1
'allowsmilies' => 1,
'fid' => $announcement_fid
);

$dates['end']['year'] = $dates['start']['year']+1;
Expand All @@ -1125,8 +1127,8 @@
// MyCode editor
$codebuttons = build_mycode_inserter();
$smilieinserter = build_clickable_smilies();
$postbit = '';

$postbit = '';
if (isset($preview)) {
$announcementarray = array(
'aid' => 0,
Expand Down

0 comments on commit 85f8101

Please sign in to comment.