Exemplo n.º 1
0
    /**
     * Recursively look for children for page version with $pid
     *
     * @param int $pid UID of page record for which to look up sub-elements following that version
     * @param int $c Counter, do not set (limits to 100 levels)
     * @return string Table with content if any
     */
    public function pageSubContent($pid, $c = 0)
    {
        $tableNames = ArrayUtility::removeArrayEntryByValue(array_keys($GLOBALS['TCA']), 'pages');
        $tableNames[] = 'pages';
        $content = '';
        foreach ($tableNames as $table) {
            // Basically list ALL tables - not only those being copied might be found!
            $mres = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', $table, 'pid=' . (int) $pid . BackendUtility::deleteClause($table), '', $GLOBALS['TCA'][$table]['ctrl']['sortby'] ? $GLOBALS['TCA'][$table]['ctrl']['sortby'] : '');
            if ($GLOBALS['TYPO3_DB']->sql_num_rows($mres)) {
                $content .= '
					<table class="table">
						<tr>
							<th class="col-icon">' . $this->moduleTemplate->getIconFactory()->getIconForRecord($table, array(), Icon::SIZE_SMALL)->render() . '</th>
							<th class="col-title">' . $GLOBALS['LANG']->sL($GLOBALS['TCA'][$table]['ctrl']['title'], true) . '</th>
							<th></th>
							<th></th>
						</tr>';
                while ($subrow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($mres)) {
                    $ownVer = $this->lookForOwnVersions($table, $subrow['uid']);
                    $content .= '
						<tr>
							<td class="col-icon">' . $this->moduleTemplate->getIconFactory()->getIconForRecord($table, $subrow, Icon::SIZE_SMALL)->render() . '</td>
							<td class="col-title">' . htmlspecialchars(BackendUtility::getRecordTitle($table, $subrow, true)) . '</td>
							<td>' . ($ownVer > 1 ? '<a href="' . htmlspecialchars(BackendUtility::getModuleUrl('web_txversionM1', array('table' => $table, 'uid' => $subrow['uid']))) . '">' . ($ownVer - 1) . '</a>' : '') . '</td>
							<td class="col-control">' . $this->adminLinks($table, $subrow) . '</td>
						</tr>';
                    if ($table == 'pages' && $c < 100) {
                        $sub = $this->pageSubContent($subrow['uid'], $c + 1);
                        if ($sub) {
                            $content .= '
								<tr>
									<td></td>
									<td></td>
									<td></td>
									<td width="98%">' . $sub . '</td>
								</tr>';
                        }
                    }
                }
                $content .= '</table>';
            }
            $GLOBALS['TYPO3_DB']->sql_free_result($mres);
        }
        return $content;
    }
Exemplo n.º 2
0
 /**
  * Removes the value $cmpValue from the $array if found there. Returns the modified array
  *
  * @param array $array Array containing the values
  * @param string $cmpValue Value to search for and if found remove array entry where found.
  * @return array Output array with entries removed if search string is found
  * @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8  - use ArrayUtility::removeArrayEntryByValue() instead
  */
 public static function removeArrayEntryByValue(array $array, $cmpValue)
 {
     static::logDeprecatedFunction();
     return ArrayUtility::removeArrayEntryByValue($array, $cmpValue);
 }
Exemplo n.º 3
0
 /**
  * Handling files for group/select function
  *
  * @param array $valueArray Array of incoming file references. Keys are numeric, values are files (basically, this is the exploded list of incoming files)
  * @param array $tcaFieldConf Configuration array from TCA of the field
  * @param string $curValue Current value of the field
  * @param array $uploadedFileArray Array of uploaded files, if any
  * @param string $status 'update' or 'new' flag
  * @param string $table tablename of record
  * @param int $id UID of record
  * @param string $recFID Field identifier [table:uid:field] for flexforms
  * @return array Modified value array
  *
  * @throws \RuntimeException
  * @see checkValue_group_select()
  */
 public function checkValue_group_select_file($valueArray, $tcaFieldConf, $curValue, $uploadedFileArray, $status, $table, $id, $recFID)
 {
     // If file handling should NOT be bypassed, do processing:
     if (!$this->bypassFileHandling) {
         // If any files are uploaded, add them to value array
         // Numeric index means that there are multiple files
         if (isset($uploadedFileArray[0])) {
             $uploadedFiles = $uploadedFileArray;
         } else {
             // There is only one file
             $uploadedFiles = array($uploadedFileArray);
         }
         foreach ($uploadedFiles as $uploadedFileArray) {
             if (!empty($uploadedFileArray['name']) && $uploadedFileArray['tmp_name'] !== 'none') {
                 $valueArray[] = $uploadedFileArray['tmp_name'];
                 $this->alternativeFileName[$uploadedFileArray['tmp_name']] = $uploadedFileArray['name'];
             }
         }
         // Creating fileFunc object.
         if (!$this->fileFunc) {
             $this->fileFunc = GeneralUtility::makeInstance(BasicFileUtility::class);
             $this->include_filefunctions = 1;
         }
         // Setting permitted extensions.
         $all_files = array();
         $all_files['webspace']['allow'] = $tcaFieldConf['allowed'];
         $all_files['webspace']['deny'] = $tcaFieldConf['disallowed'] ?: '*';
         $all_files['ftpspace'] = $all_files['webspace'];
         $this->fileFunc->init('', $all_files);
     }
     // If there is an upload folder defined:
     if ($tcaFieldConf['uploadfolder'] && $tcaFieldConf['internal_type'] == 'file') {
         $currentFilesForHistory = null;
         // If filehandling should NOT be bypassed, do processing:
         if (!$this->bypassFileHandling) {
             // For logging..
             $propArr = $this->getRecordProperties($table, $id);
             // Get destrination path:
             $dest = $this->destPathFromUploadFolder($tcaFieldConf['uploadfolder']);
             // If we are updating:
             if ($status == 'update') {
                 // Traverse the input values and convert to absolute filenames in case the update happens to an autoVersionized record.
                 // Background: This is a horrible workaround! The problem is that when a record is auto-versionized the files of the record get copied and therefore get new names which is overridden with the names from the original record in the incoming data meaning both lost files and double-references!
                 // The only solution I could come up with (except removing support for managing files when autoversioning) was to convert all relative files to absolute names so they are copied again (and existing files deleted). This should keep references intact but means that some files are copied, then deleted after being copied _again_.
                 // Actually, the same problem applies to database references in case auto-versioning would include sub-records since in such a case references are remapped - and they would be overridden due to the same principle then.
                 // Illustration of the problem comes here:
                 // We have a record 123 with a file logo.gif. We open and edit the files header in a workspace. So a new version is automatically made.
                 // The versions uid is 456 and the file is copied to "logo_01.gif". But the form data that we sent was based on uid 123 and hence contains the filename "logo.gif" from the original.
                 // The file management code below will do two things: First it will blindly accept "logo.gif" as a file attached to the record (thus creating a double reference) and secondly it will find that "logo_01.gif" was not in the incoming filelist and therefore should be deleted.
                 // If we prefix the incoming file "logo.gif" with its absolute path it will be seen as a new file added. Thus it will be copied to "logo_02.gif". "logo_01.gif" will still be deleted but since the files are the same the difference is zero - only more processing and file copying for no reason. But it will work.
                 if ($this->autoVersioningUpdate === true) {
                     foreach ($valueArray as $key => $theFile) {
                         // If it is an already attached file...
                         if ($theFile === basename($theFile)) {
                             $valueArray[$key] = PATH_site . $tcaFieldConf['uploadfolder'] . '/' . $theFile;
                         }
                     }
                 }
                 // Finding the CURRENT files listed, either from MM or from the current record.
                 $theFileValues = array();
                 // If MM relations for the files also!
                 if ($tcaFieldConf['MM']) {
                     $dbAnalysis = $this->createRelationHandlerInstance();
                     /** @var $dbAnalysis RelationHandler */
                     $dbAnalysis->start('', 'files', $tcaFieldConf['MM'], $id);
                     foreach ($dbAnalysis->itemArray as $item) {
                         if ($item['id']) {
                             $theFileValues[] = $item['id'];
                         }
                     }
                 } else {
                     $theFileValues = GeneralUtility::trimExplode(',', $curValue, true);
                 }
                 $currentFilesForHistory = implode(',', $theFileValues);
                 // DELETE files: If existing files were found, traverse those and register files for deletion which has been removed:
                 if (!empty($theFileValues)) {
                     // Traverse the input values and for all input values which match an EXISTING value, remove the existing from $theFileValues array (this will result in an array of all the existing files which should be deleted!)
                     foreach ($valueArray as $key => $theFile) {
                         if ($theFile && !strstr(GeneralUtility::fixWindowsFilePath($theFile), '/')) {
                             $theFileValues = ArrayUtility::removeArrayEntryByValue($theFileValues, $theFile);
                         }
                     }
                     // This array contains the filenames in the uploadfolder that should be deleted:
                     foreach ($theFileValues as $key => $theFile) {
                         $theFile = trim($theFile);
                         if (@is_file($dest . '/' . $theFile)) {
                             $this->removeFilesStore[] = $dest . '/' . $theFile;
                         } elseif ($this->enableLogging && $theFile) {
                             $this->log($table, $id, 5, 0, 1, 'Could not delete file \'%s\' (does not exist). (%s)', 10, array($dest . '/' . $theFile, $recFID), $propArr['event_pid']);
                         }
                     }
                 }
             }
             // Traverse the submitted values:
             foreach ($valueArray as $key => $theFile) {
                 // Init:
                 $maxSize = (int) $tcaFieldConf['max_size'];
                 // Must be cleared. Else a faulty fileref may be inserted if the below code returns an error!
                 $theDestFile = '';
                 // a FAL file was added, now resolve the file object and get the absolute path
                 // @todo in future versions this needs to be modified to handle FAL objects natively
                 if (!empty($theFile) && MathUtility::canBeInterpretedAsInteger($theFile)) {
                     $fileObject = ResourceFactory::getInstance()->getFileObject($theFile);
                     $theFile = $fileObject->getForLocalProcessing(false);
                 }
                 // NEW FILES? If the value contains '/' it indicates, that the file
                 // is new and should be added to the uploadsdir (whether its absolute or relative does not matter here)
                 if (strstr(GeneralUtility::fixWindowsFilePath($theFile), '/')) {
                     // Check various things before copying file:
                     // File and destination must exist
                     if (@is_dir($dest) && (@is_file($theFile) || @is_uploaded_file($theFile))) {
                         // Finding size.
                         if (is_uploaded_file($theFile) && $theFile == $uploadedFileArray['tmp_name']) {
                             $fileSize = $uploadedFileArray['size'];
                         } else {
                             $fileSize = filesize($theFile);
                         }
                         // Check file size:
                         if (!$maxSize || $fileSize <= $maxSize * 1024) {
                             // Prepare filename:
                             $theEndFileName = isset($this->alternativeFileName[$theFile]) ? $this->alternativeFileName[$theFile] : $theFile;
                             $fI = GeneralUtility::split_fileref($theEndFileName);
                             // Check for allowed extension:
                             if ($this->fileFunc->checkIfAllowed($fI['fileext'], $dest, $theEndFileName)) {
                                 $theDestFile = $this->fileFunc->getUniqueName($this->fileFunc->cleanFileName($fI['file']), $dest);
                                 // If we have a unique destination filename, then write the file:
                                 if ($theDestFile) {
                                     GeneralUtility::upload_copy_move($theFile, $theDestFile);
                                     // Hook for post-processing the upload action
                                     if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processUpload'])) {
                                         foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processUpload'] as $classRef) {
                                             $hookObject = GeneralUtility::getUserObj($classRef);
                                             if (!$hookObject instanceof DataHandlerProcessUploadHookInterface) {
                                                 throw new \UnexpectedValueException('$hookObject must implement interface TYPO3\\CMS\\Core\\DataHandling\\DataHandlerProcessUploadHookInterface', 1279962349);
                                             }
                                             $hookObject->processUpload_postProcessAction($theDestFile, $this);
                                         }
                                     }
                                     $this->copiedFileMap[$theFile] = $theDestFile;
                                     clearstatcache();
                                     if ($this->enableLogging && !@is_file($theDestFile)) {
                                         $this->log($table, $id, 5, 0, 1, 'Copying file \'%s\' failed!: The destination path (%s) may be write protected. Please make it write enabled!. (%s)', 16, array($theFile, dirname($theDestFile), $recFID), $propArr['event_pid']);
                                     }
                                 } elseif ($this->enableLogging) {
                                     $this->log($table, $id, 5, 0, 1, 'Copying file \'%s\' failed!: No destination file (%s) possible!. (%s)', 11, array($theFile, $theDestFile, $recFID), $propArr['event_pid']);
                                 }
                             } elseif ($this->enableLogging) {
                                 $this->log($table, $id, 5, 0, 1, 'File extension \'%s\' not allowed. (%s)', 12, array($fI['fileext'], $recFID), $propArr['event_pid']);
                             }
                         } elseif ($this->enableLogging) {
                             $this->log($table, $id, 5, 0, 1, 'Filesize (%s) of file \'%s\' exceeds limit (%s). (%s)', 13, array(GeneralUtility::formatSize($fileSize), $theFile, GeneralUtility::formatSize($maxSize * 1024), $recFID), $propArr['event_pid']);
                         }
                     } elseif ($this->enableLogging) {
                         $this->log($table, $id, 5, 0, 1, 'The destination (%s) or the source file (%s) does not exist. (%s)', 14, array($dest, $theFile, $recFID), $propArr['event_pid']);
                     }
                     // If the destination file was created, we will set the new filename in the value array, otherwise unset the entry in the value array!
                     if (@is_file($theDestFile)) {
                         $info = GeneralUtility::split_fileref($theDestFile);
                         // The value is set to the new filename
                         $valueArray[$key] = $info['file'];
                     } else {
                         // The value is set to the new filename
                         unset($valueArray[$key]);
                     }
                 }
             }
         }
         // If MM relations for the files, we will set the relations as MM records and change the valuearray to contain a single entry with a count of the number of files!
         if ($tcaFieldConf['MM']) {
             /** @var $dbAnalysis RelationHandler */
             $dbAnalysis = $this->createRelationHandlerInstance();
             // Dummy
             $dbAnalysis->tableArray['files'] = array();
             foreach ($valueArray as $key => $theFile) {
                 // Explode files
                 $dbAnalysis->itemArray[]['id'] = $theFile;
             }
             if ($status == 'update') {
                 $dbAnalysis->writeMM($tcaFieldConf['MM'], $id, 0);
                 $newFiles = implode(',', $dbAnalysis->getValueArray());
                 list(, , $recFieldName) = explode(':', $recFID);
                 if ($currentFilesForHistory != $newFiles) {
                     $this->mmHistoryRecords[$table . ':' . $id]['oldRecord'][$recFieldName] = $currentFilesForHistory;
                     $this->mmHistoryRecords[$table . ':' . $id]['newRecord'][$recFieldName] = $newFiles;
                 } else {
                     $this->mmHistoryRecords[$table . ':' . $id]['oldRecord'][$recFieldName] = '';
                     $this->mmHistoryRecords[$table . ':' . $id]['newRecord'][$recFieldName] = '';
                 }
             } else {
                 $this->dbAnalysisStore[] = array($dbAnalysis, $tcaFieldConf['MM'], $id, 0);
             }
             $valueArray = $dbAnalysis->countItems();
         }
     } else {
         if (!empty($valueArray)) {
             // If filehandling should NOT be bypassed, do processing:
             if (!$this->bypassFileHandling) {
                 // For logging..
                 $propArr = $this->getRecordProperties($table, $id);
                 foreach ($valueArray as &$theFile) {
                     // FAL handling: it's a UID, thus it is resolved to the absolute path
                     if (!empty($theFile) && MathUtility::canBeInterpretedAsInteger($theFile)) {
                         $fileObject = ResourceFactory::getInstance()->getFileObject($theFile);
                         $theFile = $fileObject->getForLocalProcessing(false);
                     }
                     if ($this->alternativeFilePath[$theFile]) {
                         // If alternative File Path is set for the file, then it was an import
                         // don't import the file if it already exists
                         if (@is_file(PATH_site . $this->alternativeFilePath[$theFile])) {
                             $theFile = PATH_site . $this->alternativeFilePath[$theFile];
                         } elseif (@is_file($theFile)) {
                             $dest = dirname(PATH_site . $this->alternativeFilePath[$theFile]);
                             if (!@is_dir($dest)) {
                                 GeneralUtility::mkdir_deep(PATH_site, dirname($this->alternativeFilePath[$theFile]) . '/');
                             }
                             // Init:
                             $maxSize = (int) $tcaFieldConf['max_size'];
                             // Must be cleared. Else a faulty fileref may be inserted if the below code returns an error!
                             $theDestFile = '';
                             $fileSize = filesize($theFile);
                             // Check file size:
                             if (!$maxSize || $fileSize <= $maxSize * 1024) {
                                 // Prepare filename:
                                 $theEndFileName = isset($this->alternativeFileName[$theFile]) ? $this->alternativeFileName[$theFile] : $theFile;
                                 $fI = GeneralUtility::split_fileref($theEndFileName);
                                 // Check for allowed extension:
                                 if ($this->fileFunc->checkIfAllowed($fI['fileext'], $dest, $theEndFileName)) {
                                     $theDestFile = PATH_site . $this->alternativeFilePath[$theFile];
                                     // Write the file:
                                     if ($theDestFile) {
                                         GeneralUtility::upload_copy_move($theFile, $theDestFile);
                                         $this->copiedFileMap[$theFile] = $theDestFile;
                                         clearstatcache();
                                         if ($this->enableLogging && !@is_file($theDestFile)) {
                                             $this->log($table, $id, 5, 0, 1, 'Copying file \'%s\' failed!: The destination path (%s) may be write protected. Please make it write enabled!. (%s)', 16, array($theFile, dirname($theDestFile), $recFID), $propArr['event_pid']);
                                         }
                                     } elseif ($this->enableLogging) {
                                         $this->log($table, $id, 5, 0, 1, 'Copying file \'%s\' failed!: No destination file (%s) possible!. (%s)', 11, array($theFile, $theDestFile, $recFID), $propArr['event_pid']);
                                     }
                                 } elseif ($this->enableLogging) {
                                     $this->log($table, $id, 5, 0, 1, 'File extension \'%s\' not allowed. (%s)', 12, array($fI['fileext'], $recFID), $propArr['event_pid']);
                                 }
                             } elseif ($this->enableLogging) {
                                 $this->log($table, $id, 5, 0, 1, 'Filesize (%s) of file \'%s\' exceeds limit (%s). (%s)', 13, array(GeneralUtility::formatSize($fileSize), $theFile, GeneralUtility::formatSize($maxSize * 1024), $recFID), $propArr['event_pid']);
                             }
                             // If the destination file was created, we will set the new filename in the value array, otherwise unset the entry in the value array!
                             if (@is_file($theDestFile)) {
                                 // The value is set to the new filename
                                 $theFile = $theDestFile;
                             } else {
                                 // The value is set to the new filename
                                 unset($theFile);
                             }
                         }
                     }
                     if (!empty($theFile)) {
                         $theFile = GeneralUtility::fixWindowsFilePath($theFile);
                         if (GeneralUtility::isFirstPartOfStr($theFile, PATH_site)) {
                             $theFile = PathUtility::stripPathSitePrefix($theFile);
                         }
                     }
                 }
                 unset($theFile);
             }
         }
     }
     return $valueArray;
 }
Exemplo n.º 4
0
    /**
     * Recursively look for children for page version with $pid
     *
     * @param int $pid UID of page record for which to look up sub-elements following that version
     * @param int $c Counter, do not set (limits to 100 levels)
     * @return string Table with content if any
     */
    public function pageSubContent($pid, $c = 0)
    {
        $tableNames = ArrayUtility::removeArrayEntryByValue(array_keys($GLOBALS['TCA']), 'pages');
        $tableNames[] = 'pages';
        $content = '';
        foreach ($tableNames as $table) {
            // Basically list ALL tables - not only those being copied might be found!
            $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($table);
            $queryBuilder->getRestrictions()->removeAll()->add(GeneralUtility::makeInstance(DeletedRestriction::class));
            $queryBuilder->select('*')->from($table)->where($queryBuilder->expr()->eq('pid', $queryBuilder->createNamedParameter($pid, \PDO::PARAM_INT)));
            if (!empty($GLOBALS['TCA'][$table]['ctrl']['sortby'])) {
                $queryBuilder->orderBy($GLOBALS['TCA'][$table]['ctrl']['sortby']);
            }
            $result = $queryBuilder->execute();
            if ($result->rowCount()) {
                $content .= '
					<table class="table">
						<tr>
							<th class="col-icon">' . $this->moduleTemplate->getIconFactory()->getIconForRecord($table, [], Icon::SIZE_SMALL)->render() . '</th>
							<th class="col-title">' . htmlspecialchars($this->getLanguageService()->sL($GLOBALS['TCA'][$table]['ctrl']['title'])) . '</th>
							<th></th>
							<th></th>
						</tr>';
                while ($subrow = $result->fetch()) {
                    $ownVer = $this->lookForOwnVersions($table, $subrow['uid']);
                    $content .= '
						<tr>
							<td class="col-icon">' . $this->moduleTemplate->getIconFactory()->getIconForRecord($table, $subrow, Icon::SIZE_SMALL)->render() . '</td>
							<td class="col-title">' . BackendUtility::getRecordTitle($table, $subrow, true) . '</td>
							<td>' . ($ownVer > 1 ? '<a href="' . htmlspecialchars(BackendUtility::getModuleUrl('web_txversionM1', ['table' => $table, 'uid' => $subrow['uid']])) . '">' . ($ownVer - 1) . '</a>' : '') . '</td>
							<td class="col-control">' . $this->adminLinks($table, $subrow) . '</td>
						</tr>';
                    if ($table == 'pages' && $c < 100) {
                        $sub = $this->pageSubContent($subrow['uid'], $c + 1);
                        if ($sub) {
                            $content .= '
								<tr>
									<td></td>
									<td></td>
									<td></td>
									<td width="98%">' . $sub . '</td>
								</tr>';
                        }
                    }
                }
                $content .= '</table>';
            }
        }
        return $content;
    }
Exemplo n.º 5
0
    /**
     * Import CSV-Data in step-by-step mode
     *
     * @return	string		HTML form
     */
    public function cmd_displayImport()
    {
        $step = GeneralUtility::_GP('importStep');
        $defaultConf = array('remove_existing' => 0, 'first_fieldname' => 0, 'valid_email' => 0, 'remove_dublette' => 0, 'update_unique' => 0);
        if (GeneralUtility::_GP('CSV_IMPORT')) {
            $importerConfig = GeneralUtility::_GP('CSV_IMPORT');
            if ($step['next'] == 'mapping') {
                $this->indata = $importerConfig + $defaultConf;
            } else {
                $this->indata = $importerConfig;
            }
        }
        if (empty($this->indata)) {
            $this->indata = array();
        }
        if (empty($this->params)) {
            $this->params = array();
        }
        // merge it with inData, but inData has priority.
        $this->indata = $this->indata + $this->params;
        //		$currentFileInfo = BasicFileUtility::getTotalFileInfo($this->indata['newFile']);
        //		$currentFileName = $currentFileInfo['file'];
        //		$currentFileSize = GeneralUtility::formatSize($currentFileInfo['size']);
        //		$currentFileMessage = $currentFileName . ' (' . $currentFileSize . ')';
        if (empty($this->indata['csv']) && !empty($_FILES['upload_1']['name'])) {
            $this->indata['newFile'] = $this->checkUpload();
            // TYPO3 6.0 returns an object...
            if (is_object($this->indata['newFile'][0])) {
                $storageConfig = $this->indata['newFile'][0]->getStorage()->getConfiguration();
                $this->indata['newFile'] = $storageConfig['basePath'] . ltrim($this->indata['newFile'][0]->getIdentifier(), '/');
            }
        } elseif (!empty($this->indata['csv']) && empty($_FILES['upload_1']['name'])) {
            if ((strpos($currentFileInfo['file'], 'import') === false ? 0 : 1) && $currentFileInfo['realFileext'] === 'txt') {
                // do nothing
            } else {
                unset($this->indata['newFile']);
            }
        }
        if ($this->indata['back']) {
            $stepCurrent = $step['back'];
        } elseif ($this->indata['next']) {
            $stepCurrent = $step['next'];
        } elseif ($this->indata['update']) {
            $stepCurrent = 'mapping';
        }
        if (strlen($this->indata['csv']) > 0) {
            $this->indata['mode'] = 'csv';
            $this->indata['newFile'] = $this->writeTempFile();
        } elseif (!empty($this->indata['newFile'])) {
            $this->indata['mode'] = 'file';
        } else {
            unset($stepCurrent);
        }
        // check if "email" is mapped
        if ($stepCurrent === 'import') {
            $map = $this->indata['map'];
            $error = array();
            // check noMap
            $newMap = ArrayUtility::removeArrayEntryByValue(array_unique($map), 'noMap');
            if (empty($newMap)) {
                $error[] = 'noMap';
            } elseif (!ArrayUtility::inArray($map, 'email')) {
                $error[] = 'email';
            }
            if ($error) {
                $stepCurrent = 'mapping';
            }
        }
        $out = "";
        switch ($stepCurrent) {
            case 'conf':
                // get list of sysfolder
                // TODO: maybe only subtree von this->id??
                $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid,title', 'pages', 'doktype = 254 AND ' . $GLOBALS['BE_USER']->getPagePermsClause(3) . BackendUtility::deleteClause('pages') . BackendUtility::BEenableFields('pages'), '', 'uid');
                $optStorage = array();
                while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
                    if (BackendUtility::readPageAccess($row['uid'], $GLOBALS['BE_USER']->getPagePermsClause(1))) {
                        $optStorage[] = array($row['uid'], $row['title'] . ' [uid:' . $row['uid'] . ']');
                    }
                }
                $GLOBALS['TYPO3_DB']->sql_free_result($res);
                $optDelimiter = array(array('comma', $this->getLanguageService()->getLL('mailgroup_import_separator_comma')), array('semicolon', $this->getLanguageService()->getLL('mailgroup_import_separator_semicolon')), array('colon', $this->getLanguageService()->getLL('mailgroup_import_separator_colon')), array('tab', $this->getLanguageService()->getLL('mailgroup_import_separator_tab')));
                $optEncap = array(array('doubleQuote', ' " '), array('singleQuote', " ' "));
                // TODO: make it variable?
                $optUnique = array(array('email', 'email'), array('name', 'name'));
                $this->params['inputDisable'] == 1 ? $disableInput = 'disabled="disabled"' : ($disableInput = '');
                // show configuration
                $out = '<hr /><h3>' . $this->getLanguageService()->getLL('mailgroup_import_header_conf') . '</h3>';
                $tblLines = array();
                // get the all sysfolder
                $tblLines[] = array($this->getLanguageService()->getLL('mailgroup_import_storage'), $this->makeDropdown('CSV_IMPORT[storage]', $optStorage, $this->indata['storage']));
                // remove existing option
                $tblLines[] = array($this->getLanguageService()->getLL('mailgroup_import_remove_existing'), '<input type="checkbox" name="CSV_IMPORT[remove_existing]" value="1"' . (!$this->indata['remove_existing'] ? '' : ' checked="checked"') . ' ' . $disableInput . '/> ');
                // first line in csv is to be ignored
                $tblLines[] = array($this->getLanguageService()->getLL('mailgroup_import_first_fieldnames'), '<input type="checkbox" name="CSV_IMPORT[first_fieldname]" value="1"' . (!$this->indata['first_fieldname'] ? '' : ' checked="checked"') . ' ' . $disableInput . '/> ');
                // csv separator
                $tblLines[] = array($this->getLanguageService()->getLL('mailgroup_import_separator'), $this->makeDropdown('CSV_IMPORT[delimiter]', $optDelimiter, $this->indata['delimiter'], $disableInput));
                // csv encapsulation
                $tblLines[] = array($this->getLanguageService()->getLL('mailgroup_import_encapsulation'), $this->makeDropdown('CSV_IMPORT[encapsulation]', $optEncap, $this->indata['encapsulation'], $disableInput));
                // import only valid email
                $tblLines[] = array($this->getLanguageService()->getLL('mailgroup_import_csv_validemail-description'), '<input type="checkbox" name="CSV_IMPORT[valid_email]" value="1"' . (!$this->indata['valid_email'] ? '' : ' checked="checked"') . ' ' . $disableInput . '/> ');
                // only import distinct records
                $tblLines[] = array($this->getLanguageService()->getLL('mailgroup_import_csv_dublette-description'), '<input type="checkbox" name="CSV_IMPORT[remove_dublette]" value="1"' . (!$this->indata['remove_dublette'] ? '' : ' checked="checked"') . ' ' . $disableInput . '/> ');
                // update the record instead renaming the new one
                $tblLines[] = array($this->getLanguageService()->getLL('mailgroup_import_update_unique'), '<input type="checkbox" name="CSV_IMPORT[update_unique]" value="1"' . (!$this->indata['update_unique'] ? '' : ' checked="checked"') . ' ' . $disableInput . '/>');
                // which field should be use to show uniqueness of the records
                $tblLines[] = array($this->getLanguageService()->getLL('mailgroup_import_record_unique'), $this->makeDropdown('CSV_IMPORT[record_unique]', $optUnique, $this->indata['record_unique'], $disableInput));
                $out .= $this->formatTable($tblLines, array('width=300', 'nowrap'), 0, array(0, 1));
                $out .= '<br /><br />';
                $out .= '<input type="submit" name="CSV_IMPORT[back]" value="' . $this->getLanguageService()->getLL('mailgroup_import_back') . '" />
						<input type="submit" name="CSV_IMPORT[next]" value="' . $this->getLanguageService()->getLL('mailgroup_import_next') . '" />' . $this->makeHidden(array('CMD' => 'displayImport', 'importStep[next]' => 'mapping', 'importStep[back]' => 'upload', 'CSV_IMPORT[newFile]' => $this->indata['newFile']));
                break;
            case 'mapping':
                // show charset selector
                $cs = array_unique(array_values($this->getLanguageService()->csConvObj->synonyms));
                $charSets = array();
                foreach ($cs as $charset) {
                    $charSets[] = array($charset, $charset);
                }
                if (!isset($this->indata['charset'])) {
                    $this->indata['charset'] = 'iso-8859-1';
                }
                $out .= '<hr /><h3>' . $this->getLanguageService()->getLL('mailgroup_import_mapping_charset') . '</h3>';
                $tblLines = array();
                $tblLines[] = array($this->getLanguageService()->getLL('mailgroup_import_mapping_charset_choose'), $this->makeDropdown('CSV_IMPORT[charset]', $charSets, $this->indata['charset']));
                $out .= $this->formatTable($tblLines, array('nowrap', 'nowrap'), 0, array(1, 1), 'border="0" cellpadding="0" cellspacing="0" class="table table-striped table-hover"');
                $out .= '<input type="submit" name="CSV_IMPORT[update]" value="' . $this->getLanguageService()->getLL('mailgroup_import_update') . '"/>';
                unset($tblLines);
                // show mapping form
                $out .= '<hr /><h3>' . $this->getLanguageService()->getLL('mailgroup_import_mapping_conf') . '</h3>';
                if ($this->indata['first_fieldname']) {
                    // read csv
                    $csvData = $this->readExampleCSV(4);
                    $csv_firstRow = $csvData[0];
                    $csvData = array_slice($csvData, 1);
                } else {
                    // read csv
                    $csvData = $this->readExampleCSV(3);
                    $fieldsAmount = count($csvData[0]);
                    $csv_firstRow = array();
                    for ($i = 0; $i < $fieldsAmount; $i++) {
                        $csv_firstRow[] = 'field_' . $i;
                    }
                }
                // read tt_address TCA
                $no_map = array('image');
                $ttAddressFields = array_keys($GLOBALS['TCA']['tt_address']['columns']);
                foreach ($no_map as $v) {
                    $ttAddressFields = ArrayUtility::removeArrayEntryByValue($ttAddressFields, $v);
                }
                $mapFields = array();
                foreach ($ttAddressFields as $map) {
                    $mapFields[] = array($map, str_replace(':', '', $this->getLanguageService()->sL($GLOBALS['TCA']['tt_address']['columns'][$map]['label'])));
                }
                // add 'no value'
                array_unshift($mapFields, array('noMap', $this->getLanguageService()->getLL('mailgroup_import_mapping_mapTo')));
                $mapFields[] = array('cats', $this->getLanguageService()->getLL('mailgroup_import_mapping_categories'));
                reset($csv_firstRow);
                reset($csvData);
                $tblLines = array();
                $tblLines[] = array($this->getLanguageService()->getLL('mailgroup_import_mapping_number'), $this->getLanguageService()->getLL('mailgroup_import_mapping_description'), $this->getLanguageService()->getLL('mailgroup_import_mapping_mapping'), $this->getLanguageService()->getLL('mailgroup_import_mapping_value'));
                for ($i = 0; $i < count($csv_firstRow); $i++) {
                    // example CSV
                    $exampleLines = array();
                    for ($j = 0; $j < count($csvData); $j++) {
                        $exampleLines[] = array($csvData[$j][$i]);
                    }
                    $tblLines[] = array($i + 1, $csv_firstRow[$i], $this->makeDropdown('CSV_IMPORT[map][' . $i . ']', $mapFields, $this->indata['map'][$i]), $this->formatTable($exampleLines, array('nowrap'), 0, array(0), 'border="0" cellpadding="0" cellspacing="0" class="table table-striped table-hover" style="width:100%; border:0px; margin:0px;"'));
                }
                if ($error) {
                    $out .= '<h3>' . $this->getLanguageService()->getLL('mailgroup_import_mapping_error') . '</h3>';
                    $out .= $this->getLanguageService()->getLL('mailgroup_import_mapping_error_detail') . '<br /><ul>';
                    foreach ($error as $errorDetail) {
                        $out .= '<li>' . $this->getLanguageService()->getLL('mailgroup_import_mapping_error_' . $errorDetail) . '</li>';
                    }
                    $out .= '</ul>';
                }
                // additional options
                $tblLinesAdd = array();
                // header
                $tblLinesAdd[] = array($this->getLanguageService()->getLL('mailgroup_import_mapping_all_html'), '<input type="checkbox" name="CSV_IMPORT[all_html]" value="1"' . (!$this->indata['all_html'] ? '' : ' checked="checked"') . '/> ');
                // get categories
                $temp = BackendUtility::getModTSconfig($this->parent->id, 'TCEFORM.sys_dmail_group.select_categories.PAGE_TSCONFIG_IDLIST');
                if (is_numeric($temp['value'])) {
                    $rowCat = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', 'sys_dmail_category', 'pid IN (' . $temp['value'] . ')' . BackendUtility::deleteClause('sys_dmail_category') . BackendUtility::BEenableFields('sys_dmail_category'));
                    if (!empty($rowCat)) {
                        $tblLinesAdd[] = array($this->getLanguageService()->getLL('mailgroup_import_mapping_cats'), '');
                        if ($this->indata['update_unique']) {
                            $tblLinesAdd[] = array($this->getLanguageService()->getLL('mailgroup_import_mapping_cats_add'), '<input type="checkbox" name="CSV_IMPORT[add_cat]" value="1"' . ($this->indata['add_cat'] ? ' checked="checked"' : '') . '/> ');
                        }
                        foreach ($rowCat as $k => $v) {
                            $tblLinesAdd[] = array('&nbsp;&nbsp;&nbsp;' . htmlspecialchars($v['category']), '<input type="checkbox" name="CSV_IMPORT[cat][' . $k . ']" value="' . $v['uid'] . '"' . ($this->indata['cat'][$k] != $v['uid'] ? '' : ' checked="checked"') . '/> ');
                        }
                    }
                }
                $out .= $this->formatTable($tblLines, array('nowrap', 'nowrap', 'nowrap', 'nowrap'), 1, array(0, 0, 1, 1), 'border="0" cellpadding="0" cellspacing="0" class="table table-striped table-hover"');
                $out .= '<br /><br />';
                // additional options
                $out .= '<hr /><h3>' . $this->getLanguageService()->getLL('mailgroup_import_mapping_conf_add') . '</h3>';
                $out .= $this->formatTable($tblLinesAdd, array('nowrap', 'nowrap'), 0, array(1, 1), 'border="0" cellpadding="0" cellspacing="0" class="table table-striped table-hover"');
                $out .= '<br /><br />';
                $out .= '<input type="submit" name="CSV_IMPORT[back]" value="' . $this->getLanguageService()->getLL('mailgroup_import_back') . '"/>
						<input type="submit" name="CSV_IMPORT[next]" value="' . $this->getLanguageService()->getLL('mailgroup_import_next') . '"/>' . $this->makeHidden(array('CMD' => 'displayImport', 'importStep[next]' => 'import', 'importStep[back]' => 'conf', 'CSV_IMPORT[newFile]' => $this->indata['newFile'], 'CSV_IMPORT[storage]' => $this->indata['storage'], 'CSV_IMPORT[remove_existing]' => $this->indata['remove_existing'], 'CSV_IMPORT[first_fieldname]' => $this->indata['first_fieldname'], 'CSV_IMPORT[delimiter]' => $this->indata['delimiter'], 'CSV_IMPORT[encapsulation]' => $this->indata['encapsulation'], 'CSV_IMPORT[valid_email]' => $this->indata['valid_email'], 'CSV_IMPORT[remove_dublette]' => $this->indata['remove_dublette'], 'CSV_IMPORT[update_unique]' => $this->indata['update_unique'], 'CSV_IMPORT[record_unique]' => $this->indata['record_unique']));
                break;
            case 'import':
                // show import messages
                $out .= '<hr /><h3>' . $this->getLanguageService()->getLL('mailgroup_import_ready_import') . '</h3>';
                $out .= $this->getLanguageService()->getLL('mailgroup_import_ready_import_label') . '<br /><br />';
                $out .= '<input type="submit" name="CSV_IMPORT[back]" value="' . $this->getLanguageService()->getLL('mailgroup_import_back') . '" />
						<input type="submit" name="CSV_IMPORT[next]" value="' . $this->getLanguageService()->getLL('mailgroup_import_import') . '" />' . $this->makeHidden(array('CMD' => 'displayImport', 'importStep[next]' => 'startImport', 'importStep[back]' => 'mapping', 'CSV_IMPORT[newFile]' => $this->indata['newFile'], 'CSV_IMPORT[storage]' => $this->indata['storage'], 'CSV_IMPORT[remove_existing]' => $this->indata['remove_existing'], 'CSV_IMPORT[first_fieldname]' => $this->indata['first_fieldname'], 'CSV_IMPORT[delimiter]' => $this->indata['delimiter'], 'CSV_IMPORT[encapsulation]' => $this->indata['encapsulation'], 'CSV_IMPORT[valid_email]' => $this->indata['valid_email'], 'CSV_IMPORT[remove_dublette]' => $this->indata['remove_dublette'], 'CSV_IMPORT[update_unique]' => $this->indata['update_unique'], 'CSV_IMPORT[record_unique]' => $this->indata['record_unique'], 'CSV_IMPORT[all_html]' => $this->indata['all_html'], 'CSV_IMPORT[add_cat]' => $this->indata['add_cat'], 'CSV_IMPORT[charset]' => $this->indata['charset']));
                $hiddenMapped = array();
                foreach ($this->indata['map'] as $fieldNr => $fieldMapped) {
                    $hiddenMapped[] = $this->makeHidden('CSV_IMPORT[map][' . $fieldNr . ']', $fieldMapped);
                }
                if (is_array($this->indata['cat'])) {
                    foreach ($this->indata['cat'] as $k => $catUid) {
                        $hiddenMapped[] = $this->makeHidden('CSV_IMPORT[cat][' . $k . ']', $catUid);
                    }
                }
                $out .= implode('', $hiddenMapped);
                break;
            case 'startImport':
                // starting import & show errors
                // read csv
                if ($this->indata['first_fieldname']) {
                    // read csv
                    $csvData = $this->readCSV();
                    $csvData = array_slice($csvData, 1);
                } else {
                    // read csv
                    $csvData = $this->readCSV();
                }
                // show not imported record and reasons,
                $result = $this->doImport($csvData);
                $out = '<hr /><h3>' . $this->getLanguageService()->getLL('mailgroup_import_done') . '</h3>';
                $defaultOrder = array('new', 'update', 'invalid_email', 'double');
                if (!empty($this->params['resultOrder'])) {
                    $resultOrder = GeneralUtility::trimExplode(',', $this->params['resultOrder']);
                } else {
                    $resultOrder = array();
                }
                $diffOrder = array_diff($defaultOrder, $resultOrder);
                $endOrder = array_merge($resultOrder, $diffOrder);
                foreach ($endOrder as $order) {
                    $tblLines = array();
                    $tblLines[] = array($this->getLanguageService()->getLL('mailgroup_import_report_' . $order));
                    if (is_array($result[$order])) {
                        foreach ($result[$order] as $k => $v) {
                            $mapKeys = array_keys($v);
                            $tblLines[] = array($k + 1, $v[$mapKeys[0]], $v['email']);
                        }
                    }
                    $out .= $this->formatTable($tblLines, array('nowrap', 'first' => 'colspan="3"'), 1, array(1));
                }
                // back button
                $out .= $this->makeHidden(array('CMD' => 'displayImport', 'importStep[back]' => 'import', 'CSV_IMPORT[newFile]' => $this->indata['newFile'], 'CSV_IMPORT[storage]' => $this->indata['storage'], 'CSV_IMPORT[remove_existing]' => $this->indata['remove_existing'], 'CSV_IMPORT[first_fieldname]' => $this->indata['first_fieldname'], 'CSV_IMPORT[delimiter]' => $this->indata['delimiter'], 'CSV_IMPORT[encapsulation]' => $this->indata['encapsulation'], 'CSV_IMPORT[valid_email]' => $this->indata['valid_email'], 'CSV_IMPORT[remove_dublette]' => $this->indata['remove_dublette'], 'CSV_IMPORT[update_unique]' => $this->indata['update_unique'], 'CSV_IMPORT[record_unique]' => $this->indata['record_unique'], 'CSV_IMPORT[all_html]' => $this->indata['all_html'], 'CSV_IMPORT[charset]' => $this->indata['charset']));
                $hiddenMapped = array();
                foreach ($this->indata['map'] as $fieldNr => $fieldMapped) {
                    $hiddenMapped[] = $this->makeHidden('CSV_IMPORT[map][' . $fieldNr . ']', $fieldMapped);
                }
                if (is_array($this->indata['cat'])) {
                    foreach ($this->indata['cat'] as $k => $catUid) {
                        $hiddenMapped[] = $this->makeHidden('CSV_IMPORT[cat][' . $k . ']', $catUid);
                    }
                }
                $out .= implode('', $hiddenMapped);
                break;
            case 'upload':
            default:
                // show upload file form
                $out = '<hr /><h3>' . $this->getLanguageService()->getLL('mailgroup_import_header_upload') . '</h3>';
                $tempDir = $this->userTempFolder();
                $tblLines[] = $this->getLanguageService()->getLL('mailgroup_import_upload_file') . '<input type="file" name="upload_1" size="30" />';
                if ($this->indata['mode'] == 'file' && !((strpos($currentFileInfo['file'], 'import') === false ? 0 : 1) && $currentFileInfo['realFileext'] === 'txt')) {
                    $tblLines[] = $this->getLanguageService()->getLL('mailgroup_import_current_file') . '<b>' . $currentFileMessage . '</b>';
                }
                if ((strpos($currentFileInfo['file'], 'import') === false ? 0 : 1) && $currentFileInfo['realFileext'] === 'txt') {
                    $handleCsv = fopen($this->indata['newFile'], 'r');
                    $this->indata['csv'] = fread($handleCsv, filesize($this->indata['newFile']));
                    fclose($handleCsv);
                }
                $tblLines[] = '';
                $tblLines[] = '<b>' . $this->getLanguageService()->getLL('mailgroup_import_or') . '</b>';
                $tblLines[] = '';
                $tblLines[] = $this->getLanguageService()->getLL('mailgroup_import_paste_csv');
                $tblLines[] = '<textarea name="CSV_IMPORT[csv]" rows="25" wrap="off"' . $this->parent->doc->formWidth(48) . '>' . LF . htmlspecialchars($this->indata['csv']) . '</textarea>';
                $tblLines[] = '<input type="submit" name="CSV_IMPORT[next]" value="' . $this->getLanguageService()->getLL('mailgroup_import_next') . '" />';
                $out .= implode('<br />', $tblLines);
                $out .= '<input type="hidden" name="CMD" value="displayImport" />
						<input type="hidden" name="importStep[next]" value="conf" />
						<input type="hidden" name="file[upload][1][target]" value="' . htmlspecialchars($tempDir) . '" ' . (GeneralUtility::_POST('importNow') ? 'disabled' : '') . '/>
						<input type="hidden" name="file[upload][1][data]" value="1" />
						<input type="hidden" name="CSV_IMPORT[newFile]" value ="' . $this->indata['newFile'] . '">';
        }
        $theOutput = $this->parent->doc->section($this->getLanguageService()->getLL('mailgroup_import') . BackendUtility::cshItem($this->cshTable, 'mailgroup_import', $GLOBALS['BACK_PATH']), $out, 1, 1, 0, true);
        /**
         *  Hook for cmd_displayImport
         *  use it to manipulate the steps in the import process
         */
        if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['direct_mail/mod3/class.tx_directmail_recipient_list.php']['cmd_displayImport'])) {
            $hookObjectsArr = array();
            foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['direct_mail/mod3/class.tx_directmail_recipient_list.php']['cmd_displayImport'] as $classRef) {
                $hookObjectsArr[] =& GeneralUtility::getUserObj($classRef);
            }
        }
        if (is_array($hookObjectsArr)) {
            foreach ($hookObjectsArr as $hookObj) {
                if (method_exists($hookObj, 'cmd_displayImport')) {
                    $theOutput = '';
                    $theOutput = $hookObj->cmd_displayImport($this);
                }
            }
        }
        return $theOutput;
    }
Exemplo n.º 6
0
 /**
  * Function mailModule main()
  *
  * @return	string	HTML (steps)
  */
 public function moduleContent()
 {
     $theOutput = "";
     $isExternalDirectMailRecord = false;
     $markers = array('WIZARDSTEPS' => '', 'FLASHMESSAGES' => '', 'NAVIGATION' => '', 'TITLE' => '');
     if ($this->CMD == 'delete') {
         $this->deleteDMail(intval(GeneralUtility::_GP('uid')));
     }
     $row = array();
     if (intval($this->sys_dmail_uid)) {
         $row = BackendUtility::getRecord('sys_dmail', intval($this->sys_dmail_uid));
         $isExternalDirectMailRecord = is_array($row) && $row['type'] == 1;
     }
     $hideCategoryStep = false;
     if ($GLOBALS['BE_USER']->userTS['tx_directmail.']['hideSteps'] && $GLOBALS['BE_USER']->userTS['tx_directmail.']['hideSteps'] == 'cat' || $isExternalDirectMailRecord) {
         $hideCategoryStep = true;
     }
     if (GeneralUtility::_GP('update_cats')) {
         $this->CMD = 'cats';
     }
     if (GeneralUtility::_GP('mailingMode_simple')) {
         $this->CMD = 'send_mail_test';
     }
     $backButtonPressed = GeneralUtility::_GP('back');
     if ($backButtonPressed) {
         // CMD move 1 step back
         switch (GeneralUtility::_GP('currentCMD')) {
             case 'info':
                 $this->CMD = '';
                 break;
             case 'cats':
                 $this->CMD = 'info';
                 break;
             case 'send_test':
                 // Sameas send_mail_test
             // Sameas send_mail_test
             case 'send_mail_test':
                 if ($this->CMD == 'send_mass' && $hideCategoryStep) {
                     $this->CMD = 'info';
                 } else {
                     $this->CMD = 'cats';
                 }
                 break;
             case 'send_mail_final':
                 // The same as send_mass
             // The same as send_mass
             case 'send_mass':
                 $this->CMD = 'send_test';
                 break;
             default:
                 // Do nothing
         }
     }
     $nextCmd = "";
     if ($hideCategoryStep) {
         $totalSteps = 4;
         if ($this->CMD == 'info') {
             $nextCmd = 'send_test';
         }
     } else {
         $totalSteps = 5;
         if ($this->CMD == 'info') {
             $nextCmd = 'cats';
         }
     }
     $navigationButtons = "";
     switch ($this->CMD) {
         case 'info':
             $fetchMessage = "";
             // step 2: create the Direct Mail record, or use existing
             $this->currentStep = 2;
             $markers['TITLE'] = $this->getLanguageService()->getLL('dmail_wiz2_detail');
             // greyed out next-button if fetching is not successful (on error)
             $fetchError = true;
             // Create DirectMail and fetch the data
             $shouldFetchData = GeneralUtility::_GP('fetchAtOnce');
             $quickmail = GeneralUtility::_GP('quickmail');
             $createMailFromInternalPage = intval(GeneralUtility::_GP('createMailFrom_UID'));
             $createMailFromExternalUrl = GeneralUtility::_GP('createMailFrom_URL');
             // internal page
             if ($createMailFromInternalPage && !$quickmail['send']) {
                 $createMailFromInternalPageLang = (int) GeneralUtility::_GP('createMailFrom_LANG');
                 $newUid = DirectMailUtility::createDirectMailRecordFromPage($createMailFromInternalPage, $this->params, $createMailFromInternalPageLang);
                 if (is_numeric($newUid)) {
                     $this->sys_dmail_uid = $newUid;
                     // Read new record (necessary because TCEmain sets default field values)
                     $row = BackendUtility::getRecord('sys_dmail', $newUid);
                     // fetch the data
                     if ($shouldFetchData) {
                         $fetchMessage = DirectMailUtility::fetchUrlContentsForDirectMailRecord($row, $this->params);
                         $fetchError = strstr($fetchMessage, $this->getLanguageService()->getLL('dmail_error')) === false ? false : true;
                     }
                     $theOutput .= '<input type="hidden" name="CMD" value="' . ($nextCmd ? $nextCmd : 'cats') . '">';
                 } else {
                     // TODO: Error message - Error while adding the DB set
                 }
                 // external URL
             } elseif ($createMailFromExternalUrl && !$quickmail['send']) {
                 // $createMailFromExternalUrl is the External URL subject
                 $htmlUrl = GeneralUtility::_GP('createMailFrom_HTMLUrl');
                 $plainTextUrl = GeneralUtility::_GP('createMailFrom_plainUrl');
                 $newUid = DirectMailUtility::createDirectMailRecordFromExternalURL($createMailFromExternalUrl, $htmlUrl, $plainTextUrl, $this->params);
                 if (is_numeric($newUid)) {
                     $this->sys_dmail_uid = $newUid;
                     // Read new record (necessary because TCEmain sets default field values)
                     $row = BackendUtility::getRecord('sys_dmail', $newUid);
                     // fetch the data
                     if ($shouldFetchData) {
                         $fetchMessage = DirectMailUtility::fetchUrlContentsForDirectMailRecord($row, $this->params);
                         $fetchError = strstr($fetchMessage, $this->getLanguageService()->getLL('dmail_error')) === false ? false : true;
                     }
                     $theOutput .= '<input type="hidden" name="CMD" value="send_test">';
                 } else {
                     // TODO: Error message - Error while adding the DB set
                     $this->error = 'no_valid_url';
                 }
                 // Quickmail
             } elseif ($quickmail['send']) {
                 $fetchMessage = $this->createDMail_quick($quickmail);
                 $fetchError = strstr($fetchMessage, $this->getLanguageService()->getLL('dmail_error')) === false ? false : true;
                 $row = BackendUtility::getRecord('sys_dmail', $this->sys_dmail_uid);
                 $theOutput .= '<input type="hidden" name="CMD" value="send_test">';
                 // existing dmail
             } elseif ($row) {
                 if ($row['type'] == '1' && (empty($row['HTMLParams']) || empty($row['plainParams']))) {
                     // it's a quickmail
                     $fetchError = false;
                     $theOutput .= '<input type="hidden" name="CMD" value="send_test">';
                     // add attachment here, since attachment added in 2nd step
                     $unserializedMailContent = unserialize(base64_decode($row['mailContent']));
                     $theOutput .= $this->compileQuickMail($row, $unserializedMailContent['plain']['content'], false);
                 } else {
                     if ($shouldFetchData) {
                         $fetchMessage = DirectMailUtility::fetchUrlContentsForDirectMailRecord($row, $this->params);
                         $fetchError = strstr($fetchMessage, $this->getLanguageService()->getLL('dmail_error')) === false ? false : true;
                     }
                     if ($row['type'] == 0) {
                         $theOutput .= '<input type="hidden" name="CMD" value="' . $nextCmd . '">';
                     } else {
                         $theOutput .= '<input type="hidden" name="CMD" value="send_test">';
                     }
                 }
             }
             $navigationButtons = '<input type="submit" class="btn btn-default" value="' . $this->getLanguageService()->getLL('dmail_wiz_back') . '" name="back"> &nbsp;';
             $navigationButtons .= '<input type="submit" value="' . $this->getLanguageService()->getLL('dmail_wiz_next') . '" ' . ($fetchError ? 'disabled="disabled" class="next btn btn-default disabled"' : ' class="btn btn-default"') . '>';
             if ($fetchMessage) {
                 $markers['FLASHMESSAGES'] = $fetchMessage;
             } elseif (!$fetchError && $shouldFetchData) {
                 /* @var $flashMessage FlashMessage */
                 $flashMessage = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', '', $this->getLanguageService()->getLL('dmail_wiz2_fetch_success'), FlashMessage::OK);
                 $markers['FLASHMESSAGES'] = $flashMessage->render();
             }
             if (is_array($row)) {
                 $theOutput .= '<div id="box-1" class="toggleBox">';
                 $theOutput .= $this->renderRecordDetailsTable($row);
                 $theOutput .= '</div>';
             }
             $theOutput .= '<input type="hidden" name="sys_dmail_uid" value="' . $this->sys_dmail_uid . '">';
             $theOutput .= !empty($row['page']) ? '<input type="hidden" name="pages_uid" value="' . $row['page'] . '">' : '';
             $theOutput .= '<input type="hidden" name="currentCMD" value="' . $this->CMD . '">';
             break;
         case 'cats':
             // shows category if content-based cat
             $this->currentStep = 3;
             $markers['TITLE'] = $this->getLanguageService()->getLL('dmail_wiz3_cats');
             $navigationButtons = '<input type="submit" class="btn btn-default " value="' . $this->getLanguageService()->getLL('dmail_wiz_back') . '" name="back">&nbsp;';
             $navigationButtons .= '<input type="submit" class="btn btn-default " value="' . $this->getLanguageService()->getLL('dmail_wiz_next') . '">';
             $theOutput .= '<div id="box-1" class="toggleBox">';
             $theOutput .= $this->makeCategoriesForm($row);
             $theOutput .= '</div></div>';
             $theOutput .= '<input type="hidden" name="CMD" value="send_test">';
             $theOutput .= '<input type="hidden" name="sys_dmail_uid" value="' . $this->sys_dmail_uid . '">';
             $theOutput .= '<input type="hidden" name="pages_uid" value="' . $this->pages_uid . '">';
             $theOutput .= '<input type="hidden" name="currentCMD" value="' . $this->CMD . '">';
             break;
         case 'send_test':
             // Same as send_mail_test
         // Same as send_mail_test
         case 'send_mail_test':
             // send test mail
             $this->currentStep = 4 - (5 - $totalSteps);
             $markers['TITLE'] = $this->getLanguageService()->getLL('dmail_wiz4_testmail');
             $navigationButtons = '<input type="submit" class="btn btn-default" value="' . $this->getLanguageService()->getLL('dmail_wiz_back') . '" name="back">&nbsp;';
             $navigationButtons .= '<input type="submit" class="btn btn-default" value="' . $this->getLanguageService()->getLL('dmail_wiz_next') . '">';
             if ($this->CMD == 'send_mail_test') {
                 // using Flashmessages to show sent test mail
                 $markers['FLASHMESSAGES'] = $this->cmd_send_mail($row);
             }
             $theOutput .= '<br /><div id="box-1" class="toggleBox">';
             $theOutput .= $this->cmd_testmail();
             $theOutput .= '</div></div>';
             $theOutput .= '<input type="hidden" name="CMD" value="send_mass">';
             $theOutput .= '<input type="hidden" name="sys_dmail_uid" value="' . $this->sys_dmail_uid . '">';
             $theOutput .= '<input type="hidden" name="pages_uid" value="' . $this->pages_uid . '">';
             $theOutput .= '<input type="hidden" name="currentCMD" value="' . $this->CMD . '">';
             break;
         case 'send_mail_final':
             // same as send_mass
         // same as send_mass
         case 'send_mass':
             $this->currentStep = 5 - (5 - $totalSteps);
             if ($this->CMD == 'send_mass') {
                 $navigationButtons = '<input type="submit" class="btn btn-default" value="' . $this->getLanguageService()->getLL('dmail_wiz_back') . '" name="back">';
             }
             if ($this->CMD == 'send_mail_final') {
                 $selectedMailGroups = GeneralUtility::_GP('mailgroup_uid');
                 if (is_array($selectedMailGroups)) {
                     $markers['FLASHMESSAGES'] = $this->cmd_send_mail($row);
                     break;
                 } else {
                     $theOutput .= 'no recipients';
                 }
             }
             // send mass, show calendar
             $theOutput .= '<div id="box-1" class="toggleBox">';
             $theOutput .= $this->cmd_finalmail($row);
             $theOutput .= '</div>';
             $theOutput = $this->doc->section($this->getLanguageService()->getLL('dmail_wiz5_sendmass'), $theOutput, 1, 1, 0, true);
             $theOutput .= '<input type="hidden" name="CMD" value="send_mail_final">';
             $theOutput .= '<input type="hidden" name="sys_dmail_uid" value="' . $this->sys_dmail_uid . '">';
             $theOutput .= '<input type="hidden" name="pages_uid" value="' . $this->pages_uid . '">';
             $theOutput .= '<input type="hidden" name="currentCMD" value="' . $this->CMD . '">';
             break;
         default:
             // choose source newsletter
             $this->currentStep = 1;
             $markers['TITLE'] = $this->getLanguageService()->getLL('dmail_wiz1_new_newsletter') . ' - ' . $this->getLanguageService()->getLL('dmail_wiz1_select_nl_source');
             $showTabs = array('int', 'ext', 'quick', 'dmail');
             $hideTabs = GeneralUtility::trimExplode(',', $GLOBALS['BE_USER']->userTS['tx_directmail.']['hideTabs']);
             foreach ($hideTabs as $hideTab) {
                 $showTabs = ArrayUtility::removeArrayEntryByValue($showTabs, $hideTab);
             }
             if (!$GLOBALS['BE_USER']->userTS['tx_directmail.']['defaultTab']) {
                 $GLOBALS['BE_USER']->userTS['tx_directmail.']['defaultTab'] = 'dmail';
             }
             $i = 1;
             $countTabs = count($showTabs);
             foreach ($showTabs as $showTab) {
                 $open = false;
                 if ($GLOBALS['BE_USER']->userTS['tx_directmail.']['defaultTab'] == $showTab) {
                     $open = true;
                 }
                 switch ($showTab) {
                     case 'int':
                         $theOutput .= $this->makeFormInternal('box-' . $i, $countTabs, $open);
                         break;
                     case 'ext':
                         $theOutput .= $this->makeFormExternal('box-' . $i, $countTabs, $open);
                         break;
                     case 'quick':
                         $theOutput .= $this->makeFormQuickMail('box-' . $i, $countTabs, $open);
                         break;
                     case 'dmail':
                         $theOutput .= $this->makeListDMail('box-' . $i, $countTabs, $open);
                         break;
                     default:
                 }
                 $i++;
             }
             $theOutput .= '<input type="hidden" name="CMD" value="info" />';
     }
     $markers['NAVIGATION'] = $navigationButtons;
     $markers['CONTENT'] = $theOutput;
     $markers['WIZARDSTEPS'] = $this->showSteps($totalSteps);
     return $markers;
 }
Exemplo n.º 7
0
 /**
  * @test
  */
 public function checkRemoveArrayEntryByValueRemovesEntryWithEmptyString()
 {
     $inputArray = array('0' => 'foo', '1' => '', '2' => 'bar');
     $compareValue = '';
     $expectedResult = array('0' => 'foo', '2' => 'bar');
     $actualResult = ArrayUtility::removeArrayEntryByValue($inputArray, $compareValue);
     $this->assertEquals($expectedResult, $actualResult);
 }
    /**
     * Recursively look for children for page version with $pid
     *
     * @param int $pid UID of page record for which to look up sub-elements following that version
     * @param int $c Counter, do not set (limits to 100 levels)
     * @return string Table with content if any
     */
    public function pageSubContent($pid, $c = 0)
    {
        $tableNames = ArrayUtility::removeArrayEntryByValue(array_keys($GLOBALS['TCA']), 'pages');
        $tableNames[] = 'pages';
        $content = '';
        foreach ($tableNames as $tN) {
            // Basically list ALL tables - not only those being copied might be found!
            $mres = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', $tN, 'pid=' . (int) $pid . BackendUtility::deleteClause($tN), '', $GLOBALS['TCA'][$tN]['ctrl']['sortby'] ? $GLOBALS['TCA'][$tN]['ctrl']['sortby'] : '');
            if ($GLOBALS['TYPO3_DB']->sql_num_rows($mres)) {
                $content .= '
					<tr>
						<td colspan="4" class="' . ($GLOBALS['TCA'][$tN]['ctrl']['versioning_followPages'] ? 'bgColor6' : ($tN == 'pages' ? 'bgColor5' : 'bgColor-10')) . '"' . (!$GLOBALS['TCA'][$tN]['ctrl']['versioning_followPages'] && $tN !== 'pages' ? ' style="color: #666666; font-style:italic;"' : '') . '>' . $tN . '</td>
					</tr>';
                while ($subrow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($mres)) {
                    $ownVer = $this->lookForOwnVersions($tN, $subrow['uid']);
                    $content .= '
						<tr>
							<td>' . $this->adminLinks($tN, $subrow) . '</td>
							<td>' . $subrow['uid'] . '</td>
							' . ($ownVer > 1 ? '<td style="font-weight: bold; background-color: yellow;"><a href="' . htmlspecialchars(BackendUtility::getModuleUrl('web_txversionM1', array('table' => $tN, 'uid' => $subrow['uid']))) . '">' . ($ownVer - 1) . '</a></td>' : '<td></td>') . '
							<td width="98%">' . BackendUtility::getRecordTitle($tN, $subrow, TRUE) . '</td>
						</tr>';
                    if ($tN == 'pages' && $c < 100) {
                        $sub = $this->pageSubContent($subrow['uid'], $c + 1);
                        if ($sub) {
                            $content .= '
								<tr>
									<td></td>
									<td></td>
									<td></td>
									<td width="98%">' . $sub . '</td>
								</tr>';
                        }
                    }
                }
            }
            $GLOBALS['TYPO3_DB']->sql_free_result($mres);
        }
        return $content ? '<table border="1" cellpadding="1" cellspacing="0" width="100%">' . $content . '</table>' : '';
    }
 /**
  * Removes an value from an Comma-separated list
  * stored $key of user settings
  *
  * @param string $key
  * @param mixed $value
  * @return void
  */
 protected function removeFromList($key, $value)
 {
     $list = $this->get($key);
     if (GeneralUtility::inList($list, $value)) {
         $list = GeneralUtility::trimExplode(',', $list, true);
         $list = ArrayUtility::removeArrayEntryByValue($list, $value);
         $this->set($key, implode(',', $list));
     }
 }
Exemplo n.º 10
0
 /**
  * Main function. Called from TypoScript.
  * This
  * - initializes internal variables,
  * - fills in the markerArray with default substitution string
  * - saves/emails if such commands are sent
  * - calls functions for display of the screen for editing/creation/deletion etc.
  *
  * @param string $content Empty string, ignore.
  * @param array $conf TypoScript properties following the USER_INT object which uses this library
  *
  * @return string HTML content
  */
 public function init($content, $conf)
 {
     $this->conf = $conf;
     // template file is fetched.
     $this->templateCode = $this->conf['templateContent'] ? $this->conf['templateContent'] : $this->cObj->fileResource($this->conf['templateFile']);
     // Getting the cmd var
     $this->cmd = (string) GeneralUtility::_GP('cmd');
     // Getting the preview var
     $this->preview = (string) GeneralUtility::_GP('preview');
     // backURL is a given URL to return to when login is performed
     $this->backURL = GeneralUtility::_GP('backURL');
     if (strstr($this->backURL, '"') || strstr($this->backURL, "'") || preg_match('/(javascript|vbscript):/i', $this->backURL) || stristr($this->backURL, "fromcharcode") || strstr($this->backURL, "<") || strstr($this->backURL, ">")) {
         $this->backURL = '';
         // Clear backURL if it seems to contain XSS code - only URLs are allowed
     }
     // Remove host from URL: Make sure that $this->backURL maps to the current site
     $this->backURL = preg_replace('|[A-Za-z]+://[^/]+|', '', $this->backURL);
     // Uid to edit:
     $this->recUid = GeneralUtility::_GP('rU');
     // Authentication code:
     $this->authCode = GeneralUtility::_GP('aC');
     // get table
     $this->theTable = $this->conf['table'];
     // link configuration
     $linkConf = is_array($this->conf['formurl.']) ? $this->conf['formurl.'] : [];
     // pid
     $this->thePid = intval($this->conf['pid']) ? intval($this->conf['pid']) : $this->getTypoScriptFrontendController()->id;
     //
     $this->codeLength = intval($this->conf['authcodeFields.']['codeLength']) ? intval($this->conf['authcodeFields.']['codeLength']) : 8;
     // Setting the hardcoded lists of fields allowed for editing and creation.
     $this->fieldList = implode(',', GeneralUtility::trimExplode(',', $GLOBALS['TCA'][$this->theTable]['feInterface']['fe_admin_fieldList'], 1));
     // globally substituted markers, fonts and colors.
     $splitMark = md5(microtime());
     list($this->markerArray['###GW1B###'], $this->markerArray['###GW1E###']) = explode($splitMark, $this->cObj->stdWrap($splitMark, $this->conf['wrap1.']));
     list($this->markerArray['###GW2B###'], $this->markerArray['###GW2E###']) = explode($splitMark, $this->cObj->stdWrap($splitMark, $this->conf['wrap2.']));
     $this->markerArray['###GC1###'] = $this->cObj->stdWrap($this->conf['color1'], $this->conf['color1.']);
     $this->markerArray['###GC2###'] = $this->cObj->stdWrap($this->conf['color2'], $this->conf['color2.']);
     $this->markerArray['###GC3###'] = $this->cObj->stdWrap($this->conf['color3'], $this->conf['color3.']);
     if (intval($this->conf['no_cache']) && !isset($linkConf['no_cache'])) {
         // needed for backwards compatibility
         $linkConf['no_cache'] = 1;
     }
     if (!$linkConf['parameter']) {
         $linkConf['parameter'] = $this->getTypoScriptFrontendController()->id;
     }
     if (!$linkConf['additionalParams']) {
         // needed for backwards compatibility
         $linkConf['additionalParams'] = $this->conf['addParams'];
     }
     $formURL = $this->cObj->typoLink_URL($linkConf);
     if (!strstr($formURL, '?')) {
         $formURL .= '?';
     }
     // Initialize markerArray, setting FORM_URL and HIDDENFIELDS
     $this->markerArray['###FORM_URL###'] = $formURL;
     $this->markerArray['###FORM_URL_ENC###'] = rawurlencode($this->markerArray['###FORM_URL###']);
     $this->markerArray['###FORM_URL_HSC###'] = htmlspecialchars($this->markerArray['###FORM_URL###']);
     $this->markerArray['###BACK_URL###'] = $this->backURL;
     $this->markerArray['###BACK_URL_ENC###'] = rawurlencode($this->markerArray['###BACK_URL###']);
     $this->markerArray['###BACK_URL_HSC###'] = htmlspecialchars($this->markerArray['###BACK_URL###']);
     $this->markerArray['###THE_PID###'] = $this->thePid;
     $this->markerArray['###REC_UID###'] = $this->recUid;
     $this->markerArray['###AUTH_CODE###'] = $this->authCode;
     $this->markerArray['###THIS_ID###'] = $this->getTypoScriptFrontendController()->id;
     $this->markerArray['###THIS_URL###'] = htmlspecialchars(GeneralUtility::getIndpEnv('TYPO3_SITE_URL'));
     $this->markerArray['###HIDDENFIELDS###'] = ($this->cmd ? '<input type="hidden" name="cmd" value="' . htmlspecialchars($this->cmd) . '" />' : '') . ($this->authCode ? '<input type="hidden" name="aC" value="' . htmlspecialchars($this->authCode) . '" />' : '') . ($this->backURL ? '<input type="hidden" name="backURL" value="' . htmlspecialchars($this->backURL) . '" />' : '');
     // Setting cmdKey which is either 'edit' or 'create'
     switch ($this->cmd) {
         case 'edit':
             $this->cmdKey = 'edit';
             break;
         default:
             $this->cmdKey = 'create';
             break;
     }
     // Setting requiredArr to the fields in 'required' intersected field the total field list in order to remove invalid fields.
     $this->requiredArr = array_intersect(GeneralUtility::trimExplode(',', $this->conf[$this->cmdKey . '.']['required'], 1), GeneralUtility::trimExplode(',', $this->conf[$this->cmdKey . '.']['fields'], 1));
     // Setting incoming data. Non-stripped
     $fe = GeneralUtility::_GP('FE');
     $this->dataArr = $fe[$this->theTable];
     // Incoming data.
     // Checking template file and table value
     if (!$this->templateCode) {
         $content = 'No template file found: ' . $this->conf['templateFile'];
         return $content;
     }
     if (!$this->theTable || !$this->fieldList) {
         $content = 'Wrong table: ' . $this->theTable;
         return $content;
         // Not listed or editable table!
     }
     // *****************
     // If data is submitted, we take care of it here.
     // *******************
     if ($this->cmd == 'delete' && !$this->preview && !GeneralUtility::_GP('doNotSave')) {
         // Delete record if delete command is sent + the preview flag is NOT set.
         $this->deleteRecord();
     }
     // If incoming data is seen...
     if (is_array($this->dataArr) && count(ArrayUtility::removeArrayEntryByValue(array_keys($this->dataArr), 'captcha'))) {
         // Evaluation of data:
         $this->parseValues();
         $this->overrideValues();
         $this->evalValues();
         if ($this->conf['evalFunc']) {
             $this->dataArr = $this->userProcess('evalFunc', $this->dataArr);
         }
         /*
         debug($this->dataArr);
         debug($this->failure);
         debug($this->preview);
         */
         // if not preview and no failures, then set data...
         if (!$this->failure && !$this->preview && !GeneralUtility::_GP('doNotSave')) {
             // doNotSave is a global var (eg a 'Cancel' submit button) that prevents the data from being processed
             $this->save();
         } else {
             if ($this->conf['debug']) {
                 debug($this->failure);
             }
         }
     } else {
         $this->defaultValues();
         // If no incoming data, this will set the default values.
         $this->preview = 0;
         // No preview if data is not received
     }
     if ($this->failure) {
         $this->preview = 0;
     }
     // No preview flag if a evaluation failure has occured
     $this->previewLabel = $this->preview ? '_PREVIEW' : '';
     // Setting preview label prefix.
     // *********************
     // DISPLAY FORMS:
     // ***********************
     if ($this->saved) {
         // Clear page cache
         $this->clearCacheIfSet();
         $this->setNoCacheHeader();
         // Displaying the page here that says, the record has been saved. You're able to include the saved values by markers.
         switch ($this->cmd) {
             case 'delete':
                 $key = 'DELETE';
                 break;
             case 'edit':
                 $key = 'EDIT';
                 break;
             default:
                 $key = 'CREATE';
                 break;
         }
         // Output message
         $templateCode = $this->cObj->getSubpart($this->templateCode, '###TEMPLATE_' . $key . '_SAVED###');
         $this->setCObjects($templateCode, $this->currentArr);
         $markerArray = $this->cObj->fillInMarkerArray($this->markerArray, $this->currentArr, '', true, 'FIELD_', $this->recInMarkersHSC);
         $content = $this->cObj->substituteMarkerArray($templateCode, $markerArray);
         // email message:
         $this->compileMail($key . '_SAVED', [$this->currentArr], $this->currentArr[$this->conf['email.']['field']], $this->conf['setfixed.']);
     } elseif ($this->error) {
         // If there was an error, we return the template-subpart with the error message
         $templateCode = $this->cObj->getSubpart($this->templateCode, $this->error);
         $this->setCObjects($templateCode);
         $content = $this->cObj->substituteMarkerArray($templateCode, $this->markerArray);
     } else {
         // Finally, if there has been no attempt to save. That is either preview or just displaying and empty or not correctly filled form:
         if (!$this->cmd) {
             $this->cmd = $this->conf['defaultCmd'];
         }
         if ($this->conf['debug']) {
             debug('Display form: ' . $this->cmd, 1);
         }
         switch ($this->cmd) {
             case 'setfixed':
                 $content = $this->procesSetFixed();
                 break;
             case 'infomail':
                 $content = $this->sendInfoMail();
                 break;
             case 'delete':
                 $content = $this->displayDeleteScreen();
                 break;
             case 'edit':
                 $content = $this->displayEditScreen();
                 break;
             case 'create':
                 $content = $this->displayCreateScreen();
                 break;
         }
     }
     // Delete temp files:
     foreach ($this->unlinkTempFiles as $tempFileName) {
         GeneralUtility::unlink_tempfile($tempFileName);
     }
     // Return content:
     return $content;
 }