Skip to content

Commit

Permalink
Minor improvements (#224)
Browse files Browse the repository at this point in the history
* Minor improvements

* Update posting_tpl.tpl

* Updated

* Update CHANGELOG.md
  • Loading branch information
belomaxorka committed Aug 21, 2023
1 parent c7be156 commit 0f092de
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
**Merged pull requests:**

- Release v2.1.5-2023.08 🎉
- Minor improvements [\#215](https://github.com/torrentpier/torrentpier-lts/pull/215), [\#216](https://github.com/torrentpier/torrentpier-lts/pull/216), [\#217](https://github.com/torrentpier/torrentpier-lts/pull/217), [\#218](https://github.com/torrentpier/torrentpier-lts/pull/218), [\#221](https://github.com/torrentpier/torrentpier-lts/pull/221), [\#222](https://github.com/torrentpier/torrentpier-lts/pull/222) ([belomaxorka](https://github.com/belomaxorka))
- Minor improvements [\#215](https://github.com/torrentpier/torrentpier-lts/pull/215), [\#216](https://github.com/torrentpier/torrentpier-lts/pull/216), [\#217](https://github.com/torrentpier/torrentpier-lts/pull/217), [\#218](https://github.com/torrentpier/torrentpier-lts/pull/218), [\#221](https://github.com/torrentpier/torrentpier-lts/pull/221), [\#222](https://github.com/torrentpier/torrentpier-lts/pull/222), [\#224](https://github.com/torrentpier/torrentpier-lts/pull/224) ([belomaxorka](https://github.com/belomaxorka))

## [v2.1.5-2023.07](https://github.com/torrentpier/torrentpier-lts/tree/v2.1.5-2023.07) (2023-08-04)
[Full Changelog](https://github.com/torrentpier/torrentpier-lts/compare/v2.1.5-2023.06...v2.1.5-2023.07)
Expand Down
22 changes: 21 additions & 1 deletion library/ajax/topic_tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
{
case 'load':
case 'save':
case 'remove':
if (!$tpl_id = (int) $this->request['tpl_id'])
{
$this->ajax_die('Выбранный шаблон не найден, создайте новый (empty tpl_id)');
Expand Down Expand Up @@ -152,6 +153,25 @@
}
break;

// удаление шаблона
case 'remove':
if (!$forum_id = (int) $this->request['forum_id'])
{
$this->ajax_die('empty forum_id');
}
if (!forum_exists($forum_id))
{
$this->ajax_die("нет такого форума [id: $forum_id]");
}
$sql = "DELETE FROM ". BB_TOPIC_TPL . " WHERE tpl_id = $tpl_id LIMIT 1";
if (!@DB()->query($sql))
{
$sql_error = DB()->sql_error();
}
DB()->query("UPDATE ". BB_FORUMS ." SET forum_tpl_id = 0 WHERE forum_id = $forum_id LIMIT 1");
$this->response['msg'] = "Шаблон {$tpl_data['tpl_name']} успешно удалён";
break;

// ошибочный $mode
default:
$this->ajax_die("invalid mode: $mode");
Expand All @@ -169,4 +189,4 @@

// выход
$this->response['mode'] = $mode;
$this->response['timestamp'] = TIMENOW;
$this->response['timestamp'] = TIMENOW;
9 changes: 7 additions & 2 deletions styles/templates/posting_tpl.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -4090,10 +4090,12 @@ ajax.topic_tpl = function(mode, params) {
$('#tpl-new-block').toggle();
break;
case 'remove':
case 'load':
ajax.exec({
action : 'topic_tpl',
mode : 'load',
mode : mode,
forum_id : {FORUM_ID},
tpl_id : $('#forum_tpl_select').val()
});
break;
Expand Down Expand Up @@ -4164,6 +4166,7 @@ ajax.callback.topic_tpl = function(data) {
break;
case 'assign':
case 'remove':
alert(data.msg);
window.location.reload();
break;
Expand All @@ -4180,6 +4183,7 @@ ajax.callback.topic_tpl = function(data) {
case 'new':
$('#tpl-new-resp').html('новый шаблон создан (в списке выбора он появится после перезагрузки страницы)');
window.location.reload();
break;
}
};
Expand Down Expand Up @@ -4400,6 +4404,7 @@ $(function(){
<!-- IF TPL_SELECT -->{TPL_SELECT} &nbsp;
<input type="button" value="Включить в этом форуме" class="bold" onclick="ajax.topic_tpl('assign', {tpl_id: $('#forum_tpl_select').val()})" /> &nbsp;
<input type="button" value="Загрузить" onclick="ajax.topic_tpl('load')" /> &nbsp;
<input type="button" value="{L_REMOVE}" onclick="ajax.topic_tpl('remove')" /> &nbsp;
<!-- ELSE -->Нет щаблонов для релизов<!-- ENDIF -->
<br /><br />
<span class="gen">
Expand Down Expand Up @@ -4849,4 +4854,4 @@ $(function(){
<textarea id="tpl-src-msg-val" rows="10" cols="10">{TPL_SRC_MSG_VAL}</textarea>
</div>
<noscript><div class="warningBox2 bold tCenter">Для показа необходимo включить JavaScript</div></noscript>
<noscript><div class="warningBox2 bold tCenter">Для показа необходимo включить JavaScript</div></noscript>

0 comments on commit 0f092de

Please sign in to comment.