public function configure()
 {
     parent::configure();
     $this->widgetSchema['modules'] = new sfWidgetFormInputHidden();
     $this->widgetSchema['modules_mark'] = new sfWidgetFormChoice(array('expanded' => true, 'multiple' => true, 'choices' => AdvancedLayout::getModules('admin')));
     $this->validatorSchema['modules_mark'] = new sfValidatorPass();
     $this->setDefaults(array('modules_mark' => json_decode($this->getObject()->getModules())));
     $this->validatorSchema->setPostValidator(new sfValidatorCallback(array('callback' => array($this, 'parseModules'))));
     $this->widgetSchema['permissions_list'] = new sfWidgetFormDoctrineChoice(array('multiple' => true, 'expanded' => true, 'order_by' => array('name', 'ASC'), 'model' => 'sfGuardPermission'));
     $this->widgetSchema->setLabels(array('modules_mark' => 'Módulos', 'menu_order' => 'Orden', 'title' => 'Título', 'permissions_list' => 'Se muestra para'));
 }
 public function configure()
 {
     parent::configure();
     $this->useFields(array('modules'));
     $this->widgetSchema['modules'] = new sfWidgetFormInputHidden();
     $this->widgetSchema['modules_mark'] = new sfWidgetFormChoice(array('expanded' => true, 'multiple' => true, 'choices' => AdvancedLayout::getModules()));
     $this->validatorSchema['modules_mark'] = new sfValidatorPass();
     $this->widgetSchema->setLabels(array('modules_mark' => 'Modulos Permitidos'));
     $this->setDefaults(array('modules_mark' => json_decode($this->getObject()->getModules())));
     $this->validatorSchema->setPostValidator(new sfValidatorCallback(array('callback' => array($this, 'parseModules'))));
 }
 public function execute($filterChain)
 {
     if ($this->isFirstCall() && $this->getContext()->getUser()->isAuthenticated()) {
         $profiles = $this->getContext()->getUser()->getGuardUser()->getPermissions();
         if (!count($profiles)) {
             $this->getContext()->getController()->forward('izarusAdvancedCustomize', 'forbidden');
             throw new sfStopException();
         }
         if (count($profiles) == 1) {
             AdvancedLayout::setCurrentProfile($profiles[0]->getId());
         }
         $profile = AdvancedLayout::getCurrentProfile();
         if (AdvancedLayout::isModuleAdvanced()) {
             $action = $this->getContext()->getActionName();
             if (!$profile && $action != 'selectProfile') {
                 $this->getContext()->getController()->forward('izarusAdvancedCustomize', 'selectProfile');
                 throw new sfStopException();
             } else {
                 $polymorfism = AdvancedLayout::modulePolymorfism();
                 if (!AdvancedLayout::userHasPermission()) {
                     $this->getContext()->getUser()->setAttribute('polymodule', false);
                     $this->getContext()->getController()->forward('izarusAdvancedCustomize', 'forbidden');
                     throw new sfStopException();
                 } else {
                     if ($polymorfism !== false) {
                         $this->getContext()->getUser()->setAttribute('polymodule', true);
                         $this->getContext()->getController()->forward($polymorfism['module'], $polymorfism['action']);
                         throw new sfStopException();
                     }
                 }
                 $this->getContext()->getUser()->setAttribute('polymodule', false);
             }
         }
     }
     $filterChain->execute();
 }
<?php

$modules = AdvancedLayout::getModules('admin', true);
if (count(json_decode($sf_data->getRaw('lateral_menu')->getModules()))) {
    foreach (json_decode($sf_data->getRaw('lateral_menu')->getModules(), true) as $m) {
        if (isset($modules[$m])) {
            ?>
<i class="fa fa-fw fa-<?php 
            echo $modules[$m]['icon'];
            ?>
"></i> <?php 
            echo $modules[$m]['title'];
            ?>
<br>
<?php 
        }
    }
} else {
    ?>
<i class="fa fa-fw fa-times"></i> Ninguno
<?php 
}
<div class="page-header">
  <h1>Módulos</h1>
</div>
<h3>Permisos de Módulos por Perfil de Acceso</h3>
<?php 
include_component('izarusModalChild', 'view', array('singular' => 'Perfil de Acceso', 'plural' => 'Perfiles de Acceso', 'class' => 'sfGuardPermission', 'form_class' => 'izarusAdvancedLayoutModulesPermissionsForm', 'form_partial' => 'izarusAdvancedCustomize/form_modules', 'enabled_actions' => array('add' => false, 'edit' => true, 'delete' => false), 'cols' => array('Perfil de Acceso' => '#getName#', 'Número de Módulos Permitidos' => '_izarusAdvancedCustomize/td_nmodules'), 'query' => array('root' => 'p', 'order_by' => 'p.name ASC', 'where' => array(array('p.enable_advanced = ?', 1))), 'messages' => array('empty' => 'No ha ingresado %option.plural%', 'add' => 'Agregar un %option.singular%', 'add_title' => 'Agregar %option.singular%', 'edit_title' => 'Editar %option.singular%', 'delete_title' => 'Eliminar %option.singular%', 'new' => 'Debe guardar para agregar %option.plural%'), 'call_js_function' => 'load_matrix'));
$polymorphisms = AdvancedLayout::getModules('', true, true);
if (count($polymorphisms) && count($permissions)) {
    ?>
<h3>Módulos con configuración avanzada</h3>
<div id="PolymorphismTable">
<?php 
    include_partial('table_polymodule', array('polymorphisms' => $polymorphisms));
    ?>
</div>

<div class="modal fade" id="PolymorphismModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  <div class="modal-dialog modal-lg" role="document">
    <div class="modal-content">
      <form method="post" action="<?php 
    echo url_for('izarusAdvancedCustomize/polyModuleForm');
    ?>
" id="PolymorphismModalForm">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true"><i class="glyphicon glyphicon-remove"></i></span></button>
          <h4 class="modal-title" id="myModalLabel">Configuración Avanzada de Módulo</h4>
        </div>
        <div class="modal-body form-horizontal">
          <i class="fa fa-spin fa-spinner"></i> Cargando...
        </div>
        <div class="modal-footer">
<?php

$module = $sf_data->getRaw('module');
$modules_permissions = AdvancedLayout::getModulesPermissions();
$modules_poly = AdvancedLayout::getModulesPolymorphism();
?>
<div class="alert alert-info text-justify">
Al utilizar un determinado Perfil de Acceso, el módulo <i class="fa fa-fw fa-<?php 
echo $module['icon'];
?>
"></i><b><?php 
echo $module['title'];
?>
</b> puede actuar como otro módulo compatible. Al hacer esto se puede cambiar el acceso a formularios de edición avanzados por unos formularios de edición más básicos.</b>
</div>
<div class="alert alert-danger text-justify hide">
Ocurrió un error al intentar guardar los cambios.
</div>
<input type="hidden" name="r" value="<?php 
echo $module['route'];
?>
" />
<div class="row">
<?php 
foreach ($modules_permissions[$module['route']] as $p) {
    ?>
  <div class="col-sm-6">
    <div class="form-group">
      <label for="for" class="col-xs-4 control-label">Perfil de Acceso</label>
      <div class="col-xs-8">
        <p class="form-control-static"><?php 
 public static function getLateralMenu()
 {
     $permission = AdvancedLayout::getCurrentProfile();
     $app = basename(dirname(dirname(sfContext::getInstance()->getModuleDirectory())));
     $menus = LateralMenuTable::getInstance()->createQuery('lm')->leftJoin('lm.Permissions p')->where('p.id = ?', $permission)->orderBy('lm.menu_order')->execute();
     $permissions = AdvancedLayout::getPermissionsModules();
     $modules = AdvancedLayout::getModules($app, true);
     $menu_arr = array();
     foreach ($menus as $me) {
         $m = array();
         $m['title'] = $me->getTitle();
         $m['modules'] = array();
         foreach (json_decode($me->getModules(), true) as $mo) {
             if (isset($permissions[$permission]) && isset($modules[$mo])) {
                 if (in_array($mo, $permissions[$permission])) {
                     $m['modules'][$mo] = $modules[$mo];
                     $poly = AdvancedLayout::modulePolymorfism($mo);
                     if ($poly !== false && isset($poly['use_title']) && $poly['use_title']) {
                         $m['modules'][$mo]['title'] = $modules[$poly['module'] . '/' . $poly['action']]['title'];
                     }
                 }
             }
         }
         $menu_arr[] = $m;
     }
     return $menu_arr;
 }
 public function executePolyModuleTable(sfWebRequest $request)
 {
     $data = array();
     $data['polymorphisms'] = AdvancedLayout::getModules('', true, true);
     return $this->renderPartial('table_polymodule', $data);
 }
<table class="table table-bordered">
  <tr>
    <th>Módulo</th>
<?php 
foreach ($permissions as $p) {
    ?>
    <th class="text-center"><?php 
    echo $p->getName();
    ?>
</th>
<?php 
}
?>
  </tr>
<?php 
foreach (AdvancedLayout::getModules('admin', true) as $action => $m) {
    ?>
  <tr>
    <td><i class="fa fa-fw fa-<?php 
    echo $m['icon'];
    ?>
"></i> <?php 
    echo $m['title'];
    ?>
</td>
<?php 
    foreach ($permissions as $p) {
        ?>
    <td class="text-center"><i class="fa fa-fw fa-<?php 
        echo $permissions_array[$p->getId()] && in_array($action, $permissions_array[$p->getId()]) ? 'check text-success' : 'times text-danger';
        ?>