Beispiel #1
0
 /**
  * Undo an activity sign up.
  *
  * @param ActivityModel $activity
  * @param Member        $user
  */
 public function signOff(ActivityModel $activity, Member $user)
 {
     $signUpMapper = $this->getServiceManager()->get('activity_mapper_signup');
     $signUp = $signUpMapper->getSignUp($activity->get('id'), $user->getLidnr());
     // If the user was not signed up, no need to signoff anyway
     if (is_null($signUp)) {
         return;
     }
     $em = $this->getServiceManager()->get('Doctrine\\ORM\\EntityManager');
     $em->remove($signUp);
     $em->flush();
 }
Beispiel #2
0
 /**
  * Disapprove of an activity
  *
  * @param ActivityModel $activity
  */
 public function disapprove(ActivityModel $activity)
 {
     $activity->setStatus(ActivityModel::STATUS_DISAPPROVED);
     $em = $this->getServiceManager()->get('Doctrine\\ORM\\EntityManager');
     $em->persist($activity);
     $em->flush();
 }
 /**
  * Create an activity translation of the specified language
  *
  * @param ActivityModel $activity
  * @param type $language
  * @return \Activity\Model\ActivityTranslation
  */
 protected function createActivityTranslation(ActivityModel $activity, $language)
 {
     $activityTranslation = new ActivityTranslationModel();
     //Populate the common-language parts
     $activityTranslation->setId($activity->getId());
     $activityTranslation->setBeginTime($activity->getBeginTime());
     $activityTranslation->setEndTime($activity->getEndTime());
     $activityTranslation->setCanSignUp($activity->getCanSignUp());
     $activityTranslation->setOnlyGEWIS($activity->getOnlyGEWIS());
     $activityTranslation->setApprover($activity->getApprover());
     $activityTranslation->setCreator($activity->getCreator());
     $activityTranslation->setStatus($activity->getStatus());
     $activityTranslation->setSignUps($activity->getSignUps());
     $activityTranslation->setSubscriptionDeadline($activity->getSubscriptionDeadline());
     //TODO: add organ when relevant.
     if ($language === 'en') {
         $activityTranslation->setName($activity->getNameEn());
         $activityTranslation->setLocation($activity->getLocationEn());
         $activityTranslation->setCosts($activity->getCostsEn());
         $activityTranslation->setDescription($activity->getDescriptionEn());
     }
     if ($language === 'nl') {
         $activityTranslation->setName($activity->getName());
         $activityTranslation->setLocation($activity->getLocation());
         $activityTranslation->setCosts($activity->getCosts());
         $activityTranslation->setDescription($activity->getDescription());
     }
     $fieldTranslations = [];
     foreach ($activity->getFields() as $field) {
         $fieldTranslations[] = $this->createActivityFieldTranslation($field, $language);
     }
     $activityTranslation->setFields($fieldTranslations);
     return $activityTranslation;
 }
Beispiel #4
0
 /**
  * Undo an activity sign up.
  *
  * @param ActivityModel $activity
  * @param Member        $user
  */
 public function signOff(ActivityModel $activity, Member $user)
 {
     if (!$this->isAllowed('signoff', 'activitySignup')) {
         $translator = $this->getTranslator();
         throw new \User\Permissions\NotAllowedException($translator->translate('You need to be logged in to sign off for this activity'));
     }
     $signUpMapper = $this->getServiceManager()->get('activity_mapper_signup');
     $signUp = $signUpMapper->getSignUp($activity->getId(), $user->getLidnr());
     // If the user was not signed up, no need to signoff anyway
     if (is_null($signUp)) {
         return;
     }
     $em = $this->getServiceManager()->get('Doctrine\\ORM\\EntityManager');
     $values = $this->getActivityFieldValueMapper()->getFieldValuesBySignup($signUp);
     foreach ($values as $value) {
         $em->remove($value);
     }
     $em->remove($signUp);
     $em->flush();
 }
Beispiel #5
0
 /**
  * Disapprove of an activity
  *
  * @param ActivityModel $activity
  */
 public function disapprove(ActivityModel $activity)
 {
     if (!$this->isAllowed('disapprove', 'model')) {
         $translator = $this->getTranslator();
         throw new \User\Permissions\NotAllowedException($translator->translate('You are not allowed to change the status of the activity'));
     }
     $activity->setStatus(ActivityModel::STATUS_DISAPPROVED);
     $em = $this->getServiceManager()->get('Doctrine\\ORM\\EntityManager');
     $em->persist($activity);
     $em->flush();
 }
Beispiel #6
0
 /**
  * Get an array that states whether a language is available for
  * the provided $activity
  *
  * @param ActivityModel $activity
  * @return string
  */
 public function getAvailableLanguages($activity)
 {
     return ['nl' => !is_null($activity->getName()), 'en' => !is_null($activity->getNameEn())];
 }