Development

Changeset 33302

You must first sign up to be able to contribute.

Changeset 33302

Show
Ignore:
Timestamp:
01/05/12 06:26:43 (1 year ago)
Author:
Stephen.Ostrow
Message:

We now can have permissions on menu items so that they are not shown. Also updated the readme for the advanced case of having attributes.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/sw2DecorationToolkitPlugin/branches/2.0/README

    r25375 r33302  
    3838            Users: '@sf_guard_user' 
    3939            Groups: '@sf_guard_group' 
     40          # Above are simple examples. Below will be advanced. 
     41          'Admin Advanced': 
     42            Home: 
     43              'href': '@homepage' 
     44              'id':   'home_link' 
     45            Logout: 
     46              'href': '@sf_guard_signout' 
     47              'id':   'logout_link' 
     48          'Mental': 
     49            _permission: 'Mental Admin Menu' 
     50            _children: 
     51              Builder:  '@mental_builder' 
     52              Category: '@mental_category' 
     53              Circuit:  '@mental_circuit' 
     54              Exercise: '@mental_exercise' 
     55              Program:  '@mental_program' 
    4056 
    4157Then update the layout.php for the correct app 
     
    7894    # /apps/frontend/public/modules/home/templates/indexSuccess.php 
    7995    <?php add_body_class('home_class'); /> 
    80      
     96 
    8197    # Outputs the following html 
    8298    <body class=".home .index .home_class"> 
  • plugins/sw2DecorationToolkitPlugin/branches/2.0/lib/helper/sw2AdminLayoutHelper.php

    r32940 r33302  
    4848 
    4949function Get_Array_Keys_UL($array = array()) { 
     50 
     51  $sf_context = sfContext::getInstance(); 
     52  $sf_user = $sf_context->getUser(); 
     53 
    5054  $recursion = __FUNCTION__; 
    5155  if(empty($array)) 
     
    5357  $out = '<ul>' . "\n"; 
    5458  foreach($array as $key => $elem) 
     59 
    5560    if(is_array($elem) && !isset($elem['href'])) { 
    56       $out .= '<li>' . $key . $recursion($elem) . '</li>' . "\n"; 
     61      if(isset($elem['_permission'])) { 
     62        if($sf_user->hasCredential($elem['_permission'])) { 
     63          $out .= '<li>' . $key . $recursion($elem['_children']) . '</li>' . "\n"; 
     64        } 
     65      } else { 
     66        $out .= '<li>' . $key . $recursion($elem) . '</li>' . "\n"; 
     67      } 
    5768    } 
     69    elseif(substr($key,0,1) =='_') {} 
    5870    elseif(is_array($elem)) { 
    5971      $href = $elem['href']; 
    6072      $options = $elem; 
    6173      unset($options['href']); 
     74      if(isset($elem['_permission']) && !$sf_user->hasCredential($elem['_permission'])) { 
     75       continue; 
     76      } 
     77      unset($options['_permission']); 
    6278      $out .= '<li>' . link_to($key, $href, $options) . '</li>'; 
    6379    } else {