Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7989355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T12:43:54+00:00 2026-06-04T12:43:54+00:00

I am using ACL to grant resources to roles in the system, the allowed

  • 0

I am using ACL to grant resources to roles in the system, the allowed actions is excuted and denied actions are routed to custom page, I want to show and hide menu elements at run time using resources at ACL, and also I want to show and hide anchors, buttons in views.

I make a helper class

  class Zend_View_Helper_Permission extends Zend_View_Helper_Abstract
  {
   private $_acl;
    public function hasAccess($role, $action, $controller)
    {
      if (!$this->_acl) {

           $this->_acl = Zend_Registry::get("Acl");
    }

     return $this->_acl->isAllowed($role, $controller, $action);
  }
} 

I define the view helper in config.ini file like this

resources.view.helperPath.Zend_View_Helper = APPLICATION_PATH "/modules/privileges/views/helpers"

how can I use this helper to make views created at run time?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T12:43:56+00:00Added an answer on June 4, 2026 at 12:43 pm

    Your method name should match class name hence it should be permission instead of hasAccess.

    I myself use a global method show() instead of using view helper

        function show($action = null)
        {
    
            $request = Zend_Controller_Front::getInstance()->getRequest();
            $action = $action === null ? $request->getActionName() : $action;
            $module = $request->getModuleName();
            $controller = $request->getControllerName();
    
            if(!Zend_Registry::isRegistered('acl')) throw new Exception('Show function can only be called inside view after preDispatch');
    
            $acl = Zend_Registry::get('acl');
    $resource = $module . '#' . $controller;
            return $acl->isAllowed(Zend_Auth::getInstance()->getIdentity(),$resource,$action);
        }
    

    To keep it simple it takes controller , module name from request object .
    To hide edit action link in list action view simply doo

    list.phtml code as follow

    <h2>Listing page Only superadmin can see edit link</h2>
    <?php if(show('edit')): ?>
    <a href="<?echo $this->url(array('action'=>'edit')) ?>">Edit</a>
    <?php endif;?>
    

    Update

    The global function show was defined inside library/Util.php which was loaded inside
    public/index.php

    require_once 'Zend/Application.php';
    require_once 'Util.php';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing forum app on Django using custom session/auth/users/acl system. One of goals
I am using acl and I want to redirect the users based on which
I want to use the navigation helper to build my navigation menus using Acl.
i just want to know the difference between using ACL and spring role-based authorization
I'm using spark_plug plugin on cakephp, this plugin provides an authentication-acl system for register
I want to allow resource to role using ACL in Zend framework I have
Using Nunit, I want to be able to write a test fixture that will
I'm contemplating using Zend_ACL. However, to me it looks like you create roles and
I currently have a web-application that implements a rudimentary form of ACL using UNIONs
I am using the Zend Framework for ACL's in codeigniter but if something is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.