Zend navigation rendering issue - zend-framework

This is my navigation XML format, there are 2 user levels in the system, Admin and Super Admin,
When login as Admin all the menu items should be displayed and it works fine, for Super Admin only the Dashboard and statistics should be displayed.
My issue is, for Super admin, along with the dashboard and statistics, labels of the other menu items (those should be displayed only for admin) are showing , Is there any work around to hide the labels. in my case , there are no actions for the top level menu items, except dashboard.
Menu is connected with Zend ACL
<configdata>
<nav>
<dashboard>
<label>Dashboard</label>
<class>nav-top-item no-submenu</class>
<controller>index</controller>
<action>index</action>
<resource>index</resource>
<privilege>index</privilege>
</dashboard>
<app>
<label>Apps</label>
<class>nav-top-item no-submenu</class>
<uri>#</uri>
<pages>
<managefeaturedapps>
<label>Manage Apps</label>
<controller>app</controller>
<action>index</action>
<resource>app</resource>
<privilege>index</privilege>
</managefeaturedapps>
<managepage>
<label>Filter Apps</label>
<controller>app</controller>
<action>filter-apps</action>
<resource>app</resource>
<privilege>filter-apps</privilege>
</managepage>
</pages>
</app>
<user>
<label>Users</label>
<class>nav-top-item no-submenu</class>
<uri>#</uri>
<pages>
<allusers>
<label>Registered Users / Developers</label>
<controller>user</controller>
<action>index</action>
<resource>user</resource>
<privilege>index</privilege>
</allusers>
</pages>
</user>
<page>
<label>Pages</label>
<class>nav-top-item no-submenu</class>
<uri>#</uri>
<pages>
<addpage>
<label>Add New Page</label>
<controller>page</controller>
<action>add-page</action>
<resource>page</resource>
<privilege>add-page</privilege>
</addpage>
</pages>
</page>
<statistics>
<label>Statistics</label>
<class>nav-top-item no-submenu</class>
<uri>#</uri>
<pages>
<viewstats>
<label>Statistics</label>
<controller>statistic</controller>
<action>index</action>
<resource>statistic</resource>
<privilege>index</privilege>
</viewstats>
</pages>
</statistics>
</nav>
ACL Code
class XXX_Controller_Action_Helper_AclPbo {
public $acl;
//Instatntiate Zend ACL
public function __construct()
{
$this->acl = new Zend_Acl();
}
//Set User Rolse
public function setRoles()
{
$this->acl->addRole(new Zend_Acl_Role('superAdmin'));
$this->acl->addRole(new Zend_Acl_Role('admin'));
}
//Set Resources - controller, models, etc...
public function setResources()
{
$this->acl->add(new Zend_Acl_Resource('app'));
$this->acl->add(new Zend_Acl_Resource('index'));
$this->acl->add(new Zend_Acl_Resource('user'));
$this->acl->add(new Zend_Acl_Resource('page'));
$this->acl->add(new Zend_Acl_Resource('statistic'));
}
//Set privileges
public function setPrivilages()
{
$this->acl->allow('superAdmin', 'user', array('login','logout'));
$this->acl->allow('superAdmin', 'index', 'index');
$this->acl->allow('superAdmin', 'app', 'index');
$this->acl->allow('superAdmin', 'statistic', array('index'));
$this->acl->allow('admin', 'user', array('index','login','logout'));
$this->acl->allow('admin', 'index', 'index');
$this->acl->allow('admin', 'app', array('index'));
$this->acl->allow('admin', 'page', array('index', 'add-page', 'edit-page'));
$this->acl->allow('admin', 'statistic', array('index'));
}
//Set ACL to registry - store ACL object in the registry
public function setAcl()
{
Zend_Registry::set('acl', $this->acl);
}
}

The reason why you are experiencing this behavior lies here
<statistics>
<label>Statistics</label>
<class>nav-top-item no-submenu</class>
<uri>#</uri>
while you should be having
<statistics>
<label>Statistics</label>
<class>nav-top-item no-submenu</class>
<controller>statistic</controller>
<action>index</action>
<resource>statistic</resource>
<privilege>index</privilege>
As long as you do not define resource's access parameters it is available to anyone.

Related

Using compiled bindings with Prism

I want to use compiled bindings in my Xamarin Forms app in combination with Prism.
I created a small xamarin forms app with a simple view, viewmodel and prism (prism:ViewModelLocator.AutowireViewModel="True"). Classic binding works as expected.
How should I implemented compiled binding without creating the binding context twice?
Classic binding with prism: HomePage.xaml
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:prism="clr-namespace:Prism.Mvvm;assembly=Prism.Forms"
prism:ViewModelLocator.AutowireViewModel="True"
x:Class="CompiledBinding.Views.HomePage">
<StackLayout>
<!-- Place new controls here -->
<Label Text="{Binding Name}"
HorizontalOptions="Center"
VerticalOptions="CenterAndExpand" />
</StackLayout>
</ContentPage>
HomePageViewModel.cs:
using Prism.Mvvm;
using Prism.Navigation;
using System;
using Xamarin.Forms;
namespace CompiledBinding.ViewModels
{
public class HomePageViewModel : BindableBase
{
string _name = "Compiled binding test";
public HomePageViewModel(INavigationService navigationService)
{
var nav = navigationService;
Device.StartTimer(TimeSpan.FromSeconds(1), () =>
{
// Do something
Name = DateTime.Now.ToString("yyyy MMMM dd hh:mm:ss");
return true; // True = Repeat again, False = Stop the timer
});
}
public string Name
{
get { return _name; }
set { SetProperty(ref _name, value); }
}
}
}
Adding the binding context to the xaml page again, is not an option:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:prism="clr-namespace:Prism.Mvvm;assembly=Prism.Forms"
prism:ViewModelLocator.AutowireViewModel="True"
xmlns:viewModels="clr-namespace:CompiledBinding.ViewModels"
x:Class="CompiledBinding.Views.HomePage"
x:DataType="viewModels:HomePageViewModel">
<ContentPage.BindingContext>
<viewModels:HomePageViewModel />
</ContentPage.BindingContext>
<StackLayout>
<!-- Place new controls here -->
<Label Text="{Binding Name}"
HorizontalOptions="Center"
VerticalOptions="CenterAndExpand" />
</StackLayout>
</ContentPage>
Besides of defining the binding context again, it also results in the error: no public parameterless constructor.
Do I oversee something? Does anyone know how to work with compiled bindings together with prism?

Sapui5: How can I set an initial sort order in smarttable?

I have a smart table. How can I set an initial sort order on one or multiple columns of the smarttable?
<mvc:View xmlns:m="sap.m" xmlns:mvc="sap.ui.core.mvc" xmlns:semantic="sap.m.semantic" xmlns:footerbar="sap.ushell.ui.footerbar"
xmlns:smartFilterBar="sap.ui.comp.smartfilterbar" xmlns:smartTable="sap.ui.comp.smarttable"
xmlns:app="http://schemas.sap.com/sapui5/extension/sap.ui.core.CustomData/1"
controllerName="audi.project.definition.controller.Worklist">
<semantic:SemanticPage id="page">
<semantic:content>
<smartTable:SmartTable id="smartTable" entitySet="ProjectHeaderSet" tableBindingPath="/ProjectHeaderSet"
app:p13nDialogSettings="{sort:{items:[{
columnKey: 'Description',
operation: 'Ascending'
}]}}"
header="{i18n>/X000558}" showRowCount="true" tableType="Responsive" smartFilterId="prdefWorklistFilterBarId"
showFullScreenButton="true" useVariantManagement="false" enableAutoBinding="true" ignoredFields="WbsElement,Method,Refnumber"
initiallyVisibleFields="ProjectDefinition,Description,ZProjecttypeName,ZMsSchemeText">
<smartTable:customToolbar>
<m:OverflowToolbar design="Transparent">
<m:ToolbarSpacer/>
<m:SearchField id="searchField" tooltip="{i18n>/X000559}" width="auto" search="onSearch" liveChange="onSearchLiveChange"></m:SearchField>
<m:Button type="Transparent" press="onCreateBtnPress" icon="sap-icon://add" tooltip="{i18n>/X000053}"/>
<m:Button type="Transparent" press="onDeleteBtnPress" icon="sap-icon://delete" tooltip="{i18n>/X000058}"/>
</m:OverflowToolbar>
</smartTable:customToolbar>
<m:Table id="table" mode="MultiSelect">
<m:items>
<m:ColumnListItem type="Navigation" press="onPress"/>
</m:items>
</m:Table>
</smartTable:SmartTable>
</semantic:content>
</semantic:SemanticPage>
</mvc:View>
The only part that could be one solution is here:
app:p13nDialogSettings="{sort:{items:[{
columnKey: 'Description',
operation: 'Ascending'
}]}}"
Thanks to the answer provided for my another question in this page, I finally reached to an answer for this question. I had to use applyVariant function in the onBindingChange or onInit function of the view. Thus I can call a function like the following each time the view is initiated or the route is matched.
setInitialSortOrder: function() {
var oSmartTable = this.getView().byId("mySmartTableId");
oSmartTable.applyVariant({
sort: {
sortItems: [{
columnKey: "ColumnId",
operation:"Ascending"}
]
}
});
}
Updated Solution
The other possibility is to use annotation. Using the annotations has some benefices in comparison to the previous solution. You can add a sort order on your set by following this annotation settings:
I found this picture in one of the comments here.
Note: Don't forget to put the following definition in your annotation file:
<Annotations xmlns="http://docs.oasis-open.org/odata/ns/edm" Target="namespace.EntityContainerName">
<Annotation Term="Common.ApplyMultiUnitBehaviorForSortingAndFiltering"/>
</Annotations>
Don't forget to update namespace.EntityContainerName based on your namespace and the entity container's name.
Also it shows the sorting sign only on grid table!

How to create a custom form action to a controller in admin html from Magento?

I have created a form in admin html, but its action not working properly, the action not coming to the controller. My config.xml file shown below
<adminhtml>
<menu>
<customercare module="customercare">
<title>Calls</title>
<sort_order>100</sort_order>
<children>
<customercare module="customercare">
<title>View Missed Calls</title>
<sort_order>0</sort_order>
<action>admin_customercare/adminhtml_missedcall</action>
</customercare>
<customercarecalllog module="customercare">
<title>View Call Logs</title>
<sort_order>1</sort_order>
<action>admin_customercare/adminhtml_calllog</action>
</customercarecalllog>
</children>
</customercare>
<customer>
<children>
<customercarevirtualretialerrequest module="customercare">
<title>Manage Virtaul Retailers</title>
<sort_order>10</sort_order>
<action>admin_customercare/adminhtml_virtualretialerrequest</action>
</customercarevirtualretialerrequest>
</children>
</customer>
</menu>
<acl>
<resources>
<all>
<title>Allow Everything</title>
</all>
<admin>
<children>
<customercare translate="title" module="customercare">
<title>Calls</title>
<sort_order>1000</sort_order>
<children>
<customercare translate="title">
<title>View Missed Calls</title>
</customercare>
<customercare translate="title">
<title>Manage Missed Calls</title>
<sort_order>0</sort_order>
</customercare>
<customercarecalllog translate="title">
<title>View Call Logs</title>
<sort_order>1</sort_order>
</customercarecalllog>
</children>
</customercare>
</children>
<customer>
<children>
<virtualretialerrequest translate="title" module="customer">
<title>Manage Virtual Retailers</title>
<sort_order>10</sort_order>
</virtualretialerrequest>
</children>
</customer>
</admin>
</resources>
</acl>
My Controller file
<?php
class Suyati_Customercare_Adminhtml_VirtualretialerrequestController extends Mage_Adminhtml_Controller_Action
{
protected function _isAllowed()
{
return true;
}
public function indexAction()
{
$this->loadLayout();
$block = $this->getLayout()->createBlock(
"Mage_Core_Block_Template",
"virtual-registration",
array('template' => 'customercare/virtual_retailer_registration_admin_form.phtml')
);
$this->_addContent($block);
$this->renderLayout();
}
public function postAction()
{
echo "hello"; die();
}
}
Phtml Form action file located in this path app/design/adminhtml/default/default/template/customercare/virtual_retailer_registration_admin_form.phtml
<form action="<?php echo Mage::helper("adminhtml")->getUrl("customercare/virtualretialerrequest/post"); ?>" id="retailerForm" method="post">
<input type="hidden" name="form_key" value="<? echo $this->getFormKey(); ?>" />
When i try to submit my form it is going to dashboard not coming to the controller action file. please help me on this. I just need to get the post data in the controller file and need to send an email to the admin.
i think the problem with form key
change
<input type="hidden" name="form_key" value="<? echo $this->getFormKey(); ?>" />
to
<input type="hidden" name="form_key" value="<?php echo Mage::getSingleton('core/session')->getFormKey(); ?>" />

Fixing Zend_Route to work with Zend_Navigation

So i have a Zend_Route in my application like this :
public function _initRoutes() {
$front = Zend_Controller_Front::getInstance();
$router = $front->getRouter();
$route = new Zend_Controller_Router_Route(':language/:controller/:action/*',
array(
'language' => 'de',
'controller'=> 'index',
'action' => 'index'
),
array(
'language' => '[a-z]{2}'
));
$router->addRoute('lang_route', $route);
}
and my xml
<?xml version="1.0" encoding="UTF-8" ?>
<configdate>
<nav>
<home>
<label>Home</label>
<controller>index</controller>
<action>index</action>
<pages>
<my_account>
<label>Galery</label>
<controller>index</controller>
<action>list</action>
</my_account>
</pages>
</home>
<login>
<label>Login</label>
<controller>login</controller>
<action>index</action>
</login>
</nav>
</configdate>
My problem is, that Zend_Navigation creats wrong urls.
So when i enter the url
http://localhost/zf/public/en
the urls generated by Zend_Navigation still looks like
http://localhost/zf/public/de/index/
Hope anyone has some ideas :)
You have to add the route you want to use for creating the correct URL in your Xml configuration:
<?xml version="1.0" encoding="UTF-8" ?>
<configdate>
<nav>
<home>
<label>Home</label>
<controller>index</controller>
<action>index</action>
<route>lang_route</route>
</home>
</nav>
</configdate>
In the Xml configuration you can use the same keywords as specified for Zend_Navigation_Page_Mvc.

giving errors in bootstrap when try to use breadcrumbs in zend framework

hi i want to use a breadcrumb for my zend framework application
i craeted navigation.xml in configs folder where application.ini is .
and in the bootstarp i added following code
protected function _initNavigation()
{
$this->bootstrap('layout');
$layout = $this->getResource('layout');
$view = $layout->getView();
$config = new Zend_Config_Xml(APPLICATION_PATH.'/configs/navigation.xml');
$navigation = new Zend_Navigation($config);
$view->navigation($navigation);
}
and in the layout i added folllowing code
<div id="menu">
<?php echo $this->navigation()->menu(); ?>
</div>
<div id="breadcrumbs">
You are in: <?php echo $this->navigation()->breadcrumbs()->setLinkLast(false)->setMinDepth(0)->render(); ?>
</div>
it is not working , errors are given
Fatal error: Uncaught exception 'Zend_Navigation_Exception' with message 'Invalid argument: Unable to determine class to instantiate' in /home/kanishka/workspace/jetwing_ibe/library/Zend/Navigation/Page.php:223
Stack trace:
#0 /home/kanishka/workspace/jetwing_ibe/library/Zend/Navigation/Container.php(117): Zend_Navigation_Page::factory(Array)
#1 /home/kanishka/workspace/jetwing_ibe/library/Zend/Navigation/Container.php(164): Zend_Navigation_Container->addPage(Array)
#2 /home/kanishka/workspace/jetwing_ibe/library/Zend/Navigation.php(46): Zend_Navigation_Container->addPages(Object(Zend_Config_Xml))
#3 /home/kanishka/workspace/jetwing_ibe/application/Bootstrap.php(94): Zend_Navigation->__construct(Object(Zend_Config_Xml))
#4 /home/kanishka/workspace/jetwing_ibe/library/Zend/Application/Bootstrap/BootstrapAbstract.php(666): Bootstrap->_initNavigation()
#5 /home/kanishka/workspace/jetwing_ibe/library/Zend/Application/Bootstrap/BootstrapAbstract.php(619): Zend_Application_Bootstrap_BootstrapAbstract->_executeResource('navigati in /home/kanishka/workspace/jetwing_ibe/library/Zend/Navigation/Page.php on line 223
this is my xml file
<?xml version="1.0" encoding="UTF-8"?>
<config>
<nav>
<dashboard>
<label>dashboard</label>
<controller>dashboard</controller>
<action>index</action>
<resource>dashboard</resource>
<pages>
<rates>
<label>Rates</label>
<controller>rates</controller>
<action>index</action>
<pages>
<index>
<label>index</label>
<controller>rates</controller>
<action>index</action>
<class>dontdisplay</class>
</index>
</pages>
</rates>
<occupancydenomination>
<label>Occupancydenominations</label>
<controller>occupancydenomination</controller>
<action>index</action>
<pages>
<index>
<label>Occupancydenomination</label>
<controller>occupancydenomination</controller>
<action>index</action>
<class>dontdisplay</class>
</index>
<add>
<label>Add Occupancydenomination</label>
<controller>occupancydenomination</controller>
<action>add</action>
<class>dontdisplay</class>
</add>
</pages>
</occupancydenomination>
</pages>
</dashboard>
</nav>
</config>
i am not sure what the error is . please help me ................
The error is due to your config file.
You're not providing enough parameters for the navigation container to determine the correct page type, Zend_Navigation_Page_Mvc or Zend_Navigation_Page_Uri.
Also, you know there's a navigation resource plugin, right?
UPDATE
Get rid of the <nav> wrapper element. It's trying to interpret that as a page.
That or do follow the example and specify the config section correctly
$config = new Zend_Config_Xml('/path/to/navigation.xml', 'nav');
$container = new Zend_Navigation($config);