Skip to content

Commit

Permalink
Merge branch 'Feature-global-component-configuration' into version-5.0.x
Browse files Browse the repository at this point in the history
  • Loading branch information
Jefferson49 committed Feb 3, 2024
2 parents e01908b + 688706a commit 0108f8d
Show file tree
Hide file tree
Showing 15 changed files with 160 additions and 3 deletions.
15 changes: 15 additions & 0 deletions com_sexypolling/admin/access.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8" ?>
<access component="com_sexypolling">
<section name="component">
<action name="core.admin" title="JACTION_ADMIN" description="JACTION_ADMIN_COMPONENT_DESC" />
<action name="core.options" title="JACTION_OPTIONS" description="JACTION_OPTIONS_COMPONENT_DESC" />
<action name="core.manage" title="JACTION_MANAGE" description="JACTION_MANAGE_COMPONENT_DESC" />
<action name="core.create" title="JACTION_CREATE" description="JACTION_CREATE_COMPONENT_DESC" />
<action name="core.delete" title="JACTION_DELETE" description="JACTION_DELETE_COMPONENT_DESC" />
<action name="core.edit" title="JACTION_EDIT" description="JACTION_EDIT_COMPONENT_DESC" />
<action name="core.edit.own" title="JACTION_EDITOWN" description="JACTION_EDITOWN_COMPONENT_DESC" />
<action name="core.edit.state" title="JACTION_EDITSTATE" description="JACTION_EDITSTATE_COMPONENT_DESC" />
<action name="core.view.answers" title="COM_SEXYPOLLING_ACTION_VIEW_ANSWERS" description="COM_SEXYPOLLING_ACTION_VIEW_ANSWERS_COMPONENT_DESC" />
<action name="core.view.votes" title="COM_SEXYPOLLING_ACTION_VIEW_VOTES" description="COM_SEXYPOLLING_ACTION_VIEW_VOTES_COMPONENT_DESC" />
</section>
</access>
39 changes: 39 additions & 0 deletions com_sexypolling/admin/config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<config>
<fieldset
name="general"
label="COM_SEXYPOLLING_CONFIG_GENERAL_SETTINGS_LABEL"
description="COM_SEXYPOLLING_CONFIG_GENERAL_SETTINGS_DESC"
addfieldprefix="Joomla\Component\SexyPolling\Administrator\Field"
>
<field
name="permission_control_for_answers_and_votes"
type="radio"
layout="joomla.form.field.radio.switcher"
label="COM_SEXYPOLLING_CONFIG_PERMISSION_CONTROL_FOR_ANSWERS_AND_VOTES_LABEL"
description="COM_SEXYPOLLING_CONFIG_PERMISSION_CONTROL_FOR_ANSWERS_AND_VOTES_DESC"
default="0"
>
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
</fieldset>

<fieldset
name="permissions"
label="JCONFIG_PERMISSIONS_LABEL"
description="JCONFIG_PERMISSIONS_DESC"
>
<field
name="rules"
type="rules"
label="JCONFIG_PERMISSIONS_LABEL"
class="inputbox"
validate="rules"
filter="rules"
component="com_sexypolling"
section="component"
/>
</fieldset>

</config>
14 changes: 13 additions & 1 deletion com_sexypolling/admin/language/de-DE/de-DE.com_sexypolling.ini
Original file line number Diff line number Diff line change
Expand Up @@ -227,4 +227,16 @@ COM_SEXYPOLLING_USER="Benutzer"
COM_SEXYPOLLING_IP="IP"
COM_SEXYPOLLING_COUNTRY="Land"
COM_SEXYPOLLING_CITY="Stadt"
COM_SEXYPOLLING_REGION="Region"
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."
12 changes: 12 additions & 0 deletions com_sexypolling/admin/language/en-GB/en-GB.com_sexypolling.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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"
22 changes: 22 additions & 0 deletions com_sexypolling/admin/views/sexyanswers/tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
?>
<script type="text/javascript">
Joomla.orderTable = function() {
Expand All @@ -66,6 +84,9 @@
<?php else : ?>
<div id="j-main-container">
<?php endif;?>
<?php if(!$show_answers): ?>
<h3 style="color: red;"><?php echo Text::_('COM_SEXYPOLLING_ACTION_VIEW_VOTES_NO_PERMISSION');?></h3>
<?php else : ?>
<div id="filter-bar" class="btn-toolbar">
<div class="filter-search btn-group pull-left">
<label for="filter_search" class="element-invisible"><?php echo Text::_('COM_SEXYPOLLING_SEARCH_BY_NAME');?></label>
Expand Down Expand Up @@ -189,4 +210,5 @@

<?php include (JPATH_BASE.'/components/com_sexypolling/helpers/footer.php'); ?>
</div>
<?php endif;?>
</form>
4 changes: 3 additions & 1 deletion com_sexypolling/admin/views/sexyanswers/view.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

/**
Expand Down
3 changes: 3 additions & 0 deletions com_sexypolling/admin/views/sexycategories/view.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

/**
Expand Down
10 changes: 10 additions & 0 deletions com_sexypolling/admin/views/sexypolling/view.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}
1 change: 1 addition & 0 deletions com_sexypolling/admin/views/sexypolls/view.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ protected function addToolbar()
JToolBarHelper::deleteList('', 'sexypolls.delete', 'JTOOLBAR_DELETE');

JToolBarHelper::divider();
JToolBarHelper::preferences('com_sexypolling');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion com_sexypolling/admin/views/sexystatistics/view.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function display($tpl = null) {
*/
protected function addToolbar()
{
JToolBarHelper::preferences('com_sexypolling');
}

/**
Expand Down
3 changes: 3 additions & 0 deletions com_sexypolling/admin/views/sexytemplates/view.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

/**
Expand Down
22 changes: 22 additions & 0 deletions com_sexypolling/admin/views/sexyvotes/tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -39,6 +41,22 @@
$archived = $this->state->get('filter.published') == 2 ? true : false;
$trashed = $this->state->get('filter.published') == -2 ? true : false;
$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.votes', 'com_sexypolling');
} else {
$show_answers = true;
}
?>
<script type="text/javascript">
Joomla.orderTable = function() {
Expand All @@ -62,6 +80,9 @@
<?php else : ?>
<div id="j-main-container">
<?php endif;?>
<?php if(!$show_answers): ?>
<h3 style="color: red;"><?php echo Text::_('COM_SEXYPOLLING_ACTION_VIEW_VOTES_NO_PERMISSION');?></h3>
<?php else : ?>
<div id="filter-bar" class="btn-toolbar">
<div class="filter-search btn-group pull-left">
<label for="filter_search" class="element-invisible"><?php echo Text::_('COM_SEXYPOLLING_SEARCH');?></label>
Expand Down Expand Up @@ -187,4 +208,5 @@

<?php include (JPATH_BASE.'/components/com_sexypolling/helpers/footer.php'); ?>
</div>
<?php endif;?>
</form>
3 changes: 3 additions & 0 deletions com_sexypolling/admin/views/sexyvotes/view.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ public function display($tpl = null) {
protected function addToolbar()
{
JToolBarHelper::deleteList('', 'sexyvotes.delete', 'JTOOLBAR_DELETE');

JToolBarHelper::divider();
JToolBarHelper::preferences('com_sexypolling');
}

/**
Expand Down
11 changes: 11 additions & 0 deletions com_sexypolling/admin/views/showstatistics/view.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}
2 changes: 2 additions & 0 deletions com_sexypolling/sexypolling.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@
<filename>controller.php</filename>
<filename>sexypolling.php</filename>
<filename>index.html</filename>
<filename>access.xml</filename>
<filename>config.xml</filename>

<folder>install</folder>
<folder>assets</folder>
Expand Down

0 comments on commit 0108f8d

Please sign in to comment.