Example #1
0
 protected function setscope()
 {
     //use passed scope
     //if no scope passed get first scope
     //initialize scope form
     if ($this->getRequest()->hasParameter('scope')) {
         if (sfConfig::get('app_sfBreadNav_UserMenus', false)) {
             $this->scope = null;
             $c = new Criteria();
             $c->add(sfBreadNavApplicationPeer::ID, $this->getRequest()->getParameter('scope'));
             $c->add(sfBreadNavApplicationPeer::USER_ID, sfContext::getInstance()->getUser()->getAttribute('user_id', null, 'sfGuardSecurityUser'));
             $tree = sfBreadNavApplicationPeer::doSelectOne($c);
             if ($tree) {
                 $this->scope = $this->getRequest()->getParameter('scope');
             }
         } else {
             $this->scope = $this->getRequest()->getParameter('scope');
         }
     } else {
         $c = new Criteria();
         //if config set to ownermenu only show users menus
         if (sfConfig::get('app_sfBreadNav_UserMenus', false)) {
             $c->add(sfBreadNavApplicationPeer::USER_ID, sfContext::getInstance()->getUser()->getAttribute('user_id', null, 'sfGuardSecurityUser'));
         }
         $c->addAscendingOrderByColumn(sfBreadNavApplicationPeer::ID);
         $tree = sfBreadNavApplicationPeer::doSelectOne($c);
         if ($tree) {
             $this->scope = $tree->getId();
         } else {
             //scope = null
             $this->scope = null;
         }
     }
     $this->scopeform = new sfBreadNavScopeForm();
     $this->scopeform->setDefault('scope', $this->scope);
 }
Example #2
0
 /**
  * Get the associated sfBreadNavApplication object
  *
  * @param      PropelPDO Optional Connection object.
  * @return     sfBreadNavApplication The associated sfBreadNavApplication object.
  * @throws     PropelException
  */
 public function getsfBreadNavApplication(PropelPDO $con = null)
 {
     if ($this->asfBreadNavApplication === null && $this->scope !== null) {
         $c = new Criteria(sfBreadNavApplicationPeer::DATABASE_NAME);
         $c->add(sfBreadNavApplicationPeer::ID, $this->scope);
         $this->asfBreadNavApplication = sfBreadNavApplicationPeer::doSelectOne($c, $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->asfBreadNavApplication->addsfBreadNavs($this);
         		 */
     }
     return $this->asfBreadNavApplication;
 }