* update forum post after editing news (when forum post has been created)

This commit is contained in:
slawkens 2017-10-24 15:18:30 +02:00
parent 6c9e09ea73
commit 21b1383c9a
3 changed files with 12 additions and 3 deletions

View File

@ -10,6 +10,7 @@
* @link http://my-aac.org * @link http://my-aac.org
*/ */
defined('MYAAC') or die('Direct access not allowed!'); defined('MYAAC') or die('Direct access not allowed!');
header('X-XSS-Protection: 0');
if(isset($_GET['archive'])) if(isset($_GET['archive']))
{ {
@ -146,7 +147,12 @@ if($canEdit)
$player_id = $news['player_id']; $player_id = $news['player_id'];
} }
else { else {
if(News::update($id, $p_title, $body, $type, $category, $player_id, $comments, $errors)) { if(News::update($id, $p_title, $body, $type, $category, $player_id, $forum_section, $errors)) {
// update forum thread if exists
if(isset($forum_section) && Validator::number($forum_section)) {
$db->query("UPDATE `" . TABLE_PREFIX . "forum` SET `author_guid` = ".(int) $player_id.", `post_text` = ".$db->quote($body).", `post_topic` = ".$db->quote($p_title).", `edit_date` = " . time() . " WHERE `id` = " . $db->quote($forum_section));
}
$action = $p_title = $body = $comments = ''; $action = $p_title = $body = $comments = '';
$type = $category = $player_id = 0; $type = $category = $player_id = 0;
} }
@ -287,7 +293,8 @@ if(!$news_cached)
'category' => isset($category) ? $category : 0, 'category' => isset($category) ? $category : 0,
'categories' => $categories, 'categories' => $categories,
'forum_boards' => getForumBoards(), 'forum_boards' => getForumBoards(),
'forum_section' => isset($forum_section) ? $forum_section : null 'forum_section' => isset($forum_section) ? $forum_section : null,
'comments' => isset($comments) ? $comments : null
)); ));
} }

View File

@ -5,5 +5,5 @@ Please choose template in which you want to edit menu items.<br/>
<option value="{{ template.template }}">{{ template.template }}</option> <option value="{{ template.template }}">{{ template.template }}</option>
{% endfor %} {% endfor %}
</select> </select>
<input type="submit" value="Edit" /> <input type="submit" class="button" value="Edit" />
</form> </form>

View File

@ -95,6 +95,8 @@
</select> </select>
</td> </td>
</tr> </tr>
{% elseif comments is not null%}
<input type="hidden" name="forum_section" value="{{ comments }}" />
{% endif %} {% endif %}
{% set rows = rows + 1 %} {% set rows = rows + 1 %}