From 7f57983485253169c457adc1331d01b06fae89c2 Mon Sep 17 00:00:00 2001
From: Jefferson49 <81484983+Jefferson49@users.noreply.github.com>
Date: Tue, 30 Jan 2024 22:04:42 +0100
Subject: [PATCH 1/3] Added permissions to global component configuration
---
com_sexypolling/admin/access.xml | 13 +++++++++++++
com_sexypolling/admin/config.xml | 23 +++++++++++++++++++++++
com_sexypolling/sexypolling.xml | 2 ++
3 files changed, 38 insertions(+)
create mode 100644 com_sexypolling/admin/access.xml
create mode 100644 com_sexypolling/admin/config.xml
diff --git a/com_sexypolling/admin/access.xml b/com_sexypolling/admin/access.xml
new file mode 100644
index 0000000..dbf9e54
--- /dev/null
+++ b/com_sexypolling/admin/access.xml
@@ -0,0 +1,13 @@
+
+
+
+
diff --git a/com_sexypolling/admin/config.xml b/com_sexypolling/admin/config.xml
new file mode 100644
index 0000000..0a9623f
--- /dev/null
+++ b/com_sexypolling/admin/config.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
diff --git a/com_sexypolling/sexypolling.xml b/com_sexypolling/sexypolling.xml
index 8966e38..a11055a 100644
--- a/com_sexypolling/sexypolling.xml
+++ b/com_sexypolling/sexypolling.xml
@@ -69,6 +69,8 @@
controller.php
sexypolling.php
index.html
+ access.xml
+ config.xml
install
assets
From 7f5b8a8df92a7405635d04c4f345cee295485c9a Mon Sep 17 00:00:00 2001
From: Jefferson49 <81484983+Jefferson49@users.noreply.github.com>
Date: Fri, 2 Feb 2024 19:22:26 +0100
Subject: [PATCH 2/3] Added option button to each view
---
com_sexypolling/admin/views/sexyanswers/view.html.php | 4 +++-
.../admin/views/sexycategories/view.html.php | 3 +++
com_sexypolling/admin/views/sexypolling/view.html.php | 10 ++++++++++
com_sexypolling/admin/views/sexypolls/view.html.php | 1 +
.../admin/views/sexystatistics/view.html.php | 2 +-
.../admin/views/sexytemplates/view.html.php | 3 +++
com_sexypolling/admin/views/sexyvotes/view.html.php | 3 +++
.../admin/views/showstatistics/view.html.php | 11 +++++++++++
8 files changed, 35 insertions(+), 2 deletions(-)
diff --git a/com_sexypolling/admin/views/sexyanswers/view.html.php b/com_sexypolling/admin/views/sexyanswers/view.html.php
index 1871318..e762e85 100644
--- a/com_sexypolling/admin/views/sexyanswers/view.html.php
+++ b/com_sexypolling/admin/views/sexyanswers/view.html.php
@@ -80,7 +80,9 @@ protected function addToolbar()
JToolBarHelper::publish('sexyanswers.publish', 'JTOOLBAR_PUBLISH', true);
JToolBarHelper::unpublish('sexyanswers.unpublish', 'JTOOLBAR_UNPUBLISH', true);
JToolBarHelper::deleteList('', 'sexyanswers.delete', 'JTOOLBAR_DELETE');
-
+
+ JToolBarHelper::divider();
+ JToolBarHelper::preferences('com_sexypolling');
}
/**
diff --git a/com_sexypolling/admin/views/sexycategories/view.html.php b/com_sexypolling/admin/views/sexycategories/view.html.php
index f24f172..90cb128 100644
--- a/com_sexypolling/admin/views/sexycategories/view.html.php
+++ b/com_sexypolling/admin/views/sexycategories/view.html.php
@@ -67,6 +67,9 @@ protected function addToolbar()
JToolBarHelper::publish('sexycategories.publish', 'JTOOLBAR_PUBLISH', true);
JToolBarHelper::unpublish('sexycategories.unpublish', 'JTOOLBAR_UNPUBLISH', true);
JToolBarHelper::deleteList('', 'sexycategories.delete', 'JTOOLBAR_DELETE');
+
+ JToolBarHelper::divider();
+ JToolBarHelper::preferences('com_sexypolling');
}
/**
diff --git a/com_sexypolling/admin/views/sexypolling/view.html.php b/com_sexypolling/admin/views/sexypolling/view.html.php
index fbc184d..c11f79e 100644
--- a/com_sexypolling/admin/views/sexypolling/view.html.php
+++ b/com_sexypolling/admin/views/sexypolling/view.html.php
@@ -17,6 +17,16 @@
class SexypollingViewsexypolling extends HtmlView {
function display($tpl = null) {
+ $this->addToolbar();
parent::display($tpl);
}
+
+ /**
+ * Add the page title and toolbar.
+ *
+ */
+ protected function addToolbar()
+ {
+ JToolBarHelper::preferences('com_sexypolling');
+ }
}
diff --git a/com_sexypolling/admin/views/sexypolls/view.html.php b/com_sexypolling/admin/views/sexypolls/view.html.php
index c99cafa..40605d8 100644
--- a/com_sexypolling/admin/views/sexypolls/view.html.php
+++ b/com_sexypolling/admin/views/sexypolls/view.html.php
@@ -91,6 +91,7 @@ protected function addToolbar()
JToolBarHelper::deleteList('', 'sexypolls.delete', 'JTOOLBAR_DELETE');
JToolBarHelper::divider();
+ JToolBarHelper::preferences('com_sexypolling');
}
/**
diff --git a/com_sexypolling/admin/views/sexystatistics/view.html.php b/com_sexypolling/admin/views/sexystatistics/view.html.php
index 1ce44b7..10b0450 100644
--- a/com_sexypolling/admin/views/sexystatistics/view.html.php
+++ b/com_sexypolling/admin/views/sexystatistics/view.html.php
@@ -79,7 +79,7 @@ public function display($tpl = null) {
*/
protected function addToolbar()
{
-
+ JToolBarHelper::preferences('com_sexypolling');
}
/**
diff --git a/com_sexypolling/admin/views/sexytemplates/view.html.php b/com_sexypolling/admin/views/sexytemplates/view.html.php
index 0b2c29f..d1b487b 100644
--- a/com_sexypolling/admin/views/sexytemplates/view.html.php
+++ b/com_sexypolling/admin/views/sexytemplates/view.html.php
@@ -66,6 +66,9 @@ protected function addToolbar()
JToolBarHelper::publish('sexytemplates.publish', 'JTOOLBAR_PUBLISH', true);
JToolBarHelper::unpublish('sexytemplates.unpublish', 'JTOOLBAR_UNPUBLISH', true);
JToolBarHelper::deleteList('', 'sexytemplates.delete', 'JTOOLBAR_DELETE');
+
+ JToolBarHelper::divider();
+ JToolBarHelper::preferences('com_sexypolling');
}
/**
diff --git a/com_sexypolling/admin/views/sexyvotes/view.html.php b/com_sexypolling/admin/views/sexyvotes/view.html.php
index 02c70fd..fe7eaa5 100644
--- a/com_sexypolling/admin/views/sexyvotes/view.html.php
+++ b/com_sexypolling/admin/views/sexyvotes/view.html.php
@@ -67,6 +67,9 @@ public function display($tpl = null) {
protected function addToolbar()
{
JToolBarHelper::deleteList('', 'sexyvotes.delete', 'JTOOLBAR_DELETE');
+
+ JToolBarHelper::divider();
+ JToolBarHelper::preferences('com_sexypolling');
}
/**
diff --git a/com_sexypolling/admin/views/showstatistics/view.html.php b/com_sexypolling/admin/views/showstatistics/view.html.php
index 69e827d..884e068 100644
--- a/com_sexypolling/admin/views/showstatistics/view.html.php
+++ b/com_sexypolling/admin/views/showstatistics/view.html.php
@@ -20,6 +20,17 @@ class SexypollingViewShowstatistics extends HtmlView {
function display($tpl = null) {
ToolbarHelper::cancel( 'showstatistics.cancel', 'JTOOLBAR_CLOSE' );
+ $this->addToolbar();
+ $this->sidebar = JHtmlSidebar::render();
parent::display($tpl);
}
+
+ /**
+ * Add the page title and toolbar.
+ *
+ */
+ protected function addToolbar()
+ {
+ JToolBarHelper::preferences('com_sexypolling');
+ }
}
From 688706afef0150f4d0ac503fd2edee30adec18f4 Mon Sep 17 00:00:00 2001
From: Jefferson49 <81484983+Jefferson49@users.noreply.github.com>
Date: Fri, 2 Feb 2024 21:58:29 +0100
Subject: [PATCH 3/3] Added option in general settings: Permission control for
viewing answers and votes
---
com_sexypolling/admin/access.xml | 2 ++
com_sexypolling/admin/config.xml | 20 +++++++++++++++--
.../language/de-DE/de-DE.com_sexypolling.ini | 14 +++++++++++-
.../language/en-GB/en-GB.com_sexypolling.ini | 12 ++++++++++
.../admin/views/sexyanswers/tmpl/default.php | 22 +++++++++++++++++++
.../admin/views/sexyvotes/tmpl/default.php | 22 +++++++++++++++++++
6 files changed, 89 insertions(+), 3 deletions(-)
diff --git a/com_sexypolling/admin/access.xml b/com_sexypolling/admin/access.xml
index dbf9e54..b9f216b 100644
--- a/com_sexypolling/admin/access.xml
+++ b/com_sexypolling/admin/access.xml
@@ -9,5 +9,7 @@
+
+
diff --git a/com_sexypolling/admin/config.xml b/com_sexypolling/admin/config.xml
index 0a9623f..0f7f54f 100644
--- a/com_sexypolling/admin/config.xml
+++ b/com_sexypolling/admin/config.xml
@@ -1,12 +1,29 @@
+
diff --git a/com_sexypolling/admin/language/de-DE/de-DE.com_sexypolling.ini b/com_sexypolling/admin/language/de-DE/de-DE.com_sexypolling.ini
index f8e0fd9..4063a53 100644
--- a/com_sexypolling/admin/language/de-DE/de-DE.com_sexypolling.ini
+++ b/com_sexypolling/admin/language/de-DE/de-DE.com_sexypolling.ini
@@ -227,4 +227,16 @@ COM_SEXYPOLLING_USER="Benutzer"
COM_SEXYPOLLING_IP="IP"
COM_SEXYPOLLING_COUNTRY="Land"
COM_SEXYPOLLING_CITY="Stadt"
-COM_SEXYPOLLING_REGION="Region"
\ No newline at end of file
+COM_SEXYPOLLING_REGION="Region"
+
+COM_SEXYPOLLING_CONFIG_GENERAL_SETTINGS_LABEL="Allgemein"
+COM_SEXYPOLLING_CONFIG_GENERAL_SETTINGS_DESC="Allgemeine Einstellungen"
+COM_SEXYPOLLING_CONFIG_PERMISSION_CONTROL_FOR_ANSWERS_AND_VOTES_LABEL="Berechtigung für die Anzeige von Antworten und Stimmen"
+COM_SEXYPOLLING_CONFIG_PERMISSION_CONTROL_FOR_ANSWERS_AND_VOTES_DESC="Aktivieren der Berechtigung zum Anzeigen von Antworten und Stimmen. Diese Einstellung erlaubt eine striktere Handhabung der Berechtigungen für Antworten/Stimmen, z.B. wenn eine Umfrage für eine Wahl genutzt wird. Berechtigungen können für jede Benutzergruppe in den Einstellungen für Berechtigungen vorgenommen werden."
+
+COM_SEXYPOLLING_ACTION_VIEW_ANSWERS="Anzeigen von Antworten"
+COM_SEXYPOLLING_ACTION_VIEW_ANSWERS_COMPONENT_DESC="Berechtigung zur Anzeige von Antworten im Backend. Nur relevant, wenn die Berechtigung für die Anzeige von Antworten/Stimmen in den allgemeinen Einstellungen aktiviert ist."
+COM_SEXYPOLLING_ACTION_VIEW_ANSWERS_NO_PERMISSION="Sie haben nicht die erforderliche Berechtigung, um Antworten anzuzeigen."
+COM_SEXYPOLLING_ACTION_VIEW_VOTES="Anzeigen von Stimmen"
+COM_SEXYPOLLING_ACTION_VIEW_VOTES_COMPONENT_DESC="Berechtigung zur Anzeige von Stimmen im Backend. Nur relevant, wenn die Berechtigung für die Anzeige von Antworten/Stimmen in den allgemeinen Einstellungen aktiviert ist."
+COM_SEXYPOLLING_ACTION_VIEW_VOTES_NO_PERMISSION="Sie haben nicht die erforderliche Berechtigung, um Stimmen anzuzeigen."
\ No newline at end of file
diff --git a/com_sexypolling/admin/language/en-GB/en-GB.com_sexypolling.ini b/com_sexypolling/admin/language/en-GB/en-GB.com_sexypolling.ini
index 56e5b4e..37e074f 100644
--- a/com_sexypolling/admin/language/en-GB/en-GB.com_sexypolling.ini
+++ b/com_sexypolling/admin/language/en-GB/en-GB.com_sexypolling.ini
@@ -229,3 +229,15 @@ COM_SEXYPOLLING_UP="Up"
COM_SEXYPOLLING_DOWN="Down"
COM_SEXYPOLLING_CUSTOM_STYLES="Custom Styles"
COM_SEXYPOLLING_SEXY_TEMPLATE="Sexy Template"
+
+COM_SEXYPOLLING_CONFIG_GENERAL_SETTINGS_LABEL="General"
+COM_SEXYPOLLING_CONFIG_GENERAL_SETTINGS_DESC="General settings"
+COM_SEXYPOLLING_CONFIG_PERMISSION_CONTROL_FOR_ANSWERS_AND_VOTES_LABEL="Permission control for viewing answers and votes"
+COM_SEXYPOLLING_CONFIG_PERMISSION_CONTROL_FOR_ANSWERS_AND_VOTES_DESC="Activate permission control for viewing answers and votes. This allows to establish stricter permission handling for answers/votes, e.g. if a poll is used for elections. Permissions can be set for each user group in the permissions settings."
+
+COM_SEXYPOLLING_ACTION_VIEW_ANSWERS="View answers"
+COM_SEXYPOLLING_ACTION_VIEW_ANSWERS_COMPONENT_DESC="Permission, wether answers are shown in the administration backend. Only relevant if permission control for viewing answers/votes is activated in general settings."
+COM_SEXYPOLLING_ACTION_VIEW_ANSWERS_NO_PERMISSION="You do not have the permission to view answers"
+COM_SEXYPOLLING_ACTION_VIEW_VOTES="View votes"
+COM_SEXYPOLLING_ACTION_VIEW_VOTES_COMPONENT_DESC="Permission, wether votes are shown in the administration backend. Only relevant if permission control for viewing answers/votes is activated in general settings."
+COM_SEXYPOLLING_ACTION_VIEW_VOTES_NO_PERMISSION="You do not have the permission to view votes"
diff --git a/com_sexypolling/admin/views/sexyanswers/tmpl/default.php b/com_sexypolling/admin/views/sexyanswers/tmpl/default.php
index b0be85b..399d258 100644
--- a/com_sexypolling/admin/views/sexyanswers/tmpl/default.php
+++ b/com_sexypolling/admin/views/sexyanswers/tmpl/default.php
@@ -19,6 +19,8 @@
* @todo Use of $this in global code might be unatended
*/
+use Joomla\CMS\Component\ComponentHelper;
+use Joomla\CMS\Factory;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Router\Route;
@@ -43,6 +45,22 @@
HTMLHelper::_('sortablelist.sortable', 'articleList', 'adminForm', strtolower($listDirn ?? ''), $saveOrderingUrl);
}
$sortFields = $this->getSortFields();
+
+$application = Factory::getApplication();
+$user = $application->getIdentity();
+
+if ($application->isClient('site')) {
+ $params = $application->getParams('com_sexypolling');
+} else {
+ $params = ComponentHelper::getParams('com_sexypolling');
+}
+
+//if permission control for answers is activated, use permission settings for viewing answers
+if ($params->get('permission_control_for_answers_and_votes', 0)) {
+ $show_answers = $user !== null && $user->authorise('core.view.answers', 'com_sexypolling');
+} else {
+ $show_answers = true;
+}
?>