示例#1
0
 /**
  * Validation of given Mail Params
  *
  * @param \In2code\Powermail\Domain\Model\Mail $mail
  * @return bool
  */
 public function isValid($mail)
 {
     foreach ($mail->getAnswers() as $answer) {
         if ($answer->getValueType() === 3) {
             if (!is_array($answer->getValue())) {
                 continue;
             }
             foreach ($answer->getValue() as $value) {
                 if (!BasicFileFunctions::checkExtension($value, $this->settings['misc.']['file.']['extension'])) {
                     $this->setErrorAndMessage($answer->getField(), 'upload_extension');
                     continue;
                 }
                 if (!BasicFileFunctions::checkFilesize($value, $this->settings)) {
                     $this->setErrorAndMessage($answer->getField(), 'upload_size');
                     continue;
                 }
             }
         }
     }
     return $this->getIsValid();
 }
示例#2
0
 /**
  * Remove unused uploaded Files
  * 		with a scheduler task
  *
  * @param string $uploadPath Define the upload Path
  * @return void
  */
 public function cleanUnusedUploadsCommand($uploadPath = 'uploads/tx_powermail/')
 {
     /**
      * Open on Command Line with
      * php cli_dispatch.phpsh extbase task:cleanunuseduploads
      * Needs BE-User _cli_lowlevel
      */
     $usedUploads = $this->getUsedUploads();
     $allUploads = BasicFileFunctions::getFilesFromRelativePath($uploadPath);
     $removeCounter = 0;
     foreach ($allUploads as $upload) {
         if (!in_array($upload, $usedUploads)) {
             $absoluteFilePath = GeneralUtility::getFileAbsFileName($uploadPath . $upload);
             if (filemtime($absoluteFilePath) < time() - $this->delta) {
                 unlink($absoluteFilePath);
                 $removeCounter++;
             }
         }
     }
     $this->outputLine('Overall Files: ' . count($allUploads));
     $this->outputLine('Removed Files: ' . $removeCounter);
 }
示例#3
0
 /**
  * Show Confirmation message after submit (if view is activated)
  *
  * @param \In2code\Powermail\Domain\Model\Mail $mail
  * @validate $mail In2code\Powermail\Domain\Validator\UploadValidator
  * @validate $mail In2code\Powermail\Domain\Validator\InputValidator
  * @validate $mail In2code\Powermail\Domain\Validator\PasswordValidator
  * @validate $mail In2code\Powermail\Domain\Validator\CaptchaValidator
  * @validate $mail In2code\Powermail\Domain\Validator\SpamShieldValidator
  * @validate $mail In2code\Powermail\Domain\Validator\CustomValidator
  * @required $mail
  * @return void
  */
 public function confirmationAction(Mail $mail)
 {
     $this->ignoreWrongForm($mail);
     BasicFileFunctions::fileUpload($this->settings['misc']['file']['folder'], $this->settings['misc']['file']['extension'], $mail);
     $this->signalSlotDispatcher->dispatch(__CLASS__, __FUNCTION__ . 'BeforeRenderView', array($mail, $this));
     $this->showThx($mail);
 }
示例#4
0
 /**
  * Reformat array for createAction
  *
  * @return void
  */
 protected function reformatParamsForAction()
 {
     $arguments = $this->request->getArguments();
     if (!isset($arguments['field'])) {
         return;
     }
     $newArguments = array('mail' => $arguments['mail']);
     // allow subvalues in new property mapper
     $mailMvcArgument = $this->arguments->getArgument('mail');
     $propertyMappingConfiguration = $mailMvcArgument->getPropertyMappingConfiguration();
     $propertyMappingConfiguration->allowProperties('answers');
     $propertyMappingConfiguration->allowCreationForSubProperty('answers');
     $propertyMappingConfiguration->allowModificationForSubProperty('answers');
     $propertyMappingConfiguration->allowProperties('form');
     $propertyMappingConfiguration->allowCreationForSubProperty('form');
     $propertyMappingConfiguration->allowModificationForSubProperty('form');
     // allow creation of new objects (for validation)
     $propertyMappingConfiguration->setTypeConverterOptions('TYPO3\\CMS\\Extbase\\Property\\TypeConverter\\PersistentObjectConverter', array(PersistentObjectConverter::CONFIGURATION_CREATION_ALLOWED => TRUE, PersistentObjectConverter::CONFIGURATION_MODIFICATION_ALLOWED => TRUE));
     $i = 0;
     foreach ((array) $arguments['field'] as $marker => $value) {
         // ignore internal fields (honeypod)
         if (substr($marker, 0, 2) === '__') {
             continue;
         }
         $fieldUid = $this->div->getFieldUidFromMarker($marker, $arguments['mail']['form']);
         // Skip fields without Uid (secondary password, upload)
         if ($fieldUid === 0) {
             continue;
         }
         // allow subvalues in new property mapper
         $propertyMappingConfiguration->forProperty('answers')->allowProperties($i);
         $propertyMappingConfiguration->forProperty('answers.' . $i)->allowAllProperties();
         $propertyMappingConfiguration->allowCreationForSubProperty('answers.' . $i);
         $propertyMappingConfiguration->allowModificationForSubProperty('answers.' . $i);
         $valueType = Div::getDataTypeFromFieldType($this->div->getFieldTypeFromMarker($marker, $arguments['mail']['form']));
         if ($valueType === 3 && is_array($value)) {
             $value = BasicFileFunctions::getUniqueNamesForFileUploads($value, $this->settings, FALSE);
         }
         if (is_array($value)) {
             if (empty($value)) {
                 $value = '';
             } else {
                 $value = json_encode($value);
             }
         }
         $newArguments['mail']['answers'][$i] = array('field' => strval($fieldUid), 'value' => $value, 'valueType' => $valueType);
         // edit form: add answer id
         if (!empty($arguments['field']['__identity'])) {
             $newArguments['mail']['answers'][$i]['__identity'] = $this->answerRepository->findByFieldAndMail($fieldUid, $arguments['field']['__identity'])->getUid();
         }
         $i++;
     }
     // edit form: add mail id
     if (!empty($arguments['field']['__identity'])) {
         $newArguments['mail']['__identity'] = $arguments['field']['__identity'];
     }
     $this->request->setArguments($newArguments);
     $this->request->setArgument('field', NULL);
 }