[TYPO3-english] Double Opt for direct Mail subscription

Bernhard Kraft kraftb at kraftb.at
Wed Oct 21 10:10:43 CEST 2009


Andreas Becker schrieb:
> Hi Bernhard
> exactly this it was I am looking for. An admin has to accept too.It would be
> nice if you can find the stuf. Sorry that my description wasn't clear enough
> at first.

Ok. Found it. You owe me a Non-Alcoholic-Or-Caffeinated-Drink (NONCD) of
your choice whenever I meet you! ;)

-------------------------------------------------------------------
# Double-Opt for direct-mail subscription
# (c) 2009 Bernhard Kraft <kraftb at think-open.at>
plugin.feadmin.dmailsubscription {
	# Set "hidden" to 3 on creation
  create.overrideValues.hidden = 3

	# Redefine the "setfixed.approve" setup
  setfixed.approve.hidden >
  setfixed.approve.hidden {
		# The magic formula is:
		#   intval(hidden/2)*2
		# Possible values in "hidden" field: 0, 1, 2, 3
		# 0: intval(0/2)*2 = intval(0)*2 = 0*2 = 0	0 => 0
		# 1: intval(1/2)*2 = intval(0.5)*2 = 0*2 = 0	1 => 0
		# 2: intval(2/2)*2 = intval(1)*2 = 1*2 = 2	2 => 2
		# 3: intval(3/2)*2 = intval(1.5)*2 = 1*2 = 2	3 => 2
		#
		# So: 0 or 1 will result in "0"
		#     2 or 3 will result in "2"
  	stdWrap = 1
  	stdWrap.stdWrap = 1
  	stdWrap.stdWrap.dataWrap = {field:hidden}/2
  	stdWrap.prioriCalc = intval
  	stdWrap.dataWrap = |*2
  	prioriCalc = intval
  }
  setfixed.approvevia.hidden	{
		# The other magic is:
		#   intval(hidden%2)
		# % == modulo = remainder of division
		# Possible values in "hidden field: 0, 1, 2, 3
		# 0: intval(0%2) = intval(0) = 0	0 => 0
		# 1: intval(1%2) = intval(1) = 1	1 => 1
		# 2: intval(2%2) = intval(0) = 0	2 => 0
		# 3: intval(3%2) = intval(1) = 1	3 => 1
  	stdWrap = 1
  	stdWrap.dataWrap = {field:hidden}%2
  	prioriCalc = intval
  }
  setfixed.approvevia._FIELDLIST=uid	
}
-------------------------------------------------------------------

Just add this TypoScript to your registration (of course you can remove
unnecesary comments)



So to also write some "proof of concept":

+++Fact I+++
Method "approve" can change the initial value (3) to (2).
Method "approvevia" can change the initial value (3) to (1).


+++Fact II+++
Each method, if called for more than one time, doesn't change the
already altered value:

After Method "approve" has been called once (2) it doesn't alter the
value any more and results in (2) again if called multiple times.

After Method "approvevia" has been called once (1) it doesn't alter the
value any more and results in (1) again if called multiple times.


+++Fact III+++
Each method, changes the value to (0) if the other method has been
called before.

After "approve" has been called (2) the second method "approvevia" will
change the value according to 2 => 0 which yields (0)

After "approvevia" has been called (1) the second method (approve) will
change the value according to 1 => 0 which yields (0)


... Ok. Even if you don't understand above facts. It works!
I do not know how I could proof this concept mathematically. Sad I did
not take university lessons ins logics, etc.


greets,
Bernhard












More information about the TYPO3-english mailing list