[FEATURE] Add two hooks to tx_sysaction_task
authorSebastian Fischer <typo3@evoweb.de>
Fri, 25 Nov 2011 10:54:55 +0000 (11:54 +0100)
committerSteffen Ritter <info@rs-websystems.de>
Mon, 12 Dec 2011 09:08:55 +0000 (10:08 +0100)
Add central hook object registration in the sys_action task which gets
used for two hook methods. One that modifies the transfered data before
the process of the task self acts on them. The other hook that enables
custom error checking. Like special checks on the submitted password
for complexity or similier.

Change-Id: I2a2a2ffdfb896d798ce0b96c3d48334956cf49b7
Fixes: #32055
Releases: 4.7
Reviewed-on: http://review.typo3.org/6915
Reviewed-by: Oliver Hader
Tested-by: Oliver Hader
Tested-by: Steffen Ritter
typo3/sysext/sys_action/task/class.tx_sysaction_task.php

index 9a72a41..ecf6b66 100644 (file)
@@ -39,11 +39,24 @@ class tx_sysaction_task implements tx_taskcenter_Task {
        var $t3lib_TCEforms;
 
        /**
+        * All hook objects get registered here for later use
+        *
+        * @var array
+        */
+       protected $hookObjects = array();
+
+       /**
         * Constructor
         */
        public function __construct(SC_mod_user_task_index $taskObject) {
                $this->taskObject = $taskObject;
                $GLOBALS['LANG']->includeLLFile('EXT:sys_action/locallang.xml');
+
+               if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['sys_action']['tx_sysaction_task'])) {
+                       foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['sys_action']['tx_sysaction_task'] as $classRef) {
+                               $this->hookObjects[] = t3lib_div::getUserObj($classRef);
+                       }
+               }
        }
 
 
@@ -56,6 +69,12 @@ class tx_sysaction_task implements tx_taskcenter_Task {
                $content = '';
                $show = intval(t3lib_div::_GP('show'));
 
+               foreach ($this->hookObjects as $hookObject) {
+                       if (method_exists($hookObject, 'getTask')) {
+                               $show = $hookObject->getTask($show, $this);
+                       }
+               }
+
                        // if no task selected, render the menu
                if ($show == 0) {
                        $content .= $this->taskObject->description(
@@ -284,6 +303,12 @@ class tx_sysaction_task implements tx_taskcenter_Task {
                                $errors[] = $GLOBALS['LANG']->getLL('error-wrong-user');
                        }
 
+                       foreach ($this->hookObjects as $hookObject) {
+                               if (method_exists($hookObject, 'viewNewBackendUser_Error')) {
+                                       $errors = $hookObject->viewNewBackendUser_Error($vars, $errors, $this);
+                               }
+                       }
+
                                // show errors if there are any
                        if (count($errors) > 0) {
                                $flashMessage = t3lib_div::makeInstance (
@@ -1031,4 +1056,4 @@ if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLA
        include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/sys_action/task/class.tx_sysaction_task.php']);
 }
 
-?>
\ No newline at end of file
+?>