Exemplo n.º 1
0
 public function executeNavigation()
 {
     $this->person = $this->getUser()->getPerson();
     $activityId = $this->getUser()->getAttribute('activityId');
     if ($this->getUser()->hasActivity($activityId)) {
         $this->activity = ActivityPeer::retrieveByPk($activityId);
     } else {
         $this->activity = null;
     }
     $this->usergroup = UsergroupPeer::retrieveByPk($this->getUser()->getAttribute('usergroupId'));
     $this->user = UserPeer::retrieveByPk($this->getUser()->getAttribute('userId'));
 }
Exemplo n.º 2
0
 protected function getUserAttributes()
 {
     if ($this->getUser()->hasAttribute('userId')) {
         $this->forward404Unless($this->usergroup = UsergroupPeer::retrieveByPk($this->getUser()->getAttribute('usergroupId')), sprintf('Object usergroup does not exist (%s).', $this->getUser()->getAttribute('usergroupId')));
         $this->forward404Unless($this->user = UserPeer::retrieveByPk($this->getUser()->getAttribute('userId')), sprintf('Object user does not exist (%s).', $this->getUser()->getAttribute('userId')));
         $this->forward404Unless($this->user->isMember($this->usergroup), 'The user is not member of the specified usergroup.');
         $this->forward404Unless($this->getUser()->getTemposUser()->isLeader($this->usergroup), 'The logged user is not leader of the specified usergroup.');
         $this->person = $this->user;
         return true;
     } else {
         $this->forward404Unless($this->person = $this->getUser()->getPerson(), 'No user or card logged-in.');
         return false;
     }
 }
Exemplo n.º 3
0
 public function executeUsergroupCreate(sfWebRequest $request)
 {
     $this->forward404Unless($request->isMethod('post'));
     if ($request->hasParameter('usergroupId')) {
         $this->forward404Unless($this->usergroup = UsergroupPeer::retrieveByPk($request->getParameter('usergroupId')), sprintf('Object usergroup does not exist (%s).', $request->getParameter('usergroupId')));
         $this->form = new UsergroupSubscriptionForm();
         $this->form->setDefaultUsergroup($this->usergroup);
         $this->form->bind($request->getParameter($this->form->getName()), $request->getFiles($this->form->getName()));
         if ($this->form->isValid()) {
             $this->form->save();
             $this->redirect('usergroup/index');
         }
     } else {
         $this->forward404('No usergroup specified.');
     }
     $this->setTemplate('usergroupNew');
 }
Exemplo n.º 4
0
 public function executeDelete(sfWebRequest $request)
 {
     $request->checkCSRFProtection();
     $this->forward404Unless($usergroup = UsergroupPeer::retrieveByPk($request->getParameter('id')), sprintf('Object usergroup does not exist (%s).', $request->getParameter('id')));
     $usergroup->delete();
     $this->redirect('usergroup/index');
 }
Exemplo n.º 5
0
 protected function handleZoneParameters(sfWebRequest $request)
 {
     if ($request->hasParameter('self')) {
         $this->getUser()->getAttributeHolder()->remove('userId');
         $this->getUser()->getAttributeHolder()->remove('usergroupId');
     }
     $this->forward404Unless($this->activity = ActivityPeer::retrieveByPk($request->getParameter('activityId')), sprintf('Object activity does not exist (%s).', $request->getParameter('activityId')));
     if ($this->getUser()->hasAttribute('userId')) {
         $this->forward404Unless($this->usergroup = UsergroupPeer::retrieveByPk($this->getUser()->getAttribute('usergroupId')), sprintf('Object usergroup does not exist (%s).', $this->getUser()->getAttribute('usergroupId')));
         $this->forward404Unless($this->usergroup->hasActivity($this->activity->getId()), sprintf('User group does not have this entry (\'%s\')', $this->activity->getName()));
         $this->forward404Unless($this->user = UserPeer::retrieveByPk($this->getUser()->getAttribute('userId')), sprintf('Object user does not exist (%s).', $this->getUser()->getAttribute('userId')));
         $this->forward404Unless($this->user->isMember($this->usergroup), 'The user is not member of the specified usergroup.');
         $this->forward404Unless($this->getUser()->getTemposUser()->isLeader($this->usergroup), 'The logged user is not leader of the specified usergroup.');
         $this->person = $this->user;
     } else {
         $this->forward404Unless($this->person = $this->getUser()->getPerson(), 'No user or card logged-in.');
     }
     $this->forward404Unless($this->person->hasActivity($this->activity->getId()), sprintf('Cannot access entry ("%s").', $this->activity));
     $this->getUser()->setAttribute('activityId', $this->activity->getId());
 }