Ejemplo n.º 1
0
 /**
  * Signup for a activity.
  */
 public function signoffAction()
 {
     $id = (int) $this->params('id');
     /** @var \Activity\Service\Activity $activityService */
     $activityService = $this->getServiceLocator()->get('activity_service_activity');
     /** @var \Activity\Service\SignUp $signupService */
     $signupService = $this->getServiceLocator()->get('activity_service_signup');
     $queryService = $this->getServiceLocator()->get('activity_service_activityQuery');
     $activity = $queryService->getActivity($id);
     $translator = $activityService->getTranslator();
     //Assure a form is used
     if (!$this->getRequest()->isPost()) {
         $message = $translator->translate('Use the form to unsubscribe');
         $this->redirectActivityRequest($id, false, $message);
         return;
     }
     $form = new RequestForm('activitysignoff');
     $form->setData($this->getRequest()->getPost());
     //Assure the form is valid
     if (!$form->isValid()) {
         $message = $translator->translate('Wrong form');
         $this->redirectActivityRequest($id, false, $message);
         return;
     }
     if (!$signupService->isAllowedToSubscribe()) {
         $message = $translator->translate('You have to be logged in to subscribe for this activity');
         $this->redirectActivityRequest($id, false, $message);
         return;
     }
     $identity = $this->getServiceLocator()->get('user_role');
     $user = $identity->getMember();
     if (!$signupService->isSignedUp($activity, $user)) {
         $message = $translator->translate('You are not subscribed for this activity!');
         $this->redirectActivityRequest($id, false, $message);
         return;
     }
     $signupService->signOff($activity, $user);
     $message = $translator->translate('Successfully unsubscribed');
     $this->redirectActivityRequest($id, true, $message);
 }
Ejemplo n.º 2
0
 /**
  * Set the approval status of the activity requested
  *
  * @param $status
  * @return array|\Zend\Http\Response
  */
 protected function setApprovalStatus($status)
 {
     $id = (int) $this->params('id');
     $activityService = $this->getServiceLocator()->get('activity_service_activity');
     $queryService = $this->getServiceLocator()->get('activity_service_activityQuery');
     /** @var $activity Activity*/
     $activity = $queryService->getActivity($id);
     //Assure the form is used
     if (!$this->getRequest()->isPost()) {
         return $this->notFoundAction();
     }
     $form = new RequestForm('updateApprovalStatus');
     $form->setData($this->getRequest()->getPost());
     //Assure the form is valid
     if (!$form->isValid()) {
         return $this->notFoundAction();
     }
     if (is_null($activity)) {
         return $this->notFoundAction();
     }
     switch ($status) {
         case 'approve':
             $activityService->approve($activity);
             break;
         case 'disapprove':
             $activityService->disapprove($activity);
             break;
         case 'reset':
             $activityService->reset($activity);
             break;
         default:
             throw new \InvalidArgumentException('No such status ' . $status);
     }
     return $this->redirect()->toRoute('admin_activity/queue');
 }