Added feature #15221: Add hook to postprocess upload of a file
authorXavier Perseguers <typo3@perseguers.ch>
Tue, 27 Jul 2010 10:02:15 +0000 (10:02 +0000)
committerXavier Perseguers <typo3@perseguers.ch>
Tue, 27 Jul 2010 10:02:15 +0000 (10:02 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@8283 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
t3lib/class.t3lib_tcemain.php
t3lib/core_autoload.php
t3lib/interfaces/interface.t3lib_tcemain_processuploadhook.php [new file with mode: 0644]

index d0ed7a7..d70f01b 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2010-07-27  Xavier Perseguers  <typo3@perseguers.ch>
+
+       * Added feature #15221: Add hook to postprocess upload of a file
+
 2010-07-27  Christian Kuhn  <lolli@schwarzbu.ch>
 
        * Fixed bug #15196: [caching framework] Speedup t3lib_cache_backend_DbBackend::has($entryIdentifier) (Thanks to Michael Knabe)
index ac4aeb9..7726685 100644 (file)
@@ -1691,6 +1691,20 @@ class t3lib_TCEmain      {
                                                                                // If we have a unique destination filename, then write the file:
                                                                        if ($theDestFile)       {
                                                                                t3lib_div::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 = t3lib_div::getUserObj($classRef);
+
+                                                                                               if (!($hookObject instanceof t3lib_TCEmain_processUploadHook)) {
+                                                                                                       throw new UnexpectedValueException('$hookObject must implement interface t3lib_TCEmain_processUploadHook', 1279962349);
+                                                                                               }
+
+                                                                                               $hookObject->processUpload_postProcessAction($theDestFile, $this);
+                                                                                       }
+                                                                               }
+
                                                                                $this->copiedFileMap[$theFile] = $theDestFile;
                                                                                clearstatcache();
                                                                                if (!@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']);
index b3c5fee..afc0a19 100644 (file)
@@ -122,6 +122,7 @@ $t3libClasses = array(
        't3lib_singleton' => PATH_t3lib . 'interfaces/interface.t3lib_singleton.php',
        't3lib_tceformsinlinehook' => PATH_t3lib . 'interfaces/interface.t3lib_tceformsinlinehook.php',
        't3lib_tcemain_checkmodifyaccesslisthook' => PATH_t3lib . 'interfaces/interface.t3lib_tcemain_checkmodifyaccesslisthook.php',
+       't3lib_tcemain_processuploadhook' => PATH_t3lib . 'interfaces/interface.t3lib_tcemain_processuploadhook.php',
        't3lib_matchcondition_abstract' => PATH_t3lib . 'matchcondition/class.t3lib_matchcondition_abstract.php',
        't3lib_matchcondition_backend' => PATH_t3lib . 'matchcondition/class.t3lib_matchcondition_backend.php',
        't3lib_matchcondition_frontend' => PATH_t3lib . 'matchcondition/class.t3lib_matchcondition_frontend.php',
diff --git a/t3lib/interfaces/interface.t3lib_tcemain_processuploadhook.php b/t3lib/interfaces/interface.t3lib_tcemain_processuploadhook.php
new file mode 100644 (file)
index 0000000..7c21211
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+/***************************************************************
+*  Copyright notice
+*
+*  (c) 2010 Xavier Perseguers <typo3@perseguers.ch>
+*  All rights reserved
+*
+*  This script is part of the TYPO3 project. The TYPO3 project is
+*  free software; you can redistribute it and/or modify
+*  it under the terms of the GNU General Public License as published by
+*  the Free Software Foundation; either version 2 of the License, or
+*  (at your option) any later version.
+*
+*  The GNU General Public License can be found at
+*  http://www.gnu.org/copyleft/gpl.html.
+*  A copy is found in the textfile GPL.txt and important notices to the license
+*  from the author is found in LICENSE.txt distributed with these scripts.
+*
+*
+*  This script is distributed in the hope that it will be useful,
+*  but WITHOUT ANY WARRANTY; without even the implied warranty of
+*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+*  GNU General Public License for more details.
+*
+*  This copyright notice MUST APPEAR in all copies of the script!
+***************************************************************/
+
+
+/**
+ * Interface for classes which hook into TCEmain and do additional processing
+ * after the upload of a file.
+ *
+ * @author     Xavier Perseguers <typo3@perseguers.ch>
+ * @package TYPO3
+ * @subpackage t3lib
+ */
+
+interface t3lib_TCEmain_processUploadHook {
+
+       /**
+        * Post-process a file upload.
+        *
+        * @param       string          The uploaded file 
+        * @param       t3lib_TCEmain           parent t3lib_TCEmain object
+        * @return      void
+        */
+       public function processUpload_postProcessAction(&$filename, t3lib_TCEmain $parentObject);
+
+}
+
+?>
\ No newline at end of file