Joomla 2.5 ACL restrict to specific features/views - components

I seem to be having a problem identifying how to restrict Joomla 2.5 back-end users to specific features / Views in a custom component I am writing. According to my understanding I should be able to add my views as a section in the access.xml file. I have attempted this by naming a section the same name as my view but I don't seem to be able to change the access to that view independently from the component as a whole. Does anybody have a more in depth example I can review or tips? Is this even possible?

I believe what you are trying to do is not supported by Joomla.
My suggestion is to add a custom rule for views in access.xml
<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="COM_CATEGORIES_ACCESS_EDITSTATE_DESC" />
</section>
<section name="views">
<action name="core.admin" title="JACTION_ADMIN" description="JACTION_ADMIN_COMPONENT_DESC" />
</section>
Then save your view in the #__assets table with a name like com_component.view.playerlist,
in the rules field you should save a JSON encoded list of your rules:
{"core.admin":{}}
You can check if current user can or cannot access a determinate section using JAccess
$user_id=JFactory::getUser()->id;
$has_permission = JAccess::check($user_id,'core.admin','com_component.view.playerlist');
if($has_permission){
draw_view();
}else{
JError::riseError(403,JText::_('PERMISSION_DENIED'));
// or
JError::raiseWarning(403,JText::_('PERMISSION_DENIED'));
}
If you have any doubt, feel free to comment.

Related

How to call new css file in magento

I am developing an online store in magento.I am editing the default theme of magento according to my new theme.
I wanted to know how can I call new css and js file to my default theme.
I tried making a blocktype in layout/page.xml like:-
<action method="addCss"><stylesheet>css/styles.css</stylesheet></action>
<action method="addCss"><stylesheet>css/bootstrap.css</stylesheet></action>
<action method="addItem"><type>skin_css</type><name>css/styles-ie.css</name><params/><if>lt IE 8</if></action>
css/widgets.css
css/print.cssmedia="print"
i want to add bootstrap.css file to my theme but its not included in the meta tag
Please help me
use
<reference name="head">
<action method="addCss">
<style>css/filename.css</style>
</action>
</reference>

Magento 1.7: Remove pagination from top and keep pagination at bottom

I am using magento 1.7. In my home page each category has pagination and the pagination appears in both top and bottom of the each category. I want to remove pagination from top and keep pagination in bottom.
For including pagination, I used the following code,
CMS > Pages > Design > Layout Update XML
<reference name="content">
<block type="catalog/product_list" name="home" template="catalog/product/list.phtml">
<action method="setCategoryId"><category_id>137</category_id></action>
<action method="addColumnCountLayoutDepend"><layout>one_column</layout><count>5</count></action>
<block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml">
<block type="page/html_pager" name="product_list_toolbar_pager"/>
</block>
<action method="setToolbarBlockName"><name>product_list_toolbar</name><count>5</count></action>
</block>
</reference>
Hello for pagination use gettoolbarhtml() check following file
/app/design/frontend/default/your_theme/template/catalog/product/list.phtml
comment below line
// echo $this->getToolbarHtml()
You can achieve your goal with something like this:
<reference name="your_parent_block_name">
<remove name="block_name_you_want_to_remove"/>
</reference>

How to remove a specific block from right column which must be shown on rest of the pages?

I had created a static block containing images aligned vertically then I added an xml block for calling it in the right column in catalog.xml.
Now it is showing that block on all pages .
BUt I dont want just this specific block to be displayed on detail page . So how can I restrict it not to be shown on detail page while showing on rest of the pages.
I did tried to remove it by this:
<remove name="right.info" />
And this is the block I'm calling:
<block type="core/text_list" name="banners">
<block type="cms/block" name="right.info">
<action method="setBlockId"><block_id>right_logos</block_id></action>
</block>
</block>
<reference name="banners">
<action method="unsetChild"><name>right.info</name></action>
</reference>

Seam page navigation with includes

I'm using seam page navigation rules. and did not experience any problem with adding rules which redirect from one page to another.
But since I designed my page views using those redirection simply don't happen anymore for those pages.
Tried to define the rule to the view that gets included, then to the view that includes the others (which to me was making more sense) but none work.
Is there anything special about page navigation in seam using included view-id ?
main.xhtml:
<h:outputLabel value="Details:"/>`
<a4j:include viewId="contacts.xhtml" id="contactsDetails"/>`
<page view-id="/*" login-required="true">
<navigation>
<rule if="#{myBean.readyToSee}">
<redirect view-id="/see-contat.xhtml"/>
</rule>
</navigation>
</page>
I'm using jsf, xhtml as my page views.
Thanks
Its difficult for me to answer this question because I simply don't understand it. However I will try to guess what you are asking.
You have a page ie: /somePage.xhtml and inside that page you include some other pages.
I tend to write all my page navigation in pages.xml. I like having everything in one place, because it makes things cleaner and easier to maintain.
You can use wildcards also in the pages.xml file.
So you can do something like this.
<page login-required="true" view-id="/admin/*">
<restrict>#{s:hasRole('orgadmin') or s:hasRole('sysadmin')}</restrict>
<navigation from-action="#{userAdmin.editUser}">
<redirect view-id="/admin/create_user.xhtml" />
</navigation>
<navigation from-action="#{applicationProcessAdmin.saveScheme}">
<rule if-outcome="failure">
<redirect view-id="/admin/processes.xhtml" />
</rule>
</navigation>
</page>
In the above example, I am using a wildcard to say that all navigation that happens from /admin/* that uses some specific action, should redirect to some page i have.
You can also be very specific with the pages
<page login-required="true" view-id="/officer/admin/contacts.xhtml">
<begin-conversation join="true" />
<navigation from-action="#{officerAdmin.saveContact}">
<redirect/>
</navigation>
</page>
If this doesn't help you, you need to clarify your question better.
Update
Try changing your
<page view-id="/*" login-required="true">
<navigation>
<rule if="#{myBean.readyToSee}">
<redirect view-id="/see-contat.xhtml"/>
</rule>
</navigation>
</page>
To this instead
<page view-id="/*" login-required="true">
<navigation from-action="#{myBean.readyToSee}">
<rule if="#{myBean.readyToSee}">
<redirect view-id="/see-contat.xhtml"/>
</rule>
</navigation>
</page>
UPDATE 2
Does all your navigation fail? Or is it only some?
Try removing the /* on page view and replace with just *
If you do this will work:
#Name("myBean")
public class MyBean {
public String doSomething() {
return "success";
}
}
Now from your xhtml (Does not matter which include page it is from)
<!-- Depending on what button you are using, <h:form> is mandatory -->
<h:form>
<h:commandButton value="TEST" action="#{myBean.doSomething}" />
</h:form>
And in your pages xml
<page view-id="*">
<navigation from-action="#{myBean.doSomething}">
<rule if-outcome="success">
<redirect view-id="/test.xhtml" />
</rule>
</navigation>
</page>
The above will work. If it does not, the error is somewhere else in your code.

DIV identified by WebDevToolbar isnt in file?

I'm trying to use Magento for my shopping cart and want to switch from a right col layout to left col. I've turned on ID/CLASS display on the Web Developer Toolbar in firefox, and am seeing ".main col2-right-layout", which i believe i must switch to ".main col2-left-layout", the alternate style is predefined. but running searches for files with the phrase "col2-right-layout" in them is only pulling up the style sheet. I am searching THE ENTIRE Magento directory. How is this possible? Not case sensitive, and I'm even searching hidden folders. How can it be?
**i have looked in that file, the div is not mentioned. **
Files are in app/layout/default/default/templates/page/
I've not got a dev copy of magento at home, thats all I can remember off the top of my head - will try and remember to confirm when at work.
If you want to swap the templates, you need to look in app/layout/default/default/layout/page.xml, plus some of the other xml files - the templates are defined there.
(Yes, magento's layout/templating system is complicated, and has a steep learning curve, but its worth it!)
col2-right-layout is mentioned in
app/design/frontend/base/default/template/page/2columns-right.phtml
or in Magento 1.3
app/design/frontend/default/default/template/page/2columns-right.phtml
If you want to swap the layout I'd suggest changing it in one of the layout xml files. For the shopping cart edit app/design/frontend/base/default/layout/checkout.xml
change
<checkout_cart_index translate="label">
<label>Shopping Cart</label>
<remove name="right"/>
<remove name="left"/>
<!-- Mage_Checkout -->
<reference name="root">
<action method="setTemplate"><template>page/1column.phtml</template></action>
</reference>
to
<checkout_cart_index translate="label">
<label>Shopping Cart</label>
<remove name="right"/>
<remove name="left"/>
<!-- Mage_Checkout -->
<reference name="root">
<action method="setTemplate"><template>page/2columns-left.phtml</template></action>
</reference>
And similarly for the checkout page in the same file change
<checkout_onepage_index translate="label">
<label>One Page Checkout</label>
<!-- Mage_Checkout -->
<remove name="left"/>
<reference name="root">
<action method="setTemplate"><template>page/2columns-right.phtml</template></action>
</reference>
to
<checkout_onepage_index translate="label">
<label>One Page Checkout</label>
<!-- Mage_Checkout -->
<remove name="left"/>
<reference name="root">
<action method="setTemplate"><template>page/2columns-left.phtml</template></action>
</reference>
As always it is better to make a copy of the file you are editing to your own theme.

Resources