forked from tcdirectmail/tcdirectmail
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclass.tx_tcdirectmail_target.php
160 lines (143 loc) · 5.02 KB
/
class.tx_tcdirectmail_target.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
<?php
/***************************************************************
* Copyright notice
*
* (c) 2006-2008 Daniel Schledermann <[email protected]>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* This is the tx_directmail_target's super class.
* All directmail targets must inherit from this class though some inheritance path.
*
* @abstract
*/
abstract class tx_tcdirectmail_target {
var $fields;
var $data;
/**
* This is the object factory, without init(), for all directmail targets.
*
* @param integer Uid of a tx_directmail_target from the database.
* @return object Of directmail_target type.
*/
public static function getTarget($uid) {
global $TYPO3_DB;
$rs = $TYPO3_DB->sql_query("SELECT * FROM tx_tcdirectmail_targets WHERE uid = $uid");
$fields = $TYPO3_DB->sql_fetch_assoc($rs);
$object = t3lib_div::makeInstance($fields['targettype']);
if (is_subclass_of($object, 'tx_tcdirectmail_target')) {
$object->fields = $fields;
return $object;
} else {
die ("Ooops.. $fields[targettype] is not a tx_tcdirectmail_target child class");
}
}
/**
* This is the object factory, with init(), for all directmail targets.
*
* @param integer Uid of a tx_directmail_target from the database.
* @return object Of directmail_target type.
*/
public static function loadTarget ($uid) {
$object = tx_tcdirectmail_target::getTarget($uid);
$object->init();
return $object;
}
/**
* This is the method called when a directmail_target is produced in the loadTarget factory
*
* @return void
*/
public function init() {
// As default I do nothing
}
/**
* Fetch one receiver record from the directmail target.
* The record MUST contain an "email"-field. Without this one this mailtarget is useless.
* In order for registered links to work, it should also contain an "authCode"-field.
* To collect bounces you will need to have both fields "authCode" and "uid".
* For compatibility with various subscription systems, the record can contain "tableName"-field.
*
* @return array Assoc array with fields for the receiver
*/
public abstract function getRecord();
/**
* Reset the directmail target, so the next record being fetched will be the first.
* Not currently in use by any known extension
*
* @return void
*/
public abstract function resetTarget();
/**
* Get the number of receivers in this directmail target
*
* @return integer Numbers of receivers.
*/
public abstract function getCount();
/**
* Get error text if the fetching of the directmail target has somehow failed.
*
* @return string Error text or empty string.
*/
public abstract function getError();
/**
* Here you can implement start events for a real send-out.
*
* @return void
*/
public function startReal() {
}
/**
* Here you can implement end events for a real send-out.
*
* @return void
*/
public function endReal() {
}
/**
* Here you can define an action when an address bounces. This can either be database operations such a a deletion.
* For external data-sources, you might consider collecting the addresses for later removal from the foreign system.
* The tx_tcdirectmail_target_sql implements a sesible default. Bounces can only be expected to work if the record
* contains "uid" and "authCode" fields. "tableName" should also be included for compatibility reasons.
* It is not mandatory to do anything, but bounce handling cannot work without it.
*
* @param integer Uid of the address that has failed.
* @param integer Status of the bounce expect: TCDIRECTMAIL_HARDBOUNCE or TCDIRECTMAIL_SOFTBOUNCE
* @return bool Status of the success of the removal.
*/
public function disableReceiver($uid, $bounce_type) {
return false;
}
/**
* Here you can implement some action to take when ever the user has opened the mail via beenthere.php
*
* @param integer Uid of the user that has opened the mail
* @return void
*/
public function registerOpen ($uid) {
}
/**
* Here you can implement some action to take when ever the user has clicked a link via click.php
*
* @param integer Uid of the user that has clicked a link
* @return void
*/
public function registerClick ($uid) {
}
}