diff --git a/README.md b/README.md index d082be6..df36064 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,6 @@ Szkielet komponentu Joomla 6 do gromadzenia pytań testowych. ## Instalacja -W Joomla wybierz **System → Install → Install from Folder** i wskaż ten katalog. Manifestem instalacyjnym jest `com_testquestions.xml` (wersja 1.43.11). +W Joomla wybierz **System → Install → Install from Folder** i wskaż ten katalog. Manifestem instalacyjnym jest `com_testquestions.xml` (wersja 1.43.12). Po instalacji komponent jest dostępny w panelu administratora jako **Pytania testowe**. diff --git a/administrator/components/com_testquestions/language/en-GB/com_testquestions.ini b/administrator/components/com_testquestions/language/en-GB/com_testquestions.ini index 7c01b82..c11ada5 100644 --- a/administrator/components/com_testquestions/language/en-GB/com_testquestions.ini +++ b/administrator/components/com_testquestions/language/en-GB/com_testquestions.ini @@ -46,6 +46,9 @@ COM_TESTQUESTIONS_ERROR_OPEN_PATTERN="Dla pytania otwartego wpisz wzorzec popraw COM_TESTQUESTIONS_ERROR_ALL_ANSWERS="Dla pytania zamkniętego uzupełnij wszystkie cztery odpowiedzi." COM_TESTQUESTIONS_ERROR_META="Wybierz poprawny czas i liczbę punktów." COM_TESTQUESTIONS_SETS="Zestawy pytań" +COM_TESTQUESTIONS_SETS_UNPUBLISH_ALL="Wyłącz wszystkie zestawy" +COM_TESTQUESTIONS_SETS_UNPUBLISH_ALL_CONFIRM="Czy na pewno wyłączyć wszystkie zestawy testów, w tym wszystkie warianty?" +COM_TESTQUESTIONS_SETS_UNPUBLISHED_ALL="Wyłączono %s zestawów." COM_TESTQUESTIONS_NEW_SET="Nowy zestaw pytań" COM_TESTQUESTIONS_EDIT_SET="Edytuj zestaw pytań" COM_TESTQUESTIONS_SET_TITLE="Nazwa zestawu" diff --git a/administrator/components/com_testquestions/sql/updates/mysql/1.43.12.sql b/administrator/components/com_testquestions/sql/updates/mysql/1.43.12.sql new file mode 100644 index 0000000..dd4811a --- /dev/null +++ b/administrator/components/com_testquestions/sql/updates/mysql/1.43.12.sql @@ -0,0 +1 @@ +-- No database changes required for version 1.43.12. diff --git a/administrator/components/com_testquestions/src/Controller/SetsController.php b/administrator/components/com_testquestions/src/Controller/SetsController.php index ca90108..5d6a55a 100644 --- a/administrator/components/com_testquestions/src/Controller/SetsController.php +++ b/administrator/components/com_testquestions/src/Controller/SetsController.php @@ -5,11 +5,40 @@ namespace Komponent\Component\Testquestions\Administrator\Controller; defined('_JEXEC') or die; use Joomla\CMS\MVC\Controller\AdminController; +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Router\Route; +use Joomla\CMS\Session\Session; class SetsController extends AdminController { protected $text_prefix = 'COM_TESTQUESTIONS'; + public function unpublishall(): void + { + if (!Session::checkToken()) { + throw new \RuntimeException(Text::_('JINVALID_TOKEN'), 403); + } + + $user = Factory::getApplication()->getIdentity(); + if (!$user->authorise('core.edit.state', 'com_testquestions') && !$user->authorise('core.edit', 'com_testquestions')) { + throw new \RuntimeException(Text::_('JERROR_ALERTNOAUTHOR'), 403); + } + + $db = Factory::getContainer()->get('DatabaseDriver'); + $db->setQuery( + $db->getQuery(true) + ->update($db->quoteName('#__testquestions_sets')) + ->set($db->quoteName('published') . ' = 0') + ->where($db->quoteName('published') . ' = 1') + )->execute(); + + $this->setRedirect( + Route::_('index.php?option=com_testquestions&view=sets', false), + Text::sprintf('COM_TESTQUESTIONS_SETS_UNPUBLISHED_ALL', $db->getAffectedRows()) + ); + } + public function getModel($name = 'Set', $prefix = 'Administrator', $config = ['ignore_request' => true]) { return parent::getModel($name, $prefix, $config); diff --git a/administrator/components/com_testquestions/src/View/Sets/HtmlView.php b/administrator/components/com_testquestions/src/View/Sets/HtmlView.php index 60cf9f0..4ccc267 100644 --- a/administrator/components/com_testquestions/src/View/Sets/HtmlView.php +++ b/administrator/components/com_testquestions/src/View/Sets/HtmlView.php @@ -15,6 +15,7 @@ class HtmlView extends BaseHtmlView protected $pagination; protected $state; protected $subjects; + protected $canUnpublishAll = false; public function display($tpl = null) { @@ -22,6 +23,8 @@ class HtmlView extends BaseHtmlView $this->pagination = $this->get('Pagination'); $this->state = $this->get('State'); $this->subjects = $this->get('Subjects'); + $user = $this->getCurrentUser(); + $this->canUnpublishAll = $user->authorise('core.edit.state', 'com_testquestions') || $user->authorise('core.edit', 'com_testquestions'); if (count($errors = $this->get('Errors'))) { throw new \RuntimeException(implode("\n", $errors)); diff --git a/administrator/components/com_testquestions/tmpl/sets/default.php b/administrator/components/com_testquestions/tmpl/sets/default.php index 5dc8b0b..a437b9a 100644 --- a/administrator/components/com_testquestions/tmpl/sets/default.php +++ b/administrator/components/com_testquestions/tmpl/sets/default.php @@ -30,6 +30,11 @@ HTMLHelper::_('behavior.multiselect');
+ canUnpublishAll) : ?> + +
diff --git a/com_testquestions.xml b/com_testquestions.xml index c4db9a4..8e2fc1a 100644 --- a/com_testquestions.xml +++ b/com_testquestions.xml @@ -4,7 +4,7 @@ 2026-10-14 Komponent GNU General Public License version 2 or later - 1.43.11 + 1.43.12 COM_TESTQUESTIONS_DESCRIPTION com_testquestions Komponent\Component\Testquestions