/** * Validates the additional fields' values * * @param array $submittedData An array containing the data submitted by the add/edit task form * @param \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $schedulerModule Reference to the scheduler backend module * @return boolean TRUE if validation was ok (or selected class is not relevant), FALSE otherwise */ public function validateAdditionalFields(array &$submittedData, SchedulerModuleController $schedulerModule) { $validInput = true; if (empty($submittedData[$this->fieldNames['time']])) { $schedulerModule->addMessage($GLOBALS['LANG']->sL($this->languageFile . 'error.empty'), FlashMessage::ERROR); $validInput = false; } try { $date = new \DateTime($submittedData[$this->fieldNames['time']]); } catch (\Exception $e) { $schedulerModule->addMessage($GLOBALS['LANG']->sL($this->languageFile . 'error.wrongFormat'), FlashMessage::ERROR); $validInput = false; } if (!empty($submittedData[$this->fieldNames['email']])) { $emails = GeneralUtility::trimExplode(';', $submittedData[$this->fieldNames['email']], true); foreach ($emails as $key => $email) { if (!GeneralUtility::validEmail($email)) { $schedulerModule->addMessage($GLOBALS['LANG']->sL($this->languageFile . 'error.wrongEmail'), FlashMessage::ERROR); $validInput = false; break; } } } $validInput = $this->validateTestRunner($submittedData); return $validInput; }
public function validateAdditionalFields(array &$submittedData, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject) { $result = TRUE; if (empty($submittedData['additionalscheduler_exec_path'])) { $parentObject->addMessage($GLOBALS['LANG']->sL('LLL:EXT:additional_scheduler/Resources/Private/Language/locallang.xml:savedirerror'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR); $result = FALSE; } return $result; }
/** * Validates the additional fields' values * * @param array $submittedData * @param \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $schedulerModule * @return bool */ public function validateAdditionalFields(array &$submittedData, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $schedulerModule) { $isValid = TRUE; if (!\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($submittedData['storagePid']) || $submittedData['storagePid'] < 0) { $isValid = FALSE; $schedulerModule->addMessage('You must set a storage pid', \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR); } return $isValid; }
/** * Validates the additional fields' values * * @param array $submittedData * @param \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $schedulerModule * @return bool */ public function validateAdditionalFields(array &$submittedData, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $schedulerModule) { $isValid = FALSE; if (tx_crawler_api::convertToPositiveInteger($submittedData['timeOut']) > 0) { $isValid = TRUE; } else { $schedulerModule->addMessage($GLOBALS['LANG']->sL('LLL:EXT:crawler/locallang_db.xml:crawler_im.invalidTimeOut'), t3lib_FlashMessage::ERROR); } return $isValid; }
/** * Validates the additional fields' values * * @param array $submittedData An array containing the data submitted by the add/edit task form * @param \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $schedulerModule Reference to the scheduler backend module * @return boolean TRUE if validation was ok (or selected class is not relevant), FALSE otherwise */ public function validateAdditionalFields(array &$submittedData, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $schedulerModule) { $validInput = TRUE; $submittedData[$this->fieldPrefix . 'NotificationEmail'] = trim($submittedData[$this->fieldPrefix . 'NotificationEmail']); if (empty($submittedData[$this->fieldPrefix . 'NotificationEmail']) || !filter_var($submittedData[$this->fieldPrefix . 'NotificationEmail'], FILTER_VALIDATE_EMAIL)) { $schedulerModule->addMessage($GLOBALS['LANG']->sL('LLL:EXT:reports/reports/locallang.xml:status_updateTaskField_notificationEmail_invalid'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR); $validInput = FALSE; } return $validInput; }
/** * 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 \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject Reference to the calling object (Scheduler's BE module) * @return bool TRUE if validation was ok (or selected class is not relevant), FALSE otherwise */ public function validateAdditionalFields(array &$submittedData, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject) { $submittedData['email'] = trim($submittedData['email']); if (empty($submittedData['email'])) { $parentObject->addMessage($GLOBALS['LANG']->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:msg.noEmail'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR); $result = FALSE; } else { $result = TRUE; } return $result; }
/** * 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 \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject Reference to the calling object (Scheduler's BE module) * @return bool TRUE if validation was ok (or selected class is not relevant), FALSE otherwise */ public function validateAdditionalFields(array &$submittedData, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject) { $submittedData['sleepTime'] = (int) $submittedData['sleepTime']; if ($submittedData['sleepTime'] < 0) { $parentObject->addMessage($GLOBALS['LANG']->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:msg.invalidSleepTime'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR); $result = false; } else { $result = true; } return $result; }
/** * 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 \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject Reference to the calling object (Scheduler's BE module) * @return boolean TRUE if validation was ok (or selected class is not relevant), FALSE otherwise */ public function validateAdditionalFields(array &$submittedData, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject) { $submittedData['sleepTime'] = intval($submittedData['sleepTime']); if ($submittedData['sleepTime'] < 0) { $parentObject->addMessage($GLOBALS['LANG']->sL('LLL:EXT:scheduler/mod1/locallang.xml:msg.invalidSleepTime'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR); $result = FALSE; } else { $result = TRUE; } return $result; }
/** * Checks if the given value is an integer * * @param array $submittedData Reference to the array containing the data submitted by the user * @param \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject Reference to the calling object (Scheduler's BE module) * @return boolean TRUE if validation was ok (or selected class is not relevant), FALSE otherwise */ public function validateAdditionalFields(array &$submittedData, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject) { $result = TRUE; // Check if number of days is indeed a number and greater or equals to 0 // If not, fail validation and issue error message if (!is_numeric($submittedData['scheduler_recyclerGarbageCollection_numberOfDays']) || (int) $submittedData['scheduler_recyclerGarbageCollection_numberOfDays'] < 0) { $result = FALSE; $parentObject->addMessage($GLOBALS['LANG']->sL('LLL:EXT:scheduler/mod1/locallang.xlf:msg.invalidNumberOfDays'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR); } return $result; }
public function validateAdditionalFields(array &$submittedData, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject) { $result = true; if (empty($submittedData['additionalscheduler_exec_path'])) { $parentObject->addMessage($GLOBALS['LANG']->sL('LLL:EXT:additional_scheduler/Resources/Private/Language/locallang.xml:savedirerror'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR); $result = false; } // check script is executable if (is_executable($submittedData['additionalscheduler_exec_path']) === false) { $parentObject->addMessage(sprintf($GLOBALS['LANG']->sL('LLL:EXT:additional_scheduler/Resources/Private/Language/locallang.xml:mustbeexecutable'), $submittedData['additionalscheduler_exec_path']), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR); $result = false; } return $result; }
/** * Validates the additional fields' values * * @param array An array containing the data submitted by the add/edit task form * @param \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController Reference to the scheduler backend module * @return boolean True if validation was ok (or selected class is not relevant), false otherwise */ public function validateAdditionalFields(array &$submittedData, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $schedulerModule) { if (empty($submittedData['tx_czsimplecal_minindexage'])) { $submittedData['tx_czsimplecal_minindexage'] = null; } elseif (!is_string($submittedData['tx_czsimplecal_minindexage'])) { $schedulerModule->addMessage($GLOBALS['LANG']->sL('LLL:EXT:cz_simple_cal/Resources/Private/Language/locallang_mod.xml:tx_czsimplecal_scheduler_index.minindexage.nostring'), t3lib_FlashMessage::ERROR); return false; } else { if (Tx_CzSimpleCal_Utility_StrToTime::strtotime($submittedData['tx_czsimplecal_minindexage']) === false) { $schedulerModule->addMessage(sprintf($GLOBALS['LANG']->sL('LLL:EXT:cz_simple_cal/Resources/Private/Language/locallang_mod.xml:tx_czsimplecal_scheduler_index.minindexage.parseerror'), $submittedData['tx_czsimplecal_minindexage']), t3lib_FlashMessage::ERROR); return false; } } return true; }
/** * Validates the additional fields' values * * @param array $submittedData An array containing the data submitted by the add/edit task form * @param \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $schedulerModule Reference to the scheduler backend module * @return bool TRUE if validation was ok (or selected class is not relevant), FALSE otherwise */ public function validateAdditionalFields(array &$submittedData, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $schedulerModule) { $validInput = TRUE; $notificationEmails = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(LF, $submittedData[$this->fieldPrefix . 'NotificationEmail'], TRUE); foreach ($notificationEmails as $notificationEmail) { if (!\TYPO3\CMS\Core\Utility\GeneralUtility::validEmail($notificationEmail)) { $validInput = FALSE; break; } } if (empty($submittedData[$this->fieldPrefix . 'NotificationEmail']) || !$validInput) { $schedulerModule->addMessage($GLOBALS['LANG']->sL('LLL:EXT:reports/reports/locallang.xlf:status_updateTaskField_notificationEmails_invalid'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR); $validInput = FALSE; } return $validInput; }
public function validateAdditionalFields(array &$submittedData, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject) { $result = TRUE; // check dir is writable if (empty($submittedData['additionalscheduler_savewebsite_path']) || is_writable($submittedData['additionalscheduler_savewebsite_path']) === FALSE) { $parentObject->addMessage($GLOBALS['LANG']->sL('LLL:EXT:additional_scheduler/Resources/Private/Language/locallang.xml:savedirerror'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR); $result = FALSE; } // check save script is executable $saveScript = PATH_site . 'typo3conf/ext/additional_scheduler/Resources/Shell/save_typo3_website.sh'; if (is_executable($saveScript) === FALSE) { $parentObject->addMessage(sprintf($GLOBALS['LANG']->sL('LLL:EXT:additional_scheduler/Resources/Private/Language/locallang.xml:mustbeexecutable'), $saveScript), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR); $result = FALSE; } return $result; }
/** * Validates the additional fields' values * * @param array $submittedData An array containing the data submitted by the add/edit task form * @param \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $schedulerModule Reference to the scheduler backend module * @return bool TRUE if validation was ok (or selected class is not relevant), FALSE otherwise */ public function validateAdditionalFields(array &$submittedData, SchedulerModuleController $schedulerModule) { $validInput = true; $notificationEmails = GeneralUtility::trimExplode(LF, $submittedData[$this->fieldPrefix . 'NotificationEmail'], true); foreach ($notificationEmails as $notificationEmail) { if (!GeneralUtility::validEmail($notificationEmail)) { $validInput = false; break; } } if (empty($submittedData[$this->fieldPrefix . 'NotificationEmail']) || !$validInput) { $schedulerModule->addMessage($this->getLanguageService()->sL('LLL:EXT:reports/Resources/Private/Language/locallang_reports.xlf:status_updateTaskField_notificationEmails_invalid'), FlashMessage::ERROR); $validInput = false; } return $validInput; }
/** * Checks that all selected backends exist in available backend list * * @param array $submittedData Reference to the array containing the data submitted by the user * @param \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject Reference to the calling object (Scheduler's BE module) * @return bool TRUE if validation was ok (or selected class is not relevant), FALSE otherwise */ public function validateAdditionalFields(array &$submittedData, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject) { $validData = true; $availableTables = array_keys($this->getDatabaseTables()); if (is_array($submittedData['scheduler_optimizeDatabaseTables_selectedTables'])) { $invalidTables = array_diff($submittedData['scheduler_optimizeDatabaseTables_selectedTables'], $availableTables); if (!empty($invalidTables)) { $parentObject->addMessage($GLOBALS['LANG']->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:msg.selectionOfNonExistingDatabaseTables'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR); $validData = false; } } else { $parentObject->addMessage($GLOBALS['LANG']->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:msg.noDatabaseTablesSelected'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR); $validData = false; } return $validData; }
/** * Checks that all selected backends exist in available backend list * * @param array $submittedData Reference to the array containing the data submitted by the user * @param \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject Reference to the calling object (Scheduler's BE module) * @return boolean TRUE if validation was ok (or selected class is not relevant), FALSE otherwise */ public function validateAdditionalFields(array &$submittedData, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject) { $validData = TRUE; $availableBackends = $this->getRegisteredBackends(); if (is_array($submittedData['scheduler_cachingFrameworkGarbageCollection_selectedBackends'])) { $invalidBackends = array_diff($submittedData['scheduler_cachingFrameworkGarbageCollection_selectedBackends'], $availableBackends); if (!empty($invalidBackends)) { $parentObject->addMessage($GLOBALS['LANG']->sL('LLL:EXT:scheduler/mod1/locallang.xlf:msg.selectionOfNonExistingCacheBackends'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR); $validData = FALSE; } } else { $parentObject->addMessage($GLOBALS['LANG']->sL('LLL:EXT:scheduler/mod1/locallang.xlf:msg.noCacheBackendSelected'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR); $validData = FALSE; } return $validData; }
/** * Validates the additional fields' values * * @param array $submittedData An array containing the data submitted by the add/edit task form * @param \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $schedulerModule Reference to the scheduler backend module * @return boolean TRUE if validation was ok (or selected class is not relevant), FALSE otherwise */ public function validateAdditionalFields(array &$submittedData, SchedulerModuleController $schedulerModule) { $validInput = TRUE; $urlsToCrawl = GeneralUtility::trimExplode(LF, $submittedData[$this->fieldPrefix . 'UrlsToCrawl'], TRUE); foreach ($urlsToCrawl as $url) { if (!GeneralUtility::isValidUrl($url)) { $validInput = FALSE; break; } } if (empty($submittedData[$this->fieldPrefix . 'UrlsToCrawl']) || !$validInput) { $message = htmlspecialchars($GLOBALS['LANG']->sL('LLL:EXT:minicrawler/locallang.xml:scheduler.error.urlNotValid')); $schedulerModule->addMessage($message, FlashMessage::ERROR); $validInput = FALSE; } return $validInput; }
/** * 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 \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject : reference to the calling object (Scheduler's BE module) * @return boolean True if validation was ok (or selected class is not relevant), false otherwise */ public function validateAdditionalFields(array &$submittedData, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject) { $submittedData['update_node_id'] = trim($submittedData['update_node_id']); if (empty($submittedData['update_node_id'])) { $parentObject->addMessage($GLOBALS['LANG']->sL('LLL:EXT:caretaker/locallang.xml:scheduler_update_node_required'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR); $result = false; } else { $result = true; } return $result; }
/** * Checks if the given values are boolean and integer * * @param array $submittedData Reference to the array containing the data submitted by the user * @param \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject Reference to the calling object (Scheduler's BE module) * @return boolean TRUE if validation was ok (or selected class is not relevant), FALSE otherwise */ public function validateAdditionalFields(array &$submittedData, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject) { $result = TRUE; // Check if number of records is indeed a number and greater or equals to 0 // If not, fail validation and issue error message if (!is_numeric($submittedData['scheduler_saltedpasswordsBulkUpdateNumberOfRecords']) || (int) $submittedData['scheduler_saltedpasswordsBulkUpdateNumberOfRecords'] < 0) { $result = FALSE; $parentObject->addMessage($GLOBALS['LANG']->sL('LLL:EXT:saltedpasswords/locallang.xlf:ext.saltedpasswords.tasks.bulkupdate.invalidNumberOfRecords'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR); } return $result; }
/** * 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 \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject Reference to the calling object (Scheduler's BE module) * @return boolean TRUE if validation was ok (or selected class is not relevant), FALSE otherwise */ public function validateAdditionalFields(array &$submittedData, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject) { $submittedData['newsPids'] = is_array($submittedData['newsPids']) ? implode(",", $submittedData['newsPids']) : $submittedData['newsPids']; if ($submittedData['newsPids'] == "") { $parentObject->addMessage($GLOBALS['LANG']->sL('LLL:EXT:moox_news/Resources/Private/Language/locallang_scheduler.xlf:tx_mooxnews_tasks_setnewsaccesstask.news_pids_error'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR); $result = FALSE; } else { $result = true; } $submittedData['ignore'] = isset($submittedData['ignore']) ? 1 : 0; return $result; }
/** * Validates the additional fields' values * * @param array $submittedData An array containing the data submitted by the add/edit task form * @param \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $schedulerModule Reference to the scheduler backend module * @return boolean TRUE if validation was ok (or selected class is not relevant), FALSE otherwise */ public function validateAdditionalFields(array &$submittedData, SchedulerModuleController $schedulerModule) { $validInput = true; $directoriesToClean = GeneralUtility::trimExplode(LF, $submittedData[$this->fieldPrefix . 'DirectoriesToClean'], true); foreach ($directoriesToClean as $path) { $path = trim($path, DIRECTORY_SEPARATOR); if (!(strlen($path) > 0 && file_exists(PATH_site . $path) && GeneralUtility::isAllowedAbsPath(PATH_site . $path) && GeneralUtility::validPathStr($path) && !GeneralUtility::inList($this->blackList, $path))) { $validInput = false; break; } } if (empty($submittedData[$this->fieldPrefix . 'DirectoriesToClean']) || $validInput === false) { $schedulerModule->addMessage($GLOBALS['LANG']->sL('LLL:EXT:minicleaner/locallang.xml:error.pathNotValid'), FlashMessage::ERROR); $validInput = false; } return $validInput; }
/** * Checks if given number of days is a positive integer * * @param array $submittedData Reference to the array containing the data submitted by the user * @param \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject Reference to the calling object (Scheduler's BE module) * @return bool True if validation was ok (or selected class is not relevant), false otherwise */ public function validateNumberOfDaysAdditionalField(array &$submittedData, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject) { $validData = FALSE; if (!isset($submittedData['scheduler_tableGarbageCollection_numberOfDays'])) { $validData = TRUE; } elseif ((int) $submittedData['scheduler_tableGarbageCollection_numberOfDays'] >= 0) { $validData = TRUE; } else { // Issue error message $parentObject->addMessage($GLOBALS['LANG']->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:msg.invalidNumberOfDays'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR); } return $validData; }
/** * 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 \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject Reference to the calling object (Scheduler's BE module) * @return boolean TRUE if validation was ok (or selected class is not relevant), FALSE otherwise */ public function validateAdditionalFields(array &$submittedData, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject) { $result = TRUE; $submittedData['pid'] = intval($submittedData['pid']); if ($submittedData['oauthAccessToken'] == "") { $parentObject->addMessage($GLOBALS['LANG']->sL('LLL:EXT:moox_social/Resources/Private/Language/locallang_scheduler.xlf:tx_mooxsocial_tasks_twittergettask.oauth_access_token_error'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR); $result = FALSE; } if ($submittedData['oauthAccessTokenSecret'] == "") { $parentObject->addMessage($GLOBALS['LANG']->sL('LLL:EXT:moox_social/Resources/Private/Language/locallang_scheduler.xlf:tx_mooxsocial_tasks_twittergettask.oauth_access_token_secret_error'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR); $result = FALSE; } if ($submittedData['consumerKey'] == "") { $parentObject->addMessage($GLOBALS['LANG']->sL('LLL:EXT:moox_social/Resources/Private/Language/locallang_scheduler.xlf:tx_mooxsocial_tasks_twittergettask.consumer_key_error'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR); $result = FALSE; } if ($submittedData['consumerKeySecret'] == "") { $parentObject->addMessage($GLOBALS['LANG']->sL('LLL:EXT:moox_social/Resources/Private/Language/locallang_scheduler.xlf:tx_mooxsocial_tasks_twittergettask.consumer_key_secret_error'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR); $result = FALSE; } if ($submittedData['screenName'] == "") { $parentObject->addMessage($GLOBALS['LANG']->sL('LLL:EXT:moox_social/Resources/Private/Language/locallang_scheduler.xlf:tx_mooxsocial_tasks_twittergettask.screen_name_error'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR); $result = FALSE; } if ($submittedData['email'] != "" && !\TYPO3\CMS\Core\Utility\GeneralUtility::validEmail($submittedData['email'])) { $parentObject->addMessage($GLOBALS['LANG']->sL('LLL:EXT:moox_social/Resources/Private/Language/locallang_scheduler.xlf:tx_mooxsocial_tasks_twittergettask.email_error'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR); $result = FALSE; } if ($result) { $config = array('consumer_key' => $submittedData['consumerKey'], 'consumer_secret' => $submittedData['consumerKeySecret'], 'oauth_access_token' => $submittedData['oauthAccessToken'], 'oauth_access_token_secret' => $submittedData['oauthAccessTokenSecret'], 'screenName' => $submittedData['screenName'], 'allowSignedRequest' => false); $twitter = new \TYPO3\MooxSocial\Twitter\TwitterAPIExchange($config); $url = "https://api.twitter.com/1.1/statuses/user_timeline.json"; $requestMethod = "GET"; $getfield = '?screen_name=' . $submittedData['screenName']; try { $rawFeed = json_decode($twitter->setGetfield($getfield)->buildOauth($url, $requestMethod)->performRequest(), $assoc = TRUE); } catch (\Exception $e) { $parentObject->addMessage($GLOBALS['LANG']->sL('LLL:EXT:moox_social/Resources/Private/Language/locallang_scheduler.xlf:tx_mooxsocial_tasks_twittergettask.api_error') . " [" . $e->getMessage() . "]", \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR); $result = FALSE; } } return $result; }
/** * This test must be raised an InvalidArgumentException * * @dataProvider checkDateWithInvalidDateValuesDataProvider * @expectedException InvalidArgumentException * @test * @param string $dateValue Test value which will be passed to $this->testObject->checkDate. */ public function checkDateWithInvalidDateValues($dateValue) { $this->testObject->checkDate($dateValue); }
/** * Validates the input of period * * @param int $period The given period as integer * @param SchedulerModuleController $schedulerModule Reference to the scheduler backend module * @return bool TRUE if validation was ok, FALSE otherwise */ protected function validateAdditionalFieldPeriod($period, SchedulerModuleController $schedulerModule) { if (!empty($period) && filter_var($period, FILTER_VALIDATE_INT) !== false) { $validPeriod = true; } else { $schedulerModule->addMessage($this->getLanguageService()->sL('LLL:EXT:recycler/Resources/Private/Language/locallang_tasks.xlf:cleanerTaskErrorPeriod'), FlashMessage::ERROR); $validPeriod = false; } return $validPeriod; }
/** * 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 \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $schedulerModule Reference to the 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, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $schedulerModule) { $isValid = TRUE; //TODO add validation to validate the $submittedData['configuration'] which is normally a comma separated string if (!empty($submittedData['linkvalidator']['email'])) { $emailList = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $submittedData['linkvalidator']['email']); foreach ($emailList as $emailAdd) { if (!\TYPO3\CMS\Core\Utility\GeneralUtility::validEmail($emailAdd)) { $isValid = FALSE; $schedulerModule->addMessage($GLOBALS['LANG']->sL('LLL:EXT:linkvalidator/Resources/Private/Language/locallang.xlf:tasks.validate.invalidEmail'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR); } } } if ($res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'pages', 'uid = ' . (int) $submittedData['linkvalidator']['page'])) { if ($GLOBALS['TYPO3_DB']->sql_num_rows($res) == 0 && $submittedData['linkvalidator']['page'] > 0) { $isValid = FALSE; $schedulerModule->addMessage($GLOBALS['LANG']->sL('LLL:EXT:linkvalidator/Resources/Private/Language/locallang.xlf:tasks.validate.invalidPage'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR); } $GLOBALS['TYPO3_DB']->sql_free_result($res); } else { $isValid = FALSE; $schedulerModule->addMessage($GLOBALS['LANG']->sL('LLL:EXT:linkvalidator/Resources/Private/Language/locallang.xlf:tasks.validate.invalidPage'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR); } if ($submittedData['linkvalidator']['depth'] < 0) { $isValid = FALSE; $schedulerModule->addMessage($GLOBALS['LANG']->sL('LLL:EXT:linkvalidator/Resources/Private/Language/locallang.xlf:tasks.validate.invalidDepth'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR); } return $isValid; }
/** * 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 \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject Reference to the calling object (Scheduler's BE module) * @return boolean TRUE if validation was ok (or selected class is not relevant), FALSE otherwise */ public function validateAdditionalFields(array &$submittedData, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject) { $result = TRUE; $submittedData['pid'] = intval($submittedData['pid']); if ($submittedData['pid'] < 0) { $parentObject->addMessage($GLOBALS['LANG']->sL('LLL:EXT:moox_social/Resources/Private/Language/locallang_scheduler.xlf:tx_mooxsocial_tasks_facebookgettask.pid_error'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR); $result = FALSE; } if ($submittedData['clearCachePages'] != "") { $clearCachePages = explode(",", $submittedData['clearCachePages']); foreach ($clearCachePages as $clearCachePage) { if (!is_numeric($clearCachePage) || $clearCachePage == "") { $parentObject->addMessage($GLOBALS['LANG']->sL('LLL:EXT:moox_social/Resources/Private/Language/locallang_scheduler.xlf:tx_mooxsocial_tasks_facebookgettask.clear_cache_pages_error'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR); $result = FALSE; } } } if ($submittedData['appId'] == "") { $parentObject->addMessage($GLOBALS['LANG']->sL('LLL:EXT:moox_social/Resources/Private/Language/locallang_scheduler.xlf:tx_mooxsocial_tasks_facebookgettask.app_id_error'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR); $result = FALSE; } if ($submittedData['secret'] == "") { $parentObject->addMessage($GLOBALS['LANG']->sL('LLL:EXT:moox_social/Resources/Private/Language/locallang_scheduler.xlf:tx_mooxsocial_tasks_facebookgettask.secret_error'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR); $result = FALSE; } if ($submittedData['pageId'] == "") { $parentObject->addMessage($GLOBALS['LANG']->sL('LLL:EXT:moox_social/Resources/Private/Language/locallang_scheduler.xlf:tx_mooxsocial_tasks_facebookgettask.page_id_error'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR); $result = FALSE; } if ($submittedData['email'] != "" && !\TYPO3\CMS\Core\Utility\GeneralUtility::validEmail($submittedData['email'])) { $parentObject->addMessage($GLOBALS['LANG']->sL('LLL:EXT:moox_social/Resources/Private/Language/locallang_scheduler.xlf:tx_mooxsocial_tasks_facebookgettask.email_error'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR); $result = FALSE; } if ($result) { $config = array('appId' => $submittedData['appId'], 'secret' => $submittedData['secret'], 'pageid' => $submittedData['pageId'], 'allowSignedRequest' => false); $facebook = new \TYPO3\MooxSocial\Facebook\Facebook($config); $url = '/' . $submittedData['pageId'] . '/feed'; try { $rawFeed = $facebook->api($url); } catch (\TYPO3\MooxSocial\Facebook\FacebookApiException $e) { $parentObject->addMessage($GLOBALS['LANG']->sL('LLL:EXT:moox_social/Resources/Private/Language/locallang_scheduler.xlf:tx_mooxsocial_tasks_facebookgettask.api_error') . " [" . $e->getMessage() . "]", \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR); $result = FALSE; } } return $result; }
/** * Validates the additional fields' values * * @param array $submittedData * @param \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $schedulerModule * @return bool */ public function validateAdditionalFields(array &$submittedData, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $schedulerModule) { $isValid = FALSE; //!TODO add validation to validate the $submittedData['configuration'] wich is normally a comma seperated string if (is_array($submittedData['configuration'])) { $isValid = TRUE; } else { $schedulerModule->addMessage($GLOBALS['LANG']->sL('LLL:EXT:crawler/locallang_db.xml:crawler_im.invalidConfiguration'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR); } if ($submittedData['depth'] < 0) { $isValid = FALSE; $schedulerModule->addMessage($GLOBALS['LANG']->sL('LLL:EXT:crawler/locallang_db.xml:crawler_im.invalidDepth'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR); } if (!tx_crawler_api::canBeInterpretedAsInteger($submittedData['startPage']) || $submittedData['startPage'] < 0) { $isValid = FALSE; $schedulerModule->addMessage($GLOBALS['LANG']->sL('LLL:EXT:crawler/locallang_db.xml:crawler_im.invalidStartPage'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR); } return $isValid; }
/** * 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 \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject Reference to the calling object (Scheduler's BE module) * * @return bool True if validation was ok (or selected class is not relevant), false otherwise */ public function validateAdditionalFields(array &$submittedData, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject) { $draftUid = $submittedData['selecteddraft'] = intval($submittedData['selecteddraft']); if ($draftUid > 0) { $draftRecord = BackendUtility::getRecord('sys_dmail', $draftUid); if ($draftRecord['type'] == 2 || $draftRecord['type'] == 3) { $result = true; } else { // TODO: localization $parentObject->addMessage('No draft record selected', FlashMessage::ERROR); $result = false; } } else { // TODO: localization $parentObject->addMessage('No drafts found. Please add one first through the direct mail process', FlashMessage::ERROR); $result = false; } return $result; }
/** * Validates the additional fields' values * * @param array $submittedData * @param \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $schedulerModule * @return bool */ public function validateAdditionalFields(array &$submittedData, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $schedulerModule) { $isValid = FALSE; if (tx_crawler_api::convertToPositiveInteger($submittedData['sleepTime']) > 0) { $isValid = TRUE; } else { $schedulerModule->addMessage($GLOBALS['LANG']->sL('LLL:EXT:crawler/locallang_db.xml:crawler_im.invalidSleepTime'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR); } if (tx_crawler_api::convertToPositiveInteger($submittedData['sleepAfterFinish']) === 0) { $isValid = FALSE; $schedulerModule->addMessage($GLOBALS['LANG']->sL('LLL:EXT:crawler/locallang_db.xml:crawler_im.invalidSleepAfterFinish'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR); } if (tx_crawler_api::convertToPositiveInteger($submittedData['countInARun']) === 0) { $isValid = FALSE; $schedulerModule->addMessage($GLOBALS['LANG']->sL('LLL:EXT:crawler/locallang_db.xml:crawler_im.invalidCountInARun'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR); } return $isValid; }