Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ACL to toolbars and related items. #2

Merged
merged 2 commits into from
Mar 29, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions administrator/components/com_onward/access.xml
Original file line number Original file line Diff line number Diff line change
@@ -1,12 +1,8 @@
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8"?>
<access component="com_onward"> <access component="com_onward">
<section name="component"> <section name="component">
<action name="core.admin" title="JACTION_ADMIN" description="JACTION_ADMIN_COMPONENT_DESC" /> <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.manage" title="JACTION_MANAGE" description="JACTION_MANAGE_COMPONENT_DESC" />
<action name="core.create" title="JACTION_CREATE" description="JACTION_CREATE_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> </section>
</access> </access>
28 changes: 28 additions & 0 deletions administrator/components/com_onward/config.xml
Original file line number Original file line Diff line number Diff line change
@@ -1,3 +1,31 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<config> <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> </config>
37 changes: 37 additions & 0 deletions administrator/components/com_onward/helpers/onward.php
Original file line number Original file line Diff line number Diff line change
@@ -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;
}
}
16 changes: 12 additions & 4 deletions administrator/components/com_onward/views/site/view.html.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @copyright Copyright (C) 2005 - 2011 Open Source Matters, Inc. All rights reserved. * @copyright Copyright (C) 2005 - 2011 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2; see LICENSE.txt * @license GNU General Public License version 2; see LICENSE.txt
*/ */

// No direct access // No direct access
defined('_JEXEC') or die; defined('_JEXEC') or die;


Expand Down Expand Up @@ -50,10 +50,18 @@ protected function addToolbar()
{ {
JRequest::setVar('hidemainmenu', true); 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::title(JText::_('COM_ONWARD_MANAGER_SITE_VIEW'), 'onward.png');
JToolBarHelper::addNew('site.batch', 'JTOOLBAR_BATCH'); if ($canDo->get('core.admin')) {
JToolBarHelper::addNew('site.scan', 'JTOOLBAR_SCAN'); JToolBarHelper::addNew('site.batch', 'JTOOLBAR_BATCH');
JToolBarHelper::cancel('site.cancel','JTOOLBAR_CANCEL'); JToolBarHelper::addNew('site.scan', 'JTOOLBAR_SCAN');
JToolBarHelper::cancel('site.cancel','JTOOLBAR_CANCEL');
}

JToolBarHelper::divider(); JToolBarHelper::divider();
JToolBarHelper::help('JHELP_COMPONENTS_ONWARD_SITE_VIEW'); JToolBarHelper::help('JHELP_COMPONENTS_ONWARD_SITE_VIEW');
} }
Expand Down
15 changes: 11 additions & 4 deletions administrator/components/com_onward/views/sites/view.html.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -52,11 +52,18 @@ public function display($tpl = null)
*/ */
protected function addToolbar() 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::title(JText::_('COM_ONWARD_MANAGER_SITES'), 'onward.png');
JToolBarHelper::preferences('com_onward'); if ($canDo->get('core.admin')) {
JToolBarHelper::divider(); JToolBarHelper::addNew('sites.discover', 'JTOOLBAR_DISCOVER');
}
if ($canDo->get('core.admin')) {
JToolBarHelper::preferences('com_onward');
JToolBarHelper::divider();
}
JToolBarHelper::help('JHELP_COMPONENTS_ONWARD_SITES'); JToolBarHelper::help('JHELP_COMPONENTS_ONWARD_SITES');
} }
} }
2 changes: 1 addition & 1 deletion plugins/onward/joomla15_categories/joomla15_categories.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class plgOnwardJoomla15_Categories extends OnwardImporterAdapter
protected $context = 'jos_categories'; 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. * @param mixed A JDatabaseQuery object or null.
* @return object A JDatabaseQuery object. * @return object A JDatabaseQuery object.
Expand Down