/** * Function executed from the Scheduler. * * @return boolean */ public function execute() { $successfullyExecuted = TRUE; foreach ($this->tables as $table) { $where = 'hidden = 1 AND ' . $this->getWhereClause($table); if ($this->markAsDeleted && in_array($table, Tx_Tablecleaner_Utility_Base::getTablesWithDeletedAndTstamp())) { $fieldValues = array('tstamp' => $_SERVER['REQUEST_TIME'], 'deleted' => 1); $GLOBALS['TYPO3_DB']->exec_UPDATEquery($table, $where, $fieldValues); } else { $GLOBALS['TYPO3_DB']->exec_DELETEquery($table, $where); $error = $GLOBALS['TYPO3_DB']->sql_error(); if (!$error && $this->optimizeOption) { $GLOBALS['TYPO3_DB']->sql_query('OPTIMIZE TABLE ' . $table); } } if ($GLOBALS['TYPO3_DB']->sql_error()) { $successfullyExecuted = FALSE; } } return $successfullyExecuted; }
/** * This method checks any additional data that is relevant to the specific task. * If the task class is not relevant, the method is expected to return TRUE. * * @param array $submittedData : reference to the array containing the data * submitted by the user * @param \tx_scheduler_Module $schedulerModule : * reference to the calling object (BE module of the Scheduler) * * @return boolean True if validation was ok (or selected class is not * relevant), FALSE otherwise */ public function validateAdditionalFields(array &$submittedData, tx_scheduler_Module $schedulerModule) { $isValid = TRUE; if (is_array($submittedData['deletedTables'])) { $tables = Tx_Tablecleaner_Utility_Base::getTablesWithDeletedAndTstamp(); foreach ($submittedData['deletedTables'] as $table) { if (!in_array($table, $tables)) { $isValid = FALSE; $schedulerModule->addMessage($GLOBALS['LANG']->sL('LLL:EXT:tablecleaner/Resources/Private/Language/locallang.xml:tasks.general.invalidTables'), t3lib_FlashMessage::ERROR); } } } else { $isValid = FALSE; $schedulerModule->addMessage($GLOBALS['LANG']->sL('LLL:EXT:tablecleaner/Resources/Private/Language/locallang.xml:tasks.general.noTables'), t3lib_FlashMessage::ERROR); } if ($submittedData['deletedDayLimit'] <= 0) { $isValid = FALSE; $schedulerModule->addMessage($GLOBALS['LANG']->sL('LLL:EXT:tablecleaner/Resources/Private/Language/locallang.xml:tasks.general.invalidNumberOfDays'), t3lib_FlashMessage::ERROR); } return $isValid; }