/** * @return array<list_Item> */ public final function getItems() { try { $request = Controller::getInstance()->getContext()->getRequest(); $questionId = intval($request->getParameter('questionId', 0)); $question = DocumentHelper::getDocumentInstance($questionId); } catch (Exception $e) { if (Framework::isDebugEnabled()) { Framework::debug(__METHOD__ . ' EXCEPTION: ' . $e->getMessage()); } return array(); } // Here we must use instanceof and not getDocumentModelName to work with injection. $results = array(); if ($question instanceof form_persistentdocument_boolean) { $trueLabel = $question->getTruelabel(); $falseLabel = $question->getFalselabel(); $results[$trueLabel] = new list_Item($trueLabel, $trueLabel); $results[$falseLabel] = new list_Item($falseLabel, $falseLabel); } else { if ($question instanceof form_persistentdocument_list) { $results = $question->getDataSource()->getItems(); } } return $results; }
/** * @param form_persistentdocument_field $document * @param Integer $parentNodeId Parent node ID where to save the document (optionnal). * @return void */ protected function preSave($document, $parentNodeId = null) { $fieldName = $document->getFieldName(); if (f_util_StringUtils::isEmpty($fieldName)) { $this->fieldNameCounter = $this->fieldNameCounter + 1; $fieldName = 'f' . time() . $this->fieldNameCounter; if (Framework::isDebugEnabled()) { Framework::debug(__METHOD__ . ' Generate FieldName: ' . $fieldName . ' for document ' . $document->__toString()); } $document->setFieldName($fieldName); } $parentDoc = $parentNodeId != null ? DocumentHelper::getDocumentInstance($parentNodeId) : $this->getParentOf($document); form_BaseformService::getInstance()->checkFieldNameAvailable($document, $parentDoc->getId()); $this->fixRequiredConstraint($document); }
/** * @param form_persistentdocument_baseform $form * @param form_persistentdocument_response $response * @param block_BlockRequest $request * @param array $result * @param String $acknowledgmentReceiver * @param String $replyTo * @return void */ protected function sendAcknowledgement($form, $response, $request, $result, $acknowledgmentReceiver, $replyTo) { $recipients = new mail_MessageRecipients(); $recipients->setTo(array($acknowledgmentReceiver)); $parameters = $this->getAcknowledgementNotificationParameters($form, $response, $request, $result, $acknowledgmentReceiver, $replyTo); if (Framework::isDebugEnabled()) { Framework::debug(__METHOD__ . " Form \"" . $form->getLabel() . "\" (id=" . $form->getId() . ")"); Framework::debug(__METHOD__ . " Parameters: " . var_export($parameters, true)); Framework::debug(__METHOD__ . " To : " . join(", ", $recipients->getTo())); Framework::debug(__METHOD__ . " ReplyTo : " . $replyTo); } $ns = notification_NotificationService::getInstance(); $ns->setMessageService(MailService::getInstance()); $notification = $form->getAcknowledgmentNotification(); $senderEmail = $this->getOverrideNotificationSender($form); return $ns->send($notification, $recipients, $parameters, 'form', $replyTo, $senderEmail); }
/** * @param form_persistentdocument_form $form * @param form_persistentdocument_response $response * @param block_BlockRequest $request * @param String $copyMail * @param String $replyTo * @return void */ private function sendEmail($form, $response, $request, $copyMail, $replyTo) { $recipients = new mail_MessageRecipients(); if ($request->hasParameter('receiverIds')) { $this->handleReceveirIds($request->getParameter('receiverIds'), $recipients); } // Determine the message recipients for this form. // Note that the following method may be overriden to allow the developper // to build specific mail recipients, depending on the request data for // example. $this->buildMessageRecipients($form, $recipients, $request); if (!$recipients->isEmpty()) { if ($form->getMessageSendingType() == self::SEND_EMAIL_AND_APPEND_TO_MAILBOX) { $messageService = mailbox_MessageService::getInstance(); Framework::debug(__METHOD__ . " Getting mailbox_MessageService instance."); } else { $messageService = MailService::getInstance(); Framework::debug(__METHOD__ . " Getting MailService instance."); } $contentTemplate = TemplateLoader::getInstance()->setPackageName('modules_form')->setMimeContentType(K::HTML)->load('Form-MailContent'); $contentTemplate->setAttribute('items', $response->getAllData()); $contentTemplate->setAttribute('response', $response->getResponseInfos()); $parameters = $response->getData(); $parameters[self::CONTENT_REPLACEMENT_NAME] = $contentTemplate->execute(); $parameters[self::FORM_LABEL_REPLACEMENT_NAME] = $form->getLabel(); if (Framework::isDebugEnabled()) { Framework::debug(__METHOD__ . " Form \"" . $form->getLabel() . "\" (id=" . $form->getId() . ")"); Framework::debug(__METHOD__ . " Parameters: " . var_export($parameters, true)); if ($recipients->hasTo()) { Framework::debug(__METHOD__ . " To : " . join(", ", $recipients->getTo())); } if ($recipients->hasBCC()) { Framework::debug(__METHOD__ . " CC : " . join(", ", $recipients->getCC())); } if ($recipients->hasBCC()) { Framework::debug(__METHOD__ . " BCC : " . join(", ", $recipients->getBcc())); } Framework::debug(__METHOD__ . " ReplyTo : " . $replyTo); } $ns = notification_NotificationService::getInstance(); $ns->setMessageService($messageService); if ($copyMail === null) { return $ns->send($form->getNotification(), $recipients, $parameters, 'form', $replyTo, $this->getOverrideNotificationSender($form)); } else { $copyRecipient = new mail_MessageRecipients(); $copyRecipient->setTo(array($copyMail)); $notification = $form->getNotification(); $sender = $this->getOverrideNotificationSender($form); return $ns->send($notification, $recipients, $parameters, 'form', $replyTo, $sender) && $ns->send($notification, $copyRecipient, $parameters, 'form', $replyTo, $sender); } } return true; }