diff --git a/CHANGELOG.md b/CHANGELOG.md index 00487b56..7b74a2d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/library/ajax/topic_tpl.php b/library/ajax/topic_tpl.php index fdc36634..1c2ee2da 100644 --- a/library/ajax/topic_tpl.php +++ b/library/ajax/topic_tpl.php @@ -16,6 +16,7 @@ switch ($mode) { case 'load': case 'save': + case 'remove': if (!$tpl_id = (int) $this->request['tpl_id']) { $this->ajax_die('Выбранный шаблон не найден, создайте новый (empty tpl_id)'); @@ -152,6 +153,25 @@ switch ($mode) } 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"); @@ -169,4 +189,4 @@ if ($sql_error) // выход $this->response['mode'] = $mode; -$this->response['timestamp'] = TIMENOW; \ No newline at end of file +$this->response['timestamp'] = TIMENOW; diff --git a/styles/templates/posting_tpl.tpl b/styles/templates/posting_tpl.tpl index 32e7ecb1..67eebc00 100644 --- a/styles/templates/posting_tpl.tpl +++ b/styles/templates/posting_tpl.tpl @@ -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; @@ -4164,6 +4166,7 @@ ajax.callback.topic_tpl = function(data) { break; case 'assign': + case 'remove': alert(data.msg); window.location.reload(); break; @@ -4180,6 +4183,7 @@ ajax.callback.topic_tpl = function(data) { case 'new': $('#tpl-new-resp').html('новый шаблон создан (в списке выбора он появится после перезагрузки страницы)'); + window.location.reload(); break; } }; @@ -4400,6 +4404,7 @@ $(function(){ {TPL_SELECT}       +   Нет щаблонов для релизов

@@ -4849,4 +4854,4 @@ $(function(){ - \ No newline at end of file +