|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Used to find contacts in data interval, which has been created to the newsletter but not added to the newsletter. |
|
4
|
|
|
* |
|
5
|
|
|
* @author Sune Jensen |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
die('used'); |
|
9
|
|
|
|
|
10
|
|
|
session_start(); |
|
11
|
|
|
|
|
12
|
|
|
define('INTRAFACE_K2', true); |
|
13
|
|
|
|
|
14
|
|
|
require '../public_html/config.local.php'; |
|
15
|
|
|
require_once '../public_html/common.php'; |
|
16
|
|
|
|
|
17
|
|
|
require_once 'Intraface/modules/contact/Contact.php'; |
|
18
|
|
|
require_once 'Intraface/modules/newsletter/NewsletterSubscriber.php'; |
|
19
|
|
|
require_once 'Intraface/modules/newsletter/NewsletterList.php'; |
|
20
|
|
|
|
|
21
|
|
|
$kernel = new Intraface_Kernel(); |
|
22
|
|
|
$kernel->intranet = new Intraface_Intranet(34); |
|
23
|
|
|
$kernel->setting = new Intraface_Setting(34); |
|
24
|
|
|
|
|
25
|
|
|
$list = new NewsletterList($kernel, 24); |
|
26
|
|
|
|
|
27
|
|
|
error_reporting(E_ALL); |
|
28
|
|
|
|
|
29
|
|
|
$db = $bucket->get('MDB2_Driver_Common'); |
|
30
|
|
|
|
|
31
|
|
|
$result = $db->query('SELECT contact.id, contact.number, contact.date_created, address.email, address.name |
|
32
|
|
|
FROM contact |
|
33
|
|
|
LEFT JOIN address ON contact.id = address.belong_to_id AND address.type = 3 AND address.active = 1 |
|
34
|
|
|
WHERE contact.active = 1 AND |
|
35
|
|
|
contact.intranet_id = 34 AND |
|
36
|
|
|
(DATE_FORMAT(date_created, "%Y-%m-%d") = "2010-05-03" OR DATE_FORMAT(date_created, "%Y-%m-%d") = "2010-05-05" OR DATE_FORMAT(date_created, "%Y-%m-%d") = "2010-05-06") |
|
37
|
|
|
AND address.email != "" AND address.address = "" |
|
38
|
|
|
'); |
|
39
|
|
|
$i = 0; |
|
40
|
|
|
|
|
41
|
|
|
if (PEAR::isError($result)) { |
|
42
|
|
|
die($result->toString()); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
while ($row = $result->fetchRow(MDB2_FETCHMODE_ASSOC)) { |
|
46
|
|
|
echo $row['number']. ', ' . $row['id']. ', ' . $row['date_created'] . ', '.$row['email']. ', '. $row['name']. ', '; |
|
47
|
|
|
|
|
48
|
|
|
$newsletter = $db->query('SELECT id FROM newsletter_subscriber WHERE contact_id = '. $row['id']); |
|
49
|
|
|
if ($newsletter->numRows() == 0) { |
|
50
|
|
|
$subscriber = new NewsletterSubscriber($list); |
|
51
|
|
|
$contact = new Contact($kernel, $row['id']); |
|
52
|
|
|
|
|
53
|
|
|
// $subscriber->addContact($contact); |
|
|
|
|
|
|
54
|
|
|
// echo 'Contact added to danish newsletter'; |
|
55
|
|
|
} else { |
|
56
|
|
|
echo 'Already in newsletter'; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
echo "\n"; |
|
60
|
|
|
$i++; |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
echo $i. " number of contacts"; |
|
64
|
|
|
|
|
65
|
|
|
?> |
|
|
|
|
|
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.