/** * Check if captcha is valid * * @return bool */ protected function validCaptcha() { $isValid = false; $wordRepository = ObjectUtility::getObjectManager()->get(WordRepository::class); $wordObject = $wordRepository->getWord(); $wordHash = $wordObject->getWordHash(); if (!empty($wordHash) && !empty($this->pluginVariables['captcha'])) { if ($wordObject->getHashFunction() == 'md5') { if (md5(strtolower(utf8_decode($this->pluginVariables['captcha']))) == $wordHash) { $wordRepository->cleanUpWord(); $isValid = true; } } } return $isValid; }
/** * Check: If there are no changes, simple redirect back * * @param User $user * @return void * @throws UnsupportedRequestTypeException */ protected function redirectIfDirtyObject(User $user) { if (!ObjectUtility::isDirtyObject($user)) { $this->addFlashMessage(LocalizationUtility::translate('noChanges'), '', FlashMessage::NOTICE); $this->redirect('edit'); } }
/** * Get changed properties (compare two objects with same getter methods) * * @param User $changedObject * @return array * [firstName][old] = Alex * [firstName][new] = Alexander */ public static function getDirtyPropertiesFromUser(User $changedObject) { $dirtyProperties = []; $ignoreProperties = ['txFemanagerChangerequest', 'ignoreDirty', 'isOnline', 'lastlogin']; foreach ($changedObject->_getCleanProperties() as $propertyName => $oldPropertyValue) { if (method_exists($changedObject, 'get' . ucfirst($propertyName)) && !in_array($propertyName, $ignoreProperties)) { $newPropertyValue = $changedObject->{'get' . ucfirst($propertyName)}(); if (!is_object($oldPropertyValue) || !is_object($newPropertyValue)) { if ($oldPropertyValue !== $newPropertyValue) { $dirtyProperties[$propertyName]['old'] = $oldPropertyValue; $dirtyProperties[$propertyName]['new'] = $newPropertyValue; } } else { if (get_class($oldPropertyValue) === 'DateTime') { /** @var $oldPropertyValue \DateTime */ /** @var $newPropertyValue \DateTime */ if ($oldPropertyValue->getTimestamp() !== $newPropertyValue->getTimestamp()) { $dirtyProperties[$propertyName]['old'] = $oldPropertyValue->getTimestamp(); $dirtyProperties[$propertyName]['new'] = $newPropertyValue->getTimestamp(); } } else { $titlesOld = ObjectUtility::implodeObjectStorageOnProperty($oldPropertyValue); $titlesNew = ObjectUtility::implodeObjectStorageOnProperty($newPropertyValue); if ($titlesOld !== $titlesNew) { $dirtyProperties[$propertyName]['old'] = $titlesOld; $dirtyProperties[$propertyName]['new'] = $titlesNew; } } } } } return $dirtyProperties; }