Permalink
Browse files

Merge pull request #2 from elinw/master

Add ACL to toolbars and related items.
  • Loading branch information...
2 parents 6c8916f + 41be5a5 commit 318c01b8bc44198b83af190f978d702811dfd825 @ianmacl committed Mar 29, 2012
@@ -1,12 +1,8 @@
-<?xml version="1.0" encoding="utf-8" ?>
+<?xml version="1.0" encoding="utf-8"?>
<access component="com_onward">
<section name="component">
<action name="core.admin" title="JACTION_ADMIN" description="JACTION_ADMIN_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.state" title="JACTION_EDITSTATE" description="JACTION_EDITSTATE_COMPONENT_DESC" />
- <action name="core.edit.own" title="JACTION_EDITOWN" description="JACTION_EDITOWN_COMPONENT_DESC" />
</section>
</access>
@@ -1,3 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<config>
+
+ <fieldset
+ name="permissions"
+ label="JCONFIG_PERMISSIONS_LABEL"
+ description="JCONFIG_PERMISSIONS_DESC"
+ >
+ <field
+ name="rules"
+ type="rules"
+ label="JCONFIG_PERMISSIONS_LABEL"
+ filter="rules"
+ validate="rules"
+ component="com_menus"
+ section="component">
+ <action
+ name="core.admin"
+ title="JACTION_ADMIN"
+ description="JACTION_ADMIN_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" />
+ </field>
+ </fieldset>
</config>
@@ -0,0 +1,37 @@
+<?php
+/**
+ * @version $Id $
+ * @package Onward
+ * @copyright Copyright (C) 2005 - 2011 Open Source Matters, Inc. All rights reserved.
+ * @license GNU General Public License version 2; see LICENSE.txt
+ */
+
+defined('_JEXEC') or die;
+
+class OnwardHelper
+{
+ /**
+ * Gets a list of the actions that can be performed.
+ *
+ * @param int The category ID.
+ *
+ * @return JObject
+ */
+ public static function getActions()
+ {
+ $user = JFactory::getUser();
+ $result = new JObject;
+
+ $assetName = 'com_onward';
+
+ $actions = array(
+ 'core.admin', 'core.manage', 'core.create'
+ );
+
+ foreach ($actions as $action) {
+ $result->set($action, $user->authorise($action, $assetName));
+ }
+
+ return $result;
+ }
+}
@@ -5,7 +5,7 @@
* @copyright Copyright (C) 2005 - 2011 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2; see LICENSE.txt
*/
-
+
// No direct access
defined('_JEXEC') or die;
@@ -50,10 +50,18 @@ protected function addToolbar()
{
JRequest::setVar('hidemainmenu', true);
+
+ $state = $this->get('State');
+ $canDo = OnwardHelper::getActions();
+ $user = JFactory::getUser();
+
JToolBarHelper::title(JText::_('COM_ONWARD_MANAGER_SITE_VIEW'), 'onward.png');
- JToolBarHelper::addNew('site.batch', 'JTOOLBAR_BATCH');
- JToolBarHelper::addNew('site.scan', 'JTOOLBAR_SCAN');
- JToolBarHelper::cancel('site.cancel','JTOOLBAR_CANCEL');
+ if ($canDo->get('core.admin')) {
+ JToolBarHelper::addNew('site.batch', 'JTOOLBAR_BATCH');
+ JToolBarHelper::addNew('site.scan', 'JTOOLBAR_SCAN');
+ JToolBarHelper::cancel('site.cancel','JTOOLBAR_CANCEL');
+ }
+
JToolBarHelper::divider();
JToolBarHelper::help('JHELP_COMPONENTS_ONWARD_SITE_VIEW');
}
@@ -52,11 +52,18 @@ public function display($tpl = null)
*/
protected function addToolbar()
{
- JToolBarHelper::title(JText::_('COM_ONWARD_MANAGER_SITES'), 'onward.png');
+ $state = $this->get('State');
+ $canDo = OnwardHelper::getActions();
+ $user = JFactory::getUser();
- JToolBarHelper::addNew('sites.discover', 'JTOOLBAR_DISCOVER');
- JToolBarHelper::preferences('com_onward');
- JToolBarHelper::divider();
+ JToolBarHelper::title(JText::_('COM_ONWARD_MANAGER_SITES'), 'onward.png');
+ if ($canDo->get('core.admin')) {
+ JToolBarHelper::addNew('sites.discover', 'JTOOLBAR_DISCOVER');
+ }
+ if ($canDo->get('core.admin')) {
+ JToolBarHelper::preferences('com_onward');
+ JToolBarHelper::divider();
+ }
JToolBarHelper::help('JHELP_COMPONENTS_ONWARD_SITES');
}
}
@@ -26,7 +26,7 @@ class plgOnwardJoomla15_Categories extends OnwardImporterAdapter
protected $context = 'jos_categories';
/**
- * Method to get the SQL query used to retrieve the list of content items.
+ * Method to get the SQL query used to retrieve the list of categories.
*
* @param mixed A JDatabaseQuery object or null.
* @return object A JDatabaseQuery object.

0 comments on commit 318c01b

Please sign in to comment.