/** * Create a panel (for authenticated user) * * @param Panel $newPanel * @return string */ public function createAction(Panel $newPanel) { if ($communityUser = $this->getLoggedInUser()) { do { $panelId = Algorithms::generateRandomString(4, 'ABCDEFGHJKMNPQRSTUVWXYZ123456789'); } while ($this->panelRepository->findOneByPanelId($panelId) instanceof Panel); $newPanel->setPanelId($panelId); $newPanel->setCommunityUser($communityUser); $this->panelRepository->add($newPanel); $this->persistenceManager->persistAll(); $message = LocalizationUtility::translate('panel.actions.create.success', $this->request->getControllerExtensionName(), array($newPanel->getTitle())); $message .= '<script>EasyvoteEducation.openPanel(' . $newPanel->getUid() . ');</script>'; $this->addFlashMessage($message, '', AbstractMessage::OK); return json_encode(array('redirectToAction' => 'managePanels')); } else { $reason = LocalizationUtility::translate('ajax.status.403', 'easyvote_education'); $reason .= '<br />PanelController/createAction'; return json_encode(array('status' => 403, 'reason' => $reason)); } }