Ejemplo n.º 1
0
 /**
  * Shows a modalbox containing a form for editing an existing target group
  * record.
  *
  * @param tx_ameosformidable $formidable the FORMidable object
  * @param int $targetGroupUid
  *        the UID of the target group to edit, must be > 0
  *
  * @return array calls to be executed on the client
  */
 public static function showEditTargetGroupModalBox(tx_ameosformidable $formidable, $targetGroupUid)
 {
     if ($targetGroupUid <= 0) {
         return $formidable->majixExecJs('alert("$targetGroupUid must be >= 0.");');
     }
     /** @var tx_seminars_Mapper_TargetGroup $targetGroupMapper */
     $targetGroupMapper = tx_oelib_MapperRegistry::get('tx_seminars_Mapper_TargetGroup');
     try {
         /** @var tx_seminars_Model_TargetGroup $targetGroup */
         $targetGroup = $targetGroupMapper->find((int) $targetGroupUid);
     } catch (tx_oelib_Exception_NotFound $exception) {
         return $formidable->majixExecJs('alert("A target group with the given UID does not exist.");');
     }
     $frontEndUser = self::getLoggedInUser();
     if ($targetGroup->getOwner() !== $frontEndUser) {
         return $formidable->majixExecJs('alert("You are not allowed to edit this target group.");');
     }
     $minimumAge = $targetGroup->getMinimumAge() > 0 ? $targetGroup->getMinimumAge() : '';
     $maximumAge = $targetGroup->getMaximumAge() > 0 ? $targetGroup->getMaximumAge() : '';
     $fields = array('uid' => $targetGroup->getUid(), 'title' => $targetGroup->getTitle(), 'minimum_age' => $minimumAge, 'maximum_age' => $maximumAge);
     foreach ($fields as $key => $value) {
         $formidable->aORenderlets['editTargetGroup_' . $key]->setValue($value);
     }
     $formidable->oRenderer->_setDisplayLabels(TRUE);
     $result = $formidable->aORenderlets['editTargetGroupModalBox']->majixShowBox();
     $formidable->oRenderer->_setDisplayLabels(FALSE);
     return $result;
 }