[TYPO3-UG Russia] [PATCH] более удобные дефолты поддержки sr_freecap для ve_guestbook

Michael Shigorin mike at osdn.org.ua
Fri Mar 16 22:15:03 CET 2007


	Здравствуйте.
Надоели две вещи: спам в комментариях и то, что автор
ve_guestbook сделал глобальный включальник: стоит sr_freecap
-- значит, пользуем, несмотря на виртхост, настройки и вообще
пользователь у нас авторизовался или прохожий.

Результат здесь и в аттаче:
http://old.linux.kiev.ua/~mike/works/typo3/patches/ve_guestbook-smarter-captcha.patch

Буду благодарен, если кто из умеющих flexforms заодно
и конфигурацию докрутит; хорошо бы в багтрекер тогда:
http://bugs.typo3.org/view.php?id=5241

-- 
 ---- WBR, Michael Shigorin <mike at altlinux.ru>
  ------ Linux.Kiev http://www.linux.kiev.ua/
-------------- next part --------------
diff -Naur ve_guestbook-1.12.1/pi1/class.tx_veguestbook_pi1.php ve_guestbook/pi1/class.tx_veguestbook_pi1.php
--- ve_guestbook-1.12.1/pi1/class.tx_veguestbook_pi1.php	2006-10-19 16:15:19 +0300
+++ ve_guestbook/pi1/class.tx_veguestbook_pi1.php	2007-03-16 22:53:48 +0200
@@ -157,10 +157,30 @@
 		$this->config['sortingField'] = $flex_sortingField ? $flex_sortingField : $this->conf['sortingField'];
 		$this->config['sortingDirection'] = $flex_sortingDirection ? $flex_sortingDirection : $this->conf['sortingDirection'];
 
-		if (t3lib_extMgm::isLoaded('sr_freecap') ) {
-
+		# more or less sane default behaviour for captcha
+		# it's de facto needed these days...
+		$try_captcha = true;
+		# but we might want to turn it off...
+		if ($this->config['captcha'] == 'off') {
+			$try_captcha = false;
+		} else {
+			# especially for authorized users...
+			if (!$this->postvars && $GLOBALS['TSFE']->loginUser) {
+				$try_captcha = false;
+			}
+		}
+		# but still explicit command should turn it on in face of any heuristics
+		if ($this->config['captcha'] == 'on') {
+			$try_captcha = true;
+		}
+		# force major: no extension installed ;-P
+		if ($try_captcha && t3lib_extMgm::isLoaded('sr_freecap') ) {
 			require_once(t3lib_extMgm::extPath('sr_freecap').'pi2/class.tx_srfreecap_pi2.php');
-
+		} else {
+			$try_captcha = false;
+		}
+		# finally...
+		if ($try_captcha) {
 			$this->freeCap = t3lib_div::makeInstance('tx_srfreecap_pi2');
 		}
 	}
@@ -1023,4 +1043,4 @@
 	include_once($TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/ve_guestbook/pi1/class.tx_veguestbook_pi1.php"]);
 }
 
-?>
\ No newline at end of file
+?>


More information about the TYPO3-russia mailing list