Exemple #1
0
 public function executeAcceso(sfWebRequest $request)
 {
     $id = $request->getParameter('id');
     $defaults = array();
     $Menu = MenuQuery::create()->usePerfilMenuQuery()->filterByPerfilId($id)->endUse()->find();
     foreach ($Menu as $fila) {
         $defaults['Menu'][] = $fila->getId();
     }
     $this->form = new AccesoForm($defaults);
     if ($request->isMethod('POST')) {
         $this->form->bind($request->getParameter('acceso'));
         if ($this->form->isValid()) {
             $valores = $this->form->getValues();
             PerfilMenuQuery::create()->findByPerfilId($id)->delete();
             foreach ($valores['Menu'] as $fila) {
                 $PerfilMenu = new PerfilMenu();
                 $PerfilMenu->setPerfilId($id);
                 $PerfilMenu->setMenuId($fila);
                 $PerfilMenu->save();
             }
             $idUsuario = $this->getUser()->getAttribute('usuario', null, 'seguridad');
             $html = Usuario::generaArbol($idUsuario);
             $this->getUser()->setAttribute('menu', $html, 'seguridad');
             $this->getUser()->setFlash('exito', 'Asignacion de Menús realizado correcamente.');
             $this->redirect('perfil/index');
         }
     }
     $this->id = $id;
 }
Exemple #2
0
 static function generaArbol($id)
 {
     $html = '';
     $Menu = MenuQuery::create()->orderByOrden()->where("superior IS NULL or superior = ''")->usePerfilMenuQuery()->usePerfilQuery()->useUsuarioQuery()->filterById($id)->endUse()->endUse()->endUse()->find();
     foreach ($Menu as $fila) {
         $html .= '<li class="dropdown">';
         $Detalle = MenuQuery::create()->filterBySuperior($fila->getId())->orderByOrden()->usePerfilMenuQuery()->usePerfilQuery()->useUsuarioQuery()->filterById($id)->endUse()->endUse()->endUse()->find();
         if (sizeof($Detalle) > 0) {
             $html .= '<a href="#" class="dropdown-toggle" data-toggle="dropdown">' . $fila->getDescripcion() . ' <span class="caret"></span></a>';
             $html .= '<ul class="dropdown-menu" role="menu">';
         } else {
             $html .= '<a href="' . sfContext::getInstance()->getController()->genUrl($fila->getModulo() . '/' . $fila->getAccion()) . '">' . $fila->getDescripcion() . ' <span class="caret"></span></a>';
         }
         foreach ($Detalle as $d) {
             sfContext::getInstance()->getUser()->addCredential($d->getModulo());
             $html .= '<li class="">';
             $html .= '<a href="' . sfContext::getInstance()->getController()->genUrl($d->getModulo() . '/' . $d->getAccion()) . '">';
             $html .= '<i class="' . $d->getIcono() . '"></i> <span>' . $d->getDescripcion() . '</span>';
             $html .= '</a>';
             $html .= '</li>';
         }
         if (sizeof($Detalle) > 0) {
             $html .= '</ul>';
         }
         $html .= '</li>';
     }
     return $html;
 }
Exemple #3
0
 public function configure()
 {
     $Menu = MenuQuery::create()->find();
     $listado = array();
     $listado[""] = '[SUPERIOR]';
     foreach ($Menu as $fila) {
         $listado[$fila->getId()] = $fila->getDescripcion();
     }
     $this->setWidget('superior', new sfWidgetFormChoice(array('choices' => $listado), array('class' => 'form-control input-medium')));
 }
Exemple #4
0
 /**
  * Removes this object from datastore and sets delete attribute.
  *
  * @param PropelPDO $con
  * @return void
  * @throws PropelException
  * @throws Exception
  * @see        BaseObject::setDeleted()
  * @see        BaseObject::isDeleted()
  */
 public function delete(PropelPDO $con = null)
 {
     if ($this->isDeleted()) {
         throw new PropelException("This object has already been deleted.");
     }
     if ($con === null) {
         $con = Propel::getConnection(MenuPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     }
     $con->beginTransaction();
     try {
         $deleteQuery = MenuQuery::create()->filterByPrimaryKey($this->getPrimaryKey());
         $ret = $this->preDelete($con);
         // symfony_behaviors behavior
         foreach (sfMixer::getCallables('BaseMenu:delete:pre') as $callable) {
             if (call_user_func($callable, $this, $con)) {
                 $con->commit();
                 return;
             }
         }
         if ($ret) {
             $deleteQuery->delete($con);
             $this->postDelete($con);
             // symfony_behaviors behavior
             foreach (sfMixer::getCallables('BaseMenu:delete:post') as $callable) {
                 call_user_func($callable, $this, $con);
             }
             $con->commit();
             $this->setDeleted(true);
         } else {
             $con->commit();
         }
     } catch (Exception $e) {
         $con->rollBack();
         throw $e;
     }
 }
Exemple #5
0
 /**
  * Get the associated Menu object
  *
  * @param PropelPDO $con Optional Connection object.
  * @return Menu The associated Menu object.
  * @throws PropelException
  */
 public function getMenu(PropelPDO $con = null)
 {
     if ($this->aMenu === null && $this->menu_id !== null) {
         $this->aMenu = MenuQuery::create()->findPk($this->menu_id, $con);
         /* The following can be used additionally to
               guarantee the related object contains a reference
               to this object.  This level of coupling may, however, be
               undesirable since it could result in an only partially populated collection
               in the referenced object.
               $this->aMenu->addPerfilMenus($this);
            */
     }
     return $this->aMenu;
 }